Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nc4 classic file can't be edited #144

Closed
doutriaux1 opened this issue Jun 21, 2017 · 1 comment
Closed

nc4 classic file can't be edited #144

doutriaux1 opened this issue Jun 21, 2017 · 1 comment
Assignees

Comments

@doutriaux1
Copy link
Contributor

@doutriaux1 doutriaux1 commented Jun 21, 2017

import cdms2
import cdat_info
import os

fnm = "sst_ice_DECK_1x1_c20170602.nc"
fnm = os.path.join(cdat_info.get_sampledata_path(),"clt.nc")
f=cdms2.open(fnm)
s=f("clt")
print "original shape",s.shape
f.close()
cdms2.setNetcdfDeflateFlag(0)
cdms2.setNetcdfDeflateLevelFlag(0)
cdms2.setNetcdfShuffleFlag(0)
cdms2.setNetcdf4Flag(1)
cdms2.setNetcdfClassicFlag(1)
f=cdms2.open("nc4.nc","w")
f.write(s)
f.close()

f=cdms2.open("nc4.nc","r+")
print "nc4 shape",f["clt"].shape
t=f["time"]
t[:]=t[:]*100.
f.close()

hangs for a while and dies.

A subsequemnt ncdump shows that it seems as if it is trying to extend the time dimension rather than altering the time dimensions

doutriaux1@crunchy:[Phillip]:[14460]> python edit.py
Traceback (most recent call last):
  File "edit.py", line 21, in <module>
    t[:]=t[:]*100.
  File "/export/doutriaux1/miniconda2/envs/2.10-nox/lib/python2.7/site-packages/cdms2/axis.py", line 2200, in __setslice__
    return self._obj_.setslice(*(low, high, numpy.ma.filled(value)))
ValueError: shapes are not aligned
doutriaux1@crunchy:[Phillip]:[14460]> ncdump -h nc4.nc 
netcdf nc4 {
dimensions:
	time = UNLIMITED ; // (2147483647 currently)
	latitude = 46 ;
	bound = 2 ;
	longitude = 72 ;
variables:
	double time(time) ;
		time:units = "months since 1979-1-1 0" ;
		time:calendar = "gregorian" ;
		time:axis = "T" ;
		time:realtopology = "linear" ;
	float latitude(latitude) ;
		latitude:bounds = "bounds_latitude" ;
		latitude:units = "degrees_north" ;
		latitude:long_name = "Latitude" ;
		latitude:axis = "Y" ;
		latitude:realtopology = "linear" ;
	double bounds_latitude(latitude, bound) ;
	float longitude(longitude) ;
		longitude:bounds = "bounds_longitude" ;
		longitude:modulo = 360. ;
		longitude:realtopology = "circular" ;
		longitude:long_name = "Longitude" ;
		longitude:units = "degrees_east" ;
		longitude:topology = "circular" ;
		longitude:axis = "X" ;
	double bounds_longitude(longitude, bound) ;
	float clt(time, latitude, longitude) ;
		clt:_FillValue = 1.e+20f ;
		clt:missing_value = 1.e+20f ;
		clt:time_statistic = "average" ;
		clt:comments = "YONU_AMIP1" ;
		clt:long_name = "Total cloudiness" ;
		clt:grid_name = "YONU4X5" ;
		clt:units = "%" ;
		clt:grid_type = "gaussian" ;

// global attributes:
		:Conventions = "CF-1.0" ;
}
@cameronsmith1
Copy link

@cameronsmith1 cameronsmith1 commented Jun 22, 2017

Thanks for working on this! BTW, when I encountered the problem, I would only get the message 'killed'. Also, the netcdf file I was using didn't seem to be altered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants