1818# ctapipe modules 
1919from  ctapipe .visualization  import  CameraDisplay 
2020from  iminuit  import  Minuit 
21- from  jacobi  import  propagate 
2221from  matplotlib  import  pyplot  as  plt 
2322from  matplotlib .backends .backend_pdf  import  PdfPages 
23+ from  scipy .optimize ._numdiff  import  approx_derivative 
2424
2525from  nectarchain .data .container  import  GainContainer 
2626
@@ -367,6 +367,22 @@ def model(params):
367367    )
368368
369369
370+ def  propagate_scipy_compatible (model , params , cov ):
371+     """ 
372+     Computes output covariance via numerical Jacobian propagation. 
373+     """ 
374+     params  =  np .asarray (params )
375+     cov  =  np .asarray (cov )
376+ 
377+     y  =  model (params )
378+     J  =  approx_derivative (model , params , method = "2-point" )
379+ 
380+     # Covariance propagation 
381+     ycov  =  J  @ cov  @ J .T 
382+ 
383+     return  y , ycov 
384+ 
385+ 
370386def  error_propagation_compute (data , minuit_resulting , plot = True , rebin = True ):
371387    """Compute both parameter uncertainties and per-pixel uncertainties of the model.""" 
372388
@@ -388,10 +404,10 @@ def error_propagation_compute(data, minuit_resulting, plot=True, rebin=True):
388404        )
389405
390406    # --- Propagate errors through the model 
391-     y , ycov  =  propagate (
407+     y , ycov  =  propagate_scipy_compatible (
392408        lambda  p : model (p ), minuit_resulting .values , minuit_resulting .covariance 
393-     )   # changed 
394-     yerr_prop  =  np .sqrt (np .diag (ycov ))   # per-pixel uncertainty 
409+     )
410+     yerr_prop  =  np .sqrt (np .diag (ycov ))
395411
396412    # --- Optionally rebin by θ 
397413    if  rebin :
0 commit comments