Re: Pressure Range Problem

From: Helen Parish <helen_at_nyahnyahspammersnyahnyah>
Date: Tue, 3 Jun 2008 15:27:28 -0700

Could you please clarify what you mean by "use gsn_csm_contour" if I
dont have the height levels as well as the pressures?. As you note,
gsn_csm_contour is already used within the routine, but the point is
that the routine as it is written below fails because the pressure
levels are not within the standard limits, so we already know this does
not work, and I am not sure what to do.

Perhaps 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 ?. However, there are many routiunes within these ncl
scripts, and I am not sure which ones I may need if I was to simply
eliminate these statements ?.

Additionally,I do not understand how to put a modified piece of code
back, if I edit in my own values ?. Is that what the "load" statements
do?.

It helps if you can write things out very explicitly, as I am
completely new to NCL, and am not really sure how anything works yet.
Note that I did not write the code below, and am only modifying it by
guesswork and trying to find examples, so the more explicit you can be
the better.

Thanks,
Helen.

On Tuesday, June 3, 2008, at 10:41 AM, Mary Haley wrote:

>
> Helen,
>
> This is an NCL question, so it's more appropriately posted to ncl-talk
> (which I've included).
>
> If you have the height values for the pressure values that you want to
> use, then you can copy the file
> $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl to your own
> directory, edit the file, and modify these lines to give them the new
> pressure/height values that you want (for each psa value you add, you
> must include a corresponding zsa value):
>
> zsa = (/ -0.3, \ ; km
> 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, \
> 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, \
> 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, 10.0, \
> 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, \
> 18.0, 19.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, \
> 50.0, 60.0, 70.0, 80.0, 84.8, 87.7, 90.6, \
> 93.3, 96.1, 97.5,100.4,104.9, \
> 110.0,114.2,116.7,119.7/)
>
> psa = (/ 1050., \ ; mb (hPa)
> 1013.25, 954.61, 898.76, 845.59, 795.01, 746.91, 701.21,
> \
> 657.80, 616.60, 577.52, 540.48, 505.39, 472.17, 440.75,
> \
> 411.05, 382.99, 356.51, 331.54, 308.00, 285.84, 264.99,
> \
> 226.99, 193.99, 165.79, 141.70, 121.11, 103.52, 88.497,
> \
> 75.652, 64.674, 55.293, 25.492, 11.970, 5.746, 2.871,
> 1.491,\
> 0.798, 0.220, 0.052, 0.010, 0.00485,0.00294,0.000178, \
> 0.000108, 0.0000656, 0.0000511, 0.0000310, 0.0000146, \
> 0.00000691, 0.00000419, 0.00000327, 0.00000254 /)
>
>
> If you don't have the height values, however, then you can just use
> gsn_csm_contour to plot pressure vs longitude or latitude, which it
> looks like you've already done below.
>
> Once you change this file, you will need to load your own copy, rather
> than the one in $NCARG_ROOT/lib/ncarg/nclscripts/csm.
>
> --Mary
>
>
> On Tue, 3 Jun 2008, Helen Parish wrote:
>
>> I am unable to do a standard plot (of e.g. pressure vs. latitude,
>> pressure vs. longitude) because the software forces a standard range
>> of pressures which you are not allowed to stray outside of. I want to
>> plot results within the pressure range of around 92 bar to 0.00003
>> bar. I may at some point also want to plot as a function of height,
>> although I only have an approximate idea of heights corresponding to
>> a given pressure. I may well want to plot as a function of z/H as
>> well as pressure.
>>
>> What I need is a simple way to modify and customize the preset
>> pressure range. I believe this pressure range is set in
>> "gsn_csm_pres_hgt", which makes use of "gsn_csm.ncl". I am not sure
>> how or if I can modify this pressure range in my code.
>>
>> Below is a copy of the code which does not work as it stands right
>> now. Can anyone tell me how to do this ?.
>>
>> 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
>>
>>
>> _______________________________________________
>> ncarg-talk mailing list
>> ncarg-talk_at_ucar.edu
>> http://mailman.ucar.edu/mailman/listinfo/ncarg-talk
>>
>
Received on Tue Jun 03 2008 - 16:27:28 MDT

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