Stream function Problem with Pressure Levels

From: Helen Parish <hparish_at_nyahnyahspammersnyahnyah>
Date: Fri, 21 Nov 2008 06:31:21 -0800

I am trying to plot the stream function for my dataset, but my pressure
levels are not standard Earth based pressure levels. As a result I am
getting the following error when I try to run my code. I suspect that
the pressure levels must need to be adjusted in another routine, but I
am not sure how and where to do this.

This is the error I am getting:

Number Of Attributes: 4
   units : m/s
   long_name : Meridional wind
   cell_method : time: mean
   _FillValue : -9999
fatal:zonal_mpsi: The pressure array must be between the values of 500
and 100500 (exclusive), and monotoni
cally increasing
fatal:Execute: Error occurred at or near line 5117 in file
$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed
.ncl

fatal:Execute: Error occurred at or near line 66 in file zonstream.ncl

The code which generated this error (zonstream.ncl) is included below:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
                                        ; input file
   diri = "./"
   fili = "surf1925i.cam2.h0.0036-07-16-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.,
20000., 10000., 5000., 3000., 1500.,
750., 390., 200., 100., 50.,25., 20., 15.,10., 8., 5.,3.,1. /)
;lev_p = (/ 91500., 90000., 87500., 80000., 67500., 50000., 30000.,
20000., 10000., 5000., 3000., 1500.,
750., 390., 200., 100., 50.,25., 14., 7., 3.5, 1.9, 0.95, 0.4, 0.1,
0.01 /)
lev_p = (/ 91500., 90000., 87500., 80000., 67500., 50000., 30000.,
20000., 10000., 5000., 3000., 1500., 7
50., 390., 200., 100., 50.,25., 14., 7., 3.5, 1.9, 0.95, 0.4, 0.1, 0.03
/)
;lev_p = (/ 91500., 90000., 87500., 80000., 67500., 50000., 30000.,
20000., 10000., 5000., 3000., 1500.,
750., 390., 200., 100., 50.,25., 14., 7., 3.5, 2.0 /)
   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)
   v = f->V
   lat = f->lat
   printVarSummary( v )

   dimu = dimsizes( v )
   ntim = dimu(0)
   klvl = dimu(1)
   nlon = dimu(2)
   mlon = dimu(3)

; meridstream = zonal_mpsi_Wrap(v,lat,lev_p,PS)
  meridstream = zonal_mpsi_Wrap(v(:,::-1,:,:),lat,lev_p(::-1),PS)

;***********************
; Create Plot
;***********************
   wks = gsn_open_wks ("pdf", "surf1925i360716stream" ) ;
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 = "surf1925i360716stream"
; plot = gsn_csm_pres_hgt(wks, u(nt,:,:,40), res ) ; (lev,lat)
       plot = gsn_csm_pres_hgt(wks, meridstream(nt,:,:), res ) ;
(lev,lat)
; plot = gsn_csm_pres_hgt_streamline(wks, uavg(nt,:,:), res ) ;
(lev,lat)
; plot = gsn_csm_contour (wks, uavg(t,:,:), 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

Thanks,
Helen.

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Nov 21 2008 - 07:31:21 MST

This archive was generated by hypermail 2.2.0 : Tue Nov 25 2008 - 10:18:44 MST