Re: Problem with overlay plots

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Wed, 22 Feb 2006 17:44:53 -0700

Hi Will,

This is a shot in the dark, but try setting the resource cnInfoLabelOn =
False for both plots, and see if that realigns them. If that doesn't
work let us know...
Adam

Will Hobbs wrote:
> Hi
>
> The script below reads in monthly mean SST and zonal wave1 amplitude
> data, and then creates and animated contour overlay SH stereographic. The
> script works fine if I set the resource for the SST cnLevelSelectionMode
> to "AutomaticLevels", but if use ManualLevels (or ExplicitLevels, for
> that matter) the zw1 contours (plot map2) is offset from the map plot.
> Any ideas?
>
> Many thanks,
>
> Will
>
>
> ;=====================================================================;
> 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"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> ;======================================================================
> ;Plot animation of SH monthly mean zw
>
> begin
>
>
> ;*******USER PARAMETERS***********************
>
> plev = 500 ; select required pressure level
>
> wave = 1 ; select required wavenumber
>
> ;***************************************8
> ;Read in data
> ;**************************************
>
> FIL1 = "zw_amplitudes_1960_2004.nc"
> diri1 = "data/"
>
> f1 = addfile(diri1+FIL1, "r")
>
> amp = f1->amplitude({wave},:,{plev},:,:)
>
> ; harmonic = f1->harmonic
> time1 = f1->time
>
> ;amp dimensions are (harmonic|,time|,level|,lat|, lon|)
>
> ;read in SST data
>
> diri2 = "/u/whobbs/ncep/"
>
> ; FIL2 = "coads_sst_SH_1960_2004.nc"
> ; datsrc = "COARDS"
>
> FIL2 = "noaa_sst_SH_1960_2002.nc"
> datsrc = "NOAA"
>
> f2 = addfile(diri2+FIL2, "r")
>
> sst = f2->sst
>
> time2 = f2->time
>
> ;(sst dims are (time, lat, lon)
>
> dimsst = dimsizes(sst)
> dimamp = dimsizes(amp)
>
> ;ensure times are coincident
>
> if (dimsst(0).gt.dimamp(0)) then
> nmos = dimamp(0)
> else
> nmos = dimsst(0)
> end if
>
> delete(dimsst)
> delete(dimamp)
>
> ;******************************************************
> ; create plots
> ;************************************************
>
> wks = gsn_open_wks("ncgm" ,"plots/zw"+wave+"_z"+plev+"_"+datsrc+"SST")
>
> gsn_define_colormap (wks, "BlueRedGray")
>
> mpres = True ;map resources
> mpres@gsnDraw = False
> mpres@gsnFrame = False
> mpres@gsnMaximize = True
> mpres@gsnPolar = "SH"
>
> mpres@mpMaxLatF = -20
> mpres@mpGridMaxLatF = -45
> mpres@mpGridLatSpacingF = 30.
> mpres@mpGridLonSpacingF = 45.
>
> mpres@gsnLeftString = plev+"hPa (gpm)"
> mpres@gsnCenterString = datsrc
> mpres@gsnRightString = "SST - degC"
>
> res = True ;sst contour resources
> res@gsnDraw = False
> res@gsnFrame = False
>
>
> res@cnLinesOn = False
> res@cnFillOn = True
> res@gsnSpreadColors = True
> res@gsnSpreadColorEnd = -2
> res@cnLevelSelectionMode = "ManualLevels"
> res@cnMaxLevelValF = 25
> res@cnMinLevelValF = -25.
> res@cnLevelSpacingF = 2
>
> res@gsnLeftString = ""
> res@gsnCenterString = ""
> res@gsnRightString = ""
> res@lbLabelBarOn = True
>
> resi = True ; zw1 contour resources
> resi_at_gsnDraw = False
> resi_at_gsnFrame = False
> resi_at_cnLinesOn = True
> resi_at_cnFillOn = False
>
> resi_at_cnLevelSelectionMode = "ManualLevels"
> resi_at_cnMaxLevelValF = 160.
> resi_at_cnMinLevelValF = -160.
> resi_at_cnLevelSpacingF = 20
> resi_at_gsnContourNegLineDashPattern = 2
> resi_at_lbLabelBarOn = False
> resi_at_cnLineLabelsOn = True
>
>
> setvalues wks
> "wkForegroundColor" : (/"Black"/)
> "wkBackgroundColor" : (/"White"/)
> end setvalues
>
>
> print("beginning plots")
>
> ;create month/year array for display
>
> yr = ispan(1960, 1959+(nmos/12), 1)
>
> mon =
> (/"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"/)
>
> date = new((/nmos/), string)
>
> dd = 0
>
> do yy = 0, dimsizes(yr)-1 ; concatenate month and years
> do mm = 0,11
> date(dd) = mon(mm)+" "+yr(yy)
> dd = dd+1
> end do
> end do
>
> delete(yr)
> delete(mon)
> delete(dd)
>
> nmo = 0
>
> mpres@tiMainString = date(nmo)+" monthly mean zonal wave "+wave+":C:
> amplitude and SST"
>
> map1 = gsn_csm_contour(wks, sst(0,:,:), res)
> map2 = gsn_csm_contour(wks, amp(0,:,:), resi)
>
> mapid = gsn_csm_map_polar(wks, mpres)
>
> overlay(mapid, map1)
> overlay(mapid, map2)
>
> draw(mapid)
> frame(wks)
>
> do nmo = 1, nmos-1
> monyr = date(nmo)
>
> setvalues mapid
> "tiMainString" : monyr+" monthly mean zonal wave "+wave+":C:
> amplitude and SST"
> end setvalues
>
> setvalues map1_at_data
> "sfDataArray" : sst(nmo,:,:)
> end setvalues
>
> setvalues map2_at_data
> "sfDataArray" : amp(nmo,:,:)
> end setvalues
>
> draw(mapid)
> frame(wks)
>
> end do
>
> delete(mapid)
> delete(map1)
> delete(map2)
> delete(amp)
> delete(sst)
>
>
> end
>
> ============================
> Room 3221C
> UCLA Department of Geography
> 1255 Bunche Hall
> Los Angeles CA 90095-1524
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> 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
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Feb 22 2006 - 17:44:53 MST

This archive was generated by hypermail 2.2.0 : Thu Feb 23 2006 - 09:24:06 MST