Skip to content

Conversation

@davidhassell
Copy link
Collaborator

Bug fix for #715

Discovered when this tutorial example code failed with ValueError: Z coordinate 'dimensioncoordinate0' must match exactly an element of 'axes' (['domainaxis0'])

    >>> v = cf.read('vertical.nc')[0]
   >>> print(v)
   Field: eastward_wind (ncvar%ua)
   -------------------------------
   Data            : eastward_wind(time(3), air_pressure(5), grid_latitude(11), grid_longitude(10)) m s-1
   Cell methods    : time(3): mean
   Dimension coords: time(3) = [1979-05-01 12:00:00, 1979-05-02 12:00:00, 1979-05-03 12:00:00] gregorian
                   : air_pressure(5) = [850.0, ..., 50.0] hPa
                   : grid_latitude(11) = [23.32, ..., 18.92] degrees
                   : grid_longitude(10) = [-20.54, ..., -16.58] degrees
   Auxiliary coords: latitude(grid_latitude(11), grid_longitude(10)) = [[67.12, ..., 66.07]] degrees_north
                   : longitude(grid_latitude(11), grid_longitude(10)) = [[-45.98, ..., -31.73]] degrees_east
   Coord references: grid_mapping_name:rotated_latitude_longitude
   >>> new_z = cf.DimensionCoordinate(data=cf.Data([800, 705, 632, 510, 320.], 'hPa'))
   >>> new_v = v.regridc([new_z], axes='Z', method='linear', z='Z', ln_z=True)
   >>> print(new_v)
   Field: eastward_wind (ncvar%ua)
   -------------------------------
   Data            : eastward_wind(time(3), Z(5), grid_latitude(11), grid_longitude(10)) m s-1
   Cell methods    : time(3): mean
   Dimension coords: time(3) = [1979-05-01 12:00:00, 1979-05-02 12:00:00, 1979-05-03 12:00:00] gregorian
                   : Z(5) = [800.0, ..., 320.0] hPa
                   : grid_latitude(11) = [23.32, ..., 18.92] degrees
                   : grid_longitude(10) = [-20.54, ..., -16.58] degrees
   Auxiliary coords: latitude(grid_latitude(11), grid_longitude(10)) = [[67.12, ..., 66.07]] degrees_north
                   : longitude(grid_latitude(11), grid_longitude(10)) = [[-45.98, ..., -31.73]] degrees_east
   Coord references: grid_mapping_name:rotated_latitude_longitude

@davidhassell davidhassell added bug Something isn't working regridding Relating to regridding operations labels Mar 26, 2024
@davidhassell davidhassell added this to the Next release milestone Mar 26, 2024
Copy link
Member

@sadielbartholomew sadielbartholomew left a comment

Choose a reason for hiding this comment

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

I have confirmed that this isolates the bug with a test and fixes it in a logical way. We should probably add a Changelog entry so we don't lose track of the fix, so ideally add one now here, but otherwise this is all good, so please merge.

@davidhassell
Copy link
Collaborator Author

No need for a new change log entrry, as the existing

* Added 3-d spherical regridding to `cf.Field.regrids`, and the option
  to regrid the vertical axis in logarithmic coordinates to
  `cf.Field.regrids` and `cf.Field.regridc`
  (https://github.com/NCAS-CMS/cf-python/issues/715)

covers it - this PR is raised against that issue.

@davidhassell davidhassell merged commit 7827ba4 into NCAS-CMS:main Mar 26, 2024
@sadielbartholomew
Copy link
Member

Oh fair, good point. Thanks David.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working regridding Relating to regridding operations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow 3-d spherical regridding, including an option to regrid the vertical axis in logarithmic coordinates

2 participants