Closed nishadhka closed 4 years ago
I'm not totally sure, but I have a recommendation.
First, I want to describe how I tested you example on on Google Colab without an issue.
Steps:
import xarray as xr
db=xr.open_dataset('cf_camx_test4.nc')
6. Download camx_test4.nc from your link.
7. Upload it to colab.
8. Run all cells except for the last one. Runs without an error.
9. Restart the "kernel."
10. Run the last cell.
I get no errors or warnings... Not sure why this would be the case.
# Recommendation
My guess is that somewhere a buffering is occurring that leaves the file in an odd state. The `save` method returns the netcdf4.Dataset that is "on disk" and still in an open state. Perhaps an explicit `close` would help to flush write.
< infile.save(outpath, verbose=0)
infile.save(outpath, verbose=0).close()
Since I cannot repeat the errors, I cannot be sure. Please let me know if that helps.
Thanks, the explicit close did the magic. Now the files gets open without any error after a Python session. The code is as follows
import PseudoNetCDF as pnc
inpath = 'camx_test4.nc'
outpath = 'cf_camx_test4.nc'
infile = pnc.pncopen(inpath, format='ioapi').copy()
pnc.conventions.ioapi.add_cf_from_ioapi(infile)
infile.save(outpath, verbose=0).close()
Closing the python session (ctrl+x) and running following comment raises, no error!
import xarray as xr
outpath = 'cf_camx_test4.nc'
db=xr.open_dataset(outpath)
There is a WRF output necdf file preprocesed to use with camx model, https://drive.google.com/file/d/1KmFxnKi0FT5h9NRsBJo3mQS61EOcRP9x/view?usp=sharing. When I want to convert that file into CF form. used following codes
However, after that python session closed (ctrl+x). Reopening of the
outpath
through following errorApart from the xarray open, this file is not being able to open in
cdo
as well,cdo
raises a similar error forInterestingly, after the system reboot. In case within a docker env, logging off/exit. The opening of the file in xarry or cdo, won't raise any error. Is it a memory leak