comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Do netCDF Files Have a DataType of INT?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Do netCDF Files Have a DataType of INT? [message #84414] Mon, 03 June 2013 07:23
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
From the netCDF docs:

<quote>
A variable external data type is one of a small set of netCDF types. In
classic and 64-bit offset files, only the original six types are
available (byte, character, short, int, float, and double).
</quote>

That indicates to me that the netCDF "int" is equivalent to the IDL
"long", i.e. a 4-byte integer.

Similarly, the netCDF "short" is equivalent to the IDL "int"

From netcdf.h:
/*
* The netcdf external data types
*/
#define NC_NAT 0
#define NC_BYTE 1
#define NC_CHAR 2
#define NC_SHORT 3
#define NC_INT 4
#define NC_LONG NC_INT
#define NC_FLOAT 5
#define NC_DOUBLE 6
#define NC_UBYTE 7
#define NC_USHORT 8
#define NC_UINT 9
#define NC_INT64 10
#define NC_UINT64 11
#define NC_STRING 12
#define NC_MAX_ATOMIC_TYPE NC_STRING

cheers,

paulv

On 06/02/13 22:36, David Fanning wrote:
> Folks,
>
> I've run into a problem with a netCDF file and I need a sanity check.
>
> I define a variable attribute "colortable" with an integer value, say
> 33. As far as I know netCDF files don't have a datatype named "INT", so
> I use the datatype "SHORT" when I create the attribute:
>
> NCDF_ATTPUT, fileID, self.ID, 'colortable', 33, /SHORT
>
> Now, I want to read this attribute out of the file and copy it to
> another file. To learn something about this attribute I use the IDL
> routine NCDF_ATTINQ:
>
> attrInfo = NCDF_AttInq(fileID, GLOBAL=1, 'colortable')
>
> But, the datatype field of this attribute structure is inexplicably set
> to INT:
>
> IDL> Print, attrInfo.datatype
> INT
>
> Does that make *any* sense to anyone?
>
> Cheers,
>
> David
>
>
Re: Do netCDF Files Have a DataType of INT? [message #84419 is a reply to message #84414] Mon, 03 June 2013 05:03 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> I've run into a problem with a netCDF file and I need a sanity check.
>
> I define a variable attribute "colortable" with an integer value, say
> 33. As far as I know netCDF files don't have a datatype named "INT", so
> I use the datatype "SHORT" when I create the attribute:
>
> NCDF_ATTPUT, fileID, self.ID, 'colortable', 33, /SHORT
>
> Now, I want to read this attribute out of the file and copy it to
> another file. To learn something about this attribute I use the IDL
> routine NCDF_ATTINQ:
>
> attrInfo = NCDF_AttInq(fileID, GLOBAL=1, 'colortable')
>
> But, the datatype field of this attribute structure is inexplicably set
> to INT:
>
> IDL> Print, attrInfo.datatype
> INT
>
> Does that make *any* sense to anyone?

Oh, never mind. After sleeping on this, I think this is a user error on
my part. :-(

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Do netCDF Files Have a DataType of INT? [message #84420 is a reply to message #84419] Sun, 02 June 2013 22:11 Go to previous message
SonicKenking is currently offline  SonicKenking
Messages: 51
Registered: October 2010
Member
On Monday, June 3, 2013 12:36:19 PM UTC+10, David Fanning wrote:
> Folks,
>
>
>
> I've run into a problem with a netCDF file and I need a sanity check.
>
>
>
> I define a variable attribute "colortable" with an integer value, say
>
> 33. As far as I know netCDF files don't have a datatype named "INT", so
>
> I use the datatype "SHORT" when I create the attribute:
>
>
>
> NCDF_ATTPUT, fileID, self.ID, 'colortable', 33, /SHORT
>
>
>
> Now, I want to read this attribute out of the file and copy it to
>
> another file. To learn something about this attribute I use the IDL
>
> routine NCDF_ATTINQ:
>
>
>
> attrInfo = NCDF_AttInq(fileID, GLOBAL=1, 'colortable')
>
>
>
> But, the datatype field of this attribute structure is inexplicably set
>
> to INT:
>
>
>
> IDL> Print, attrInfo.datatype
>
> INT
>
>
>
> Does that make *any* sense to anyone?
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

My understanding is that NCDF Short is equivalant to IDL Int. They are both 2 byte integers.
But since IDL does not have a Short type, the data type is reported by NCDF_AttInq (an IDL routine) as INT, which is the result of an implicit type conversion.
They are basically the same thing. But I do think the fact that you get INT from AttInq but have to use SHORT in VarDef is rather confusing.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Use IDLanROI or not
Next Topic: Re: Use IDLanROI or not

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:41:49 PDT 2025

Total time taken to generate the page: 0.00632 seconds