Re: reading netcdf-4 ubyte datatype [message #74678] |
Fri, 28 January 2011 11:22  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Alison writes:
> This is not the desired result, as the 255 has become -1. It seems
> that IDL just doesn't support unsigned bytes in netcdf. Can you
> verify this? or am I missing something here?
Despite outward appearances, I'm not the authority on
what IDL supports. :-)
Have you contacted the folks at ITTVIS? I would
assume (hope, really!) this is a question they
could answer quite easily.
But, I would say, you certainly appear to be correct.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: reading netcdf-4 ubyte datatype [message #74679 is a reply to message #74678] |
Fri, 28 January 2011 11:08   |
alison
Messages: 7 Registered: October 2004
|
Junior Member |
|
|
David,
I don't see a way off-hand to attach a file to this post, so here is
the content of a "test_read.cdl" file which can be used to create a
netcdf4 file with "ncgen -k 3 test_read.cdl".
netcdf test_read {
variables:
ubyte myvar;
data:
myvar = 255;
}
This creates a little netcdf4 file containing a single variable of
type ubyte (unsigned byte) whose value is 255. Trying to read this
file in IDL I get this:
IDL> ncid = ncdf_open('test_read.nc')
% Loaded DLM: NCDF.
IDL> varid = ncdf_varid(ncid,'myvar')
IDL> ncdf_varget, ncid, varid, x
% NCDF_VARGET: File format error. Varid 0 has a unknown type
% Execution halted at: $MAIN$
IDL>
Conversely, if I try to create a netcdf4 file from within IDL and
store an unsigned byte into it, there is not a "ubyte" option
available to the ncdf_vardef command, and if I use the "byte" option,
like this:
x = 255b
ncid = ncdf_create('test_write.nc',/netcdf4_format,/clobber)
varid = ncdf_vardef(ncid,'myvar',/byte)
ncdf_varput, ncid, varid, x
Then, "ncdump test_write.nc" shows that the resulting netcdf4 file
contains this:
netcdf test_write {
variables:
byte myvar ;
data:
myvar = -1 ;
}
This is not the desired result, as the 255 has become -1. It seems
that IDL just doesn't support unsigned bytes in netcdf. Can you
verify this? or am I missing something here?
Alison
On Jan 28, 10:44 am, David Fanning <n...@dfanning.com> wrote:
> Alison writes:
>> I am using IDL 8.0 for Linux. I also notice that if I write an IDL
>> "byte" variable (which is unsigned) to a netcdf file, it is written as
>> a netcdf "byte" type (signed), when it should be "ubyte" (unsigned).
>> There doesn't appear to be any way to control the datatype which IDL
>> is automatically choosing when reading/writing from netcdf file. Is
>> there a way to represent my 8-bit unsigned data so that it is handled
>> properly in both IDL and netcdf-4?
>
> Do you have an example of such a file we can test with?
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
Re: reading netcdf-4 ubyte datatype [message #74683 is a reply to message #74682] |
Fri, 28 January 2011 09:35   |
alison
Messages: 7 Registered: October 2004
|
Junior Member |
|
|
Hi,
I am using IDL 8.0 for Linux. I also notice that if I write an IDL
"byte" variable (which is unsigned) to a netcdf file, it is written as
a netcdf "byte" type (signed), when it should be "ubyte" (unsigned).
There doesn't appear to be any way to control the datatype which IDL
is automatically choosing when reading/writing from netcdf file. Is
there a way to represent my 8-bit unsigned data so that it is handled
properly in both IDL and netcdf-4?
Thanks,
Alison
On Jan 28, 4:39 am, Fabzou <fabien.mauss...@tu-berlin.de> wrote:
> Hi,
>
> Which version of IDL are you using?
>
> IDL 7.1 does not support netCDF 4 files unless you use a patch for new
> data formats (I think it is included in IDL 7.1.1 but I am not sure)
>
> Fabz
>
> On 01/28/2011 02:33 AM, alison wrote:
>
>> Hi,
>> I'm having trouble reading a netcdf-4 file with "ubyte" type data in
>> it. I believe that "ubyte" is a valid netcdf-4 datatype (unsigned
>> byte) and should just correspond to IDL "byte" type, but ncdf_varget
>> tells me that datatype is "unknown'. I get this error msg:
>
>> % NCDF_VARGET: File format error. Varid 5 has a unknown type
>
>> I don't think it is a file format problem, as I can read this file
>> just fine with Fortran, and it also passes the CF conventions checker
>> cleanly. Does anyone know how to read the "ubyte" datatype from a
>> netcdf-4 file using IDL?
>> Thanks,
>> Alison Walker
>
>
|
|
|
|
Re: reading netcdf-4 ubyte datatype [message #74815 is a reply to message #74678] |
Thu, 03 February 2011 13:27  |
alison
Messages: 7 Registered: October 2004
|
Junior Member |
|
|
On Jan 28, 12:22 pm, David Fanning <n...@dfanning.com> wrote:
> Alison writes:
>> This is not the desired result, as the 255 has become -1. It seems
>> that IDL just doesn't support unsigned bytes in netcdf. Can you
>> verify this? or am I missing something here?
>
> Despite outward appearances, I'm not the authority on
> what IDL supports. :-)
>
> Have you contacted the folks at ITTVIS? I would
> assume (hope, really!) this is a question they
> could answer quite easily.
>
> But, I would say, you certainly appear to be correct.
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Update: I reported this issue to ittvis tech support. Josh confirmed
it is a bug and will file a bug report.
Alison
|
|
|