| Title: | Cosmic Insights: Statistical Frameworks for Astronomers |
|---|---|
| Description: | A comprehensive toolkit for astronomical and cosmological computations. Provides functions for angular coordinate conversions (degrees, hours-minutes-seconds, degrees-minutes-seconds, and radians), Julian Days and the conversion of equatorial (right ascension, declination) to horizontal (altitude, azimuth) coordinates, access to fundamental physical constants ('CODATA' 2018), queries to the Gaia Catalogue of Nearby Stars through the Gaia Archive TAP (Table Access Protocol) service, a 'Lambda-CDM' cosmology model with comoving, luminosity and angular-diameter distances, cosmic time and the age of the universe, early-universe thermal physics including photon density, 'Saha' equation solutions, and a full thermal-cosmology module covering the Hubble rate in the radiation-dominated era, effective relativistic degrees of freedom, entropy density, equilibrium yields, the Boltzmann relic-abundance ('pebble') equation for WIMP freeze-out, the freeze-out temperature solver, and the Peebles equation for hydrogen recombination. Also includes the Drake equation for estimating the number of communicating extraterrestrial civilisations in the Milky Way. |
| Authors: | Samrit Pramanik [aut, cre] (ORCID: <https://orcid.org/0000-0003-2055-9007>), Kazi Abu Rousan [aut] (ORCID: <https://orcid.org/0000-0002-7906-2030>) |
| Maintainer: | Samrit Pramanik <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.0 |
| Built: | 2026-10-25 16:40:05 UTC |
| Source: | https://github.com/samrit2442/astronomr |
A comprehensive toolkit for astronomical and cosmological computations. Provides functions for angular coordinate conversions (degrees, hours-minutes-seconds, degrees-minutes-seconds, and radians), Julian Days and the conversion of equatorial (right ascension, declination) to horizontal (altitude, azimuth) coordinates, access to fundamental physical constants (CODATA 2018), queries to the Gaia Catalogue of Nearby Stars through the Gaia Archive TAP (Table Access Protocol) service, a Lambda-CDM cosmology model with comoving, luminosity and angular-diameter distances, cosmic time and the age of the universe, early-universe thermal physics including photon density, 'Saha' equation solutions, and a full thermal-cosmology module covering the Hubble rate in the radiation-dominated era, effective relativistic degrees of freedom, entropy density, equilibrium yields, the Boltzmann relic-abundance ('pebble') equation for WIMP freeze-out, the freeze-out temperature solver, and the Peebles equation for hydrogen recombination. Also includes the Drake equation for estimating the number of communicating extraterrestrial civilisations in the Milky Way.
deg_to_dms, dms_to_deg,
deg_to_hms and hms_to_deg convert between
decimal degrees and degrees-minutes-seconds or hours-minutes-seconds;
deg_to_rad and rad_to_deg convert between
degrees and radians.
julian_day gives the Julian Day of a date-time, and
radec_to_altaz converts right ascension and declination to
altitude and azimuth for an observer at a given place and time.
constants_df is a table of physical constants and
constant_value looks a constant up by name.
get_gaia_data queries the Gaia archive TAP service (an
internet connection is required).
cosmology_model builds a cosmological model that the other
functions take as their cosmo argument:
age_of_universe, cosmic_time,
comoving_distance, luminosity_distance,
angular_diameter_distance,
transverse_comoving_distance,
radius_of_curvature, hubble_distance and
hubble_ratio. Distances default to Mpc and times to Gyr.
redshift_to_scale_factor and
scale_factor_to_redshift convert between redshift and scale
factor; km_to_Mpc and Mpc_to_km convert
distances.
Photon energy and number densities as functions of temperature or redshift
(photon_energy_density_fn_T,
photon_energy_density_fn_z,
photon_number_density_fn_T,
photon_number_density_fn_z); hydrogen ionization from the
Saha equation (Saha_Xe, soln_saha); the
radiation-era Hubble rate and thermal bath (hubble_radiation,
g_star_eff, entropy_density,
equilibrium_number_density, equilibrium_yield);
thermal relic freeze-out (boltzmann_pebble_rhs,
solve_relic_abundance, freeze_out_xf); and
hydrogen recombination with the Peebles equation
(peebles_rhs).
drake_equation estimates the number of communicating
civilizations in the Milky Way.
Maintainer: Samrit Pramanik [email protected] (ORCID)
Authors:
Samrit Pramanik [email protected] (ORCID)
Kazi Abu Rousan [email protected] (ORCID)
Useful links:
Report bugs at https://github.com/samrit2442/astronomR/issues
Returns , the right-hand side of the Boltzmann equation
governing the evolution of the comoving yield of a
thermally produced relic species:
boltzmann_pebble_rhs( x, Y, m_GeV, sigmav_GeV2, g_dof = 2, g_star_val = NULL, g_star_S_val = NULL )boltzmann_pebble_rhs( x, Y, m_GeV, sigmav_GeV2, g_dof = 2, g_star_val = NULL, g_star_S_val = NULL )
x |
Numeric. Dimensionless inverse temperature
|
Y |
Numeric. Current yield |
m_GeV |
Numeric. Particle mass in GeV. |
sigmav_GeV2 |
Numeric. Thermally averaged annihilation cross
section |
g_dof |
Integer. Internal degrees of freedom. Default 2. |
g_star_val |
Numeric. |
g_star_S_val |
Numeric. |
This equation is commonly called the "pebble equation" in thermal dark-matter / freeze-out literature because the relic density drops away from equilibrium like a stone and then plateaus.
The variable is used as the time variable so
that the equation is well-behaved through freeze-out
(). is evaluated with
and both and with
.
Numeric. (dimensionless).
Kolb & Turner (1990), Eq. (5.42). Gondolo & Gelmini, Nucl. Phys. B 360 (1991) 145.
solve_relic_abundance, freeze_out_xf,
equilibrium_yield, g_star_eff
sigmav <- 2.2e-9 # GeV^-2 (typical WIMP value) Y_eq <- equilibrium_yield(x = 20, m_GeV = 100) boltzmann_pebble_rhs(x = 20, Y = Y_eq, m_GeV = 100, sigmav_GeV2 = sigmav) # Above equilibrium the yield is driven back down boltzmann_pebble_rhs(x = 20, Y = 10 * Y_eq, m_GeV = 100, sigmav_GeV2 = sigmav)sigmav <- 2.2e-9 # GeV^-2 (typical WIMP value) Y_eq <- equilibrium_yield(x = 20, m_GeV = 100) boltzmann_pebble_rhs(x = 20, Y = Y_eq, m_GeV = 100, sigmav_GeV2 = sigmav) # Above equilibrium the yield is driven back down boltzmann_pebble_rhs(x = 20, Y = 10 * Y_eq, m_GeV = 100, sigmav_GeV2 = sigmav)
Looks up a physical constant in constants_df by name or
symbol and returns its value and unit in SI or natural units.
constant_value(constant_name, unit = c("SI", "Natural"))constant_value(constant_name, unit = c("SI", "Natural"))
constant_name |
Character string. Name, symbol or part of the name of
the constant, e.g. |
unit |
Character. Unit system of the result: |
Matching ignores case and leading or trailing white space, and is tried
in three steps: an exact match on the full name (e.g.
"Boltzmann Constant"), then an exact match on the symbol (e.g.
"k"), then a partial match on the name (e.g. "planck"). The
first step that finds anything decides the result: a single match is
returned, and several matches are an error that lists them. The partial
match looks for constant_name as a fixed string, not a regular
expression, so characters such as ".", "+" or "("
have no special meaning. The spelling "Boltzman" used for two
constants before astronomR 0.4.0 is still accepted.
Natural units are
with energies in eV (see constants_df). The Avogadro
constant, the Faraday constant and the molar gas constant have no
natural-unit value: for these, unit = "Natural" gives NA for
both value and unit, with a warning.
A list with elements name (character, full name of the
constant), value (numeric) and unit (character, unit of
value; "-" if dimensionless). value and unit
are NA, with a warning, when the constant has no value in the
requested unit system.
constants_df for the full table.
constant_value("speed of light") constant_value("k") # by symbol constant_value("planck", unit = "Natural") # h = 2 pi constant_value("electron mass", unit = "Natural") # Several partial matches are an error that lists them try(constant_value("electron")) # Mole-based constants have no natural-unit value (NA, with a warning) constant_value("Avogadro", unit = "Natural")constant_value("speed of light") constant_value("k") # by symbol constant_value("planck", unit = "Natural") # h = 2 pi constant_value("electron mass", unit = "Natural") # Several partial matches are an error that lists them try(constant_value("electron")) # Mole-based constants have no natural-unit value (NA, with a warning) constant_value("Avogadro", unit = "Natural")
A table of 19 fundamental physical constants with their CODATA 2018 recommended values in SI units and in natural units.
constants_dfconstants_df
A tibble with 19 rows and 6 columns:
Character. Full name of the constant, e.g.
"Planck Constant".
Character. Short symbol, e.g. "h".
Numeric. CODATA 2018 value in SI units.
Character. SI unit of value_SI; "-" means
dimensionless.
Numeric. Value in natural units with
(Heaviside-Lorentz) and energies in eV; see Details. NA for the
Avogadro constant, the Faraday constant and the molar gas constant,
which are defined per mole and have no natural-unit value.
Character. Unit of value_Natural:
"-" (dimensionless), "eV" or "eV^(-2)";
NA where value_Natural is NA.
The SI values are the CODATA 2018 values, published by NIST in May 2019.
The speed of light has been exact since 1983. Since the revision
of the SI on 20 May 2019, the Planck constant , the elementary
charge , the Boltzmann constant and the Avogadro constant
are exact as well, and so are the constants derived from these
five alone: the molar gas constant , the Faraday constant
, the Stefan-Boltzmann constant
,
the magnetic flux quantum , the
conductance quantum and the electron
volt ( joules). The magnetic constant is now
measured and is no longer exactly
N A^-2.
The natural-unit values use
(the Heaviside-Lorentz convention), with energies in electron volts. In
this system and the elementary charge is
, about 0.303, so that
,
and . Masses are given as rest
energies in eV, and the Rydberg constant as the energy
in eV (the Rydberg energy
, about 13.6 eV, is times
larger). The gravitational constant becomes
in eV^-2, where
is the Planck mass.
A tibble; see the Format section.
CODATA 2018 recommended values of the fundamental physical constants: E. Tiesinga, P. J. Mohr, D. B. Newell and B. N. Taylor (2021), Rev. Mod. Phys. 93, 025010. https://physics.nist.gov/cuu/Constants/
constant_value to look up a single constant.
constants_df # The mole-based constants have no natural-unit value constants_df[is.na(constants_df$value_Natural), c("name", "value_SI")]constants_df # The mole-based constants have no natural-unit value constants_df[is.na(constants_df$value_Natural), c("name", "value_SI")]
cosmic_time() gives the age of the universe at redshift z:
the proper time since the big bang () for a model created
by cosmology_model,
age_of_universe() is the age today, cosmic_time(cosmo, 0).
cosmic_time(cosmo, z, unit = c("Gyr", "year")) age_of_universe(cosmo, unit = c("Gyr", "year"))cosmic_time(cosmo, z, unit = c("Gyr", "year")) age_of_universe(cosmo, unit = c("Gyr", "year"))
cosmo |
A cosmological model created by |
z |
Numeric vector of finite redshifts, each greater than -1.
|
unit |
Unit of the result: |
Negative redshifts (-1 < z < 0) give times in the future. The
integral is evaluated numerically with integrate
(relative tolerance 1e-10). The Hubble time
is converted to years with the IAU megaparsec (see Mpc_to_km)
and the Julian year of 365.25 days.
A pure de Sitter model (Omega_m = Omega_r = Omega_k = 0) has no big
bang, so its age is infinite and Inf is returned. An error is raised
if anywhere between the big bang and
z: for example a bouncing model that never had ,
or a future redshift that a recollapsing model never reaches.
Times since the big bang in unit: gigayears (Gyr) by
default, or years. cosmic_time() returns an unnamed numeric vector
with one element per redshift; age_of_universe() returns a single
number.
Hogg, D. W. (1999). Distance measures in cosmology. https://arxiv.org/abs/astro-ph/9905116
cosmology_model, hubble_ratio,
redshift_to_scale_factor, comoving_distance
cosmo <- cosmology_model() age_of_universe(cosmo) age_of_universe(cosmo, unit = "year") cosmic_time(cosmo, c(1100, 10, 1, 0)) # Gyr after the big bang cosmic_time(cosmo, -0.5) # when the universe is twice as bigcosmo <- cosmology_model() age_of_universe(cosmo) age_of_universe(cosmo, unit = "year") cosmic_time(cosmo, c(1100, 10, 1, 0)) # Gyr after the big bang cosmic_time(cosmo, -0.5) # when the universe is twice as big
Distance measures of Hogg (1999) for a model created by
cosmology_model, vectorized over the redshift z.
hubble_distance(): the Hubble distance
comoving_distance(): the line-of-sight comoving distance
with from hubble_ratio.
transverse_comoving_distance(): the transverse comoving
distance . It equals in a flat model; in
an open model ()
and in a closed model ()
luminosity_distance():
.
angular_diameter_distance():
.
radius_of_curvature(): the curvature radius today,
, which
is Inf for a flat model.
hubble_distance(cosmo, unit = c("Mpc", "km")) comoving_distance(cosmo, z, unit = c("Mpc", "km")) transverse_comoving_distance(cosmo, z, unit = c("Mpc", "km")) luminosity_distance(cosmo, z, unit = c("Mpc", "km")) angular_diameter_distance(cosmo, z, unit = c("Mpc", "km")) radius_of_curvature(cosmo, unit = c("Mpc", "km"))hubble_distance(cosmo, unit = c("Mpc", "km")) comoving_distance(cosmo, z, unit = c("Mpc", "km")) transverse_comoving_distance(cosmo, z, unit = c("Mpc", "km")) luminosity_distance(cosmo, z, unit = c("Mpc", "km")) angular_diameter_distance(cosmo, z, unit = c("Mpc", "km")) radius_of_curvature(cosmo, unit = c("Mpc", "km"))
cosmo |
A cosmological model created by |
unit |
Unit of the result: |
z |
Numeric vector of finite, non-negative redshifts. |
The integral for is evaluated numerically with
integrate (relative tolerance 1e-10). An error
is raised if anywhere between 0 and the
largest requested redshift, e.g. beyond the bounce of a bouncing model. In
a closed model is not monotonic: it falls back to zero at
the antipode, where , and is negative beyond it.
A single number for hubble_distance() and
radius_of_curvature(); otherwise an unnamed numeric vector with
one element per redshift. Distances are in unit: megaparsecs (Mpc)
by default, or kilometers (km).
Hogg, D. W. (1999). Distance measures in cosmology. https://arxiv.org/abs/astro-ph/9905116
cosmology_model, hubble_ratio,
cosmic_time, km_to_Mpc
cosmo <- cosmology_model() z <- c(0.1, 0.5, 1, 2) hubble_distance(cosmo) comoving_distance(cosmo, z) transverse_comoving_distance(cosmo, z) # equal to D_C: the model is flat luminosity_distance(cosmo, z) angular_diameter_distance(cosmo, z) luminosity_distance(cosmo, 1, unit = "km") radius_of_curvature(cosmo) # Inf for a flat model open_model <- cosmology_model(Omega_m = 0.3, Omega_Lambda = 0.6, Omega_k = 0.1) radius_of_curvature(open_model) transverse_comoving_distance(open_model, z)cosmo <- cosmology_model() z <- c(0.1, 0.5, 1, 2) hubble_distance(cosmo) comoving_distance(cosmo, z) transverse_comoving_distance(cosmo, z) # equal to D_C: the model is flat luminosity_distance(cosmo, z) angular_diameter_distance(cosmo, z) luminosity_distance(cosmo, 1, unit = "km") radius_of_curvature(cosmo) # Inf for a flat model open_model <- cosmology_model(Omega_m = 0.3, Omega_Lambda = 0.6, Omega_k = 0.1) radius_of_curvature(open_model) transverse_comoving_distance(open_model, z)
Creates a homogeneous Friedmann-Lemaitre-Robertson-Walker (FLRW) model of the universe with matter, radiation, spatial curvature and a cosmological constant, whose expansion rate relative to today is
with km/s/Mpc. The model is the
cosmo argument of hubble_ratio,
cosmic_time and the distance functions such as
comoving_distance. The defaults are the Planck 2015 flat
Lambda-CDM parameters (Planck Collaboration 2016, Table 4, last column),
without radiation.
cosmology_model( h = 0.6774, Omega_m = 0.3089, Omega_Lambda = 0.6911, Omega_r = 0, Omega_k = 0, T_cmb = 2.7255 ) ## S3 method for class 'astronomR_cosmology' print(x, ...)cosmology_model( h = 0.6774, Omega_m = 0.3089, Omega_Lambda = 0.6911, Omega_r = 0, Omega_k = 0, T_cmb = 2.7255 ) ## S3 method for class 'astronomR_cosmology' print(x, ...)
h |
Dimensionless Hubble parameter, |
Omega_m |
Matter density parameter today (non-negative). |
Omega_Lambda |
Cosmological-constant (dark-energy) density parameter today. May be negative. |
Omega_r |
Radiation density parameter today (non-negative). |
Omega_k |
Curvature density parameter today: 0 for a flat, positive for an open and negative for a closed universe. |
T_cmb |
CMB temperature today in kelvin (non-negative). Stored for reference only; it is not used in any calculation. |
x |
An object of class |
... |
Ignored. |
The curvature type follows the sign of Omega_k: "flat"
(Omega_k = 0), "open" (Omega_k > 0) or
"closed" (Omega_k < 0). Omega_k is not derived from
the other parameters: for a consistent model choose it so that
Omega_m + Omega_Lambda + Omega_r + Omega_k = 1, which makes
. A warning is given when this sum differs from 1 by more
than 0.001.
T_cmb is stored and printed for reference only. It does not set
Omega_r, which must be given explicitly (CMB photons alone give
for T_cmb = 2.7255).
cosmology_model() returns a list of class
astronomR_cosmology with elements h, H0 (the Hubble
constant in km/s/Mpc), Omega_m, Omega_Lambda,
Omega_r, Omega_k, T_cmb (in K) and curvature
("flat", "open" or "closed"). The print()
method prints a summary of the model and returns x invisibly.
Planck Collaboration (2016). Planck 2015 results. XIII. Cosmological parameters. Astronomy and Astrophysics, 594, A13. https://arxiv.org/abs/1502.01589
Fixsen, D. J. (2009). The temperature of the cosmic microwave background. The Astrophysical Journal, 707, 916. https://arxiv.org/abs/0911.1955
hubble_ratio, comoving_distance,
luminosity_distance, cosmic_time,
age_of_universe
# Planck 2015 flat Lambda-CDM (the defaults) cosmo <- cosmology_model() cosmo # the same model with radiation cosmology_model(h = 0.6774, Omega_m = 0.3089, Omega_Lambda = 0.6911, Omega_r = 8.4e-5) # an open model: Omega_k = 1 - Omega_m - Omega_Lambda open_model <- cosmology_model(h = 0.7, Omega_m = 0.3, Omega_Lambda = 0.6, Omega_k = 0.1) open_model$curvature# Planck 2015 flat Lambda-CDM (the defaults) cosmo <- cosmology_model() cosmo # the same model with radiation cosmology_model(h = 0.6774, Omega_m = 0.3089, Omega_Lambda = 0.6911, Omega_r = 8.4e-5) # an open model: Omega_k = 1 - Omega_m - Omega_Lambda open_model <- cosmology_model(h = 0.7, Omega_m = 0.3, Omega_Lambda = 0.6, Omega_k = 0.1) open_model$curvature
Converts a decimal degree angle to the Degrees-Minutes-Seconds (DMS) format commonly used in astronomy for expressing declination and other angles.
deg_to_dms(deg, type = c("cat", "mat"), digit = 5)deg_to_dms(deg, type = c("cat", "mat"), digit = 5)
deg |
Numeric vector of angles in decimal degrees. All values must be
between -90 and 90 (the declination range). |
type |
Character string specifying the output format. Options are:
|
digit |
Whole number from 0 to 10: the number of decimal places of
the seconds. Default is |
The angle is rounded once, to the nearest
arcsecond, and then split exactly into degrees, minutes and seconds, so the
minutes and seconds are always below 60: deg_to_dms(10.1) gives 10
degrees, 6 minutes and 0 seconds. Seconds are written in fixed notation
without trailing zeros. The sign is "-" only when the angle is
negative and still non-zero after rounding, so deg_to_dms(-1e-9)
prints +0 degrees.
When type = "cat", prints the DMS string and returns
NULL invisibly. When type = "mat", returns a character
matrix with one row per angle and columns SIGN ("+" or
"-"), DEG (degrees, 0 to 90), MIN (arcminutes, 0 to
59) and SEC (arcseconds, below 60). The row for an NA
angle is all NA.
dms_to_deg for the reverse conversion,
deg_to_hms for right ascension, and
deg_to_rad.
deg_to_dms(45.5042) deg_to_dms(c(10.1, -0.5)) deg_to_dms(-12.5, type = "mat") deg_to_dms(c(10.25, 45.5), type = "mat") # Paste the "mat" columns into strings to convert them back x <- deg_to_dms(c(-0.5, 45.5042), type = "mat") dms_to_deg(paste0(x[, "SIGN"], x[, "DEG"], "d", x[, "MIN"], "m", x[, "SEC"], "s"))deg_to_dms(45.5042) deg_to_dms(c(10.1, -0.5)) deg_to_dms(-12.5, type = "mat") deg_to_dms(c(10.25, 45.5), type = "mat") # Paste the "mat" columns into strings to convert them back x <- deg_to_dms(c(-0.5, 45.5042), type = "mat") dms_to_deg(paste0(x[, "SIGN"], x[, "DEG"], "d", x[, "MIN"], "m", x[, "SEC"], "s"))
Converts a decimal degree angle to Hours-Minutes-Seconds (HMS) format, which is used in astronomy to express Right Ascension (RA).
deg_to_hms(deg, type = c("cat", "mat"), digit = 5)deg_to_hms(deg, type = c("cat", "mat"), digit = 5)
deg |
Numeric vector of angles in decimal degrees. Any finite value is
accepted and wrapped into |
type |
Character string specifying the output format. Options are:
|
digit |
Whole number from 0 to 10: the number of decimal places of
the seconds. Default is |
Any finite angle is first wrapped into degrees, so
-15 gives 23 hours and 375 gives 1 hour (one hour is 15
degrees). The angle is then rounded once, to the nearest
second of time, and split exactly, so the
minutes and seconds are always below 60 and the hours run from 0 to 23 (an
angle that rounds up to 24 hours is shown as 0 hours). Seconds are written
in fixed notation without trailing zeros.
When type = "cat", prints the HMS string and returns
NULL invisibly. When type = "mat", returns a numeric matrix
with one row per angle and columns HRS (hours, 0 to 23),
MIN (minutes of time, 0 to 59) and SEC (seconds of time,
below 60). The row for an NA angle is all NA.
hms_to_deg for the reverse conversion,
deg_to_dms for declination, and deg_to_rad.
deg_to_hms(deg = 45) deg_to_hms(deg = 45, type = "mat") deg_to_hms(deg = 177.74208, digit = 3) deg_to_hms(c(-15, 20, 375)) # The "mat" columns convert straight back x <- deg_to_hms(177.74208, type = "mat") hms_to_deg(x[, "HRS"], x[, "MIN"], x[, "SEC"])deg_to_hms(deg = 45) deg_to_hms(deg = 45, type = "mat") deg_to_hms(deg = 177.74208, digit = 3) deg_to_hms(c(-15, 20, 375)) # The "mat" columns convert straight back x <- deg_to_hms(177.74208, type = "mat") hms_to_deg(x[, "HRS"], x[, "MIN"], x[, "SEC"])
Converts angles from degrees to radians. Supports vectorized input.
deg_to_rad(deg)deg_to_rad(deg)
deg |
Numeric. The angle(s) in degrees to convert to radians.
|
Numeric. The corresponding angle(s) in radians,
.
rad_to_deg for the reverse conversion;
deg_to_dms and deg_to_hms for
sexagesimal output.
deg_to_rad(180) deg_to_rad(c(0, 90, 180))deg_to_rad(180) deg_to_rad(c(0, 90, 180))
Converts an angle expressed in Degrees-Minutes-Seconds (DMS) format to decimal degrees. Accepts either separate numeric arguments or a single formatted string.
dms_to_deg(d, m = 0, s = 0, digit = 5)dms_to_deg(d, m = 0, s = 0, digit = 5)
d |
Numeric or character vector. The degrees component, whose sign is
the sign of the angle, or DMS strings such as |
m |
Numeric vector. The minutes component, from 0 to less than 60.
Default is |
s |
Numeric vector. The seconds component, from 0 to less than 60.
Default is |
digit |
Whole number from 0 to 10: the number of decimal places to
round the result to. Default is |
With numeric input, d, m and s are recycled to a
common length and the result is
, with the sign
taken from d. For a negative angle smaller than one degree, use R's
negative zero: dms_to_deg(-0, 30) is -0.5, while
dms_to_deg(0, 30) is 0.5.
A character d is parsed element by element. Each string holds an
optional sign ("+", "-" or the Unicode minus sign U+2212),
the degrees, and optionally the minutes and then the seconds. The degrees
may be followed by the degree sign "\u00B0", "d", "D"
or ":"; the minutes by "'", the Unicode prime U+2032,
"m", "M" or ":"; and the seconds by "\"", the
Unicode double prime U+2033, "s" or "S". Spaces alone may
also separate the fields. Only the last field may have a decimal part.
Accepted strings include "12\u00B034'56\"", "-0\u00B030'00\"",
"+12\u00B034'56.7\"", "12d34m56s", "12:34:56",
"12 34 56", "12\u00B034'" and "12.5\u00B0". A string
that cannot be parsed gives NA with a warning; NA gives
NA silently.
For both kinds of input the minutes and seconds must be in
and the angle in degrees
(the declination range, as in deg_to_dms); other values are
an error.
Numeric vector of angles in decimal degrees (between -90 and 90),
rounded to digit decimal places.
deg_to_dms for the reverse conversion,
hms_to_deg for right ascension, and
deg_to_rad.
dms_to_deg(d = 12, m = 34, s = 56) dms_to_deg(d = "12\u00B034'56\"", digit = 3) # The sign comes from 'd'; use -0 for angles between -1 and 0 degrees dms_to_deg(c(-12, -0, 0), m = 30) # Several string formats, and an NA dms_to_deg(c("12d34m56s", "12:34:56", "-0\u00B030'", "12.5\u00B0", NA))dms_to_deg(d = 12, m = 34, s = 56) dms_to_deg(d = "12\u00B034'56\"", digit = 3) # The sign comes from 'd'; use -0 for angles between -1 and 0 degrees dms_to_deg(c(-12, -0, 0), m = 30) # Several string formats, and an NA dms_to_deg(c("12d34m56s", "12:34:56", "-0\u00B030'", "12.5\u00B0", NA))
Computes N, the estimated number of active, technologically advanced civilizations capable of interstellar communication in the Milky Way, using the Drake equation:
drake_equation( R_star = 1.5, fp = 1, ne = 0.4, fl = 1, fi = 1, fc = 0.1, L = 1000 )drake_equation( R_star = 1.5, fp = 1, ne = 0.4, fl = 1, fi = 1, fc = 0.1, L = 1000 )
R_star |
Numeric. Average rate of star formation per year in the Milky
Way (stars yr |
fp |
Numeric. Fraction of stars that have planetary systems.
Must be in |
ne |
Numeric. Mean number of planets per planetary system that
could potentially support life (Earth-like / habitable-zone planets).
Default: |
fl |
Numeric. Fraction of suitable planets on which life actually
appears. Must be in |
fi |
Numeric. Fraction of life-bearing planets on which intelligent
life evolves. Must be in |
fc |
Numeric. Fraction of intelligent civilizations that develop
detectable communication technology. Must be in |
L |
Numeric. Mean longevity (years) of a communicating
civilization. Default: |
Default values reflect widely cited contemporary estimates (see References).
All fraction parameters must lie in .
A named list with the following elements:
NNumeric. Estimated number of communicating civilizations.
inputsNamed numeric vector of all seven input parameters.
equationCharacter. Human-readable form of the equation with
values substituted, with embedded line breaks; print it with
cat().
interpretationCharacter. A qualitative interpretation of N
spanning six tiers from effectively zero
() to galaxy teeming with life
().
Drake, F. D. (1961). Discussion at the first SETI conference, Green Bank, West Virginia. NRAO.
Vakoch, D. A., & Dowd, M. F. (Eds.) (2015). The Drake Equation: Estimating the Prevalence of Extraterrestrial Life through the Ages. Cambridge University Press.
# Using all defaults (optimistic estimate) drake_equation() # Pessimistic "Rare Earth" scenario drake_equation(R_star = 1.5, fp = 1.0, ne = 0.4, fl = 0.01, fi = 0.01, fc = 0.01, L = 304) # Custom values result <- drake_equation(R_star = 3, fp = 0.9, ne = 0.5, fl = 0.5, fi = 0.1, fc = 0.1, L = 10000) result$N # cat() renders the equation string with real line breaks cat(result$equation, "\n", sep = "") result$interpretation# Using all defaults (optimistic estimate) drake_equation() # Pessimistic "Rare Earth" scenario drake_equation(R_star = 1.5, fp = 1.0, ne = 0.4, fl = 0.01, fi = 0.01, fc = 0.01, L = 304) # Custom values result <- drake_equation(R_star = 3, fp = 0.9, ne = 0.5, fl = 0.5, fi = 0.1, fc = 0.1, L = 10000) result$N # cat() renders the equation string with real line breaks cat(result$equation, "\n", sep = "") result$interpretation
Returns the entropy density of the cosmological
radiation bath:
where is the effective number of entropy degrees of
freedom.
entropy_density(T_GeV, g_star_S = NULL)entropy_density(T_GeV, g_star_S = NULL)
T_GeV |
Numeric. Temperature in GeV. |
g_star_S |
Numeric. Effective entropy degrees of freedom
|
Numeric. Entropy density in
.
Kolb & Turner (1990), Eq. (3.65).
entropy_density(0.1) entropy_density(1, g_star_S = 106.75)entropy_density(0.1) entropy_density(1, g_star_S = 106.75)
Computes the equilibrium number density
for a non-relativistic species in the Maxwell-Boltzmann limit:
equilibrium_number_density(T_GeV, m_GeV, g_dof = 2)equilibrium_number_density(T_GeV, m_GeV, g_dof = 2)
T_GeV |
Numeric. Temperature in GeV. |
m_GeV |
Numeric. Particle mass in GeV. |
g_dof |
Integer. Internal degrees of freedom. Default 2. |
Numeric. Equilibrium number density in
.
Kolb & Turner (1990), Eq. (5.25).
equilibrium_number_density(T_GeV = 0.01, m_GeV = 0.1, g_dof = 2)equilibrium_number_density(T_GeV = 0.01, m_GeV = 0.1, g_dof = 2)
The yield is the comoving number density
(number per comoving entropy). In equilibrium:
where and is the modified Bessel function
of the second kind of order 2.
equilibrium_yield(x, m_GeV, g_dof = 2, g_star_S = NULL)equilibrium_yield(x, m_GeV, g_dof = 2, g_star_S = NULL)
x |
Numeric. Dimensionless parameter |
m_GeV |
Numeric. Particle mass in GeV. |
g_dof |
Integer. Internal degrees of freedom. Default 2. |
g_star_S |
Numeric. Entropy degrees of freedom. If
|
Numeric. Dimensionless equilibrium yield
.
Kolb & Turner (1990), Eq. (5.34). Gondolo & Gelmini, Nucl. Phys. B 360 (1991) 145.
equilibrium_number_density,
entropy_density, boltzmann_pebble_rhs
equilibrium_yield(x = 3, m_GeV = 100, g_dof = 2) equilibrium_yield(x = 25, m_GeV = 100)equilibrium_yield(x = 3, m_GeV = 100, g_dof = 2) equilibrium_yield(x = 25, m_GeV = 100)
Estimates the freeze-out inverse temperature
using the iterative approximation from the condition
(Kolb & Turner 1990):
freeze_out_xf( m_GeV, sigmav_GeV2, g_dof = 2, c_coeff = 0.5, g_star = 106.75, tol = 1e-06, max_iter = 100 )freeze_out_xf( m_GeV, sigmav_GeV2, g_dof = 2, c_coeff = 0.5, g_star = 106.75, tol = 1e-06, max_iter = 100 )
m_GeV |
Numeric. Particle mass in GeV. |
sigmav_GeV2 |
Numeric. |
g_dof |
Integer. Internal degrees of freedom. Default 2. |
c_coeff |
Numeric. Order-unity coefficient ( |
g_star |
Numeric. |
tol |
Numeric. Convergence tolerance. Default 1e-6. |
max_iter |
Integer. Maximum iterations. Default 100. |
Here
GeV is the full (non-reduced) Planck mass, for which the coefficient
is defined;
GeV is the
reduced Planck mass used by hubble_radiation.
The equation is solved by fixed-point iteration, starting from the
logarithm of the argument without the
factor. The approximation describes non-relativistic freeze-out and
needs a log argument well above (); an
error is raised if the argument would be , which happens
for very small masses or cross sections. Typical WIMP values lie in the
range : with the defaults,
GeV and
GeV give , i.e.
GeV.
Numeric vector of the dimensionless freeze-out parameter
, recycled to the common length of m_GeV,
sigmav_GeV2, g_dof, c_coeff and g_star.
A warning is given if the iteration has not converged after
max_iter steps.
Kolb & Turner (1990), Eq. (5.44). Jungman, Kamionkowski & Griest, Phys. Rep. 267 (1996) 195.
solve_relic_abundance,
boltzmann_pebble_rhs
sigmav <- 2.2e-9 # GeV^-2 x_f <- freeze_out_xf(m_GeV = 100, sigmav_GeV2 = sigmav) cat("x_f =", x_f, " T_f =", 100 / x_f, "GeV\n") freeze_out_xf(m_GeV = c(10, 100, 1000), sigmav_GeV2 = sigmav)sigmav <- 2.2e-9 # GeV^-2 x_f <- freeze_out_xf(m_GeV = 100, sigmav_GeV2 = sigmav) cat("x_f =", x_f, " T_f =", 100 / x_f, "GeV\n") freeze_out_xf(m_GeV = c(10, 100, 1000), sigmav_GeV2 = sigmav)
Returns a step-function approximation of the Standard Model effective
number of relativistic degrees of freedom as a function of temperature:
, which sets the radiation energy density
, or
, which sets the entropy density
.
g_star_eff(T_GeV, type = c("energy", "entropy"))g_star_eff(T_GeV, type = c("energy", "entropy"))
T_GeV |
Numeric vector of positive temperatures in GeV, without missing values. |
type |
Character. |
Each relativistic species with internal degrees of
freedom and temperature contributes
and likewise for with the third power of
. This function uses the instantaneous-decoupling step
approximation: a species counts fully while is above its mass
threshold and not at all below it. The bins are half-open,
, with
in GeV:
| T (GeV) | g_* | g_*S | removed relative to the row above |
| above 173 | 106.75 | 106.75 | none (all SM particles) |
| 125 to 173 | 96.25 | 96.25 | top quark (173 GeV) |
| 80.4 to 125 | 95.25 | 95.25 | Higgs boson (125 GeV) |
| 4.18 to 80.4 | 86.25 | 86.25 | W and Z bosons (both at 80.4 GeV) |
| 1.777 to 4.18 | 75.75 | 75.75 | bottom quark (4.18 GeV) |
| 1.27 to 1.777 | 72.25 | 72.25 | tau lepton (1.777 GeV) |
| 0.15 to 1.27 | 61.75 | 61.75 | charm quark (1.27 GeV) |
| 0.1396 to 0.15 | 17.25 | 17.25 | QCD transition (150 MeV) |
| 0.1057 to 0.1396 | 14.25 | 14.25 | pions (139.6 MeV) |
| 5.11e-4 to 0.1057 | 10.75 | 10.75 | muon (105.7 MeV) |
| up to 5.11e-4 | 3.36 | 3.91 | electron and positron (511 keV) |
At the QCD transition the u, d and s quarks and the gluons are replaced
by the three pions.
The last row counts photons and three neutrino species that decoupled
before e+e- annihilation and are colder by :
and
. At higher temperatures all species share one
temperature and . The step values agree
with the instantaneous-decoupling values of Husdal (2016); the true
is smooth across each threshold, most visibly around the
QCD transition.
Numeric vector, the same length as T_GeV: the
dimensionless or .
Husdal, L. (2016). On Effective Degrees of Freedom in the Early Universe. Galaxies, 4, 78. arXiv:1609.04979.
Kolb, E. W. & Turner, M. S. (1990). The Early Universe. Addison-Wesley, Chapter 3.
hubble_radiation, entropy_density,
equilibrium_yield, boltzmann_pebble_rhs
g_star_eff(100) # 95.25: below the Higgs, above W/Z g_star_eff(1e-3) # 10.75: photons, e+-, 3 neutrinos g_star_eff(1e-4) # 3.36: after e+e- annihilation g_star_eff(1e-4, type = "entropy") # 3.91 g_star_eff(c(500, 1, 0.01)) # 106.75 61.75 10.75g_star_eff(100) # 95.25: below the Higgs, above W/Z g_star_eff(1e-3) # 10.75: photons, e+-, 3 neutrinos g_star_eff(1e-4) # 3.36: after e+e- annihilation g_star_eff(1e-4, type = "entropy") # 3.91 g_star_eff(c(500, 1, 0.01)) # 106.75 61.75 10.75
Queries the Gaia Archive TAP service for stars in the Gaia Catalogue of
Nearby Stars (GCNS), the census of objects within 100 pc of the Sun built
from Gaia Early Data Release 3 (EDR3) and served as the table
external.gaiaedr3_gcns_main_1. Returns the requested columns for the
rows that match a filter condition.
get_gaia_data(vars, condition, timeout = 60)get_gaia_data(vars, condition, timeout = 60)
vars |
A single character string giving the columns to retrieve,
separated by commas (e.g., |
condition |
A single character string giving the ADQL |
timeout |
A single number, at least |
This function sends the synchronous ADQL query
SELECT vars FROM external.gaiaedr3_gcns_main_1 WHERE condition to
the Gaia Archive TAP service at
https://gea.esac.esa.int/tap-server/tap/sync. An internet
connection is required.
The function fails gracefully: problems on the remote side (no
connection, a timeout, an HTTP error status such as a rejected query, or
a malformed response) never raise an error or a warning. Instead a
message explains what went wrong, including the HTTP status and the
archive's error text when there is one, and NULL is returned
invisibly, so check the result with is.null() before using it.
Invalid arguments are still errors.
The columns of the result are named by splitting vars at its
commas. If the archive returns fewer columns than this gives names, for
example because an entry of vars is a function call with several
arguments, the result is also NULL with a message.
timeout caps how long the function can block. Queries that return
many rows can need more than the default 60 seconds; increase
timeout for them. Opening the connection is also limited,
separately, by the curl package, and a larger timeout does not
extend that limit.
A data frame with one row per matching star and one column per
entry of vars, named as written there. Values are in the units of
the GCNS table (e.g., ra and dec in degrees,
parallax in mas).
If the query runs but no rows match, a data frame with zero rows and the same column names (all numeric) is returned, with a message.
If the Gaia Archive cannot be reached, does not answer in time, returns an
HTTP error status, or sends a response that is not valid JSON or does not
hold a table of results with a column for every entry of vars, a
message gives the reason and NULL is returned invisibly.
deg_to_hms and deg_to_dms to express
the returned ra and dec in sexagesimal form.
vars <- "source_id, ra, dec, phot_bp_mean_mag, phot_rp_mean_mag, parallax" condition <- "parallax > 40" result <- get_gaia_data(vars, condition) head(result)vars <- "source_id, ra, dec, phot_bp_mean_mag, phot_rp_mean_mag, parallax" condition <- "parallax > 40" result <- get_gaia_data(vars, condition) head(result)
Converts an angle expressed in Hours-Minutes-Seconds (HMS) format to decimal degrees. Accepts either separate numeric arguments or a single formatted string.
hms_to_deg(h, m = 0, s = 0, digit = 5)hms_to_deg(h, m = 0, s = 0, digit = 5)
h |
Numeric or character vector. The hours component, or HMS strings
such as |
m |
Numeric vector. The minutes component, from 0 to less than 60.
Default is |
s |
Numeric vector. The seconds component, from 0 to less than 60.
Default is |
digit |
Whole number from 0 to 10: the number of decimal places to
round the result to. Default is |
With numeric input, h, m and s are recycled to a
common length and the result is
degrees. h
must be in , m and s in
, and the total may not exceed 24 hours.
A character h is parsed element by element, ignoring case: the
hours, then optionally the minutes and then the seconds, as in
"03h15m30s", "3h 15m 30s", "3H15M30S",
"03:15:30", "3 15 30", "3h15m30.5s", "3h15m"
or "3h". Only the last field may have a decimal part, and a leading
"+" is allowed. The parsed values must lie in the same ranges as
numeric input (so a negative value is an error). A string that cannot be
parsed gives NA with a warning; NA gives NA silently.
Numeric vector of angles in decimal degrees (between 0 and 360),
rounded to digit decimal places.
deg_to_hms for the reverse conversion,
dms_to_deg for declination, and deg_to_rad.
hms_to_deg(h = 3, m = 15, s = 30) hms_to_deg(h = 3, m = 15, s = 30.123) hms_to_deg(h = "03h15m30s") hms_to_deg(c("3h 15m 30s", "03:15:30", "3h15m", "3h", NA))hms_to_deg(h = 3, m = 15, s = 30) hms_to_deg(h = 3, m = 15, s = 30.123) hms_to_deg(h = "03h15m30s") hms_to_deg(c("3h 15m 30s", "03:15:30", "3h15m", "3h", NA))
Computes the Hubble expansion rate during the
radiation-dominated epoch using the Friedmann equation:
where is the reduced Planck mass and is the
effective number of relativistic degrees of freedom.
hubble_radiation(T_GeV, g_star = 106.75)hubble_radiation(T_GeV, g_star = 106.75)
T_GeV |
Numeric. Plasma temperature in GeV. |
g_star |
Numeric. Effective relativistic degrees of freedom
|
Numeric. Hubble rate in GeV (natural units).
Kolb, E. W. & Turner, M. S. (1990). The Early Universe. Addison-Wesley, Eq. (3.46).
g_star_eff, boltzmann_pebble_rhs
# H at T = 100 GeV with SM degrees of freedom hubble_radiation(100) # H at T = 1 MeV (neutrino decoupling era), g* ~ 10.75 hubble_radiation(1e-3, g_star = 10.75)# H at T = 100 GeV with SM degrees of freedom hubble_radiation(100) # H at T = 1 MeV (neutrino decoupling era), g* ~ 10.75 hubble_radiation(1e-3, g_star = 10.75)
Computes the expansion rate relative to today for a model created by
cosmology_model, that is
with
An error is raised where , i.e. where the
model has no real expansion rate.
hubble_ratio(cosmo, z)hubble_ratio(cosmo, z)
cosmo |
A cosmological model created by |
z |
Numeric vector of finite redshifts, each greater than -1
(negative values lie in the future). |
Numeric vector of the same length as z (no names): the
dimensionless ratio . Multiply by
cosmo$H0 to get in km/s/Mpc.
Hogg, D. W. (1999). Distance measures in cosmology. https://arxiv.org/abs/astro-ph/9905116
cosmology_model, hubble_distance,
comoving_distance, cosmic_time
cosmo <- cosmology_model() hubble_ratio(cosmo, c(0, 0.5, 1, 2)) cosmo$H0 * hubble_ratio(cosmo, 1) # H(z = 1) in km/s/Mpccosmo <- cosmology_model() hubble_ratio(cosmo, c(0, 0.5, 1, 2)) cosmo$H0 * hubble_ratio(cosmo, 1) # H(z = 1) in km/s/Mpc
Converts date-times to Julian Days (JD): the continuous count of days, with the fraction of the day, since noon Universal Time on 1 January 4713 BC of the proleptic Julian calendar.
julian_day(datetime)julian_day(datetime)
datetime |
A |
The Julian Day is computed from the instant itself,
where is the number of seconds since 1970-01-01 00:00:00 UTC, i.e.
as.numeric(as.POSIXct(datetime)). The result therefore does not
depend on the time zone a date-time is displayed in, and it includes
seconds and fractions of a second.
Calendar dates are read on the proleptic Gregorian calendar, as everywhere in R, so for dates before 1582-10-15 the result differs from the Julian-calendar convention used by Meeus (1998). Leap seconds and the difference UT1 - UTC (always less than 0.9 s) are ignored: UTC is treated as Universal Time.
A numeric vector of Julian Days (in days), the same length as
datetime. Missing date-times (including an all-NA logical
vector) give NA.
Meeus, J. (1998). Astronomical Algorithms, 2nd edition. Willmann-Bell, Richmond, Virginia. Chapter 7.
radec_to_altaz, which uses the Julian Day to obtain
the sidereal time.
# The J2000.0 epoch julian_day(as.POSIXct("2000-01-01 12:00:00", tz = "UTC")) # Meeus (1998) Example 7.a: 1957 October 4.81 UT print(julian_day("1957-10-04 19:26:24"), digits = 10) # The same instant displayed in two time zones has one Julian Day noon_new_york <- as.POSIXct("2024-07-04 12:00:00", tz = "America/New_York") print(julian_day(noon_new_york), digits = 10) print(julian_day("2024-07-04 16:00:00"), digits = 10) # Dates refer to midnight UTC print(julian_day(as.Date("2024-01-01")), digits = 10)# The J2000.0 epoch julian_day(as.POSIXct("2000-01-01 12:00:00", tz = "UTC")) # Meeus (1998) Example 7.a: 1957 October 4.81 UT print(julian_day("1957-10-04 19:26:24"), digits = 10) # The same instant displayed in two time zones has one Julian Day noon_new_york <- as.POSIXct("2024-07-04 12:00:00", tz = "America/New_York") print(julian_day(noon_new_york), digits = 10) print(julian_day("2024-07-04 16:00:00"), digits = 10) # Dates refer to midnight UTC print(julian_day(as.Date("2024-01-01")), digits = 10)
Converts distances from kilometers (km) to megaparsecs (Mpc) using the exact
IAU definitions of the astronomical unit, 1 au = 149597870.7 km (IAU 2012
Resolution B2), and of the parsec, 1 pc = au
(IAU 2015 Resolution B2):
km_to_Mpc(km)km_to_Mpc(km)
km |
Numeric vector of distances in kilometers. |
Numeric vector of the same length as km: the distances in
megaparsecs (Mpc).
Mpc_to_km for the inverse conversion;
hubble_distance and the other distance functions, which
return Mpc by default.
km_to_Mpc(3.0856775814913673e19) # 1 Mpc km_to_Mpc(c(1e19, 1e20, 1e21))km_to_Mpc(3.0856775814913673e19) # 1 Mpc km_to_Mpc(c(1e19, 1e20, 1e21))
Converts distances from megaparsecs (Mpc) to kilometers (km) using the exact
IAU definitions of the astronomical unit, 1 au = 149597870.7 km (IAU 2012
Resolution B2), and of the parsec, 1 pc = au
(IAU 2015 Resolution B2):
Mpc_to_km(mpc)Mpc_to_km(mpc)
mpc |
Numeric vector of distances in megaparsecs. |
Numeric vector of the same length as mpc: the distances in
kilometers (km).
km_to_Mpc for the inverse conversion.
Mpc_to_km(1) # 3.0856775814913673e19 km Mpc_to_km(c(0.5, 1, 4425.6))Mpc_to_km(1) # 3.0856775814913673e19 km Mpc_to_km(c(0.5, 1, 4425.6))
Computes the derivative of the free-electron fraction during cosmological hydrogen recombination from the Peebles (1968) equation, with the Peebles C-factor in the form used by RECFAST (Seager, Sasselov & Scott 1999).
peebles_rhs( lna, xe, H, n_H, alpha_B, beta_B, lambda_alpha = 1.21567e-07, Lambda_2s1s = 8.22458, neutral_floor = 1e-30, T0 = 2.7255 )peebles_rhs( lna, xe, H, n_H, alpha_B, beta_B, lambda_alpha = 1.21567e-07, Lambda_2s1s = 8.22458, neutral_floor = 1e-30, T0 = 2.7255 )
lna |
Natural logarithm of the scale factor,
|
xe |
Free-electron fraction per hydrogen nucleus,
|
H |
Hubble expansion rate at |
n_H |
Total hydrogen-nuclei number density at |
alpha_B |
Case-B recombination coefficient at temperature |
beta_B |
Photoionization rate from the |
lambda_alpha |
Lyman-alpha wavelength in metres; it also sets the
|
Lambda_2s1s |
Hydrogen |
neutral_floor |
Small lower limit for neutral-hydrogen density,
used only to avoid division by zero at |
T0 |
Radiation (CMB) temperature today in K. Default 2.7255 (Fixsen 2009). |
The Peebles equation for the evolution of the free-electron fraction is
where
and eV. The Boltzmann factor gives the population of
the level, from which photoionizes,
relative to the ground state.
The Peebles C-factor
accounts for the fact that a hydrogen atom formed in an excited state can be photoionized again before reaching the stable ground state via the two-photon or Lyman-alpha escape channels.
The Lyman-alpha escape rate is
where is the
ground-state hydrogen density.
The matter temperature is assumed equal to the radiation temperature,
which holds while Compton scattering keeps them coupled (); alpha_B and beta_B should be evaluated at
that . All inputs are single numbers in SI units (metres,
seconds, Kelvin). Note that here is in s,
whereas hubble_radiation returns it in GeV.
The example uses inputs at ( K) for a
flat cosmology with km s
Mpc, ,
,
and helium mass
fraction (Planck 2018): , , from the case-B fit
of Pequignot, Petitjean & Boisson (1991) times the RECFAST fudge factor
1.14, and with eV.
A named numeric vector containing:
dxe_dlnaDerivative of with respect to
(dimensionless).
CPeebles C-factor (dimensionless probability that an excited atom reaches the ground state before being re-ionized).
lambda_alpha_escapeEffective Lyman-alpha escape rate
in s.
Peebles, P. J. E. (1968). Recombination of the Primeval Plasma. Astrophysical Journal, 153, 1.
Seager, S., Sasselov, D. D. & Scott, D. (1999). A New Calculation of the Recombination Epoch. Astrophysical Journal Letters, 523, L1 (RECFAST).
Pequignot, D., Petitjean, P. & Boisson, C. (1991). Total and effective radiative recombination coefficients. Astronomy and Astrophysics, 251, 680.
Saha_Xe for the equilibrium (Saha) ionization
fraction.
# Physically consistent inputs at z = 1100 (see Details) z <- 1100 peebles_rhs( lna = -log(1 + z), xe = 0.5, H = 5.14e-14, # s^-1 n_H = 2.53e8, # m^-3 alpha_B = 7.62e-19, # m^3 s^-1 beta_B = 590 # s^-1 )# Physically consistent inputs at z = 1100 (see Details) z <- 1100 peebles_rhs( lna = -log(1 + z), xe = 0.5, H = 5.14e-14, # s^-1 n_H = 2.53e8, # m^-3 alpha_B = 7.62e-19, # m^3 s^-1 beta_B = 590 # s^-1 )
Calculates the energy density of blackbody photons at temperature
, using
in natural units ().
photon_energy_density_fn_T(temp, unit = "eV")photon_energy_density_fn_T(temp, unit = "eV")
temp |
Numeric vector of non-negative temperatures, in eV or Kelvin. |
unit |
Character. The unit of the temperature input. Either
|
A temperature given in Kelvin is first converted to eV with the exact
Boltzmann constant
eV/K. To obtain an energy density per volume, divide the result by
, with eV cm: for the CMB today (2.7255 K) this
gives about 0.2606 eV cm.
Numeric vector, the same length as temp. The photon energy
density in natural units, (with in
eV).
photon_energy_density_fn_z,
photon_number_density_fn_T
photon_energy_density_fn_T(1, "eV") photon_energy_density_fn_T(300, "K") # CMB today in eV cm^-3 photon_energy_density_fn_T(2.7255, "K") / 1.973270e-5^3photon_energy_density_fn_T(1, "eV") photon_energy_density_fn_T(300, "K") # CMB today in eV cm^-3 photon_energy_density_fn_T(2.7255, "K") / 1.973270e-5^3
Calculates the energy density of the cosmic microwave background photons
at redshift , with temperature
and K (Fixsen 2009), using
.
photon_energy_density_fn_z(z)photon_energy_density_fn_z(z)
z |
Numeric vector of redshifts, |
Numeric vector, the same length as z. The photon energy
density in natural units, ; see
photon_energy_density_fn_T for the conversion to
eV cm.
Fixsen, D. J. (2009). The Temperature of the Cosmic Microwave Background. Astrophysical Journal, 707, 916.
photon_energy_density_fn_T,
photon_number_density_fn_z
photon_energy_density_fn_z(1300) photon_energy_density_fn_z(c(0, 1100))photon_energy_density_fn_z(1300) photon_energy_density_fn_z(c(0, 1100))
Calculates the number density of blackbody photons at temperature
, using
in natural units ().
photon_number_density_fn_T(temp, unit = "eV")photon_number_density_fn_T(temp, unit = "eV")
temp |
Numeric vector of non-negative temperatures, in eV or Kelvin. |
unit |
Character. The unit of the temperature input. Either
|
A temperature given in Kelvin is first converted to eV with the exact
Boltzmann constant
eV/K. To obtain a number per volume, divide the result by
, with eV cm: for the CMB today (2.7255 K) this
gives about 410.7 photons cm.
Numeric vector, the same length as temp. The photon number
density in natural units, (with in
eV).
photon_number_density_fn_z,
photon_energy_density_fn_T
photon_number_density_fn_T(1, "eV") photon_number_density_fn_T(300, "K") # CMB today in photons per cm^3 photon_number_density_fn_T(2.7255, "K") / 1.973270e-5^3photon_number_density_fn_T(1, "eV") photon_number_density_fn_T(300, "K") # CMB today in photons per cm^3 photon_number_density_fn_T(2.7255, "K") / 1.973270e-5^3
Calculates the number density of the cosmic microwave background photons
at redshift , with temperature
and K (Fixsen 2009), using
.
photon_number_density_fn_z(z)photon_number_density_fn_z(z)
z |
Numeric vector of redshifts, |
Numeric vector, the same length as z. The photon number
density in natural units, ; see
photon_number_density_fn_T for the conversion to
cm.
Fixsen, D. J. (2009). The Temperature of the Cosmic Microwave Background. Astrophysical Journal, 707, 916.
photon_number_density_fn_T,
photon_energy_density_fn_z
photon_number_density_fn_z(1300) photon_number_density_fn_z(c(0, 1100))photon_number_density_fn_z(1300) photon_number_density_fn_z(c(0, 1100))
Converts angles from radians to degrees. Supports vectorized input.
rad_to_deg(rad)rad_to_deg(rad)
rad |
Numeric. The angle(s) in radians to convert to degrees.
|
Numeric. The corresponding angle(s) in degrees,
.
deg_to_rad for the reverse conversion;
deg_to_dms and deg_to_hms for
sexagesimal output.
rad_to_deg(pi) rad_to_deg(c(0, pi / 2, pi))rad_to_deg(pi) rad_to_deg(c(0, pi / 2, pi))
Converts equatorial coordinates (right ascension and declination) to horizontal coordinates (altitude and azimuth) for an observer at a given place on Earth and a given instant.
radec_to_altaz(ra, dec, lat, lon, datetime)radec_to_altaz(ra, dec, lat, lon, datetime)
ra |
Numeric vector. Apparent right ascension in hours, in
|
dec |
Numeric vector. Apparent declination in degrees, in
|
lat |
Numeric vector. Geographic latitude of the observer in degrees,
in |
lon |
Numeric vector. Geographic longitude of the observer in degrees, positive east of Greenwich and negative west of it. Any finite value is accepted (280 is the same as -80). |
datetime |
Instant(s) of the observation: anything accepted by
|
The Greenwich mean sidereal time, in hours, is
which is equation 12.4 of Meeus (1998) without its very small quadratic
and cubic terms, with from julian_day. For
longitude and right ascension the
local sidereal time is
and the hour angle
is degrees. With
declination and latitude , the altitude
and azimuth are
where the sine of the altitude is clamped to to absorb
rounding errors and the azimuth is reduced to .
Conventions and limitations:
Longitude is positive east of Greenwich and negative west of it.
Azimuth is measured from North through East: North is 0, East 90, South 180 and West 270 degrees. Meeus (1998) measures azimuth from South, so add 180 degrees to his values to compare.
ra and dec must be apparent coordinates, referred to
the true equator and equinox of the date. No precession, nutation or
aberration is applied. Catalog (J2000.0) positions are fine for rough
work, but precession alone shifts them by roughly 0.01 degrees for
every year away from 2000.
The altitude is geometric: atmospheric refraction, which raises objects near the horizon by about 0.5 degrees, is not applied.
The sidereal time is mean, not apparent (the equation of the
equinoxes, at most about 1.2 s of time, is ignored), and
datetime is taken as Universal Time (UT1 - UTC is ignored).
For Meeus (1998) Example 13.b (Venus seen from the US Naval Observatory in Washington on 1987 April 10 at 19:21:00 UT) the function returns an altitude of 15.1243 and an azimuth of 248.0343 degrees, within 0.0007 degrees of the published 15.1249 and 248.0337 (68.0337 measured from South). The difference comes mainly from the mean sidereal time: given the apparent sidereal time and the longitude (5h08m15.7s) that Meeus uses, the results agree with his to better than 0.0001 degrees.
All arguments are vectorized: each must have length 1 or a common length
, and the result has rows. A missing value in any argument
gives NA in the corresponding row.
A data frame with one row per observation and the columns
altitudeAltitude above the horizon in degrees, in
.
azimuthAzimuth in degrees, in , measured
from North through East.
Meeus, J. (1998). Astronomical Algorithms, 2nd edition. Willmann-Bell, Richmond, Virginia. Chapters 12 and 13.
julian_day; dms_to_deg for a
sexagesimal dec, and hms_to_deg for a sexagesimal
right ascension. hms_to_deg() returns degrees, so pass
hms_to_deg(h, m, s) / 15 as ra.
# The globular cluster M13 (RA 16h41.7m, Dec +36d28m) seen from # Birmingham, UK radec_to_altaz(ra = 16.695, dec = 36.466667, lat = 52.5, lon = -1.9166667, datetime = as.POSIXct("1998-08-10 23:10:00", tz = "UTC")) # Meeus (1998) Example 13.b: Venus seen from Washington, D.C. radec_to_altaz(ra = 23 + 9 / 60 + 16.641 / 3600, dec = -(6 + 43 / 60 + 11.61 / 3600), lat = 38 + 55 / 60 + 17 / 3600, lon = -(77 + 3 / 60 + 56 / 3600), datetime = "1987-04-10 19:21:00") # Track of Rigel seen from Rochester, NY, every three hours times <- seq(as.POSIXct("2024-10-02 00:00:00", tz = "UTC"), by = "3 hours", length.out = 9) track <- radec_to_altaz(ra = 78.634467 / 15, dec = -8.20164, lat = 43.1566, lon = -77.6088, datetime = times) data.frame(time = times, track)# The globular cluster M13 (RA 16h41.7m, Dec +36d28m) seen from # Birmingham, UK radec_to_altaz(ra = 16.695, dec = 36.466667, lat = 52.5, lon = -1.9166667, datetime = as.POSIXct("1998-08-10 23:10:00", tz = "UTC")) # Meeus (1998) Example 13.b: Venus seen from Washington, D.C. radec_to_altaz(ra = 23 + 9 / 60 + 16.641 / 3600, dec = -(6 + 43 / 60 + 11.61 / 3600), lat = 38 + 55 / 60 + 17 / 3600, lon = -(77 + 3 / 60 + 56 / 3600), datetime = "1987-04-10 19:21:00") # Track of Rigel seen from Rochester, NY, every three hours times <- seq(as.POSIXct("2024-10-02 00:00:00", tz = "UTC"), by = "3 hours", length.out = 9) track <- radec_to_altaz(ra = 78.634467 / 15, dec = -8.20164, lat = 43.1566, lon = -77.6088, datetime = times) data.frame(time = times, track)
redshift_to_scale_factor() returns the scale factor
( today) and scale_factor_to_redshift() the
inverse, .
redshift_to_scale_factor(z) scale_factor_to_redshift(a)redshift_to_scale_factor(z) scale_factor_to_redshift(a)
z |
Numeric vector of redshifts, each greater than -1. |
a |
Numeric vector of positive scale factors. |
Numeric vector of the same length as the input (no names):
dimensionless scale factors from redshift_to_scale_factor(),
dimensionless redshifts from scale_factor_to_redshift().
redshift_to_scale_factor(c(0, 1, 3, 1100)) scale_factor_to_redshift(c(1, 0.5, 0.25))redshift_to_scale_factor(c(0, 1, 3, 1100)) scale_factor_to_redshift(c(1, 0.5, 0.25))
Saha_Xe() calculates the equilibrium ionization fraction
of hydrogen at redshift from the Saha equation.
soln_saha() returns , whose root (for example via
uniroot) is the redshift at which hydrogen is half
ionized.
Saha_Xe(z) soln_saha(z)Saha_Xe(z) soln_saha(z)
z |
Numeric vector of redshifts, |
In natural units the Saha equation for hydrogen reads
with , K,
eV (NIST), MeV and the
hydrogen density , where the baryon-to-photon ratio is
. Writing the right-hand side
as , the physical root of is
evaluated in the cancellation-free form
so stays in : it tends to 1 at high redshift and is
exactly 0 once overflows (below ).
Saha equilibrium describes the start of recombination but predicts it to
finish too early; see peebles_rhs for the
out-of-equilibrium Peebles equation.
For Saha_Xe(), a numeric vector the same length as
z: the dimensionless ionization fraction , between 0
and 1. For soln_saha(), the numeric vector .
peebles_rhs, photon_number_density_fn_z
Saha_Xe(1300) Saha_Xe(c(1100, 1300, 1500)) soln_saha(1350) # Redshift at which hydrogen is half ionized in Saha equilibrium uniroot(soln_saha, c(1000, 2000))$rootSaha_Xe(1300) Saha_Xe(c(1100, 1300, 1500)) soln_saha(1350) # Redshift at which hydrogen is half ionized in Saha equilibrium uniroot(soln_saha, c(1000, 2000))$root
Numerically integrates the thermal relic Boltzmann equation
(boltzmann_pebble_rhs) from to
using deSolve, starting in equilibrium,
.
Returns the comoving yield and the final relic density
parameter .
solve_relic_abundance( m_GeV, sigmav_GeV2, g_dof = 2, x_ini = 5, x_fin = 1000, n_steps = 2000 )solve_relic_abundance( m_GeV, sigmav_GeV2, g_dof = 2, x_ini = 5, x_fin = 1000, n_steps = 2000 )
m_GeV |
Numeric. Particle mass in GeV (a single positive number). |
sigmav_GeV2 |
Numeric. |
g_dof |
Integer. Internal DOF. Default 2. |
x_ini |
Numeric. Initial |
x_fin |
Numeric. Final |
n_steps |
Integer. Number of output grid points, at least 2. Default 2000. |
The relic abundance today is:
where is the yield at .
Requires the deSolve package. The equation is solved for
with the "lsoda" method
(rtol = 1e-8, atol = 1e-10), using
g_star_eff for and .
An error is raised if the integration stops before x_fin.
A list with:
xNumeric vector of values.
YNumeric vector of yield .
Y_eqNumeric vector of equilibrium yield
.
Omega_h2Numeric. Relic density
.
Kolb & Turner (1990), Chapter 5.
boltzmann_pebble_rhs, freeze_out_xf,
equilibrium_yield
sigmav <- 2.2e-9 # GeV^-2 result <- solve_relic_abundance(m_GeV = 100, sigmav_GeV2 = sigmav) cat("Omega h^2 =", result$Omega_h2, "\n")sigmav <- 2.2e-9 # GeV^-2 result <- solve_relic_abundance(m_GeV = 100, sigmav_GeV2 = sigmav) cat("Omega h^2 =", result$Omega_h2, "\n")