Closed paolomassa closed 11 months ago
I have tested the changes I made and they seems to be correct. Also Säm tried out the code and approved the changes.
Yes, an array of 32 (energies) x 12 (pixels) x 32 (detectors) x number of time bins is always generated by stx_read_pixel_data_fits_file and then populated with the data in the file see: https://github.com/i4Ds/STIX-GSW/blob/d87eb573ad40ca6b7354df1c0733b0a12080d3d2/stix/idl/io/stx_read_pixel_data_fits_file.pro#L167C9-L167C9
The ELUT files contain the 31 edges to describe the 30 normal science energy channels. The telemetry additionally contains edges at ADC values of 0 and 4095 to define the lower and upper level discriminator bins to bring the total to 32. It is unlikely although possible that this could be changed in the future (e.g. if we wanted to use all 32 bins in the science range) in that case there would need to be changes to the software in many places.
It would probably be good to discuss the expectations around stx_read_pixel_data_fits_file at the software meeting in Poland.
- The implementation also assumes that both the science and the background fits files contain more that one energy bin (i.e., that the energy_bin_mask contains more than one entry equal to one).
I think it's possible to have only one entry in the energy_bin_edge_mask
e.g `0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
is 4-5 keV
I think the code crashes if only one energy bin is present. Do you want me to modify it so that it handles also that case?
There was a potential mismatch between the input energy range and the indices of the energy axis that were selected in the pixel data matrix. The problem raised when e_axis.LOW started from 0 keV (where e_axis is the energy axis structure returned by
stx_read_pixel_data_fits_file
). Indeed, in that case, the indices corresponding to the input energy interval were selected assuming that the first energy bin was 0-4 keV, while the first energy interval of the pixel data matrix (stored in thecounts
variable) was systematically discarded before selecting the energy bins. As a consequence, it could happen that the input energy interval was 5-8 keV, but the energy interval that was actually selected by the code was 7-9 keV.A similar mismatch could also happen when the indices of the ELUT were selected. In that case, the energy correction factors of the first and the last energy interval (which should be between ~0.95 and ~1.05) could take values close to 2 or close to 0 (or even negative!).
I solved this issue in the following way:
energy_bin_mask
among the fields contained in thedata
structure returned bystx_read_pixel_data_fits_file
. In this way, we have information on which energy bins are contained in the science (or background) fits fileenergy_bin_mask
to select the energy bins ofdata.COUNTS
(wheredata
is the structure returned bystx_read_pixel_data_fits_file
) that actually contains measurements. Therefore, I assume thatdata.COUNTS
always contains 32 energy bins and that the energy bins that do not contain actual measurements are filled with zeros. @grazwegian, is this assumption correct?ekev_actual
is 31 (@grazwegian, this valid for every ELUT, right?). Therefore, when I create the matrices containing the low and the high energy edges, I create them so that they contain 32 energy bins by setting the low edge of the first energy bin equal to zero and the high edge of the last energy bin equal to NaN.energy_bin_mask
contains more than one entry equal to one).