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

IDEX L1b science data processing #1224

Open
wants to merge 20 commits into
base: dev
Choose a base branch
from

Conversation

lacoak21
Copy link
Contributor

Change Summary

IDEX l1b science data processing and tests

Overview

Adds processing to unpack telemetry items using imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv, and converts all instrument setting variables and waveforms to engineering units.

Addition of spice data and two more attributes will be added in another PR.

closes #833

New Files

  • imap_processing/cdf/config/imap_idex_l1b_variable_attrs.yaml
    • L1b variable attrs
  • imap_processing/idex/idex_l1b.py
    • Unpack instrument settings
    • Convert instrument settings and waveforms to engineering units
  • imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv
    • Csv containing unpacking information and conversions
  • imap_processing/tests/idex/test_idex_l1b.py
    • Tests for l1b code

Updated Files

  • imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml
    • Add l1b data level
  • imap_processing/idex/idex_l1a.py
    • Add logger statement
    • Fix dimension for science variable
  • imap_processing/cli.py
    • Fixed L1a cli handling
    • Added L1b handling

Testing

  • 5 l1b unit tests added

@lacoak21 lacoak21 added Ins: IDEX Related to the IDEX instrument Level: L1 Level 1 processing labels Dec 16, 2024
@lacoak21 lacoak21 added this to the Dec 2024 milestone Dec 16, 2024
@lacoak21 lacoak21 requested a review from a team December 16, 2024 18:03
@lacoak21 lacoak21 self-assigned this Dec 16, 2024
@lacoak21 lacoak21 requested review from bourque, sdhoyt, subagonsouth and tech3371 and removed request for a team December 16, 2024 18:03
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.

I had some non-blocking comments. Once you address those, it looks good to me!


l1b_tof_base: &l1b_tof_base
<<: *l1b_data_base
DEPEND_1: time_high_sr
Copy link
Contributor

Choose a reason for hiding this comment

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

If you have a DEPEND_1, then you will need LABL_PTR_1 instead of LABLAXIS. I tried to capture something about this here, https://imap-processing.readthedocs.io/en/latest/external-tools/cdf/cdf_requirements.html#metadata-data. But let me know if you like to chat about this.

Copy link
Contributor Author

@lacoak21 lacoak21 Dec 18, 2024

Choose a reason for hiding this comment

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

Ah got it! Thanks for linking those docs. I think I need to do this for l1a as well and then can copy them to l1b.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good. If this is not blocking this PR, then you can do that in future PR if you like to not make this PR bigger.

imap_processing/idex/idex_l1b.py Show resolved Hide resolved
imap_processing/idex/idex_l1b.py Show resolved Hide resolved
imap_processing/idex/idex_l1b.py Show resolved Hide resolved
imap_processing/idex/idex_l1b.py Show resolved Hide resolved
imap_processing/tests/idex/test_idex_l1b.py Show resolved Hide resolved
imap_processing/tests/idex/test_idex_l1b.py 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.

Great work. Nice clean, well organized code. I left a few comments to consider.

VAR_TYPE: data
CATDESC: ""
FIELDNAM: ""
FILLVAL: *int_fillval
Copy link
Contributor

Choose a reason for hiding this comment

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

The defined int_fillval is only valid for 64 bit signed integers. Based on the VALIDMIN and VALIDMAX, it seems like a mismatch.

detector_voltage:
<<: *trigger_base
FIELDNAM: Detector Voltage
CATDESC: Last measurement in raw dN for processor board signal - "Detector Voltage"
Copy link
Contributor

Choose a reason for hiding this comment

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

All of these CATDESCs say "measurement in raw dN" but the UNITS say Voltage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes those descriptions should be updated thanks

imap_processing/tests/idex/test_idex_l1b.py Show resolved Hide resolved
return l1b_dataset


def unpack_instrument_settings(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason that the fields that get unpacked are not defined in the xtce and unpacked by space_packet_parser rather than as done here at L1B?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was also confused about that. I talked to the IDEX team and they wanted l1a to have all the raw instrument settings so people could go back to l1a and look at them if need be.

l1b_dataset = convert_raw_to_eu(
l1b_dataset,
conversion_table_path=var_information_path,
packet_name=var_information_df["packetName"].to_list(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting... The docstring for convert_raw_to_eu says packet_name is a str, not a list. Is this working correctly? The function reduces the dataframe read in from the conversion table to only the entries where dataframe["packetName"] == packet_name which I would expect to be an array full of False, meaning no conversions get applied.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm it is in fact working as expected. It is converting every value but I am definitely using "packetName" incorrectly. I will have to fix this.

imap_processing/idex/idex_l1b.py Show resolved Hide resolved
waveforms_pc = {}

for var in ConvFactors:
waveforms_pc[var.name] = l1a_dataset[var.name] * var.value
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that numpy will convert the dtype to a float in this statement. Is that the desired dtype for the output CDF?

Copy link
Collaborator

@bourque bourque left a comment

Choose a reason for hiding this comment

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

Awesome work, you are making great progress! I have a few minor suggestions if you want to use them, otherwise this looks good.

imap_processing/tests/idex/test_idex_l1b.py Show resolved Hide resolved
imap_processing/tests/idex/test_idex_l1b.py Show resolved Hide resolved
imap_processing/idex/idex_l1b.py Show resolved Hide resolved
imap_processing/idex/idex_l1b.py Show resolved Hide resolved
imap_processing/idex/idex_l1b.py Show resolved Hide resolved
imap_processing/idex/idex_l1b.py Show resolved Hide resolved
imap_processing/idex/idex_l1b.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ins: IDEX Related to the IDEX instrument Level: L1 Level 1 processing
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Produce IDEX L1B CDFs
4 participants