gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 5603241: CosmicCalculator: find redshift based


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 5603241: CosmicCalculator: find redshift based on observe wavelength
Date: Sat, 11 May 2019 17:38:48 -0400 (EDT)

branch: master
commit 5603241392771bea9c3a7eb0c36c62c0c42f17df
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    CosmicCalculator: find redshift based on observe wavelength
    
    Until now the only way to specify a redshift in CosmicCalculator was to
    explicitly give it with the `-z' option. But in some situations, you know
    the observed wavelength of an emission line, and its rest-frame wavelength
    (which can also be used to estimate the redshift).
    
    With this commit CosmicCalculator has the new `--obsline' option where you
    can feed this information about observed and rest-frame wavelengths and let
    CosmicCalculator estimate the redshift from them and continue as
    before. Since we aren't explicity giving the redshift, another
    `--usedredshift' option has been added to CosmicCalculator to print the
    used redshift with any other requested calculated value.
    
    In order to do this, it was necessary to define a new library in Gnuastro
    to keep the wavelengths and give standard names to spectral lines. That
    library is now saved in `lib/speclines.c' and `lib/gnuastro/speclines.h'.
---
 NEWS                      |  14 +++
 bin/cosmiccal/args.h      |  28 ++++++
 bin/cosmiccal/cosmiccal.c |   5 +
 bin/cosmiccal/main.h      |   3 +-
 bin/cosmiccal/ui.c        | 119 +++++++++++++++++++++--
 bin/cosmiccal/ui.h        |   6 +-
 doc/gnuastro.texi         | 236 +++++++++++++++++++++++++++++++++++++++++++---
 lib/Makefile.am           |  13 +--
 lib/cosmology.c           |  30 +++++-
 lib/gnuastro/cosmology.h  |   4 +-
 lib/gnuastro/speclines.h  | 180 +++++++++++++++++++++++++++++++++++
 lib/speclines.c           | 231 +++++++++++++++++++++++++++++++++++++++++++++
 12 files changed, 840 insertions(+), 29 deletions(-)

diff --git a/NEWS b/NEWS
index 9eec5f9..7795903 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,17 @@ See the end of the file for license conditions.
 
 ** New features
 
+  CosmicCalculator:
+   --obsline: alternative way to set the used redshift. With this option
+     instead of explicity giving the redshift, you can give a rest-frame
+     and observed wavelength and the redshift to use will be calculated
+     internally. For many lines, it is possible to give the line name
+     instead of its rest-frame wavelength. For example
+     `--obsline=lyalpha,6000' will use the redshift where the Lyman-alpha
+     line has been shifted to 6000 Angestroms.
+   --usedredshift: Print the used redshift as a "Specific calculation" (in
+     line with other single-valued calculations).
+
   Statistics:
    --sigclip-number, --sigclip-median, --sigclip-mean, --sigclip-std: Do
      sigma-clipping and only print the desired value as a single-value
@@ -33,6 +44,9 @@ See the end of the file for license conditions.
      datasets
 
   Library:
+   - New `speclines.h' library functions and macros related to spectral
+     lines. It has many macros with line wavelengths, and several functions
+     for using them in combination with their names.
    - gal_statistics_outlier_flat_cfp: Improved implementation with new API.
 
 ** Bugs fixed
