Re: [ncl-talk] Pressure Range Problem

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed, 4 Jun 2008 10:57:13 -0600 (MDT)

Helen,

It is only the gsn_csm_pres_hgt routine that is failing because of
the pressure value checks.

If, instead, you use gsn_csm_contour to do your plotting, then it
doesn't care what range your pressure values are in. It's just a
generic contouring routine and doesn't do any checking of
values. However, gsn_csm_contour will not include the height values on
the right Y axis; that extra capability is what gsn_csm_pres_hgt does
for you.

In your code below, you are calling gsn_csm_pres_hgt and then
gsn_csm_contour two times. I'm not sure sure what you are trying to
accomplish here, but I think all you need to do is comment out the
gsn_csm_pres_hgt call, and you should still get the plots from the
gsn_csm_contour calls.

--Mary

On Tue, 3 Jun 2008, Helen Parish wrote:

> I dont have the height levels as well as the pressures, so rewriting the
> pressure levels and height levels in gsn_csm.ncl would not work. It does not
> help that gsn_csm_contour is used within the routine, because the routine as
> it is currently written fails, as the pressure levels are not within the
> standard limits, so I am not clear what to do.
>
> Do I need to get rid of the
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> and load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> statements, since these contain the routine that checks that pressure values
> are within standard limits ?. However, since there are many routines within
> these ncl scripts, I am not sure which ones I am using and may need if I was
> to simply eliminate these statements ?.
>
> The routine which fails, as it is currently written, is included below.
>
> Thanks,
> Helen.
>
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>> begin
>>> ; input file
>>> diri = "./"
>>> fili = "rayleigh4a.cam2.h0.0009-01-04-00000.nc"
>>> fi = addfile (diri+fili, "r")
>>> ; output file
>>> diro = "./"
>>> filo = "helen.nc"
>>> system ("/bin/rm -f "+diro+filo) ; remove any pre-exist file
>>> fo = addfile (diro+filo, "c")
>>> ; add any file attributes
>>> fo_at_title = fi_at_title + ": Selected Variables at pressure levels"
>>> fo_at_history = systemfunc ("date")
>>> fo_at_source = fi_at_source
>>> fo_at_case = fi_at_case
>>> fo_at_Conventions = fi_at_Conventions
>>>
>>> Var = (/ "T" , "Q", "U", "V"/) ; select variable to be
>>> interpolated.
>>> nVar = dimsizes (Var)
>>> ; desired output levels
>>> lev_p = (/ 91500., 90000., 87500., 80000., 67500., 50000., 30000.,
>>> 25000., 18000., 10000., 8500., 7000., 4000., 3750., 3000., 2000., 1750.,
>>> 1200., 600., 200., 100., 30., 10., 4., 1.5, 0.5, 0.03 /)
>>> lev_p!0 = "lev_p" ; variable and dimension name the
>>> same
>>> lev_p&lev_p = lev_p ; create coordinate variable
>>> lev_p_at_long_name = "pressure" ; attach some attributes
>>> lev_p_at_units = "hPa"
>>> lev_p_at_positive = "down"
>>>
>>> hyam = fi->hyam ; read hybrid info
>>> hybm = fi->hybm
>>> PS = fi->PS
>>> P0mb = 0.01*fi->P0
>>>
>>> do n=0,nVar-1 ; loop over the variables
>>> X = fi->$Var(n)$
>>> Xp = vinth2p (X, hyam, hybm, lev_p ,PS, 1, P0mb, 2, True)
>>> copy_VarAtts(X, Xp)
>>> fo->$Var(n)$ = Xp ; write to netCDF file
>>> print (Var(n)+": interpolated and written to netCDF")
>>> end do
>>>
>>> end
>>> ;***********************
>>> ; zonal.ncl
>>> ;***********************
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>> ;***********************
>>> begin
>>> f = addfile ("helen.nc","r")
>>> print(f)
>>> u = f->U
>>> printVarSummary( u )
>>>
>>> dimu = dimsizes( u )
>>> ntim = dimu(0)
>>> klvl = dimu(1)
>>> nlon = dimu(2)
>>> mlon = dimu(3)
>>> ;***********************
>>> ; Create Plot
>>> ;***********************
>>> wks = gsn_open_wks ("x11", "h_lat" ) ; 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
>>>
>>> do nt=0,ntim-1
>>>
>>> res_at_gsnCenterString = "t="+u&time(nt)
>>> plot = gsn_csm_pres_hgt(wks, u(nt,:,:,0), res ) ; (lev,lat)
>>>
>>> res_at_trYReverse = True
>>> plot = gsn_csm_contour (wks, u(nt,:,:,0), res ) ; (lev,lat)
>>> plot = gsn_csm_contour (wks, u(nt,:,0,:), res ) ; (lev,lon)
>>>
>>> kl = 5
>>> res_at_mpFillOn = False
>>> res_at_mpGridAndLimbOn = True
>>> res_at_mpGridLineDashPattern = 2
>>> res_at_mpOutlineBoundarySets = "NoBoundaries"
>>> res_at_mpCenterLonF = 180.
>>> res_at_gsnCenterString = res_at_gsnCenterString+" p="+u&lev_p(kl)
>>> plot = gsn_csm_contour_map_ce (wks, u(nt,kl,:,:), res )
>>>
>>> end do
>>>
>>> end
>>>
>
> _______________________________________________
> 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 Wed Jun 04 2008 - 10:57:13 MDT

This archive was generated by hypermail 2.2.0 : Wed Jun 04 2008 - 15:44:20 MDT