@@ -32,17 +32,26 @@ def test_generate_pset_dataset(
3232 hi_l1_test_data_path ,
3333 hi_test_cal_prod_config_path ,
3434 use_fake_spin_data_for_time ,
35+ use_fake_repoint_data_for_time ,
3536 imap_ena_sim_metakernel ,
3637):
3738 """Test coverage for generate_pset_dataset function"""
3839 use_fake_spin_data_for_time (482372987.999 )
3940 l1b_de_path = hi_l1_test_data_path / "imap_hi_l1b_45sensor-de_20250415_v999.cdf"
4041 l1b_dataset = load_cdf (l1b_de_path )
42+ l1b_met = l1b_dataset ["ccsds_met" ].values [0 ]
43+ # Set repoint start and end times.
44+ seconds_per_day = 24 * 60 * 60
45+ use_fake_repoint_data_for_time (
46+ np .asarray ([l1b_met - 15 * 60 , l1b_met + seconds_per_day ]),
47+ np .asarray ([l1b_met , l1b_met + seconds_per_day + 1 ]),
48+ )
4149 l1c_dataset = hi_l1c .generate_pset_dataset (
4250 l1b_dataset , hi_test_cal_prod_config_path
4351 )
4452
4553 assert l1c_dataset .epoch .data [0 ] == l1b_dataset .epoch .data [0 ].astype (np .int64 )
54+ assert l1c_dataset .epoch_delta .data [0 ] == seconds_per_day * 1e9
4655
4756 np .testing .assert_array_equal (l1c_dataset .despun_z .data .shape , (1 , 3 ))
4857 np .testing .assert_array_equal (l1c_dataset .hae_latitude .data .shape , (1 , 3600 ))
@@ -59,7 +68,7 @@ def test_generate_pset_dataset(
5968 write_cdf (l1c_dataset )
6069
6170
62- def test_empty_pset_dataset ():
71+ def test_empty_pset_dataset (use_fake_repoint_data_for_time ):
6372 """Test coverage for empty_pset_dataset function"""
6473 n_energy_steps = 8
6574 l1b_esa_energy_steps = xr .DataArray (
@@ -68,11 +77,17 @@ def test_empty_pset_dataset():
6877 )
6978 n_calibration_prods = 5
7079 sensor_str = HIAPID .H90_SCI_DE .sensor
80+ l1b_met = 482373065
81+ use_fake_repoint_data_for_time (
82+ np .asarray ([l1b_met - 15 * 60 , l1b_met + 24 * 60 * 60 ])
83+ )
84+
7185 dataset = hi_l1c .empty_pset_dataset (
72- 100 , l1b_esa_energy_steps , n_calibration_prods , sensor_str
86+ l1b_met , l1b_esa_energy_steps , n_calibration_prods , sensor_str
7387 )
7488
7589 assert dataset .epoch .size == 1
90+ assert dataset .epoch_delta .size == 1
7691 assert dataset .spin_angle_bin .size == 3600
7792 assert dataset .esa_energy_step .size == n_energy_steps
7893 np .testing .assert_array_equal (
@@ -127,7 +142,12 @@ def test_pset_geometry(mock_frame_transform, mock_geom_frame_transform, sensor_s
127142
128143
129144@pytest .mark .external_test_data
130- def test_pset_counts (hi_l1_test_data_path , hi_test_cal_prod_config_path ):
145+ @mock .patch ("imap_processing.hi.hi_l1c.get_pointing_times" , return_value = (100 , 200 ))
146+ def test_pset_counts (
147+ mock_pointing_times ,
148+ hi_l1_test_data_path ,
149+ hi_test_cal_prod_config_path ,
150+ ):
131151 """Test coverage for pset_counts function."""
132152 l1b_de_path = hi_l1_test_data_path / "imap_hi_l1b_45sensor-de_20250415_v999.cdf"
133153 l1b_dataset = load_cdf (l1b_de_path )
@@ -145,7 +165,12 @@ def test_pset_counts(hi_l1_test_data_path, hi_test_cal_prod_config_path):
145165
146166
147167@pytest .mark .external_test_data
148- def test_pset_counts_empty_l1b (hi_l1_test_data_path , hi_test_cal_prod_config_path ):
168+ @mock .patch ("imap_processing.hi.hi_l1c.get_pointing_times" , return_value = (100 , 200 ))
169+ def test_pset_counts_empty_l1b (
170+ mock_pointing_times ,
171+ hi_l1_test_data_path ,
172+ hi_test_cal_prod_config_path ,
173+ ):
149174 """Test coverage for pset_counts function when the input L1b contains no counts."""
150175 l1b_de_path = hi_l1_test_data_path / "imap_hi_l1b_45sensor-de_20250415_v999.cdf"
151176 l1b_dataset = load_cdf (l1b_de_path )
@@ -254,6 +279,7 @@ def test_pset_backgrounds():
254279 )
255280
256281
282+ @mock .patch ("imap_processing.hi.hi_l1c.get_pointing_times" , return_value = (100 , 200 ))
257283@mock .patch ("imap_processing.hi.hi_l1c.get_spin_data" , return_value = None )
258284@mock .patch ("imap_processing.hi.hi_l1c.get_instrument_spin_phase" )
259285@mock .patch ("imap_processing.hi.hi_l1c.get_de_clock_ticks_for_esa_step" )
@@ -263,6 +289,7 @@ def test_pset_exposure(
263289 mock_de_clock_ticks ,
264290 mock_spin_phase ,
265291 mock_spin_data ,
292+ mock_pointing_times ,
266293):
267294 """Test coverage for pset_exposure function"""
268295 l1b_energy_steps = xr .DataArray (
0 commit comments