Gnuastro’s library has the following macros and functions for dealing with spectral lines. All these functions are declared in gnuastro/spectra.h.
Internal values/identifiers for recognized spectral lines as is clear from their names. They are based on the UV an optical table of galaxy emission lines of Drew Chojnowski280.
Note the first and last macros, they can be used when parsing the lines automatically: both do not correspond to any line, but their integer values correspond to the two integers just before and after the first and last line identifier:
GAL_SPECLINES_INVALID
has a value of zero, and allows you to have a fixed integer which never corresponds to a line.
GAL_SPECLINES_INVALID_MAX
is the total number of pre-defined lines, plus one.
So you can parse all the known lines with a for
loop like this:
for(i=1;i<GAL_SPECLINES_INVALID_MAX;++i)
Wavelength (in Angstroms) of the named lines.
The *
can take any of the line names of the GAL_SPECLINES_*
Macros above.
Names (as literal stings without any space) that can be used to refer to the lines in your program and converted to and from line identifiers using the functions below.
The *
can take any of the line names of the GAL_SPECLINES_*
Macros above.
char *
(int linecode
)
¶Return the literal string of the given spectral line identifier Macro (for
example GAL_SPECLINES_HALPHA
or GAL_SPECLINES_LYLIMIT
).
int
(char *name
)
¶Return the spectral line identifier of the given standard name (for example
GAL_SPECLINES_NAME_HALPHA
or GAL_SPECLINES_NAME_LYLIMIT
).
double
(int linecode
)
¶Return the wavelength (in Angstroms) of the given line.
double
(double obsline
, double restline
)
¶Return the redshift where the observed wavelength (obsline
) was
emitted from (if its restframe wavelength was restline
).
double
(double obsline
, int linecode
)
¶Return the redshift where the observed wavelength (obsline
) was emitted from a pre-defined spectral line in the macros above.
For example, you want the redshift where the H-alpha line falls at a wavelength of 8000 Angstroms, you can call this function like this:
gal_speclines_line_redshift_code(8000, GAL_SPECLINES_H_alpha);
GNU Astronomy Utilities 0.23 manual, July 2024.