[ncl-talk] Could there be a bug

Dennis Shea shea at ucar.edu
Tue Aug 28 12:01:05 MDT 2018


More information:

If the netCDF file is CF or COARDS convention conforming as identified by :

// global attributes:
                :*Conventions* = "CF-???"

then these conventions *require *that the first formula Mary mentioned be
used*, *Specifically:

*   xF = xS*xS at scale_factor + x at add_offset   *; x*F*=>float, x*S*=>short

The CDO (1) check for the presence of the CF/COARDS *Conventions*
attribute. If present, (2) the CDO automatically applies the formula.

While NCL could do the conversion automatically, it assumes that the reader
wants what is on the file

    xS = f->xShort                 ; type short
    printVarSummary(xS)

As noted previously,

    xF = *short2flt*
<http://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml>(
f->xShort )   ; type float
    printVarSummary(xF)
    printMinMax(xF,0)

On Tue, Aug 28, 2018 at 9:17 AM, Mary Haley <haley at ucar.edu> wrote:

> Hi Dave,
>
> I started to reply and then saw that Jim had replied.
>
> He's correct that you need to apply the scale_factor and add_offset to
> your data. You can use the special "short2flt" function to do this:
>
> sst = short2flt(f->sst)
>
> It's important to note that packed data is not always packed the same
> way!  short2flt applies this calculation:
>
>      xF = xS*xS at scale_factor + x at add_offset
>
> but we've seen data where the formula was :
>
>     xF = xS at scale_factor * (xS-xS at add_offset)
>
> This is a case where you have to look at your data (i.e. via printMinMax)
> after you do the calculation, to make sure the values look right. Sometimes
> data will have a "valid_range" attribute that tells you what the expected
> range of this particular variable is.
>
> --Mary
>
>
>
>
>
>
> On Tue, Aug 28, 2018 at 8:33 AM, dave montgomery <
> montgomery_dave at yahoo.com> wrote:
>
>> Dear NCL Users,
>> I plotted sst on a local scale using NCL. The result for the sst variable
>> are way too high. Plotting the same data with CDO and using ncview, the
>> results for the sst variable are in the values to be expected. In CDO, the
>> variable sst has a range from 297.274K to 300.189K but in NCL the plotted
>> graph showed a range from about 12000 to 16000. Could our most esteem NCL
>> experts help me out here? I would be grateful for your help.
>> Attached are the file, script and the corresponding plot.
>> I am using NCL version 6.4.0
>> Data is from ERA5
>>
>> Best regards
>> Dave Montgomery
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> 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/20180828/b888ce19/attachment.html>


More information about the ncl-talk mailing list