Skip to content

Commit

Permalink
Update xesmf to versions >= 0.4.0 (#2728)
Browse files Browse the repository at this point in the history
Co-authored-by: Valeriu Predoi <valeriu.predoi@gmail.com>
  • Loading branch information
zklaus and valeriupredoi committed May 23, 2023
1 parent 4f6369c commit 113cdb6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ jobs:
- run:
name: Install dependencies
command: |
set -x
. /opt/conda/etc/profile.d/conda.sh
conda activate esmvaltool
mkdir /logs
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies:
- seawater
- shapely <2.0.0 # github.com/ESMValGroup/ESMValTool/issues/2965
- xarray>=0.12.0
- xesmf==0.3.0
- xesmf>=0.7.1
- xgboost>1.6.1 # github.com/ESMValGroup/ESMValTool/issues/2779
- xlsxwriter
- zarr
Expand Down
2 changes: 1 addition & 1 deletion environment_osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ dependencies:
- seawater
- shapely
- xarray>=0.12.0
- xesmf==0.3.0
- xesmf>=0.7.1
- xgboost>1.6.1 # github.com/ESMValGroup/ESMValTool/issues/2779
- xlsxwriter
- zarr
Expand Down
18 changes: 10 additions & 8 deletions esmvaltool/cmorizers/data/formatters/datasets/cds_uerra.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
Notes
-----
- It might be needed to split up the request into smaller chunks
- This script uses the xesmf regridder, which is not standard included in
ESMValTool, install it in the esmvaltool environment:
conda install -c conda-forge xesmf
Modification history
20190821-A_crezee_bas: written.
Expand Down Expand Up @@ -216,6 +212,7 @@ def _regrid_dataset(in_dir, var, cfg):
# Match any year here
filepattern = var['file'].format(year='????', month='??')
filelist = glob.glob(os.path.join(in_dir, filepattern))
regridder = None
for infile in filelist:
_, infile_tail = os.path.split(infile)
outfile = os.path.join(cfg['work_dir'], infile_tail)
Expand All @@ -234,10 +231,15 @@ def _regrid_dataset(in_dir, var, cfg):
assert int((input_da == 0.).sum()) == 0 # Make sure that there
# are no zero's in the data,
# since they will be masked out
regridder = xe.Regridder(input_ds,
targetgrid_ds,
'bilinear',
reuse_weights=True)
shapes = (input_ds["lon"].shape, input_ds["lat"].shape,
targetgrid_ds["lon"].shape, targetgrid_ds["lat"].shape)
if regridder is None:
regridder = xe.Regridder(input_ds,
targetgrid_ds,
'bilinear')
ref_shapes = shapes
else:
assert shapes == ref_shapes
da_out = regridder(input_da)
da_out = da_out.where(da_out != 0.)
da_out = da_out - constantval
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
'seawater',
'shapely<2.0.0', # github.com/ESMValGroup/ESMValTool/issues/2965
'xarray',
'xesmf==0.3.0',
'xesmf>=0.7.1',
'xgboost>1.6.1', # github.com/ESMValGroup/ESMValTool/issues/2779
'xlsxwriter',
'zarr',
Expand Down

0 comments on commit 113cdb6

Please sign in to comment.