NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: [netcdf-java] supporting unsigned byte data

Tom Whittaker wrote:
I found there has been some discussion about having a variable
attribute "_Unsigned" that would allow for unsigned byte data to be
supported.  Well, one of our people created a netCDF file with bytes
which he treated as "unsigned"....but when he read the file and
specified a (float) scale and offset, he got the "wrong"
answers...until he started treating the byte values as signed -- his
unhappiness is that IDL apparently treats bytes as unsigned, so he
cannot easily use his file in both (IDV is the other one) places.  I
tried a few combinations in the toosUI, using NCML, but could not get
anything to work...

Is this supported?  If so, is there some magic?  (I'm running netCDF-java 4.1).

Thanks...

tom

Hi Tom:

Classic netcdf has only signed bytes. netcdf-java introduced the concept of unsigned bytes by adding an attribute

 varname:_Unsigned = "true";

This only matters to the library when you are doing scale/offset. of course, the application also wants to deal with it when using it in calculations, see:

http://www.unidata.ucar.edu/software/netcdf-java/reference/DataType.html

for more info.

If IDL insists on treating bytes as unsigned, then storing as unsigned with attribute as above should work in both places. If you have a file where this isnt working in IDV, send it to me and ill check it out.



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: