Martin,
This depends a lot on how the script is written, but an _expression_
can definitely be sent in as the argument to a script. When running
Ferret or PyFerret the behavior is the same when running Ferret
commands and scripts.
The vland and vfland scripts take arguments which specify a line in
X or Y, given by a single value and a range, given as strings
containing x= and y= specifiers.
! usage: arg1 arg2 arg3 arg4
! GO vland [resolution] [pen] x=val y=lo:hi
! x=lo:hi y=val
! usage: arg1 arg2 arg3 arg4
! GO vfland [resolution] [palette] x=val y=lo:hi
! x=lo:hi y=val
They specifically look for argument 3 and 4 to be in that form, and
they check that those arguments fit that requirement. So in this
case the answer is to just find out what the script is doing, do
something similar in a custom script.
Script arguments are treated as symbols on entry into the script.
The script will evaluate them and may treat them as numbers, or as
strings which refer to variable names, whole complex expressions,
file names, etc. They are just seen by Ferret on entry to the
script as pieces of text.
If I have a script with just this:
! my_plot_script.jnl
!
plot/color=blue $1
then it works fine to call it as follows:
yes? use etopo20
yes? go my_plot_script rose[x=@var]
! my_plot_script.jnl
!
plot/color=blue $1
!-> plot/color=blue rose[x=@var]
and it makes the plot.
Another example of a complex script argument: the "polymark.jnl"
script takes a whole graphics command as an argument. Here's the
argument at the start of that script
! yes? LET xpts = 180 + 50*COS(2*3.14*I[I=1:50]/60)
! yes? LET ypts = 15 + 20*SIN(2*3.14*I[I=1:50]/60)
! yes? LET sst = 25 - ypts + RANDN(ypts)
! yes? GO basemap x=120:250 Y=25s:65n 20
!
! yes? GO polymark polygon/over/key/title="SST"
xpts,ypts,sst,ex, 0.5
!
- the first argument is this string:
polygon/over/key/title="SST"
so an _expression_ may be passed into a script - and of course when
writing your own scripts they can handle arguments as you wish.
Symbol substitution is a dense syntax, but also a powerful one.
-Ansley
On 9/28/2015 4:23 PM, Martin Schmidt
wrote:
Hi Anley,
I am in Luanda in the moment and have only a windows PC. So I
cannot check anything and I do not write to the list ...
Using pyferret I had observed recently that scripts take only a
variable but not the transformations applied to. To be
specific, I tried:
go script var[x=@din]
and in the script
a=$1
I did not get an error message but the output was not as expected.
But I needed such a script since "var" was many variables. As a
solution I have shifted the [x=@din] to the script
go script var
a=$1[x=@din]
This solved the problems as far as output was as expected. May be
the point is the difference between
go script var[x=@din]
a=$1
and
go script var
a=$1[x=@din]
If there is non, I am wrong, if there is some - ferret behaves
differently then expected from intuition.
The question was on the list, so a fast late nite answer from
nowhere ....
Best,
Martin
Am 28.09.2015 21:04, schrieb Ansley Manke:
Hi Pearse,
Yes, the arguments to those scripts are simple numbers or
ranges, not expressions.
To see what the scripts are doing, use
yes? go/help vland
yes? go/help vfland
It would be quite simple to do the same thing as vland,
using the x-average of a topography variable. In vland.jnl, the
script opens a topo dataset, and does this plot command.
PLOT/NOLAB/overlay/VLIM=($ppl$ymax):($ppl$ymin)/SET
-1*fv_rosedepth[($fv_xyregion)]
but in defining the XY region, the script requires a range in
one direction and a scalar in the other. Instead, it sounds as
if you want something along these lines:
USE etopo20
PLOT/NOLAB/overlay/VLIM=($ppl$ymax):($ppl$ymin)/SET
-1*rose[x=@AVE,y=-90:90]
vfland.jnl sets up some variables and symbols, and calls the
"fill_between" script. Here, I'd suggest you watch it in action
for a single value of X, to see how you could set things up to
call it with an x-averaged topography variable. Make your plot
calls:
yes? fill my_variable
then turn on "mode verify" so you can see the commands as
they're run.
yes? set mode verify:always
yes? go vfland 20 gray x=150 y=-90:90
What you're looking for in that output, is how the "GO
fill_between" script is called.
On 9/28/2015 12:17 AM, Pearse Buchanan wrote:
Hi fellow ferreters,
I’m trying to make some meridional section plots over
various regions of the ocean. This includes a global zonal
average, as well as zonal averages for the Indian, pacific
and Atlantic oceans with various variables (please see the
attached pretty plots).
I came across the vland and vfland scripts during my
searching, and was attempting to use them. However, it
seems that you must define an exact vertical/horizontal
section, i.e. no averages!
This is how I tried to get it to work originally, with no
success:
go vfland 20 grey x=@ave y=-90:90
Command file, command group, or REPEAT execution
aborted
**ERROR: error: data is not a line
It seems the x=@ave argument is not
recognised. Is there an alternative?
Any help would be appreciated.
Thanks,
Pearse
Pearse J. Buchanan
PhD Candidate / CSIRO-UTAS Quantitative Marine
Science
Institute for Marine and Antarctic Studies (IMAS),
University of Tasmania
~~~ “Ocean deoxygenation: A Palaeo-Modelling
Perspective” ~~~
Parts of the Ocean are predicted to lose oxygen in
the coming century. But why?
Looking into the past, how does oxygen in the ocean
change across climate transitions?
University of Tasmania Electronic Communications Policy
(December, 2014).
This email is confidential, and is for the intended
recipient only. Access, disclosure, copying, distribution,
or reliance on any of it by anyone outside the intended
recipient organisation is prohibited and may be a criminal
offence. Please delete if obtained in error and email
confirmation to the sender. The views expressed in this
email are not necessarily the views of the University of
Tasmania, unless clearly intended otherwise.
|