Skip to content

Flux uncertainties from the integrate function

When using the integrate function I obtain error estimates that are orders of magnitudes off from the expected values and I find no way to solve this. I checked that other MPDAF functions (most notably the plot with noise=True or snr=True) are working fine with my spectrum and variance.

I might be doing something wrong, but following the logic of propagation of uncertainties it seems to me that the following line computing the variance of the integral:

err_flux = (self.var[i1:i2] * np.diff(d**2)).sum() 

should instead be

err_flux = (self.var[i1:i2] * (np.diff(d))**2).sum() 

i.e. you need to sum the square of the pixel size in wavelength multiplied by the variance per pixel, instead of summing the "size" of the pixel in "wavelength**2" multiplied by the variance per pixel.

so the actual flux measurement and its uncertainty to be returned with out_unit units should be

flux, np.sqrt(err_flux)

In this way I get reasonable error estimates.

I did everything "by hand" and printed d, np.diff(d), (np.diff(d))2 and np.diff(d2), and it really seems the right quantity to be used is (np.diff(d))**2.

I hope I'm not creating confusion, but please try with a real spectrum and let me know.

Many thanks in advance for your help!

Edited by Simon Conseil