Hi Helen,
I think I see your problem:
utimeavg = dim_avg_Wrap(utime_reorder) ; (lev,lat)
vtimeavg = dim_avg_Wrap(vtime_reorder) ; (lev,lat)
uvproduct = new ( (/klvl,nlat/) , double)
uvproduct!0 = "lev"
uvproduct!1 = "lat"
uvproduct = utimeavg * vtimeavg ; (lev,lat)
I bet if you do a printVarSummary(uvproduct) after the lines above you
will see that uvproduct does not have any coordinate variable
information associated with it. This is because you haven't assigned any
coordinate variable information to uvproduct. According to the
documentation, gsn_csm_pres_hgt requires that "The leftmost dimension
(of the input data array) must contain a one-dimensional coordinate
array of pressure values, and the values must be in the correct units."
http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_csm_pres_hgt.shtml
Switch this:
uvproduct = new ( (/klvl,nlat/) , double)
uvproduct!0 = "lev"
uvproduct!1 = "lat"
uvproduct = utimeavg * vtimeavg ; (lev,lat)
to this
uvproduct = utimeavg ; copy utimeavg coordinate variables to uvproduct
uvproduct = (/ utimeavg * vtimeavg /) ; (/ /) means only pass data
from right hand side to left hand side, no metadata
printVarSummary(uvproduct)
Adam
Helen Parish wrote:
> I am trying to do some averaging on variables, and want to store the
> results into another variable and plot the results. I cannot find a
> way to do this without getting an error from gsn_csm_pres_hgt, which
> does not accept the variables the way I have defined them. I have
> tried many different ways of getting around this, some of which
> appeared to work in other scripts, but which for some reason do not
> work here.
>
> The error I am currently getting is as follows :
>
> (0) gsn_csm_pres_hgt: Fatal: The first dimension of the input
> data must
> (0) have a coordinate variable called 'lev.'
> (0) Cannot create plot.
> fatal:Illegal right-hand side type for assignment
> fatal:Execute: Error occurred at or near line 74
>
> Does anyone have any ideas as to what I need to do to get my script
> to work ?. I enclose my current script below.
>
> Thanks,
> Helen.
>
> ;***********************
> ; first.ncl
> ;***********************
> 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/csm/contributed.ncl"
>
> begin
>
> ; Keep all files open when have a lot of files :
> setfileoption("nc","SuppressClose",False)
>
> diri = "./"
> fili = systemfunc("cd "+diri+" ; ls azeusrand09125*.cam2.h0*nc")
>
> f = addfiles (fili,"r")
> U = addfiles_GetVar(f,fili,"U")
> V = addfiles_GetVar(f,fili,"V")
> printVarSummary( U )
> printVarSummary( V )
>
> dimu = dimsizes( U ) ; (time,lev,lat,lon)
> ntim = dimu(0)
> klvl = dimu(1)
> nlat = dimu(2)
> mlon = dimu(3)
>
> dimv = dimsizes( V ) ; (time,lev,lat,lon)
> ntimv = dimv(0)
> klvlv = dimv(1)
> nlatv = dimv(2)
> mlonv = dimv(3)
>
> ureorder = U(lev | :, lat | :, lon | :, time | :) ;
> (lev,lat,lon,time)
> vreorder = V(lev | :, lat | :, lon | :, time | :) ;
> (lev,lat,lon,time)
>
> utime = dim_avg_Wrap(ureorder) ; (lev,lat,lon)
> vtime = dim_avg_Wrap(vreorder) ; (lev,lat,lon)
>
> utime_reorder = utime(lev | :, lat | :, lon | :) ; (lev,lat,lon)
> vtime_reorder = vtime(lev | :, lat | :, lon | :) ; (lev,lat,lon)
>
> utimeavg = dim_avg_Wrap(utime_reorder) ; (lev,lat)
> vtimeavg = dim_avg_Wrap(vtime_reorder) ; (lev,lat)
>
> uvproduct = new ( (/klvl,nlat/) , double)
> uvproduct!0 = "lev"
> uvproduct!1 = "lat"
> ; uvproduct&lev = utimeavg_at_lev
> ; uvproduct&lat = utimeavg&lat
>
> uvproduct = utimeavg * vtimeavg ; (lev,lat)
>
> ;***********************
> ; Create Plot
> ;***********************
> wks = gsn_open_wks ("pdf", "angmom1" ) ; open workstation
> gsn_define_colormap(wks,"rainbow") ; choose colormap
>
> res = True
> res_at_cnFillOn = True
> res_at_lbLabelAutoStride = True
> res_at_gsnMaximize = True ; if [ps, eps, pdf] make large
> res_at_gsnSpreadColors = True ; span color map
>
> res_at_gsnLeftString = ""
> res_at_gsnCenterString = "First angular momentume term, year 164"
> res_at_gsnRightString = ""
>
> res_at_tiXAxisString = "Latitude (degrees)"
> res_at_tiYAxisString = "Pressure (mb)"
>
> plot = gsn_csm_pres_hgt(wks, uvproduct(lev | :,lat | :),
> res ) ; (lev,lat)
>
> res_at_trYReverse = True
>
> end
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-- -------------------------------------------------------------- Adam Phillips asphilli_at_ucar.edu National Center for Atmospheric Research tel: (303) 497-1726 ESSL/CGD/CAS 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-talkReceived on Wed Sep 02 2009 - 09:47:31 MDT
This archive was generated by hypermail 2.2.0 : Thu Sep 03 2009 - 07:55:08 MDT