Skip to content

Commit 7c19097

Browse files
committed
Address PR comments - add check that all exposure times are the same value
1 parent c438107 commit 7c19097

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

imap_processing/glows/l2/glows_l2_data.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ def __post_init__(self, l1b_data: xr.Dataset, position_angle: float) -> None:
106106
self.photon_flux = np.zeros(self.number_of_bins)
107107
self.flux_uncertainties = np.zeros(self.number_of_bins)
108108

109-
if len(self.exposure_times) != 0 and self.exposure_times[0] > 0:
109+
if (
110+
len(self.exposure_times) != 0
111+
and self.exposure_times[0] > 0
112+
and len(np.unique(self.exposure_times)) == 1
113+
):
110114
self.photon_flux = self.raw_histograms / self.exposure_times
111115
self.flux_uncertainties = raw_uncertainties / self.exposure_times
112116

imap_processing/tests/glows/test_glows_l2_data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,9 @@ def test_zero_exposure_bins(l1b_dataset, mock_ecliptic_bin_centers):
176176

177177

178178
def test_zero_exposure_values(l1b_dataset, mock_ecliptic_bin_centers):
179-
"""Zero exposure yields zero flux and zero uncertainty per bin.
179+
"""Zero exposure yields zero flux and zero uncertainty per bin."""
180180

181-
Note: all bins have the same exposure time, so if one is zero all are zero.
182-
"""
181+
# Note: all bins have the same exposure time, so if one is zero all are zero.
183182

184183
# Update values used to calculate exposure times to
185184
# ensure a zero exposure result.
@@ -191,6 +190,7 @@ def test_zero_exposure_values(l1b_dataset, mock_ecliptic_bin_centers):
191190

192191
expected = np.zeros(l1b_dataset.sizes["bins"], dtype=float)
193192
assert lc.exposure_times.shape == expected.shape
193+
assert len(np.unique(lc.exposure_times)) == 1
194194
assert np.array_equal(lc.exposure_times, expected)
195195
assert np.array_equal(lc.photon_flux, expected)
196196
assert np.array_equal(lc.flux_uncertainties, expected)

0 commit comments

Comments
 (0)