[ncl-talk] Scale and offset not being applied to float type variables

Mary Haley haley at ucar.edu
Fri Feb 12 14:32:50 MST 2016


Vimal,

For one, NCL doesn't *not* automatically apply scale_factor / add_offset
type of attributes. This either has to be done directly by you (which I
assume you did here), or else you have to use one of the "short2flt",
"byte2flt", type of functions that apply the attributes for you.

Also, when you do straight multiply / add operations, NCL will not update
the "units" attribute for you, because it has no way of knowing what kind
of conversion you are applying. It is up the user to make the correction to
the "units" attribute.

heat at units = "degC"

--Mary


On Tue, Feb 9, 2016 at 4:39 AM, Vimal Koul <koulvimal18 at gmail.com> wrote:

> Sorry, There is a correction in my previous mail.
>
> The offset and scale is being applied correctly but the units are not
> being changed.
>
> So the issue is with the units of the read variable not the value.
>
> Thanks
> Vimal
>
>
> Regards,
> Vimal Koul
>
>
> On 9 February 2016 at 16:59, Vimal Koul <koulvimal18 at gmail.com> wrote:
>
>> Dear all,
>>
>> I have a variable with the following description.
>>
>>  float temperature ( time, depth, lat, lon )
>>          long_name :    temperature
>>          standard_name :    sea_water_potential_temperature
>>          units :    kelvin
>>          _FillValue :    -32768
>>          add_offset :    273.15
>>          scale_factor :       1
>>          valid_min :    -5
>>          valid_max :    45
>>
>>
>> When I read this variable in NCL, the values are in degrees Celsius and
>> not in Kelvin even though a printVarSummary gives the units as "Kelvin".
>>
>> h      = addfile("HadIProfile_201305_2.5deg.nc","r")
>>
>> heat = h->temperature(0,{0:305},:,:)
>>
>> printVarSummary(heat)
>>
>> Variable: heat
>> Type: float
>> Total Size: 787968 bytes
>>             196992 values
>> Number of Dimensions: 3
>> Dimensions and sizes:    [depth | 19] x [lat | 72] x [lon | 144]
>> Coordinates:
>>             depth: [5.02159..270.5341]
>>             lat: [88.75..-88.75]
>>             lon: [1.25..358.75]
>> Number Of Attributes: 8
>>   time :    77932.5
>>   standard_name :    sea_water_potential_temperature
>>   long_name :    temperature
>>   units :    kelvin
>>   add_offset :    273.15
>>   scale_factor :     1
>>   _FillValue :    -32768
>>   missing_value :    -32768
>>
>>
>> It seems NCL is not using the scale/add_offset for float-type variables
>> like it does for short-type or did I miss something?
>>
>> Any suggestions would be helpful.
>>
>> Thanks,
>> Vimal
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160212/8bf58fed/attachment.html 


More information about the ncl-talk mailing list