-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposed new regridder save-load API in 0.3.0 (not backward compatible) #75
Comments
Major question: I think it should be kept. |
Good point... I haven't thought of a case. One concern is that
I am thinking about catching the |
This new API seems like a nice step forward, and the package is young enough that you shouldn't worry too much about backwards compatibility IMO. It's still 0.X after all 😄 Thanks for xESMF! It's an excellent tool. |
Would it be helpful to document whether the longitudes range from -180:180 vs 0:360 in the filename like: Also, I think it'd be nice to have an What about I prefer having a default filename since naming is hard. |
Maybe a simpler option would be to have a
An alternative to |
I encountered the same MemoryError when doing loops. I have updated xESMF to 0.3.0 but have not found these methods. Does this mean the backward-compatibility has been kept? With the latest version and the same calling, I still see the memory cannot be released timely, see my following screenshot. Did I miss something? |
The API changes proposed above have not been released, nor merged into master. If you want to take a look at the branch #91 and provide feedback, that would be useful. |
Add how-to instructions on how to cut a new release
I'd like to implement a new regridder save-load API to resolve #11. ESMPy 8.0.0 is the prerequisite for this, and is now available on Conda conda-forge/esmpy-feedstock#26
Before implementing this, I'd like users of xESMF to review and comment on the new API, because there will be backward-incompatible changes.
Description of the changes
The current & old API (until 0.2.x) is:
The first call writes out a NetCDF file containing regridding weights, and reads the file back to memory to construct a SciPy sparse matrix (representing the regridding operation). Such extra I/O exists because ESMPy < 8.0.0 can only dump weights to disk. ESMPy 8.0.0 allows in-memory retrival of weights as numpy arrays, so such disk I/O is no longer needed.
The second call, with
reuse_weights=True
, detects that the weight file exists and simply reads it back without re-computation.filename
is an optional kwarg. If not specified, the regridder file will be given a default name likebilinear_25x53_59x87.nc
, indicating(regrid method, input grid shape, output grid shape)
.The new API (starting 0.3.0) will be:
The first call only constructs the regridder in-memory, and will not write any files to disk.
Instead of implicitly handing the save/load as part of
xesmf.Regridder()
call, the newsave()
andload_regridder()
do so explicitly. They are similar tosave()
/load_model()
in Keras orsave
/load()
in PyTorch.The original
reuse_weights
andfilename
kwargs will be removed inxesmf.Regridder()
.Major question on backward-compatibility
Should the
reuse_weights=True
kwarg be kept for backward-compatibility? My inclination is no, as there should only be one unambiguous way to load the regridder.However, one convenient thing about the old
xesmf.Regridder(..., reuse_weights=True)
API is that this single line of code works in any cases. If the weight file doesn't exist on disk, xesmf builds it and writes to disk; if exists, xesmf reads it back without re-computation.The same logic with the new API would be:
This is more verbose, but also more explicit, and explicit is better than implicit
Minor questions
xesmf.load_regridder()
or justxesmf.load()
? I prefer the former as it's more explicit.regridder.save()
has a default filename? I slightly prefer no, but some people might have a hard time choosing a name :) Can still use the current default naming scheme likebilinear_25x53_59x87.nc
. Welcome other suggestions.The text was updated successfully, but these errors were encountered: