Skip to content
Draft
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
15 changes: 10 additions & 5 deletions imap_processing/cdf/config/imap_glows_l1a_variable_attrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,19 @@ histogram:
VAR_TYPE: data

pkts_file_name:
<<: *support_data_defaults
CATDESC: Name of input file with CCSDS packets data
DISPLAY_TYPE: no_plot
FIELDNAM: Packets-data input filename
FILLVAL: # TBD: what is fillval for strings?
FORMAT: S256 # TBC
LABLAXIS: File name
FILLVAL: " "
FORMAT: A49
VAR_TYPE: metadata

ground_software_version:
CATDESC: Version of ground software used for processing
DISPLAY_TYPE: no_plot
FIELDNAM: Ground Software Version
FILLVAL: " "
FORMAT: A4
VAR_TYPE: metadata

first_spin_id:
Expand Down Expand Up @@ -504,7 +510,6 @@ missing_packets_sequence: # Used to be missing_packets_sequence
VAR_TYPE: metadata

flight_software_version:
<<: *support_data_defaults
CATDESC: GLOWS flight software version
FIELDNAM: GLOWS flight software version
FILLVAL: *max_uint32
Expand Down
21 changes: 12 additions & 9 deletions imap_processing/cdf/config/imap_glows_l1b_variable_attrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,11 @@ histogram:
VAR_TYPE: data

pkts_file_name:
<<: *support_data_defaults
CATDESC: Name of input file with L0 CCSDS packets data
CATDESC: Name of input file with CCSDS packet data
DISPLAY_TYPE: no_plot
FIELDNAM: L0 data input filename
FILLVAL: # TBD: what is fillval for strings?
FORMAT: S256 # TBC
LABLAXIS: File name # MS: is this needed for no_plot?
VALIDMAX: # TBD: what is validmax for a string?
VALIDMIN: # TBD: what is validmin for a string?
FIELDNAM: CCSDS packet data input filename
FILLVAL: " "
FORMAT: A49
VAR_TYPE: metadata

first_spin_id:
Expand Down Expand Up @@ -690,14 +686,21 @@ missing_packets_sequence: # Used to be missing_packets_sequence
VAR_TYPE: metadata

flight_software_version:
<<: *support_data_defaults
CATDESC: GLOWS flight software version
FIELDNAM: GLOWS flight software version
FILLVAL: *max_uint32
FORMAT: I8
LABLAXIS: FSW ver
VALIDMAX: 16777215

ground_software_version:
CATDESC: Version of ground software used for processing
DISPLAY_TYPE: no_plot
FIELDNAM: Ground Software Version
FILLVAL: " "
FORMAT: A4
VAR_TYPE: metadata

# Flags
# MS: this needs to be thoroughly discussed
bad_time_flag_hist_attrs: # MS: this should be different for DE and HIST
Expand Down
16 changes: 16 additions & 0 deletions imap_processing/cdf/config/imap_glows_l2_variable_attrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ identifier:
VALIDMAX: 99999
DICT_KEY: SPASE>Support>SupportQuantity:Temporal

flight_software_version:
<<: *support_data_defaults
CATDESC: GLOWS flight software version
FIELDNAM: GLOWS flight software version
FILLVAL: *max_uint32
FORMAT: I8
LABLAXIS: FSW ver
VALIDMAX: 16777215

pkts_file_name:
VAR_TYPE: metadata
CATDESC: Name of L0 packets file data originated
FIELDNAM: Packets File Name
FILLVAL: ' '
FORMAT: A49

