Re: Paneling attached plots

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 30 2013 - 08:37:47 MDT

Hi Kyle,

I did notice the problem with the incorrect call to gsn_panel, but I saw another problem as well, which is something we need to fix.

When you run your script, do you get multiple errors of the form:

warning:TransformPostDraw: tfPolyDrawList element 0 is invalid

?

Whenever you see these, this might mean that some plot elements are not getting drawn, like attached lines or markers. It's important to resolve these.

I couldn't see that these errors were causing an issue with your program, but I think this is because you are drawing the plots right after they are created. If you were storing them to a variable and drawing them later, the exta elements might be gone.

Just in case, to fix this, add the following lines:

;
; This is a kludge to make sure that plot objects attached to xyplot2
; are attached to xyplot1, so they get returned with this function.
;
  atts = getvaratts(xyplot2)
  do i=0,dimsizes(atts)-1
    xyplot1@$atts(i)$ = xyplot2@$atts(i)$
  end do

right before this line:

  overlay(xyplot1,xyplot2)

I will fix the gsn_csm_x2y code so that you don't need to do this.

--Mary

On Oct 29, 2013, at 12:26 PM, Kyle Griffin <ksgriffin2@wisc.edu> wrote:

> Hi everyone,
>
> After looking over a couple more code examples provided by Mike Ventrice, I was able to figure out that it was a relatively simple mistake.
>
> In my code, I made panel plots using the plot IDs returned by gsn_attach_plots, not the actual base contour plot I was attaching to. Once I changed my call to gsn_panel to use the original base plot that I was attaching things to, the code works just fine. For the record, this is exactly how Mary's example showed it, but I apparently neglected to notice this!
>
> Thanks again for everyone's assistance with this!
>
>
> Kyle
>
> ----------------------------------------
> Kyle S. Griffin
> Department of Atmospheric and Oceanic Sciences
> University of Wisconsin - Madison
> Room 1421
> 1225 W Dayton St, Madison, WI 53706
> Email: ksgriffin2@wisc.edu
>
>
> On Mon, Oct 28, 2013 at 11:55 PM, Kyle Griffin <ksgriffin2@wisc.edu> wrote:
> Hi Mary and all,
>
> Although I didn't have any custom function calls in my original code, I decided to do some up similar to what you and Carl have both mentioned now. However, that does not resolve the problem in the slightest and the errors I'm receiving are the same as before. Interestingly, I've also removed any use of arrays from my code as well, thinking that may have been causing problems, but to no avail.
>
> I've prepared two scripts and the provided the relevant data files at http://marrella.meteor.wisc.edu/~ksgriffin2/npac/temp/
> You'll see two nc files and two different ncl scripts. The share_panel_hov.ncl script is my original, where each plot is first plotted, saved at the appropriate panel of an arrary, overlay the two x2y plots, and attach to a hovmoller within a loop that loops over each panel. This script plots as desired if gsn_attach_plots is taken out and the number of panels in the panel plot is doubled to allow the unattached plots to be plotted as shown in the one image that is in the folder.
>
> The share_fxn_panel_hov.ncl script is an attempt to modify my original script with exterior functions as you have done in the attach+panel example. It also eliminates the loop over panels and instead tries to create a single-panel image, although this results in an identical error to the previous script.
>
> You'll also notice that this is within a larger loop where these paneled plots are being made for each season, but the workspace is created from scratch and deleted within the loop each time and I'mpretty sure this is outside the time frame when the plot IDs would need to be preserved. As I understand, the plot IDs in each member of the array (or, in the second script, the distinct 1-D variable) is sufficient storage of the plot IDs.
>
> The output I'm getting with both scripts, run exactly as they are within the folder linked above, is (output from first script shown):
> -----
> (0) 0000 UTC 1 Dec 1980
> (0) 0000 UTC 31 Dec 1980
> (0) 0000 UTC 30 Jan 1981
> fatal:Invalid plot ID=189 passed to NhlGetBB
> warning:pmOverlaySequenceIds isn't a resource in this object
> warning:NhlGetValues:Error retrieving pmOverlaySequenceIds
> fatal:["Execute.c":8470]:Execute: Error occurred at or near line 1726 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl
>
> fatal:["Execute.c":8470]:Execute: Error occurred at or near line 6424 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl
>
> fatal:["Execute.c":8470]:Execute: Error occurred at or near line 7123 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl
>
> fatal:["Execute.c":8470]:Execute: Error occurred at or near line 171 in file share_panel_hov.ncl
>
> ----
>
> Since this is identical for both scripts, my remaining thought was that the x2y plot might have issues being identified as the appropriate plot class after being overlain, but a quick test also shows this persists in trying to attach a simple xy plot without any overlay.
>
> I'm hoping that I've just made a simple error in the plotting somewhere along the way, but I've failed to identify where my code differs from the code in the new panel_10.ncl example and what Carl suggested as well. Any other thoughts? Thanks so much...
>
>
> Kyle
>
>
> ----------------------------------------
> Kyle S. Griffin
> Department of Atmospheric and Oceanic Sciences
> University of Wisconsin - Madison
> Room 1421
> 1225 W Dayton St, Madison, WI 53706
> Email: ksgriffin2@wisc.edu
>
>
> On Mon, Oct 28, 2013 at 1:53 PM, Mary Haley <haley@ucar.edu> wrote:
> Hi folks,
>
> I think to get the "plot_with_attach" function to work, you just need to make sure that the return attribute name is unique.
>
> So, instead of:
>
> > base@attached = gsn_attach_plots( base, side, False, False)
>
> use:
>
> str = unique_string("attached")
> base@$str$ = gsn_attach_plots( base, side, False, False)
>
>
> "str" will be "attached1" the first time, "attached2" the second time, etc.
>
>
> I created a version of panel_10.ncl that panels the attached plots. See "panel_attached_10.ncl" at:
>
> http://www.ncl.ucar.edu/Applications/panel.shtml#ex10
>
> --Mary
>
> On Oct 25, 2013, at 6:56 AM, Carl Schreck <cjschrec@ncsu.edu> wrote:
>
> > Hi Kyle,
> >
> > I've had some success attaching and paneling, so should be possible (see attached, no pun intended ;-). The one trick I found was that you have to be careful if you're using you're own functions to make the plots.
> >
> > So for example, this pseudocode works for overlaying:
> > --
> > function plot_with_overlay
> > begin
> > draw base plot
> > draw top plot
> > overlay( base, top )
> > return(base)
> > end
> >
> > begin ; main
> > plotA = plot_with_overlay
> > plotB = plot_with_overlay
> >
> > gsn_panel( wks, (/ plotA, plotB /), (/ 2, 1 /), False )
> > end ; main
> > --
> >
> > But this similar pseudocode would not work:
> > --
> > function plot_with_attach
> > begin
> > draw base plot
> > draw side plot
> > base@attached = gsn_attach_plots( base, side, False, False)
> > return(base)
> > end
> >
> > begin ; main
> > plotA = plot_with_attach
> > plotB = plot_with_attach
> >
> > gsn_panel( wks, (/ plotA, plotB /), (/ 2, 1 /), False )
> > end ; main
> > --
> > You have to figure out a way for plot_with_attach to return both the base plot and the side plot.
> >
> > Hopefully this is helpful, and not just more confusing :-)
> >
> > Carl
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Oct 24, 2013 at 4:12 PM, Kyle Griffin <ksgriffin2@wisc.edu> wrote:
> > Hi all,
> >
> > I've been working on what I thought would be a relatively simple task, but it appears I've run into some complications. My goal was to attach an XY plot with 3 different variables plotted to the right side of a gsn_csm_contour plot. I've done this before and it works great, much akin to the sample code #10 under paneling (see http://www.ncl.ucar.edu/Applications/Scripts/panel_10.ncl). However, my issues begin when I try to create a 3-panel figure of these attached plots. While the attaching process works fine, I get the error (included below) at the gsn_csm_panel call. The paneling works just fine if I double the number of panels and plot the XY plot and the contour plots separately in their own panels (see link below).
> >
> > Is there an internal limitation that prevents the paneling of multiple attached plots, or have I done something wrong along the way? I can provide the moderately simple script and FTP the necessary data files if that might be useful to someone's cause here. Any advice would be appreciated here.
> >
> > Thanks!
> >
> >
> > Kyle Griffin
> >
> >
> >
> > Image with each in separated panels, no attach attempted:
> > http://marrella.meteor.wisc.edu/~ksgriffin2/npac/temp/metric_0.png
> >
> >
> > Error code: (note - the last call to line 199 is simply the call to gsn_csm_panel).
> > fatal:Invalid plot ID=189 passed to NhlGetBB
> > warning:pmOverlaySequenceIds isn't a resource in this object
> > warning:NhlGetValues:Error retrieving pmOverlaySequenceIds
> > fatal:["Execute.c":8470]:Execute: Error occurred at or near line 1726 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl
> >
> > fatal:["Execute.c":8470]:Execute: Error occurred at or near line 6424 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl
> >
> > fatal:["Execute.c":8470]:Execute: Error occurred at or near line 7123 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl
> >
> > fatal:["Execute.c":8470]:Execute: Error occurred at or near line 199 in file panel_hov_interact.ncl
> >
> > ----------------------------------------
> > Kyle S. Griffin
> > Department of Atmospheric and Oceanic Sciences
> > University of Wisconsin - Madison
> > Room 1421
> > 1225 W Dayton St, Madison, WI 53706
> > Email: ksgriffin2@wisc.edu
> >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> >
> >
> >
> > --
> >
> >
> > Follow CICS-NC on Facebook
> > Carl J. Schreck III, PhD
> > Research Associate
> > Cooperative Institute for Climate and Satellites NC
> > North Carolina State University
> > NOAA's National Climatic Data Center
> > 151 Patton Ave, Asheville, NC 28801
> > e: cjschrec@ncsu.edu
> > o: +1 828 257 3140
> > CycloneCenter.org: Help analyze tropical cyclones
> > monitor.cicsnc.org/mjo: See recent MJO diagnostics
> > <annual_ace.png>_______________________________________________
> > 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 Wed Oct 30 08:37:51 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 01 2013 - 08:58:14 MDT