[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #QCI-275305]: reading netcdf data of type BYTE
- Subject: [netCDF #QCI-275305]: reading netcdf data of type BYTE
- Date: Wed, 16 Oct 2013 15:55:12 -0600
Hi Rachel,
> I am having a lot of trouble reading netcdf variables with the data type
> BYTE. For example, I am trying to read flag values where each byte is
> given a specific reason for being flagged. I understand that variable data
> should be an 8 bit number of zeros and ones, but the Fortran 90 compiler
> and system I use apparently only reads in signed integers from -128 to 127.
>
> Are there some netcdf commands I could use to convert this to something I
> can understand?
Try transforming the values with something like
if(ival < 0) ival = ival + 256
That transforms the range of signed integers between -128 to 127 into the
unsigned integers 0 to 255 in a way that preserves the bits for bit flags.
NetCDF-4 explicitly supports unsigned bytes with the type nf90_ubyte, but
the above trick may let you deal with signed bytes as if they were unsigned.
--Russ
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
Ticket Details
===================
Ticket ID: QCI-275305
Department: Support netCDF
Priority: Normal
Status: Closed