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

Recreate metrics #233

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmip6_preprocessing/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def recreate_metrics(ds, grid):
)
dist = distance(lon0, lat0, lon1, lat1)
ds.coords["dx_gy"] = xr.DataArray(
dist, coords=grid.interp(ds.lon, "Y", boundary="extrapolate").coords
dist, coords=grid.interp(ds.lon, "Y", boundary="extend").coords
)

# infer dy at the east/west face
Expand All @@ -191,7 +191,7 @@ def recreate_metrics(ds, grid):
)
dist = distance(lon0, lat0, lon1, lat1)
ds.coords["dy_gx"] = xr.DataArray(
dist, coords=grid.interp(ds.lon, "X", boundary="extrapolate").coords
dist, coords=grid.interp(ds.lon, "X", boundary="extend").coords
)

# for the distances that dont line up with the cell boundaries we need some different logic
Expand Down Expand Up @@ -265,8 +265,8 @@ def recreate_metrics(ds, grid):
)

metrics_dict = {
"X": [co for co in ["dx_t", "dx_gy", "dx_gx"] if co in ds.coords],
"Y": [co for co in ["dy_t", "dy_gy", "dy_gx"] if co in ds.coords],
"X": [co for co in ["dx_t", "dx_gy", "dx_gx", "dx_gxgy"] if co in ds.coords],
"Y": [co for co in ["dy_t", "dy_gy", "dy_gx", "dy_gxgy"] if co in ds.coords],
"Z": [co for co in ["dz_t"] if co in ds.coords],
}
# # only put out axes that have entries
Expand Down
11 changes: 8 additions & 3 deletions cmip6_preprocessing/specs/staggered_grid_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ NorESM1-F:
NorESM2-LM:
gn:
axis_shift:
X: right
X: left
Y: left
gr:
axis_shift:
X: right
X: left
Y: left
NorESM2-MM:
gn:
Expand Down Expand Up @@ -336,5 +336,10 @@ UKESM1-0-LL:
MPI-ESM1-2-LR:
gn:
axis_shift:
X: left
X: right
Y: left
CMCC-ESM2:
gn:
axis_shift:
X: right
Y: right