Skip to content

Commit d78e4e9

Browse files
authored
I-ALiRT CoDICE-Hi - update to include spin angle (IMAP-Science-Operations-Center#3126)
* update to use spin angle dimension * spin angle * reorder metadata
1 parent 021b8ea commit d78e4e9

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

imap_processing/cdf/config/imap_ialirt_l1_variable_attrs.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,20 @@ codice_hi_spin_sector:
240240
VAR_TYPE: support_data
241241
dtype: int32
242242

243+
codice_hi_spin_angle:
244+
CATDESC: CoDICE-Hi spin angle for each spin sector and polar angle pair
245+
DEPEND_1: codice_hi_spin_sector
246+
DEPEND_2: codice_hi_polar
247+
FIELDNAM: CoDICE-Hi spin angle
248+
FILLVAL: -1.0e31
249+
FORMAT: F12.6
250+
SCALETYP: linear
251+
UNITS: degrees
252+
VALIDMAX: 360.0
253+
VALIDMIN: 0.0
254+
VAR_TYPE: support_data
255+
dtype: float32
256+
243257
codice_hi_spin_sector_labels:
244258
CATDESC: CoDICE-Hi spin sector labels
245259
FIELDNAM: CoDICE-Hi spin sector labels

imap_processing/ialirt/utils/create_xarray.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
HI_IALIRT_ELEVATION_ANGLE,
1313
)
1414
from imap_processing.ialirt.utils.constants import (
15+
HI_IALIRT_SPIN_ANGLE,
1516
IALIRT_DIMS,
1617
IALIRT_DTYPES,
1718
codice_hi_energy_center,
@@ -232,6 +233,15 @@ def create_xarray_from_records(records: list[dict]) -> xr.Dataset: # noqa: PLR0
232233
),
233234
)
234235

236+
spin_angle = xr.DataArray(
237+
data=HI_IALIRT_SPIN_ANGLE.T.astype(np.float32),
238+
name="codice_hi_spin_angle",
239+
dims=["codice_hi_spin_sector", "codice_hi_polar"],
240+
attrs=cdf_manager.get_variable_attributes(
241+
"codice_hi_spin_angle", check_schema=False
242+
),
243+
)
244+
235245
spin_sector_labels = xr.DataArray(
236246
[
237247
"0",
@@ -267,6 +277,7 @@ def create_xarray_from_records(records: list[dict]) -> xr.Dataset: # noqa: PLR0
267277
"codice_hi_polar": polar,
268278
"codice_hi_polar_labels": polar_labels,
269279
"codice_hi_spin_sector": spin_sector,
280+
"codice_hi_spin_angle": spin_angle,
270281
"codice_hi_spin_sector_labels": spin_sector_labels,
271282
"swe_electron_energy": swe_electron_energy,
272283
}

imap_processing/tests/ialirt/unit/test_create_xarray.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy.testing as npt
77

88
from imap_processing.cdf.utils import write_cdf
9-
from imap_processing.ialirt.utils.constants import swe_energy
9+
from imap_processing.ialirt.utils.constants import HI_IALIRT_SPIN_ANGLE, swe_energy
1010
from imap_processing.ialirt.utils.create_xarray import create_xarray_from_records
1111

1212

@@ -166,3 +166,12 @@ def test_create_dataset():
166166
)
167167

168168
assert test_data_path.exists()
169+
170+
# codice_hi_spin_angle should be a 2D array of actual spin angles (degrees).
171+
# Shape: (spin_sector=4, polar=4).
172+
spin_angle = dataset["codice_hi_spin_angle"]
173+
assert spin_angle.dims == ("codice_hi_spin_sector", "codice_hi_polar")
174+
assert spin_angle.shape == (4, 4)
175+
npt.assert_allclose(
176+
spin_angle.values, HI_IALIRT_SPIN_ANGLE.T.astype(np.float32), rtol=1e-6
177+
)

0 commit comments

Comments
 (0)