diff --git a/imap_processing/codice/L0/decom_python_example.py b/imap_processing/codice/L0/decom_python_example.py deleted file mode 100644 index 102152b97..000000000 --- a/imap_processing/codice/L0/decom_python_example.py +++ /dev/null @@ -1,252 +0,0 @@ -""" -Main script to extract and decommute parameters from a binary file containing packets. - -This script reads a binary file containing packet data, searches for a packet with a -specific Application Process Identifier (APID), and then decommutes the packet's -parameters using a provided decommutation table. The extracted values are printed. - -Usage: - 1. Set the `bin_file_path` variable to the path containing packet data. - 2. Replace `target_apid` with the desired APID to search for. - 3. Define the `decomm_table` with the decommutation info for different parameters. - 4. Run the script to extract and print decommuted parameter values. - -Example: - Assuming `read_binary_file` and other functions are defined: - - Given a binary file at `bin_file_path` and a desired `target_apid`: - - If a packet with the `target_apid` is found, parameters are extracted and printed. - - If no matching packet is found, a message indicating such is printed. -""" - - -def read_binary_file(file_path): - """ - Parameters - ---------- - file_path : str - Path to the binary file containing packet data. - - Returns - -------- - data : dict - Each dictionary should contain: - - "mnemonic": A unique identifier for the parameter. - - "sequence": An optional parameter sequence number. - - "startByte": Starting byte index in the packet. - - "startBitInByte": Starting bit index within the starting byte. - - "startBit": Overall starting bit index in the packet. - - "lengthInBits": Number of bits to extract for this parameter. - - "dataType": Data type of the parameter: "unsigned_int", "float", etc. - """ - with open(file_path, "rb") as file: - data = file.read() - return data - - -def extract_bits(data, start_bit, length): - """ - Extracts a value from binary data by interpreting a specified range of bits. - - This function is used to extract a value from a sequence of binary data by - specifying the starting bit position and the number of bits to consider. - The bits are interpreted as an unsigned integer value. - - Parameters - ---------- - data : bytes - The binary data from which the value will be extracted. - start_bit : int - The index of the starting bit for extraction. - length : int - The number of bits to extract. - - Returns - ------- - int - The extracted value represented as an integer. - """ - byte_offset = start_bit // 8 - bit_shift = start_bit % 8 - mask = (1 << length) - 1 - - value = 0 - for i in range(length): - byte = data[byte_offset + i] - value |= (byte >> bit_shift) << (i * 8) - - return value & mask - - -def find_packet_with_apid(bin_data, target_apid): - """ - Finds the index of the first occurrence of a packet with a specific - APID in binary data. - - This function searches through a sequence of binary data to find the - index of the first packet that matches the specified Application Process - Identifier (APID). The APID is a unique identifier used in packet-based data - communication protocols. - - Parameters - ---------- - bin_data : bytes - The binary data to search within. - target_apid : int - The target APID to search for. - - Returns - ------- - idx : int - The index of the first occurrence of the packet with the specified APID - - Example: - binary_data = bytes ([0x12, 0x34, 0x56, 0x12, 0x78, 0x90]) - target_apid = 0x1234 - Example target APID - packet_index = find_packet_with_apid - (binary_data, target_apid) - """ - # Search for the target APID in the binary data - target_apid_bytes = target_apid.to_bytes(2, byteorder="big") - idx = bin_data.find(target_apid_bytes) - - return idx - - -# Decommutation table variables may not all be the same -def decommute_packet(packet_data, decomm_table): - """ - Decommutes packet data using a provided decommutation table. - - This function takes a packet's binary data and a decommutation table as input, and - returns a dictionary of parameter values extracted from the packet - according to the table. - - Parameters - ---------- - packet_data : bytes - Binary data of the packet to decommute. - decomm_table : list - List of dictionaries, each containing decommutation information for a parameter. - - Returns - ------- - parameters : dict - The decommuted parameters. Each dictionary should contain: - - "mnemonic": A unique identifier for the parameter. - - "sequence": An optional parameter sequence number. - - "startByte": Starting byte index in the packet. - - "startBitInByte": Starting bit index within the starting byte. - - "startBit": Overall starting bit index in the packet. - - "lengthInBits": Number of bits to extract for this parameter. - - "dataType": Data type of the parameter: "unsigned_int", "float", etc. - """ - parameters = {} - - for entry in decomm_table: - mnemonic = entry["mnemonic"] - entry["sequence"] - entry["startByte"] - entry["startBitInByte"] - start_bit = entry["startBit"] - length_in_bits = entry["lengthInBits"] - entry["dataType"] - - value = extract_bits(packet_data, start_bit, length_in_bits) - parameters[mnemonic] = value - - return parameters - - -if __name__ == "__main__": - bin_file_path = "../RAW.bin" - target_apid = 0x460 # Replace with the APID of the desired packet - decomm_table = [ - { - "mnemonic": "SHCOARSE", - "sequence": 7, - "startByte": 6, - "startBitInByte": 0, - "startBit": 48, - "lengthInBits": 32, - "dataType": "UINT", - }, - { - "mnemonic": "Spare", - "sequence": 8, - "startByte": 10, - "startBitInByte": 0, - "startBit": 80, - "lengthInBits": 6, - "dataType": "UINT", - }, - { - "mnemonic": "Power_Cycle_Rq", - "sequence": 9, - "startByte": 10, - "startBitInByte": 6, - "startBit": 86, - "lengthInBits": 1, - "dataType": "UINT", - }, - { - "mnemonic": "Power_Off_Rq", - "sequence": 10, - "startByte": 10, - "startBitInByte": 7, - "startBit": 87, - "lengthInBits": 1, - "dataType": "UINT", - }, - { - "mnemonic": "Heater_Control_Enabled", - "sequence": 11, - "startByte": 11, - "startBitInByte": 0, - "startBit": 88, - "lengthInBits": 1, - "dataType": "UINT", - }, - { - "mnemonic": "Heater_1_State", - "sequence": 12, - "startByte": 11, - "startBitInByte": 1, - "startBit": 89, - "lengthInBits": 1, - "dataType": "UINT", - }, - { - "mnemonic": "Heater_2_State", - "sequence": 13, - "startByte": 11, - "startBitInByte": 2, - "startBit": 90, - "lengthInBits": 1, - "dataType": "UINT", - }, - { - "mnemonic": "Spare2", - "sequence": 14, - "startByte": 11, - "startBitInByte": 3, - "startBit": 91, - "lengthInBits": 5, - "dataType": "UINT", - }, - ] - - data = read_binary_file(bin_file_path) - idx = find_packet_with_apid(data, target_apid) - - if idx >= 0: - packet_data = data[idx:] - parameters = decommute_packet(packet_data, decomm_table) - print("Decommuted Parameters of Apid:") - for mnemonic, value in parameters.items(): - print(f"{mnemonic}: {value}") - else: - print("Packet with APID not found in the binary data.") - -# FileNotFoundError: If the specified file does not exist. -# IOError: If an error occurs while reading the file. diff --git a/imap_processing/codice/L0/example_xtce.xml b/imap_processing/codice/L0/example_xtce.xml deleted file mode 100644 index 9bf6e0268..000000000 --- a/imap_processing/codice/L0/example_xtce.xml +++ /dev/null @@ -1,217 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CCSDS Packet Version Number (always 0) - - - CCSDS Packet Type Indicator (0=telemetry) - - - CCSDS Packet Secondary Header Flag (always 1) - - - CCSDS Packet Application Process ID - - - CCSDS Packet Grouping Flags (3=not part of group) - - - CCSDS Packet Sequence Count (increments with each new packet) - - - CCSDS Packet Length (number of bytes after Packet length minus 1) - - - CCSDS Packet Time Stamp (coarse time) - - - Spare - required per GI-ICD - - - Power Cycle Request - - - Power Off Request - - - Specifies whether the FSW bang-bang controller for the heaters is enabled. If the controller is not enabled, both heaters should be OFF. If control is enabled, heater outputs will vary as the control algorithm determines when to turn them ON or OFF. - - - Current ON/OFF state of the heater 1 output - - - Current ON/OFF state of the heater 2 output - - - Spare for alignment - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/imap_processing/codice/packet_definitions/P_COD_HI_INSTRUMENT_COUNTERS.xml b/imap_processing/codice/packet_definitions/P_COD_HI_INSTRUMENT_COUNTERS.xml new file mode 100644 index 000000000..f57f7baf4 --- /dev/null +++ b/imap_processing/codice/packet_definitions/P_COD_HI_INSTRUMENT_COUNTERS.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 4325376 + + + + + + + CCSDS Packet Version Number (always 0) + + + CCSDS Packet Type Indicator (0=telemetry) + + + CCSDS Packet Secondary Header Flag (always 1) + + + CCSDS Packet Application Process ID + + + CCSDS Packet Grouping Flags (3=not part of group) + + + CCSDS Packet Sequence Count (increments with each new packet) + + + CCSDS Packet Length (number of bytes after Packet length minus 1) + + + CCSDS Packet Time Stamp (coarse time) + + + Packet Version + + + Spin Period reported by the Spacecraft + + + Acquisition Start Time (Seconds) + + + Acquisition Start Time (Subseconds) + + + Spare for alignment + + + Science Lookup Table Version/ID + + + Plan Table ID + + + Plan Step Number + + + View table used for data collapsing and compression + + + Half-spin when Reduced Gain Factor Operation was activated + + + Half-spin when No Scan Operation was activated + + + Bias Voltage Mode + + + Indicates a data quality issue + + + Compression Configuration + + + Number of bytes in the Data array + + + Data Array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/imap_processing/codice/packet_definitions/P_COD_HI_OMNI_SPECIES_COUNTS.xml b/imap_processing/codice/packet_definitions/P_COD_HI_OMNI_SPECIES_COUNTS.xml index 0e975b5c8..11d983fe7 100644 --- a/imap_processing/codice/packet_definitions/P_COD_HI_OMNI_SPECIES_COUNTS.xml +++ b/imap_processing/codice/packet_definitions/P_COD_HI_OMNI_SPECIES_COUNTS.xml @@ -1,19 +1,28 @@ - + + + + + + + - - + + + + + - - + + @@ -21,24 +30,15 @@ - - - - - - - - - - - - + + + @@ -74,66 +74,52 @@ CCSDS Packet Time Stamp (coarse time) - Packet version - this will be incremented each time the format of the packet changes. + Packet Version - Spin period reported by the Spacecraft in the Time and Status message. Reported period is the period that was active when the 16-spin acquisition cycle started. + Spin Period reported by the Spacecraft - Full-seconds portion of the time at which the 16-spin cycle started + Acquisition Start Time (Seconds) - Sub-seconds portion of the time at which the 16-spin cycle started (microseconds) + Acquisition Start Time (Subseconds) Spare for alignment - Unique ID assigned to a specific table configuration. This field is used to link the overall acquisition and processing settings to a specific table configuration. + Science Lookup Table Version/ID - Plan table that was in use + Plan Table ID - Plan step that was active when this data was acquired and processed. + Plan Step Number - View ID provides information about how data was collapsed and/or compressed. + View table used for data collapsing and compression - N/A for CoDICE-Hi; included in order to maintain common packet format + Half-spin when Reduced Gain Factor Operation was activated - N/A for CoDICE-Hi; included in order to maintain common packet format + Half-spin when No Scan Operation was activated - N/A for CoDICE-Hi; included in order to maintain common packet format + Bias Voltage Mode - Indicates that there was some error detected during acquisition or processing of the data. Errors could include corrupted acquisition memory (i.e. EDAC errors), timing violations, or other events that interrupted or otherwise affected data collection. + Indicates a data quality issue - Whether/how the data is compressed. + Compression Configuration - Number of bytes in the Data array. If compressed, this value represents the length of the compressed data. + Number of bytes in the Data array - Counter Data - -Variable Length; Maximum (based on uncollapsed, uncompressed data, and assuming all 146 sqrt(2) speceis counters included): - -16 spins x 16 positions x 24 spin-angles x 32 bits x 146 counters = 28,704,768 bits (3,588,096 bytes) - -Nominal (based on current plan for counter selection, collapsing, and compression): 42,240 bits (5,281 bytes) - -Data format is a series of spin-angle x position x spin number data cubes collapsed per the SCI_LUT Collapse Table selected by the View_ID. Which counters are included is determined by using the Plan_ID and Plan_Step to index into the SCI_LUT Data Products Hi/Lo tables to find all the counters that are associated with the View_ID. - -The collapsed data cubes are also optionally compressed using Lossy and/or Lossless Compression. Lossy compression is a table-based 24->8 bit compression applied to each counter value. Lossless compression uses the LZMA compression algorithm and is applied to the full Data field as a single unit. - -Field will additionally be padded in order to meet the requirement of packets being a multiple of 16 bits; any pad bits will be accounted for in the CCSDS header Length field, but will *not* be included in the Byte_Count field - -When this array is too large for a single CCSDS packet, CoDICE will utilize the CCSDS Grouping flags to provide the full data packet over several CCSDS packets. + Data Array diff --git a/imap_processing/codice/packet_definitions/P_COD_HI_PHA.xml b/imap_processing/codice/packet_definitions/P_COD_HI_PHA.xml index 01be9a44f..b36410165 100644 --- a/imap_processing/codice/packet_definitions/P_COD_HI_PHA.xml +++ b/imap_processing/codice/packet_definitions/P_COD_HI_PHA.xml @@ -1,19 +1,22 @@ - + - - - + + + + + + - - + + @@ -21,18 +24,15 @@ - - - - - - + + + @@ -68,56 +68,40 @@ CCSDS Packet Time Stamp (coarse time) - Packet version - this will be incremented each time the format of the packet changesCOD_LO_PHA. + Packet Version - Spin period reported by the Spacecraft in the Time and Status message. Reported period is the period that was active when the 16-spin acquisition cycle started. + Spin Period reported by the Spacecraft - Full-seconds portion of the time at which the 16-spin cycle started + Acquisition Start Time (Seconds) - Sub-seconds portion of the time at which the 16-spin cycle started + Acquisition Start Time (Subseconds) Spare for alignment - Total number of TCR events that occurred during the collection cycle + Total number of TCR events - Total number of DCR events that occurred during the collection cycle + Total number of DCR events - Total number of APD-Only events that occurred during the collection cycle + Total number of APD-Only events - Number of events selected for downlink (i.e. number of events in the Event_Data array) + Number of events included in this packet - Whether the event data is compressed. If 1/Yes, Event_Data array is compressed using the Rice compression algorithm. + Whether the event data is compressed - Number of bytes in the Event_Data array. If compressed, this value represents the length of the compressed data. + Number of bytes in the Event Data array - Optionally compressed array of Event Data - -Format is TBD; some considerations/options: -- Full events have a lot of redundant data (e.g. will have many events with the same priority/spin/spin phase information). How well does compression to deal with the redundancy? -- Could include mini-headers for each (priority,spin, spin-phase) group and strip the redundant data from the events -- Should events be tightly packed, or can we pad out to 64-bit word boundaries? How well does compression compensate for the extra bits? - -Each event consists of: -- 10-bit TOF -- 9-bit SSD Energy -- 2-bit Energy Range -- 7-bit Spin Angle -- 4-bit SSD Position -- 4-bit Spin Number -- 2-bit PHA Type - -TBD: Events may be tightly packed, or may have spares added to keep each event byte-aligned. In either case, there may be up to 1 byte of padding to keep the total size of the packet even. + Event Data diff --git a/imap_processing/codice/packet_definitions/P_COD_HI_SECT_SPECIES_COUNTS.xml b/imap_processing/codice/packet_definitions/P_COD_HI_SECT_SPECIES_COUNTS.xml new file mode 100644 index 000000000..1ea8c3f28 --- /dev/null +++ b/imap_processing/codice/packet_definitions/P_COD_HI_SECT_SPECIES_COUNTS.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9043968 + + + + + + + CCSDS Packet Version Number (always 0) + + + CCSDS Packet Type Indicator (0=telemetry) + + + CCSDS Packet Secondary Header Flag (always 1) + + + CCSDS Packet Application Process ID + + + CCSDS Packet Grouping Flags (3=not part of group) + + + CCSDS Packet Sequence Count (increments with each new packet) + + + CCSDS Packet Length (number of bytes after Packet length minus 1) + + + CCSDS Packet Time Stamp (coarse time) + + + Packet Version + + + Spin Period reported by the Spacecraft + + + Acquisition Start Time (Seconds) + + + Acquisition Start Time (Subseconds) + + + Spare for alignment + + + Science Lookup Table Version/ID + + + Plan Table ID + + + Plan Step Number + + + View table used for data collapsing and compression + + + Half-spin when Reduced Gain Factor Operation was activated + + + Half-spin when No Scan Operation was activated + + + Bias Voltage Mode + + + Indicates a data quality issue + + + Compression Configuration + + + Number of bytes in the Data array + + + Data Array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/imap_processing/codice/packet_definitions/P_COD_LO_INSTRUMENT_COUNTERS.xml b/imap_processing/codice/packet_definitions/P_COD_LO_INSTRUMENT_COUNTERS.xml new file mode 100644 index 000000000..7d5738061 --- /dev/null +++ b/imap_processing/codice/packet_definitions/P_COD_LO_INSTRUMENT_COUNTERS.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 25952256 + + + + + + + CCSDS Packet Version Number (always 0) + + + CCSDS Packet Type Indicator (0=telemetry) + + + CCSDS Packet Secondary Header Flag (always 1) + + + CCSDS Packet Application Process ID + + + CCSDS Packet Grouping Flags (3=not part of group) + + + CCSDS Packet Sequence Count (increments with each new packet) + + + CCSDS Packet Length (number of bytes after Packet length minus 1) + + + CCSDS Packet Time Stamp (coarse time) + + + Packet Version + + + Spin Period reported by the Spacecraft + + + Acquisition Start Time (Seconds) + + + Acquisition Start Time (Subseconds) + + + Spare for alignment + + + Science Lookup Table Version/ID + + + Plan Table ID + + + Plan Step Number + + + View table used for data collapsing and compression + + + Half-spin when Reduced Gain Factor Operation was activated + + + Half-spin when No Scan Operation was activated + + + Bias Voltage Mode + + + Indicates a data quality issue + + + Compression Configuration + + + Number of bytes in the Data array + + + Data Array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/imap_processing/codice/packet_definitions/P_COD_LO_NSW_ANGULAR_COUNTS.xml b/imap_processing/codice/packet_definitions/P_COD_LO_NSW_ANGULAR_COUNTS.xml new file mode 100644 index 000000000..a0ba5271a --- /dev/null +++ b/imap_processing/codice/packet_definitions/P_COD_LO_NSW_ANGULAR_COUNTS.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 37748736 + + + + + + + CCSDS Packet Version Number (always 0) + + + CCSDS Packet Type Indicator (0=telemetry) + + + CCSDS Packet Secondary Header Flag (always 1) + + + CCSDS Packet Application Process ID + + + CCSDS Packet Grouping Flags (3=not part of group) + + + CCSDS Packet Sequence Count (increments with each new packet) + + + CCSDS Packet Length (number of bytes after Packet length minus 1) + + + CCSDS Packet Time Stamp (coarse time) + + + Packet Version + + + Spin Period reported by the Spacecraft + + + Acquisition Start Time (Seconds) + + + Acquisition Start Time (Subseconds) + + + Spare for alignment + + + Science Lookup Table Version/ID + + + Plan Table ID + + + Plan Step Number + + + View table used for data collapsing and compression + + + Half-spin when Reduced Gain Factor Operation was activated + + + Half-spin when No Scan Operation was activated + + + Bias Voltage Mode + + + Indicates a data quality issue + + + Compression Configuration + + + Number of bytes in the Data array + + + Data Array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/imap_processing/codice/packet_definitions/P_COD_LO_NSW_SPECIES_COUNTS.xml b/imap_processing/codice/packet_definitions/P_COD_LO_NSW_SPECIES_COUNTS.xml index 41c3ed886..71d4b30b6 100644 --- a/imap_processing/codice/packet_definitions/P_COD_LO_NSW_SPECIES_COUNTS.xml +++ b/imap_processing/codice/packet_definitions/P_COD_LO_NSW_SPECIES_COUNTS.xml @@ -1,19 +1,28 @@ - + + + + + + + - - + + + + + - - + + @@ -21,24 +30,15 @@ - - - - - - - - - - - - + + + @@ -74,66 +74,52 @@ CCSDS Packet Time Stamp (coarse time) - Packet version - this will be incremented each time the format of the packet changes. + Packet Version - Spin period reported by the Spacecraft in the Time and Status message. Reported period is the period that was active when the 16-spin acquisition cycle started. + Spin Period reported by the Spacecraft - Full-seconds portion of the time at which the 16-spin cycle started + Acquisition Start Time (Seconds) - Sub-seconds portion of the time at which the 16-spin cycle started (microseconds) + Acquisition Start Time (Subseconds) Spare for alignment - Unique ID assigned to a specific table configuration. This field is used to link the overall acquisition and processing settings to a specific table configuration. + Science Lookup Table Version/ID - Plan table that was in use + Plan Table ID - Plan step that was active when this data was acquired and processed. + Plan Step Number - View ID provides information about how data was collapsed and/or compressed. + View table used for data collapsing and compression - Indicates the point when Reduced Gain Factor Operation (RGFO) was actived. In RGFO, the Entrance ESA voltage is reduced in order to limit the number of ions that reach the detectors. + Half-spin when Reduced Gain Factor Operation was activated - Indicates the point when No-Scan Operation (NSO) was actived. In NSO, the ESA voltage is set to the first step in the scan and remains fixed until the next cycle boundary. + Half-spin when No Scan Operation was activated - Indicates whether FSW is tracking the High-Gain bias curve or the Low-Gain bias curve. + Bias Voltage Mode - Indicates that there was some error detected during acquisition or processing of the data. Errors could include corrupted acquisition memory (i.e. EDAC errors), timing violations, or other events that interrupted or otherwise affected data collection. + Indicates a data quality issue - Whether/how the data is compressed. + Compression Configuration - Number of bytes in the Data array. If compressed, this value represents the length of the compressed data. + Number of bytes in the Data array - Counter Data - -Variable Length; Maximum (based on uncollapsed, uncompressed data, and assuming all 32 species-counters included): - -128 energies x 24 positions x 12 spin-angles x 32 bits x 32 counters = 37,748,736 bits (4,718,592 bytes) - -Realistically, data is aggressively collapsed and compressed, and only a subset of the 32 species counters will be included, so this data field will be much smaller than the maximum. - -Data format is a series of spin-angle x position x energy data cubes collapsed per the SCI_LUT Collapse Table selected by the View_ID. Which counters are included is determined by using the Plan_ID and Plan_Step to index into the SCI_LUT Data Products Hi/Lo tables to find all the counters that are associated with the View_ID. - -The collapsed data cubes are also optionally compressed using Lossy and/or Lossless Compression. Lossy compression is a table-based 24->8 bit compression applied to each counter value. Lossless compression uses the LZMA compression algorithm and is applied to the full Data field as a single unit. - -Field will additionally be padded in order to meet the requirement of packets being a multiple of 16 bits; any pad bits will be accounted for in the CCSDS header Length field, but will *not* be included in the Byte_Count field - -When this array is too large for a single CCSDS packet, CoDICE will utilize the CCSDS Grouping flags to provide the full data packet over several CCSDS packets. + Data Array diff --git a/imap_processing/codice/packet_definitions/P_COD_LO_PHA.xml b/imap_processing/codice/packet_definitions/P_COD_LO_PHA.xml index 4ab88f175..6fb10ed38 100644 --- a/imap_processing/codice/packet_definitions/P_COD_LO_PHA.xml +++ b/imap_processing/codice/packet_definitions/P_COD_LO_PHA.xml @@ -1,19 +1,22 @@ - + - - - + + + + + + - - + + @@ -21,18 +24,15 @@ - - - - - - + + + @@ -68,58 +68,40 @@ CCSDS Packet Time Stamp (coarse time) - Packet version - this will be incremented each time the format of the packet changesCOD_LO_PHA. + Packet Version - Spin period reported by the Spacecraft in the Time and Status message. Reported period is the period that was active when the 16-spin acquisition cycle started. + Spin Period reported by the Spacecraft - Full-seconds portion of the time at which the 16-spin cycle started + Acquisition Start Time (Seconds) - Sub-seconds portion of the time at which the 16-spin cycle started + Acquisition Start Time (Subseconds) Spare for alignment - Total number of TCR events that occurred during the collection cycle + Total number of TCR events - Total number of DCR events that occurred during the collection cycle + Total number of DCR events - Total number of APD-Only events that occurred during the collection cycle + Total number of APD-Only events - Number of events selected for downlink (i.e. number of events in the Event_Data array) + Number of events included in this packet - Whether the event data is compressed. If 1/Yes, Event_Data array is compressed using the LZMA compression algorithm. + Whether the event data is compressed - Number of bytes in the Event_Data array. If compressed, this value represents the length of the compressed data. + Number of bytes in the Event Data array - Optionally compressed array of Event Data - -Format is TBD; some considerations/options: -- Full events have a lot of redundant data (e.g. will have many events with the same priority/e-step/spin phase information). How well does compression to deal with the redundancy? -- Could include mini-headers for each (priority,e-step, spin-phase) group and strip the redundant data from the events -- Should events be tightly packed, or can we pad out to 64-bit word boundaries? How well does compression compensate for the extra bits? - -Each event consists of: -- 7-bit E-step -- 10-bit TOF -- 9-bit APD Energy -- 7-bit Spin Angle -- 5-bit Position -- 5-bit APD-ID -- 1-bit APD-Gain -- 2-bit PHA Type -- 3-bit Priority Range - -TBD: Events may be tightly packed, or may have spares added to keep each event byte-aligned. In either case, there may be up to 1 byte of padding to keep the total size of the packet even. + Event Data diff --git a/imap_processing/codice/packet_definitions/P_COD_LO_PRIORITY_COUNTS.xml b/imap_processing/codice/packet_definitions/P_COD_LO_PRIORITY_COUNTS.xml new file mode 100644 index 000000000..b1cefe845 --- /dev/null +++ b/imap_processing/codice/packet_definitions/P_COD_LO_PRIORITY_COUNTS.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 9437184 + + + + + + + CCSDS Packet Version Number (always 0) + + + CCSDS Packet Type Indicator (0=telemetry) + + + CCSDS Packet Secondary Header Flag (always 1) + + + CCSDS Packet Application Process ID + + + CCSDS Packet Grouping Flags (3=not part of group) + + + CCSDS Packet Sequence Count (increments with each new packet) + + + CCSDS Packet Length (number of bytes after Packet length minus 1) + + + CCSDS Packet Time Stamp (coarse time) + + + Packet Version + + + Spin Period reported by the Spacecraft + + + Acquisition Start Time (Seconds) + + + Acquisition Start Time (Subseconds) + + + Spare for alignment + + + Science Lookup Table Version/ID + + + Plan Table ID + + + Plan Step Number + + + View table used for data collapsing and compression + + + Half-spin when Reduced Gain Factor Operation was activated + + + Half-spin when No Scan Operation was activated + + + Bias Voltage Mode + + + Indicates a data quality issue + + + Compression Configuration + + + Number of bytes in the Data array + + + Data Array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/imap_processing/codice/packet_definitions/P_COD_LO_SW_ANGULAR_COUNTS.xml b/imap_processing/codice/packet_definitions/P_COD_LO_SW_ANGULAR_COUNTS.xml new file mode 100644 index 000000000..3e72f107b --- /dev/null +++ b/imap_processing/codice/packet_definitions/P_COD_LO_SW_ANGULAR_COUNTS.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 37748736 + + + + + + + CCSDS Packet Version Number (always 0) + + + CCSDS Packet Type Indicator (0=telemetry) + + + CCSDS Packet Secondary Header Flag (always 1) + + + CCSDS Packet Application Process ID + + + CCSDS Packet Grouping Flags (3=not part of group) + + + CCSDS Packet Sequence Count (increments with each new packet) + + + CCSDS Packet Length (number of bytes after Packet length minus 1) + + + CCSDS Packet Time Stamp (coarse time) + + + Packet Version + + + Spin Period reported by the Spacecraft + + + Acquisition Start Time (Seconds) + + + Acquisition Start Time (Subseconds) + + + Spare for alignment + + + Science Lookup Table Version/ID + + + Plan Table ID + + + Plan Step Number + + + View table used for data collapsing and compression + + + Half-spin when Reduced Gain Factor Operation was activated + + + Half-spin when No Scan Operation was activated + + + Bias Voltage Mode + + + Indicates a data quality issue + + + Compression Configuration + + + Number of bytes in the Data array + + + Data Array + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/imap_processing/codice/packet_definitions/P_COD_LO_SW_SPECIES_COUNTS.xml b/imap_processing/codice/packet_definitions/P_COD_LO_SW_SPECIES_COUNTS.xml index b880a16d6..58cc20926 100644 --- a/imap_processing/codice/packet_definitions/P_COD_LO_SW_SPECIES_COUNTS.xml +++ b/imap_processing/codice/packet_definitions/P_COD_LO_SW_SPECIES_COUNTS.xml @@ -1,19 +1,28 @@ - + + + + + + + - - + + + + + - - + + @@ -21,24 +30,15 @@ - - - - - - - - - - - - + + + @@ -74,66 +74,52 @@ CCSDS Packet Time Stamp (coarse time) - Packet version - this will be incremented each time the format of the packet changes. + Packet Version - Spin period reported by the Spacecraft in the Time and Status message. Reported period is the period that was active when the 16-spin acquisition cycle started. + Spin Period reported by the Spacecraft - Full-seconds portion of the time at which the 16-spin cycle started + Acquisition Start Time (Seconds) - Sub-seconds portion of the time at which the 16-spin cycle started (microseconds) + Acquisition Start Time (Subseconds) Spare for alignment - Unique ID assigned to a specific table configuration. This field is used to link the overall acquisition and processing settings to a specific table configuration. + Science Lookup Table Version/ID - Plan table that was in use + Plan Table ID - Plan step that was active when this data was acquired and processed. + Plan Step Number - View ID provides information about how data was collapsed and/or compressed. + View table used for data collapsing and compression - Indicates the point when Reduced Gain Factor Operation (RGFO) was actived. In RGFO, the Entrance ESA voltage is reduced in order to limit the number of ions that reach the detectors. + Half-spin when Reduced Gain Factor Operation was activated - Indicates the point when No-Scan Operation (NSO) was actived. In NSO, the ESA voltage is set to the first step in the scan and remains fixed until the next cycle boundary. + Half-spin when No Scan Operation was activated - Indicates whether FSW is tracking the High-Gain bias curve or the Low-Gain bias curve. + Bias Voltage Mode - Indicates that there was some error detected during acquisition or processing of the data. Errors could include corrupted acquisition memory (i.e. EDAC errors), timing violations, or other events that interrupted or otherwise affected data collection. + Indicates a data quality issue - Whether/how the data is compressed. + Compression Configuration - Number of bytes in the Data array. If compressed, this value represents the length of the compressed data. + Number of bytes in the Data array - Counter Data - -Variable Length; Maximum (based on uncollapsed, uncompressed data, and assuming all 32 species-counters included): - -128 energies x 24 positions x 12 spin-angles x 32 bits x 32 counters = 37,748,736 bits (4,718,592 bytes) - -Realistically, data is aggressively collapsed and compressed, and only a subset of the 32 species counters will be included, so this data field will be much smaller than the maximum. - -Data format is a series of spin-angle x position x energy data cubes collapsed per the SCI_LUT Collapse Table selected by the View_ID. Which counters are included is determined by using the Plan_ID and Plan_Step to index into the SCI_LUT Data Products Hi/Lo tables to find all the counters that are associated with the View_ID. - -The collapsed data cubes are also optionally compressed using Lossy and/or Lossless Compression. Lossy compression is a table-based 24->8 bit compression applied to each counter value. Lossless compression uses the LZMA compression algorithm and is applied to the full Data field as a single unit. - -Field will additionally be padded in order to meet the requirement of packets being a multiple of 16 bits; any pad bits will be accounted for in the CCSDS header Length field, but will *not* be included in the Byte_Count field - -When this array is too large for a single CCSDS packet, CoDICE will utilize the CCSDS Grouping flags to provide the full data packet over several CCSDS packets. + Data Array diff --git a/imap_processing/codice/packet_definitions/P_COD_NHK.xml b/imap_processing/codice/packet_definitions/P_COD_NHK.xml new file mode 100644 index 000000000..819b71e4b --- /dev/null +++ b/imap_processing/codice/packet_definitions/P_COD_NHK.xml @@ -0,0 +1,583 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CCSDS Packet Version Number (always 0) + + + CCSDS Packet Type Indicator (0=telemetry) + + + CCSDS Packet Secondary Header Flag (always 1) + + + CCSDS Packet Application Process ID + + + CCSDS Packet Grouping Flags (3=not part of group) + + + CCSDS Packet Sequence Count (increments with each new packet) + + + CCSDS Packet Length (number of bytes after Packet length minus 1) + + + CCSDS Packet Time Stamp (coarse time) + + + Packet Version + + + Number of commands executed + + + Number of commands rejected + + + Last executed opcode + + + Instrument Mode + + + Memory Operation State + + + Memory Dump State + + + Number of ITF errors encountered + + + Number of spin pulses received + + + Number of missed PPS pulses + + + Number of watchdog timeouts since last reset + + + Status of the HV Disable Plug + + + Number of Command FIFO Overruns + + + Number of Command FIFO Underruns + + + Number of Command FIFO Parity Errors + + + Number of Command FIFO Frame Errors + + + Number of Telemetry FIFO Overruns + + + Spin Bin Period + + + Current Spin Period + + + Spin Period Timer + + + Full-seconds timestamp of the most recent spin pulse + + + Sub-seconds timestamp of the most recent spin pulse + + + Spin Bin Index + + + Optics HV - Number of command errors + + + Spare for alignment + + + Optics HV - Number of arm errors + + + Optics HV - Master Enable + + + Optics HV - p15KV Enable + + + Optics HV - ESA B Enable + + + Spare (was Optics HV - ESA B Range) + + + Optics HV - ESA A Enable + + + Spare (was Optics HV - ESA A Range) + + + Sensor HV - Number of command errors + + + Sensor HV - Number of Arm errors + + + Sensor HV - Master Enable + + + Sensor HV - APD Bias Enable + + + Sensor HV - p6KV Enable + + + Sensor HV - Stop MCP Enable + + + Sensor HV - Start MCP Enable + + + Spare for alignment + + + Optics HV - ESA A DAC + + + Optics HV - ESA B DAC + + + Optics HV - Ion Bulk DAC + + + Sensor HV - SSDO Enable + + + Sensor HV - SSD Bias Enable + + + Sensor HV - ADP Bias Enable + + + Sensor HV - ADP Bias 2 Enable + + + Sensor HV - Start MCP DAC + + + Sensor HV - Stop MCP DAC + + + Sensor HV - Stop Optics Grid DAC + + + HVPS – V1: Sensor Bulk Voltage Monitor + + + HVPS – V2: SSD Optics Voltage Monitor + + + HVPS – V3: SSD Bias Voltage Monitor + + + HVPS – V4: APD1 Bias Voltage Monitor + + + HVPS – V5: APD1 Bias Voltage Monitor + + + HVPS – V6: IO Bulk Voltage Monitor + + + HVPS – V7: ESA A High Range Voltage Monitor + + + Spare (was ESAA_LO_VMON) + + + HVPS – V9: Start MCP Voltage Monitor + + + HVPS – V10: Stop MCP Voltage Monitor + + + HVPS – V11: Stop Optics Grid Voltage Monitor + + + HVPS – V12: APD1 Bias Current Monitor + + + HVPS – V13: ESA A High Range Voltage Monitor + + + Spare (was ESAB_LO_VMON) + + + HVPS – V15: APD2 Bias Current Monitor + + + HVPS – V16: SSD Bias Current Moniotr + + + HVPS – I1: Stop MCP Current Monitor + + + HVPS – I2: IO Bulk CurrentMonitor + + + HVPS – I3: Start MCP Current Monitor + + + System Temperature 1: MDM25P – 14 Temperature + + + System Temperature 2: MDM25P – 15 Temperature + + + System Temperature 3: MDM25P – 16 Temperature + + + LO Temperature: MDM51P – 27 Temperature + + + HVPS Temperature: IO-HVPS Temperature + + + LVPS Temperature 1: LVPS – 12V Temperature + + + LVPS Temperature 2: LVPS – 5V Temperature + + + LVPS Temperature 3: LVPS – +3.3V Temperature + + + LVPS – Digital V1: LVPS – +3.3V + + + LVPS – Digital V2: LVPS – +5V + + + LVPS – Digital V3: LVPS – -5V + + + LVPS – Digital V4: LVPS – +12V + + + LVPS – Digital V5: LVPS – -12V + + + LVPS – Digital I1: LVPS – +3.3V Current + + + LVPS – Digital I2: LVPS – +5V Current + + + LVPS – Digital I3: LVPS – -5V Current + + + LVPS – Digital I4: LVPS – +12V Current + + + LVPS – Digital I5: LVPS – -12V Current + + + CDH – + 1.5V + + + CDH – +1.8V + + + CDH – +3.3V + + + CDH – +12V + + + CDH – -12V + + + CDH – +5V + + + CDH – Analog Ref: CDH – +5V ADC + + + TBD - Placeholder for HVPS 1 Interface error counts + + + TBD - Placeholder for HVPS 2 Interface error counts + + + TBD - Placeholder for FEE 1 Interface error counts + + + TBD - Placeholder for FEE 2 Interface error counts + + + TBD - Placeholder for Macro status + + + Indicates whether any CATEGORY 1 limits have triggered + + + Indicates whether any CATEGORY 2 limits have triggered + + + Indicates whether any CATEGORY 3 limits have triggered + + + Indicates whether any CATEGORY 4 limits have triggered + + + Indicates whether any CATEGORY 5 limits have triggered + + + Indicates whether any CATEGORY 6 limits have triggered + + + Indicates whether any CATEGORY 7 limits have triggered + + + Indicates whether any CATEGORY 8 limits have triggered + + + Indicates whether the most recent trigger was a minimum or maximum limit + + + Indicates the ID of the most recent FDC trigger + + + Indicates the action that was taken for the most recent FDC trigger + + + Round Robin Parameter Report Index + + + Round Robin Parameter Report Value + + + State of the heater controller + + + State of the heater output + + + Spare for alignment + + + CDH – Processor Temp monitor + + + CDH – +1.8V LDO Temp monitor + + + CDH – +1.5V LDO Temp monitor + + + CDH – SDRAM Temp monitor + + + CoDICE – Sensor HVPS Temp monitor + + + Spare for alignment + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/xtce_generation/TLM_COD.xlsx b/tools/xtce_generation/TLM_COD.xlsx new file mode 100644 index 000000000..abf02dc72 Binary files /dev/null and b/tools/xtce_generation/TLM_COD.xlsx differ diff --git a/tools/xtce_generation/xtce_generator_codice.py b/tools/xtce_generation/xtce_generator_codice.py new file mode 100644 index 000000000..bcf075adb --- /dev/null +++ b/tools/xtce_generation/xtce_generator_codice.py @@ -0,0 +1,40 @@ +from pathlib import Path + +from tools.xtce_generation.telemetry_generator import TelemetryGenerator + + +def main(): + instrument_name = "codice" + current_directory = Path(__file__).parent + module_path = f"{current_directory}/../../imap_processing" + packet_definition_path = f"{module_path}/{instrument_name}/packet_definitions" + path_to_excel_file = f"{current_directory}/TLM_COD.xlsx" + + # CoDICE packets + packets = { + "P_COD_HI_PHA": 1169, + "P_COD_LO_PHA": 1153, + "P_COD_LO_NSW_SPECIES_COUNTS": 1157, + "P_COD_HI_OMNI_SPECIES_COUNTS": 1172, + "P_COD_LO_SW_SPECIES_COUNTS": 1156, + "P_COD_NHK": 1136, + "P_COD_HI_INSTRUMENT_COUNTERS": 1170, + "P_COD_LO_INSTRUMENT_COUNTERS": 1154, + "P_COD_LO_PRIORITY_COUNTS": 1155, + "P_COD_LO_NSW_ANGULAR_COUNTS": 1159, + "P_COD_LO_SW_ANGULAR_COUNTS": 1158, + "P_COD_HI_SECT_SPECIES_COUNTS": 1173, + } + + for packet_name, app_id in packets.items(): + print(packet_name) + telemetry_generator = TelemetryGenerator( + packet_name=packet_name, path_to_excel_file=path_to_excel_file, apid=app_id + ) + telemetry_generator.generate_telemetry_xml( + f"{packet_definition_path}/{packet_name}.xml", packet_name + ) + + +if __name__ == "__main__": + main()