attaching xy to ce plot with irregular grid

From: mark collier <mark.collier_at_nyahnyahspammersnyahnyah>
Date: Sat Mar 17 2012 - 03:58:55 MDT

Hi,
I'm trying to attach an xy plot to a lat/lon plot. The lat/lon plot required 2D latitudes and longitudes to be supplied for the call to gsn_csm_contour_map_ce to work, as shown in the script. The following example works if the grid is regular (e.g. spherical) but not when irregular.
Is there some way to still attach the xy plot in this case? I'm wondering if the attaching is failing because the right edge of the lat/lon plot may not match up with the xy plot (lat_A1p0 vector)?

I have downloaded the file thetaozavg_Omon_ACCESS1-0_piControl_r1i1p1_0390-0439_ANN_LM.nc to the incoming area. The script is pasted below. The script works (minus the attachment) if you delete the lines:

  xyp=gsn_csm_xy(wks,dim_avg(A1p0),lat_A1p0,xyres)
  attachid3=gsn_attach_plots(plot,xyp,attachres1,attachres2)

Regards,
Mark.
load "/home/599/mac599/marsland/all_scripts.ncl"

begin

ifile="thetaozavg_Omon_ACCESS1-0_piControl_r1i1p1_0390-0439_ANN_LM.nc"

fh=addfile(ifile,"r")

A1p0=fh->thetaozavg

A1p0!0="lat"
A1p0!1="lon"
A1p0&lat=fh->j
A1p0&lon=fh->i
A1p0@lat2d=fh->lat
A1p0@lon2d=fh->lon

outp="test"

wks = gsn_open_wks("ps",outp)

xyres = True ; xy plot mods desired
xyres@vpWidthF = .20 ; set width of second plot
xyres@tmXBLabelStride = 2 ; label stride
xyres@gsnDraw = False ; don't draw yet
xyres@gsnFrame = False ; don't advance frame yet
xyres@gsnCenterString = "Average" ; add title
xyres@txFontHeightF = .025 ; change font height

attachres1 = True
attachres1@gsnAttachPlotXAxis=True
attachres2 = True

res = True
res@gsnDraw = False ; don't draw
res@gsnFrame = False ; don't advance frame
res@cnFillOn = True ; turn on color
res@cnLinesOn = False
res@gsnSpreadColors = True ; spread out color table
res@cnLineLabelDensityF = 0.0 ; <1.0 = less, >1.0 = more
res@cnLineLabelsOn = False
res@cnFillMode = "AreaFill"
res@mpCenterLonF = 180.
res@mpMinLonF = 0.
res@mpMaxLonF = 360.
res@mpMinLatF = -90.0
res@mpMaxLatF = 90.0
res@mpFillOn = False ; turn off modern continents

res@gsnAddCyclic = False
res@gsnRightString = ""
res@cnLevelSelectionMode = "ExplicitLevels"

lat2D_A1p0=fh->lat
lat_A1p0=lat2D_A1p0(:,0)
lat_A1p0(245:299)=lat2D_A1p0(245:299,89);89/90 maximum latitude (base 0)

  plot = gsn_csm_contour_map_ce(wks,A1p0,res)
  xyp=gsn_csm_xy(wks,dim_avg(A1p0),lat_A1p0,xyres)
  attachid3=gsn_attach_plots(plot,xyp,attachres1,attachres2)

resP=True

gsn_panel(wks,(/plot/),(/1,1/),resP) ; now draw as one plot

print("Finished "+outp+".")

end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sat Mar 17 03:59:08 2012

This archive was generated by hypermail 2.1.8 : Tue Mar 20 2012 - 15:27:15 MDT