Open dvalters opened 6 years ago
@blazk I've discovered this does not happen if you do the following steps:
I think this is something to do with the way the netcdf library writes Variable data only when you close the dataset handle(?). i.e. dset.close()
So it is buffering the changes somehow and only writes them when unmounting (possibly? - I'm not 100% sure)
Finally, you should explicitly close any netCDF datasets into which data has been written by calling NF90_CLOSE before program termination. Otherwise, modifications to the dataset may be lost.
I've been looking if there are options to disable this somehow.
There is dataset.sync()
but it does not seem to have the expected effect...
http://unidata.github.io/netcdf4-python/#netCDF4.Dataset.sync
https://www.unidata.ucar.edu/software/netcdf/netcdf-4/newdocs/netcdf-c/nc_005fsync.html
@dvalters the problem is caused by caching of the variable data representation, basically the data representation is generated only first time when the VardataAsFlatTextFiles() is called; all subsequent calls return cached representation. Quick fix is to disable caching: comment out @memoize decorator from VardataAsFlatTextFiles() definition.
Also i'm not sure the current implementation of writing to a variable is correct; it seems to be a bit more complex task than I thought. I'm currently experimenting with the code, will propose some changes later today
Supercedes #37
Consider implementation of
truncate()
Can 'write' edits to variable's DATA_REPR, but the change is not retained when the file is reopened.