From 3a7181c191e0ee1e78d22f7d7546b3a6f6499508 Mon Sep 17 00:00:00 2001 From: Noe Brucy Date: Tue, 2 Nov 2021 16:40:35 +0100 Subject: [PATCH] [sinks] correct units --- plotter.py | 2 +- snapshotprocessor.py | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/plotter.py b/plotter.py index 600812d..efb7337 100644 --- a/plotter.py +++ b/plotter.py @@ -895,7 +895,7 @@ class Plotter(Aggregator, BaseProcessor): self.current_processor.get_value("/datasets/sinks") ) part_pos = sinks[["x", "y", "z"]].values - mass = sinks.M + mass = sinks.msink unit_length /= self.current_processor.lbox except KeyError: self.current_processor._log("No sinks particles", "WARNING") diff --git a/snapshotprocessor.py b/snapshotprocessor.py index af0103a..00ccfa4 100644 --- a/snapshotprocessor.py +++ b/snapshotprocessor.py @@ -1359,11 +1359,16 @@ class SnapshotProcessor(HDF5Container): f = open(csv_name) first_line = f.readline() + second_line = f.readline() f.close() if first_line[1] == "#": header = first_line[3:-1].split(",") + units = second_line[3:-1].split(",") df = pd.read_csv(csv_name, header=None, names=header, skiprows=2) + for key in header: + if units[header.index(key)] == "m": + df[key] = df[key] * self.info["unit_mass"].express(U.Msun) else: header = [ "id", @@ -1652,9 +1657,9 @@ class SnapshotProcessor(HDF5Container): self._sinks, group="/datasets", unit={ - "Id": U.none, - "M": U.Msun, - "dmf": U.Msun, + "id": U.none, + "msink": U.Msun, + "dmfsink": U.Msun, "x": "unit_density", "y": "unit_density", "z": "unit_density", @@ -1662,14 +1667,24 @@ class SnapshotProcessor(HDF5Container): "vy": "unit_velocity", "vz": "unit_velocity", "rot_period": "unit_time", - "lx": U.none, - "ly": U.none, - "lz": U.none, - "acc_rate": U.none, + "lx": {"unit_mass" : 1, "unit_length" : 2, "unit_time" : -1}, + "ly": {"unit_mass" : 1, "unit_length" : 2, "unit_time" : -1}, + "lz": {"unit_mass" : 1, "unit_length" : 2, "unit_time" : -1}, + "acc_rate": {"unit_mass" : 1, "unit_time" : -1}, "acc_lum": U.none, "age": U.year, "int_lum": U.none, "Teff": U.K, + "level": U.none, + "mbh": "unit_mass", + "tform": "unit_time", + "del_mass": U.Msun, + "rho_gas": "unit_density", + "cs**2": {"unit_velocity" : 2}, + "etherm": {"unit_mass" : 1, "unit_velocity" : 2}, + "vx_gas": "unit_velocity", + "vy_gas": "unit_velocity", + "vz_gas": "unit_velocity", }, ), "pspec": Rule(self, self._pspec, "Power spectrum", "/hdf5"),