Re: Maximum temp calculation

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Apr 14 2010 - 14:17:14 MDT

The problem is that you are trying to access the leftmost dimension
of "temp" in chunks of 24,
but you don't have a nice multiple of 24 for time.

The first time in the loop, cntr is 0, so you access elements 0:23 of
the time dimension. This is fine.

The second time in the loop, cntr is 24, so you access elements 24:47
of the time dimension. This is also fine.

The third time: cntr=48, and elements 49:71 are okay.

However, the fourth time, cntr is 72, which means you are trying to
access elements 72:95, and you only have 88 time values
Hence the error.

You will need to do something special for that last subset, something
like this:

   temp_dims = dimsizes(temp)
   ntime = temp_dims(0)
   nt24 = ntime/24
   do gg = 0,nt24
     cntr = gg*24
     cntr23 = cntr+23
     if(cntr23.ge.ntime) then
; . . . do something else here, maybe print a warning or calculate a
partial max.
; dailymax(gg,:,:) = dim_max_n(temp(cntr:ntime-1,0,:,:),0)
     else
       dailymax(gg,:,:) = dim_max_n(temp(cntr:cntr23,0,:,:),0)
     end if
   end do

--Mary

On Apr 14, 2010, at 11:18 AM, Sahidul wrote:

>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
>>
>> begin
>>
>> datadir = "/scratch/WRF/2010041400/"
>> FILES = systemfunc ("ls -1 " + datadir + "wrfout_d01_2010-04* " )
>> numFILES = dimsizes(FILES)
>> a = addfiles(FILES+".nc","r")
>>
>> wks = gsn_open_wks("ps","test")
>>
>> gsn_define_colormap(wks,"gui_default")
>>
>> P = a[:]->P ; perturbation
>> Pb = a[:]->PB ; base state pressure
>> Pt = P + Pb ; total pressure
>> Tc = a[:]->T ; perturbation potential temperature(theta+t0)
>> Tc = Tc + 300
>>
>> temp = wrf_tk(Pt,Tc)
>>
>> dailymax = temp(0::24,0,:,:) ; copy metadata
>> printVarSummary(dailymax)
>> dailymax = dailymax@_FillValue
>>
>> res = True ; plot mods desired
>> res@gsnSpreadColors = True ; make cn span
>> entire color map
>> res@cnFillOn = True
>> res@gsnAddCyclic = False
>> res@cnLineLabelsOn = False
>>
>> plts = new (3 , "graphic")
>>
>> cntr = 0
>> do gg = 0,dimsizes(temp(0::24,0,0,0))-1
>>
>> dailymax(gg,:,:) = dim_max_n(temp(cntr:cntr+23,0,:,:),0)
>> cntr = cntr+24
>>
>> plts(gg) =gsn_csm_contour(wks,dailymax(gg,:,:),res)
>>
>> end do
>> end
>> ;;;=====================================

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Apr 14 14:21:23 2010

This archive was generated by hypermail 2.1.8 : Fri Apr 16 2010 - 16:21:29 MDT