[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 369f6bd9: `Library (units.h): new function to
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 369f6bd9: `Library (units.h): new function to convert jy to wavelength flux.den |
Date: |
Mon, 1 Jul 2024 17:01:49 -0400 (EDT) |
branch: master
commit 369f6bd91435d6bf317734546bb3c23dc4b5f777
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
`Library (units.h): new function to convert jy to wavelength flux.den
Until now, we didn't have a function to derive wavelength flux density
within Gnuastro.
With this commit, a new function has been added in the units library (and
from there, the Arithmetic program).
---
NEWS | 6 ++++++
doc/gnuastro.texi | 23 ++++++++++++++++++++++-
lib/arithmetic.c | 13 +++++++++++--
lib/gnuastro/arithmetic.h | 1 +
lib/gnuastro/units.h | 3 +++
lib/units.c | 10 ++++++++++
6 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index aba6ab5e..1fe6e8cb 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,9 @@ See the end of the file for license conditions.
- New operators (also avaialble in "Column Arithmetic" of the Table
progam):
+ - jy-to-wavelength-flux-density: converts Janskys to wavelength flux
+ density (erg/cm^2/s/Å) at the given wavelength.
+
- filter-madclip-mean: filter/smooth the input using MAD-clipped mean.
- filter-madclip-median: filter/smooth the input using MAD-clipped
@@ -93,6 +96,9 @@ See the end of the file for license conditions.
- gal_statistics_concentration: measure the concentration of values around
the median; see the book for the details.
+- gal_units_jy_to_wavelength_flux_density: convert Janskys to wavelength
+ flux density.
+
- gal_units_zeropoint_change: change the zero point of the input data set
to an output zero point.
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index d37a5b08..9d968bc0 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -21908,6 +21908,27 @@ Convert AB magnitudes to Janskys, see @ref{Brightness
flux magnitude}.
@item jy-to-mag
Convert Janskys to AB magnitude, see @ref{Brightness flux magnitude}.
+@item jy-to-wavelength-flux-density
+@cindex Jansky (Jy)
+@cindex Wavelength flux density
+@cindex Flux density (wavelength)
+Convert Janskys to wavelength flux density (in units of
@mymath{erg/cm^2/s/\AA}) at a certain wavelength (given in units of Angstroms).
+Recall that Jansky is also a unit of flux density, but it is in units of
frequency (@mymath{erg/cm^2/s/Hz}).
+For example at the wavelength of 5556, Vega's frequency flux density is 3500
Janskys.
+To convert this to wavelength flux density, you can use this command:
+
+@example
+$ astarithmetic 3.5e3 5556 jy-to-wavelength-flux-density
+@end example
+
+If your input values are in units of counts or magnitudes, you can use the
@code{mag-to-jy} or @code{count-to-jy} operators described above.
+For example, if you want the wavelength flux density of a source with
magnitude 21 in the J-PAS J0660 filter (centered at approximately
@mymath{6600\AA}), you can use this command:
+
+@example
+$ astarithmetic 21 mag-to-jy 6600 \
+ jy-to-wavelength-flux-density
+@end example
+
@item au-to-pc
@cindex Parsecs
@cindex Astronomical Units (AU)
@@ -29380,7 +29401,7 @@ Using the zero point magnitude (@mymath{Z}), we can
write the magnitude relation
@dispmath{m = -2.5\log_{10}(B) + Z}
-@cindex Janskys (Jy)
+@cindex Jansky (Jy)
@cindex AB magnitude
@cindex Magnitude, AB
Gnuastro has an installed script to estimate the zero point of any image, see
@ref{Zero point estimation} (it contains practical tutorials to help you get
started fast).
diff --git a/lib/arithmetic.c b/lib/arithmetic.c
index 519e5751..4cafe8eb 100644
--- a/lib/arithmetic.c
+++ b/lib/arithmetic.c
@@ -3025,8 +3025,8 @@ arithmetic_function_binary_flt(int operator, int flags,
gal_data_t *il,
if( il->size==0 || il->array==NULL || ir->size==0 || ir->array==NULL )
{
if(il->array==0 || il->array==NULL)
- { if(flags & GAL_ARITHMETIC_FLAG_FREE) gal_data_free(ir); return il;}
- else {if(flags & GAL_ARITHMETIC_FLAG_FREE) gal_data_free(il); return ir;}
+ { if(flags&GAL_ARITHMETIC_FLAG_FREE)gal_data_free(ir);return il;}
+ else {if(flags&GAL_ARITHMETIC_FLAG_FREE)gal_data_free(il);return ir;}
}
@@ -3095,6 +3095,9 @@ arithmetic_function_binary_flt(int operator, int flags,
gal_data_t *il,
BINFUNC_F_OPERATOR_SET( gal_units_counts_to_jy, +0 ); break;
case GAL_ARITHMETIC_OP_JY_TO_COUNTS:
BINFUNC_F_OPERATOR_SET( gal_units_jy_to_counts, +0 ); break;
+ case GAL_ARITHMETIC_OP_JY_TO_WAVELENGTH_FLUX_DENSITY:
+ BINFUNC_F_OPERATOR_SET( gal_units_jy_to_wavelength_flux_density,
+ +0 ); break;
case GAL_ARITHMETIC_OP_COUNTS_TO_NANOMAGGY:
BINFUNC_F_OPERATOR_SET( gal_units_counts_to_nanomaggy, +0 ); break;
case GAL_ARITHMETIC_OP_NANOMAGGY_TO_COUNTS:
@@ -4108,6 +4111,9 @@ gal_arithmetic_set_operator(char *string, size_t
*num_operands)
{ op=GAL_ARITHMETIC_OP_LY_TO_AU; *num_operands=1; }
else if( !strcmp(string, "au-to-ly"))
{ op=GAL_ARITHMETIC_OP_AU_TO_LY; *num_operands=1; }
+ else if (!strcmp(string, "jy-to-wavelength-flux-density"))
+ { op=GAL_ARITHMETIC_OP_JY_TO_WAVELENGTH_FLUX_DENSITY;
+ *num_operands=2; }
/* Celestial coordinate conversions. */
else if (!strcmp(string, "eq-b1950-to-eq-j2000"))
@@ -4455,6 +4461,8 @@ gal_arithmetic_operator_string(int operator)
case GAL_ARITHMETIC_OP_NANOMAGGY_TO_COUNTS: return "nanomaggy-to-counts";
case GAL_ARITHMETIC_OP_MAG_TO_JY: return "mag-to-jy";
case GAL_ARITHMETIC_OP_JY_TO_MAG: return "jy-to-mag";
+ case GAL_ARITHMETIC_OP_JY_TO_WAVELENGTH_FLUX_DENSITY:
+ return "jy-to-wavelength-flux-density";
case GAL_ARITHMETIC_OP_AU_TO_PC: return "au-to-pc";
case GAL_ARITHMETIC_OP_PC_TO_AU: return "pc-to-au";
case GAL_ARITHMETIC_OP_LY_TO_PC: return "ly-to-pc";
@@ -4748,6 +4756,7 @@ gal_arithmetic(int operator, size_t numthreads, int
flags, ...)
case GAL_ARITHMETIC_OP_MAG_TO_COUNTS:
case GAL_ARITHMETIC_OP_NANOMAGGY_TO_COUNTS:
case GAL_ARITHMETIC_OP_COUNTS_TO_NANOMAGGY:
+ case GAL_ARITHMETIC_OP_JY_TO_WAVELENGTH_FLUX_DENSITY:
d1 = va_arg(va, gal_data_t *);
d2 = va_arg(va, gal_data_t *);
out=arithmetic_function_binary_flt(operator, flags, d1, d2);
diff --git a/lib/gnuastro/arithmetic.h b/lib/gnuastro/arithmetic.h
index c8fb1ff2..53600bca 100644
--- a/lib/gnuastro/arithmetic.h
+++ b/lib/gnuastro/arithmetic.h
@@ -157,6 +157,7 @@ enum gal_arithmetic_operators
GAL_ARITHMETIC_OP_JY_TO_COUNTS, /* Janskys to Counts (AB zeropoint). */
GAL_ARITHMETIC_OP_MAG_TO_JY, /* Magnitude to Janskys. */
GAL_ARITHMETIC_OP_JY_TO_MAG, /* Janskys to Magnitude. */
+ GAL_ARITHMETIC_OP_JY_TO_WAVELENGTH_FLUX_DENSITY, /* Janskys to f_\lambda. */
GAL_ARITHMETIC_OP_ZEROPOINT_CHANGE, /* Change the zero point. */
GAL_ARITHMETIC_OP_COUNTS_TO_NANOMAGGY,/* Counts to SDSS nanomaggies. */
GAL_ARITHMETIC_OP_NANOMAGGY_TO_COUNTS,/* SDSS nanomaggies to counts. */
diff --git a/lib/gnuastro/units.h b/lib/gnuastro/units.h
index c72d4c13..1e33df35 100644
--- a/lib/gnuastro/units.h
+++ b/lib/gnuastro/units.h
@@ -112,6 +112,9 @@ gal_units_nanomaggy_to_counts(double counts, double
zeropoint_ab);
double
gal_units_jy_to_mag(double jy);
+double
+gal_units_jy_to_wavelength_flux_density(double jy, double wavelength);
+
double
gal_units_mag_to_jy(double mag);
diff --git a/lib/units.c b/lib/units.c
index 2e255852..3776f24f 100644
--- a/lib/units.c
+++ b/lib/units.c
@@ -514,6 +514,16 @@ gal_units_jy_to_mag(double jy)
+double
+gal_units_jy_to_wavelength_flux_density(double jy, double angstrom)
+{
+ return jy * 2.99792458e-05 / (angstrom*angstrom);
+}
+
+
+
+
+
double
gal_units_mag_to_jy(double mag)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master 369f6bd9: `Library (units.h): new function to convert jy to wavelength flux.den,
Mohammad Akhlaghi <=