Re: WRF: Max & Min Temperature calculation

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Tue Mar 09 2010 - 09:57:12 MST

Hi Sahidul,
If you are using addfiles, you need to use the a[:]-> syntax when
reading in a variable. If you are simply using addfile, then you should
be using the a-> syntax.

a = addfile(FILES(ifil)+".nc","r")
temp = a->TK

Adam

On 03/08/2010 11:31 PM, Sahidul wrote:
> Hello Adam,
> Thank you for your help.
> Yes, you are right. In my WRF out files, T is defined as:
>
> netcdf wrfout_d01_2010-02-16_00\:00\:00 {
> dimensions:
> Time = UNLIMITED ; // (1 currently)
> DateStrLen = 19 ;
> west_east = 369 ;
> south_north = 307 ;
> west_east_stag = 370 ;
> bottom_top = 26 ;
> south_north_stag = 308 ;
> bottom_top_stag = 27 ;
> soil_layers_stag = 5 ;
> variables:
> char Times(Time, DateStrLen) ;
> float T(Time, bottom_top, south_north, west_east) ;
> T:FieldType = 104 ;
> T:MemoryOrder = "XYZ" ;
> T:description = "perturbation potential temperature
> (theta-t0)" ;
> T:units = "K" ;
> T:stagger = "" ;
> T:coordinates = "XLONG XLAT" ;
>
>
> I tried to construct according to your script. I have written script
> like below:
> -------------------------------
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
> begin
>
> datadir = "/casvol5/basantas/cas/WRF3-1/output-wrf/2010030600/"
> FILES = systemfunc ("ls -1 " + datadir + "wrfout_d01* " )
> numFILES = dimsizes(FILES)
>
> do ifil = 0,numFILES-1
> a = addfile(FILES(ifil)+".nc","r")
>
> ;fils = systemfunc("ls /wrf/cas/WRF3-1/output-wrf/2010030600/wrfout_d01_*")
> ;a = addfiles(fils+".nc","r")
> ;temp = a[:]->T ; T = temperature or theta? If theta use wrf_tk to
> ; convert if desired
> wks = gsn_open_wks("x11","test")
>
> P = a->P ; perturbation
> Pb = a->PB ; base state pressure
> P = P + Pb ; total pressure
> T = a->T ; perturbation potential temperature (theta+t0)
> T = T
>
> TK = wrf_tk (P, T)
>
> temp = a[:]->TK
>
>
> dailymax = temp(0::24,:,:,:) ; copy metadata
> ;dailymax = dailymax@_FillValue
> dailymin = dailymax
> cntr = 0
> do gg = 0,dimsizes(temp&Time)-1
> dailymax(cntr,:,:,:) = dim_max_n(temp(cntr:cntr+23,:,:,:),0)
> dailymin(cntr,:,:,:) = dim_min_n(temp(cntr:cntr+23,:,:,:),0)
> cntr = cntr+24
> end do
> end do
> end
> -------------------------------
>
> I am getting errors in ( temp = a[:]->TK ) ; like
> fatal:List subscripting used on non-list variable, can't continue
> fatal:Execute: Error occurred at or near line 27 in file max-min.ncl
> Here line 27: temp = a[:]->TK
>
> Please help me to sort it.
>
> Message: 2
> Date: Mon, 08 Mar 2010 10:01:53 -0700
> From: Adam Phillips <asphilli@ucar.edu <mailto:asphilli@ucar.edu>>
> Subject: Re: WRF: Max & Min Temperature calculation
> To: ncl-talk@ucar.edu <mailto:ncl-talk@ucar.edu>
> Message-ID: <4B952D81.6080707@ucar.edu
> <mailto:4B952D81.6080707@ucar.edu>>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> HI Sahidul,
> Using dim_max/dim_min (or dim_max_n/dim_min_n if you have version
> 5.1.1), this should not be that bad. For example:
> -----------------------------
> fils = systemfunc("ls wrfout*")
> a = addfiles(fils+".nc","r")
> temp = a[:]->T ; T = temperature or theta? If theta use wrf_tk to
> convert if desired
>
> dailymax = temp(0::24,:,:,:) ; copy metadata
> dailymax = dailymax@_FillValue
> dailymin = dailymax
> cntr = 0
> do gg = 0,dimsizes(temp&Time)-1
> dailymax(cntr,:,:,:) = dim_max_n(temp(cntr:cntr+23,:,:,:),0)
> dailymin(cntr,:,:,:) = dim_min_n(temp(cntr:cntr+23,:,:,:),0)
> cntr = cntr+24
> end do
> -----------------------------
>
> That will calculate the max/min temperature for every grid point at
> every level. I am not sure whether for your model data if temperature is
> output or whether theta is output. If theta is, and you want to convert
> it to temperature use wrf_tk:
> http://www.ncl.ucar.edu/Document/Functions/Built-in/wrf_tk.shtml
> Good luck,
> Adam
>
>
> On 03/08/2010 09:25 AM, Sahidul wrote:
> > Dear Sir/NCL Users,
> >
> > I would like to calculate maximum and Minimum temperature in a
> day(24 hours).
> >
> > I am having WRF output files saved in 1 hour interval. Like below ( 1
> > day forecast files = 24)
> >
> > wrfout_d01_2010-03-05-00:00:00 (Times = 2010-03-05-00:00:00)
> > (temperature -> T (Time, lev,lat,lon) )
> > wrfout_d01_2010-03-05-01:00:00 (Times = 2010-03-05-01:00:00)
> > wrfout_d01_2010-03-05-02:00:00 (Times = 2010-03-05-02:00:00)
> > ......
> > .....
> > wrfout_d01_2010-03-05-23:00:00 (Times = 2010-03-05-23:00:00)
> >
> >
> > please help me to calculate it. If anyone has any scripts for this,
> > kindly provide me.
> >
> > Thanking you,
> >
> > Sahidul
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
__________________________________________________
Adam Phillips 
asphilli@ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
Climate and Global Dynamics Division         fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Mar 9 09:57:16 2010

This archive was generated by hypermail 2.1.8 : Thu Mar 11 2010 - 11:17:07 MST