<div dir="ltr"><div><div><div><div><div>Hello<br><br>[1]<br></div>I'm not sure what R's SPEI function <br><br> <a href="https://cran.r-project.org/web/packages/SPEI/SPEI.pdf">https://cran.r-project.org/web/packages/SPEI/SPEI.pdf</a><br><br>has to do with extra-terrestrial radiation. SPEI uses temperature and precipitation. These variables are 'always' present.<br><br>[2]<br></div>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.<br><br></div>I have added more documentation to explicitly show what radext_fao56 returns. See:<br><br> <a href="http://www.ncl.ucar.edu/Document/Functions/Crop/radext_fao56.shtml">http://www.ncl.ucar.edu/Document/Functions/Crop/radext_fao56.shtml</a><br></div> Example 3: <br> Click on "here" at the end of this example. It shows printed values.<br><br>[3]<br></div><div>Example 2 at: <a href="http://www.ncl.ucar.edu/Applications/crop.shtml">http://www.ncl.ucar.edu/Applications/crop.shtml</a><br><br></div><div>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.']<br><br>[4]<br></div><div>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.<br><pre> radext = <a href="http://www.ncl.ucar.edu/Document/Functions/Crop/radext_fao56.shtml"><strong>radext_fao56</strong></a>(jday, lat, ounit)<br> ; set all _FillValue = 0.0<br> radext = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml"><strong>where</strong></a>(<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/ismissing.shtml"><strong>ismissing</strong></a>(radext), 0, radext)
</pre><br></div><div>HTH<br><br></div><div>D<br></div><br><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 26, 2016 at 1:55 PM, Tam, Benita (EC) <span dir="ltr"><<a href="mailto:benita.tam@canada.ca" target="_blank">benita.tam@canada.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-US">
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">Thanks.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">I’ve been able to successfully run the code.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">However, when I pull out data for a specific location, the months, November to March, contain missing values.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">I’ve tested the same data in R using the SPEI program, and there are no missing values.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">(output and scripts attached)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">Thanks,
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">Benita<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Dennis Shea [mailto:<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>]
<br>
<b>Sent:</b> July 26, 2016 3:09 PM<br>
<b>To:</b> Mary Haley<br>
<b>Cc:</b> Tam, Benita (EC); <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
<b>Subject:</b> Re: [ncl-talk] Testing out new function (ncl 6.4.0): radext_fao56 doesn't work<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">Your code<br>
f= addfile("./Cangrd/<a href="http://tasmax_cangrd_1900_1950.nc" target="_blank">tasmax_cangrd_1900_1950.nc</a>", "r")<br>
tasmax = f->tasmax ; tasmax(time,lat,lon)<br>
tasmax@units = "degC" <br>
printVarSummary(tasmax) <br>
time = f->time <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> jday = time ; <******* I would be **stunned** if this were correct
<br>
radext = radext_fao56(jday, lat, 1) ; (time,lat)<br>
<br>
---<br>
Please read:<br>
<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml" target="_blank">
http://www.ncl.ucar.edu/Document/Functions/Built-in/cd_calendar.shtml</a><br>
<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/conform.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Functions/Built-in/conform.shtml</a><br>
<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/day_of_year.shtml" target="_blank">
http://www.ncl.ucar.edu/Document/Functions/Built-in/day_of_year.shtml</a><br>
<br>
f= addfile("./Cangrd/<a href="http://tasmax_cangrd_1900_1950.nc" target="_blank">tasmax_cangrd_1900_1950.nc</a>", "r")<br>
tasmax = f->tasmax ; tasmax(time,lat,lon) <br>
printVarSummary(tasmax) <br>
<br>
time = f->time <br>
date = <strong>cd_calendar</strong>(time, -5)<br>
jday = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/day_of_year.shtml" target="_blank">
<strong>day_of_year</strong></a>(date(:,0),date(:,1),date(:,2)<u></u><u></u></p>
<pre> radext = radext_fao56(jday, tasmax&lat, 1) ; (time,lat)<br><br> RADEXT = conform(tas, radext, (/0,1/) ) ; time;lat,lon<br> copy_VarAtts(radext, RADEXT)<br> copy_VarCoords(tas, RADEXT)<br> printVarSummary(RADEXT)<br><br>---<u></u><u></u></pre>
<pre style="margin-bottom:12.0pt">I also suggest you read the FAO-56 document. <br>In particular, the section on external radiation. <u></u><u></u></pre>
<pre>Good luck<u></u><u></u></pre>
<pre style="margin-bottom:12.0pt"><u></u> <u></u></pre>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Tue, Jul 26, 2016 at 12:14 PM, Mary Haley <<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">In the future, please respond back to ncl-talk so other users can benefit from the answers.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Dennis will have to answer your question about the function, as he wrote the suite of crop routines. He's on ncl-talk.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">--Mary<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Tue, Jul 26, 2016 at 11:45 AM, Tam, Benita (EC) <<a href="mailto:benita.tam@canada.ca" target="_blank">benita.tam@canada.ca</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">Thanks, Mary.
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">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?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">(script attached)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d">Benita</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Mary Haley [mailto:<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>]
<br>
<b>Sent:</b> July 26, 2016 1:10 PM<br>
<b>To:</b> Tam, Benita (EC)<br>
<b>Cc:</b> <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
<b>Subject:</b> Re: [ncl-talk] Testing out new function (ncl 6.4.0): radext_fao56 doesn't work</span><u></u><u></u></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">You need to load the "crop.ncl" library:</span><u></u><u></u></p>
</div>
<div>
<pre><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/<a href="http://www.ncl.ucar.edu/Document/Functions/Crop/crop.shtml" target="_blank">crop.ncl</a>"</span><u></u><u></u></pre>
<pre><span style="font-size:12.0pt;font-family:"Arial","sans-serif"">The documentation for this function has this information in the "Prototype" section:</span><u></u><u></u></pre>
<pre><span style="font-family:"Arial","sans-serif""><a href="http://www.ncl.ucar.edu/Document/Functions/Crop/radext_fao56.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Functions/Crop/radext_fao56.shtml</a></span><u></u><u></u></pre>
<pre> <u></u><u></u></pre>
</div>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Tue, Jul 26, 2016 at 10:48 AM, Tam, Benita (EC) <<a href="mailto:benita.tam@canada.ca" target="_blank">benita.tam@canada.ca</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA">Hi,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA">I am testing out the latest version of NCL (6.4.0). The function, radext_fao56, doesn’t seem to work.
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA">Error:</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA">fatal:Undefined identifier: (radext_fao56) is undefined, can't continue</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA">fatal:["Execute.c":8575]:Execute: Error occurred at or near line 30 in file cangrd_ra.ncl</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA">(NCL script attached)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA">Thanks,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"" lang="EN-CA">Benita</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</blockquote></div><br></div>