Fix for allowing a weight file to be written when it does not exist when using filename argument. #234
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This might address issues #153 and #202. I had been using xESMF version 0.3.0 and now improving code to use the latest 0.7.0. In version 0.3.0, with Regridding(reuse_weights=True and filename="...") and the filename does not exist, the weights file is created on the first pass and reused in subsequent uses. In version 0.7.0, we encounter this error when the weights file does not exist. We do not pre-generate a weights file,
This patch restores the previous behavior from 0.3.0.
The logic is just a little complex.
If reuse_weights is False, compute new weights each time unless the weights argument is specified.
The weights argument, if a filename, MUST exist.
If reuse_weights is True, use the weights argument if provided. Override weights argument, if filename is provided. If the weights argument is a filename, it MUST exist. If a filename argument is provided, override the weights argument. If the provided filename exists, use it for the weights otherwise compute new weights and trigger saving the weights to the filename in the first pass. Subsequent calls will utilize the new and existing filename.
Maybe add some wording to the function arguments to further clarify use.