Re: rainfall calculations

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu, 24 Aug 2006 08:24:37 -0600 (MDT)

Anil,

I'm not sure where the error message about the units is coming
from, but you are calling WRF_map_c with the wrong argument.
Please note what the error message says:

    fatal:Argument type mismatch on argument (0) of (WRF_map_c) can not coerce

The "0" argument is the first argument (since NCL is 0-based). The
first argument of WRF_map_c is supposed to be of type "file" (that is,
the type of variable that gets returned by a call to "addfile").

You are calling it with:

    WRF_map_c(F, res, 0) ; reads info from file

where "F" is actually a "list" (this is what's returned by "addfiles").

I'm not familiar with how WRF_map_c works, but it is designed to work
on single WRF files, and not an group of WRF files which is what "F"
is.

Since the WRF_map_c function is set up specifically to work with WRF
files, this means it is expecting certain WRF variables (XLAT/XLONG)
and attributes ("MAP_PROJ", "CEN_LON", "CEN_LAT") to be set on the
file.

What I think you need to do is 1) write out the variables that you
have generated from the list of WRF files to a single WRF netCDF file,
and 2) read this file in with "addfile", and 3) pass that argument to
WRF_map_c.

You will need to make sure that the variable or variables that you
write to the new WRF file has the XLAT, XLONG variables, and that
global attributes like MAP_PROJ, CEN_LON, CEN_LAT, TRUELAT1, and
TRUELAT2 are also written to the new file.

--Mary

On Wed, 23 Aug 2006, anil rohilla wrote:
C
> Dear lists i am now able to read the times in my files but still i am
> geeting this error
>
> ----------------------------oupte of ncl----------------------
> Variable: F
> Type: list
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
>
>
> Variable: ntim
> Type: integer
> Total Size: 4 bytes
> 1 values
> Number of Dimensions: 1
> Dimensions and sizes: [1]
> Coordinates:
> (0) 8
>
>
> Variable: times
> Type: string
> Total Size: 32 bytes
> 8 values
> Number of Dimensions: 1
> Dimensions and sizes: [8]
> Coordinates:
> (0) 2006-07-01_00:00:00
> (1) 2006-07-01_03:00:00
> (2) 2006-07-01_06:00:00
> (3) 2006-07-01_09:00:00
> (4) 2006-07-01_12:00:00
> (5) 2006-07-01_15:00:00
> (6) 2006-07-01_18:00:00
> (7) 2006-07-01_21:00:00
> warning:Attempt to reference attribute (units) which is undefined
> fatal:Argument type mismatch on argument (0) of (WRF_map_c) can not coerce
> fatal:Execute: Error occurred at or near line 77 in file myplot.ncl
> -----------------------------------------------------------------------------
>
> my script is
> ------------------------------
>
> ;*************************************************
> ; WRF: RPRECIPITATION: Total, Cumulus and non-cumulus prc
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
> begin
> ;************************************************
> ; open file
> ; Read Cumulus (rinc) and Non-cumulus (rainnc) prc
> ;************************************************
> diri = "/datatmp3/anilkuma/temp/"
> fili = systemfunc("cd "+diri +"; ls *d02*")
> fili = fili +".nc" ; explicitly add file extension
>
> F = addfiles (diri+fili, "r") ; refers to *all* files
> ; f = addfile (diri+fili(0), "r") ; refers to 1st file only
> print(F)
> ;************************************************
> ; open file and read in data
> ; (1) Read RAINC
> ; (2) Read character variable Times; Convert to string for plots
> ;************************************************
> times = chartostring(F[:]->Times) ; built-in function
> ntim = dimsizes(times) ; # of time steps
> print(ntim)
> print(times)
>
>
>
>
>
>
> ; f =
> addfile("/datatmp3/anilkuma/temp/wrfout_d02_2006-07-01_12:00:00.nc",
> "r")
> rainc = F[:]->RAINC ; (Time, south_north, west_east)
> rainnc = F[:]->RAINNC
>
> times = chartostring(F[:]->Times) ; convert to type string [plot]
> ntim = dimsizes(times) ; # time steps
> ;************************************************
> ; Use NCL operator > to make sure all values >=0.0
> ; Sum components and assign attributes
> ;************************************************
> rainc = rainc > 0.0
> rainnc = rainnc > 0.0
> rainTot = rainc + rainnc
> rainTot_at_description = "Total Precipitation"
> rainTot_at_units = rainc_at_units
> ;************************************************
> ; create plots: create colormap using named colors
> ; unequal contour levels
> ;************************************************
> wks = gsn_open_wks("ps" ,"rain_cumulus2512") ; ps,pdf,x11,ncgm,eps
> colors = (/"white","black" \ ; {for/back}ground
> ,"white" \
> ,"white","palegreen","green", "greenyellow" \
> ,"yellow","goldenrod","orange","orangered" \
> ,"red","deeppinK", "violet","darkviolet" \
> ,"blueviolet","blue" /)
> gsn_define_colormap(wks, colors)
>
> res = True ; plot mods desired
> ;;res_at_gsnMaximize = True ; uncomment to maximize size
> res_at_gsnSpreadColors = True ; use full range of colormap
> res_at_cnFillOn = True ; color plot desired
> res_at_cnLinesOn = False ; turn off contour lines
> res_at_cnLineLabelsOn = False ; turn off contour labels
>
> res_at_cnLevelSelectionMode = "ExplicitLevels" ; explicit [unequal] cn levels
> res_at_cnLevels =
> (/0,10,20.5,50,70.5,100,150,250,325,437.5,550,675,700,825,950/)
> res_at_cnFillMode = "RasterFill"
> res_at_lbOrientation = "Vertical" ; default is horizontal
> ;************************************************
> ; Use WRF_contributed procedure to set map resources
> ;************************************************
> WRF_map_c(F, res, 0) ; reads info from file
> ;************************************************
> ; set True for native projection (faster)
> ;************************************************
> res_at_tfDoNDCOverlay = True
>
> ;****************************************************************************
> ; create panel of different components
> ;****************************************************************************
> plts = new (3 , "graphic") ; 1d array to hold plots
>
> res_at_gsnDraw = False ; (a) do not draw
> res_at_gsnFrame = False ; (b) do not advance 'frame'
> res_at_lbLabelBarOn = False ; (c) turn off individual lb's
> ;************************************************
> ; create panel: panel plots have their own set of resources
> ;************************************************
> resP = True ; modify the panel plot
> resP_at_gsnMaximize = True ; maximize panel area
> resP_at_gsnPanelRowSpec = True ; specify 1 top, 2 lower level
> resP_at_gsnPanelLabelBar = True ; add common colorbar
> resP_at_pmLabelBarWidthF = 0.85 ; make label wider
> resP_at_lbLabelFontHeightF = 0.015 ; default 0.02 [demo
> make smaller]
>
> nt = 8 ; demo only one time
> do nt=0,ntim-1 ; uncomment to loop over all
> times
> plts(0) = gsn_csm_contour_map(wks,rainTot(nt,:,:),res)
> plts(1) = gsn_csm_contour_map(wks,rainnc(nt,:,:),res)
> plts(2) = gsn_csm_contour_map(wks,rainc(nt,:,:),res)
>
> resP_at_txString = f_at_TITLE+": "+times(nt)
> gsn_panel(wks,plts,(/1,2/),resP) ; now draw as one plot
> end do
> end
> --------------------------------------------------------
>
> Any help in this regards
>
>
>
>
>
> --
> ANIL KUMAR ROHILLA
> Meteorologist
> Long Range Forecasting Section
> NATIONAL CLIMATE CENTER
> O/o ADGM(Research)
> India Meteorological Department
> Shivaji Nagar
> PUNE-411005.
> INDIA
> Mobile: 09422023277
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 24 2006 - 08:24:37 MDT

This archive was generated by hypermail 2.2.0 : Thu Aug 24 2006 - 11:35:02 MDT