[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master c6d8a2d: CosmicCalculator: --listlines option
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master c6d8a2d: CosmicCalculator: --listlines option to help in remembering line names |
Date: |
Wed, 4 Dec 2019 14:25:38 -0500 (EST) |
branch: master
commit c6d8a2d6efcffa02c8bbc8a1eed26d31aee046a7
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
CosmicCalculator: --listlines option to help in remembering line names
Until now, when using CosmicCalculator with spectral lines, it was hard to
remember the exact line name used (you had to go to the proper section of
the manual).
With this commit CosmicCalculator now has the `--listlines' option that
will list all the spectral lines that Gnuastro's spectra library
recognizes. Maybe later as more lines are added, we can specify ranges like
(UV, visible, IR or etc). But for now, there aren't too many.
---
NEWS | 6 ++++++
bin/cosmiccal/args.h | 20 ++++++++++++++++++++
bin/cosmiccal/main.h | 1 +
bin/cosmiccal/ui.c | 27 +++++++++++++++++++++++++++
bin/cosmiccal/ui.h | 1 +
doc/gnuastro.texi | 8 ++++++++
lib/gnuastro/speclines.h | 10 +++++++---
7 files changed, 70 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index bcc5c73..3db946e 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,12 @@ See the end of the file for license conditions.
** New features
+ CosmicCalculator:
+ --listlines: list the pre-defined spectral line wavelengths and names
+ (which you can use with the `--obsline' and `--lineatz' options). This
+ is convenient when you forget the specific name of the spectral line
+ used within Gnuastro.
+
Fits:
--datasum: Calculate and print the given HDU's "datasum" to stdout.
diff --git a/bin/cosmiccal/args.h b/bin/cosmiccal/args.h
index 1876746..912a4db 100644
--- a/bin/cosmiccal/args.h
+++ b/bin/cosmiccal/args.h
@@ -114,6 +114,26 @@ struct argp_option program_options[] =
+
+ /* Output options */
+ {
+ "listlines",
+ UI_KEY_LISTLINES,
+ 0,
+ 0,
+ "List known spectral lines.",
+ GAL_OPTIONS_GROUP_OUTPUT,
+ &p->listlines,
+ GAL_OPTIONS_NO_ARG_TYPE,
+ GAL_OPTIONS_RANGE_0_OR_1,
+ GAL_OPTIONS_NOT_MANDATORY,
+ GAL_OPTIONS_NOT_SET
+ },
+
+
+
+
+
{
0, 0, 0, 0,
"Specific calculations",
diff --git a/bin/cosmiccal/main.h b/bin/cosmiccal/main.h
index 0801aa6..3dbe74c 100644
--- a/bin/cosmiccal/main.h
+++ b/bin/cosmiccal/main.h
@@ -52,6 +52,7 @@ struct cosmiccalparams
double omatter; /* Current matter density. */
double oradiation; /* Current radiation density. */
gal_data_t *obsline; /* Observed wavelength of a line. */
+ uint8_t listlines; /* List the known spectral lines. */
/* Outputs. */
gal_list_i32_t *specific; /* Codes for single row calculations. */
diff --git a/bin/cosmiccal/ui.c b/bin/cosmiccal/ui.c
index 0340ae7..665fa54 100644
--- a/bin/cosmiccal/ui.c
+++ b/bin/cosmiccal/ui.c
@@ -417,10 +417,37 @@ ui_read_check_only_options(struct cosmiccalparams *p)
/*************** Preparations *******************/
/**************************************************************/
static void
+ui_list_lines(struct cosmiccalparams *p)
+{
+ size_t i;
+
+ /* First print the metadata */
+ printf("# Column 1: Wavelength [Angstrom,f32] Pre-defined line
wavelength.\n");
+ printf("# Column 2: Name [name, str10] Pre-defined line name.\n");
+
+ /* Print the line information. */
+ for(i=1;i<GAL_SPECLINES_NUMBER;++i)
+ printf("%-15g%s\n", gal_speclines_line_angstrom(i),
+ gal_speclines_line_name(i));
+
+ /* Abort the program. */
+ exit(EXIT_SUCCESS);
+}
+
+
+
+
+
+static void
ui_preparations(struct cosmiccalparams *p)
{
double *obsline = p->obsline ? p->obsline->array : NULL;
+ /* If `--listlines' is given, print them and abort, don't continue with
+ the preparations. */
+ if(p->listlines)
+ ui_list_lines(p);
+
/* If `--obsline' has been given, set the redshift based on it. */
if(p->obsline)
p->redshift = ( (p->obsline->status==GAL_SPECLINES_INVALID)
diff --git a/bin/cosmiccal/ui.h b/bin/cosmiccal/ui.h
index 0b36e52..a588b05 100644
--- a/bin/cosmiccal/ui.h
+++ b/bin/cosmiccal/ui.h
@@ -72,6 +72,7 @@ enum option_keys_enum
/* Only with long version (start with a value 1000, the rest will be set
automatically). */
+ UI_KEY_LISTLINES = 1000,
};
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 737ca98..2249976 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -17226,6 +17226,14 @@ Matter (including massive neutrinos) density divided
by the critical density in
@itemx --oradiation=FLT
Radiation density divided by the critical density in the current Universe
(@mymath{\Omega_{r,0}}).
+@item --listlines
+List the pre-defined spectral line wavelengths and names on standard output,
then abort CosmicCalculator.
+When this option is given, other operations on the command-line will be
ignored.
+This is convenient when you forget the specific name of the spectral line used
within Gnuastro.
+
+The format of the list is a two-column table, with Gnuastro's text table
format (see @ref{Gnuastro text table format}).
+These names can be used with the options that deal with spectral lines, for
example @option{--obsline} (below) and @option{--lineatz}
(@ref{CosmicCalculator specific calculations}).
+
@item -O STR/FLT,FLT
@itemx --obsline=STR/FLT,FLT
@cindex Rest-frame wavelength
diff --git a/lib/gnuastro/speclines.h b/lib/gnuastro/speclines.h
index add541d..9d52b15 100644
--- a/lib/gnuastro/speclines.h
+++ b/lib/gnuastro/speclines.h
@@ -46,7 +46,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
__BEGIN_C_DECLS /* From C++ preparations */
-/* Spectral line internal codes. */
+/* Spectral line internal codes (SORT BY WAVELENGTH). */
enum gal_speclines_line_codes
{
GAL_SPECLINES_INVALID=0,
@@ -79,10 +79,14 @@ enum gal_speclines_line_codes
GAL_SPECLINES_HEIIBLUE,
GAL_SPECLINES_LYALPHA,
GAL_SPECLINES_LYLIMIT,
+
+ /* This should be the last element (to keep the total number of
+ lines). */
+ GAL_SPECLINES_NUMBER,
};
-/* Spectral lines wavelengths in Angstroms. */
+/* Spectral lines wavelengths in Angstroms (SORT BY WAVELENGTH). */
#define GAL_SPECLINES_ANGSTROM_SIIRED 6731
#define GAL_SPECLINES_ANGSTROM_SII 6724
#define GAL_SPECLINES_ANGSTROM_SIIBLUE 6717
@@ -114,7 +118,7 @@ enum gal_speclines_line_codes
#define GAL_SPECLINES_ANGSTROM_LYLIMIT 912
-/* Spectral line name strings. */
+/* Spectral line name strings (SORT BY WAVELENGTH). */
#define GAL_SPECLINES_NAME_SIIRED "siired"
#define GAL_SPECLINES_NAME_SII "sii"
#define GAL_SPECLINES_NAME_SIIBLUE "siiblue"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master c6d8a2d: CosmicCalculator: --listlines option to help in remembering line names,
Mohammad Akhlaghi <=