How to use Ferret "constant arrays" (e.g. "{1,3,5}")
Below is an annotated version of the script constant_array_demo.jnl
! constant_array_demo.jnl (4/99)
! Description: Demonstration of the {1, 3, 5} "constant array" syntax
! Constant array syntax introduced into Ferret in V5.0
! Constant arrays allow you quickly to enter lists of constant values.
! SYNTAX:
! Constant arrays are comma-separated lists enclosed in curly
braces.
! If the list needs to contain gaps (missing values), simply omit
the element
! For example
LIST {1,3,5}, {1,,5}
yes? LIST {1,3,5}, {1,,5} X: 0.5 to 3.5 Column 1: {1,3,5} Column 2: {1,,5} {1,3,5} {1,,5} 1 / 1: 1.000 1.000 2 / 2: 3.000 .... 3 / 3: 5.000 5.000
! Note that a constant variable is always an array oriented
in the X direction
! To create a constant aray oriented in, say, the Y direction
use YSEQUENCE
STAT/BRIEF YSEQUENCE({1,3,5})
yes? STAT/BRIEF YSEQUENCE({1,3,5})
Total # of data points: 3 (1*3*1*1) # flagged as bad data: 0 Minimum value: 1 Maximum value: 5 Mean value: 3 (unweighted average)
! EXAMPLES
! Below are several examples illustrating uses of constant arrays
! 1) plots a triangle
! 2) plots a series of triangles at data points
! 3) Samples a variable at a list of subscripts
! Ex 1) plot a triangle
LET xtriangle = {0,.5,1} LET ytriangle = {0,1,0} POLYGON/LINE=8 xtriangle, ytriangle, 0
! Ex 2) plot a series of triangles at data points
! See also XXXX.jnl for a more automated way to do this)
LET xpts = 10*RANDU(j[j=1:20]+0) ! random X coordinates LET ypts = 10*RANDU(j[j=1:20]+1) ! random Y coordinates LET values = 10* j[j=1:20] ! value at each (x,y) point POLYGON xpts+xtriangle, ypts+ytriangle, values
! Ex 3) Sample winter and summer in the Northern hemisphere from sst in coads_climatology
USE coads_climatology LET my_sst_winter = SAMPLEL({1,2,12}, sst[Y=0:90N]) LET my_sst_summer = SAMPLEL({6,7,8}, sst[Y=0:90N]) STAT/BRIEF my_sst_winter STAT/BRIEF my_sst_summer
yes? STAT/BRIEF my_sst_winter
Total # of data points: 24300 (180*45*1*3)
# flagged as bad data: 12310
Minimum value: -2.2
Maximum value: 29.513
Mean value: 17.703 (unweighted average)yes? STAT/BRIEF my_sst_summer
Total # of data points: 24300 (180*45*1*3)
# flagged as bad data: 11094
Minimum value: -2.3
Maximum value: 33.15
Mean value: 19.648 (unweighted average)
oar.pmel.contact_ferret@noaa.gov 5 Apr, 1999