Skip to content

Commit 19382dd

Browse files
Harrison #56 - PMCL - GLOWS L3e: Track Lo L1b NHK files as parents of Lo survival probability
We use these files to determine the Lo pivot angle for each repointing
1 parent 479bd91 commit 19382dd

4 files changed

Lines changed: 30 additions & 18 deletions

File tree

imap_l3_processing/glows/glows_processor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,11 @@ def process_l3e(initializer_data: GlowsL3EInitializerOutput):
445445

446446
with SwallowExceptionAndLog(f"Exception encountered when processing L3e lo for repointing {repointing}"):
447447
lo_parent_file_names = initializer_data.dependencies.get_lo_parents()
448-
lo_elongation = lo_pivot_angles[repointing]
448+
pivot_info = lo_pivot_angles[repointing]
449+
if pivot_info.parent_filename is not None:
450+
lo_parent_file_names = lo_parent_file_names + [pivot_info.parent_filename]
449451
lo_version = initializer_data.repointings.lo_repointings[repointing]
450-
products_list.extend(process_l3e_lo(lo_parent_file_names, repointing, start_repointing, epoch_delta, lo_elongation, lo_version))
452+
products_list.extend(process_l3e_lo(lo_parent_file_names, repointing, start_repointing, epoch_delta, pivot_info.pivot_angle, lo_version))
451453

452454
with SwallowExceptionAndLog(f"Exception encountered when processing L3e hi-90 for repointing {repointing}"):
453455
hi_parent_file_names = initializer_data.dependencies.get_hi_parents()

imap_l3_processing/glows/l3e/glows_l3e_utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@ def get_lo_pivot_angle_from_l1b_file(path: Path) -> float:
142142
return 90
143143
return np.round(np.median(angles_to_consider))
144144

145-
def get_lo_pivot_angles(repointings: list[int]) -> dict[int, float]:
145+
@dataclass
146+
class LoPivotAngle:
147+
parent_filename: Optional[str]
148+
pivot_angle: float
149+
150+
def get_lo_pivot_angles(repointings: list[int]) -> dict[int, LoPivotAngle]:
146151
l1b_results = imap_data_access.query(
147152
instrument="lo",
148153
data_level="l1b",
@@ -154,7 +159,7 @@ def get_lo_pivot_angles(repointings: list[int]) -> dict[int, float]:
154159
for repointing in repointings:
155160
if path := paths_by_repointing.get(repointing):
156161
downloaded_path = imap_data_access.download(path)
157-
result[repointing] = get_lo_pivot_angle_from_l1b_file(downloaded_path)
162+
result[repointing] = LoPivotAngle(parent_filename=Path(path).name, pivot_angle=get_lo_pivot_angle_from_l1b_file(downloaded_path))
158163
else:
159-
result[repointing] = 90
164+
result[repointing] = LoPivotAngle(parent_filename=None, pivot_angle=90)
160165
return result

tests/glows/l3e/test_glows_l3e_utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from imap_l3_processing.glows.l3e.glows_l3e_call_arguments import GlowsL3eCallArguments
1111
from imap_l3_processing.glows.l3e.glows_l3e_utils import determine_call_args_for_l3e_executable, \
1212
determine_l3e_files_to_produce, find_first_updated_cr, get_lo_pivot_angles, \
13-
get_lo_pivot_angle_from_l1b_file
13+
get_lo_pivot_angle_from_l1b_file, LoPivotAngle
1414
from tests.test_helpers import get_test_data_path, create_mock_query_results
1515

1616

@@ -285,4 +285,9 @@ def mock_read_from_cdf(path: Path):
285285
call("file4.cdf"),
286286
call("file6.cdf"),
287287
])
288-
self.assertEqual({3: 105, 4: 90, 6: 84, 10: 90}, result)
288+
self.assertEqual({
289+
3: LoPivotAngle(parent_filename="file3.cdf", pivot_angle=105),
290+
4: LoPivotAngle(parent_filename="file4.cdf", pivot_angle=90),
291+
6: LoPivotAngle(parent_filename="file6.cdf", pivot_angle=84),
292+
10: LoPivotAngle(parent_filename=None, pivot_angle=90),
293+
}, result)

tests/glows/test_glows_processor.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from imap_l3_processing.glows.l3e.glows_l3e_initializer import GlowsL3EInitializerOutput
3838
from imap_l3_processing.glows.l3e.glows_l3e_lo_model import GlowsL3ELoData
3939
from imap_l3_processing.glows.l3e.glows_l3e_ultra_model import GlowsL3EUltraData
40-
from imap_l3_processing.glows.l3e.glows_l3e_utils import GlowsL3eRepointings
40+
from imap_l3_processing.glows.l3e.glows_l3e_utils import GlowsL3eRepointings, LoPivotAngle
4141
from imap_l3_processing.models import InputMetadata
4242
from imap_l3_processing.utils import save_data
4343
from tests.test_helpers import get_test_instrument_team_data_path, get_test_data_path, get_test_data_folder, \
@@ -1045,7 +1045,7 @@ def test_process_l3e(self, mock_process_ultra, mock_process_ultra_hf, mock_proce
10451045
mock_process_lo.return_value = [Path('path/to/lo_l3e')]
10461046
mock_process_ultra.return_value = [Path('path/to/ultra_l3e')]
10471047
mock_process_ultra_hf.return_value = [Path('path/to/ultra_l3e_hf')]
1048-
mock_get_lo_pivot_angles.return_value = {25: 75}
1048+
mock_get_lo_pivot_angles.return_value = {25: LoPivotAngle("l1b_nhk.cdf",75)}
10491049

10501050
expected_l3e_products = [
10511051
Path('path/to/lo_l3e'),
@@ -1083,7 +1083,7 @@ def test_process_l3e(self, mock_process_ultra, mock_process_ultra_hf, mock_proce
10831083
call(["hi_ancillary.dat"], 25, start_epoch, epoch_delta, 90, 1),
10841084
call(["hi_ancillary.dat"], 25, start_epoch, epoch_delta, 135, 2)
10851085
])
1086-
mock_process_lo.assert_called_once_with(["lo_ancillary.dat"], 25, start_epoch, epoch_delta, 75,
1086+
mock_process_lo.assert_called_once_with(["lo_ancillary.dat", "l1b_nhk.cdf"], 25, start_epoch, epoch_delta, 75,
10871087
3)
10881088
mock_process_ultra.assert_called_once_with(["ul_ancillary.dat"], 25, start_epoch, epoch_delta, 4)
10891089
mock_process_ultra_hf.assert_called_once_with(["ul_ancillary.dat"], 25, start_epoch, epoch_delta, 4)
@@ -1433,10 +1433,10 @@ def test_process_l3e_skips_repointing_on_exception(self, mock_process_ultra, moc
14331433
ValueError("Failed to generate ultra!")
14341434
]
14351435
mock_get_lo_pivot_angles.return_value = {
1436-
24: 124,
1437-
25: 125,
1438-
26: 126,
1439-
27: 127,
1436+
24: LoPivotAngle(parent_filename="l1b_nhk_24", pivot_angle=124),
1437+
25: LoPivotAngle(parent_filename="l1b_nhk_25", pivot_angle=125),
1438+
26: LoPivotAngle(parent_filename="l1b_nhk_26", pivot_angle=126),
1439+
27: LoPivotAngle(parent_filename=None, pivot_angle=90),
14401440
}
14411441

14421442
expected_l3e_products = [
@@ -1516,10 +1516,10 @@ def test_process_l3e_skips_repointing_on_exception(self, mock_process_ultra, moc
15161516
call(hi_parents, 27, start_epoch_4, epoch_delta_4, 135, 2)
15171517
])
15181518
mock_process_lo.assert_has_calls([
1519-
call(lo_parents, 24, start_epoch_1, epoch_delta_1, 124, 3),
1520-
call(lo_parents, 25, start_epoch_2, epoch_delta_2, 125, 3),
1521-
call(lo_parents, 26, start_epoch_3, epoch_delta_3, 126, 3),
1522-
call(lo_parents, 27, start_epoch_4, epoch_delta_4, 127, 3),
1519+
call(lo_parents + ["l1b_nhk_24"], 24, start_epoch_1, epoch_delta_1, 124, 3),
1520+
call(lo_parents + ["l1b_nhk_25"], 25, start_epoch_2, epoch_delta_2, 125, 3),
1521+
call(lo_parents + ["l1b_nhk_26"], 26, start_epoch_3, epoch_delta_3, 126, 3),
1522+
call(lo_parents, 27, start_epoch_4, epoch_delta_4, 90, 3),
15231523
])
15241524

15251525
mock_process_ultra.assert_has_calls([

0 commit comments

Comments
 (0)