RE: [ncl-talk] arrays of graphics devices

From: Douglas Lowe <Douglas.Lowe_at_nyahnyahspammersnyahnyah>
Date: Fri Jul 06 2012 - 04:28:21 MDT

Hi all,

Ahh - if it's a specific attribute that carries the parent identifier then I guess it's not a surprise that previous workstations will get closed down as that identifier is changed.

I'll give your work around of saving the "app" attribute a try - otherwise I guess we'll stick to using if statements.

Thanks to everyone for all the helpful suggestions.

Cheers,
Doug

________________________________
From: Mary Haley [haley@ucar.edu]
Sent: 06 July 2012 05:06
To: brownrig@ucar.edu
Cc: Douglas Lowe; ncl-talk@ucar.edu
Subject: Re: arrays of graphics devices

Hi All,

The issue is that gsn_open_wks returns an attribute (attached to the variable on the left-side of the "=" sign) called "app". This attribute represents the parent identifier for that workstation.

The second time in the loop, "app" gets overwritten, which means the previous parent id no longer exists, which means the previous workstation effectively is invalid.

The documentation for gsn_open_wks probably should be updated to indicate that you can't have arrays of workstations like this.

However, I think a work-around, using Rick's third example below, is to make sure that the "app" attribute that is returned each time through the loop gets saved:

  filenames = (/ "foo1", "foo2", "foo3" /)
  wks = new(3, "graphic" )
  do i=0,2
     wks(i) = gsn_open_wks("x11",filenames(i))
     str = "app"+i
     wks@$str$ = wks@app ; This makes sure the "app" id "lives" for the rest of the script.
  end do

  do i=0,2
     gsn_define_colormap(wks(i),"BlueGreen14")
     gsn_draw_colormap(wks(i))
  end do

--Mary

On Jul 5, 2012, at 9:31 AM, <brownrig@ucar.edu<mailto:brownrig@ucar.edu>> <brownrig@ucar.edu<mailto:brownrig@ucar.edu>> wrote:

Hi Doug,

I can't say for certain at the moment, but this would appear to be
either a bug or a rather curious scoping behavior. In trying to
duplicate this, I did:

  filenames = (/ "foo1", "foo2", "foo3" /)
  wks = new(3, "graphic" )
  do i=0,2
     wks(i) = gsn_open_wks("ps",filenames(i))
     gsn_define_colormap(wks(i),"BlueGreen14")
     gsn_draw_colormap(wks(i))
  end do

...which works. I modified the loop to look more like yours:

  do i=0,2
     foo = gsn_open_wks("ps",filenames(i))
     wks(i) = foo
     delete(foo)
     gsn_define_colormap(wks(i),"BlueGreen14")
     gsn_draw_colormap(wks(i))
  end do

...which also works. However, if I do this:

  do i=0,2
     wks(i) = gsn_open_wks("ps",filenames(i))
  end do
  do i=0,2
     gsn_define_colormap(wks(i),"BlueGreen14")
    gsn_draw_colormap(wks(i))
  end do

It fails.

We'll have to look into this more...

Rick

On Wed, 4 Jul 2012 09:50:17 +0000
 Douglas Lowe <Douglas.Lowe@manchester.ac.uk<mailto:Douglas.Lowe@manchester.ac.uk>> wrote:
Hi all,

Is it possible to open graphics devices within an array, rather than
as individual objects?

We've attempted to use the code below to do this, but all that
happens is that as one graphics object is added to the array the rest
are closed.

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

type = "ps"
wks_array = new(nspc*2, "graphic") ; create workstation array

do ispc = 0,nspc-1
 print("opening workstations "+2*ispc+" and "+(2*ispc+1))
 wks_temp1 = gsn_open_wks(type,savefile(2*ispc))
 wks_temp2 = gsn_open_wks(type,savefile(2*ispc+1))

 wks_array(2*ispc) = wks_temp1
 wks_array(2*ispc+1) = wks_temp2
 delete(wks_temp1)
 delete(wks_temp2)
end do

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

We're attempting to open the graphics objects in this way so that we
can loop through our processing code
(rather than have to duplicate everything 12 times). Does ncl
support pointers? If so would it be possible for
us to use those to do this instead?

Thanks,
Doug
_______________________________________________
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 Fri Jul 6 04:45:21 2012

This archive was generated by hypermail 2.1.8 : Mon Jul 09 2012 - 10:45:32 MDT