Improving NCL run-time

From: Kelly Mahoney <kelly.mahoney_at_nyahnyahspammersnyahnyah>
Date: Fri Aug 03 2012 - 11:58:03 MDT

Hi,

I'm trying to do NCL analyses that require calling in 10 netcdf files
(they're fairly big; ~650x650 model gridpoints), read in fields from
each file, average those fields, and plot the result.

Some of the operations in the script, though, make doing this take a
really long time (hours per script and I've got a LOT more of them to do).

I've done this averaging for simple fields like 2m Temp alone and it
doesn't take a long time, so I'm wondering if either the wrf functions,
smoothing, or vectors are causing this to be prohibitively slow.

Or, even more fundamentally, if there's a smarter way to read in my data
from the beginning?

My script is pasted below...thanks for any help or advice you might have!

Kelly

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"

begin

diri2="../Output_Links/Past/"
   innames2=(/diri2+"R1/wrfout_d02_1986-07-17_00:00:00.nc", \
           diri2+"R2/wrfout_d02_1986-07-18_00:00:00.nc",\
           diri2+"R3/wrfout_d02_1983-06-29_00:00:00.nc",\
           diri2+"R4/wrfout_d02_1990-08-04_00:00:00.nc",\
           diri2+"R5/wrfout_d02_1998-08-04_00:00:00.nc",\
           diri2+"R6/wrfout_d02_1993-06-29_00:00:00.nc",\
           diri2+"R7/wrfout_d02_2000-07-01_00:00:00.nc",\
           diri2+"R8/wrfout_d02_1998-07-09_18:00:00.nc",\
           diri2+"R9/wrfout_d02_1982-07-03_18:00:00.nc",\
           diri2+"R10/wrfout_d02_1997-07-27_18:00:00.nc"/)
   f2=addfiles(innames2,"r")

   terfile=addfile(diri2+"R1/wrfout_d02_1986-07-17_00:00:00.nc","r")

   nfiles = dimsizes(innames2)
   print(f2)
   print("nfiles = "+nfiles)

   type = "ps"
   wks = gsn_open_wks(type,"SLP_GFDLTS_Top10Avg_PAST")
   gsn_define_colormap(wks,"WhViBlGrYeOrReWh")

; Set some basic resources
   res = True
   res@MainTitle = "SLP GFDLTS Past Top10Avg F00"

   pltres = True
   mpres = True
   mpres@mpGeophysicalLineColor = "Black"
   mpres@mpNationalLineColor = "Black"
   mpres@mpUSStateLineColor = "Black"
   mpres@mpGridLineColor = "Black"
   mpres@mpLimbLineColor = "Black"
   mpres@mpPerimLineColor = "Black"
   mpres@mpGridSpacingF = 10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

   it = -1

   slp = wrf_user_getvar(f2,"slp",it) ; calculate SLP
       wrf_smooth_2d( slp, 6 ) ; smooth slp
     td2 = wrf_user_getvar(f2,"td2",it) ; Td2 in C
     tc2 = wrf_user_getvar(f2,"T2",it) ; T2 in Kelvin
        tc2 = tc2-273.16 ; T2 in C
     u10 = wrf_user_getvar(f2,"U10",it) ; u at 10 m, mass point
     v10 = wrf_user_getvar(f2,"V10",it) ; v at 10 m, mass point

     u10 = u10*1.94386 ; Turn wind into knots
     v10 = v10*1.94386
       u10@units = "kts"
       v10@units = "kts"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;; Averaging ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

avg_slp=dim_avg_n_Wrap(slp,0)
avg_slp@description="GT Past Top10Avg SLP Temp at F00"

avg_tc2=dim_avg_n_Wrap(tc2,0)
avg_td2=dim_avg_n_Wrap(td2,0)
avg_u10=dim_avg_n_Wrap(u10,0)
avg_v10=dim_avg_n_Wrap(v10,0)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Plotting options for T
       opts = res
       opts@cnFillOn = True
       opts@ContourParameters = (/ -20., 40., 2./)
       opts@gsnSpreadColorEnd = -3 ; End third from the last color in
color map
       contour_tc = wrf_contour(terfile,wks,avg_tc2,opts)
       delete(opts)

     ; Plotting options for Td
       opts = res
       opts@cnFillOn = True
       opts@cnLinesOn = True
       opts@cnLineLabelsOn = True
       opts@ContourParameters = (/ -10., 24., 2./)
       opts@cnLineLabelBackgroundColor = -1
       opts@gsnSpreadColorEnd = -10 ; End third from the last color in
color map
       contour_td = wrf_contour(terfile,wks,avg_td2,opts)
       delete(opts)

     ; Plotting options for SLP
       opts = res
       opts@cnLineColor = "Blue"
       opts@cnHighLabelsOn = True
       opts@cnLowLabelsOn = True
       opts@ContourParameters = (/ 900., 1100., 2. /)
       opts@cnLineLabelBackgroundColor = -1
       opts@gsnContourLineThicknessesScale = 2.0
       contour_psl = wrf_contour(terfile,wks,avg_slp,opts)
       delete(opts)

     ; Plotting options for Wind Vectors
       opts = res
       opts@FieldTitle = "Wind" ; overwrite Field Title
       opts@NumVectors = 30 ; density of wind barbs
       vector = wrf_vector(terfile,wks,avg_u10,avg_v10,opts)
       delete(opts)

     ; MAKE PLOTS
       plot =
wrf_map_overlays(terfile,wks,(/contour_tc,contour_psl,vector/),pltres,mpres)
       plot =
wrf_map_overlays(terfile,wks,(/contour_td,vector/),pltres,mpres)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Aug 3 11:58:14 2012

This archive was generated by hypermail 2.1.8 : Fri Aug 03 2012 - 14:39:58 MDT