Skip to content

Conversation

flamingbear
Copy link
Member

@flamingbear flamingbear commented Aug 28, 2025

Description

A short description of the changes in this PR.

Write dimension variables into inherited groups. This is a band-aid to xarray's roundtrip of opening a datatree with inherited dimensions getting added to the child groups. What results is a dimension on the group that doesn't exist. Because there's a keyword parameter to the datatree.to_netcdf function this may be a design choice. I am going to look and see. But for now, writing the dimension vars into the child groups allows panoply to open the files properly.

This change will require regression hashes to be updated as the output files will be different for many requests.

Jira Issue ID

DAS-2411

Local Test Steps

Pull this branch. Build and verify all tests pass. Deploy the image to your local Harmony-In-A-Box.

Run this curl command against uat and localhost to generate the file against the current implementation (uat) and the updated (localhost)

curl -Ln -bj 'http://localhost:3000/C1263085200-NSIDC_CUAT/ogc-api-coverages/1.0.0/collections/parameter_vars/coverage/rangeset?granuleId=G1263085428-NSIDC_CUAT&subset=lat(25.0%3A49.8)&subset=lon(-127.0%3A-65.0)&variable=EASE2_global_projection&variable=GEO%2Flatitude&variable=GEO%2Flongitude&variable=NEE%2Fnee_mean&variable=RH%2Frh_mean&variable=x&variable=y&serviceId=S1273752002-EEDTEST' -o spl4cmdl-localhost.nc4

and

curl -Ln -bj 'http://harmony.uat.earthdata.nasa.gov/C1263085200-NSIDC_CUAT/ogc-api-coverages/1.0.0/collections/parameter_vars/coverage/rangeset?granuleId=G1263085428-NSIDC_CUAT&subset=lat(25.0%3A49.8)&subset=lon(-127.0%3A-65.0)&variable=EASE2_global_projection&variable=GEO%2Flatitude&variable=GEO%2Flongitude&variable=NEE%2Fnee_mean&variable=RH%2Frh_mean&variable=x&variable=y&serviceId=S1273752002-EEDTEST' -o spl4cmdl-uat.nc4

Open the files and verify that the localhost variables are plotable in panoply but the uat's are not.

PR Acceptance Checklist

  • Jira ticket acceptance criteria met.
  • CHANGELOG.md updated to include high level summary of PR changes.
  • docker/service_version.txt updated if publishing a release.
  • [N/A] Tests added/updated and passing.
  • Documentation updated (if needed).

The xarray to_NetCDF() function appears to enforce alignment of dimensions in a
hierarchical tree, including writing those dimensions into groups below that
inherited them.  by including the keyword write_inherited_coords=True on the
function call the dimension variables are also included. This allows panoply to
find the needed values to plot a variable
@@ -115,7 +115,7 @@ def amend_in_file_metadata(
# whole `xarray.DataTree` in one operation. Making this write variables
# and group separately reduces the memory usage, but makes the
# operation slower. (See Harmony SMAP L2 Gridder implementation)
datatree.to_netcdf(output_file_name)
datatree.to_netcdf(output_file_name, write_inherited_coords=True)

Choose a reason for hiding this comment

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

Is there a JIRA to investigation/fix a better solution?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope. I'm going to do some quick investigation today if I get a chance.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually this is going to end up involved. But I've discovered why HRS is failing after this update and will have to implement configuration changes there also. before generating the regression output.

@vutrannasa
Copy link

vutrannasa commented Aug 29, 2025

Test: PASS
Env: localhost

Test Steps:

Screenshot 2025-08-29 at 12 40 37 PM branch)
  • Ran curl command against UAT:
    curl -Ln -bj 'http://harmony.uat.earthdata.nasa.gov/C1263085200-NSIDC_CUAT/ogc-api-coverages/1.0.0/collections/parameter_vars/coverage/rangeset?granuleId=G1263085428-NSIDC_CUAT&subset=lat(25.0%3A49.8)&subset=lon(-127.0%3A-65.0)&variable=EASE2_global_projection&variable=GEO%2Flatitude&variable=GEO%2Flongitude&variable=NEE%2Fnee_mean&variable=RH%2Frh_mean&variable=x&variable=y&serviceId=S1273752002-EEDTEST' -o spl4cmdl-uat.nc4
  • Verify Panaploy NOT able to view UAT request

Copy link

@vutrannasa vutrannasa left a comment

Choose a reason for hiding this comment

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

Great job

@flamingbear
Copy link
Member Author

I'm going to close this. This fix was working around pydata/xarray#10241 before I could discover if that was a bug or design decision. Since this is fixed in xarray v25.8.0. I'm going to add h5netcdf to the deps and remove it when we can add the next version of xarray that includes the fix to pydata/xarray#10654. with the PR pydata/xarray#10656

@flamingbear flamingbear closed this Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants