Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/304.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow loading of RHESSI fits files with `SUMFLAG=0` which only contain data from one detector.
8 changes: 3 additions & 5 deletions sunkit_spex/extern/rhessi.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,9 @@ def load_spectrum(spec_fn: str):
"""
with fits.open(spec_fn) as spec:
rate_dat = spec["RATE"]
if rate_dat.header["SUMFLAG"] != 1:
raise ValueError("Cannot perform spectroscopy on un-summed RHESSI data.")
num_dets_used = str(rate_dat.header["DETUSED"]).count("|") + 1
if (rate_dat.header["SUMFLAG"] != 1) and (num_dets_used > 1):
raise ValueError("Cannot load RHESSI FITS files with >1 detector per file")

# Note that for rate, the units are per detector, i.e. counts sec-1 detector-1.
# https://hesperia.gsfc.nasa.gov/rhessi3/software/spectroscopy/spectrum-software/index.html
Expand Down Expand Up @@ -807,9 +808,6 @@ def load_srm(srm_file: str):
# handle attenuated responses and `None` simultaneously
all_srms = srm_options_by_attenuator_state(srm_file_dat)

if not all(h["header"]["SUMFLAG"] for h in all_srms.values()):
raise ValueError("SRM SUMFLAG's must be 1 for RHESSI spectroscopy")

sample_key = list(all_srms.keys())[0]
sample_srm = all_srms[sample_key]["data"]
low_photon_bins = sample_srm["ENERG_LO"]
Expand Down
Loading