Re: error on reading binary data

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Fri Jan 25 2013 - 14:02:42 MST

This is just the difference between unsigned and signed data. Instead of reading the data as type "byte", use "ubyte".
Or you can use the function "tounsigned" on the 'bdata' variable.
  -dave

On Jan 25, 2013, at 1:56 PM, tingting@ucar.edu wrote:

> Hi all,
> I have one question on reading a binary data, the format of binary data:
> One-byte (scaled, unsigned integer) flat binary arrays preceded by a
> 300-byte header, no byte order/endianness.
> Part of my script:
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> fin = "./conc/nt_200801_f17_v01_n.bin"
> ;--read header--;
> head = fbindirread(fin, 0, 300, "character")
> ;print(head)
> ;exit
> ;---read data--;
> bdata = fbindirread(fin,0,(/ NY,MX /),"byte")
> data = byte2flt(bdata)
> printMinMax(data, True)
> ...
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Then, the output shows the range: -127~128. While, in data document, the
> range is 0~255. Will be something wrong in my script?
> Thanks a lot in advance!
> Tingting
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jan 25 14:02:56 2013

This archive was generated by hypermail 2.1.8 : Tue Jan 29 2013 - 22:44:26 MST