Skip to content

Commit 4e4854d

Browse files
authored
MNT: Add sc velocity to Lo pointing sets in l1c (#2625)
Lo doesn't want to wait until CG calculations and wants this information in the l1c pointing set itself when created.
1 parent c106df1 commit 4e4854d

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

imap_processing/lo/l1c/lo_l1c.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import xarray as xr
1010

1111
from imap_processing.cdf.imap_cdf_manager import ImapCdfAttributes
12+
from imap_processing.ena_maps.utils.corrections import add_spacecraft_velocity_to_pset
1213
from imap_processing.lo import lo_ancillary
1314
from imap_processing.lo.l1b.lo_l1b import set_bad_or_goodtimes
1415
from imap_processing.spice.geometry import (
@@ -202,6 +203,9 @@ def lo_l1c(sci_dependencies: dict, anc_dependencies: list) -> list[xr.Dataset]:
202203
}
203204
)
204205

206+
# add the spacecraft velocity and direction
207+
pset = add_spacecraft_velocity_to_pset(pset)
208+
205209
return [pset]
206210

207211

imap_processing/tests/lo/test_lo_l1c.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ def expected_bg():
219219
@patch("imap_processing.lo.l1c.lo_l1c.set_background_rates")
220220
@patch("imap_processing.lo.l1c.lo_l1c.filter_goodtimes")
221221
@patch("imap_processing.lo.l1c.lo_l1c.set_pointing_directions")
222+
@patch("imap_processing.lo.l1c.lo_l1c.add_spacecraft_velocity_to_pset")
222223
def test_lo_l1c(
224+
mock_add_spacecraft_velocity,
223225
mock_set_pointing_directions,
224226
mock_filter_goodtimes,
225227
mock_set_background_rates,
@@ -245,16 +247,20 @@ def test_lo_l1c(
245247
np.ones(PSET_SHAPE, dtype=np.float32),
246248
dims=["epoch", "esa_energy_step", "spin_angle", "off_angle"],
247249
)
250+
mock_add_spacecraft_velocity.side_effect = lambda pset: pset
248251
expected_logical_source = "imap_lo_l1c_pset"
249252

250253
# Act
251-
output_dataset = lo_l1c(data, anc_dependencies)
254+
output_dataset = lo_l1c(data, anc_dependencies)[0]
252255

253256
# Assert
254-
assert expected_logical_source == output_dataset[0].attrs["Logical_source"]
257+
assert expected_logical_source == output_dataset.attrs["Logical_source"]
255258
# Verify that pivot_angle is passed through from l1b_de
256-
assert "pivot_angle" in output_dataset[0]
257-
assert output_dataset[0]["pivot_angle"].values[0] == 45.0
259+
assert "pivot_angle" in output_dataset
260+
assert output_dataset["pivot_angle"].values[0] == 45.0
261+
# We want sc velocity and direction added to the l1c pointing sets,
262+
# not waiting until CG is needed.
263+
mock_add_spacecraft_velocity.assert_called_once()
258264

259265

260266
def test_filter_goodtimes(l1b_de, anc_dependencies):

0 commit comments

Comments
 (0)