diff --git a/bin/cosmiccal/args.h b/bin/cosmiccal/args.h
index e7359cb..d241ca0 100644
--- a/bin/cosmiccal/args.h
+++ b/bin/cosmiccal/args.h
@@ -45,6 +45,20 @@ struct argp_option program_options[] =
       GAL_OPTIONS_NOT_SET
     },
     {
+      "obsline",
+      UI_KEY_OBSLINE,
+      "STR,FLT",
+      0,
+      "Redshift from line and observed wavelength.",
+      GAL_OPTIONS_GROUP_INPUT,
+      &p->obsline,
+      GAL_TYPE_STRING,
+      GAL_OPTIONS_RANGE_ANY,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+      ui_parse_obsline
+    },
+    {
       "H0",
       UI_KEY_H0,
       "FLT",
@@ -106,6 +120,20 @@ struct argp_option program_options[] =
       UI_GROUP_SPECIFIC
     },
     {
+      "usedredshift",
+      UI_KEY_USEDREDSHIFT,
+      0,
+      0,
+      "Used redshift in this run.",
+      UI_GROUP_SPECIFIC,
+      &p->specific,
+      GAL_OPTIONS_NO_ARG_TYPE,
+      GAL_OPTIONS_RANGE_0_OR_1,
+      GAL_OPTIONS_NOT_MANDATORY,
+      GAL_OPTIONS_NOT_SET,
+      ui_add_to_single_value,
+    },
+    {
       "agenow",
       UI_KEY_AGENOW,
       0,
diff --git a/bin/cosmiccal/cosmiccal.c b/bin/cosmiccal/cosmiccal.c
index e58a834..9d52a29 100644
--- a/bin/cosmiccal/cosmiccal.c
+++ b/bin/cosmiccal/cosmiccal.c
@@ -167,6 +167,11 @@ cosmiccal(struct cosmiccalparams *p)
       for(tmp=p->specific;tmp!=NULL;tmp=tmp->next)
         switch(tmp->v)
           {
+          case UI_KEY_USEDREDSHIFT:
+            printf("%g ",
+                   p->redshift==MAIN_REDSHIFT_ZERO ? 0.0f: p->redshift);
+            break;
+
           case UI_KEY_AGENOW:
             printf("%f ", gal_cosmology_age(0.0f, p->H0, p->olambda,
                                             p->omatter, p->oradiation));
diff --git a/bin/cosmiccal/main.h b/bin/cosmiccal/main.h
index e6aff26..958a8db 100644
--- a/bin/cosmiccal/main.h
+++ b/bin/cosmiccal/main.h
@@ -33,7 +33,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #define PROGRAM_EXEC   "astcosmiccal"     /* Program executable name. */
 #define PROGRAM_STRING PROGRAM_NAME" (" PACKAGE_NAME ") " PACKAGE_VERSION
 
-
+#define MAIN_REDSHIFT_ZERO 1e-20
 
 
 
@@ -51,6 +51,7 @@ struct cosmiccalparams
   double               olambda; /* Current cosmological constant dens.  */
   double               omatter; /* Current matter density.              */
   double            oradiation; /* Current radiation density.           */
+  gal_data_t          *obsline; /* Observed wavelength of a line.       */
 
   /* Outputs. */
   gal_list_i32_t     *specific; /* Codes for single row calculations.   */
diff --git a/bin/cosmiccal/ui.c b/bin/cosmiccal/ui.c
index 192f6fc..32f4008 100644
--- a/bin/cosmiccal/ui.c
+++ b/bin/cosmiccal/ui.c
@@ -26,11 +26,14 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #include <errno.h>
 #include <error.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <gsl/gsl_const_mksa.h>
 
 #include <gnuastro/fits.h>
 #include <gnuastro/table.h>
+#include <gnuastro/speclines.h>
+#include <gnuastro/cosmology.h>
 
 #include <gnuastro-internal/timing.h>
 #include <gnuastro-internal/options.h>
@@ -231,6 +234,97 @@ ui_add_to_single_value(struct argp_option *option, char 
*arg,
 
 
 
+/* Parse the observed line properties: LINE,OBSERVED_WAVELENGHT. */
+void *
+ui_parse_obsline(struct argp_option *option, char *arg,
+                 char *filename, size_t lineno, void *junk)
+{
+  size_t nc, two=2;
+  char *c, *linename;
+  gal_data_t *obsline, *tobsline;
+  double *dptr, *tdptr, manualwl=NAN;
+  char *str, sstr[GAL_OPTIONS_STATIC_MEM_FOR_VALUES];
+
+  /* We want to print the stored values. */
+  if(lineno==-1)
+    {
+      /* Set the value pointer to `obsline'. */
+      obsline=*(gal_data_t **)(option->value);
+      dptr = obsline->array;
+
+      /* First write the line name into the output string. */
+      nc=0;
+      linename=gal_speclines_line_name(obsline->status);
+      nc += sprintf(sstr+nc, "%s,", linename);
+
+      /* Write the observed wavelength. */
+      sprintf(sstr+nc, "%g", dptr[0]);
+
+      /* Copy the string into a dynamically allocated space, because it
+         will be freed later.*/
+      gal_checkset_allocate_copy(sstr, &str);
+      return str;
+    }
+  else
+    {
+      /* The first part of `arg' (before the first comma) is not
+         necessarily a number. So we need to separate the first part from
+         the rest.*/
+      linename=arg;
+      c=arg; while(*c!='\0' && *c!=',') ++c;
+      arg = (*c=='\0') ? NULL : c+1;
+      *c='\0';
+
+      /* Read the parameters. */
+      obsline=gal_options_parse_list_of_numbers(arg, filename, lineno);
+
+      /* Only one number must be given as second argument. */
+      if(obsline->size!=1)
+        error(EXIT_FAILURE, 0, "too many values (%zu) given to `--obsline'. "
+              "Only two values (line name/wavelengh, and observed wavelengh) "
+              "must be given", obsline->size+1);
+
+      /* If a wavelength is given directly as a number (not a name), then
+         put that number in a second element of the array. */
+      dptr=&manualwl;
+      if( gal_type_from_string((void **)(&dptr), linename, GAL_TYPE_FLOAT64) )
+        { /* `linename' isn't a number. */
+          obsline->status=gal_speclines_line_code(linename);
+          if(obsline->status==GAL_SPECLINES_INVALID)
+            error(EXIT_FAILURE, 0, "`%s' not recognized as a standard spectral 
"
+                  "line name", linename);
+        }
+      else
+        { /* `linename' is a number. */
+
+          /* Allocate the new space. */
+          tobsline=gal_data_alloc(NULL, GAL_TYPE_FLOAT64, 1, &two, NULL,
+                                  0, -1, NULL, NULL, NULL);
+          tobsline->status=GAL_SPECLINES_INVALID;
+
+          /* Write the values into tptr. */
+          dptr=obsline->array;
+          tdptr=tobsline->array;
+          tdptr[0]=dptr[0];
+          tdptr[1]=manualwl;
+
+          /* Free the old dataset and use the new one. */
+          gal_data_free(obsline);
+          obsline=tobsline;
+        }
+
+      /* Point `option->value' to the dataset. */
+      *(gal_data_t **)(option->value) = obsline;
+
+      /* Our job is done, return NULL. */
+      return NULL;
+    }
+}
+
+
+
+
+
 
 
 
@@ -264,12 +358,10 @@ ui_read_check_only_options(struct cosmiccalparams *p)
           "and radiation (`oradiation') densities are given as %.8f, %.8f, "
           "%.8f", sum, p->olambda, p->omatter, p->oradiation);
 
-  /* Currently GSL will fail for z=0. So if a value of zero is given (bug
-     #56299). As a work-around, in such cases, we'll change it to 1e-14
-     (close to, but not exactly, the 64-bit floating point precision
-     limit). GSL will do the integration without any error with this
-     value. */
-  if(p->redshift==0.0f) p->redshift=1e-14;
+  /* Make sure that `--redshift' and `--obsline' aren't called together. */
+  if(!isnan(p->redshift) && p->obsline)
+    error(EXIT_FAILURE, 0, "`--redshift' and `--obsline' cannot be called "
+          "together");
 }
 
 
@@ -297,6 +389,21 @@ ui_read_check_only_options(struct cosmiccalparams *p)
 static void
 ui_preparations(struct cosmiccalparams *p)
 {
+  double *obsline = p->obsline ? p->obsline->array : NULL;
+
+  /* If `--obsline' has been given, set the redshift based on it. */
+  if(p->obsline)
+    p->redshift = ( (p->obsline->status==GAL_SPECLINES_INVALID)
+                    ? gal_speclines_line_redshift(obsline[0], obsline[1])
+                    : gal_speclines_line_redshift_code(obsline[0],
+                                                       p->obsline->status) );
+
+  /* Currently GSL will fail for z=0. So if a value of zero is given (bug
+     #56299). As a work-around, in such cases, we'll change it to an
+     extremely small value. NOTE: This has to be after the `obsline'
+     check.*/
+  if(p->redshift==0.0f) p->redshift=MAIN_REDSHIFT_ZERO;
+
   /* The list is filled out in a first-in-last-out order. By the time
      control reaches here, the list is finalized. So we should just reverse
      it so the user gets values in the same order they requested them. */
diff --git a/bin/cosmiccal/ui.h b/bin/cosmiccal/ui.h
index f59a5c6..dcc57f9 100644
--- a/bin/cosmiccal/ui.h
+++ b/bin/cosmiccal/ui.h
@@ -42,18 +42,20 @@ enum program_args_groups
 
 /* Available letters for short options:
 
-   e f i j k n p t w x y
-   B E J O Q R W X Y
+   f i j k n p t w x y
+   B E J Q R W X Y
 */
 enum option_keys_enum
 {
   /* With short-option version. */
   UI_KEY_REDSHIFT            = 'z',
+  UI_KEY_OBSLINE             = 'O',
   UI_KEY_H0                  = 'H',
   UI_KEY_OLAMBDA             = 'l',
   UI_KEY_OMATTER             = 'm',
   UI_KEY_ORADIATION          = 'r',
 
+  UI_KEY_USEDREDSHIFT        = 'e',
   UI_KEY_AGENOW              = 'G',
   UI_KEY_CRITICALDENSITYNOW  = 'C',
   UI_KEY_PROPERDISTANCE      = 'd',
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 56436ae..417ea28 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -600,6 +600,7 @@ Gnuastro library
 * Convolution functions::       Library functions to do convolution.
 * Interpolation::               Interpolate (over blank values possibly).
 * Git wrappers::                Wrappers for functions in libgit2.
+* Spectral lines library::
 * Cosmology library::           Cosmological calculations.
 
 Multithreaded programming (@file{threads.h})
@@ -18534,9 +18535,9 @@ options}). Please see the descriptions there for more.
 The quantile of the signal-to-noise ratio distribution of clumps in
 undetected regions, used to define true clumps. After identifying all the
 usable clumps in the undetected regions of the dataset, the given quantile
-of their signal-to-noise ratios is used to define a the signal-to-noise
-ratio of a ``true'' clump. Effectively, this can be seen as an inverse
-p-value measure. See Figure 9 and Section 3.2.1 of
+of their signal-to-noise ratios is used to define the signal-to-noise ratio
+of a ``true'' clump. Effectively, this can be seen as an inverse p-value
+measure. See Figure 9 and Section 3.2.1 of
 @url{https://arxiv.org/abs/1505.01664, Akhlaghi and Ichikawa [2015]} for a
 complete explanation. The full distribution of clump signal-to-noise ratios
 over the undetected areas can be saved into a table with @option{--checksn}
@@ -19171,7 +19172,7 @@ upper-limit distributions. See The description of 
@option{--upmaskfile} in
 
 
 @node Measuring elliptical parameters, Adding new columns to MakeCatalog, 
Quantifying measurement limits, MakeCatalog
-       @subsection Measuring elliptical parameters
address@hidden Measuring elliptical parameters
 
 The shape or morphology of a target is one of the most commonly desired
 parameters of a target. Here, we will review the derivation of the most
@@ -22593,6 +22594,10 @@ $ astcosmiccal -z2.5
 ## Only print Comoving volume over 4pi stradian to z (Mpc^3):
 $ astcosmiccal --redshift=0.8 --volume
 
+## Print redshift and age of universe when Lyman-alpha line is
+## at 6000 angstrom (another way to specify redshift).
+$ astcosmiccal --obsline=lyalpha,6000 --age
+
 ## Print luminosity distance, angular diameter distance and age
 ## of universe in one row at redshift 0.4
 $ astcosmiccal -z0.4 -LAg
@@ -22631,7 +22636,7 @@ The inputs to CosmicCalculator can be specified with 
the following options:
 
 @item -z FLT
 @itemx --redshift=FLT
-The redshift of interest.
+The redshift of interest. This cannot be called with @option{--obsline}.
 
 @item -H FLT
 @itemx --H0=FLT
@@ -22651,6 +22656,67 @@ density in the current Universe 
(@mymath{\Omega_{m,0}}).
 @itemx --oradiation=FLT
 Radiation density divided by the critical density in the current Universe
 (@mymath{\Omega_{r,0}}).
+
address@hidden -O STR/FLT,FLT
address@hidden --obsline=STR/FLT,FLT
address@hidden Rest-frame wavelength
address@hidden Wavelength, rest-frame
+Find the redshift to use in next steps based on the rest-frame and observed
+wavelengths of a line. Wavelenghts are assumed to be in Angstroms. The
+first argument identifies the line. It can be one of the standard names
+below, or any rest-frame wavelengh in Angestroms. The second argument is
+the observed wavelength of that line. For example
address@hidden,6000} is the same as
address@hidden,6000}.
+
+The accepted names are listed below, sorted from red (longer wavelengh) to
+blue (shorter wavelengh).
+
address@hidden @code
address@hidden halpha
address@hidden address@hidden
address@hidden line at @mymath{6562.8} Angstrom.
+
address@hidden oiiired
+OIII doublet's redder line at @mymath{5007} Angstrom.
+
address@hidden oiii
address@hidden Doublet: OIII
address@hidden OIII doublet
+OIII doublet's mean center at @mymath{4983} Angstrom.
+
address@hidden oiiiblue
+OIII doublet's bluer line at @mymath{4959} Angstrom.
+
address@hidden hbeta
address@hidden address@hidden
address@hidden line at @mymath{4861.36} Angstrom.
+
address@hidden blimit
address@hidden Balmer limit
+Balmer limit at @mymath{3646} Angstrom.
+
address@hidden oiiired
+OII doublet's redder line at @mymath{3729} Angstrom.
+
address@hidden oiii
address@hidden Doublet: OII
address@hidden OII doublet
+OII doublet's mean center at @mymath{3727.5} Angstrom.
+
address@hidden oiiiblue
+OII doublet's bluer line at @mymath{3726} Angstrom.
+
address@hidden lyalpha
address@hidden address@hidden
address@hidden line at @mymath{1215.67} Angstrom.
+
address@hidden lylimit
address@hidden Lyman limit
+Lyman limit line at @mymath{912} Angstrom.
+
address@hidden table
+
 @end table
 
 
