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

Lo L1C CDF Creation for SIT-3 #614

Merged
merged 22 commits into from
Jun 13, 2024

Conversation

sdhoyt
Copy link
Contributor

@sdhoyt sdhoyt commented Jun 12, 2024

Change Summary

Overview

This PR adds adds the following:

  • Lo L1C CDF YAML attribute definitions for Pointing Sets (minimum goal for SIT-3)
  • CDF Creation for Pointing Sets (minimum goal for SIT-3)
    • I have no sample data so there is temporary code in here to get things working for SIT-3
  • Updates to cli.py to kick off Lo L1C processing

New Dependencies

None

New Files

  • imap_processing/cdf/config/imap_lo_l1c_variable_attrs.yaml
  • imap_processing/lo/l1c/lo_l1c.py
    • handles Lo L1C processing

Deleted Files

None

Updated Files

  • imap_processing/cdf/config/imap_lo_global_cdf_attrs.yaml
    • Added L1C global attrs
  • imap_processing/cli.py
    • added trigger for Lo L1C processing

Testing

  • added the unit test test_lo_l1b to test L1B processing
  • ran cli.py and checked the correct file was created in the database

@sdhoyt sdhoyt added Ins: Lo Related to the IMAP-Lo instrument Level: L1 Level 1 processing labels Jun 12, 2024
@sdhoyt sdhoyt requested a review from a team June 12, 2024 18:12
@sdhoyt sdhoyt self-assigned this Jun 12, 2024
@sdhoyt sdhoyt requested review from bourque, greglucas, subagonsouth and tech3371 and removed request for a team June 12, 2024 18:12
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 is great. I have a few comments. Thanks for the nice idea of how to generate the dims keyword argument needed for the xr.DataArray constructor.

coords={
"epoch": epoch_time,
"pointing_bins": pointing_bins,
"pointing_bins_label": pointing_bins_label,
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 that you are perhaps following what @tech3371 did. I didn't catch this in her PR, but I wonder if the label variables should really be coordinates or are they just regular variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good question. If they can be normal variables, I feel like it still makes more sense to have them as coordinates since they're basically string versions of the coordinates. I haven't looked at it much yet, but I'm hoping there is a good way to just convert the data to a string and use that as the label within write_cdf or cdflib instead of having to define attributes for the label since all the attributes are easily determined (ie. string length) or straight from the coordinate attributes.

field = data_field.name.lower()
# Create a list of all the dimensions using the DEPEND_I keys in the
# YAML attributes
dims = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. I like that you are extracting the dims form the attributes. I need to implement this in my pointing set code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree this is nice. I wonder if we should add this as a general helper to the AttributeManager class (not in this PR). get_variable_dims() (naming TBD) that would encapsulate this logic for everyone.

assert dataset.mode.shape[0] == 1
assert len(dataset.pivot_angle.shape) == 1
assert dataset.pivot_angle.shape[0] == 1
assert len(dataset.triples_counts.shape) == 3
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 the individual asserts for each variable can be done in a single line such as:

Suggested change
assert len(dataset.triples_counts.shape) == 3
np.testing.assert_array_equal(dataset.triples_counts.shape, (1, 3600, 7))

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe just compare against an array itself which will also check shape for you: np.testing.assert_array_equal(dataset.triples_counts, np.ones((1, 3600, 7)))

pointing_bins_label:
CATDESC: Pointing bins
FIELDNAM: Pointing bins
FORMAT: A3
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 this has to be A4 to fit any value > 999.

esa_step_label:
CATDESC: ESA Steps
FIELDNAM: ESA Steps
FORMAT: A3
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this just be A1 since esa_step will always be one character?

# The data type will be set in the data class when that's created
elif field == "exposure_time":
dataset[field] = xr.DataArray(
data=[7 * [np.float16(1)]],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest using numpy array shapes for all of these temporary data fields which is a bit more explicit IMO.

Suggested change
data=[7 * [np.float16(1)]],
data=np.ones((1, 7), dtype=np.float16),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I need to get better at recognizing when I can use numpy

assert dataset.mode.shape[0] == 1
assert len(dataset.pivot_angle.shape) == 1
assert dataset.pivot_angle.shape[0] == 1
assert len(dataset.triples_counts.shape) == 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe just compare against an array itself which will also check shape for you: np.testing.assert_array_equal(dataset.triples_counts, np.ones((1, 3600, 7)))

@sdhoyt sdhoyt requested review from greglucas and subagonsouth June 13, 2024 15:30
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.

Looks good to me.

@sdhoyt sdhoyt merged commit a242a47 into IMAP-Science-Operations-Center:dev Jun 13, 2024
17 checks passed
@sdhoyt sdhoyt deleted the lo-l1c-cdf branch June 13, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ins: Lo Related to the IMAP-Lo instrument Level: L1 Level 1 processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants