<div dir="ltr"><div><div><div><div><div>The variable, tasC, is an *array * <br><br> tasC = tasL - 273.15 ; Convert K to C<br></div> printVarSummary(tasC)<br><br></div>You can not use an array as a loop variable ... in any language.<br>
<br> do tasC = 0,364<br><br></div>could be, say,<br><br> do day = 0,364<br><br></div>See:<br><a href="https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclStatements.shtml#Loops">https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclStatements.shtml#Loops</a><br>
<br></div>Specifically:<br><pre> do <i>loop_identifier</i> = <i>scalar_start_expr</i> , <i>end_expr<br><br></i></pre><pre><i>T</i>he "scalar_start_expr , end_expr" are scalar.</pre><br><div><div><div><div><br>===<br>
<br> a = addfile("tas_day_CCSM4_lgm_<div id=":13g" class=""><a href="http://r2i1p1_18700101-19001231.nc">r2i1p1_18700101-19001231.nc</a>","r")<br>
tasL = a->tas(0:364,:,:)<br><br></div><div id=":13g" class=""> TIME = cd_calendar(tasL&time,0) ; TIME(ntim,6)<br></div><div id=":13g" class=""> print(TIME)<br></div>
<div id=":13g" class=""><br></div><div id=":13g" class="">
tasC = tasL - 273.15 ; Convert K to C<br></div><div id=":13g" class=""> tasC = where(tasC.gt.0.0, tasc, 0.0)<br></div><div id=":13g" class=""> pdd = dim_sum_n_Wrap(tasC, 0) ; (lat,lon)<br>
</div><div id=":13g" class=""> pdd@long_name = "degree days for year="+toint(TIME(0,0))<br></div><div id=":13g" class=""> pdd@units = "degC"<br><br><br></div></div></div></div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 4, 2014 at 9:16 AM, Lauren Jean Vargo <span dir="ltr"><<a href="mailto:lvargo@unm.edu" target="_blank">lvargo@unm.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I’m having trouble doing a calculation with NCL, ultimately I am trying to calculate the Positive degree-day (PDD) sum. I’ve read in daily temperature data (which is 3D [time,lat,lon]). What I am trying to do is calculate the sum of the temperatures that are greater than 0C for 1 year.<br>
<br>
The way I was trying to do this was with a loop, and to first set any temperature less than or equal to zero, just to zero. Next I want to sum all the temperatures over 365 days at each lat & lon point. If there is an easier way to do this using NCL functions, that would be great.<br>
<br>
The error message that I am getting is that the “loop must be scalar". However, I’m not sure how to specify that I want the temperature value to be analyzed when tasC is (time,lat,lon).<br>
<br>
I’ve uploaded the file "tas_day_CCSM4_lgm_r2i1p1_18700101-19001231.nc” to the ftp account.<br>
<br>
I’m running ncl version 6.1.2, and the system is Darwin Kernel Version 13.3.0<br>
<br>
<br>
Here is the script:<br>
<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>
load “$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"<br>
<br>
begin<br>
<br>
; Read in near surface air temperature (Ta)<br>
<br>
a = addfile("tas_day_CCSM4_lgm_r2i1p1_18700101-19001231.nc","r")<br>
tasL = a->tas(0:364,:,:)<br>
tasC = tasL - 273.15 ; Convert K to C<br>
print (tasC)<br>
printVarSummary (tasC)<br>
<br>
do tasC = 0,364<br>
if (tasC .le. 0)<br>
H = 0<br>
end if<br>
end do<br>
<br>
PDD_sum = dim_cumsum_n_Wrap(tasC)<br>
<br>
end<br>
<br>
<br>
Any help would be greatly appreciated.<br>
<br>
Thanks,<br>
<br>
Lauren Vargo<br>
M.S. Candidate<br>
The University of New Mexico<br>
_______________________________________________<br>
ncl-talk mailing list<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><br>
</blockquote></div><br></div>