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

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Nov 04 2013 - 09:38:49 MST

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
Received on Mon Nov 4 09:39:00 2013

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