[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20050513: netCDF Perl Interface - storing BYTE data in NetCDF using Perl interface



Janine,

> To: address@hidden
> From: "Janine Goldstein" <address@hidden>
> Subject: netCDF Perl Interface - storing BYTE data in NetCDF using Perl 
> interface
> Organization: UCAR/Unidata
> Keywords: 200505121957.j4CJvbxJ003611

The above message contained the following:

> Institution: UCAR/JOSS
> Package Version: not sure - would need to ask sys admin
> Operating System: solaris
> Hardware Information: sun of some type, I think (I know, I\'m clueless)
> Inquiry: I would like to store numeric data in NetCDF as type BYTE,
> but there seem to be packing issues that I don\'t quite understand and I
> can\'t find any good documentation.
>
> In order to use the data I read with a varget, I need to unpack it to
> a char to get the number from the decimal equivalent,

I'm afraid I don't understand the above.

> but when I use
> varput to write the data in the first place, what do I do?
>
> ...
> @value = (0) x 20;
> NetCDF::varput($ncid, $varid, 0, 1, \\@value);

The above lines should, instead, be something like

    @coords = (0);
    @counts = (20);
    @value = (0) x 20;
    NetCDF::varput($ncid, $varid, \@coords, \@counts, \@value);

> ...
> 
> ncdump gives:
> byte station_occurrence(...
> station_occurrence = 32, _, 32, _, 32, _, ...
> 
> I managed to get the fill value to be 48b just by setting $fillValue = 0 and 
> calling
> NetCDF::attput($ncid, $varid, \"_FillValue\", NetCDF::BYTE, \\$fillValue);
> 
> So why doesn\'t ncdump give
> station_occurrence = _, _, _, _, _, _, ...  ??
> 
> Janine

Regards,
Steve Emmerson

> NOTE: All email exchanges with Unidata User Support are recorded in the
> Unidata inquiry tracking system and then made publicly available
> through the web.  If you do not want to have your interactions made
> available in this way, you must let us know in each email you send to us.