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
6 changes: 5 additions & 1 deletion imap_processing/cdf/config/imap_ialirt_global_cdf_attrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ instrument_base: &instrument_base
HIT (High-energy Ion Telescope), MAG (Magnetometer),
and SWAPI (Solar Wind and Pickup Ion).
See https://imap.princeton.edu for more details.
Instrument_type: Particles (space), Magnetic Fields (space), Plasma and Solar Wind (space), Ephemeris/Attitude/Ancillary
Instrument_type:
- "Particles (space)"
- "Magnetic Fields (space)"
- "Plasma and Solar Wind (space)"
- "Ephemeris/Attitude/Ancillary"

imap_ialirt_l1_realtime:
<<: *instrument_base
Expand Down
61 changes: 33 additions & 28 deletions imap_processing/cdf/config/imap_ialirt_l1_variable_attrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ codice_hi_energy_center:
FILLVAL: -1.0e31
FORMAT: F12.6
dtype: float32
LABLAXIS: Proton energy bin

codice_hi_energy_minus:
CATDESC: CoDICE-Hi proton energy bin lower delta (MeV)
Expand All @@ -194,6 +195,7 @@ codice_hi_energy_minus:
FILLVAL: -1.0e31
FORMAT: F12.6
dtype: float32
LABLAXIS: Energy lower delta

codice_hi_energy_plus:
CATDESC: CoDICE-Hi proton energy bin upper delta (MeV)
Expand All @@ -205,6 +207,7 @@ codice_hi_energy_plus:
FILLVAL: -1.0e31
FORMAT: F12.6
dtype: float32
LABLAXIS: Energy upper delta

codice_hi_elevation:
CATDESC: Elevation Angle
Expand Down Expand Up @@ -235,6 +238,7 @@ codice_hi_spin_sector:
VALIDMIN: 0
VALIDMAX: 3
dtype: int32
LABLAXIS: Spin sector index

codice_hi_spin_sector_labels:
CATDESC: CoDICE-Hi spin sector labels
Expand All @@ -252,7 +256,7 @@ swe_electron_energy:
VALIDMIN: 0.0
VALIDMAX: 2000.0
FILLVAL: -1.0e31
FORMAT: F12.6
FORMAT: F6.1
dtype: float32

# Variables
Expand All @@ -269,7 +273,7 @@ codice_hi_h:
DEPEND_2: codice_hi_spin_sector
DEPEND_3: codice_hi_elevation
DISPLAY_TYPE: no_plot
FORMAT: F16.6
FORMAT: F6.1
VAR_NOTES: Energy ranges (MeV) are 0.0200 to 0.0283, 0.0283 to 0.0400, 0.0400 to 0.0566, 0.0566 to 0.0800, 0.0800 to 0.113, 0.113 to 0.160, 0.160 to 0.226, 0.226 to 0.320, 0.320 to 0.453, 0.453 to 0.640, 0.640 to 0.905, 0.905 to 1.28, 1.28 to 1.81, 1.81 to 2.56, 2.56 to 3.62.

codice_lo_c_over_o_abundance:
Expand Down Expand Up @@ -339,135 +343,135 @@ codice_lo_fe_low_over_fe_high:
FORMAT: F16.6

hit_e_a_side_low_en:
<<: *default_uint32
<<: *default_float32
CATDESC: Count rates from HIT for electrons above 0.5 MeV, A-side aperture (anti-sunward) look direction
FIELDNAM: Low energy electron count rate (A-side)
LABLAXIS: A-side e- >0.5 MeV
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: A-side indicates the HIT aperture that is nominally looking in the anti-sunward direction. B-side indicates the aperture looking nominally in the sunward direction.

hit_e_a_side_med_en:
<<: *default_uint32
<<: *default_float32
CATDESC: Count rates from HIT for electrons below 1 MeV, A-side aperture (anti-sunward) look direction
FIELDNAM: Medium energy electron count rate (A-side)
LABLAXIS: A-side e- <1 MeV
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: A-side indicates the HIT aperture that is nominally looking in the anti-sunward direction. B-side indicates the aperture looking nominally in the sunward direction.

hit_e_a_side_high_en:
<<: *default_uint32
<<: *default_float32
CATDESC: High energy (>3 MeV) electron count rate (A-side, anti-sunward)
FIELDNAM: High energy electron count rate (A-side)
LABLAXIS: A-side e- >3 MeV
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: A-side indicates the HIT aperture that is nominally looking in the anti-sunward direction. B-side indicates the aperture looking nominally in the sunward direction.

hit_e_b_side_low_en:
<<: *default_uint32
<<: *default_float32
CATDESC: Count rates from HIT for electrons above 0.5 MeV, B-side aperture (sunward) look direction
FIELDNAM: Low energy electron count rate (B-side)
LABLAXIS: B-side e- >0.5 MeV
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: A-side indicates the HIT aperture that is nominally looking in the anti-sunward direction. B-side indicates the aperture looking nominally in the sunward direction.

