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

WIP/MNT: Update SWE to use packet_file_to_datasets #802

Merged

Conversation

greglucas
Copy link
Collaborator

Change Summary

Overview

This is switching SWE over to packet_file_to_datasets rather than iterating through all of the packets individually.

@greglucas greglucas added Ins: SWE Related to the SWE instrument Level: L0 Level 0 processing labels Aug 30, 2024
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.

Looks great! Thank you for doing this work!

@@ -202,7 +187,7 @@ def swe_science(decom_data: list, data_version: str) -> xr.Dataset:
# Add APID to global attrs for following processing steps
l1a_global_attrs = cdf_attrs.get_global_attributes("imap_swe_l1a_sci")
# Formatting to string to be complaint with ISTP
l1a_global_attrs["packet_apid"] = f"{decom_data[0].header['PKT_APID'].raw_value}"
# l1a_global_attrs["packet_apid"] = SWEAPID.SWE_SCIENCE.value
Copy link
Contributor

Choose a reason for hiding this comment

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

can you uncomment this?

]
)
for var_name, arr in l0_dataset.variables.items():
arr.attrs = cdf_attrs.get_variable_attributes(var_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like we got the CDF attrs set properly for remaining variables. Did you want me to look into CDF attrs for another place/case after this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for doing this! This was on my todo list.

shared_keys = set([x.lower() for x in validation_data.keys()]).intersection(
first_data.keys()
)
# TODO: Why are all the fields not the same between the two
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you clarify this?

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 curious why all the validation data isn't the same as the dataset we are producing. I would think that our dataset should contain all the values that are in the validation data, but there is a difference between the validation data keys, and the created dataset keys.

These are the variables that are in one or the other, but not both.

{'cem1', 'phverno', 'cem3', 'phapid', 'phgroupf', 'cem2', 'phtype', 'phseqcnt', 'timestamp', 'cem5', 'cem4', 'cem6', 'cem7', 'phdlen', 'phshf'}

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Those are CCSDS header but they called it different than our standard names in XTCE. They called it like this.

PHVERNO, PHTYPE, PHSHF, PHAPID, PHGROUPF, PHSEQCNT, PHDLEN

and remaining are decommed data of SCIENCE_DATA -

CEM1, CEM2, CEM3, CEM4, CEM5, CEM6, CEM7

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, would you like me to remove the comment or update it to something else?

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 can add comment to validate those CEM# data when we get better data, that would be great.

Copy link
Collaborator Author

@greglucas greglucas Sep 3, 2024

Choose a reason for hiding this comment

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

👍 Sounds good. I just updated the comment.

assert decom_test_data[2].data["QUARTER_CYCLE"].derived_value == "THIRD"
assert decom_test_data[3].data["QUARTER_CYCLE"].derived_value == "FORTH"
np.testing.assert_array_equal(
decom_test_data.isel(epoch=slice(0, 4))["quarter_cycle"], [0, 1, 2, 3]
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

This is switching SWE over to packet_file_to_datasets rather than
iterating through all of the packets individually.
@greglucas greglucas merged commit 0a9830d into IMAP-Science-Operations-Center:dev Sep 9, 2024
17 checks passed
@greglucas greglucas deleted the swe-l0-update branch September 9, 2024 14:38
@bourque bourque added this to the Sept 2024 milestone Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ins: SWE Related to the SWE instrument Level: L0 Level 0 processing
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants