mirror of
https://github.com/Richard-Sti/csiborgtools.git
synced 2024-12-23 03:08:01 +00:00
add box2cosmoredshift
This commit is contained in:
parent
06d3fede95
commit
858a153fad
1 changed files with 19 additions and 1 deletions
|
@ -17,10 +17,11 @@ Simulation box unit transformations.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import numpy
|
import numpy
|
||||||
from astropy.cosmology import LambdaCDM
|
from astropy.cosmology import (LambdaCDM, z_at_value)
|
||||||
from astropy import (constants, units)
|
from astropy import (constants, units)
|
||||||
from ..io import read_info
|
from ..io import read_info
|
||||||
|
|
||||||
|
|
||||||
# Map of unit conversions
|
# Map of unit conversions
|
||||||
CONV_NAME = {
|
CONV_NAME = {
|
||||||
"length": ["peak_x", "peak_y", "peak_z", "Rs", "rmin", "rmax", "r200",
|
"length": ["peak_x", "peak_y", "peak_z", "Rs", "rmin", "rmax", "r200",
|
||||||
|
@ -198,6 +199,23 @@ class BoxUnits:
|
||||||
"""
|
"""
|
||||||
return self.box2kpc(length) * 1e-3
|
return self.box2kpc(length) * 1e-3
|
||||||
|
|
||||||
|
def box2cosmoredshift(self, length):
|
||||||
|
r"""
|
||||||
|
Convert the box comoving distance to cosmological redshift.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
length : float
|
||||||
|
Length in box units.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
cosmo_redshift : foat
|
||||||
|
The cosmological redshift.
|
||||||
|
"""
|
||||||
|
dist = self.box2mpc(length) * units.Mpc
|
||||||
|
return z_at_value(self._cosmo.comoving_distance, dist)
|
||||||
|
|
||||||
def solarmass2box(self, mass):
|
def solarmass2box(self, mass):
|
||||||
r"""
|
r"""
|
||||||
Convert mass from :math:`M_\odot` (with :math:`h=0.705`) to box units.
|
Convert mass from :math:`M_\odot` (with :math:`h=0.705`) to box units.
|
||||||
|
|
Loading…
Reference in a new issue