View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Spectral typing tool: spectype.cl

Frank Valdes wrote on Aug 03, 1999

# SPECTYPE -- Compare spectrum against a library of spectra.
# The library parameter is a file of spectrum names in some desired order.
#
# This task uses SPECPLOT to plot the spectrum between two library spectra
# and then uses a cursor read to get the next command.  So users must first
# type 'q' to quit SPECPLOT and then type one of the keys of this task.
#
# n - go to next library spectrum
# p - go to previous library spectrum
# r - redraw with current library spectrum
# x - exit
#
# To install this task:
#
# 1. Copy script to your IRAF home directory.
# 2. In your loginuser.cl or login.cl enter before the final keep:
#        task spectype=home$spectype.cl
#
# Note that the library is a text file of single comparison spectra.  If
# the spectra are in a single multispec file or multiextension fits you would
# use a syntax like abc.ms[*,3] or mef.fits[3] for each spectrum.

procedure spectype (spectrum)

string	spectrum		{prompt="Spectrum to type"}
string	library			{prompt="File of comparison spectra"}
pset	specplot		{prompt="Specplot parameters"}

struct	*fd

begin
	string	spec, spec1, spec2, temp, key
	real	xcur, ycur
	int	wcs
	struct	cmd
	bool	plot

	# Check for SPECPLOT.
	if (!deftask ("specplot"))
	    error (5, "First load package with SPECPLOT")

	# Query parameters.
	spec = spectrum

	# Check parameters.
	if (!imaccess (spec))
	    error (1, "Spectrum not available")
	if (!access (library))
	    error (2, "Library not available")

	fd = library
	if (fscan (fd, spec1) == EOF)
	    error (3, "Library is empty")
	if (fscan (fd, spec2) == EOF)
	    error (4, "Library contains only one spectrum")

	key = "r"
	while (key != "x") {
	    if (key == "n") {
		temp = spec1
		if (fscan (fd, spec1) == EOF) {
		    printf ("At end of library\n")
		    beep
		    plot = no
		} else {
		    spec2 = temp
		    plot = yes
		}
	    } else if (key == "p") {
		fd = library
		temp = spec1
		i = fscan (fd, spec1)
		if (spec1 == temp) {
		    printf ("At beginning of library\n")
		    beep
		    plot = no
		} else {
		    while (fscan (fd, spec2) != EOF) {
			if (spec2 == temp)
			    break
			spec1 = spec2
		    }
		    plot = yes
		}
	    } else if (key == "r") {
		plot = yes
	    } else {
		printf ("Unrecognized key: %s\n", key)
		beep
	    }

	    if (plot) {
		specplot (spec2//","//spec//","//spec1)
		plot = no
	    }
	    printf ("Command: (x=exit, n=next, p=previos, r=redraw)\n")
	    if (fscan (gcur, xcur, ycur, wcs, key, cmd) == EOF)
		break
	}
	fd = ""
end
----------


----- End Included Message -----

Last post on Aug 03, 1999