diff --git a/imap_processing/ccsds/excel_to_xtce.py b/imap_processing/ccsds/excel_to_xtce.py index 658907b25..d34aa6d3a 100644 --- a/imap_processing/ccsds/excel_to_xtce.py +++ b/imap_processing/ccsds/excel_to_xtce.py @@ -226,7 +226,9 @@ def _create_container_sets(self) -> None: if pd.isna(row.get("packetName")): # This is a poorly formatted row, skip it continue - name = f"{row['packetName']}_{row['mnemonic']}" + # separate the packet name and mnemonic with a period + # a hyphen is sometimes in the packet name or mnemonic already + name = f"{row['packetName']}.{row['mnemonic']}" parameter_ref_entry = Et.SubElement( packet_entry_list, "xtce:ParameterRefEntry" ) @@ -247,7 +249,7 @@ def _add_parameter(self, row: pd.Series, total_packet_bits: int) -> None: """ parameter = Et.SubElement(self._parameter_set, "xtce:Parameter") # Combine the packet name and mnemonic to create a unique parameter name - name = f"{row['packetName']}_{row['mnemonic']}" + name = f"{row['packetName']}.{row['mnemonic']}" parameter.attrib["name"] = name # UINT8, ... parameter.attrib["parameterTypeRef"] = name diff --git a/imap_processing/tests/ccsds/test_data/expected_output.xml b/imap_processing/tests/ccsds/test_data/expected_output.xml index 93182b78c..187953349 100644 --- a/imap_processing/tests/ccsds/test_data/expected_output.xml +++ b/imap_processing/tests/ccsds/test_data/expected_output.xml @@ -24,10 +24,10 @@ - + - + @@ -37,13 +37,13 @@ - + - + - + @@ -53,16 +53,16 @@ - + - + - + - + @@ -88,31 +88,31 @@ CCSDS Packet Length (number of bytes after Packet length minus 1) - + Mission elapsed time - + Unsgned integer data with conversion - + Integer data - + Signed integer data - + Binary data - variable length - + Fill data - + Float data - + Mission elapsed time - + Variable 1 - long desc @@ -135,13 +135,13 @@ - - - - - - - + + + + + + + @@ -151,8 +151,8 @@ - - + + diff --git a/imap_processing/utils.py b/imap_processing/utils.py index 72eab657a..12cac4920 100644 --- a/imap_processing/utils.py +++ b/imap_processing/utils.py @@ -391,6 +391,18 @@ def packet_file_to_datasets( ) ds = ds.sortby("epoch") + # Strip any leading characters before "." from the field names which was due + # to the packet_name being a part of the variable name in the XTCE definition + ds = ds.rename( + { + # partition splits the string into 3 parts: before ".", ".", after "." + # if there was no ".", the second part is an empty string, so we use + # the original key in that case + key: key.partition(".")[2] or key + for key in ds.variables + } + ) + dataset_by_apid[apid] = ds return dataset_by_apid