xESMF icon indicating copy to clipboard operation
xESMF copied to clipboard

xESMF with CMIP6 models

Open sg2400 opened this issue 5 years ago • 16 comments

Hi

Thanks for writing this package. I have been trying to use xESMF with a number of CMIP6 models, and while some are working, others are not; and it is not clear why these are not working. The error message is not clear to me. For example, the following error was with the model CNRM-ESM2-1:

ValueError: ESMC_FieldRegridStoreFile() failed with rc = 506. Please check the log files (named "*ESMF_LogFile").

and the Log file states that:

20191210 115316.651 ERROR PET0 ESMF_Regrid.F90:360 ESMF_RegridStore Invalid argument - Internal subroutine call returned Error 20191210 115316.658 ERROR PET0 ESMF_FieldRegrid.F90:1292 ESMF_FieldRegridStoreNX Invalid argument - Internal subroutine call returned Error 20191210 115316.658 ERROR PET0 ESMF_Field_C.F90:1168 f_esmf_regridstorefile Invalid argument - Internal subroutine call returned Error 20191210 115316.713 INFO PET0 Finalizing ESMF

Thanks

sg2400 avatar Dec 10 '19 11:12 sg2400

Could you post the complete notebook to reproduce the error, so I can actually diagnose the problem? Please also include the steps/commands to obtain the data files. See more at ask for help

Just notice today that CMIP6 is now available in Google cloud storage. You can probably reproduce the workflow via Pangeo binder: https://github.com/hdrake/cmip6-temperature-demo/

JiaweiZhuang avatar Dec 10 '19 17:12 JiaweiZhuang

Hi. Sorry for the delay, but I have not used the Pangeo binder before, and it seems to have a bit of a learning curve. I have attached a small script (extension changed to .txt) that shows the problem. The data file can be downloaded from

https://drive.google.com/file/d/14KTlJV6qvNlDT_xDsJ3UrzQOU2MuNeAn/view?usp=sharing

This is not the only model that has problems. As mentioned before, some models work fine.

Thanks xesmf_cmip6.py.txt

sg2400 avatar Dec 16 '19 09:12 sg2400

Hello. I am experiencing the same error with the model IPSL. I had success using the below script for the CESM2 and CanESM5 models. Thank you in advance.

The netcdf file is here: https://www.dropbox.com/s/rcyzd97ne2raszi/IPSL_fgco2.nc?dl=0

The steps I used after loading the file: ds_out = xe.util.grid_global(1, 1) regridder = xe.Regridder(IPSL_fgco2, ds_out, 'bilinear', reuse_weights=True) dr_out = regridder(IPSL_fgco2) IPSL_conv_lon = et.grid.convert_lon(IPSL_fgco2) regridder = xe.Regridder(IPSL_conv_lon, ds_out, 'bilinear', reuse_weights=True, periodic=True) dr_out = regridder(IPSL_conv_lon)

Error:

ValueError Traceback (most recent call last) in 1 # 3/10/20 copy and paste all of warning/error messages to send to xe designer 2 ----> 3 regridder = xe.Regridder(IPSL_conv_lon, ds_out, 'bilinear', reuse_weights=True, periodic=True) 4 dr_out = regridder(IPSL_conv_lon)

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/xesmf/frontend.py in init(self, ds_in, ds_out, method, periodic, filename, reuse_weights, ignore_degenerate) 180 181 # get weight matrix --> 182 self._write_weight_file() 183 self.weights = read_weights(self.filename, self.n_in, self.n_out) 184

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/xesmf/frontend.py in _write_weight_file(self) 224 regrid = esmf_regrid_build(self._grid_in, self._grid_out, self.method, 225 filename=self.filename, --> 226 ignore_degenerate=self.ignore_degenerate) 227 esmf_regrid_finalize(regrid) # only need weights, not regrid object 228

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/xesmf/backend.py in esmf_regrid_build(sourcegrid, destgrid, method, filename, extra_dims, ignore_degenerate) 246 regrid_method=esmf_regrid_method, 247 unmapped_action=ESMF.UnmappedAction.IGNORE, --> 248 ignore_degenerate=ignore_degenerate) 249 250 return regrid

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/ESMF/util/decorators.py in new_func(*args, **kwargs) 62 63 esmp = esmpymanager.Manager(debug = False) ---> 64 return func(*args, **kwargs) 65 return new_func 66

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/ESMF/api/regrid.py in init(self, srcfield, dstfield, filename, src_mask_values, dst_mask_values, regrid_method, pole_method, regrid_pole_npoints, line_type, norm_type, extrap_method, extrap_num_src_pnts, extrap_dist_exponent, unmapped_action, ignore_degenerate, create_rh, src_frac_field, dst_frac_field) 148 createRH=create_rh, 149 srcFracField=src_frac_field, --> 150 dstFracField=dst_frac_field) 151 else: 152 self._routehandle = ESMP_FieldRegridStore(srcfield, dstfield,

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/ESMF/util/decorators.py in new_func(*args, **kwargs) 50 lineno=func.code.co_firstlineno + 1, 51 ) ---> 52 return func(*args, **kwargs) 53 return new_func 54