hit_e_b_side_med_en:
<<: *default_uint32
<<: *default_float32
CATDESC: Count rates from HIT for electrons below 1 MeV, B-side aperture (sunward) look direction
FIELDNAM: Medium energy electron count rate (B-side)
LABLAXIS: B-side e- <1 MeV
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: A-side indicates the HIT aperture that is nominally looking in the anti-sunward direction. B-side indicates the aperture looking nominally in the sunward direction.

hit_e_b_side_high_en:
<<: *default_uint32
<<: *default_float32
CATDESC: High energy (>3 MeV) electron count rate (B-side, sunward)
FIELDNAM: High energy electron count rate (B-side)
LABLAXIS: B-side e- >3 MeV
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: A-side indicates the HIT aperture that is nominally looking in the anti-sunward direction. B-side indicates the aperture looking nominally in the sunward direction.

hit_h_omni_low_en:
<<: *default_uint32
<<: *default_float32
CATDESC: Count rates from HIT for protons between 6 to 8 MeV, omnidirectional (sum of particles divided by full sky area)
FIELDNAM: Proton count rate 6 to 8 MeV (omni)
LABLAXIS: Omni H+ 6 to 8 MeV
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: Omni indicates the sum of the number of particles divided by the area of the full sky.

hit_h_omni_med_en:
<<: *default_uint32
<<: *default_float32
CATDESC: Count rates from HIT for protons between 12 to 15 MeV, omnidirectional (sum of particles divided by full sky area)
FIELDNAM: Proton count rate 12 to 15 MeV (omni)
LABLAXIS: Omni H+ 12 to 15 MeV
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: Omni indicates the sum of the number of particles divided by the area of the full sky.

hit_h_a_side_high_en:
<<: *default_uint32
<<: *default_float32
CATDESC: High energy (>70 MeV) proton count rate (A-side, anti-sunward)
FIELDNAM: Proton count rate >70 MeV (A-side)
LABLAXIS: A-side H >70 MeV
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: A-side indicates the HIT aperture that is nominally looking in the anti-sunward direction. B-side indicates the aperture looking nominally in the sunward direction.

hit_h_b_side_high_en:
<<: *default_uint32
<<: *default_float32
CATDESC: High energy (>70 MeV) proton count rate (B-side, sunward)
FIELDNAM: Proton count rate >70 MeV (B-side)
LABLAXIS: B-side H >70 MeV
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: A-side indicates the HIT aperture that is nominally looking in the anti-sunward direction. B-side indicates the aperture looking nominally in the sunward direction.

hit_he_omni_low_en:
<<: *default_uint32
<<: *default_float32
CATDESC: Count rates from HIT for He4 between 6 to 8 MeV/nuc, omnidirectional (sum of particles divided by full sky area)
FIELDNAM: Helium count rate 6 to 8 MeV/nuc (omni)
LABLAXIS: Omni He 6 to 8 MeV/nuc
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: Omni indicates the sum of the number of particles divided by the area of the full sky.

hit_he_omni_high_en:
<<: *default_uint32
<<: *default_float32
CATDESC: Count rates from HIT for He4 between 15 to 70 MeV/nuc, omnidirectional (sum of particles divided by full sky area)
FIELDNAM: Helium count rate 15 to 70 MeV/nuc (omni)
LABLAXIS: Omni He 15 to 70 MeV/nuc
DEPEND_0: hit_epoch
UNITS: counts per second
VALIDMIN: 0
VALIDMAX: 1000000000
VALIDMAX: 1000000000.0
VAR_NOTES: Omni indicates the sum of the number of particles divided by the area of the full sky.

mag_B_magnitude:
Expand Down Expand Up @@ -597,9 +601,10 @@ swe_normalized_counts:
FIELDNAM: Normalized electron counts
UNITS: normalized counts
VALIDMIN: 0
VALIDMAX: 500000
VALIDMAX: 5000000000000
DEPEND_1: swe_electron_energy
DISPLAY_TYPE: stack_plot
SCALETYP: log
LABLAXIS: Electron counts
DEPEND_0: swe_epoch
VAR_NOTES: The nominal central energies for the 8 i-ALiRT channels are 100.4, 140, 194, 270, 376, 523, 727, and 1011 eV.
Expand Down Expand Up @@ -638,7 +643,7 @@ sc_velocity_GSE:

