Copy additional coordinates when regridding#3048
Open
bouweandela wants to merge 10 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3048 +/- ##
=======================================
Coverage 96.18% 96.19%
=======================================
Files 271 271
Lines 15913 15937 +24
=======================================
+ Hits 15306 15330 +24
Misses 607 607 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
For testing purposes, here are four types of grids we commonly encounter: In [1]: from esmvalcore.dataset import Dataset
...: from esmvalcore.preprocessor import regrid
In [2]: cordex_lambert_conformal = Dataset(
...: project="CORDEX",
...: mip="mon",
...: short_name="tas",
...: dataset="RegCM4-6",
...: ensemble="r1i1p1",
...: driver="CNRM-CERFACS-CNRM-CM5",
...: institute="ICTP",
...: domain="EUR-11",
...: exp="historical",
...: rcm_version="v2",
...: timerange="2001/2005",
...: use_standard_grid=True,
...: ).load()
...:
...: cordex_rotated_pole = Dataset(
...: project="CORDEX",
...: mip="day",
...: short_name="ts",
...: dataset="HIRHAM5",
...: ensemble="r1i1p1",
...: driver="IPSL-IPSL-CM5A-MR",
...: institute="DMI",
...: domain="EUR-11",
...: exp="historical",
...: rcm_version="v1",
...: timerange="2001/2005",
...: ).load()
...:
...: tas = Dataset(
...: project="CMIP6",
...: mip="Amon",
...: short_name="tas",
...: dataset="CanESM5",
...: ensemble="r1i1p1f1",
...: exp="historical",
...: grid="gn",
...: timerange="2001/2005",
...: ).load()
...:
...: tos = Dataset(
...: project="CMIP6",
...: mip="Omon",
...: short_name="tos",
...: dataset="CanESM5",
...: ensemble="r1i1p1f1",
...: exp="historical",
...: grid="gn",
...: timerange="2001/2005",
...: ).load()
...:
WARNING:esmvalcore.cmor._fixes.cordex.cordex_fixes:Support for CORDEX datasets in a Lambert Conformal coordinate system is ongoing. Certain preprocessor functions may fail.
WARNING:esmvalcore.cmor._fixes.cordex.cordex_fixes:Maximum difference between original projection_x_coordinate points and standard EUR-11 domain points for variable tas from dataset RegCM4-6 is 131500.0 m. Consider visualizing the data on a map and comparing with recognizable features such as coastlines to check that the grid is correct.
WARNING:esmvalcore.cmor._fixes.cordex.cordex_fixes:Maximum difference between original projection_y_coordinate points and standard EUR-11 domain points for variable tas from dataset RegCM4-6 is 131500.0 m. Consider visualizing the data on a map and comparing with recognizable features such as coastlines to check that the grid is correct.
WARNING:esmvalcore.cmor._fixes.cordex.cordex_fixes:Maximum difference between original latitude points and standard EUR-11 domain points for variable tas from dataset RegCM4-6 is 1.331701984850012 degrees_north. Consider visualizing the data on a map and comparing with recognizable features such as coastlines to check that the grid is correct.
WARNING:esmvalcore.cmor._fixes.cordex.cordex_fixes:Maximum difference between original longitude points and standard EUR-11 domain points for variable tas from dataset RegCM4-6 is 359.7994925609495 degrees_east. Consider visualizing the data on a map and comparing with recognizable features such as coastlines to check that the grid is correct.
/home/bandela/src/esmvalgroup/esmvalcore/.pixi/envs/default/lib/python3.14/site-packages/intake_esgf/catalog.py:73: UserWarning: You have enabled at least one index which uses the old Solr technology. ESGF is moving away from this technology and you may find that some indicesfail to return a response.
warnings.warn(
/home/bandela/src/esmvalgroup/esmvalcore/.pixi/envs/default/lib/python3.14/site-packages/intake_esgf/catalog.py:73: UserWarning: You have enabled at least one index which uses the old Solr technology. ESGF is moving away from this technology and you may find that some indicesfail to return a response.
warnings.warn(Note that with this branch, the regridded data has all horizontal coordinates of the target grid, instead of a subset: In [3]: regrid(tos, target_grid=cordex_rotated_pole, scheme="linear").coords()
Out[3]:
[<DimCoord: time / (days since 1850-1-1 00:00:00) [...]+bounds shape(60,)>,
<DimCoord: grid_latitude / (degrees) [-23.375, ...]+bounds shape(412,)>,
<DimCoord: grid_longitude / (degrees) [-28.375, ...]+bounds shape(424,)>,
<AuxCoord: latitude / (degrees_north) [...]+bounds shape(412, 424)>,
<AuxCoord: longitude / (degrees_east) [...]+bounds shape(412, 424)>]
In [4]: regrid(cordex_rotated_pole, target_grid=tos, scheme="linear").coords()
Out[4]:
[<DimCoord: time / (days since 1850-1-1 00:00:00) [...]+bounds shape(1825,)>,
<DimCoord: cell index along second dimension / (1) [ 0, 1, ..., 289, 290] shape(291,)>,
<DimCoord: cell index along first dimension / (1) [ 0, 1, ..., 358, 359] shape(360,)>,
<AuxCoord: latitude / (degrees_north) [...]+bounds shape(291, 360)>,
<AuxCoord: longitude / (degrees_east) [[73.5, 74.5, ..., 71.5, 72.5], ...]+bounds shape(291, 360)>]while with the current In [3]: regrid(tos, target_grid=cordex_rotated_pole, scheme="linear").coords()
Out[3]:
[<DimCoord: time / (days since 1850-1-1 00:00:00) [...]+bounds shape(60,)>,
<DimCoord: grid_latitude / (degrees) [-23.375, ...]+bounds shape(412,)>,
<DimCoord: grid_longitude / (degrees) [-28.375, ...]+bounds shape(424,)>]
In [4]: regrid(cordex_rotated_pole, target_grid=tos, scheme="linear").coords()
Out[4]:
[<DimCoord: time / (days since 1850-1-1 00:00:00) [...]+bounds shape(1825,)>,
<AuxCoord: latitude / (degrees_north) [...]+bounds shape(291, 360)>,
<AuxCoord: longitude / (degrees_east) [[73.5, 74.5, ..., 71.5, 72.5], ...]+bounds shape(291, 360)>] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
regridpreprocessor function regrids one set of coordinates to another. However, CORDEX data typically has two sets of coordinates:rotated_latitude/rotated_longitudeorprojection_y_coordinate/projection_x_coordinateas airis.coords.DimCoordandlatitude/longitudeas an additionaliris.coords.AuxCoord. The changes in this pull request ensure that if the target grid has multiple coordinates, these will be available on the regridded cube, even if only one set is used for the regridding.Closes #2839
Link to documentation:
Before you get started
Checklist
It is the responsibility of the author to make sure the pull request is ready to review. The icons indicate whether the item will be subject to the 🛠 Technical or 🧪 Scientific review.
To help with the number pull requests: