Re: Plotting wind speed time series

From: Andrea N. Hahmann <ahah_at_nyahnyahspammersnyahnyah>
Date: Fri Jul 06 2012 - 05:12:50 MDT

Hi Nick

In the line you make the plot:

plot = gsn_csm_xy(wks,ntimes,spd,res)

Ntimes is an integer, no dimensions. You need to make a new variable with
the "times" which is dimensioned by ntimes
Something like

Times = ispan(0,ntimes-1,ntimes)
Then

plot = gsn_csm_xy(wks,times,spd,res)

Andrea

On 7/6/12 1:11 AM, "Nick Dawson" <ndawson33@gmail.com> wrote:

>Hello,
>
>I am having trouble plotting wind speed as a function of time. I know
>the error states that the diminsions are incorect but how can I
>correct this error? ntimes and spd need to have the same dimensions,
>but which should I fix?
>
>(0) gsn_csm_xy: Fatal: X and Y must have the same dimensions
>sizes, or one must be one-dimensional and both have the same rightmost
>dimension.
>fatal:CheckArray:Each vector in the caXArray array must have at least 2
>elements
>
>
>Here is my script
>
>
>;***********************************************
>; WRF: Extract/plot wind speed at specific location
>;***********************************************
>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"
>load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
>begin
>
>
>;************************************************
>; open file and read in data
>;************************************************
>
>
> all_files = systemfunc("ls wrfout_d02*") + ".nc"
> f = addfiles(all_files,"r")
> ListSetType (f,"cat")
>
>
>;************************************************
>;read only one file because XLAT/XLON for plot location
>; will not work with a list of files
>;************************************************
> s = addfile ("wrfout_d02_2012-01-09_00:00:00.nc","r")
>
>;************************************************
>; Read all the times. Define wind speed
>;************************************************
> time = wrf_user_list_times(f)
> ntimes = dimsizes(time)
> spd = new(ntimes,float)
>
>
>;************************************************
>; Import time series of u and v
>; at a specified grid point and calculate speed
>;************************************************
>do it = 0,ntimes-1
>
> u = wrf_user_getvar(f,"U",it)
> u_point = u(3,248,92)
> v = wrf_user_getvar(f,"V",it)
> v_point = v(3,248,92)
> spd(it) = (u_point*u_point+v_point*v_point)^(0.5)
> print(spd(it))
>
>end do
>
>
>;************************************************
>; For plot label, read the lat/lon location
>;************************************************
> lat = s->XLAT(0,248,92)
> lon = s->XLONG(0,248,92)
>
>
>;************************************************
>; create plots: two variations.
>;************************************************
> wks = gsn_open_wks("pdf" ,"WRF_xy") ; ps,pdf,x11,ncgm,eps
>
> res = True ; plot mods desired
> res@tiMainString = "80m Wind Speed at"+lat+"N "+fabs(lon)+"W"
> ;res@tiXAxisString = time@units ; label bottom axis with
>units
> res@xyLineThicknessF = 3.0 ; make a bit thicker
> plot = gsn_csm_xy(wks,ntimes,spd,res)
>
>
>end
>
>Thank you,
>
>Nick Dawson
>_______________________________________________
>ncl-talk mailing list
>List instructions, subscriber options, unsubscribe:
>http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jul 6 05:13:06 2012

This archive was generated by hypermail 2.1.8 : Mon Jul 09 2012 - 10:45:32 MDT