i4Ds / STIXCore

STIX Core functionalities
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

Slight discrepancies in energy edges #359

Closed grazwegian closed 9 months ago

grazwegian commented 12 months ago

For the current fine thermal energy scheme the science energy channels are not at integer values. The numbers recorded in the FITS files are slightly different than expected e.g. the 6.56 keV edge is stored as 6.558594, while this is a very small discrepancy 0.02% it is higher than expected.

Additionally these get magnified when taking the difference to calculate the bin width resulting in a ~1% discrepancy between the nominal value of 0.24 and the estimated value from the stored edges (0.242..).

fine_energy_edges
samaloney commented 9 months ago

Ok yea I see the problem I was trying to be clever and save some space so used a float16 but I think fits only support float32 and float64 and when you cast 5.45 from 16 to 32 you get 5.4492188 and vice versa. Have change to use float32 and that seems to have solved the issue.

spec = fits.open('solo_L0_stix-sci-xray-spec_0502044066-0502044220_V01_0000000401-50034.fits')

In [19]: spec[4].data['e_low']
Out[19]:
array([  0.  ,   4.  ,   4.45,   4.95,   5.45,   5.95,   6.45,   6.95,
         7.35,   7.75,   8.25,   8.75,   9.25,  10.  ,  10.5 ,  11.  ,
        12.  ,  13.  ,  15.  ,  18.  ,  21.  ,  25.  ,  28.  ,  32.  ,
        36.  ,  43.  ,  50.  ,  59.  ,  70.  ,  84.  , 110.  , 150.  ],
      dtype='>f4')

In [20]: spec[4].data['e_high']
Out[20]:
array([  4.  ,   4.45,   4.95,   5.45,   5.95,   6.45,   6.95,   7.35,
         7.75,   8.25,   8.75,   9.25,  10.  ,  10.5 ,  11.  ,  12.  ,
        13.  ,  15.  ,  18.  ,  21.  ,  25.  ,  28.  ,  32.  ,  36.  ,
        43.  ,  50.  ,  59.  ,  70.  ,  84.  , 110.  , 150.  ,    nan],
      dtype='>f4')

Note this isn't real data just AX data I had handy to test solo_L0_stix-sci-xray-spec_0502044066-0502044220_V01_0000000401-50034.fits.zip