diff --git a/docs/source/code-documentation/idex.rst b/docs/source/code-documentation/idex.rst index aa5135776..881fcef35 100644 --- a/docs/source/code-documentation/idex.rst +++ b/docs/source/code-documentation/idex.rst @@ -15,4 +15,5 @@ Level 1 Processing Code: :template: autosummary.rst :recursive: - idex_packet_parser + l0.idex_l0 + l1.idex_l1 diff --git a/imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml b/imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml new file mode 100644 index 000000000..78a8545be --- /dev/null +++ b/imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml @@ -0,0 +1,24 @@ +instrument_base: &instrument_base + Descriptor: IDEX>Interstellar Dust Experiment + TEXT: > + The Interstellar Dust Experiment (IDEX) is a time-of-flight (TOF) + dust impact ionization mass spectrometer on the IMAP mission that + provides the elemental composition, speed, and mass distributions + of interstellar dust and interplanetary dust particles. Each record + contains the data from a single dust impact. See + https://imap.princeton.edu/instruments/idex for more details. + Instrument_type: + +imap_idex_l1_sci: + <<: *instrument_base + Data_level: L1 + Data_type: L1_SCI>Level-1 Science Data + Logical_source: imap_idex_l1_sci + Logical_source_description: IMAP Mission IDEX Instrument Level-1 Data. + +imap_idex_l2_sci: + <<: *instrument_base + Data_level: L2 + Data_type: L2_SCI>Level-2 Science Data + Logical_source: idex_l2_global_attrs + Logical_source_description: IMAP Mission IDEX Instrument Level-2 Data \ No newline at end of file diff --git a/imap_processing/cdf/config/imap_idex_l1_variable_attrs.yaml b/imap_processing/cdf/config/imap_idex_l1_variable_attrs.yaml new file mode 100644 index 000000000..b0e541ef4 --- /dev/null +++ b/imap_processing/cdf/config/imap_idex_l1_variable_attrs.yaml @@ -0,0 +1,443 @@ +int_fillval: &int_fillval -9223372036854775808 +min_epoch: &min_epoch -315575942816000000 +max_epoch: &max_epoch 3155630469184000000 + +data_min: &data_min 0 +data_max: &data_max 4096 + +sample_rate_min: &sample_rate_min -130 +sample_rate_max: &sample_rate_max 130 + +int_maxval: &int_maxval 9223372036854775807 + +l1_data_base: &l1_data_base + VALIDMIN: *data_min + VALIDMAX: *data_max + DISPLAY_TYPE: spectrogram + DEPEND_0: epoch + FORMAT: "" + UNITS: dN + VAR_TYPE: data + # VAR_PURPOSE: PRIMARY + CATDESC: "" + FIELDNAM: "" + FILLVAL: *int_fillval + LABLAXIS: "" + +l1_tof_base: &l1_tof_base + <<: *l1_data_base + DEPEND_1: time_high_sr + +l1_target_base: &l1_target_base + <<: *l1_data_base + DEPEND_1: time_low_sr + +epoch: + <<: *l1_data_base + CATDESC: Time, number of nanoseconds since J2000 with leap seconds included + FIELDNAM: epoch + FILLVAL: *int_fillval + LABLAXIS: epoch + FORMAT: "" # Supposedly not required, fails in xarray_to_cdf + UNITS: ns + VALIDMIN: *min_epoch + VALIDMAX: *max_epoch + VAR_TYPE: support_data + SCALETYP: linear + MONOTON: INCREASE + TIME_BASE: J2000 + TIME_SCALE: Terrestrial Time + REFERENCE_POSITION: Rotating Earth Geoid + +sample_rate_base: &sample_rate_base + DISPLAY_TYPE: no_plot + CATDESC: "" + FIELDNAM: "" + FILLVAL: -1.0e+31 + VALIDMIN: *sample_rate_min + VALIDMAX: *sample_rate_max + DEPEND_0: epoch + FORMAT: F64.5 + LABLAXIS: Time + UNITS: microseconds + VAR_TYPE: support_data # Not in attrs file + VAR_NOTES: The number of microseconds since the event. + 0 is the start of data collection, negative + numbers represent data collected prior to a dust event + +trigger_base: &trigger_base + VALIDMIN: 0 + VALIDMAX: *int_maxval + DISPLAY_0: epoch + DISPLAY_TYPE: no_plot + CATDESC: "" + FIELDNAM: "" + VAR_TYPE: support_data + FILLVAL: *int_fillval + LABLAXIS: "" + FORMAT: I12 + UNITS: "" + +# TODO: All of these have var_notes in idex_cef_attrs. Should I add these? +low_sr_attrs: + <<: *sample_rate_base + CATDESC: Low sample rate time steps for a dust event. + FIELDNAM: Low Sample Rate Time + FILLVAL: *int_fillval + VAR_NOTES: The low sample rate in microseconds. Steps are approximately 1/4.025 + microseconds in duration. Used by the Ion_Grid, Target_Low, and + Target_High variables. + +high_sr_attrs: + <<: *sample_rate_base + CATDESC: High sample rate time steps for a dust event. + FIELDNAM: High Sample Rate Time + VAR_NOTES: The high sample rate in microseconds. Steps are approximately 1/260 + microseconds in duration. Used by the TOF_High, TOF_Mid, and + TOF_Low variables. + +tof_high_attrs: + <<: *l1_tof_base + CATDESC: Time of flight waveform on the high-gain channel + FIELDNAM: High Gain Time of Flight + LABLAXIS: TOF High Ampl. + VAR_NOTES: High gain channel of the time-of-flight signal. + Sampled at 260 Megasamples per second, with a 10-bit resolution. + Data is used to quantify dust composition. + +tof_mid_attrs: + <<: *l1_tof_base + CATDESC: Time of flight waveform on the mid-gain channel + FIELDNAM: Mid Gain Time of Flight + LABLAXIS: TOF Mid Ampl. + VAR_NOTES: Mid gain channel of the time-of-flight signal. + Sampled at 260 Megasamples per second, with a 10-bit resolution. + Data is used to quantify dust composition. + +tof_low_attrs: + <<: *l1_tof_base + FILLVAL: *int_fillval + CATDESC: Time of flight waveform on the low-gain channel + FIELDNAM: Low Gain Time of Flight + LABLAXIS: TOF Low Ampl. + VAR_NOTES: Low gain channel of the time-of-flight signal. + Sampled at 260 Megasamples per second, with a 10-bit resolution. + Data is used to quantify dust composition. + + +target_low_attrs: + <<: *l1_target_base + CATDESC: Target low charge sensitive amplifier waveform + FIELDNAM: Low Target Signal + LABLAXIS: Low Target Ampl. + VAR_NOTES: Low gain channel of IDEX's target signal. + Sampled at 3.75 Msps with 12-bit resolution. + Data is used to quantify dust charge. + +target_high_attrs: + <<: *l1_target_base + CATDESC: Ion grid charge sensitive amplifier waveform + FIELDNAM: High Target Signal + LABLAXIS: High Target Ampl. + VAR_NOTES: High gain channel of IDEX's target signal. + Sampled at 3.75 Msps with 12-bit resolution. + Data is used to quantify dust charge. + +ion_grid_attrs: + <<: *l1_target_base + CATDESC: Ion grid charge sensitive amplifier waveform data + FIELDNAM: Ion Grid Signal + LABLAXIS: Ion Grid Ampl. + VAR_NOTES: This is the ion grid signal from IDEX. + Sampled at 3.75 Msps with 12-bit resolution. + Data is used to quantify dust charge. + +# Trigger Stuff + +event_number: + <<: *trigger_base + CATDESC: The unique number assigned to the impact by the FPGA + FIELDNAM: Event Number + VALIDMAX: 65535 + LABLAXIS: Event Number + UNITS: "" + +tof_high_trigger_level: + <<: *trigger_base + VALIDMAX: 1023 + FIELDNAM: TOF High Trigger Level + CATDESC: Trigger level for the TOF High Channel + LABLAXIS: Level + UNITS: "" + +tof_high_trigger_num_max_1_2: + <<: *trigger_base + VALIDMAX: 2047 + FIELDNAM: TOF High Double Pulse Max Samples + CATDESC: Maximum number of samples between pulse 1 and 2 for TOF. High double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_high_trigger_num_min_1_2: + <<: *trigger_base + VALIDMAX: 2047 + FIELDNAM: TOF High Double Pulse Min Samples + CATDESC: Minimum number of samples between pulse 1 and 2 for TOF High. Double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_high_trigger_num_min_1: + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: TOF High Pulse 1 Min Samples + CATDESC: Minimum number of samples for pulse 1 for TOF High single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_high_trigger_num_max_1: + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: TOF High Pulse 1 Max Samples + CATDESC: Maximum number of samples for pulse 1 for TOF High single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_high_trigger_num_min_2: + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: TOF High Pulse 2 Min Samples + CATDESC: Minimum number of samples for pulse 2 for TOF High single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_high_trigger_num_max_2: + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: TOF High Pulse 2 Max Samples + CATDESC: Maximum number of samples for pulse 2 for TOF High single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_low_trigger_level: + <<: *trigger_base + VALIDMAX: 1023 + FIELDNAM: TOF Low Trigger Level + CATDESC: Trigger level for the TOF Low Channel + LABLAXIS: Level + UNITS: "" # "samples" in idex_packet_parser...? + +tof_low_trigger_num_max_1_2: + <<: *trigger_base + VALIDMAX: 2047 + FIELDNAM: TOF Low Double Pulse Max Samples + CATDESC: Maximum number of samples between pulse 1 and 2 for TOF Low double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_low_trigger_num_min_1_2: + <<: *trigger_base + VALIDMAX: 2047 + FIELDNAM: TOF Low Double Pulse Min Samples + CATDESC: Minimum number of samples between pulse 1 and 2 for TOF Low double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_low_trigger_num_min_1: + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: TOF Low Pulse 1 Min Samples + CATDESC: Minimum number of samples for pulse 1 for TOF Low single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_low_trigger_num_max_1: + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: TOF Low Pulse 1 Max Samples + CATDESC: Maximum number of samples for pulse 1 for TOF Low single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_low_trigger_num_min_2 : + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: TOF Low Pulse 2 Min Samples + CATDESC: Minimum number of samples for pulse 2 for TOF Low single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_low_trigger_num_max_2: + <<: *trigger_base + VALIDMAX: 65535 + FIELDNAM: TOF Low Pulse 2 Max Samples + CATDESC: Maximum number of samples for pulse 2 for TOF Low single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_mid_trigger_level: + <<: *trigger_base + VALIDMAX: 1023 + FIELDNAM: TOF Mid Trigger Level + CATDESC: Trigger level for the TOF Mid Channel + LABLAXIS: Level + UNITS: "" # "samples" in idex_packet_parser...? + +tof_mid_trigger_num_max_1_2: + <<: *trigger_base + VALIDMAX: 2047 + FIELDNAM: TOF Mid Double Pulse Max Samples + CATDESC: Maximum number of samples between pulse 1 and 2 for TOF Mid double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_mid_trigger_num_min_1_2: + <<: *trigger_base + VALIDMAX: 2047 + FIELDNAM: TOF Mid Double Pulse Min Samples + CATDESC: Minimum number of samples between pulse 1 and 2 for TOF Mid double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_mid_trigger_num_min_1: + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: TOF Mid Pulse 1 Min Samples + CATDESC: Minimum number of samples for pulse 1 for TOF Mid single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_mid_trigger_num_max_1: + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: TOF Mid Pulse 1 Max Samples + CATDESC: Maximum number of samples for pulse 1 for TOF Mid single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_mid_trigger_num_min_2: + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: TOF Mid Pulse 2 Min Samples + CATDESC: Minimum number of samples for pulse 2 for TOF Mid single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +tof_mid_trigger_num_max_2: + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: TOF Mid Pulse 2 Max Samples + CATDESC: Maximum number of samples for pulse 2 for TOF Mid single and double pulse triggering. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +low_sample_coincidence_mode_blocks: + <<: *trigger_base + VALIDMAX: 7 + FIELDNAM: LS Coincidence Mode Blocks + CATDESC: Number of blocks coincidence window is enabled after low sample trigger. + LABLAXIS: Blocks Number + UNITS: "" # "blocks" in idex_packet_parser...? + +low_sample_trigger_polarity: + <<: *trigger_base + VALIDMAX: 1 + FIELDNAM: LS Trigger Polarity + CATDESC: The trigger polarity for low sample (0 = normal, 1 = inverted) + LABLAXIS: Polarity + UNITS: "" + +low_sample_trigger_level: + <<: *trigger_base + VALIDMAX: 4095 + FIELDNAM: LS Trigger Level + CATDESC: Trigger level for the low sample + LABLAXIS: Level + UNITS: "" + +low_sample_trigger_num_min: + <<: *trigger_base + VALIDMAX: 255 + FIELDNAM: LS Trigger Min Num Samples + CATDESC: The minimum number of samples above/below the trigger level for triggering the low sample. + LABLAXIS: Samples Number + UNITS: "" # "samples" in idex_packet_parser...? + +low_sample_trigger_mode: + <<: *trigger_base + VALIDMAX: 1 + FIELDNAM: LS Trigger Mode Enabled + CATDESC: Low sample trigger mode (0=disabled, 1=enabled) + LABLAXIS: Mode + UNITS: "" + +tof_low_trigger_mode: + <<: *trigger_base + VALIDMAX: 1 + FIELDNAM: TOF Low Trigger Mode Enabled + CATDESC: TOF Low trigger mode (0=disabled, 1=enabled) + LABLAXIS: Mode + UNITS: "" + +tof_mid_trigger_mode: + <<: *trigger_base + VALIDMAX: 1 + FIELDNAM: TOF Mid Trigger Mode Enabled + CATDESC: TOF Mid trigger mode (0=disabled, 1=enabled) + LABLAXIS: Mode + UNITS: "" + +tof_high_trigger_mode: + <<: *trigger_base + VALIDMAX: 3 + FIELDNAM: TOF High Trigger Mode Enabled + CATDESC: TOF High trigger mode (0=disabled, 1=threshold mode, 2=single pulse mode, 3=double pulse mode). + LABLAXIS: Mode + UNITS: "" + +detector_voltage: + <<: *trigger_base + VALIDMAX: 4095 + FIELDNAM: Detector Voltage + CATDESC: Last measurement in raw dN for processor board signal - "Detector Voltage" + LABLAXIS: Voltage + UNITS: dN + +sensor_voltage: + <<: *trigger_base + VALIDMAX: 4095 + FIELDNAM: Sensor Voltage + CATDESC: Last measurement in raw dN for processor board signal - "Sensor Voltage " + LABLAXIS: Voltage + UNITS: dN + +target_voltage: + <<: *trigger_base + VALIDMAX: 4095 + FIELDNAM: Target Voltage + CATDESC: Last measurement in raw dN for processor board signal - "Target Voltage" + LABLAXIS: Voltage + UNITS: dN + +reflectron_voltage: + <<: *trigger_base + VALIDMAX: 4095 + FIELDNAM: Reflectron Voltage + CATDESC: Last measurement in raw dN for processor board signal - "Reflectron Voltage" + LABLAXIS: Voltage + UNITS: dN + +rejection_voltage: + <<: *trigger_base + VALIDMAX: 4095 + FIELDNAM: Rejection Voltage + CATDESC: Last measurement in raw dN for processor board signal - "Rejection Voltage" + LABLAXIS: Voltage + UNITS: dN + +detector_current: + <<: *trigger_base + VALIDMAX: 4095 + FIELDNAM: Detector Current + CATDESC: Last measurement in raw dN for processor board signal - "Detector Current " + LABLAXIS: Current + UNITS: dN \ No newline at end of file diff --git a/imap_processing/cli.py b/imap_processing/cli.py index b872a2827..80b1989fd 100644 --- a/imap_processing/cli.py +++ b/imap_processing/cli.py @@ -43,7 +43,7 @@ from imap_processing.hi.l1c import hi_l1c from imap_processing.hit.l1a.hit_l1a import hit_l1a from imap_processing.hit.l1b.hit_l1b import hit_l1b -from imap_processing.idex.idex_packet_parser import PacketParser +from imap_processing.idex.l1.idex_l1 import PacketParser from imap_processing.lo.l1a import lo_l1a from imap_processing.lo.l1b import lo_l1b from imap_processing.lo.l1c import lo_l1c diff --git a/imap_processing/idex/idex_cdf_attrs.py b/imap_processing/idex/idex_cdf_attrs.py deleted file mode 100644 index 5935beb50..000000000 --- a/imap_processing/idex/idex_cdf_attrs.py +++ /dev/null @@ -1,184 +0,0 @@ -"""Contains CDF attribute definitions for IDEX.""" - -import dataclasses - -from imap_processing.cdf.defaults import GlobalConstants -from imap_processing.cdf.global_attrs import ( - FloatAttrs, - GlobalDataLevelAttrs, - GlobalInstrumentAttrs, - ScienceAttrs, -) -from imap_processing.idex import __version__ -from imap_processing.idex.idex_constants import IdexConstants - -# Global Attributes -text = ( - "The Interstellar Dust Experiment (IDEX) is a time-of-flight (TOF) " - "dust impact ionization mass spectrometer on the IMAP mission that " - "provides the elemental composition, speed, and mass distributions " - "of interstellar dust and interplanetary dust particles. Each record " - "contains the data from a single dust impact. See " - "https://imap.princeton.edu/instruments/idex for more details." -) - -idex_base = GlobalInstrumentAttrs( - __version__, "IDEX>Interstellar Dust Experiment", text -) - -idex_l1_global_attrs = GlobalDataLevelAttrs( - "L1_SCI>Level-1 Science Data", - "imap_idex_l1_sci", - "IMAP Mission IDEX Instrument Level-1 Data.", - idex_base, -) - -idex_l2_global_attrs = GlobalDataLevelAttrs( - "L2_SCI>Level-2 Science Data", - "imap_idex_l2_sci", - "IMAP Mission IDEX Instrument Level-2 Data", - idex_base, -) - -l1_data_base = ScienceAttrs( - IdexConstants.DATA_MIN, - IdexConstants.DATA_MAX, - display_type="spectrogram", - depend_0="epoch", - format="I12", - units="dN", - var_type="data", - variable_purpose="PRIMARY", -) - -# L1 variables base dictionaries -# (these need to be filled in by the variable dictionaries below) -l1_tof_base = dataclasses.replace(l1_data_base, depend_1="Time_High_SR") -l1_target_base = dataclasses.replace(l1_data_base, depend_1="Time_Low_SR") - -sample_rate_base = FloatAttrs( - IdexConstants.SAMPLE_RATE_MIN, - IdexConstants.SAMPLE_RATE_MAX, - depend_0="epoch", - format="F12.5", - label_axis="Time", - units="microseconds", - var_notes=( - "The number of microseconds since the event. " - "0 is the start of data collection, negative " - "numbers represent data collected prior to a dust event" - ), -) - -# TODO: is "VALIDMAX" not required here? Added INT_MAXVAL, incl the existing CDF for ref -trigger_base = ScienceAttrs( - 0, - GlobalConstants.INT_MAXVAL, - depend_0="epoch", - format="I12", - var_type="data", - display_type="no_plot", -) -# { -# "DEPEND_0": "epoch", -# "FILLVAL": Constants.INT_FILLVAL, -# "FORMAT": "I12", -# "VALIDMIN": 0, # All values are positive integers or 0 by design -# "VAR_TYPE": "data", -# "DISPLAY_TYPE": "no_plot", -# } - -# L1 Attribute Dictionaries -low_sr_attrs = dataclasses.replace( - sample_rate_base, - catdesc="Low sample rate time steps for a dust " "event.", - fieldname="Low Sample Rate Time", - var_notes=( - "The low sample rate in microseconds. Steps are approximately 1/4.025 " - "microseconds in duration. Used by the Ion_Grid, Target_Low, and " - "Target_High variables." - ), -) - -high_sr_attrs = dataclasses.replace( - sample_rate_base, - catdesc="High sample rate time steps for a dust event.", - fieldname="High Sample Rate Time", - var_notes=( - "The high sample rate in microseconds. Steps are approximately 1/260 " - "microseconds in duration. Used by the TOF_High, TOF_Mid, and " - "TOF_Low variables." - ), -) - -tof_high_attrs = dataclasses.replace( - l1_tof_base, - catdesc="Time of flight waveform on the high-gain channel", - fieldname="High Gain Time of Flight", - label_axis="TOF High Ampl.", - var_notes=( - "High gain channel of the time-of-flight signal. " - "Sampled at 260 Megasamples per second, with a 10-bit resolution. " - "Data is used to quantify dust composition." - ), -) - -tof_mid_attrs = dataclasses.replace( - l1_tof_base, - catdesc="Time of flight waveform on the mid-gain channel", - fieldname="Mid Gain Time of Flight", - label_axis="TOF Mid Ampl.", - var_notes=( - "Mid gain channel of the time-of-flight signal. " - "Sampled at 260 Megasamples per second, with a 10-bit resolution. " - "Data is used to quantify dust composition." - ), -) - -tof_low_attrs = dataclasses.replace( - l1_tof_base, - catdesc="Time of flight waveform on the low-gain channel", - fieldname="Low Gain Time of Flight", - label_axis="TOF Low Ampl.", - var_notes=( - "Low gain channel of the time-of-flight signal. " - "Sampled at 260 Megasamples per second, with a 10-bit resolution. " - "Data is used to quantify dust composition." - ), -) - -target_low_attrs = dataclasses.replace( - l1_target_base, - catdesc="Target low charge sensitive amplifier waveform", - fieldname="Low Target Signal", - label_axis="Low Target Ampl.", - var_notes=( - "Low gain channel of IDEX's target signal. " - "Sampled at 3.75 Msps with 12-bit resolution. " - "Data is used to quantify dust charge. " - ), -) - -target_high_attrs = dataclasses.replace( - l1_target_base, - catdesc="Ion grid charge sensitive amplifier waveform", - fieldname="High Target Signal", - label_axis="High Target Ampl.", - var_notes=( - "High gain channel of IDEX's target signal. " - "Sampled at 3.75 Msps with 12-bit resolution. " - "Data is used to quantify dust charge." - ), -) - -ion_grid_attrs = dataclasses.replace( - l1_target_base, - catdesc="Ion grid charge sensitive amplifier waveform data", - fieldname="Ion Grid Signal", - label_axis="Ion Grid Ampl.", - var_notes=( - "This is the ion grid signal from IDEX. " - "Sampled at 3.75 Msps with 12-bit resolution. " - "Data is used to quantify dust charge." - ), -) diff --git a/imap_processing/idex/l0/__init__.py b/imap_processing/idex/l0/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/imap_processing/idex/l0/idex_l0.py b/imap_processing/idex/l0/idex_l0.py new file mode 100644 index 000000000..9b21f134e --- /dev/null +++ b/imap_processing/idex/l0/idex_l0.py @@ -0,0 +1,29 @@ +"""Decommutate IDEX CCSDS packets.""" + +import logging + +from imap_processing import decom, imap_module_directory + +logger = logging.getLogger(__name__) + + +def decom_packets(packet_file: str) -> list: + """ + Decom IDEX data packets using IDEX packet definition. + + Parameters + ---------- + packet_file : str + String to data packet path with filename. + + Returns + ------- + list + All the unpacked data. + """ + xtce_filename = "idex_packet_definition.xml" + xtce_file = f"{imap_module_directory}/idex/packet_definitions/{xtce_filename}" + + decom_packet_list = decom.decom_packets(packet_file, xtce_file) + + return list(decom_packet_list) diff --git a/imap_processing/idex/l1/__init__.py b/imap_processing/idex/l1/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/imap_processing/idex/idex_packet_parser.py b/imap_processing/idex/l1/idex_l1.py similarity index 50% rename from imap_processing/idex/idex_packet_parser.py rename to imap_processing/idex/l1/idex_l1.py index f43d46e2b..cde3f1a40 100644 --- a/imap_processing/idex/idex_packet_parser.py +++ b/imap_processing/idex/l1/idex_l1.py @@ -1,11 +1,9 @@ """ -Decommutate IDEX CCSDS packets. +Perform IDEX l1 Processing. -This module contains code to decommutate IDEX packets and creates xarrays to -support creation of L1 data products. +This module processes decommutated IDEX packets and creates l1 data products. """ -import dataclasses import logging from collections import namedtuple from enum import IntEnum @@ -13,12 +11,10 @@ import numpy as np import space_packet_parser import xarray as xr -from space_packet_parser import parser, xtcedef -from imap_processing import imap_module_directory -from imap_processing.cdf.global_attrs import ConstantCoordinates +from imap_processing.cdf.imap_cdf_manager import ImapCdfAttributes from imap_processing.cdf.utils import met_to_j2000ns -from imap_processing.idex import idex_cdf_attrs +from imap_processing.idex.l0.idex_l0 import decom_packets logger = logging.getLogger(__name__) @@ -45,418 +41,70 @@ class Scitype(IntEnum): """ TriggerDescription = namedtuple( "TriggerDescription", - ["name", "packet_name", "num_bits", "field", "notes", "label", "units"], + ["name", "packet_name"], ) trigger_description_dict = { trigger.name: trigger for trigger in [ - TriggerDescription( - "event_number", - "IDX__TXHDREVTNUM", - 16, - "Event Number", - "The unique number assigned to the impact by the FPGA", - "Event #", - "", - ), - TriggerDescription( - "tof_high_trigger_level", - "IDX__TXHDRHGTRIGLVL", - 10, - "TOF High Trigger Level", - "Trigger level for the TOF High Channel", - "Level", - "", - ), - TriggerDescription( - "tof_high_trigger_num_max_1_2", - "IDX__TXHDRHGTRIGNMAX12", - 11, - "TOF High Double Pulse Max Samples", - ( - "Maximum number of samples between pulse 1 and 2 for TOF " - "High double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_high_trigger_num_min_1_2", - "IDX__TXHDRHGTRIGNMIN12", - 11, - "TOF High Double Pulse Min Samples", - ( - "Minimum number of samples between pulse 1 and 2 for TOF High " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_high_trigger_num_min_1", - "IDX__TXHDRHGTRIGNMIN1", - 8, - "TOF High Pulse 1 Min Samples", - ( - "Minimum number of samples for pulse 1 for TOF High single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_high_trigger_num_max_1", - "IDX__TXHDRHGTRIGNMAX1", - 8, - "TOF High Pulse 1 Max Samples", - ( - "Maximum number of samples for pulse 1 for TOF High single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_high_trigger_num_min_2", - "IDX__TXHDRHGTRIGNMIN2", - 8, - "TOF High Pulse 2 Min Samples", - ( - "Minimum number of samples for pulse 2 for TOF High single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_high_trigger_num_max_2", - "IDX__TXHDRHGTRIGNMAX2", - 8, - "TOF High Pulse 2 Max Samples", - ( - "Maximum number of samples for pulse 2 for TOF High single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_low_trigger_level", - "IDX__TXHDRLGTRIGLVL", - 10, - "TOF Low Trigger Level", - "Trigger level for the TOF Low Channel", - "Level", - "samples", - ), - TriggerDescription( - "tof_low_trigger_num_max_1_2", - "IDX__TXHDRLGTRIGNMAX12", - 11, - "TOF Low Double Pulse Max Samples", - ( - "Maximum number of samples between pulse 1 and 2 for TOF Low " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_low_trigger_num_min_1_2", - "IDX__TXHDRLGTRIGNMIN12", - 11, - "TOF Low Double Pulse Min Samples", - ( - "Minimum number of samples between pulse 1 and 2 for TOF Low " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_low_trigger_num_min_1", - "IDX__TXHDRLGTRIGNMIN1", - 8, - "TOF Low Pulse 1 Min Samples", - ( - "Minimum number of samples for pulse 1 for TOF Low single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_low_trigger_num_max_1", - "IDX__TXHDRLGTRIGNMAX1", - 8, - "TOF Low Pulse 1 Max Samples", - ( - "Maximum number of samples for pulse 1 for TOF Low single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_low_trigger_num_min_2", - "IDX__TXHDRLGTRIGNMIN2", - 8, - "TOF Low Pulse 2 Min Samples", - ( - "Minimum number of samples for pulse 2 for TOF Low single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_low_trigger_num_max_2", - "IDX__TXHDRLGTRIGNMAX2", - 16, - "TOF Low Pulse 2 Max Samples", - ( - "Maximum number of samples for pulse 2 for TOF Low single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_mid_trigger_level", - "IDX__TXHDRMGTRIGLVL", - 10, - "TOF Mid Trigger Level", - "Trigger level for the TOF Mid Channel", - "Level", - "# Samples", - ), - TriggerDescription( - "tof_mid_trigger_num_max_1_2", - "IDX__TXHDRMGTRIGNMAX12", - 11, - "TOF Mid Double Pulse Max Samples", - ( - "Maximum number of samples between pulse 1 and 2 for TOF Mid " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_mid_trigger_num_min_1_2", - "IDX__TXHDRMGTRIGNMIN12", - 11, - "TOF Mid Double Pulse Min Samples", - ( - "Minimum number of samples between pulse 1 and 2 for TOF Mid " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_mid_trigger_num_min_1", - "IDX__TXHDRMGTRIGNMIN1", - 8, - "TOF Mid Pulse 1 Min Samples", - ( - "Minimum number of samples for pulse 1 for TOF Mid single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_mid_trigger_num_max_1", - "IDX__TXHDRMGTRIGNMAX1", - 8, - "TOF Mid Pulse 1 Max Samples", - ( - "Maximum number of samples for pulse 1 for TOF Mid single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_mid_trigger_num_min_2", - "IDX__TXHDRMGTRIGNMIN2", - 8, - "TOF Mid Pulse 2 Min Samples", - ( - "Minimum number of samples for pulse 2 for TOF Mid single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "tof_mid_trigger_num_max_2", - "IDX__TXHDRMGTRIGNMAX2", - 8, - "TOF Mid Pulse 2 Max Samples", - ( - "Maximum number of samples for pulse 2 for TOF Mid single and " - "double pulse triggering" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "low_sample_coincidence_mode_blocks", - "IDX__TXHDRLSTRIGCMBLOCKS", - 3, - "LS Coincidence Mode Blocks", - ( - "Number of blocks coincidence window is enabled after " - "low sample trigger" - ), - "# Blocks", - "Blocks", - ), - TriggerDescription( - "low_sample_trigger_polarity", - "IDX__TXHDRLSTRIGPOL", - 1, - "LS Trigger Polarity", - "The trigger polarity for low sample (0 = normal, 1 = inverted) ", - "Polarity", - "", - ), - TriggerDescription( - "low_sample_trigger_level", - "IDX__TXHDRLSTRIGLVL", - 12, - "LS Trigger Level", - "Trigger level for the low sample", - "Level", - "", - ), - TriggerDescription( - "low_sample_trigger_num_min", - "IDX__TXHDRLSTRIGNMIN", - 8, - "LS Trigger Min Num Samples", - ( - "The minimum number of samples above/below the trigger level for " - "triggering the low sample" - ), - "# Samples", - "samples", - ), - TriggerDescription( - "low_sample_trigger_mode", - "IDX__TXHDRLSTRIGMODE", - 1, - "LS Trigger Mode Enabled", - "Low sample trigger mode (0=disabled, 1=enabled)", - "Mode", - "", - ), - TriggerDescription( - "tof_low_trigger_mode", - "IDX__TXHDRLSTRIGMODE", - 1, - "TOF Low Trigger Mode Enabled", - "TOF Low trigger mode (0=disabled, 1=enabled)", - "Mode", - "", - ), - TriggerDescription( - "tof_mid_trigger_mode", - "IDX__TXHDRMGTRIGMODE", - 1, - "TOF Mid Trigger Mode Enabled", - "TOF Mid trigger mode (0=disabled, 1=enabled)", - "Mode", - "", - ), - TriggerDescription( - "tof_high_trigger_mode", - "IDX__TXHDRHGTRIGMODE", - 2, - "TOF High Trigger Mode Enabled", - ( - "TOF High trigger mode (0=disabled, 1=threshold mode, " - "2=single pulse mode, 3=double pulse mode)" - ), - "Mode", - "", - ), - TriggerDescription( - "detector_voltage", - "IDX__TXHDRHVPSHKCH0", - 12, - "Detector Voltage", - ( - "Last measurement in raw dN for processor board signal: " - "Detector Voltage" - ), - "Voltage", - "dN", - ), - TriggerDescription( - "sensor_voltage", - "IDX__TXHDRHVPSHKCH1", - 12, - "Sensor Voltage", - ( - "Last measurement in raw dN for processor board signal: " - "Sensor Voltage " - ), - "Voltage", - "dN", - ), - TriggerDescription( - "target_voltage", - "IDX__TXHDRHVPSHKCH2", - 12, - "Target Voltage", - ( - "Last measurement in raw dN for processor board signal: " - "Target Voltage" - ), - "Voltage", - "dN", - ), - TriggerDescription( - "reflectron_voltage", - "IDX__TXHDRHVPSHKCH3", - 12, - "Reflectron Voltage", - ( - "Last measurement in raw dN for processor board signal: " - "Reflectron Voltage" - ), - "Voltage", - "dN", - ), - TriggerDescription( - "rejection_voltage", - "IDX__TXHDRHVPSHKCH4", - 12, - "Rejection Voltage", - ( - "Last measurement in raw dN for processor board signal: " - "Rejection Voltage" - ), - "Voltage", - "dN", - ), - TriggerDescription( - "detector_current", - "IDX__TXHDRHVPSHKCH5", - 12, - "Detector Current", - ( - "Last measurement in raw dN for processor board signal: " - "Detector Current " - ), - "Current", - "dN", - ), + TriggerDescription("event_number", "IDX__TXHDREVTNUM"), + TriggerDescription("tof_high_trigger_level", "IDX__TXHDRHGTRIGLVL"), + TriggerDescription("tof_high_trigger_num_max_1_2", "IDX__TXHDRHGTRIGNMAX12"), + TriggerDescription("tof_high_trigger_num_min_1_2", "IDX__TXHDRHGTRIGNMIN12"), + TriggerDescription("tof_high_trigger_num_min_1", "IDX__TXHDRHGTRIGNMIN1"), + TriggerDescription("tof_high_trigger_num_max_1", "IDX__TXHDRHGTRIGNMAX1"), + TriggerDescription("tof_high_trigger_num_min_2", "IDX__TXHDRHGTRIGNMIN2"), + TriggerDescription("tof_high_trigger_num_max_2", "IDX__TXHDRHGTRIGNMAX2"), + TriggerDescription("tof_low_trigger_level", "IDX__TXHDRLGTRIGLVL"), + TriggerDescription("tof_low_trigger_num_max_1_2", "IDX__TXHDRLGTRIGNMAX12"), + TriggerDescription("tof_low_trigger_num_min_1_2", "IDX__TXHDRLGTRIGNMIN12"), + TriggerDescription("tof_low_trigger_num_min_1", "IDX__TXHDRLGTRIGNMIN1"), + TriggerDescription("tof_low_trigger_num_max_1", "IDX__TXHDRLGTRIGNMAX1"), + TriggerDescription("tof_low_trigger_num_min_2", "IDX__TXHDRLGTRIGNMIN2"), + TriggerDescription("tof_low_trigger_num_max_2", "IDX__TXHDRLGTRIGNMAX2"), + TriggerDescription("tof_mid_trigger_level", "IDX__TXHDRMGTRIGLVL"), + TriggerDescription("tof_mid_trigger_num_max_1_2", "IDX__TXHDRMGTRIGNMAX12"), + TriggerDescription("tof_mid_trigger_num_min_1_2", "IDX__TXHDRMGTRIGNMIN12"), + TriggerDescription("tof_mid_trigger_num_min_1", "IDX__TXHDRMGTRIGNMIN1"), + TriggerDescription("tof_mid_trigger_num_max_1", "IDX__TXHDRMGTRIGNMAX1"), + TriggerDescription("tof_mid_trigger_num_min_2", "IDX__TXHDRMGTRIGNMIN2"), + TriggerDescription("tof_mid_trigger_num_max_2", "IDX__TXHDRMGTRIGNMAX2"), + TriggerDescription("low_sample_coincidence_mode_blocks", "IDX__TXHDRLSTRIGCMBLOCKS"), # noqa + TriggerDescription("low_sample_trigger_polarity", "IDX__TXHDRLSTRIGPOL"), + TriggerDescription("low_sample_trigger_level", "IDX__TXHDRLSTRIGLVL"), + TriggerDescription("low_sample_trigger_num_min", "IDX__TXHDRLSTRIGNMIN"), + TriggerDescription("low_sample_trigger_mode", "IDX__TXHDRLSTRIGMODE"), + TriggerDescription("tof_low_trigger_mode", "IDX__TXHDRLSTRIGMODE"), + TriggerDescription("tof_mid_trigger_mode", "IDX__TXHDRMGTRIGMODE"), + TriggerDescription("tof_high_trigger_mode", "IDX__TXHDRHGTRIGMODE"), + TriggerDescription("detector_voltage", "IDX__TXHDRHVPSHKCH0"), + TriggerDescription("sensor_voltage", "IDX__TXHDRHVPSHKCH1"), + TriggerDescription("target_voltage", "IDX__TXHDRHVPSHKCH2"), + TriggerDescription("reflectron_voltage", "IDX__TXHDRHVPSHKCH3"), + TriggerDescription("rejection_voltage", "IDX__TXHDRHVPSHKCH4"), + TriggerDescription("detector_current", "IDX__TXHDRHVPSHKCH5"), ] -} +} # fmt: skip + + +def get_idex_attrs(data_version: str) -> ImapCdfAttributes: + """ + Load in CDF attributes for IDEX instrument. + + Parameters + ---------- + data_version : str + Data version for CDF filename, in the format "vXXX". + + Returns + ------- + idex_attrs : ImapCdfAttributes + Imap object with l1a attribute files loaded in. + """ + idex_attrs = ImapCdfAttributes() + idex_attrs.add_instrument_global_attrs("idex") + idex_attrs.add_instrument_variable_attrs("idex", "l1") + idex_attrs.add_global_attribute("Data_version", data_version) + return idex_attrs class PacketParser: @@ -484,7 +132,7 @@ class PacketParser: from imap_processing.idex.idex_packet_parser import PacketParser l0_file = "imap_processing/tests/idex/imap_idex_l0_sci_20230725_v001.pkts" - l1_data = PacketParser(l0_file) + l1_data = PacketParser(l0_file, data_version) l1_data.write_l1_cdf() """ @@ -503,40 +151,35 @@ def __init__(self, packet_file: str, data_version: str) -> None: ----- Currently assumes one L0 file will generate exactly one l1a file. """ - xtce_filename = "idex_packet_definition.xml" - xtce_file = f"{imap_module_directory}/idex/packet_definitions/{xtce_filename}" - packet_definition = xtcedef.XtcePacketDefinition(xtce_document=xtce_file) - packet_parser = parser.PacketParser(packet_definition) + decom_packet_list = decom_packets(packet_file) dust_events = {} - with open(packet_file, "rb") as binary_data: - packet_generator = packet_parser.generator(binary_data) - for packet in packet_generator: - if "IDX__SCI0TYPE" in packet.data: - scitype = packet.data["IDX__SCI0TYPE"].raw_value - event_number = packet.data["IDX__SCI0EVTNUM"].derived_value - if scitype == Scitype.FIRST_PACKET: - # Initial packet for new dust event - # Further packets will fill in data - dust_events[event_number] = RawDustEvent(packet) - elif event_number not in dust_events: - raise KeyError( - f"Have not receive header information from event number\ - {event_number}. Packets are possibly out of order!" - ) - else: - # Populate the IDEXRawDustEvent with 1's and 0's - dust_events[event_number].parse_packet(packet) + for packet in decom_packet_list: + if "IDX__SCI0TYPE" in packet.data: + scitype = packet.data["IDX__SCI0TYPE"].raw_value + event_number = packet.data["IDX__SCI0EVTNUM"].derived_value + if scitype == Scitype.FIRST_PACKET: + # Initial packet for new dust event + # Further packets will fill in data + dust_events[event_number] = RawDustEvent(packet, data_version) + elif event_number not in dust_events: + raise KeyError( + f"Have not receive header information from event number\ + {event_number}. Packets are possibly out of order!" + ) else: - logger.warning(f"Unhandled packet received: {packet}") + # Populate the IDEXRawDustEvent with 1's and 0's + dust_events[event_number].parse_packet(packet) + else: + logger.warning(f"Unhandled packet received: {packet}") processed_dust_impact_list = [ dust_event.process() for dust_event in dust_events.values() ] self.data = xr.concat(processed_dust_impact_list, dim="epoch") - self.data.attrs = idex_cdf_attrs.idex_l1_global_attrs.output() - self.data.attrs["Data_version"] = data_version + idex_attrs = get_idex_attrs(data_version) + self.data.attrs = idex_attrs.get_global_attributes("imap_idex_l1_sci") class RawDustEvent: @@ -550,6 +193,8 @@ class RawDustEvent: ---------- header_packet : space_packet_parser.parser.Packet The FPGA metadata event header. + data_version : str + The version of the data product being created. Attributes ---------- @@ -585,7 +230,9 @@ class RawDustEvent: 512 # The number of samples in a "block" of high sample data ) - def __init__(self, header_packet: space_packet_parser.parser.Packet) -> None: + def __init__( + self, header_packet: space_packet_parser.parser.Packet, data_version: str + ) -> None: """ Initialize a raw dust event, with an FPGA Header Packet from IDEX. @@ -599,6 +246,8 @@ def __init__(self, header_packet: space_packet_parser.parser.Packet) -> None: ---------- header_packet : space_packet_parser.parser.Packet The FPGA metadata event header. + data_version : str + Data version for CDF filename, in the format "vXXX". """ # Calculate the impact time in seconds since epoch self.impact_time = 0 @@ -626,6 +275,8 @@ def __init__(self, header_packet: space_packet_parser.parser.Packet) -> None: self.Target_High_bits = "" self.Ion_Grid_bits = "" + self.cdf_attrs = get_idex_attrs(data_version) + def _set_impact_time(self, packet: space_packet_parser.parser.Packet) -> None: """ Calculate the datetime64 from the FPGA header information. @@ -878,6 +529,9 @@ def process(self) -> xr.Dataset: xarray.Dataset A Dataset object containing the data from a single impact. """ + # Create object for CDF attrs + idex_attrs = self.cdf_attrs + # Gather the huge number of trigger info metadata trigger_vars = {} for var, value in self.trigger_values.items(): @@ -886,53 +540,51 @@ def process(self) -> xr.Dataset: name=var, data=[value], dims=("epoch"), - attrs=dataclasses.replace( - idex_cdf_attrs.trigger_base, - catdesc=trigger_description.notes, - fieldname=trigger_description.field, - var_notes=trigger_description.notes, - validmax=2**trigger_description.num_bits - 1, - label_axis=trigger_description.label, - units=trigger_description.units, - ).output(), + attrs=idex_attrs.get_variable_attributes(trigger_description.name), ) # Process the 6 primary data variables tof_high_xr = xr.DataArray( name="TOF_High", data=[self._parse_high_sample_waveform(self.TOF_High_bits)], - dims=("epoch", "Time_High_SR_dim"), - attrs=idex_cdf_attrs.tof_high_attrs.output(), + dims=("epoch", "time_high_ssr_dim"), + # attrs=idex_cdf_attrs.tof_high_attrs.output(), + attrs=idex_attrs.get_variable_attributes("tof_high_attrs"), ) tof_low_xr = xr.DataArray( name="TOF_Low", data=[self._parse_high_sample_waveform(self.TOF_Low_bits)], - dims=("epoch", "Time_High_SR_dim"), - attrs=idex_cdf_attrs.tof_low_attrs.output(), + dims=("epoch", "time_high_sr"), + # attrs=idex_cdf_attrs.tof_low_attrs.output(), + attrs=idex_attrs.get_variable_attributes("tof_low_attrs"), ) tof_mid_xr = xr.DataArray( name="TOF_Mid", data=[self._parse_high_sample_waveform(self.TOF_Mid_bits)], - dims=("epoch", "Time_High_SR_dim"), - attrs=idex_cdf_attrs.tof_mid_attrs.output(), + dims=("epoch", "time_high_sr"), + # attrs=idex_cdf_attrs.tof_mid_attrs.output(), + attrs=idex_attrs.get_variable_attributes("tof_mid_attrs"), ) target_high_xr = xr.DataArray( name="Target_High", data=[self._parse_low_sample_waveform(self.Target_High_bits)], - dims=("epoch", "Time_Low_SR_dim"), - attrs=idex_cdf_attrs.target_high_attrs.output(), + dims=("epoch", "time_low_sr"), + # attrs=idex_cdf_attrs.target_high_attrs.output(), + attrs=idex_attrs.get_variable_attributes("target_high_attrs"), ) target_low_xr = xr.DataArray( name="Target_Low", data=[self._parse_low_sample_waveform(self.Target_Low_bits)], - dims=("epoch", "Time_Low_SR_dim"), - attrs=idex_cdf_attrs.target_low_attrs.output(), + dims=("epoch", "time_low_sr"), + # attrs=idex_cdf_attrs.target_low_attrs.output(), + attrs=idex_attrs.get_variable_attributes("target_low_attrs"), ) ion_grid_xr = xr.DataArray( name="Ion_Grid", data=[self._parse_low_sample_waveform(self.Ion_Grid_bits)], - dims=("epoch", "Time_Low_SR_dim"), - attrs=idex_cdf_attrs.ion_grid_attrs.output(), + dims=("epoch", "time_low_sr"), + # attrs=idex_cdf_attrs.ion_grid_attrs.output(), + attrs=idex_attrs.get_variable_attributes("ion_grid_attrs"), ) # Determine the 3 coordinate variables @@ -940,21 +592,24 @@ def process(self) -> xr.Dataset: name="epoch", data=[self.impact_time], dims=("epoch"), - attrs=ConstantCoordinates.EPOCH, + # attrs=ConstantCoordinates.EPOCH, + attrs=idex_attrs.get_variable_attributes("epoch"), ) time_low_sr_xr = xr.DataArray( - name="Time_Low_SR", + name="time_low_sr", data=[self._calc_low_sample_resolution(len(target_low_xr[0]))], - dims=("epoch", "Time_Low_SR_dim"), - attrs=idex_cdf_attrs.low_sr_attrs.output(), + dims=("epoch", "time_low_sr_dim"), + # attrs=idex_cdf_attrs.low_sr_attrs.output(), + attrs=idex_attrs.get_variable_attributes("low_sr_attrs"), ) time_high_sr_xr = xr.DataArray( - name="Time_High_SR", + name="time_high_sr", data=[self._calc_high_sample_resolution(len(tof_low_xr[0]))], - dims=("epoch", "Time_High_SR_dim"), - attrs=idex_cdf_attrs.high_sr_attrs.output(), + dims=("epoch", "time_high_sr_dim"), + # attrs=idex_cdf_attrs.high_sr_attrs.output(), + attrs=idex_attrs.get_variable_attributes("high_sr_attrs"), ) # Combine to return a dataset object @@ -970,7 +625,7 @@ def process(self) -> xr.Dataset: | trigger_vars, coords={ "epoch": epoch_xr, - "Time_Low_SR": time_low_sr_xr, - "Time_High_SR": time_high_sr_xr, + "time_low_sr": time_low_sr_xr, + "time_high_sr": time_high_sr_xr, }, ) diff --git a/imap_processing/tests/idex/test_decom.py b/imap_processing/tests/idex/test_idex_l0.py similarity index 94% rename from imap_processing/tests/idex/test_decom.py rename to imap_processing/tests/idex/test_idex_l0.py index 758f207ce..3309be7e8 100644 --- a/imap_processing/tests/idex/test_decom.py +++ b/imap_processing/tests/idex/test_idex_l0.py @@ -6,7 +6,7 @@ import pytest from imap_processing import imap_module_directory -from imap_processing.idex.idex_packet_parser import PacketParser +from imap_processing.idex.l1.idex_l1 import PacketParser @pytest.fixture(scope="session") diff --git a/imap_processing/tests/idex/test_l1_cdfs.py b/imap_processing/tests/idex/test_idex_l1.py similarity index 97% rename from imap_processing/tests/idex/test_l1_cdfs.py rename to imap_processing/tests/idex/test_idex_l1.py index a5488b6e7..0a7463a56 100644 --- a/imap_processing/tests/idex/test_l1_cdfs.py +++ b/imap_processing/tests/idex/test_idex_l1.py @@ -9,7 +9,7 @@ from imap_processing import imap_module_directory from imap_processing.cdf.utils import load_cdf, write_cdf -from imap_processing.idex.idex_packet_parser import PacketParser +from imap_processing.idex.l1.idex_l1 import PacketParser @pytest.fixture()