@@ -22722,6 +22788,15 @@ option which has the units along with a short 
description.
 
 @table @option
 
address@hidden -e
address@hidden --usedredshift
+The redshift that was used in this run. In many cases this is the main
+input parameter to CosmicCalculator, but it is useful in others. For
+example in combination with @option{--obsline} (where you give an observed
+and restframe wavelength and would like to know the redshift), or if you
+want to run CosmicCalculator in a loop while changing the redshift and you
+want to keep the redshift value.
+
 @item -G
 @itemx --agenow
 The current age of the universe (given the input parameters) in Ga (Giga
@@ -23735,6 +23810,7 @@ documentation will correspond to your installed version.
 * Convolution functions::       Library functions to do convolution.
 * Interpolation::               Interpolate (over blank values possibly).
 * Git wrappers::                Wrappers for functions in libgit2.
+* Spectral lines library::
 * Cosmology library::           Cosmological calculations.
 @end menu
 
@@ -24280,11 +24356,11 @@ out = gal_type_to_string(&string, GAL_TYPE_STRING, 1);
 @end deftypefun
 
 @deftypefun int gal_type_from_string (void @code{**out}, char @code{*string}, 
uint8_t @code{type})
-Read a string as a given data type and put a the pointer to it in
+Read a string as a given data type and put a pointer to it in
 @code{*out}. When @code{*out!=NULL}, then it is assumed to be already
-allocated and the value will be simply put the memory. If
address@hidden, then space will be allocated for the given type and the
-string will be read into that type.
+allocated and the value will be simply put there. If @code{*out==NULL},
+then space will be allocated for the given type and the string will be read
+into that type.
 
 Note that when we are dealing with a string type, @code{*out} should be
 interpreted as @code{char **} (one element in an array of pointers to
@@ -28481,7 +28557,7 @@ Free all the allocated arrays within @code{tl}.
 @node Bounding box, Polygons, Tessellation library, Gnuastro library
 @subsection Bounding box (@file{box.h})
 
-Functions related to reporting a the bounding box of certain inputs are
+Functions related to reporting the bounding box of certain inputs are
 declared in @file{gnuastro/box.h}. All coordinates in this header are in
 the FITS format (first axis is the horizontal and the second axis is
 vertical).
@@ -30068,7 +30144,7 @@ blank. To see if any blank (non-interpolated) elements 
remain, you can use
 @end deftypefun
 
 
address@hidden Git wrappers, Cosmology library, Interpolation, Gnuastro library
address@hidden Git wrappers, Spectral lines library, Interpolation, Gnuastro 
library
 @subsection Git wrappers (@file{git.h})
 
 @cindex Git
@@ -30104,8 +30180,144 @@ not installed or the program calling this function is 
not within a version
 controlled directory, then the output will be the @code{NULL} pointer.
 @end deftypefun
 
address@hidden Spectral lines library, Cosmology library, Git wrappers, 
Gnuastro library
address@hidden Spectral lines library (@file{speclines.h})
+
+Gnuastro's library has the following macros and functions for dealing with
+spectral lines. All these functions are declared in
address@hidden/spectra.h}.
+
address@hidden  Macro GAL_SPECLINES_INVALID
address@hidden Macro GAL_SPECLINES_SIIRED
address@hidden Macro GAL_SPECLINES_SII
address@hidden Macro GAL_SPECLINES_SIIBLUE
address@hidden Macro GAL_SPECLINES_NIIRED
address@hidden Macro GAL_SPECLINES_NII
address@hidden Macro GAL_SPECLINES_HALPHA
address@hidden Macro GAL_SPECLINES_NIIBLUE
address@hidden Macro GAL_SPECLINES_OIIIRED
address@hidden Macro GAL_SPECLINES_OIII
address@hidden Macro GAL_SPECLINES_OIIIBLUE
address@hidden Macro GAL_SPECLINES_HBETA
address@hidden Macro GAL_SPECLINES_HEIIRED
address@hidden Macro GAL_SPECLINES_HGAMMA
address@hidden Macro GAL_SPECLINES_HDELTA
address@hidden Macro GAL_SPECLINES_HEPSILON
address@hidden Macro GAL_SPECLINES_NEIII
address@hidden Macro GAL_SPECLINES_OIIRED
address@hidden Macro GAL_SPECLINES_OII
address@hidden Macro GAL_SPECLINES_OIIBLUE
address@hidden Macro GAL_SPECLINES_BLIMIT
address@hidden Macro GAL_SPECLINES_MGIIRED
address@hidden Macro GAL_SPECLINES_MGII
address@hidden Macro GAL_SPECLINES_MGIIBLUE
address@hidden Macro GAL_SPECLINES_CIIIRED
address@hidden Macro GAL_SPECLINES_CIII
address@hidden Macro GAL_SPECLINES_CIIIBLUE
address@hidden Macro GAL_SPECLINES_HEIIBLUE
address@hidden Macro GAL_SPECLINES_LYALPHA
address@hidden Macro GAL_SPECLINES_LYLIMIT
+Internal values/identifiers for specific spectral lines as is clear from
+their names.
address@hidden deffn
+
address@hidden  Macro GAL_SPECLINES_ANGSTROM_SIIRED
address@hidden Macro GAL_SPECLINES_ANGSTROM_SII
address@hidden Macro GAL_SPECLINES_ANGSTROM_SIIBLUE
address@hidden Macro GAL_SPECLINES_ANGSTROM_NIIRED
address@hidden Macro GAL_SPECLINES_ANGSTROM_NII
address@hidden Macro GAL_SPECLINES_ANGSTROM_HALPHA
address@hidden Macro GAL_SPECLINES_ANGSTROM_NIIBLUE
address@hidden Macro GAL_SPECLINES_ANGSTROM_OIIIRED
address@hidden Macro GAL_SPECLINES_ANGSTROM_OIII
address@hidden Macro GAL_SPECLINES_ANGSTROM_OIIIBLUE
address@hidden Macro GAL_SPECLINES_ANGSTROM_HBETA
address@hidden Macro GAL_SPECLINES_ANGSTROM_HEIIRED
address@hidden Macro GAL_SPECLINES_ANGSTROM_HGAMMA
address@hidden Macro GAL_SPECLINES_ANGSTROM_HDELTA
address@hidden Macro GAL_SPECLINES_ANGSTROM_HEPSILON
address@hidden Macro GAL_SPECLINES_ANGSTROM_NEIII
address@hidden Macro GAL_SPECLINES_ANGSTROM_OIIRED
address@hidden Macro GAL_SPECLINES_ANGSTROM_OII
address@hidden Macro GAL_SPECLINES_ANGSTROM_OIIBLUE
address@hidden Macro GAL_SPECLINES_ANGSTROM_BLIMIT
address@hidden Macro GAL_SPECLINES_ANGSTROM_MGIIRED
address@hidden Macro GAL_SPECLINES_ANGSTROM_MGII
address@hidden Macro GAL_SPECLINES_ANGSTROM_MGIIBLUE
address@hidden Macro GAL_SPECLINES_ANGSTROM_CIIIRED
address@hidden Macro GAL_SPECLINES_ANGSTROM_CIII
address@hidden Macro GAL_SPECLINES_ANGSTROM_CIIIBLUE
address@hidden Macro GAL_SPECLINES_ANGSTROM_HEIIBLUE
address@hidden Macro GAL_SPECLINES_ANGSTROM_LYALPHA
address@hidden Macro GAL_SPECLINES_ANGSTROM_LYLIMIT
+Wavelengh (in Angstroms) of the named lines.
address@hidden deffn
+
address@hidden  Macro GAL_SPECLINES_NAME_SIIRED
address@hidden Macro GAL_SPECLINES_NAME_SII
address@hidden Macro GAL_SPECLINES_NAME_SIIBLUE
address@hidden Macro GAL_SPECLINES_NAME_NIIRED
address@hidden Macro GAL_SPECLINES_NAME_NII
address@hidden Macro GAL_SPECLINES_NAME_HALPHA
address@hidden Macro GAL_SPECLINES_NAME_NIIBLUE
address@hidden Macro GAL_SPECLINES_NAME_OIIIRED
address@hidden Macro GAL_SPECLINES_NAME_OIII
address@hidden Macro GAL_SPECLINES_NAME_OIIIBLUE
address@hidden Macro GAL_SPECLINES_NAME_HBETA
address@hidden Macro GAL_SPECLINES_NAME_HEIIRED
address@hidden Macro GAL_SPECLINES_NAME_HGAMMA
address@hidden Macro GAL_SPECLINES_NAME_HDELTA
address@hidden Macro GAL_SPECLINES_NAME_HEPSILON
address@hidden Macro GAL_SPECLINES_NAME_NEIII
address@hidden Macro GAL_SPECLINES_NAME_OIIRED
address@hidden Macro GAL_SPECLINES_NAME_OII
address@hidden Macro GAL_SPECLINES_NAME_OIIBLUE
address@hidden Macro GAL_SPECLINES_NAME_BLIMIT
address@hidden Macro GAL_SPECLINES_NAME_MGIIRED
address@hidden Macro GAL_SPECLINES_NAME_MGII
address@hidden Macro GAL_SPECLINES_NAME_MGIIBLUE
address@hidden Macro GAL_SPECLINES_NAME_CIIIRED
address@hidden Macro GAL_SPECLINES_NAME_CIII
address@hidden Macro GAL_SPECLINES_NAME_CIIIBLUE
address@hidden Macro GAL_SPECLINES_NAME_HEIIBLUE
address@hidden Macro GAL_SPECLINES_NAME_LYALPHA
address@hidden Macro GAL_SPECLINES_NAME_LYLIMIT
+Names (as literal stings without any space, all in small-caps) that can be
+used to refer to the lines in your program and converted to and from line
+identifiers using the functions below.
address@hidden deffn
+
address@hidden {char *} gal_speclines_line_name (int @code{linecode})
+Return the literal string of the given spectral line identifier Macro (for
+example @code{GAL_SPECLINES_HALPHA} or @code{GAL_SPECLINES_LYLIMIT}).
address@hidden deftypefun
+
address@hidden int gal_speclines_line_code (char @code{*name})
+Return the spectral line identifier of the given standard name (for example
address@hidden or @code{GAL_SPECLINES_NAME_LYLIMIT}).
address@hidden deftypefun
+
address@hidden double gal_speclines_line_angstrom (int @code{linecode})
+Return the wavelengh (in Angstroms) of the given line.
address@hidden deftypefun
+
address@hidden double gal_speclines_line_redshift (double @code{obsline}, 
double @code{restline})
address@hidden Rest-frame
+Return the redshift where the observed wavelength (@code{obsline}) was
+emitted from (if its restframe wavelength was @code{restline}).
address@hidden deftypefun
+
address@hidden double gal_speclines_line_redshift_code (double @code{obsline}, 
int @code{linecode})
+Return the redshift where the observed wavelength (@code{obsline}) was
+emitted from (assuming its a specific spectra line, identified with
address@hidden).
address@hidden deftypefun
+
+
+
+
 
address@hidden Cosmology library,  , Git wrappers, Gnuastro library
address@hidden Cosmology library,  , Spectral lines library, Gnuastro library
 @subsection Cosmology library (@file{cosmology.h})
 
 This library does the main cosmological calculations that are commonly
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 6677a96..1dda613 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -59,9 +59,9 @@ libgnuastro_la_SOURCES = arithmetic.c arithmetic-and.c 
arithmetic-bitand.c \
   arithmetic-or.c arithmetic-plus.c array.c binary.c blank.c box.c         \
   checkset.c convolve.c cosmology.c data.c eps.c fits.c git.c              \
   interpolate.c jpeg.c label.c list.c match.c options.c pdf.c              \
-  permutation.c pointer.c polygon.c qsort.c dimension.c statistics.c       \
-  table.c tableintern.c threads.c tiff.c tile.c tile-internal.c timing.c   \
-  txt.c type.c wcs.c
+  permutation.c pointer.c polygon.c qsort.c dimension.c speclines.c        \
+  statistics.c table.c tableintern.c threads.c tiff.c tile.c               \
+  tile-internal.c timing.c txt.c type.c wcs.c
 
 
 
@@ -79,9 +79,10 @@ pkginclude_HEADERS = gnuastro/config.h 
$(headersdir)/arithmetic.h          \
   $(headersdir)/jpeg.h $(headersdir)/label.h $(headersdir)/list.h          \
   $(headersdir)/match.h $(headersdir)/pdf.h $(headersdir)/permutation.h    \
   $(headersdir)/pointer.h $(headersdir)/polygon.h $(headersdir)/qsort.h    \
-  $(headersdir)/statistics.h $(headersdir)/table.h $(headersdir)/threads.h \
-  $(headersdir)/tiff.h $(headersdir)/tile.h $(headersdir)/txt.h            \
-  $(headersdir)/type.h $(headersdir)/wcs.h
+  $(headersdir)/speclines.h $(headersdir)/statistics.h                     \
+  $(headersdir)/table.h $(headersdir)/threads.h $(headersdir)/tiff.h       \
+  $(headersdir)/tile.h $(headersdir)/txt.h $(headersdir)/type.h            \
+  $(headersdir)/wcs.h
 
 
 
diff --git a/lib/cosmology.c b/lib/cosmology.c
index 3d3a65c..138bdcb 100644
--- a/lib/cosmology.c
+++ b/lib/cosmology.c
@@ -152,7 +152,7 @@ cosmology_integrand_comoving_volume(double z, void *params)
 
 
 /**************************************************************/
-/************          Final functions            *************/
+/************      Basic cosmology functions      *************/
 /**************************************************************/
 /* Age of the universe (in Gyrs). H0 is in units of (km/sec/Mpc) and the
    fractional densities must add up to 1. */
@@ -310,3 +310,31 @@ gal_cosmology_to_absolute_mag(double z, double H0, double 
o_lambda_0,
                                            o_radiation_0);
   return dm-2.5*log10(1.0+z);
 }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************************************************************/
