Re: four-panel (2x2) plots of combining SST contours and wind vectors

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Nov 04 2013 - 22:38:02 MST

Yi-Chih,

Yes, it is possible to have four panels of overlays of contours and wind vectors. This kind of thing is done regularly.

I see now that you have another error in your code. You want the gsn_panel call outside your do loop:

   do nm= 0,nmo-1
     plot1(nm)= gsn_csm_contour_map(wks,dt(nm,:,:),res)
     plot2(nm)= gsn_csm_vector(wks,du(nm,:,:),dv(nm,:,:),wres)
     overlay(plot1(nm),plot2(nm))
   end do

   pres = True
   pres@gsnMaximize = True
   gsn_panel(wks,plot1,(/2,2/),pres)

Note that I added a "pres" resource list so I can increase the size of your panel plots.

----------------

Please see our panel page to better understand how this procedure works:

http://www.ncl.ucar.edu/Applications/panel.shtml

In particular, look at example #13, which is overlaying vectors on color contours and then paneling them.

----------------

You may want to look at other examples on that page to learn more about gsn_panel.

For example, if you want to panel several plots that have the same color bar, then there are things you need to do to make sure all of your plots use the same color bar, by making sure they all have the same contour levels. See example #3 on the above page for an example. I see from your script below that you are *not* setting any contour levels, so NCL is going to generate them for you, and it may generate a different set of levels for every plot, based on the min/max of the data for that plot. This can be misleading if you are using the same color bar for all color contours.

--Mary

On Nov 4, 2013, at 7:45 PM, Yi-Chih Huang <dscpln@gmail.com> wrote:

