Adding Scaling Algorithms to SAOtng

SAOtng supports the following scale algorithms internally:

See Binning Pixel Values by Scaling for more information.

Support for other scaling algorithms can be added to SAOtng by writing a program that takes a FITS image as input and generates a scaled (8-bit) FIT image as output. When activated, a scale command line macro-expanded to fill in user-defined arguments and then is executed externally using the system() function (see Macro expansion in SAOtng.

The ASCII file that defines new scaling algorithms consists of one or more scale descriptors, each of which has the following format:

Note that blank lines separate the file descriptions and should not be used as part of a description. Also, the '#' character is a comment character.

For example, the default image access file currently contains the following:

#
# Data scaling descriptions:
#	help line
#	name of scale
#	type (always "scale")
#	scale command

Linear data scaling
linear
scale
$data | linear min=$min max=$max

Log data scaling
log
scale
$data | log log=10 min=$min max=$max

Square root data scaling
sqrt
scale
$data | pow pow=0.5 min=$min max=$max

Linear wrapped data scaling
wrap
scale
$data | wrap min=$min max=$max

No data scaling
none
scale
$data | none

Each scale program command line takes $data as stdin and write the scaled FITS image to stdout. When the scale algorithm is executed, $data will be replaced by a command to retrieve the unscaled data which then is passed to the scale program. The output scaled FITS image will be sent back to SAOtng for display using XPA.

The scale programs shown above are written so that the program itself takes FITS data into its stdin and write scaled FITS data to stdout This need not be the case, however, since it the entire command line that must process "stdin" and "stdout" and not just the program. For example, consider a case of a scale program that read and wrote FITS disk files instead of stdin and stdout:

    scaleit -i [unscaled_fits] -o [scaled_fits]
This program could use the following command line to scale data in SAOtng:
    $data > /tmp/foo; scaleit -i /tmp/foo -o /tmp/goo; cat /tmp/goo
SAOtng will replace $data with an XPA command to retrieve the unscaled data and also add the appropriate commands on the send output file back for display. Of course, it clearly is more efficient to read and write to stdin/stdout and avoid the overhead of disk access.
Return to Advanced Topics Page

Return to Main SAOtng Help Page

Last Updated May 1, 1995