change density to mass/mpc^3

This commit is contained in:
rstiskalek 2022-11-06 10:06:40 +00:00
parent 5fa429ceb0
commit 859e3f4eb2

View file

@ -234,7 +234,7 @@ class BoxUnits:
def box2dens(self, density): def box2dens(self, density):
r""" r"""
Convert density from box units to :math:`M_\odot / \mathrm{pc}^3` Convert density from box units to :math:`M_\odot / \mathrm{Mpc}^3`
(with :math:`h=0.705`). (with :math:`h=0.705`).
Parameters Parameters
@ -248,11 +248,11 @@ class BoxUnits:
Density in :math:`M_\odot / \mathrm{pc}^3`. Density in :math:`M_\odot / \mathrm{pc}^3`.
""" """
return (density * self._unit_d / self._Msuncgs return (density * self._unit_d / self._Msuncgs
* (units.pc.to(units.cm))**3) * (units.Mpc.to(units.cm))**3)
def dens2box(self, density): def dens2box(self, density):
r""" r"""
Convert density from :math:`M_\odot / \mathrm{pc}^3` Convert density from :math:`M_\odot / \mathrm{Mpc}^3`
(with :math:`h=0.705`) to box units. (with :math:`h=0.705`) to box units.
Parameters Parameters
@ -266,16 +266,16 @@ class BoxUnits:
Density in box units. Density in box units.
""" """
return (density / self._unit_d * self._Msuncgs return (density / self._unit_d * self._Msuncgs
/ (units.pc.to(units.cm))**3) / (units.Mpc.to(units.cm))**3)
def convert_from_boxunits(data, names, boxunits): def convert_from_boxunits(data, names, boxunits):
r""" r"""
Convert columns named `names` in array `data` from box units to physical Convert columns named `names` in array `data` from box units to physical
units, such that units, such that
- length -> Mpc, - length -> :math:`Mpc`,
- mass -> solar mass, - mass -> :math:`M_\odot`,
- density -> solar mass per cubed kpc. - density -> :math:`M_\odot / \mathrm{Mpc}^3`.
Any other conversions are currently not implemented. Note that the array Any other conversions are currently not implemented. Note that the array
is passed by reference and directly modified, even though it is also is passed by reference and directly modified, even though it is also
explicitly returned. Additionally centres the box coordinates on the explicitly returned. Additionally centres the box coordinates on the