correct bugs

This commit is contained in:
Noe Brucy
2020-04-21 10:39:24 +02:00
parent 9e5fc8b4ad
commit 8dfdf918a0
3 changed files with 100 additions and 52 deletions
+49 -8
View File
@@ -126,7 +126,7 @@ class Plotter(Aggregator, BaseProcessor):
name_full = name
if rule.is_valid(arg):
if rule.kind == "classic":
if rule.kind == "classic" or rule.kind == "runs":
try:
runs = kwargs.pop("runs")
if isinstance(runs, RunSelector):
@@ -136,9 +136,17 @@ class Plotter(Aggregator, BaseProcessor):
i = 0
for run in runs:
files = []
for num in self.nums[run]:
if rule.kind == "classic":
nums = self.nums[run]
else:
nums = [None]
for num in nums:
plot_filename = self._find_filename(name_full, run, num)
save = tables.open_file(self.pp[run][num].filename)
if rule.kind == "classic":
save = tables.open_file(self.pp[run][num].filename)
else:
save = tables.open_file(self.comp.filename, "r")
try:
self._plot_rule(
rule,
@@ -265,7 +273,10 @@ class Plotter(Aggregator, BaseProcessor):
return r"{} = {}".format(prop_label, prop_value_str)
if nml_key is None and label is None:
if "attrs" in self.save.root._v_attrs:
if (
"attrs" in self.save.root._v_attrs
and run in self.save.root._v_attrs.attrs
):
label_run = r"{}".format(self.save.root._v_attrs.attrs[run].label)
else:
label_run = run
@@ -479,8 +490,9 @@ class Plotter(Aggregator, BaseProcessor):
def _plot_hist(
self,
name,
ax_los=None,
run="",
ax_los,
run,
group="/hist/",
label=None,
unit=None,
unit_coeff=1.0,
@@ -495,13 +507,15 @@ class Plotter(Aggregator, BaseProcessor):
color=None,
colors=None,
nml_color=None,
fit=None,
fitlabel=None,
**kwargs
):
if not ax_los is None:
name = name + "_" + ax_los
node = self.save.get_node("/hist/" + name)
node = self.save.get_node(group + name)
if xlog is None:
try:
@@ -511,7 +525,12 @@ class Plotter(Aggregator, BaseProcessor):
label, unit_old, unit = self._ax_label_unit(node, label, unit, unit_coeff)
values, centers = node.read()
if "mean" in node:
index = node["runs"].read().index(run)
values, centers = node["mean"].read()[index]
else:
values, centers = node.read()
if xlog:
centers = centers + np.log10(unit_old.express(unit))
else:
@@ -570,6 +589,11 @@ class Plotter(Aggregator, BaseProcessor):
P.ylim([None, 1.0])
if not fit is None:
self._overlay_fit(
centers, values, kind=fit, ls="--", lw=1.5, label=fitlabel
)
def _plot(
self,
name_x,
@@ -582,6 +606,7 @@ class Plotter(Aggregator, BaseProcessor):
yunit=None,
xunit_coeff=1.0,
yunit_coeff=1.0,
ylog=False,
fit=None,
fitlabel=None,
smooth=0,
@@ -618,6 +643,9 @@ class Plotter(Aggregator, BaseProcessor):
if grid:
P.grid()
if ylog:
P.yscale("log")
if put_time:
time = self.save.root._v_attrs.time * self.comp.info["unit_time"]
time_str = self.pp_params.plot.time_fmt.format(
@@ -878,6 +906,19 @@ class Plotter(Aggregator, BaseProcessor):
"$\rho$-PDF",
dependencies=["rho_pdf"],
),
"avg_coldens_pdf": PlotRule(
self,
partial(
self._plot_hist,
"avg_time_coldens_pdf_z",
group="/comp/",
xlog=True,
put_time=False,
),
"PDF",
kind="runs",
dependencies={"avg_time_coldens_pdf": "z"},
),
"T_pdf": PlotRule(
self, partial(self._plot_hist, "T_pdf"), "T-PDF", dependencies=["T_pdf"]
),