View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

LSARITH – Long slit spectrum arithmetic

Frank Valdes wrote on Mar 03, 1998


# LSARITH -- Long slit spectrum arithmetic.
#
# This script uses SARITH to operate on every line/column of one or two
# long slit spectra.  The final image will be a long slit spectrum with
# dispersion axis along the first dimension.  The primary purpose of this
# script is to allow arithmetic between two spectra with different dispersions.
# It can also be used to resample to a specified starting and ending
# wavelength using the "copy" operation and no second input spectrum.
# A script is required because using SARITH directly will produce an
# output multispec format which can overflow header limits if there are
# many spectral lines/columns in the input.  For large images this task
# will be slow compared to a compiled program but it will do the job.
# Don't use this task if the dispersions are the same and IMARITH could
# be used instead.
#
# NOTE THAT THE PACKAGE PARAMETER NSUM WILL BE USED.
#
# To install as a private script:
#
#    1) place the script as lsarith.cl in your IRAF login directory
#    2) in your login.cl or loginuser.cl add the statements
#	    noao
#	    twodspec
#	    longslit
#           task lsarith = home$lsarith.cl
#    3) start IRAF
#
# This will load the LONGSLIT package and add this task as part of that
# package.

procedure lsarith (input1, op, input2, output)

file	input1			{prompt="First input spectrum"}
string	op			{prompt="Operation"}
file	input2			{prompt="Second input spectrum"}
file	output			{prompt="Output spectrum"}

real	w1 = INDEF		{prompt="Starting wavelength"}
real	w2 = INDEF		{prompt="Ending wavelength"}
bool	verbose = no		{prompt="Verbose?"}

begin
	file	in1, in2, out, temp
	string	op1
	int	nspec, spec

	# Get query parameters.
	in1 = input1
	op1 = op
	in2 = input2
	out = output

	# Define a temporary filename.
	temp = mktemp ("tmp")

	# Determine the number of spectra.
	if (imaccess (in1))
	    slist (in1, apertures="", long-) | count ("STDIN") | scan (nspec)
	else
	    slist (in2, apertures="", long-) | count ("STDIN") | scan (nspec)

	# Make the output spectrum using the first aperture.
	sarith (in1, op1, in2, out, w1=w1, w2=w2, apertures="1", bands="",
	    beams="", apmodulus=0, reverse=no, ignoreaps=no,
	    format="multispec", renumber=no, offset=0, clobber=no,
	    merge=no, rebin=yes, errval=0., verbose=verbose)
	imstack (out, temp, title="*", pixtype="*")
	blkrep (temp, temp, 1, nspec)
	hedit (temp, "apnum1", delete+, add-, show-, verify-, update+)
	hedit (temp, "wat0_001", "system=image", add+, show-, verify-, update+)
	imdelete (out, verify-)

	# Do the remaining spectra.
	for (spec=2; spec<=nspec; spec+=1) {
	    sarith (in1, op1, in2, out, w1=w1, w2=w2, apertures=spec, bands="",
		beams="", apmodulus=0, reverse=no, ignoreaps=no,
		format="multispec", renumber=no, offset=0, clobber=no,
		merge=no, rebin=yes, errval=0., verbose=verbose)
	    imcopy (out, temp//"[*,"//spec//"]", verbose-)
	    imdelete (out, verify-)
	}
	imrename (temp, out, verbose-)
end

Last post on Mar 03, 1998