-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:IMAP-Science-Operations-Center/imap_…
…processing into codice-lo-sw-angular-validation
- Loading branch information
Showing
10 changed files
with
87 additions
and
82 deletions.
There are no files selected for viewing
This file contains 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 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 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
Binary file added
BIN
+38.4 KB
imap_processing/tests/hi/test_data/l1/imap_hi_l1a_45sensor-de_20250415_v999.cdf
Binary file not shown.
Binary file added
BIN
+75.1 KB
imap_processing/tests/hi/test_data/l1/imap_hi_l1b_45sensor-de_20250415_v999.cdf
Binary file not shown.
Binary file removed
BIN
-876 KB
imap_processing/tests/hi/test_data/l1a/imap_hi_l1a_45sensor-de_20250415_v000.cdf
Binary file not shown.
This file contains 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 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 |
---|---|---|
@@ -1,56 +1,46 @@ | ||
"""Test coverage for imap_processing.hi.l1c.hi_l1c.py""" | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
from imap_processing.cdf.utils import write_cdf | ||
from imap_processing.hi.l1a.hi_l1a import hi_l1a | ||
from imap_processing.hi.l1b.hi_l1b import hi_l1b | ||
from imap_processing.cdf.utils import load_cdf, write_cdf | ||
from imap_processing.hi.l1c import hi_l1c | ||
from imap_processing.hi.utils import HIAPID | ||
|
||
|
||
@pytest.mark.skip( | ||
reason="See TODO in test comments. Need to convert this test" | ||
"to use a test L1B file rather than running L1B on fake" | ||
"data." | ||
) | ||
def test_generate_pset_dataset(create_de_data): | ||
def test_generate_pset_dataset(hi_l1_test_data_path): | ||
"""Test coverage for generate_pset_dataset function""" | ||
# TODO: once things are more stable, check in an L1B DE file as test data? | ||
# For now, test using false de data run through l1a and l1b processing | ||
bin_data_path = create_de_data(HIAPID.H45_SCI_DE.value) | ||
processed_data = hi_l1a(bin_data_path, "002") | ||
l1b_dataset = hi_l1b(processed_data[0], "002") | ||
|
||
l1b_de_path = hi_l1_test_data_path / "imap_hi_l1b_45sensor-de_20250415_v999.cdf" | ||
l1b_dataset = load_cdf(l1b_de_path) | ||
l1c_dataset = hi_l1c.generate_pset_dataset(l1b_dataset) | ||
|
||
assert l1c_dataset.epoch.data[0] == l1b_dataset.epoch.data[0] | ||
assert l1c_dataset.epoch.data[0] == np.mean(l1b_dataset.epoch.data[[0, -1]]).astype( | ||
np.int64 | ||
) | ||
|
||
np.testing.assert_array_equal(l1c_dataset.despun_z.data.shape, (1, 3)) | ||
np.testing.assert_array_equal(l1c_dataset.hae_latitude.data.shape, (1, 3600)) | ||
np.testing.assert_array_equal(l1c_dataset.hae_longitude.data.shape, (1, 3600)) | ||
for var in [ | ||
"counts", | ||
"exposure_times", | ||
"background_rates", | ||
"background_rates_uncertainty", | ||
]: | ||
np.testing.assert_array_equal(l1c_dataset[var].data.shape, (1, 9, 5, 3600)) | ||
|
||
# Test ISTP compliance by writing CDF | ||
l1c_dataset.attrs["Data_version"] = 1 | ||
write_cdf(l1c_dataset) | ||
|
||
def test_allocate_pset_dataset(): | ||
"""Test coverage for allocate_pset_dataset function""" | ||
n_esa_steps = 10 | ||
|
||
def test_empty_pset_dataset(): | ||
"""Test coverage for empty_pset_dataset function""" | ||
n_esa_steps = 9 | ||
n_calibration_prods = 5 | ||
sensor_str = HIAPID.H90_SCI_DE.sensor | ||
dataset = hi_l1c.allocate_pset_dataset(n_esa_steps, sensor_str) | ||
dataset = hi_l1c.empty_pset_dataset(n_esa_steps, sensor_str) | ||
|
||
assert dataset.epoch.size == 1 | ||
assert dataset.spin_angle_bin.size == 3600 | ||
assert dataset.esa_energy_step.size == n_esa_steps | ||
assert dataset.calibration_prod.size == n_calibration_prods | ||
np.testing.assert_array_equal(dataset.despun_z.data.shape, (1, 3)) | ||
np.testing.assert_array_equal(dataset.hae_latitude.data.shape, (1, 3600)) | ||
np.testing.assert_array_equal(dataset.hae_longitude.data.shape, (1, 3600)) | ||
for var in [ | ||
"counts", | ||
"exposure_times", | ||
"background_rates", | ||
"background_rates_uncertainty", | ||
]: | ||
np.testing.assert_array_equal( | ||
dataset[var].data.shape, (1, n_esa_steps, n_calibration_prods, 3600) | ||
) | ||
# Verify resulting CDF is ISTP compliant by writing to disk | ||
dataset.attrs["Data_version"] = 1 | ||
write_cdf(dataset) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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