New ELUT correction and propagation of live time uncertainty#244
New ELUT correction and propagation of live time uncertainty#244paolomassa wants to merge 13 commits into
Conversation
…files and propagation of livetime uncertainty.
New calibration files are now used for spectroscopy (only for CPD files, not for spectrograms for now)
ennosigaeus
left a comment
There was a problem hiding this comment.
A few observations on the new calibration file search logic and the ELUT correction flow — mostly clarifications and one question about intent. Nice work on the overall restructuring.
ennosigaeus
left a comment
There was a problem hiding this comment.
Two more observations — one on code duplication and one on an edge case in the spectral index calculation.
| aux_fits_file = aux_fits_file, flare_location_hpc = flare_location_hpc, flare_location_stx = flare_location_stx, $ | ||
| eff_ewidth = eff_ewidth, sys_uncert = sys_uncert, plot = plot, background_data = background_data, silent = silent, $ | ||
| elut_correction = elut_correction, fits_info_params = fits_info_params, xspec=xspec, ospex_obj = ospex_obj | ||
| ;;***************** CREATE SRM |
There was a problem hiding this comment.
Observation (SRM/OSPEX duplication): The SRM construction and OSPEX integration (lines 552–700, ~150 lines) is now inlined here. The old stx_convert_science_data2ospex.pro still exists and was not modified in this PR.
This means there are now two copies of the SRM/OSPEX logic — the new inline version (with the updated ELUT correction, grid transmission, and livetime propagation) and the old standalone function. Fixes to one won't propagate to the other.
Not blocking, but worth discussing: should stx_convert_science_data2ospex be deprecated, or should the shared logic be extracted so both paths call the same code?
There was a problem hiding this comment.
This is addressed in 1a24f45. The function stx_convert_science_data2ospex looks deprecated now, should we remove it?
|
|
||
| for i=0,idx_peak-1 do begin | ||
| this_x=alog(e_mean(i+1))-alog(e_mean(i)) | ||
| this_y=alog(spectrum(i+1))-alog(spectrum(i)) |
There was a problem hiding this comment.
Edge case (zero or negative spectrum values): If any spectrum bin is zero or negative after background subtraction, alog(spectrum(i)) produces -Inf or NaN. The cleanup at lines 107–108 (where(~finite(...))) catches bad values in the final index_final array, but the intermediate e_weighted values (computed from index_tmp in the first pass, lines 64–66) could already contain NaN. Since e_weighted feeds the second-pass recalculation (lines 87–101), NaN can propagate to adjacent good bins via alog(e_weighted(i-1)).
The flat-spectrum case (all equal values) is fine — produces all-zero indices as expected. The concern is specifically about bins with zero or negative counts.
- Remove committed .DS_Store and add it to .gitignore - Fix date typos: "April 22026" → "April 2026", "Fubruary" → "February" - Add missing trailing newlines to five new files
fa1a4a4 to
58ed4ab
Compare
The procedure 'stx_convert_spectrogram' now utilizes the new transmission calibration for the SRM calculation.
The code has been refactored so that 'stx_convert_pixel_data' and 'stx_convert_spectrogram' utilize the same function ('stx_convert_spectrogram2ospex') to avoid code replication.
Finally, 'stx_convert_spectrogram2ospex' prints a warning if the fine-resolution sub-collimators are considered, as the high-energy calibration is not completed yet.
Code reviewFound 2 issues:
STIX-GSW/stix/idl/processing/spectrogram/stx_convert_pixel_data.pro Lines 386 to 410 in edd1eb8
STIX-GSW/stix/idl/processing/spectrogram/stx_estimate_spectral_index.pro Lines 57 to 102 in edd1eb8 Also: your 2026-05-08 question — "The function `stx_convert_science_data2ospex` looks deprecated now, should we remove it?" — is still open. The new `stx_convert_spectrogram2ospex` supersedes it; happy to drop the old one in this PR if you prefer. (Reviewed at `edd1eb8`. The earlier suspicions about the `corr_low` formula in `stx_elut_correction.pro` and the BKG-subtraction order in `stx_convert_spectrogram.pro` turned out to be consistent with the documented intent on closer inspection.) [Generated with Claude Code] - If this code review was useful, please react with thumbs-up. Otherwise, react with thumbs-down. |
We implemented a new ELUT correction which
Correction has been implemented for imaging and for spectroscopy. However, in the case of spectroscopy it works only for CPD files and not for spectrograms (ELUT correction for spectrograms is meaningless).
We also added code for propagating live time uncertainty.
Finally, we use a calibrated version of the BKG detector transmission in
stx_convert_pixel_data. This calibrated transmission has been provided by @MurielStiefel.TODO list:
stx_convert_spectrogramas it is or modify it in a way similar to what done forstx_convert_pixel_data?