JiaweiZhuang / xESMF

Universal Regridder for Geospatial Data
http://xesmf.readthedocs.io/
MIT License
269 stars 49 forks source link

Making silent the reuse of weights message... #34

Closed itarec1988 closed 6 years ago

itarec1988 commented 6 years ago

Hey @JiaweiZhuang

I am using xESMF since some weeks ago and I am very happy with it. Its very fast compared to my former regridding tool ESMPy.. Well done.

I was just wondering if there is a way of avoiding the messages when the weights are reused? I tried with ; at the end of the code snipet but still the message is printed out. I am looping over several layer and I really want to avoid printing. This is an excerpt of the loop I have:

for time in range(co.shape[0]):
    for lev in range(co.shape[1]):
        co_xr                  = xr.Dataset(data_vars={'co': (('lat','lon'),co[time,lev]),
                                                        'pres':(('lat','lon'),pi_ecmwf[time,lev])},
                                             coords={'lat':co_lat,'lon':co_lon })
        regridder              = xe.Regridder(co_xr,ds_out,'bilinear',reuse_weights=True)
        co_re                  = regridder(co_xr['co'])
        pi_re                  = regridder(co_xr['pres'])
        co_fields_re[time,lev] = co_re.data
        pi_fields_re[time,lev] = pi_re.data

This is printed after each loop... Reuse existing file: bilinear_451x900_184x309.nc

Thanks in advance..

JiaweiZhuang commented 6 years ago

Glad that you find xESMF helpful!

You don't have to loop over layers. xESMF will do the broadcasting for you, i.e. regridder(co) should just work.

The next version will let users explicitly load existing weights instead of doing so implicitly (#11), so that message won't exist anymore.

itarec1988 commented 6 years ago

You are right.. it works. Thanks again.

lizziel commented 4 years ago

What is the status of this? I am using xesmf 0.2.0 with esmf/esmpy 7.1.0 and would really like to turn off the reuse existing weights prints.

lizziel commented 4 years ago

This https://github.com/JiaweiZhuang/xESMF/issues/86 PR exists but has not been submitted yet. @JiaweiZhuang , could the next version have the reuse weights message commented out, or do you see a real need to have it? When we create GEOS-Chem benchmark plots we literally gets hundreds of lines of this message, drowning out the important messages.

JiaweiZhuang commented 4 years ago

This #86 PR exists but has not been submitted yet. @JiaweiZhuang

That one is an issue not an PR. A quick PR to switch it to logging/warning is welcome!

lizziel commented 4 years ago

I propose removal in the next version with an open call for submission of a PR to implement as logging/warning.