[ncl-talk] Fwd: Setting contour levels with setvalues

Mary Haley haley at ucar.edu
Tue Aug 26 10:09:28 MDT 2014


Hi Kyle,

I took a quick look at your script, and yes, you are correct that order
matters, *if* you are using "setvalues" with one resource setting at a
time.  If, inside a single call to a setvalues block, you are setting a
bunch of resources, then order doesn't matter. Order also doesn't matter
when you set resources via the usual way of creating a "res" variable and
then passing that to gsn_csm_xxxx.

I understand why you coded it this way, because there's no way to pass an
arbitrary list of resources to "setvalues".

However, there's another way you can do this, and that is via the
"attsetvalues" procedure:

http://www.ncl.ucar.edu/Document/Functions/Built-in/attsetvalues.shtml

So, instead of this code:

 do jj=0,dimsizes(vresource)-1
    setvalues plot
      vresource(jj) : vresvalue(jj)
    end setvalues
  end do

you could do something like this:

 res = True
 do jj=0,dimsizes(vresource)-1
    res@$vresource(jj)$ = vresvalue(jj)
 end do
 attsetvalues(plot,res)

--Mary



On Tue, Aug 26, 2014 at 8:26 AM, Kyle Griffin <ksgriffin2 at wisc.edu> wrote:

> Hi all,
>
> I solved this problem this morning. While the biggest issue with my
> example was the lack of a statement to convert the input from string to a
> numeric type, I did have such provisions in my actual code of interest.
>
> It turns out that the order with which contour resources are set *does*
> matter. If cnLevels or cnMinLevelValF, cnMaxLevelValF, and cnLevelSpacingF
> (depending on selection mode) are set before the cnLevelSelectionMode is
> set, the previously-set limits are essentially ignored (or perhaps
> partially reset?). I can't quite say what was happening as I didn't look
> into it, but just wanted to clarify that it is crucial to set
> cnLevelSelectionMode ***before*** setting any other related resources with
> the 'setvalues' command.
>
>
> 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 at wisc.edu
>
>
> ---------- Forwarded message ----------
> From: Kyle Griffin <ksgriffin2 at wisc.edu>
> Date: Mon, Aug 25, 2014 at 6:29 PM
> Subject: Setting contour levels with setvalues
> To: ncl-talk <ncl-talk at ucar.edu>
>
>
> Hi all,
>
> I have either found a bug or am missing other resources that need setting.
> My problem stems from not being able to properly limit the min and max
> levels with cnMinLevelValF/cnMaxLevelValF in ManualLevels mode and cnLevels
> with ExplicitLevels mode. While this doesn't seem to always occur, I've
> attached a script which duplicates this problem. There might be a few
> unnecessary lines in the script as well, as I've been testing quite a bit
> of the object-oriented setvalues/getvalues commands. You can test each mode
> by commenting/uncommenting the pair of vresources/vresvalue variables just
> inside the begin statement. I think this is all self-contained (aside from
> the two gsm load statements), but let me know if anything doesn't work when
> the script is run. This is on a 64-bit linux system with 6.1.2. Thanks,
>
>
> 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 at wisc.edu
>
>
> _______________________________________________
> ncl-talk mailing list
> 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/20140826/b7a7eb54/attachment.html 


More information about the ncl-talk mailing list