[sinks] correct units

This commit is contained in:
Noe Brucy
2021-11-02 16:40:35 +01:00
parent d51be7504b
commit 3a7181c191
2 changed files with 23 additions and 8 deletions
+1 -1
View File
@@ -895,7 +895,7 @@ class Plotter(Aggregator, BaseProcessor):
self.current_processor.get_value("/datasets/sinks") self.current_processor.get_value("/datasets/sinks")
) )
part_pos = sinks[["x", "y", "z"]].values part_pos = sinks[["x", "y", "z"]].values
mass = sinks.M mass = sinks.msink
unit_length /= self.current_processor.lbox unit_length /= self.current_processor.lbox
except KeyError: except KeyError:
self.current_processor._log("No sinks particles", "WARNING") self.current_processor._log("No sinks particles", "WARNING")
+22 -7
View File
@@ -1359,11 +1359,16 @@ class SnapshotProcessor(HDF5Container):
f = open(csv_name) f = open(csv_name)
first_line = f.readline() first_line = f.readline()
second_line = f.readline()
f.close() f.close()
if first_line[1] == "#": if first_line[1] == "#":
header = first_line[3:-1].split(",") header = first_line[3:-1].split(",")
units = second_line[3:-1].split(",")
df = pd.read_csv(csv_name, header=None, names=header, skiprows=2) 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: else:
header = [ header = [
"id", "id",
@@ -1652,9 +1657,9 @@ class SnapshotProcessor(HDF5Container):
self._sinks, self._sinks,
group="/datasets", group="/datasets",
unit={ unit={
"Id": U.none, "id": U.none,
"M": U.Msun, "msink": U.Msun,
"dmf": U.Msun, "dmfsink": U.Msun,
"x": "unit_density", "x": "unit_density",
"y": "unit_density", "y": "unit_density",
"z": "unit_density", "z": "unit_density",
@@ -1662,14 +1667,24 @@ class SnapshotProcessor(HDF5Container):
"vy": "unit_velocity", "vy": "unit_velocity",
"vz": "unit_velocity", "vz": "unit_velocity",
"rot_period": "unit_time", "rot_period": "unit_time",
"lx": U.none, "lx": {"unit_mass" : 1, "unit_length" : 2, "unit_time" : -1},
"ly": U.none, "ly": {"unit_mass" : 1, "unit_length" : 2, "unit_time" : -1},
"lz": U.none, "lz": {"unit_mass" : 1, "unit_length" : 2, "unit_time" : -1},
"acc_rate": U.none, "acc_rate": {"unit_mass" : 1, "unit_time" : -1},
"acc_lum": U.none, "acc_lum": U.none,
"age": U.year, "age": U.year,
"int_lum": U.none, "int_lum": U.none,
"Teff": U.K, "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"), "pspec": Rule(self, self._pspec, "Power spectrum", "/hdf5"),