[Thread Prev][Thread Next][Index]

Re: [ferret_users] looping through viewports



Hi Jeniffer,

I'll insist with the first example. I'm sorry because I gave you wrong commands. Instead, you should try the following:

let vplist = {"ul", "ur", "ll", "lr"}
repeat/range=1:4/name=m ( \
   let myvp = vplist[i=`m`]; \  ! or 
let myvp = "vplist[i=`m`]",  I'm not sure
   set viewport `myvp`; \
   plot obgc01[l=`m`:200]; \


Pay attention for the variable "myvp". I missed this step and gave you the commands without testing. Previously we had "set viewport `vplist[i=m]`", what's wrong because Ferret cannot solve the loop counter "m" and the variable varying with it in a single grave accent pair. Test this and let me know if didn't work.

{"ul", "ur", "ll", "lr"} are Ferret predefined viewports. You can define custom viewports with "define viewport" command. More details here: http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/commands-reference/DEFINE#_VPINDEXENTRY_1361 

Once you define your own viewports, giving them sequenced-numbered names, you can simply call them with "set viewport vp`m`" within the loop, where "m" is your loop counter and "vp" is the base of viewport names. However, it won't work to define Ferret symbols refering to viewports. 

In some cases, Ferret symbols has similar purpose of user-defined variables, but always different syntax. To call the value stored in a symbol you must use $(my_symbol) syntax. I don't think it's suitable for the case. You find more about Ferret symbols here:  http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/commands-reference/DEFINE#_VPINDEXENTRY_1346 

Cheers,
Paulo
 

2012/9/17 <Jennifer.Abernethy@xxxxxxxx>
Paulo,

thanks so much for your help.  I've tried both your examples and I see the approach but am having pesky syntax problems:

!I make viewport names
define symbol v1 "ul"
define symbol v2 "ur"
define symbol v3 "ll"
define symbol v4 "lr"

! a simple trial
repeat/range=1:4/name=m ( \
set viewport v`m` ; \
plot obgc01[l=`m`:200]; \
)

___!-> REPEAT: M:1
 !-> set viewport v1
 **ERROR: invalid command: Unknown argument:v1
set viewport v1
Command file, command group, or REPEAT execution aborted

Is it $v`m` or $(v`m`) or ($v`m`)....? I can't get any variation to work (except, of course, to hard-code  'set viewport "ul"' in the loop).




I also tried the first example:

let vplist = {"ul", "ur", "ll", "lr"}
repeat/range=1:4/name=m ( \
set viewport `vplist[i=m]`; \
plot obgc01[l=`m`:200]; \
)
!-> REPEAT: M:1
 **ERROR: command syntax: M
set viewport `vplist[i=m]`
Command file, command group, or REPEAT execution aborted


I tried all the variations of $ and `` I can think of with this one, too, and none work. Do you see what I'm doing wrong? I'm using version6.72.


thanks so much for helping a poor lost ferreter!
jenny

_____________________________________
From: Paulo Santiago [paulohsm@xxxxxxxxx]
Sent: Monday, September 17, 2012 5:54 PM
To: Whelan, Jennifer (CMAR, Aspendale)
Cc: ferret_users@xxxxxxxx
Subject: Re: [ferret_users] looping through viewports

Dear Jennifer,

Lets adopt a simpler example to illustrate. Suppose we have a variable with four timesteps (l=4), and we want to plot each timestep in a viewport. We do

vplist = {"ul", "ur", "ll", "lr"}
repeat/range=1:4/name=m ( \
set viewport `vplist[i=m]`; \
fill variable[l=`m`]; \
)

If you have more than four viewports, you'll have to define those viewports before use it. In this case, you can use numbered-sequenced viewport names, such as vp1, vp2, vp3, ..., vpN. This makes your life easier if you have to use these viewports inside a repeat loop, and you should simply use something like the example below.

repeat/range=1:N/name=m ( \
set viewport vp`m`; \
<plot commands>; \
)

Hope it helps.

Cheers,
Paulo Santiago

2012/9/17 <Jennifer.Abernethy@xxxxxxxx<mailto:Jennifer.Abernethy@xxxxxxxx>>
Hi,

i'm trying to write a ferret script that can plot varying-length timeseries in sections, i.e., for 40 years of monthly data make 4 plots, for 100 years of monthly data make 10 plots, etc. I can do most of this in a repeat/range loop, but the one part I can't figure out is how to loop through viewports. I just want to loop through an array, arr[1], arr[2], arr[3] arr[4], arr[1], arr[2], etc etc - at least, that's how I'd do it in other languages. I was wanting 4 plots/page, ul (upper left) ur, ll, lr.

something like this:
let f = {"ul","ur","ll","lr"}   !how do I address the elements of this list?
let c =1    !montlhly data counter
repeat/range=`startyear`:`endyear-10`:10:name=m (let g = `c+120`; !120 months = 10yrs ; set viewport ???? ; plot data[`c`:`g`] ; label/nouser 0,4,-1,0,.15 Title Year `m` to `m+10`; let c=`g`)
frame/file=plots.gif

I was also wondering if after 4+ iterations of this loop that the resulting gif file will have multiple pages, or will the last 4 plots overwrite any previous ones?
thanks for any help you can give,
jenny






--
Paulo Santiago
Doutorado em Meteorologia
Programa de Pós-Graduação em Meteorologia
Instituto Nacional de Pesquisas Espaciais
Tel.: (12) 3186 8637



--
Paulo Santiago
Doutorado em Meteorologia
Programa de Pós-Graduação em Meteorologia
Instituto Nacional de Pesquisas Espaciais
Tel.: (12) 3186 8637


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement