[ncl-talk] Testing out new function (ncl 6.4.0): radext_fao56: missing values consistent for Nov-March

Dennis Shea shea at ucar.edu
Wed Jul 27 10:37:29 MDT 2016


Hello

[1]
I'm not sure what R's SPEI function

   https://cran.r-project.org/web/packages/SPEI/SPEI.pdf

has to do with extra-terrestrial radiation. SPEI uses temperature and
precipitation. These variables are 'always' present.

[2]
Extraterrestrial radiation, as defined by the FAO-56 reference, is a
function of day-of-year and latitude. Yes  ... both of those are also
'always' present. :-) The issue is that the FAO-56 solar declination
approximation used is not appropriate for some high latitudes on certain
days of the year. NCL returns _FillValue where the approximations are not
valid or where  'numerical issues' result in negative values.

I have added more documentation to explicitly show what radext_fao56
returns. See:

        http://www.ncl.ucar.edu/Document/Functions/Crop/radext_fao56.shtml
        Example 3:
        Click on "here" at the end of this example. It shows printed values.

[3]
Example 2 at: http://www.ncl.ucar.edu/Applications/crop.shtml

uses a figure (top) to show when (jday) and where (latitude) the function
returns vald vales. That is the point of the example. [It also 'looks
nice.']

[4]
As noted, if you prefer to have 0s, rather than _FillValue (which NCL
ignores in graphics and computations) then you can change to zero rather
easily.

  radext = *radext_fao56*
<http://www.ncl.ucar.edu/Document/Functions/Crop/radext_fao56.shtml>(jday,
lat, ounit)
         ;  set all _FillValue = 0.0
  radext = *where*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml>(*ismissing*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/ismissing.shtml>(radext),
0, radext)


HTH

D



On Tue, Jul 26, 2016 at 1:55 PM, Tam, Benita (EC) <benita.tam at canada.ca>
wrote:

> Thanks.
>
>
>
> I’ve been able to successfully run the code.
>
>
>
> However, when I pull out data for a specific location, the months,
> November to March, contain missing values.
>
>
>
> I’ve tested the same data in R using the SPEI program, and there are no
> missing values.
>
>
>
> (output and scripts attached)
>
>
>
> Thanks,
>
> Benita
>
> *From:* Dennis Shea [mailto:shea at ucar.edu]
> *Sent:* July 26, 2016 3:09 PM
> *To:* Mary Haley
> *Cc:* Tam, Benita (EC); ncl-talk at ucar.edu
> *Subject:* Re: [ncl-talk] Testing out new function (ncl 6.4.0):
> radext_fao56 doesn't work
>
>
>
> Your code
>         f= addfile("./Cangrd/tasmax_cangrd_1900_1950.nc", "r")
>         tasmax = f->tasmax                 ; tasmax(time,lat,lon)
>         tasmax at units = "degC"
>         printVarSummary(tasmax)
>         time = f->time
>
>         jday = time   ; <******* I would be **stunned** if this were
> correct
>         radext   = radext_fao56(jday, lat, 1)    ; (time,lat)
>
> ---
> Please read:
>   http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml
>   http://www.ncl.ucar.edu/Document/Functions/Built-in/conform.shtml
>   http://www.ncl.ucar.edu/Document/Functions/Built-in/day_of_year.shtml
>
>         f= addfile("./Cangrd/tasmax_cangrd_1900_1950.nc", "r")
>         tasmax = f->tasmax                 ; tasmax(time,lat,lon)
>         printVarSummary(tasmax)
>
>         time   = f->time
>         date  = *cd_calendar*(time, -5)
>         jday  = *day_of_year*
> <http://www.ncl.ucar.edu/Document/Functions/Built-in/day_of_year.shtml>
> (date(:,0),date(:,1),date(:,2)
>
>     radext   = radext_fao56(jday, tasmax&lat, 1)    ; (time,lat)
>
>     RADEXT   = conform(tas, radext, (/0,1/) )   ; time;lat,lon
>     copy_VarAtts(radext, RADEXT)
>     copy_VarCoords(tas,  RADEXT)
>     printVarSummary(RADEXT)
>
> ---
>
> I also suggest you read the FAO-56 document.
> In particular, the section on external radiation.
>
> Good luck
>
>
>
>
>
>
>
>
> On Tue, Jul 26, 2016 at 12:14 PM, Mary Haley <haley at ucar.edu> wrote:
>
> In the future, please respond back to ncl-talk so other users can benefit
> from the answers.
>
>
>
> Dennis will have to answer your question about the function, as he wrote
> the suite of crop routines. He's on ncl-talk.
>
>
>
> --Mary
>
>
>
>
>
> On Tue, Jul 26, 2016 at 11:45 AM, Tam, Benita (EC) <benita.tam at canada.ca>
> wrote:
>
> Thanks, Mary.
>
>
>
> I have one more question: I am trying to produce extraterrestrial
> radiation (radext) with three dimensions, but currently, my output is only
> 2D. Is there a way to ensure that NCL keeps my longitude dimension?
>
>
>
> (script attached)
>
>
>
> Thanks,
>
> Benita
>
>
>
> *From:* Mary Haley [mailto:haley at ucar.edu]
> *Sent:* July 26, 2016 1:10 PM
> *To:* Tam, Benita (EC)
> *Cc:* ncl-talk at ucar.edu
> *Subject:* Re: [ncl-talk] Testing out new function (ncl 6.4.0):
> radext_fao56 doesn't work
>
>
>
> You need to load the "crop.ncl" library:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/crop.ncl <http://www.ncl.ucar.edu/Document/Functions/Crop/crop.shtml>"
>
> The documentation for this function has this information in the "Prototype" section:
>
> http://www.ncl.ucar.edu/Document/Functions/Crop/radext_fao56.shtml
>
>
>
>
>
> On Tue, Jul 26, 2016 at 10:48 AM, Tam, Benita (EC) <benita.tam at canada.ca>
> wrote:
>
> Hi,
>
>
>
> I am testing out the latest version of NCL (6.4.0). The function,
> radext_fao56, doesn’t seem to work.
>
>
>
> Error:
>
>
>
> fatal:Undefined identifier: (radext_fao56) is undefined, can't continue
>
> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 30 in
> file cangrd_ra.ncl
>
>
>
> (NCL script attached)
>
>
>
> Thanks,
>
> Benita
>
>
> _______________________________________________
> 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/20160727/f6f10ba9/attachment.html 


More information about the ncl-talk mailing list