Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions imap_processing/cdf/config/imap_ialirt_l1_variable_attrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,20 @@ codice_hi_spin_sector:
VAR_TYPE: support_data
dtype: int32

codice_hi_spin_angle:
CATDESC: CoDICE-Hi spin angle for each spin sector and polar angle pair
DEPEND_1: codice_hi_spin_sector
DEPEND_2: codice_hi_polar
FIELDNAM: CoDICE-Hi spin angle
FILLVAL: -1.0e31
FORMAT: F12.6
SCALETYP: linear
UNITS: degrees
VALIDMAX: 360.0
VALIDMIN: 0.0
VAR_TYPE: support_data
dtype: float32

codice_hi_spin_sector_labels:
CATDESC: CoDICE-Hi spin sector labels
FIELDNAM: CoDICE-Hi spin sector labels
Expand Down
11 changes: 11 additions & 0 deletions imap_processing/ialirt/utils/create_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
HI_IALIRT_ELEVATION_ANGLE,
)
from imap_processing.ialirt.utils.constants import (
HI_IALIRT_SPIN_ANGLE,
IALIRT_DIMS,
IALIRT_DTYPES,
codice_hi_energy_center,
Expand Down Expand Up @@ -232,6 +233,15 @@ def create_xarray_from_records(records: list[dict]) -> xr.Dataset: # noqa: PLR0
),
)

spin_angle = xr.DataArray(
data=HI_IALIRT_SPIN_ANGLE.T.astype(np.float32),
name="codice_hi_spin_angle",
dims=["codice_hi_spin_sector", "codice_hi_polar"],
attrs=cdf_manager.get_variable_attributes(
"codice_hi_spin_angle", check_schema=False
),
)

spin_sector_labels = xr.DataArray(
[
"0",
Expand Down Expand Up @@ -267,6 +277,7 @@ def create_xarray_from_records(records: list[dict]) -> xr.Dataset: # noqa: PLR0
"codice_hi_polar": polar,
"codice_hi_polar_labels": polar_labels,
"codice_hi_spin_sector": spin_sector,
"codice_hi_spin_angle": spin_angle,
"codice_hi_spin_sector_labels": spin_sector_labels,
"swe_electron_energy": swe_electron_energy,
}
Expand Down
11 changes: 10 additions & 1 deletion imap_processing/tests/ialirt/unit/test_create_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy.testing as npt

from imap_processing.cdf.utils import write_cdf
from imap_processing.ialirt.utils.constants import swe_energy
from imap_processing.ialirt.utils.constants import HI_IALIRT_SPIN_ANGLE, swe_energy
from imap_processing.ialirt.utils.create_xarray import create_xarray_from_records


Expand Down Expand Up @@ -166,3 +166,12 @@ def test_create_dataset():
)

assert test_data_path.exists()

# codice_hi_spin_angle should be a 2D array of actual spin angles (degrees).
# Shape: (spin_sector=4, polar=4).
spin_angle = dataset["codice_hi_spin_angle"]
assert spin_angle.dims == ("codice_hi_spin_sector", "codice_hi_polar")
assert spin_angle.shape == (4, 4)
npt.assert_allclose(
spin_angle.values, HI_IALIRT_SPIN_ANGLE.T.astype(np.float32), rtol=1e-6
)
Loading