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

CoDICE L1 decompression and unpacking data updates #762

Merged

Conversation

bourque
Copy link
Collaborator

@bourque bourque commented Aug 20, 2024

Change Summary

Overview

This PR makes improvements to how CoDICE data is unpacked and structured as data arrays in the CDF data products. Prior to SIT-3, this step of the algorithm was mostly glossed over in order to get CDFs created to support the test, but I am now going back to properly implement how the data arrays get stored. This PR also makes improvements to the decompression algorithm, namely making it so that an entire binary string can be decompressed at once, instead of individual values.

Updated Files

  • imap_processing/cdf/config/imap_codice_l1a/b_variable_attrs.yaml
    • Added attribute definition for spin_sector coordinate
  • imap_processing/codice/codice_l1a.py
    • Various fixes and restructuring of data arrays, now utilizing spin_sector coordinate; split unpack_science_data into two functions, one for each hi and lo, since they have slightly differently ways of upacking data.
  • imap_processing/codice/constants.py
    • Modified dataset configurations to support spin_sector; removed Collapse Table lookups, as they are not needed because I am defining configurations via the DATA_PRODUCT_CONFIGURATIONS dictionaries.
  • imap_processing/codice/decompress.py
    • Refactored module so that an entire binary string can be decompressed, as opposed to individual integer values.
  • imap_processing/tests/codice/test_codice_l1a.py
    • Updated tests to reflect new data array structure
  • imap_processing/tests/codice/test_decompress.py
    • Updated tests to reflect new way of decompressing data

@bourque bourque added Ins: CoDICE Related to the CoDICE instrument Level: L1 Level 1 processing labels Aug 20, 2024
@bourque bourque requested a review from a team August 20, 2024 20:50
@bourque bourque self-assigned this Aug 20, 2024
@bourque bourque requested review from greglucas, subagonsouth and tech3371 and removed request for a team August 20, 2024 20:50
imap_processing/codice/codice_l1a.py Outdated Show resolved Hide resolved
imap_processing/codice/codice_l1a.py Show resolved Hide resolved
imap_processing/codice/constants.py Outdated Show resolved Hide resolved
imap_processing/codice/constants.py Outdated Show resolved Hide resolved
imap_processing/codice/constants.py Outdated Show resolved Hide resolved
imap_processing/codice/decompress.py Outdated Show resolved Hide resolved
Copy link
Contributor

@subagonsouth subagonsouth left a comment

Choose a reason for hiding this comment

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

This all looks good to me. I like how you have chosen to structure your code. I will hold off on approving since there are some open items from Greg's feedback.

imap_processing/codice/codice_l1a.py Show resolved Hide resolved
@bourque
Copy link
Collaborator Author

bourque commented Aug 21, 2024

Closes #767

Comment on lines +41 to +44
CATDESC: Azimuth
FIELDNAM: Azimuth
FORMAT: I2
LABLAXIS: Azimuth
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm planning to provide better labels/descriptions for these in an upcoming PR where I address nomenclature

Copy link
Contributor

@subagonsouth subagonsouth left a comment

Choose a reason for hiding this comment

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

This all looks good to me!

Copy link
Contributor

@tech3371 tech3371 left a comment

Choose a reason for hiding this comment

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

LGTM

# For CoDICE-lo, data are a 3D arrays with a shape representing
# [<num_positions>,<num_spin_sectors>,<num_energy_steps>]
if self.instrument == "lo":
self.data = np.array(science_values_decompressed, dtype=np.uint).reshape(
Copy link
Contributor

Choose a reason for hiding this comment

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

do you mean to add dtype=np.uint32 or 64?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think this can be uint32. This prompted me to read up on what the difference between np.uint and np.uint32 was, and it sounds like uint32 is a better choice:

np.uint:

    This is an alias for the default unsigned integer type in NumPy, which is platform-dependent. On most platforms, np.uint is equivalent to np.uint32, meaning it is a 32-bit unsigned integer. However, this can vary based on the platform and version of NumPy.

np.uint32:

    This explicitly defines a 32-bit unsigned integer. It can store values from 0 to 232−1232−1, which is 0 to 4,294,967,295. This is a fixed-size type and is not platform-dependent.

"""
Apply 8-bit to 32-bit Lossy B decompression algorithm.
Apply 8-bit to 32-bit Lossy A decompression algorithm.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Apply 8-bit to 32-bit Lossy A decompression algorithm.
Apply 8-bit to 32-bit Lossy B decompression algorithm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for catching that! It was a bad copy/paste

@bourque bourque merged commit 2abaa22 into IMAP-Science-Operations-Center:dev Aug 30, 2024
17 checks passed
@bourque bourque deleted the codice-l1-unpacking branch August 30, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ins: CoDICE Related to the CoDICE instrument Level: L1 Level 1 processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CoDICE: Implement proper unpacking and restructuring of data arrays for CoDICE-lo
4 participants