The problem is that this tempfile at this point, when exiting the function appears to the system not to be needed anymore, so that it will be erased at the first best occasion (at best at the next garbage collection). If we open it with xarray using open_dataset though, this is a lazy opening and relies on the file still existing.
The solution would be to open the xarray with xarray.load_dataset but this will load everything in memory. Might this be an issue for very large weight files?
the function
cdo_generate_weights
uses thetempfile
to generate a tempfileweight_file
for the weights, which is then read to an xarray withThe problem is that this tempfile at this point, when exiting the function appears to the system not to be needed anymore, so that it will be erased at the first best occasion (at best at the next garbage collection). If we open it with xarray using
open_dataset
though, this is a lazy opening and relies on the file still existing.The solution would be to open the xarray with
xarray.load_dataset
but this will load everything in memory. Might this be an issue for very large weight files?