[SciPy-User] help! strange netCDF output

Neil Berg nberg at atmos.ucla.edu
Fri Nov 12 14:06:21 EST 2010


> 
> Check that the arrays you're writing out have the same size *data
> type* as the ones you're creating.  It looks like an int64 vs. int32
> issue
> 
> Ryan

You are right.  I changed the data type to "double", which gave me the correct output.  I am still confused on how this solved the problem tho.  Here is what the read-in time_y variable looks like:

time_y: # dim. = 1, NC_INT, # att. = 3, ID = 0
time_y dimension 0: time, size = 744, dim. ID = 4(REC)
time_y RAM size is 744*nco_typ_lng(NC_INT) = 744*4 = 2976 bytes
time_y attribute 0: units, size = 4 NC_CHAR, value = year
time_y attribute 1: type, size = 4 NC_CHAR, value = axis
time_y attribute 2: long_name, size = 9 NC_CHAR, value = Time_year

time[0] time_y[0]=1959 year
time[1] time_y[1]=1959 year

I believe the data type is a long integer, right?  So, I changed the output data type to "dtype('l')" and the back-and-forth to zero output still occurred.  The bad output summary looks like:

time_y: type NC_INT, 1 dimension, 3 attributes, chunked? no, compressed? no, packed? no, ID = 1
time_y RAM size is 744*sizeof(NC_INT) = 744*4 = 2976 bytes
time_y dimension 0: time, size = 744, dim. ID = 0
time_y attribute 0: units, size = 4 NC_CHAR, value = year
time_y attribute 1: long_name, size = 9 NC_CHAR, value = Time_year
time_y attribute 2: type, size = 4 NC_CHAR, value = axis

time[0] time_y[0]=0 year
time[1] time_y[1]=1959 year

But, when I change to dtype('d'), all is good:

time_y: type NC_DOUBLE, 1 dimension, 3 attributes, chunked? no, compressed? no, packed? no, ID = 1
time_y RAM size is 744*sizeof(NC_DOUBLE) = 744*8 = 5952 bytes
time_y dimension 0: time, size = 744, dim. ID = 0
time_y attribute 0: units, size = 4 NC_CHAR, value = year
time_y attribute 1: long_name, size = 9 NC_CHAR, value = Time_year
time_y attribute 2: type, size = 4 NC_CHAR, value = axis

time[0] time_y[0]=1959 year
time[1] time_y[1]=1959 year

Thank you for solving the problem, and if you could explain to me more on how this problem was solved I would greatly appreciate it!  

Neil





More information about the SciPy-User mailing list