Skip to content

Commit

Permalink
deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbuntemeyer committed Jul 3, 2023
1 parent 96bc68d commit 3ebddec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
33 changes: 8 additions & 25 deletions cordex/preprocessing/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,31 +405,13 @@ def get_grid_mapping_name(ds):
grid_mapping_name attribute.
"""
return get_grid_mapping(ds).grid_mapping_name


def get_grid_mapping_varname(ds):
"""Returns grid mapping dataarray name.
Returns the variable name of the first grid mapping found
in the dataset.
Parameters
----------
ds : xr.Dataset
CORDEX like dataset.
Returns
-------
grid_mapping_varname : str
Variable name of the grid mapping.
"""
return next(
ds[va].attrs["grid_mapping"]
for va in ds.data_vars
if "grid_mapping" in ds[va].attrs
message = (
"get_grid_mapping_name is deprecated, please use cf_xarray "
'accessor ds.cf["grid_mapping"].grid_mapping_name instead.'
)
warn(message, DeprecationWarning, stacklevel=2)
return ds.cf["grid_mapping"].grid_mapping_name
# return get_grid_mapping(ds).grid_mapping_name


def get_grid_mapping(ds):
Expand All @@ -455,7 +437,8 @@ def get_grid_mapping(ds):
)
warn(message, DeprecationWarning, stacklevel=2)

return ds[get_grid_mapping_varname(ds)]
return ds.cf["grid_mapping"]
# return ds[get_grid_mapping_varname(ds)]


def remap_lambert_conformal(ds, regridder=None, domain=None):
Expand Down
1 change: 0 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Preprocessing
:toctree: generated/

preprocessing.rename_cordex
preprocessing.get_grid_mapping
preprocessing.replace_coords
preprocessing.cordex_dataset_id
preprocessing.promote_empty_dims
Expand Down

0 comments on commit 3ebddec

Please sign in to comment.