sodri126 / netcdf4-python

Automatically exported from code.google.com/p/netcdf4-python
Other
0 stars 0 forks source link

cannot create variables with type uint #134

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

$ python
>>> from netCDF4 import Dataset as ncdf4
>>> ncfile = ncdf4('/tmp/uinttest.nc', mode='w', format='NETCDF3_CLASSIC')
>>> ncfile.createDimension('time', 2)
>>> newvar = ncfile.createVariable('uint_var', 'u1', dimensions=('time',))

What is the expected output? What do you see instead?

This should create a variable of type uint8, instead I get the following error:
>>> newvar = ncfile.createVariable('uint_var', 'u1', dimensions=('time',))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "netCDF4.pyx", line 1665, in netCDF4.Dataset.createVariable (netCDF4.c:18279)
  File "netCDF4.pyx", line 2192, in netCDF4.Variable.__init__ (netCDF4.c:23672)
RuntimeError: NetCDF: Not a valid data type or _FillValue type mismatch

Variable creation works fine with any other type except for any uint type that 
I tried (u1,u2,u4,u8). I have also tried setting the fill_value keyword 
explicitly (fill_value=False; fill_value=255) - without any luck.

What version of the product are you using? On what operating system?
netcdf 4.1.1
netcdf4-python 1.0
Linux 3.2.0-0.bpo.2-amd64 #1 SMP Fri Jun 29 20:42:29 UTC 2012 x86_64 GNU/Linux

Please provide any additional information below.

I have verified this behaviour on two different machines (both x64) with 
different kernels - but same versions of netcdf and netcdf4-python.

Original issue reported on code.google.com by mde.p...@gmail.com on 27 Aug 2012 at 2:11

GoogleCodeExporter commented 9 years ago
Ok, I think I can just answer that myself now: NetCDF3 has no UINT type. This 
was only introduced in the NetCDF4 format.
So I'm making this bug report a suggestion: How about trying to catch this 
inappropriate use of data types in NetCDF3 format? This might lead to less 
frustration on the user's side when accidentally trying something like this... 
;)

Original comment by mde.p...@gmail.com on 27 Aug 2012 at 2:17

GoogleCodeExporter commented 9 years ago
You did get an error message that said "not a valid data type".  

Original comment by whitaker.jeffrey@gmail.com on 27 Aug 2012 at 2:50

GoogleCodeExporter commented 9 years ago
True, but the _FillValue thing distracted me from that. So I always suspected 
that the problem was with the _FillValue and not the actual variable type. 

Original comment by mde.p...@gmail.com on 27 Aug 2012 at 3:01

GoogleCodeExporter commented 9 years ago

Original comment by whitaker.jeffrey@gmail.com on 26 Feb 2014 at 2:04