View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Easy spectral typing tool?

Frank Valdes wrote on Aug 03, 1999

Q:  I'm trying to spectral type a bunch of stars and I'm looking for a
simpler way to do it than the ways I have tried before.  What I'd like
to know is either: 1) is there a tool or kludge to do what I describe
below or 2) how difficult would it be for me to adapt the specplot
package to do this?  (please read on)

What I have in hand is an array of spectra of standard stars in a single
multispec file ordered from F9 to M4.  I also have separate .ms files of
my unknown stars.  What I am currently doing is running two copies of
IRAF and running splot in both - one for the grid of standards and one
to show the unknown star.  In this way, I've been able to easily flip
between stds with "(" and ")".  But running in two windows makes zooming
in to look at particular features a pain, since I have to do the same
for each window and pressing "(" or ")" undoes the zoom in the grid
window.

What would be ideal is a tool like specplot that could display three
spectra: the unknown in the middle and a standard above and
below (the goal being to find two standards which bracket the unknown in
spectral type).  Then one could press a set of keys ("u/d" or "+/-" etc)
to browse through the standards.  The specplot-like environment would be
ideal as it could preserve the current zoom and use the standard "w"
keys.

I've built a tool like this in IDL and it works moderately well despite
being incomplete.  However, I find it's very inconvenient to transform
.ms files so IDL can read them (I'm just wspectext'ing them...).  It
would be much nicer to be able to work with any old .ms file right in
IRAF.  I'm a pretty good programmer, but my proficiency is just
read-only for SPP (so far).  How big a project would you guess it would
be for me to adapt specplot to accomplish this?  (I'm encouraged by the
fact that specplot has been recycled into other tasks like
imred.hydra.skysub)


A:  I had time to look at your mail and I thought writing a script would be
a fun exercise.  Below is the script I wrote.  You could modify it if
you want.  Note that I wrote it so that the library is a text file
containing a list of single spectra.  For a multispec file of comparison
spectra you would use a syntax like:

cl> type library
standards[*,1]
standards[*,2]
    etc.
    

[Note that this script is archived in the adass.iraf.sources newsgroup.]

----- spectype.cl -----
# 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