Closed JonathanGregory closed 8 months ago
Thanks, Jonathan. This issue (https://github.com/Unidata/netcdf4-python/issues/1020) suggests that it is due to the user setting of an "illegal" attribute. I can replicate your result when I access your durack_prime.nc
, but when I read the CDl directly it all works:
>>> import cf
>>> f = cf.read('durack_prime.cdl')[0] # cf-python reads CDL!
>>> cf.write(f, 'tmp.nc')
>>> g = cf.read('tmp.nc')[0]
>>> g.equals(f)
True
How did you make your netCDF file? cf-python is using ncgen -knc4 -o
, but I also tested with ncgen -o
, and that woked too ...
Thanks for testing it. I made durack_prime.cdl
on the RACC with ncgen -o
. I don't get the error if I make it on RACC with ncgen -knc4 -o
(file durack_prime.racc-knc4.nc
), nor if I make it on my desktop machine with ncgen -o
(file durack_prime.mreydhon5.nc
). Apparently the problem is coming from the default behaviour of /usr/bin/ncgen
on RACC. It's an old version of ncgen
(netcdf library version 4.3.3.1 of Dec 10 2015 16:44:18), whereas on my desktop machine I have a modern one (netcdf library version 4.8.1 of Jan 25 2023 06:27:17). durack_prime.nc
is a netCDF-3 file, I presume.
racc-login-0$ file durack_prime.nc
durack_prime.nc: NetCDF Data Format data
racc-login-0$ file durack_prime.racc-knc4.nc
durack_prime.racc-knc4.nc: Hierarchical Data Format (version 5) data
Is that a correct interpretation? If so, I suppose it means there is something which isn't being set correctly when a netCDF-3 file is read. In any case, I know how to work round it now, thanks.
Thanks, Jonathan.
Your interpretation makes sense to me. I'm guessing that the presence of the _NCProperties
global attribute is handled differently with netCDF-3 output. Nearly 10 years old - that impressive(ly bad).
I get an error from
cf.write
for a field I have got bycf.read
fromdurack_prime.nc
. This file can be found in/storage/basic/baobab/jonathan/general/FAFMIP
on the Reading system, or you can make it from durack_prime.cdl withncgen
. I'm aware that the field and coordinate data are all missing. In my program, I read in the field as a template, fill in the data, and write it out, but it fails in the same way, indicating the problem isn't the missing data. Here's the error. Is it my mistake? If not, is there a work-round or can it be fixed? Thanks.