Ax-aware plotting, More PDFs, improve format

This commit is contained in:
Noe Brucy
2020-02-19 17:51:23 +01:00
parent a87abeb52d
commit 8d7c5296cc
5 changed files with 281 additions and 108 deletions
+33 -5
View File
@@ -217,9 +217,21 @@ class Comparator(Aggregator, HDF5Container):
cmd_grep = "sed '/cpu.*/d' {} | grep 'Number of sink' -A 2".format(log_filename)
content = os.popen(cmd_grep).readlines()
for i in range(0, len(content), 4):
series["nb_sink"][run].append(np.int(content[i].split("=")[1]))
series["mass_sink"][run].append(np.float(content[i + 1].split("=")[1]))
series["time"][run].append(np.float(content[i + 2].split("=")[1]))
try:
nb_sink = np.int(content[i].split("=")[1])
mass_sink = np.float(content[i + 1].split("=")[1])
time = np.float(content[i + 2].split("=")[1])
series["nb_sink"][run].append(nb_sink)
series["mass_sink"][run].append(mass_sink)
series["time"][run].append(time)
except (ValueError, IndexError):
self._log(
"Error encountered in parsing {} (grepped block {})".format(
log_filename, i
),
"WARNING",
)
return series
def _extract_sfr_from_log(self, series, log_filename, run):
@@ -299,16 +311,21 @@ class Comparator(Aggregator, HDF5Container):
"/series/sinks_from_log/mass_sink/" + run
).read()
mass_sink = mass_sink * mass_unit.express(cst.Msun)
if avg_window is None:
shift = 1
else:
# We assume that the timestep do not vary a lot ...
shift = np.searchsorted(time, time[0] + avg_window, side="left")
shift = np.searchsorted(time, time[-1] - avg_window, side="right")
shift = len(time) - shift
sfr = (mass_sink[shift:] - mass_sink[:-shift]) / (
time[shift:] - time[:-shift]
)
sfr_beg = (mass_sink[:shift] - mass_sink[0]) / (time[:shift] - time[0])
ssfr[run] = np.zeros(len(mass_sink))
ssfr[run][shift:] = sfr / surface
ssfr[run][:shift] = sfr_beg / surface
return ssfr, {"avg_window": avg_window}
def _turb_power(self):
@@ -376,6 +393,17 @@ class Comparator(Aggregator, HDF5Container):
"q975": "97.5 percentile of {}".format(descr),
}
# units={
# "runs": cst.none,
# "mean": unit,
# "std": unit,
# "median": unit,
# "max": unit,
# "min": unit,
# "q025": unit,
# "q975": unit}
units = unit
if name is None:
name = "avg_" + src_name
@@ -391,7 +419,7 @@ class Comparator(Aggregator, HDF5Container):
self,
fn,
group="/comp",
unit=unit,
unit=units,
description=description,
dependencies=[rule_src_name],
)