start_time:
<<: *time_data_defaults
CATDESC: Start time (UTC) of observational day
Expand Down
29 changes: 27 additions & 2 deletions imap_processing/glows/l1a/glows_l1a.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def generate_de_dataset(

# First variable is the output data type, second is the list of values
support_data: dict = {
# "flight_software_version": [],
"seq_count_in_pkts_file": [np.uint16, []],
"number_of_de_packets": [np.uint32, []],
}
Expand Down Expand Up @@ -337,7 +336,6 @@ def generate_histogram_dataset(

# First variable is the output data type, second is the list of values
support_data: dict = {
"flight_software_version": [np.uint32, []],
"seq_count_in_pkts_file": [np.uint16, []],
"first_spin_id": [np.uint32, []],
"last_spin_id": [np.uint32, []],
Expand Down Expand Up @@ -428,6 +426,33 @@ def generate_histogram_dataset(

output["histogram"] = hist

# These attributes are the same for each record, so we don't
# need to store them per epoch like most of the other fields
output["flight_software_version"] = xr.DataArray(
np.array([hist_l1a_list[0].flight_software_version], dtype=np.uint32),
name="flight_software_version",
dims=["scalar"],
attrs=glows_cdf_attributes.get_variable_attributes(
"flight_software_version", check_schema=False
),
)
output["pkts_file_name"] = xr.DataArray(
np.array([hist_l1a_list[0].pkts_file_name], dtype=object),
name="pkts_file_name",
dims=["scalar"],
attrs=glows_cdf_attributes.get_variable_attributes(
"pkts_file_name", check_schema=False
),
)
output["ground_software_version"] = xr.DataArray(
np.array([hist_l1a_list[0].ground_software_version], dtype=object),
name="ground_software_version",
dims=["scalar"],
attrs=glows_cdf_attributes.get_variable_attributes(
"ground_software_version", check_schema=False
),
)

for key, value in support_data.items():
output[key] = xr.DataArray(
np.array(value[1], dtype=value[0]),
Expand Down
12 changes: 6 additions & 6 deletions imap_processing/glows/l1a/glows_l1a_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ class HistogramL1A:

l0: InitVar[HistogramL0]
histogram: list[int] = field(init=False)
# next four are in block header
flight_software_version: int = field(init=False)
ground_software_version: str = field(init=False)
pkts_file_name: str = field(init=False)
pkts_file_name: str = ""
ground_software_version: str = ""
# next four are in block header
seq_count_in_pkts_file: int = field(init=False)
first_spin_id: int = field(init=False)
last_spin_id: int = field(init=False)
Expand Down Expand Up @@ -383,7 +383,7 @@ def merge_de_packets(self, second_l0: DirectEventL0) -> None:
raise ValueError(
f"Sequence for direct event L1A is out of order or "
f"incorrect. Attempted to append sequence counter "
f"{second_l0.SEQ} after {self.most_recent_seq}."
f"{second_l0.SEQ} after {self.most_recent_seq}. "
f"New DE time: {second_l0.SEC}, current time: {self.l0.SEC}."
)

Expand All @@ -397,7 +397,7 @@ def merge_de_packets(self, second_l0: DirectEventL0) -> None:
if not match:
raise ValueError(
f"While attempting to merge L0 packet {second_l0} "
f"with {self.l0} mismatched values"
f"with {self.l0} mismatched values "
f"were found. "
)

Expand Down Expand Up @@ -534,7 +534,7 @@ def _build_compressed_event(

else:
raise ValueError(
f"Incorrect length {len(raw)} for {raw}, expecting 2 or 3"
f"Incorrect length {len(raw)} for {raw}, expecting 2 or 3 "
f"bit compressed direct event data"
)

Expand Down
37 changes: 36 additions & 1 deletion imap_processing/glows/l1b/glows_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,31 @@ def glows_l1b(
output_dataarrays, input_dataset["epoch"], input_dataset["bins"], cdf_attrs
)

output_dataset["flight_software_version"] = xr.DataArray(
input_dataset["flight_software_version"].data,
name="flight_software_version",
dims=["scalar"],
attrs=cdf_attrs.get_variable_attributes(
"flight_software_version", check_schema=False
),
)

output_dataset["ground_software_version"] = xr.DataArray(
input_dataset["ground_software_version"].data,
name="ground_software_version",
dims=["scalar"],
attrs=cdf_attrs.get_variable_attributes(
"ground_software_version", check_schema=False
),
)

output_dataset["pkts_file_name"] = xr.DataArray(
input_dataset["pkts_file_name"].data,
name="pkts_file_name",
dims=["scalar"],
attrs=cdf_attrs.get_variable_attributes("pkts_file_name", check_schema=False),
)

return output_dataset


Expand Down Expand Up @@ -267,7 +292,7 @@ def process_histogram(

# histograms is the only multi dimensional input variable, so we set the non-epoch
# dimension ("bins").
# The rest of the input vars are epoch only, so they have an empty list.
# The rest of the non-scalar input vars are epoch only, so they have an empty list.
input_dims[0] = ["bins"]

# Create a closure that captures the ancillary objects
Expand Down Expand Up @@ -485,6 +510,16 @@ def create_l1b_de_output(
fields[index].name
)

# TODO: Not sure if this is requested in this product...
# parents = input_dataset.attrs.get("Parent", "")
# output_dataset["pkts_file_name"] = xr.DataArray(
# [parent for parent in parents if parent.endswith("cdf")],
# attrs=cdf_attrs.get_variable_attributes("pkts_file_name", check_schema=False),
# )
# output_dataset["pkts_file_name"] = [
# parent for parent in parents if parent.endswith("cdf")
# ]

output_dataset["within_the_second"] = within_the_second_data
output_dataset.attrs["missing_packets_sequence"] = input_dataset.attrs.get(
"missing_packets_sequence", ""
Expand Down
14 changes: 12 additions & 2 deletions imap_processing/glows/l1b/glows_l1b_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,8 @@ class DirectEventL1B:
float. From direct_events.
direct_event_pulse_lengths: ndarray
array of pulse lengths [μs] for direct events. From direct_events
pkts_file_name
Name of the input CCSDS packets file
"""

direct_events: InitVar[np.ndarray]
Expand Down Expand Up @@ -526,6 +528,7 @@ class DirectEventL1B:
direct_event_glows_times: np.ndarray | None = field(init=False, default=None)
# 3rd value is pulse length
direct_event_pulse_lengths: np.ndarray | None = field(init=False, default=None)
# pkts_file_name: str = ""
# TODO: where does the multi-event flag go?

def __post_init__(
Expand Down Expand Up @@ -662,7 +665,6 @@ class HistogramL1B:
----------
histogram
array of block-accumulated count numbers
flight_software_version: str
seq_count_in_pkts_file: int
first_spin_id: int
The start ID
Expand Down Expand Up @@ -731,10 +733,18 @@ class HistogramL1B:
flags
flags for extra information, per histogram. This should be a human-readable
structure.
flight_software_version
The version of the flight software, copied from L1A
pkts_file_name
The name of the input CCSDS packets file
ground_software_version
The version of the ground software, copied from L1A
"""

histogram: np.ndarray
flight_software_version: str
flight_software_version: np.ndarray
pkts_file_name: np.ndarray
ground_software_version: np.ndarray
seq_count_in_pkts_file: int
first_spin_id: int
last_spin_id: int
Expand Down
Loading
Loading