[ncl-talk] multi-panel wkSpaceTime
Mary Haley
haley at ucar.edu
Sun Jan 29 09:56:22 MST 2017
To add this this, you may need to make sure that anything that's attached
to a plot via a gsn_add_text or gsn_add_polyline call continues to "live"
outside the script that it was called from. This means that the unique id
returned from each of these calls must be attached as an attribute to the
plot.
For example, in the procedure "addHorVertLines", you have this code:
begin
gsres = True
gsres at gsLineDashPattern = 1
gsn_polyline(wks, plot, x1,y1,gsres)
gsn_polyline(wks, plot, x1,y2,gsres)
gsn_polyline(wks, plot, x1,y3,gsres)
gsn_polyline(wks, plot, x2,y4,gsres)
txres = True
txres at txJust = "CenterLeft"
txres at txFontHeightF = 0.013
gsn_text(wks, plot, "3 days" ,-14.7,.345,txres)
gsn_text(wks, plot, "6 days" ,-14.7,.175,txres)
gsn_text(wks, plot, "30 days",-14.7,.045,txres)
end
which needs to have all the gsn_polyline and gsn_text calls changed to
gsn_add_polyline and gsn_add_text, but they also need to be returned from
this procedure. You can use "unique_string" to generate a unique id each
time:
begin
gsres = True
gsres at gsLineDashPattern = 1
plot@$unique_string("poly")$ = gsn_add_polyline(wks, plot, x1,y1,gsres)
plot@$unique_string("poly")$ = gsn_add_polyline(wks, plot, x1,y2,gsres)
plot@$unique_string("poly")$ = gsn_add_polyline(wks, plot, x1,y3,gsres)
plot@$unique_string("poly")$ = gsn_add_polyline(wks, plot, x2,y4,gsres)
txres = True
txres at txJust = "CenterLeft"
txres at txFontHeightF = 0.013
plot@$unique_string("text")$ = gsn_add_text(wks, plot, "3 days"
,-14.7,.345,txres)
plot@$unique_string("text")$ = gsn_add_text(wks, plot, "6 days"
,-14.7,.175,txres)
plot@$unique_string("text")$ = gsn_add_text(wks, plot, "30
days",-14.7,.045,txres)
end
You can also do it like this, for slightly cleaner code, but it does
require that you create some arrays ahead of time with "new" to hold all
the text and polylines being added:
;---Create arrays to hold polylines and text
polyid = new(4,graphic)
textid = new(3,graphic)
polyid(0) = gsn_add_polyline(wks, plot, x1,y1,gsres)
polyid(1) = gsn_add_polyline(wks, plot, x1,y2,gsres)
polyid(2) = gsn_add_polyline(wks, plot, x1,y3,gsres)
polyid(3) = gsn_add_polyline(wks, plot, x2,y4,gsres)
txres = True
txres at txJust = "CenterLeft"
txres at txFontHeightF = 0.013
textid(0) = gsn_add_text(wks, plot, "3 days" ,-14.7,.345,txres)
textid(1) = gsn_add_text(wks, plot, "6 days" ,-14.7,.175,txres)
textid(2) = gsn_add_text(wks, plot, "30 days",-14.7,.045,txres)
;---Make sure polyid and textid continue to "live" outside this procedure
plot at unique_string("poly") = polyid
plot at unique_string("text") = textid
See the attached diagnostics_cam_panel.ncl. This is UNTESTED, but hopefully
it gives you an idea where to start.
--Mary
On Sat, Jan 28, 2017 at 8:54 AM, Dennis Shea <shea at ucar.edu> wrote:
> When I wrote the functions, my focus was on doing the computations and
> graphics correctly. Paneling the graphics was not a priority. To be honest,
> I did not even think about paneling. :-(
>
> It would be possible to restructure ('refactor') the code. However, it
> would require some time and .effort.
> [1] copy the code:
> cp $NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl
> diagnostics_cam.panel.ncl
>
> [2] Change the local code: add 'res at gsnDraw=False' in multiple places;
> change 'polyline' procedure calls to the 'gsn_add_polyline' functions, etc
>
> ---
>
> Perhaps, using Imagemagick's 'convert' tool.
>
> %> convert <return>
>
> See the -append /+append options
>
> I have not used the 'append' option very often. 'convert' has other
> options that may also be of use. See:
>
> http://www.imagemagick.org/Usage/layers/
>
> This link has numerous examples.
>
> ------
>
> Consider image1.png, image2.png, image3.png, image4.png
>
> %> convert -append image1.png image2.png IMAGE_12.TopBottom.png
> %> display IMAGE_12.TopBottom.png
>
> %> convert -append image3.png image4.png IMAGE_34.TopBottom.png
> %> display IMAGE_34.TopBottom.png
>
> %> convert +append IMAGE_12.TopBottom.png IMAGE_34.TopBottom.png
> IMAGE_2x2.png
> %> display IMAGE_2x2.png
>
> ---
> This type of thing could be invoked within an NCL script to save manually
> doing it. How?
> After the 'image[1-4].png' have been created .... EG
>
> wkSpaceTime (u, diro, case, VAR, ,latBound, spd , nDayWin, nDaySkip, opt ) ; create images
>
> system("convert -append image1.png image2.png
> IMAGE_12.TopBottom.png")
> system("convert -append image3.png image4.png
> IMAGE_34.TopBottom.png")
> system("convert +append IMAGE_12.TopBottom.png IMAGE_34.TopBottom.png
> IMAGE_2x2.png")
> system("rm IMAGE*TopBottom.png")
>
> ---
> Two on top; one at bottom
>
> %> convert +append image1.png image2.png IMAGE_12.LeftRight.png
> %> display IMAGE_12.LeftRight.png
>
> %> convert -append IMAGE_12.LeftRight.png image3.png IMAGE_123.png
> %> display IMAGE_123.png
>
> I am sure you can 'center' the bottom figure but I'll leave that up to
> you. :-)
>
> ----
> From the above link: 10 figures
>
> convert \( font_1.gif font_2.gif font_3.gif +append \) \
> \( font_4.gif font_5.gif font_6.gif +append \) \
> \( font_7.gif font_8.gif font_9.gif +append \) \
> \( -size 32x32 xc:none font_0.gif +append \) \
> -background none -append append_array.gif
>
>
>
> I hope it works for you.
>
> Good luck
> D
>
>
>
>
> On Fri, Jan 27, 2017 at 5:45 PM, Millie J <millie.jyo at gmail.com> wrote:
>
>> Hi,
>>
>> Is there a way to plot the Wheeler-Kiladis space-time spectra (Figs. 1 to
>> 3), for multiple model outputs, on a single graphic plot? Thanks.
>> Jyothi
>>
>>
>> Jyothi Nattala
>> GMAO / NASA GSFC
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170129/490f5c7b/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diagnositcs_cam_panel.ncl
Type: application/octet-stream
Size: 139677 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170129/490f5c7b/attachment.obj
More information about the ncl-talk
mailing list