From 0baa81a4f49dede88fa3b558891b0dc26431247b Mon Sep 17 00:00:00 2001 From: rstiskalek Date: Sun, 6 Nov 2022 09:06:03 +0000 Subject: [PATCH] centre coords at 0 --- csiborgtools/units/box_units.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/csiborgtools/units/box_units.py b/csiborgtools/units/box_units.py index 8904bd2..b45fb2a 100644 --- a/csiborgtools/units/box_units.py +++ b/csiborgtools/units/box_units.py @@ -278,7 +278,8 @@ def convert_from_boxunits(data, names, boxunits): - density -> solar mass per cubed kpc. Any other conversions are currently not implemented. Note that the array is passed by reference and directly modified, even though it is also - explicitly returned. + explicitly returned. Additionally centres the box coordinates on the + observer, if they are being transformed. Parameters ---------- @@ -288,7 +289,7 @@ def convert_from_boxunits(data, names, boxunits): Columns to be converted. boxunits : `BoxUnits` Box units class of the simulation and snapshot. - + Returns ------- data : structured array @@ -323,4 +324,8 @@ def convert_from_boxunits(data, names, boxunits): raise NotImplementedError( "Conversion of `{}` is not defined.".format(name)) + # Center at the observer + if name in ["peak_x", "peak_y", "peak_z"]: + data[name] -= transforms["length"](0.5) + return data