Program: COMBIN
Purpose: Combine sets to create new sets using mathematical
expressions.
Category: ANALYSIS, COMBINATION, MANIPULATION, CALCULATION
File: combin.shl
Author: M. Vogelaar
Keywords:
RESULT01= Combination code for first output set.
The code must contain at least one parameter ($n).
If you want a set with for example only noise, try
something like: ($1 - $1) + expression for noise.
RESULT02= Combination code for the second output set.
If carriage return is given, COMBIN assumes that
no other output combinations are wanted.
RESULT03= etc.
SET01= Input set (and subsets) for first combination.
Maximum number of subsets is 2048. The output
set(s) will get the same sizes as this first
input set.
BOX01= Frame for first input parameter. [entire subset]
SET02= Input set (and subsets) for second parameter.
Input is accepted if the number of subsets is
equal to the previous number of subsets.
If you want to use COMBIN outside a given box
(see OPTION= keyword), all the input sets need
to have the same axis sizes.
BOX02= Frame for second parameter. [previous box]
The axis lengths of this box have to be equal to the
axis lengths of the previous box. If using COMBIN
outside a box, the relative position of this box
has to be the same as the position of the first box.
SET03= etc.
BOX03= etc.
SETOUT01= Give set and subset(s) where the first combination is
to be stored.
SETOUT02= Give set and subset(s) where the second combination is
to be stored.
SETOUT03= etc.
*** OPTION= [0]
0. COMBIN operates inside given box and blanks values
outside this box
1. COMBIN operates inside given box and transfers
'outside' values of SET01
2. COMBIN operates outside given box and blanks values
inside this box
3. COMBIN operates outside given box and transfers
'inside' values of SET01
Description: This program allows the user to create sets which are
a (complicated) combination of other sets. The
combination description language is best illustrated
by the following example: suppose that one
has two sets which are the result of a Fourier
transform, one containing the real part and the other
the imaginary part of the result. The code needed to
convert these two sets to amplitude and phase is the
following:
RESULT01= SQRT( $1*$1 + $2*$2 ) (amplitude)
RESULT02= DEG( ATAN2 ( $2, $1 ) ) (phase in degrees)
Here $1 and $2 denote the first and second input sets.
In this example two input sets result in two output
sets. But just as easy we could produce a third output
set which contains the scaled real part. Then the code
would be:
RESULT03= 2 * $1 + 1 (scaled real part)
So with COMBIN we can combine M input sets into N
output sets.
The example above can be achieved with the following
keywords:
COMBIN,RESULT01=sqrt($1*$1+$2*$2)
COMBIN,RESULT02=deg(atan2($2,$1))
COMBIN,RESULT03=
Note: Two different types of output sets will be
produced
Input sets:
COMBIN,SET01=AURORA_RE FREQ 1:10
COMBIN,SET02=AURORA_IM FREQ 1:10
Output sets:
COMBIN,SETOUT01=AURORA_AM FREQ 1:10
COMBIN,SETOUT02=AURORA_PH FREQ 1:10
Note: We used (the default) option 0
Available mathematics:
1) functions; syntax ff(..); where ff is one of the
following available functions:
abs(x) absolute value of x
sqrt(x) square root of x
sin(x) sine of x
asin(x) inverse sine of x
cos(x) cosine of x
acos(x) inverse cosine of x
tan(x) tangent of x
atan(x) inverse tan of x
atan2(x,y) inverse tan (mod 2pi) x = sin, y = cos
exp(x) exponential of x
ln(x) natural log of x
log(x) log (base 10) of x
sinh(x) hyperbolic sine of x
cosh(x) hyperbolic cosine of x
tanh(x) hyperbolic tangent of x
rad(x) convert x to radians
deg(x) convert x to degrees
erf(x) error function of x
erfc(x) 1-error function
max(x,y) maximum of x and y
min(x,y) minimum of x and y
sinc(x) sin(x)/x (sinc function)
sign(x) sign of x (-1,0,1)
mod(x,y) gives remainder of x/y
int(x) truncates to integer
nint(x) nearest integer
ranu(x,y) generates uniform noise between x and y
rang(x,y) generates gaussian noise with mean x
and dispersion y
ranp(x) generates poisson noise with mean x
ifeq(x,y,a,b) returns a if x == y, else b
ifne(x,y,a,b) returns a if x != y, else b
ifgt(x,y,a,b) returns a if x > y, else b
ifge(x,y,a,b) returns a if x >= y, else b
iflt(x,y,a,b) returns a if x < y, else b
ifle(x,y,a,b) returns a if x <= y, else b
ifblank(x,a,b) returns a if x == BLANK, else b
Some (statistical) functions have a variable number
of arguments:
sum(x1,..,xn) sum of elements x1 .. xn
mean(x1,..,xn) mean
var(x1,..,xn) variance
sdev(x1,..,xn) standard deviation
adev(x1,..,xn) absolute deviation
skew(x1,..,xn) skewness
kurt(x1,..,xn) kurtosis
median(x1,..,xn) median
nblanks(x1,..,xn) number of blanks
max(x1,..,xn) maximum of elements x1 .. xn
min(x1,..,xn) minimum
Note that n <= 128
2) constants; syntax cc; where cc is one of the following
available constants:
PI 3.14159....
C speed of light (SI)
H Planck (SI)
K Boltzmann (SI)
G gravitation (SI)
S Stefan-Boltzman (SI)
M mass of sun (SI)
P parsec (SI)
BLANK Universal undefined value
Note: the Hubble constant is not included.
3) operators; syntax op; where op is one of the following
available operators:
+ addition
- subtraction
* multiplication
/ division
** power
4) parameters; syntax $n; where 1 <= n <= 128.
Remarks: A) The calculations are all done in double precision.
B) BLANK values are recognized. Any operation on a
BLANK causes the result to be set to BLANK (except the
function IFBLANK). Also all illegal operations, like
dividing by zero or the logarithm of a negative value,
will cause the result to be set to BLANK.
C) If you cannot find your favorite constant or function
in the list, please contact Kor Begeman. He might be
persuaded to put it in.
Examples: 1) Add three maps
RESULT01=$1+$2+$3
RESULT02=
SET01= set and subset(s) of first parameter
SET02= set and subset(s) of second parameter
SET03= set and subset(s) of third parameter
SETOUT01= set and subset(s) of sum
2) Add gaussian noise to a map with zero mean and a
rms of 2
RESULT01=$1+rang(0,2)
RESULT02=
SET01= input set and subset(s)
SETOUT01= output set and subset(s) with noise added
3) Clip values in a set between -4 and 5 and replace with
'BLANK'
RESULT01=ifgt($1,5,BLANK,iflt($1,-4,BLANK,$1))
RESULT02=
SET01= input set and subset(s)
SETOUT01= clipped output set and subset(s) with values
between -4 and 5
4) Conditional transfer: if value in second set is
greater than 2 then result is value from first set,
else set this value to BLANK
RESULT01=ifgt($2,2,$1,BLANK)
RESULT02=
SET01= input set and subset(s)
SET02= test set and subset(s)
SETOUT01= conditional transfered output set and
subset(s)
5) Calculate median of three sets and put result in output
set MEDIAN
RESULT01=median($1,$2,$3)
RESULT02=
SET01=OPTC1
SET01=OPTC2
SET01=OPTC3
SETOUT01=MEDIAN
Notes: