-
Notifications
You must be signed in to change notification settings - Fork 44
Closed
Description
Hi! I'm using recreate_metrics
to calculate distances along cmip6 grids. It can calculate all metrics (dx_t
, dy_t
, dx_gy
, dy_gx
, dx_gx
, dy_gy
, dy_gxgy
and dz_t
) except for dx_gxgy
(dx at the corner point). When using the ff method:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Input In [34], in <cell line: 2>()
1 # infer dx at the corner point
----> 2 lon0, lon1 = grid.axes["X"]._get_neighbor_data_pairs(
3 _interp_vertex_to_bounds(ds.lon_verticies.load(), "y")
4 .isel(bnds=ns_bound_idx)
5 .squeeze(),
6 axis_vel_pos["X"],
7 )
The input positions to _get_neighbor_data_pairs
are similar and this error appears:
File /srv/conda/envs/notebook/lib/python3.9/site-packages/xgcm/grid.py:517, in Axis._get_neighbor_data_pairs(self, da, position_to, boundary, fill_value, ignore_connections, boundary_discontinuity, vector_partner, position_check)
514 valid_positions = ["outer", "inner", "left", "right", "center"]
516 if position_to == position_from:
--> 517 raise ValueError("Can't get neighbor pairs for the same position.")
519 if position_to not in valid_positions:
520 raise ValueError(
521 "`%s` is not a valid axis position name. Valid "
522 "names are %r." % (position_to, valid_positions)
523 )
ValueError: Can't get neighbor pairs for the same position.
I tried it with CMIP6 models where the X
axis is either shifted to the right (e.g., IPSL-CM6A-LR
) or left (e.g., NorESM2-LM
), and the same error appears. Example:
cat_url = "https://storage.googleapis.com/cmip6/pangeo-cmip6-noQC.json"
col = intake.open_esm_datastore(cat_url)
cat = col.search(table_id='Omon',experiment_id='historical',
variable_id=['wmo','umo','vmo'], grid_label='gn', member_id='r1i1p1f1',source_id='IPSL-CM6A-LR')
ipsl = cat.to_dataset_dict(
zarr_kwargs={'consolidated':True, 'decode_times': True, 'use_cftime': True},
preprocess=combined_preprocessing,
aggregate=False)
wmo = ipsl['CMIP.IPSL.IPSL-CM6A-LR.historical.r1i1p1f1.Omon.wmo.gn.gs://cmip6/CMIP6/CMIP/IPSL/IPSL-CM6A-LR/historical/r1i1p1f1/Omon/wmo/gn/v20180803/.nan.20180803.good.none.none']
umo = ipsl['CMIP.IPSL.IPSL-CM6A-LR.historical.r1i1p1f1.Omon.umo.gn.gs://cmip6/CMIP6/CMIP/IPSL/IPSL-CM6A-LR/historical/r1i1p1f1/Omon/umo/gn/v20180803/.nan.20180803.good.none.none']
vmo = ipsl['CMIP.IPSL.IPSL-CM6A-LR.historical.r1i1p1f1.Omon.vmo.gn.gs://cmip6/CMIP6/CMIP/IPSL/IPSL-CM6A-LR/historical/r1i1p1f1/Omon/vmo/gn/v20180803/.nan.20180803.good.none.none']
umo = umo.rename({'x':'x_c','lon':'lon_u', 'lat':'lat_u'})
vmo = vmo.rename({'y':'y_c','lon':'lon_v', 'lat':'lat_v'})
wmo = wmo.rename({'lev': 'lev_w'})
ds_subset = xr.merge([umo, vmo, wmo], compat='override')
grid = Grid(ds_subset, coords={ 'X':{'center':'x', 'right':'x_c'}, 'Y':{'center':'y', 'right': 'y_c'}, 'Z':{'center':'lev'},},)
ds, metrics_dict = recreate_metrics(ds_subset, grid)
ValueError: Can't get neighbor pairs for the same position.
Metadata
Metadata
Assignees
Labels
No labels