-
Notifications
You must be signed in to change notification settings - Fork 29
Fix GLOWS L2 - add per-bin zero handling for flux calculations #2890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -175,6 +175,29 @@ def test_zero_exposure_bins(l1b_dataset, mock_ecliptic_bin_centers): | |||||||||||||||||||||||||||||||||||||||||||||||||||
| assert np.allclose(lc.exposure_times, expected_exposure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def test_zero_exposure_values(l1b_dataset, mock_ecliptic_bin_centers): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Zero exposure yields zero flux and zero uncertainty per bin.""" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Note: all bins have the same exposure time, so if one is zero all are zero. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Update values used to calculate exposure times to | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ensure a zero exposure result. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| l1b_dataset["spin_period_average"].data[:] = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| l1b_dataset["number_of_spins_per_block"].data[:] = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| with np.errstate(divide="raise", invalid="raise"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| lc = DailyLightcurve(l1b_dataset, position_angle=0.0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| expected = np.zeros(l1b_dataset.sizes["bins"], dtype=float) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert lc.exposure_times.shape == expected.shape | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert len(np.unique(lc.exposure_times)) == 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert np.array_equal(lc.exposure_times, expected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert np.array_equal(lc.photon_flux, expected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert np.array_equal(lc.flux_uncertainties, expected) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert np.all(np.isfinite(lc.photon_flux)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert np.all(np.isfinite(lc.flux_uncertainties)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| @pytest.mark.xfail( | |
| reason=( | |
| "Per-bin zero exposure handling not yet implemented. " | |
| "Once supported, construct a dataset with mixed exposure values " | |
| "(some bins zero, others non-zero) and assert that only the " | |
| "zero-exposure bins have zero flux/uncertainty with no divide-by-zero." | |
| ) | |
| ) | |
| def test_mixed_zero_exposure_values(l1b_dataset, mock_ecliptic_bin_centers): | |
| """Placeholder for mixed per-bin exposure test. | |
| This test should be updated once the pipeline supports per-bin zero | |
| exposure handling. The intended behavior is: | |
| * Bins with zero exposure time produce zero photon_flux and | |
| flux_uncertainties. | |
| * Bins with non-zero exposure time retain finite, non-NaN values. | |
| * No divide-by-zero or invalid floating-point operations occur even when | |
| using np.errstate(divide="raise", invalid="raise"). | |
| """ | |
| pytest.xfail( | |
| "TODO: implement mixed per-bin exposure test when exposure can vary by bin." | |
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All bins have the same exposure time so if one is zero all will be zero
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxinelasp What should happen if these conditions aren't met. Should an error be raised or should processing proceed?