Re: A question about processing HDF-eos when using ncl-6.2.0

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 29 2014 - 10:35:01 MDT

Cheung,

There is a function short2flt_hdf
http://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt_hdf.shtml

Which is probably you want to use.

Also, there is a compatibility issue between 6.1.0 and 6.2.0 for HDF-EOS2,
as 6.1.0 could not read the meta data, but 6.2.0 can read the metadata.

If you the data well, you can just use the (scale-)factor and offset directly
to convert the data from short to float.

Wei

On Apr 29, 2014, at 8:03 AM, Cheung <zuibeidemei@126.com> wrote:

> Hi wei, thanks for the help.
>
> I don’t understand why same code yields different results for var_f (in my case)
>
> under ncl-6.1.0 and 6.2.0?
>
> As commented in the code, using 6.1.0, the var_f prints my desired one, which is -99,
>
> but in 6.2.0, var_f will print -9900.
>
>
>
>
>
>
> 原始邮件
> 发件人: Wei Huang<huangwei@ucar.edu>
> 收件人: Cheung<zuibeidemei@126.com>
> 抄送: NCL<ncl-talk@ucar.edu>
> 发送时间: 2014年4月29日(周二) 21:41
> 主题: Re: [ncl-talk] A question about processing HDF-eos when using ncl-6.2.0
>
> Cheung,
>
> Your code:
>
> filein = "2009200040119_17152_CS_2B-TAU_GRANULE_P_R04_E02.hdf"
> eos_file = addfile(filein+".he2","r")
>
> ;read using eos file
> var = eos_file->layer_optical_depth_2B_TAU
> var_f = short2flt(eos_file->layer_optical_depth_2B_TAU)/100
>
> which var read for the he2 directly, and NCL show it as short:
>
> Variable: var (subsection)
> Type: short
> Total Size: 8 bytes
> 4 values
> Number of Dimensions: 1
> Dimensions and sizes: [nray_2B_TAU | 4]
> Coordinates:
> Number Of Attributes: 9
> factor : 100
> offset : 0
> long_name : Layer cloud optical depth
> units : -
> valid_range : ( 0, 5000 )
> missing : -9900
> missop : ==
> _FillValue : 0
> hdfeos_name : layer_optical_depth
> (0) -9900
> (1) -9900
> (2) -9900
> (3) -9900
>
>
> When you use short2flt, NCL has the (scale-)factor multiplied to the var, and then return as float.
> see the print:
>
> Variable: var_f (subsection)
> Type: float
> Total Size: 16 bytes
> 4 values
> Number of Dimensions: 1
> Dimensions and sizes: [4]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : 0
> (0) -9900
> (1) -9900
> (2) -9900
> (3) -9900
>
>
> In most the case, when the data is short, and has factor and offset,
> you can get the original value as:
>
> new_var = ori_var * tofloat(factor) + tofloat(offset)
>
> That is what short2flt does.
> See document for short2flt at:
> http://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml
>
> In your case, you may want to do:
>
> new_var = ori_var / tofloat(factor)
>
> You do not need the offset, as it is zero for your case.
>
> Hope this help:
>
> Wei
>
>
> On Apr 28, 2014, at 9:37 PM, Cheung <zuibeidemei@126.com> wrote:
>
>> Hi Wei:
>>
>> Thanks for your response.
>>
>> I put an example online https://github.com/slashgithub/test_2btau,
>>
>> which contains data and test script, please download and check it.
>>
>> ---
>>
>> Regards
>>
>> Cheung
>>
>>
>>
>> At 2014-04-29 00:53:57,"Wei Huang" <huangwei@ucar.edu> wrote:
>> Cheung,
>>
>> Can you point us a data you are using, so we can take a look?
>>
>> Thanks,
>>
>> Wei
>> On Apr 23, 2014, at 6:23 AM, Cheung <zuibeidemei@126.com> wrote:
>>
>>> Dear all:
>>> I just came across a different result when I use ncl-6.2.0 processing the HDF-eos file from CloudSat, before I was using 6.1.0.
>>>
>>> This particular variable is layer_optical_depth from 2b-tau as documented http://www.cloudsat.cira.colostate.edu/dataSpecs.php?prodid=2.
>>>
>>> I used to use:
>>>
>>> var = short2flt(eos_file->layer_optical_depth_2B_TAU)/100 to retreive the "actual" value in float from this file due to a factor of 100.
>>>
>>> However, in this new version, I found I need to "xxxxx/10000" to retreive the "actual" value in float.
>>>
>>> I'm not sure what happen during this process, any comment is appreciated.
>>>
>>> Regards
>>>
>>> Cheung
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> 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 Tue Apr 29 10:35:15 2014

This archive was generated by hypermail 2.1.8 : Sun May 04 2014 - 12:38:56 MDT