sc_position_GSM:
<<: *default_float32
CATDESC: Spacecraft position vector in GSM coordinates
CATDESC: Spacecraft position in GSM coordinates
FIELDNAM: Spacecraft position in GSM coordinates
LABLAXIS: SC position (GSM)
UNITS: km
Expand Down
21 changes: 8 additions & 13 deletions imap_processing/ialirt/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@
"codice_lo_o_plus_7_over_o_plus_6": ["codice_lo_epoch"],
# Fe low/Fe high charge state ratio
"codice_lo_fe_low_over_fe_high": ["codice_lo_epoch"],
# Low energy (>0.5 MeV) electrons (A-side)
"hit_e_a_side_low_en": ["hit_epoch"],
# Medium energy (<1 MeV) electrons (A-side)
"hit_e_a_side_med_en": ["hit_epoch"],
# Low energy (>0.5 MeV) electrons (B-side)
"hit_e_b_side_low_en": ["hit_epoch"],
# Medium energy (<1 MeV) electrons (B-side)
"hit_e_b_side_med_en": ["hit_epoch"],
# Low energy (6 to 8 MeV) protons (Omnidirectional)
Expand Down Expand Up @@ -89,16 +85,13 @@
"codice_lo_o_plus_7_over_o_plus_6": np.float32,
"codice_lo_fe_low_over_fe_high": np.float32,
# HIT scalars
"hit_e_a_side_low_en": np.uint32,
"hit_e_a_side_med_en": np.uint32,
"hit_e_b_side_low_en": np.uint32,
"hit_e_b_side_med_en": np.uint32,
"hit_h_omni_low_en": np.uint32,
"hit_h_omni_med_en": np.uint32,
"hit_he_omni_low_en": np.uint32,
"hit_he_omni_high_en": np.uint32,
"hit_e_a_side_med_en": np.float32,
"hit_e_b_side_med_en": np.float32,
"hit_h_omni_low_en": np.float32,
"hit_h_omni_med_en": np.float32,
"hit_he_omni_low_en": np.float32,
"hit_he_omni_high_en": np.float32,
# MAG
"mag_epoch": np.int64, # if you are treating this as a data variable
"mag_B_magnitude": np.float32,
"mag_B_RTN": np.float32,
"mag_B_GSE": np.float32,
Expand Down Expand Up @@ -126,6 +119,8 @@
"hit_e_b_side_high_en",
"hit_h_a_side_high_en",
"hit_h_b_side_high_en",
"hit_e_a_side_low_en",
"hit_e_b_side_low_en",
}

codice_hi_energy_center = [
Expand Down
26 changes: 19 additions & 7 deletions imap_processing/ialirt/utils/create_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,22 +267,34 @@ def create_xarray_from_records(records: list[dict]) -> xr.Dataset: # noqa: PLR0

for i, record in enumerate(by_inst.get("codice_lo", [])):
for key in IALIRT_DIMS.keys():
if key.startswith("codice_lo_"):
dataset[key].data[i] = np.float32(record[key])
val = record.get(key)
if (
key.startswith("codice_lo_")
and key != "codice_lo_epoch"
and val is not None
):
dataset[key].data[i] = np.float32(val)

for i, record in enumerate(by_inst.get("hit", [])):
for key in IALIRT_DIMS.keys():
if key.startswith("hit_") and key not in hit_restricted_fields:
dataset[key].data[i] = np.uint32(record[key])
val = record.get(key)
if (
key.startswith("hit_")
and key != "hit_epoch"
and val is not None
and key not in hit_restricted_fields
):
dataset[key].data[i] = np.float32(val)

for i, record in enumerate(by_inst.get("swapi", [])):
for key in IALIRT_DIMS.keys():
if key.startswith("swapi_"):
dataset[key].data[i] = np.float32(record[key])
val = record.get(key)
if key.startswith("swapi_") and key != "swapi_epoch" and val is not None:
dataset[key].data[i] = np.float32(val)

for i, record in enumerate(by_inst.get("swe", [])):
dataset["swe_normalized_counts"].data[i, :] = np.asarray(
record["swe_normalized_counts"], dtype=np.uint32
record["swe_normalized_counts"], dtype=np.int64
)
dataset["swe_counterstreaming_electrons"].data[i] = np.uint8(
record["swe_counterstreaming_electrons"]
Expand Down
8 changes: 3 additions & 5 deletions imap_processing/tests/ialirt/unit/test_create_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ def test_create_dataset():
dataset["swe_normalized_counts"].values[0],
np.zeros(8, dtype=np.uint32),
)
np.testing.assert_allclose(
dataset["hit_e_a_side_low_en"].values,
[0.0],
)
np.testing.assert_allclose(
dataset["mag_B_GSE"].sel(mag_epoch=123456789000001).values,
[5.0, -3.2, 1.1],
Expand All @@ -165,6 +161,8 @@ def test_create_dataset():
# Tests that you can write to a cdf.
dataset.attrs["Data_version"] = "001"
dataset.attrs["Start_date"] = "20260114"
test_data_path = write_cdf(dataset, istp=True, compression=None)
test_data_path = write_cdf(
dataset, istp=True, auto_fix_depends=False, compression=None
)

assert test_data_path.exists()