/usr/local/Caskroom/miniconda/base/lib/python3.7/site-packages/ESMF/interface/cbindings.py in ESMP_FieldRegridStoreFile(srcField, dstField, filename, srcMaskValues, dstMaskValues, regridmethod, polemethod, regridPoleNPnts, lineType, normType, unmappedaction, ignoreDegenerate, createRH, srcFracField, dstFracField) 2146 if rc != constants._ESMP_SUCCESS: 2147 raise ValueError('ESMC_FieldRegridStoreFile() failed with rc = '+str(rc)+ -> 2148 '. '+constants._errmsg) 2149 return routehandle 2150

ValueError: ESMC_FieldRegridStoreFile() failed with rc = 506. Please check the log files (named "*ESMF_LogFile").

holivarez19 avatar Mar 16 '20 14:03 holivarez19

I just ran into this error too, it appears to be just related to the CNRM-ESM2 (and CNRM-CM6) ocean model as I am able to regrid data from the atmospheric model using the same bit of code, see below. Thank you!

set up common grid

ds_out = xr.Dataset({'lat': (['lat'], np.arange(-88.5, 89.5, 1.)), 'lon': (['lon'], np.arange(0.5, 360., 1.)), } )

def regrid_to_common(ds, ds_out): """ Regrid from rectilinear grid to common grid """ regridder = xe.Regridder(ds, ds_out, 'bilinear',periodic=True, reuse_weights=True) return regridder(ds)

ds = (load_tas_data(source_id, 'historical', mem_id).sel(time=slice('1901', '2014')))

rename spatial dimensions if necessary

if ('longitude' in ds.dims) and ('latitude' in ds.dims): ds = ds.rename({'longitude':'lon', 'latitude': 'lat'}) if ('i' in ds.dims) and ('j' in ds.dims): ds = ds.rename({'longitude':'lon', 'latitude': 'lat'}) ds = xr.decode_cf(ds)

sst_ng = ds.tos # get data on native grade sst = regrid_to_common(sst_ng, ds_out) regrid

amvaruolo-clarke avatar Mar 24 '20 21:03 amvaruolo-clarke

I find this 506 type error for many ocean models. I dont understand the underlying problem.

aaronspring avatar May 11 '20 13:05 aaronspring

the error doesnt occur with ignore_degenerate=True. this closes the issue from my point of view

aaronspring avatar Jun 05 '20 16:06 aaronspring

Thank you, Aaron! This worked for me as well.

-- Holly Olivarez (she/her) NSF Graduate Research Fellow Environmental Studies Program Institute of Arctic and Alpine Research (INSTAAR) University of Colorado Boulder instaar.colorado.edu/people/holly-olivarezhttps://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Finstaar.colorado.edu%2Fpeople%2Fholly-olivarez%2F&data=01%7C01%7Ciceleste%40nmsu.edu%7Cc334f0e0680b495e4f3008d73c744f33%7Ca3ec87a89fb84158ba8ff11bace1ebaa%7C1&sdata=al3Yq0xvgDxlnaLBASzEYJ7QC%2BwYaxTJ5FmIASPR3q0%3D&reserved=0 @holivarez19

From: Aaron Spring [email protected] Reply-To: JiaweiZhuang/xESMF [email protected] Date: Friday, June 5, 2020 at 10:18 AM To: JiaweiZhuang/xESMF [email protected] Cc: Holly Olivarez [email protected], Comment [email protected] Subject: Re: [JiaweiZhuang/xESMF] xESMF with CMIP6 models (#78)

the error doesnt occur with ignore_degenerate=True. this closes the issue from my point of view

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/JiaweiZhuang/xESMF/issues/78#issuecomment-639606052, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJOLXOTOLRP5N7GHCEY2MG3RVELHBANCNFSM4JY5IISA.

holivarez19 avatar Jul 14 '20 15:07 holivarez19

Setting ignore_degenerate=True does not appear to uniformly fix the issue, at least for regridding the CMIP6 MPI-ESM1-2-HR monthly precipitation values hosted on Pangeo. When including that argument within xe.Regridder() I get the error message TypeError: __init__() got an unexpected keyword argument 'ignore_degenerate'.

tristanballard avatar Aug 19 '20 06:08 tristanballard

Which version of xesmf are you using?

aaronspring avatar Aug 19 '20 07:08 aaronspring

Setting ignore_degenerate=True did not fix the issue. When I include that argument i get the error message AssertionError: The horizontal shape of input data is (362, 4), different from that ofthe regridder (332, 362)!

my xesmf version : '0.3.0'

LeparaLaMapara avatar Feb 04 '21 11:02 LeparaLaMapara

What’s the input data? len=4 looks suspicious

aaronspring avatar Feb 04 '21 12:02 aaronspring

The data has the following dimensions: axis_nbounds: 2 nvertex: 4 time: 1980 x: 362 y: 332

LeparaLaMapara avatar Feb 08 '21 09:02 LeparaLaMapara

Try to get rid of axis bounds and nvertex and then regrid. Or transpose x and y to the front.

aaronspring avatar Feb 08 '21 12:02 aaronspring

Thanks it work!. But what is the axis bounds and nvertex? is it the different ensembles? Where can I get information about?

LeparaLaMapara avatar Feb 09 '21 06:02 LeparaLaMapara

thats some information about the grid description. how did you solve it? by transposing x and y first or dropping the other coords?

aaronspring avatar Feb 09 '21 09:02 aaronspring

By dropping the other coords, such that my data dimensions are as follows: time: 1980 x: 362 y: 332

LeparaLaMapara avatar Feb 09 '21 09:02 LeparaLaMapara