Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I-ALiRT: L0 parsing #246

Merged
merged 21 commits into from
Nov 8, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
response to pr
laspsandoval committed Nov 6, 2023
commit 11c064e6b86d7c553d0884855754175c6c2cba03
26 changes: 21 additions & 5 deletions imap_processing/ialirt/l0/decom_ialirt.py
Original file line number Diff line number Diff line change
@@ -25,6 +25,22 @@
xr.Dataset
A dataset containing the decoded data fields with 'time' as the coordinating
dimension.

Example Output:
---------------
# This is an example of what the xarray dataset might look like
# after being processed by this function.

<xarray.Dataset>
Dimensions: (SC_SCLK_SEC: 5)
Coordinates:
* SC_SCLK_SEC (SC_SCLK_SEC) int64 322168 322169 322170 322171 322172
Data variables:
SC_MAG_STATUS (SC_SCLK_SEC) int64 0 1 0 1 0
SC_HIT_STATUS (SC_SCLK_SEC) int64 1 0 1 0 1

This example shows a dataset with 'SC_SCLK_SEC' as the coordinate
and two data variables 'SC_MAG_STATUS' and 'SC_HIT_STATUS'.
"""
try:
packets = decom_packets(packet_file, xtce)
@@ -54,16 +70,16 @@
key_matched = False
for inst in instruments:
if key.startswith(inst):
# Directly append to the list without checking if the key exists
# Directly append to the list
data_storage[inst][key].append(value.derived_value)
key_matched = True
break

if not key_matched:
# If after checking all instruments, none match, then log a warning
logger.warning(f"Unexpected key '{key}' found in packet data.")
if not key_matched:
# If after checking all instruments, none match, raise an error.
raise ValueError(f"Unexpected key '{key}' found in packet data.")

Check warning on line 80 in imap_processing/ialirt/l0/decom_ialirt.py

Codecov / codecov/patch

imap_processing/ialirt/l0/decom_ialirt.py#L80

Added line #L80 was not covered by tests

logger.debug("Generating datasets for each instrument.")
logger.info("Generating datasets for each instrument.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.info("Generating datasets for each instrument.")
logger.debug("Generating datasets for each instrument.")


# Generate xarray dataset for each instrument and spacecraft
datasets = {}
5 changes: 2 additions & 3 deletions imap_processing/ialirt/tests/unit/test_decom_ialirt.py
Original file line number Diff line number Diff line change
@@ -73,13 +73,13 @@
binary_file_path, "wb"
) as binary_file:
for line in text_file:
if not line.startswith("#"):

Check warning on line 76 in imap_processing/ialirt/tests/unit/test_decom_ialirt.py

Codecov / codecov/patch

imap_processing/ialirt/tests/unit/test_decom_ialirt.py#L76

Added line #L76 was not covered by tests
# Split the line by semicolons
# Discard the first value since it is only a counter
hex_values = line.strip().split(";")[1:]

Check warning on line 79 in imap_processing/ialirt/tests/unit/test_decom_ialirt.py

Codecov / codecov/patch

imap_processing/ialirt/tests/unit/test_decom_ialirt.py#L79

Added line #L79 was not covered by tests
# Convert hex to binary
binary_data = bytearray.fromhex("".join(hex_values))
binary_file.write(binary_data)

Check warning on line 82 in imap_processing/ialirt/tests/unit/test_decom_ialirt.py

Codecov / codecov/patch

imap_processing/ialirt/tests/unit/test_decom_ialirt.py#L81-L82

Added lines #L81 - L82 were not covered by tests

yield binary_file_path

@@ -101,9 +101,8 @@

def test_binary_value_length():
"""
Creates a binary file from the text packet data, which is more representative
of the actual operational environment. The binary file is deleted after the
test session.
Validates the length of binary data converted
from a text file containing hexadecimal packet data.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is sort of recreating what you're already doing in the fixture above. You could just add the assert up there if you're trying to test that file.

"""
packet_path = (
imap_module_directory