From 1037aa4db980c8d61bb3df53675abf82d7fd49f8 Mon Sep 17 00:00:00 2001 From: rstiskalek Date: Fri, 18 Nov 2022 10:53:06 +0000 Subject: [PATCH] add velocity conversion --- csiborgtools/units/box_units.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/csiborgtools/units/box_units.py b/csiborgtools/units/box_units.py index a3c4bc9..4adcd31 100644 --- a/csiborgtools/units/box_units.py +++ b/csiborgtools/units/box_units.py @@ -199,6 +199,22 @@ class BoxUnits: """ return self.box2kpc(length) * 1e-3 + def box2vel(self, vel): + r""" + Convert velocity from box units to :math:`\mathrm{m} / \mathrm{s}^2`. + + Parameters + ---------- + vel : float + Velocity in box units. + + Returns + ------- + vel : float + Velocity in :math:`\mathrm{m} / \mathrm{s}^2` + """ + return vel * (1e-2 * self._unit_l / self._unit_t / self.aexp) + def box2cosmoredshift(self, length): r""" Convert the box comoving distance to cosmological redshift.