STScI Logo

compspec stsdas.toolbox.testdata


NAME · USAGE · DESCRIPTION · PARAMETERS · EXAMPLES · BUGS · SEE_ALSO

NAME

compspec -- Create a spectrum from an algebraic expression.

USAGE

compspec spectrum expr npoints fstwave lstwave units

DESCRIPTION

This task creates artificial spectra (1-dimensional images) where the spectrum can be expressed as an algebraic function. The algebraic expression has the same syntax as an expression in a CL script, with a few extensions. The expression can only contain one variable of up to 31 characters. The expression is evaluated at each point in the spectrum, with the value of the variable varying linearly between the value of fstwave and lstwave. Integer and real values are distinguished while evaluating the expression, just as in CL or Fortran, so that 3./5. is 0.6, but 3/5 is 0.

This task will create a new image with only the default header and group parameters. This task creates only one group in an image. If you wish to create a new multi-group image, set spectrum to an image name of the form <image>.<ext>[1/<ngroups>] for the first run. For example, an FOS spectrum with six groups might have the name ytest.hhh[1/6]. Then make subsequent runs of this task, changing the spectrum value to an image name of the form <image>.<ext>[<group>]. For example, to create the remaining five groups of the FOS spectrum, make five more runs of this task, changing spectrum to ytest.hhh[2] through ytest.hhh[6]. The following tables summarize the syntax of the algebraic expression. The following mathematical operators can be used in an expression.

-	unary minus
+	addition
-	subtraction
*	multiplication
/	division
**	exponentiation

The following functions are also available. All angles in the trigonometric functions are in degrees.

abs	absolute value
acos	arc cosine
asin	arcsine
atan	arc tangent
atan2	arc tangent with two arguments
cos	cosine
exp	exponent
int	integer truncation
log	natural logarithm (base e)
log10	common logarithm (base 10)
max	maximum of two arguments
min	minimum of two arguments
mod	first argument modulus second argument
nint	nearest integer
sin	sine
sqrt	square root
tan	tangent

Conditional expressions can also be used. These expressions have the form <boolean expr> ? <expr> : <expr>. If the boolean expression is true, then the expression before the colon is evaluated, if it is false, the expression after the colon is evaluated. The following expression could be used to create a step function: "x > 256 ? 1.0 : 0.0". These operators are available for use in the boolean expression.

<	less than
<=	less than or equal
>	greater than
>= 	greater than or equal
==	equal
!=	not equal
&&	and
||	or
!	not

PARAMETERS

spectrum [file name]
The name of the output spectrum file created by this task.
expr [string]
An algebraic expression in one variable. The syntax for this parameter is explained in the Description section, above.
npoints [integer, min=2]
The number of points in the spectrum.
fstwave [real]
The value of the variable in the expression at the first point in the spectrum.
lstwave [real]
The value of the variable in the expression at the last point in the spectrum.
units [string]
The units of the variable in the expression.

EXAMPLES

1. Create a spectrum with 512 points named ytest.hhh, which contains a ramp function. The ramp function goes from 0 to 1000:

  to> compspec ytest.hhh wave 512 0. 1000. pixel

2. Create a spectrum with 1024 points named ytest.hhh containing a sine wave:

  to> compspec ytest.hhh "1+sin(theta)" 1024 0. 360. degree

BUGS

SEE ALSO


Source Code · Package Help · Search Form · STSDAS