/*-------------------------------------------------------------------------*/ /** @file spectral_lines.h @author N. Devillard @date November 1999 @version $Revision: 1.11 $ @brief spectrum line handling routines */ /*--------------------------------------------------------------------------*/ /* $Id: spectral_lines.h,v 1.11 2001/11/12 13:41:30 yjung Exp $ $Author: yjung $ $Date: 2001/11/12 13:41:30 $ $Revision: 1.11 $ */ #ifndef _SPECTRAL_TABLE_H_ #define _SPECTRAL_TABLE_H_ /*--------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include #include #include "xmemory.h" /*--------------------------------------------------------------------------- New types ---------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /** @brief an emission line type this structure contain the position (wavel), the relative intensity (intens) ant the type (type) of the emission line. type can be "oh", "xe", "ar", it always has to be 2 letters. */ /*-------------------------------------------------------------------------*/ typedef struct _EMISSION_LINE_ { double wavel ; double intens ; char type[2] ; } emission_line ; /*-------------------------------------------------------------------------*/ /** @brief a spectral table type The following struct stores in the simplest way a list of spectral lines. nlines is the number of lines in the table wave contains their wavelength in Angstroems irel contains their relative intensity (no units) */ /*-------------------------------------------------------------------------*/ typedef struct _SPECTRAL_TABLE_ { int nlines ; emission_line * lines ; } spectral_table ; /*--------------------------------------------------------------------------- Function ANSI prototypes ---------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /** @brief Initialize a spectral line table. @param path Name of the table to initialize. @return 1 newly allocated spectral_table object. The received path string indicates where the spectral table should be loaded from. \begin{tabular}{ll} "oh" & OH table \\ "Xe" & Xenon table \\ "Ar" & Argon table \\ "Xe+Ar" & Xenon+Argon table \\ /path/file & User-specified external table \end{tabular} If the given table name corresponds to a user-specified table, it is loaded from the disk and dynamically allocated. See spectral_table_parse_list() for the acceptable The returned table must be deallocated using spectral_table_destroy() */ /*--------------------------------------------------------------------------*/ spectral_table * spectral_table_init(char * path) ; /*-------------------------------------------------------------------------*/ /** @brief Create a spectral table @param size Size of the created table @return the allocated spectral table */ /*--------------------------------------------------------------------------*/ spectral_table * spectral_table_create(int size) ; /*-------------------------------------------------------------------------*/ /** @brief Deallocate a spectral table. @param spt Spectral table to deallocate. @return void */ /*--------------------------------------------------------------------------*/ void spectral_table_destroy(spectral_table * spt) ; /*-------------------------------------------------------------------------*/ /** @brief Sort a spectral table @param table spectral table to sort (modified) @return 0 if Ok, -1 otherwise */ /*--------------------------------------------------------------------------*/ int spectral_table_sort(spectral_table * table) ; /*-------------------------------------------------------------------------*/ /** @brief Dump a spectral table @param table spectral table to dump @param out Opened file pointer @return 0 if Ok, -1 otherwise */ /*--------------------------------------------------------------------------*/ int spectral_table_dump( spectral_table * table, FILE * out) ; /*-------------------------------------------------------------------------*/ /** @brief Merge two spectral tables @param spt1 First spectral table @param spt2 Second spectral table @return a spectral table composed with the two input ones */ /*--------------------------------------------------------------------------*/ spectral_table * spectral_table_merge( spectral_table * spt1, spectral_table * spt2) ; /*-------------------------------------------------------------------------*/ /** @brief Select lines in a spectral table @param ref reference spectral table @param type type of lines selected @return a spectral table created with selected lines */ /*--------------------------------------------------------------------------*/ spectral_table * spectral_table_select( spectral_table * ref, char * type) ; /*-------------------------------------------------------------------------*/ /** @brief Read a spectral table from an external file. @param path Full path name of the file to load. @return 1 pointer to newly allocated spectral table. This function loads an external spectral table into a spectral_table object. The file must be an ASCII file, following these properties: \begin{itemize} \item Lines starting with a '#' are comments and ignored. \item Blank lines are ignored. \item Spectral lines are given as two values per line, separated by any number of blanks or tabs. The first value gives the wavelength in Angstroems, the second gives the relative intensity, which must be consistent with all lines in the same table. \end{itemize} The returned object must be deallocated using spectral_table_destroy(). */ /*--------------------------------------------------------------------------*/ spectral_table * spectral_table_parse_list(char * path) ; /*-------------------------------------------------------------------------*/ /** @brief Build a 1d signal from a spectral table @param spt Spectral table to use. @param wave_min Lower bound of the spectral range. @param wave_max Upper bound of the spectral range. @param size Size of the signal to generate. @return 1 pointer to a newly allocated array of 'size' doubles. Provide an allocated spectral table and a wavelength range in Angstroems as [wavemin, wavemax], and the size in pixels of the signal to generate. The returned array is a 1d signal (of doubles) containing the spectral lines as pixels. Returns NULL in case of error (e.g. invalid wavelength range). */ /*--------------------------------------------------------------------------*/ double * spectral_table_build_signal( spectral_table * spt, double wave_min, double wave_max, int size) ; /*-------------------------------------------------------------------------*/ /** @brief Output a list of table lines as a signal to a file. @param table_name Name of the table to output. @param outfilename Name of the output file. @param wave_min Lower bound of the wavelength range. @param wave_max Upper bound of the wavelength range. @param nsamples Number of samples to produce. @return void This function builds a 1d signal based on the requested table name and wavelength range, and outputs it to an ASCII file. This is useful to dump out lists of lines for e.g. debugging purposes, to compare a calibrated signal with a list of reference lines. Provide NULL or the character string "STDOUT" to output the list to stdout. Any other name specifies a file. If another file by the same name already exists, it will be overwritten. */ /*--------------------------------------------------------------------------*/ void spectral_table_build_spectrum( char * table_name, char * outfilename, double wave_min, double wave_max, int nsamples) ; #endif