[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")
)
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")
+22 -7
View File
@@ -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"),