-
Notifications
You must be signed in to change notification settings - Fork 22
ULTRA L1C HELIO index maps #2492
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
Merged
lacoak21
merged 32 commits into
IMAP-Science-Operations-Center:dev
from
lacoak21:ultra_l1c_helio_index_maps
Dec 17, 2025
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
233d4e4
helio map func
lacoak21 763be69
refactor slightly
lacoak21 a0e2303
validation test
lacoak21 bafdaef
fix tests and pr comments
lacoak21 50e7a7a
explicitely download validation files for test
lacoak21 92399c5
updated fucntions to handle energy dependent fov and theta and phi lo…
lacoak21 4a74794
remove test for helio adjusted data
lacoak21 43f1348
more test updates
lacoak21 9319e20
fix inside fov function.
lacoak21 794976a
constants for helio maps and inside fov
lacoak21 778d041
update pset code and eff, gf functions to handle energy dependent ind…
lacoak21 f702d8f
Helio pset validation test and fix other tests
lacoak21 b9777bc
rename module
lacoak21 4c46340
remove kernel hcanges to conftest
lacoak21 c20809e
fix test
lacoak21 0a74e94
full healpy import"
lacoak21 52b992b
PR comments. Remove hardcoded constants and offsets.
lacoak21 d756571
more PR comments addressed
lacoak21 12882ae
corrected wrong kernel
lacoak21 c30154f
fix kernel issue
lacoak21 af7c2ae
add sim kernel folder to project include list
lacoak21 90935e3
add test for coverage
lacoak21 3f18d45
address pr comments
lacoak21 16860ba
add helio pset test to codecov
lacoak21 7425181
move constants into class
lacoak21 87fc647
fix test coverage
lacoak21 379de25
typo
lacoak21 f79ffa1
test for coverage check
lacoak21 653eae0
test for coverage
lacoak21 903e2a6
typos
lacoak21 6219650
fix test
lacoak21 5b08b1e
codecov
lacoak21 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| from unittest import mock | ||
|
|
||
| import numpy as np | ||
| import pandas as pd | ||
| import pytest | ||
| import xarray as xr | ||
|
|
||
| from imap_processing import imap_module_directory | ||
| from imap_processing.cdf.utils import load_cdf | ||
| from imap_processing.tests.conftest import _download_external_data | ||
| from imap_processing.ultra.constants import UltraConstants | ||
| from imap_processing.ultra.l1c.helio_pset import calculate_helio_pset | ||
|
|
||
| TEST_PATH = imap_module_directory / "tests" / "ultra" / "data" / "l1" | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="Long running test for validation purposes.") | ||
| def test_validate_exposure_time_and_sensitivities( | ||
| ancillary_files, deadtime_datasets, imap_ena_sim_metakernel | ||
| ): | ||
| """Validates exposure time and sensitivities for ebin 0.""" | ||
| sens_filename = "SENS-IMAP_ULTRA_90-IMAP_DPS-HELIO-nside32-ebin0.csv" | ||
| exposure_filename = "Exposures-IMAP_ULTRA_90-IMAP_DPS-HELIO-nside32-ebin0.csv" | ||
| de_filename = "imap_ultra_l1b_90sensor-de_20000101-repoint00000_v000.cdf" | ||
| test_data = [ | ||
| (sens_filename, "ultra/data/l1/"), | ||
| (exposure_filename, "ultra/data/l1/"), | ||
| (de_filename, "ultra/data/l1/"), | ||
| ] | ||
| _download_external_data(test_data) | ||
| l1b_de = TEST_PATH / de_filename | ||
| l1b_de = load_cdf(l1b_de) | ||
| sensitivities_ebin_0 = pd.read_csv(TEST_PATH / sens_filename) | ||
| exposure_factor_ebin_0 = pd.read_csv(TEST_PATH / exposure_filename) | ||
|
|
||
| test_deadtimes = ( | ||
| pd.read_csv(TEST_PATH / "test_p0_ebin0_deadtimes.csv", header=None) | ||
| .to_numpy() | ||
| .squeeze() | ||
| ) | ||
| npix = 12288 # nside 32 | ||
| # Create a minimal dataset to pass to the function | ||
| dataset = xr.Dataset( | ||
| { | ||
| "spin_number": (["epoch"], np.array([1, 2, 3])), | ||
| } | ||
| ) | ||
| dataset.attrs["Repointing"] = "repoint00000" | ||
|
|
||
| pointing_range_met = (472374890.0, 582378000.0) | ||
| # Create mock spin data that has 5525 nominal spins | ||
| # Create DataFrame | ||
| nspins = 5522 | ||
| nominal_spin_seconds = 15.0 | ||
| spin_data = pd.DataFrame( | ||
| { | ||
| "spin_start_met": np.linspace( | ||
| pointing_range_met[0], pointing_range_met[1], nspins | ||
| ), | ||
| "spin_period_sec": np.full(nspins, nominal_spin_seconds), | ||
| "spin_phase_valid": np.ones(nspins), | ||
| "spin_period_valid": np.ones(nspins), | ||
| } | ||
| ) | ||
| with ( | ||
| # Mock the pointing times | ||
| mock.patch( | ||
| "imap_processing.ultra.l1c.helio_pset.get_pointing_times_from_id", | ||
| return_value=pointing_range_met, | ||
| ), | ||
| mock.patch( | ||
| "imap_processing.ultra.l1c.ultra_l1c_pset_bins.ttj2000ns_to_met", | ||
| side_effect=lambda x: x, | ||
| ), | ||
| # Mock deadtimes to be all ones | ||
| mock.patch( | ||
| "imap_processing.ultra.l1c.ultra_l1c_pset_bins." | ||
| "get_deadtime_ratios_by_spin_phase", | ||
| return_value=xr.DataArray(test_deadtimes, dims="spin_phase_step"), | ||
| ), | ||
| # Mock spin data to match nominal spins in a pointing period | ||
| mock.patch( | ||
| "imap_processing.ultra.l1c.ultra_l1c_pset_bins.get_spin_data", | ||
| return_value=spin_data, | ||
| ), | ||
| # Mock background rates to be constant 0.1 | ||
| mock.patch( | ||
| "imap_processing.ultra.l1c.helio_pset.get_spacecraft_background_rates", | ||
| return_value=np.ones((46, npix)), | ||
| ), | ||
| # Mock culling mask (no culling) | ||
| mock.patch("imap_processing.ultra.l1c.helio_pset.compute_culling_mask"), | ||
| ): | ||
| pset = calculate_helio_pset( | ||
| l1b_de, | ||
| dataset, | ||
| deadtime_datasets["rates"], | ||
| deadtime_datasets["params"], | ||
| "imap_ultra_l1c_90sensor-heliopset", | ||
| ancillary_files, | ||
| 90, | ||
| UltraConstants.TOFXPH_SPECIES_GROUPS["proton"], | ||
| ) | ||
|
|
||
| # Validate exposure times for ebin 0 | ||
| exposure_times = pset["exposure_factor"][0, 0, :].values | ||
| expected_exposure_times = exposure_factor_ebin_0["P0"].to_numpy() | ||
| np.testing.assert_allclose( | ||
| exposure_times, | ||
| expected_exposure_times, | ||
| atol=95, # TODO This is due to the helio index map differences | ||
| err_msg="Exposure times do not match expected values for ebin 0.", | ||
| ) | ||
| # Validate sensitivities for ebin 0 | ||
| sensitivity = pset["sensitivity"][0, :].values | ||
| expected_sensitivity = sensitivities_ebin_0["Sensitivity (cm2)"].to_numpy() | ||
| np.testing.assert_allclose( | ||
| sensitivity, | ||
| expected_sensitivity, | ||
| atol=0.0006, # TODO This is due to the helio index map differences | ||
| err_msg="Sensitivities times do not match expected values for ebin 0.", | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.