+/************      Basic cosmology functions      *************/
+/**************************************************************/
+double
+gal_cosmology_redshift_from_line(double obsline, double restline)
+{
+  return (obsline/restline)-1;
+}
diff --git a/lib/gnuastro/cosmology.h b/lib/gnuastro/cosmology.h
index b7568ad..a5d80a1 100644
--- a/lib/gnuastro/cosmology.h
+++ b/lib/gnuastro/cosmology.h
@@ -88,7 +88,9 @@ double
 gal_cosmology_to_absolute_mag(double z, double H0, double o_lambda_0,
                               double o_matter_0, double o_radiation_0);
 
-
+/* Get the redshift from the observed and restframe line. */
+double
+gal_cosmology_redshift_from_line(double obsline, double restline);
 
 
 __END_C_DECLS    /* From C++ preparations */
diff --git a/lib/gnuastro/speclines.h b/lib/gnuastro/speclines.h
new file mode 100644
index 0000000..4c4a669
--- /dev/null
+++ b/lib/gnuastro/speclines.h
@@ -0,0 +1,180 @@
+/*********************************************************************
+Spectral lines.
+This is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+     Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2019, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#ifndef __GAL_SPECLINES_H__
+#define __GAL_SPECLINES_H__
+
+/* Include other headers if necessary here. Note that other header files
+   must be included before the C++ preparations below */
+
+
+
+/* C++ Preparations */
+#undef __BEGIN_C_DECLS
+#undef __END_C_DECLS
+#ifdef __cplusplus
+# define __BEGIN_C_DECLS extern "C" {
+# define __END_C_DECLS }
+#else
+# define __BEGIN_C_DECLS                /* empty */
+# define __END_C_DECLS                  /* empty */
+#endif
+/* End of C++ preparations */
+
+
+
+/* Actual header contants (the above were for the Pre-processor). */
+__BEGIN_C_DECLS  /* From C++ preparations */
+
+
+/* Spectral line internal codes. */
+enum gal_speclines_line_codes
+{
+  GAL_SPECLINES_INVALID=0,
+  GAL_SPECLINES_SIIRED,
+  GAL_SPECLINES_SII,
+  GAL_SPECLINES_SIIBLUE,
+  GAL_SPECLINES_NIIRED,
+  GAL_SPECLINES_NII,
+  GAL_SPECLINES_HALPHA,
+  GAL_SPECLINES_NIIBLUE,
+  GAL_SPECLINES_OIIIRED,
+  GAL_SPECLINES_OIII,
+  GAL_SPECLINES_OIIIBLUE,
+  GAL_SPECLINES_HBETA,
+  GAL_SPECLINES_HEIIRED,
+  GAL_SPECLINES_HGAMMA,
+  GAL_SPECLINES_HDELTA,
+  GAL_SPECLINES_HEPSILON,
+  GAL_SPECLINES_NEIII,
+  GAL_SPECLINES_OIIRED,
+  GAL_SPECLINES_OII,
+  GAL_SPECLINES_OIIBLUE,
+  GAL_SPECLINES_BLIMIT,
+  GAL_SPECLINES_MGIIRED,
+  GAL_SPECLINES_MGII,
+  GAL_SPECLINES_MGIIBLUE,
+  GAL_SPECLINES_CIIIRED,
+  GAL_SPECLINES_CIII,
+  GAL_SPECLINES_CIIIBLUE,
+  GAL_SPECLINES_HEIIBLUE,
+  GAL_SPECLINES_LYALPHA,
+  GAL_SPECLINES_LYLIMIT,
+};
+
+
+/* Spectral lines wavelengths in Angstroms. */
+#define GAL_SPECLINES_ANGSTROM_SIIRED    6731
+#define GAL_SPECLINES_ANGSTROM_SII       6724
+#define GAL_SPECLINES_ANGSTROM_SIIBLUE   6717
+#define GAL_SPECLINES_ANGSTROM_NIIRED    6584
+#define GAL_SPECLINES_ANGSTROM_NII       6566
+#define GAL_SPECLINES_ANGSTROM_HALPHA    6562.8
+#define GAL_SPECLINES_ANGSTROM_NIIBLUE   6548
+#define GAL_SPECLINES_ANGSTROM_OIIIRED   5007
+#define GAL_SPECLINES_ANGSTROM_OIII      4983
+#define GAL_SPECLINES_ANGSTROM_OIIIBLUE  4959
+#define GAL_SPECLINES_ANGSTROM_HBETA     4861.36
+#define GAL_SPECLINES_ANGSTROM_HEIIRED   4686
+#define GAL_SPECLINES_ANGSTROM_HGAMMA    4340.46
+#define GAL_SPECLINES_ANGSTROM_HDELTA    4101.74
+#define GAL_SPECLINES_ANGSTROM_HEPSILON  3970.07
+#define GAL_SPECLINES_ANGSTROM_NEIII     3869
+#define GAL_SPECLINES_ANGSTROM_OIIRED    3729
+#define GAL_SPECLINES_ANGSTROM_OII       3727.5
+#define GAL_SPECLINES_ANGSTROM_OIIBLUE   3726
+#define GAL_SPECLINES_ANGSTROM_BLIMIT    3646
+#define GAL_SPECLINES_ANGSTROM_MGIIRED   2796
+#define GAL_SPECLINES_ANGSTROM_MGII      2799.5
+#define GAL_SPECLINES_ANGSTROM_MGIIBLUE  2803
+#define GAL_SPECLINES_ANGSTROM_CIIIRED   1907
+#define GAL_SPECLINES_ANGSTROM_CIII      1908
+#define GAL_SPECLINES_ANGSTROM_CIIIBLUE  1909
+#define GAL_SPECLINES_ANGSTROM_HEIIBLUE  1640
+#define GAL_SPECLINES_ANGSTROM_LYALPHA   1215.67
+#define GAL_SPECLINES_ANGSTROM_LYLIMIT   912
+
+
+/* Spectral line name strings. */
+#define GAL_SPECLINES_NAME_SIIRED    "siired"
+#define GAL_SPECLINES_NAME_SII       "sii"
+#define GAL_SPECLINES_NAME_SIIBLUE   "siiblue"
+#define GAL_SPECLINES_NAME_NIIRED    "niired"
+#define GAL_SPECLINES_NAME_NII       "nii"
+#define GAL_SPECLINES_NAME_HALPHA    "halpha"
+#define GAL_SPECLINES_NAME_NIIBLUE   "niiblue"
+#define GAL_SPECLINES_NAME_OIIIRED   "oiiired"
+#define GAL_SPECLINES_NAME_OIII      "oiii"
+#define GAL_SPECLINES_NAME_OIIIBLUE  "oiiiblue"
+#define GAL_SPECLINES_NAME_HBETA     "hbeta"
+#define GAL_SPECLINES_NAME_HEIIRED   "heiired"
+#define GAL_SPECLINES_NAME_HGAMMA    "hgamma"
+#define GAL_SPECLINES_NAME_HDELTA    "hdelta"
+#define GAL_SPECLINES_NAME_HEPSILON  "hepsilon"
+#define GAL_SPECLINES_NAME_NEIII     "neiii"
+#define GAL_SPECLINES_NAME_OIIRED    "oiired"
+#define GAL_SPECLINES_NAME_OII       "oii"
+#define GAL_SPECLINES_NAME_OIIBLUE   "oiiblue"
+#define GAL_SPECLINES_NAME_BLIMIT    "blimit"
+#define GAL_SPECLINES_NAME_MGIIRED   "mgiired"
+#define GAL_SPECLINES_NAME_MGII      "mgii"
+#define GAL_SPECLINES_NAME_MGIIBLUE  "mgiiblue"
+#define GAL_SPECLINES_NAME_CIIIRED   "ciiired"
+#define GAL_SPECLINES_NAME_CIII      "ciii"
+#define GAL_SPECLINES_NAME_CIIIBLUE  "ciiiblue"
+#define GAL_SPECLINES_NAME_HEIIBLUE  "heiiblue"
+#define GAL_SPECLINES_NAME_LYALPHA   "lyalpha"
+#define GAL_SPECLINES_NAME_LYLIMIT   "lylimit"
+
+
+
+
+
+/*********************************************************************/
+/*************        Internal names and codes         ***************/
+/*********************************************************************/
+char *
+gal_speclines_line_name(int linecode);
+
+int
+gal_speclines_line_code(char *name);
+
+double
+gal_speclines_line_angstrom(int linecode);
+
+
+
+
+
+/*********************************************************************/
+/*************             Redshifted lines            ***************/
+/*********************************************************************/
+double
+gal_speclines_line_redshift(double obsline, double restline);
+
+double
+gal_speclines_line_redshift_code(double obsline, int linecode);
+
+
+__END_C_DECLS    /* From C++ preparations */
+
+#endif           /* __GAL_COSMOLOGY_H__ */
diff --git a/lib/speclines.c b/lib/speclines.c
new file mode 100644
index 0000000..c98c212
--- /dev/null
+++ b/lib/speclines.c
@@ -0,0 +1,231 @@
+/*********************************************************************
+Spectral lines.
+This is part of GNU Astronomy Utilities (Gnuastro) package.
+
+Original author:
+     Mohammad Akhlaghi <address@hidden>
+Contributing author(s):
+Copyright (C) 2019, Free Software Foundation, Inc.
+
+Gnuastro is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+Gnuastro is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Gnuastro. If not, see <http://www.gnu.org/licenses/>.
+**********************************************************************/
+#include <config.h>
+
+#include <math.h>
+#include <stdio.h>
+#include <errno.h>
+#include <error.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <gnuastro/speclines.h>
+
+
+/*********************************************************************/
+/*************        Internal names and codes         ***************/
+/*********************************************************************/
+/* Return line's name as literal string. */
+char *
+gal_speclines_line_name(int linecode)
+{
+  switch(linecode)
+    {
+    case GAL_SPECLINES_SIIRED:           return GAL_SPECLINES_NAME_SIIRED;
+    case GAL_SPECLINES_SII:              return GAL_SPECLINES_NAME_SII;
+    case GAL_SPECLINES_SIIBLUE:          return GAL_SPECLINES_NAME_SIIBLUE;
+    case GAL_SPECLINES_NIIRED:           return GAL_SPECLINES_NAME_NIIRED;
+    case GAL_SPECLINES_NII:              return GAL_SPECLINES_NAME_NII;
+    case GAL_SPECLINES_HALPHA:           return GAL_SPECLINES_NAME_HALPHA;
+    case GAL_SPECLINES_NIIBLUE:          return GAL_SPECLINES_NAME_NIIBLUE;
+    case GAL_SPECLINES_OIIIRED:          return GAL_SPECLINES_NAME_OIIIRED;
+    case GAL_SPECLINES_OIII:             return GAL_SPECLINES_NAME_OIII;
+    case GAL_SPECLINES_OIIIBLUE:         return GAL_SPECLINES_NAME_OIIIBLUE;
+    case GAL_SPECLINES_HBETA:            return GAL_SPECLINES_NAME_HBETA;
+    case GAL_SPECLINES_HEIIRED:          return GAL_SPECLINES_NAME_HEIIRED;
+    case GAL_SPECLINES_HGAMMA:           return GAL_SPECLINES_NAME_HGAMMA;
+    case GAL_SPECLINES_HDELTA:           return GAL_SPECLINES_NAME_HDELTA;
+    case GAL_SPECLINES_HEPSILON:         return GAL_SPECLINES_NAME_HEPSILON;
+    case GAL_SPECLINES_NEIII:            return GAL_SPECLINES_NAME_NEIII;
+    case GAL_SPECLINES_OIIRED:           return GAL_SPECLINES_NAME_OIIRED;
+    case GAL_SPECLINES_OII:              return GAL_SPECLINES_NAME_OII;
+    case GAL_SPECLINES_OIIBLUE:          return GAL_SPECLINES_NAME_OIIBLUE;
+    case GAL_SPECLINES_BLIMIT:           return GAL_SPECLINES_NAME_BLIMIT;
+    case GAL_SPECLINES_MGIIRED:          return GAL_SPECLINES_NAME_MGIIRED;
+    case GAL_SPECLINES_MGII:             return GAL_SPECLINES_NAME_MGII;
+    case GAL_SPECLINES_MGIIBLUE:         return GAL_SPECLINES_NAME_MGIIBLUE;
+    case GAL_SPECLINES_CIIIRED:          return GAL_SPECLINES_NAME_CIIIRED;
+    case GAL_SPECLINES_CIII:             return GAL_SPECLINES_NAME_CIII;
+    case GAL_SPECLINES_CIIIBLUE:         return GAL_SPECLINES_NAME_CIIIBLUE;
+    case GAL_SPECLINES_HEIIBLUE:         return GAL_SPECLINES_NAME_HEIIBLUE;
+    case GAL_SPECLINES_LYALPHA:          return GAL_SPECLINES_NAME_LYALPHA;
+    case GAL_SPECLINES_LYLIMIT:          return GAL_SPECLINES_NAME_LYLIMIT;
+    default:                           return NULL;
+    }
+  return NULL;
+}
+
+
+
+
+
+/* Return the code of the given line name. */
+int
+gal_speclines_line_code(char *name)
+{
+  if( !strcmp(name, GAL_SPECLINES_NAME_SIIRED) )
+    return GAL_SPECLINES_SIIRED;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_SII) )
+    return GAL_SPECLINES_SII;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_SIIBLUE) )
+    return GAL_SPECLINES_SIIBLUE;
+  if( !strcmp(name, GAL_SPECLINES_NAME_NIIRED) )
+    return GAL_SPECLINES_NIIRED;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_NII) )
+    return GAL_SPECLINES_NII;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_HALPHA) )
+    return GAL_SPECLINES_HALPHA;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_NIIBLUE) )
+    return GAL_SPECLINES_NIIBLUE;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_OIIIRED) )
+    return GAL_SPECLINES_OIIIRED;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_OIII) )
+    return GAL_SPECLINES_OIII;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_OIIIBLUE) )
+    return GAL_SPECLINES_OIIIBLUE;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_HBETA) )
+    return GAL_SPECLINES_HBETA;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_HEIIRED) )
+    return GAL_SPECLINES_HEIIRED;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_HGAMMA) )
+    return GAL_SPECLINES_HGAMMA;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_HDELTA) )
+    return GAL_SPECLINES_HDELTA;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_HEPSILON) )
+    return GAL_SPECLINES_HEPSILON;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_NEIII) )
+    return GAL_SPECLINES_NEIII;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_OIIRED) )
+    return GAL_SPECLINES_OIIRED;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_OII) )
+    return GAL_SPECLINES_OII;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_OIIBLUE) )
+    return GAL_SPECLINES_OIIBLUE;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_BLIMIT) )
+    return GAL_SPECLINES_BLIMIT;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_MGIIRED) )
+    return GAL_SPECLINES_MGIIRED;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_MGII) )
+    return GAL_SPECLINES_MGII;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_MGIIBLUE) )
+    return GAL_SPECLINES_MGIIBLUE;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_CIIIRED) )
+    return GAL_SPECLINES_CIIIRED;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_CIII) )
+    return GAL_SPECLINES_CIII;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_CIIIBLUE) )
+    return GAL_SPECLINES_CIIIBLUE;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_HEIIBLUE) )
+    return GAL_SPECLINES_HEIIBLUE;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_LYALPHA) )
+    return GAL_SPECLINES_LYALPHA;
+  else if( !strcmp(name, GAL_SPECLINES_NAME_LYLIMIT) )
+    return GAL_SPECLINES_LYLIMIT;
+  else return GAL_SPECLINES_INVALID;
+  return GAL_SPECLINES_INVALID;
+}
+
+
+
+
+
+/* Return the wavelength (in Angstroms) of given line. */
+double
+gal_speclines_line_angstrom(int linecode)
+{
+  switch(linecode)
+    {
+    case GAL_SPECLINES_SIIRED:        return GAL_SPECLINES_ANGSTROM_SIIRED;
+    case GAL_SPECLINES_SII:           return GAL_SPECLINES_ANGSTROM_SII;
+    case GAL_SPECLINES_SIIBLUE:       return GAL_SPECLINES_ANGSTROM_SIIBLUE;
+    case GAL_SPECLINES_NIIRED:        return GAL_SPECLINES_ANGSTROM_NIIRED;
+    case GAL_SPECLINES_NII:           return GAL_SPECLINES_ANGSTROM_NII;
+    case GAL_SPECLINES_HALPHA:        return GAL_SPECLINES_ANGSTROM_HALPHA;
+    case GAL_SPECLINES_NIIBLUE:       return GAL_SPECLINES_ANGSTROM_NIIBLUE;
+    case GAL_SPECLINES_OIIIRED:       return GAL_SPECLINES_ANGSTROM_OIIIRED;
+    case GAL_SPECLINES_OIII:          return GAL_SPECLINES_ANGSTROM_OIII;
+    case GAL_SPECLINES_OIIIBLUE:      return GAL_SPECLINES_ANGSTROM_OIIIBLUE;
+    case GAL_SPECLINES_HBETA:         return GAL_SPECLINES_ANGSTROM_HBETA;
+    case GAL_SPECLINES_HEIIRED:       return GAL_SPECLINES_ANGSTROM_HEIIRED;
+    case GAL_SPECLINES_HGAMMA:        return GAL_SPECLINES_ANGSTROM_HGAMMA;
+    case GAL_SPECLINES_HDELTA:        return GAL_SPECLINES_ANGSTROM_HDELTA;
+    case GAL_SPECLINES_HEPSILON:      return GAL_SPECLINES_ANGSTROM_HEPSILON;
+    case GAL_SPECLINES_NEIII:         return GAL_SPECLINES_ANGSTROM_NEIII;
+    case GAL_SPECLINES_OIIRED:        return GAL_SPECLINES_ANGSTROM_OIIRED;
+    case GAL_SPECLINES_OII:           return GAL_SPECLINES_ANGSTROM_OII;
+    case GAL_SPECLINES_OIIBLUE:       return GAL_SPECLINES_ANGSTROM_OIIBLUE;
+    case GAL_SPECLINES_BLIMIT:        return GAL_SPECLINES_ANGSTROM_BLIMIT;
+    case GAL_SPECLINES_MGIIRED:       return GAL_SPECLINES_ANGSTROM_MGIIRED;
+    case GAL_SPECLINES_MGII:          return GAL_SPECLINES_ANGSTROM_MGII;
+    case GAL_SPECLINES_MGIIBLUE:      return GAL_SPECLINES_ANGSTROM_MGIIBLUE;
+    case GAL_SPECLINES_CIIIRED:       return GAL_SPECLINES_ANGSTROM_CIIIRED;
+    case GAL_SPECLINES_CIII:          return GAL_SPECLINES_ANGSTROM_CIII;
+    case GAL_SPECLINES_CIIIBLUE:      return GAL_SPECLINES_ANGSTROM_CIIIBLUE;
+    case GAL_SPECLINES_HEIIBLUE:      return GAL_SPECLINES_ANGSTROM_HEIIBLUE;
+    case GAL_SPECLINES_LYALPHA:       return GAL_SPECLINES_ANGSTROM_LYALPHA;
+    case GAL_SPECLINES_LYLIMIT:       return GAL_SPECLINES_ANGSTROM_LYLIMIT;
+    default:
+      error(EXIT_FAILURE, 0, "%s: `%d' not recognized line identifier",
+            __func__, linecode);
+    }
+  return NAN;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*********************************************************************/
+/*************             Redshifted lines            ***************/
+/*********************************************************************/
+double
+gal_speclines_line_redshift(double obsline, double restline)
+{
+  return (obsline/restline)-1;
+}
+
+
+
+
+
+double
+gal_speclines_line_redshift_code(double obsline, int linecode)
+{
+  double restline=gal_speclines_line_angstrom(linecode);
+  return (obsline/restline)-1;
+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]