Re: read TRMM version 7 Level 2 hdf file

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Sun Mar 30 2014 - 11:50:45 MDT

Hi Yen,
This actually seems quite strange because recent versions of NCL do *not* print the byte type using hexadecimal numbers.
I am not sure how you can have NCL 6.1.2 printing hexadecimal values for the byte type.

Also in version 6.0.0 the byte type was changed from unsigned (ranging from 0-255) to signed (ranging from -128 to +127).
The ubyte type was added as the unsigned type. In case you didn't realize it, the signed value -99 has the some underlying bit pattern as the
unsigned value 157. You can use the functions 'tounsigned' and 'tosigned' convert back and forth between any unsigned integer type and its
signed version.

So:
ncl 8> print(tosigned(157B)) ; B is the suffix for unsigned byte (ubyte)
(0) -99
ncl 9> print(tounsigned(-99b)) ; b is the suffix for byte
(0) 157

On Mar 29, 2014, at 8:38 PM, yinjinfang88 <yinjinfang88@163.com> wrote:

>
> Dear all£¬
> Thank you very much for your reply. I still get a wrong result following your method. There are as follows:
> $ ncl
> Copyright (C) 1995-2013 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.1.2
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> ncl 0> f = addfile("2A12.20100101.69095.7.HDF","r") ; Add file
> ncl 1> fzHIndex = f->freezingHeightIndex ; read freezingHeightIndex
> ncl 2> printVarSummary(fzHIndex)
>
> Variable: fzHIndex
> Type: byte
> Total Size: 607568 bytes
> 607568 values
> Number of Dimensions: 2
> Dimensions and sizes: [nscan | 2921] x [npixel | 208]
> Coordinates:
> Number Of Attributes: 1
> hdf_name : freezingHeightIndex
>
> ncl 3> print("fzHIndex: min="+min(fzHIndex)+" max="+max(fzHIndex))
> (0) fzHIndex: min=0x01 max=0x9d
>
> ncl 4> print("fzHIndex: min="+min(toshort(fzHIndex))+" max="+max(toshort(fzHIndex)))
> (0) fzHIndex: min=1 max=157
>
> ncl 5> print("fzHIndex: min="+min(toshort(fzHIndex))+" max="+max(toshort(fzHIndex)))
> (0) fzHIndex: min=1 max=157
>
> ncl 6> print("fzHIndex: min="+toshort(min(fzHIndex))+" max="+toshort(max(zHIndex)))
> (0) fzHIndex: min=1 max=157
>
> ncl 8> print("fzHIndex: min="+min(toint(fzHIndex))+" max="+max(toint(fzHIndex)))
> (0) fzHIndex: min=1 max=157
>
> ncl 9> print("fzHIndex: min="+toint(min(fzHIndex))+" max="+toint(max(fzHIndex)))
> (0) fzHIndex: min=1 max=157
>
> ==============================
> The results should be "(0) fzHIndex: min=-99 max=13".
> However, NCL got strange results. I am confused whether it is related to the computer hardware. I run NCL in unix of AIX.
>
> The returns of uname and gcc commands are shown
>
> $uname -a
> AIX cma18n01 1 7 0007471BD400
>
> $gcc --version
> gcc (GCC) 4.8.1
> Copyright (C) 2013 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
>
>
> Thanks.
>
> Yin
>
> Yin Jin-Fang
> State Key Laboratory of Severe Weather, Chinese Academy of Meteorological Sciences, Beijing 100081, China
> _______________________________________________
> 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 Sun Mar 30 11:50:56 2014

This archive was generated by hypermail 2.1.8 : Mon Mar 31 2014 - 11:47:09 MDT