> Mary,
>
> Thanks much for the commands. The do loop created wind vectors and the overlay of contours and wind vectors. But yet there is no four-panels plot. No further warning or error message showed up. Do you think it is possible to have a four-panels plot of overlay of contours and wind vectors?
>
> Thanks,
>
> Yi-Chih
>
>
> On Tue, Nov 5, 2013 at 1:38 AM, Mary Haley <haley@ucar.edu> wrote:
> Dear Yi-Chih,
>
> Please include ncl-talk@ucar.edu on all follow-up emails, so folks can see the follow-up questions and responses.
>
> We sometimes take the conversation purposely offline, but we will state this explicitly if we do so.
>
> The issue is with trying to call "overlay" directly inside of gsn_panel.
>
> This will not work because "overlay" doesn't return anything. It's a procedure and not a function.
>
> "overlay" simply takes the second plot in the argument list and transforms it into the data space of the first plot (the "base" plot). The "base" plot now contains both plots, and this is the variable you should be passing to gsn_panel:
>
> > do nm= 0,nmo-1
> > plot1(nm)= gsn_csm_contour_map(wks,dt(nm,:,:),res)
> > plot2(nm)= gsn_csm_vector(wks,du(nm,:,:),dv(nm,:,:),wres)
> > overlay(plot1(nm),plot2(nm))
> > gsn_panel(wks,plot1(nm),(/2,2/),False)
> > end do
>
>
> --Mary
>
> On Nov 3, 2013, at 9:36 PM, Yi-Chih Huang <dscpln@gmail.com> wrote:
>
> > Mary,
> >
> > Thanks for pointing out this. My purpose is to have 2x2 panels so I used the following commands. However, an error showed up. What do you think the problem is?
> >
> > Thanks much,
> >
> > Yi-Chih
> >
> > #####
> > do nm= 0,nmo-1
> > plot1(nm)= gsn_csm_contour_map(wks,dt(nm,:,:),res)
> > plot2(nm)= gsn_csm_vector(wks,du(nm,:,:),dv(nm,:,:),wres)
> > gsn_panel(wks,overlay(plot1(nm),plot2(nm)),(/2,2/),False)
> > end do
> >
> > #####
> > yhuang@arc-env:/fs3/yhuang/scripts$ ncl sstWind.ncl
> > Copyright (C) 1995-2013 - All Rights Reserved
> > University Corporation for Atmospheric Research
> > NCAR Command Language Version 6.1.2
> > The use of this software is governed by a License Agreement.
> > See http://www.ncl.ucar.edu/ for more details.
> > fatal:syntax error: line 178 in file sstWind.ncl before or near overlay
> > gsn_panel(wks,overlay
> > ------------------------^
> >
> > fatal:error in statement
> > fatal:Syntax Error in block, block not executed
> > fatal:error at line 185 in file sstWind.ncl
> >
> >
> >
> > On Mon, Nov 4, 2013 at 12:14 PM, Mary Haley <haley@ucar.edu> wrote:
> > Dear Yi-Chih,
> >
> > "overlay" is a procedure, not a function, so it can't be assigned to a variable.
> >
> > Try:
> >
> > overlay(plot1(nm),plot2(nm))
> >
> > You will then want to pass "plot1" to the gsn_panel call.
> >
> > --Mary
> >
> > On Nov 2, 2013, at 11:32 PM, Yi-Chih Huang <dscpln@gmail.com> wrote:
> >
> >> Hello,
> >>
> >> I am trying to make four-panel (2x2) plots of combining SST contours and wind vectors. I already have individual SST contours and wind vectors. However, I got the error message about "overlay" as below. I have read the examples about overlay on NCL web pages. But yet I can't figure out what the error is about. Do you have any idea about this error message?
> >>
> >> Thanks much,
> >>
> >> Yi-Chih
> >>
> >> #####
> >> yhuang@arc-env:/fs3/yhuang/scripts$ ncl sstWind.ncl
> >> Copyright (C) 1995-2013 - All Rights Reserved
> >> University Corporation for Atmospheric Research
> >> NCAR Command Language Version 6.1.2
> >> The use of this software is governed by a License Agreement.
> >> See http://www.ncl.ucar.edu/ for more details.
> >> fatal:syntax error: line 158 in file sstWind.ncl before or near overlay
> >> plot(nm)= overlay
> >> ---------------------^
> >>
> >> fatal:Syntax Error in block, block not executed
> >> fatal:error at line 163 in file sstWind.ncl
> >>
> >> #####
> >> wks= gsn_open_wks("X11","sstWind")
> >> gsn_define_colormap(wks,"BlueRed") ; use the BlueRed colormap (instead of default colormap)
> >> plot1= new(4,graphic)
> >> plot2= new(4,graphic)
> >> plot = new(4,graphic)
> >>
> >> res = True
> >> res@gsnAddCyclic = False
> >> res@mpMinLatF = -30
> >> res@mpMaxLatF = 30
> >> res@mpMinLonF = 30
> >> res@mpMaxLonF = 160
> >> res@cnFillOn = True
> >> res@gsnSpreadColors = True ; use full colormap
> >> res@gsnSpreadColorStart = 10 ; for BlueRed
> >> res@gsnSpreadColorEnd = 250 ; for BlueRed
> >> res@cnSpanFillPalette = True
> >> res@cnLinesOn = False ; turn off the contour lines
> >>
> >> res@lbLabelBarOn = True
> >> res@pmLabelBarWidthF= 0.8
> >> res@lbLabelStride = 4
> >> res@mpFillOn = False
> >> res@mpOutlineBoundarySets = "National" ; turns on country boundaries.
> >> res@cnFillDrawOrder = "Predraw"
> >>
> >> wres= True
> >> wres@vcRefMagnitudeF = 10.0 ; define vector ref mag
> >> wres@vcRefLengthF = 0.045 ; define length of vec ref
> >> wres@vcMinDistanceF = 0.025 ; thin out windbarbs
> >> wres@vcVectorDrawOrder = "Predraw"
> >> wres@gsnLeftString = "JJA: Average Monthly Wind Vectors on 850 hPa"
> >> wres@gsnLeftStringFontHeightF = 0.025
> >> wres@gsnRightStringFontHeightF = 0.025
> >> wres@gsnDraw = False
> >> wres@gsnFrame = False
> >>
> >> do nm= 0,mo-1
> >> plot1(nm)= gsn_csm_contour_map(wks,dt(nm,:,:),res)
> >> plot2(nm)= gsn_csm_vector(wks,du(nm,:,:),dv(nm,:,:),wres)
> >> plot(nm)= overlay(plot1(nm),plot2(nm))
> >> end do
> >>
> >> maximize_output(wks,True)
> >> gsn_panel(wks,plot,(/2,2/),False)
> >> _______________________________________________
> >> ncl-talk mailing list
> >> List instructions, subscriber options, unsubscribe:
> >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> >
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Nov 4 22:38:15 2013

This archive was generated by hypermail 2.1.8 : Mon Nov 11 2013 - 09:45:33 MST