Re: Re-using Backgrounds

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 30 2011 - 10:35:35 MST

Hi Paul,

The "wkFileName does not have 'S' access" error means that "wkFileName" is a resource that can only be set when the object is created, and not after the fact with a "setvalues" call.
You can't change the name of the file while you are still trying to draw to it.

Since you have a loop for each plot, you can easily construct the name of the PNG file yourself:

getvalues wks
      "wkFileName" : wks_prefix
 end getvalues

do parameter = 0,N

   fname = wks_prefix + "." + sprinti("%06i",parameter) + ".png"
. . .

--Mary

> do parameter = 0,N

On Nov 29, 2011, at 2:40 PM, Paul Scorer wrote:

> I am attempting to create a reusable background.
>
> The real code is significantly more complicated, and the data files
> huge, but the idea is _illustrated_ by the code below (although it
> obviously won't run!).
>
> I would also note that the do ... end do is in a separate file, if that
> is relevant.
>
> My code basically works, except that I get a warning:
>
> warning:_NhlSetValues:wkFileName does not have "S" access
>
> I have only been able to establish that 'some values do not have "S"
> access'.
>
> Further, the output filenames are "tmp.000001,png", "tmp.000002.png"
>
>
> The only workaround I can think of is to do
>
> system("mv tmp.000001.png " + "ParameterFilename")
>
> But how can I find out what is the current tmp filename?
>
> I have established that doing something like
> getvalues wks
> "wkFileName" : fname
> end getvalues
> only yields "tmp.png"
>
> Can anything be done about this?
>
>
> I hope this is sufficient information.
>
>
> Regards & Many Thanks in anticipation.
>
> PaulS
>
> ;;;; EXAMPLE CODE START
>
> ; Create a workstation
> wks = create "tmp" imageWorkStationClass defaultapp
> ; stuff here, eg Height, Width, ...
> end create
>
> ; Stop the background being drawn
> opts_bg = True
> opts_bg@gsnDraw = False
> opts_bg@gsnFrame = False
>
> ; Specify other details, etc
> opts_bg@mpProjection = ...
> ; also Corners, etc, etc
>
> ; Create the background map
> bg = gsn_csm_map(wks, opts_bg)
>
> ; Loop over lots of parameters, all to have the same background
> do parameter = 0,N
>
> ; Create the parameter contour, to go onto the background map
>
> ; Don't draw it yet
> opts_cn@gsnDraw = False
> opts_cn@gsnFrame = False
>
> ; duplicate the background, so can re-use
> param_bg = bg
>
> ; set individual parameter filename
> setvalues wks
> "wkFileName" : "ParameterFileName"
> end setvalues
>
> ; create the contour
> contour = gsn_csm_contour(wks, data, opts_cn)
>
> ; Put the contour onto the background
> overlay(param_bg, contour)
>
> ; Draw the plot
> draw(param_bg)
> ; Advance the frame
> frame(wks)
>
> ; Destroy the copied background, so can recreate
> delete(param_bg)
> end
> ;;;; CODE END
>
> _______________________________________________
> 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 Nov 30 10:35:43 2011

This archive was generated by hypermail 2.1.8 : Wed Nov 30 2011 - 19:52:47 MST