This commit is contained in:
Noe Brucy
2020-02-29 10:16:27 +01:00
parent 8d7c5296cc
commit 1c2750a7bd
4 changed files with 1669 additions and 32 deletions
+43 -17
View File
@@ -129,6 +129,8 @@ class Plotter(Aggregator, BaseProcessor):
if rule.kind == "classic":
try:
runs = kwargs.pop("runs")
if isinstance(runs, RunSelector):
runs = runs.runs
except KeyError:
runs = self.runs
@@ -150,7 +152,12 @@ class Plotter(Aggregator, BaseProcessor):
run=run,
**kwargs
)
except TypeError:
except TypeError as e:
if (
str(e)
!= "'LocatableAxes' object does not support indexing"
):
raise
self._plot_rule(
rule,
save,
@@ -207,7 +214,7 @@ class Plotter(Aggregator, BaseProcessor):
tag_name = "_" + tag_name
if not run is None and not num is None:
fmt = "{out}/{run}/{name}{tag}_{run}_{num:05}_{ext}"
fmt = "{out}/{run}/{name}{tag}_{run}_{num:05}{ext}"
elif not run is None:
fmt = "{out}/{run}/{name}{tag}_{run}{ext}"
else:
@@ -300,6 +307,7 @@ class Plotter(Aggregator, BaseProcessor):
overlays=[],
overlays_kwargs=[],
title=None,
put_title=True,
nml_key=None,
put_time=True,
time_unit=cst.Myr,
@@ -352,19 +360,20 @@ class Plotter(Aggregator, BaseProcessor):
if not label is None:
cbar.set_label(label)
title = self._label_run(run, node, title, nml_key)
if put_title:
title = self._label_run(run, node, title, nml_key)
if put_time:
time = self.save.root._v_attrs.time * self.comp.info["unit_time"]
time_str = self.pp_params.plot.time_fmt.format(
time.express(time_unit), time_unit.latex
)
if len(title) > 0:
title = title + " | " + time_str
else:
title = time_str
if put_time:
time = self.save.root._v_attrs.time * self.comp.info["unit_time"]
time_str = self.pp_params.plot.time_fmt.format(
time.express(time_unit), time_unit.latex
)
if len(title) > 0:
title = title + " | " + time_str
else:
title = time_str
P.title(title)
P.title(title)
for i, plot_overlay in enumerate(overlays):
try:
@@ -470,6 +479,7 @@ class Plotter(Aggregator, BaseProcessor):
xlog=None,
ylog=False,
kind="bar",
color=None,
colors=None,
nml_color=None,
**kwargs
@@ -505,8 +515,7 @@ class Plotter(Aggregator, BaseProcessor):
P.title(title)
color = None
if not colors is None:
if color is None and not colors is None:
if nml_color is None:
color = colors[run]
else:
@@ -547,6 +556,7 @@ class Plotter(Aggregator, BaseProcessor):
self,
name_x,
name_y,
node_arg=None,
xlabel=None,
ylabel=None,
label=None,
@@ -558,14 +568,19 @@ class Plotter(Aggregator, BaseProcessor):
fitlabel=None,
smooth=0,
nml_key=None,
run=None,
runs=None,
yerr_kind="std",
sigma_err=2.0,
grid=True,
colors=None,
nml_color=None,
**kwargs
):
if not node_arg is None:
name_x, name_y = name_x + "_" + node_arg, name_y + "_" + node_arg
node_x = self.save.get_node(name_x)
node_y = self.save.get_node(name_y)
@@ -578,7 +593,9 @@ class Plotter(Aggregator, BaseProcessor):
P.xlabel(xlabel)
P.ylabel(ylabel)
P.grid()
if grid:
P.grid()
yerr = None
if node_y._v_attrs.CLASS == "ARRAY":
@@ -588,7 +605,9 @@ class Plotter(Aggregator, BaseProcessor):
x, y = x[mask], y[mask]
if smooth > 0:
y = gaussian_filter1d(y, sigma=smooth)
(base_line,) = P.plot(x, y, "*", **kwargs)
if not run is None:
label = self._label_run(run, node_y, label, nml_key)
(base_line,) = P.plot(x, y, label=label, **kwargs)
elif "mean" in node_y:
x = node_x.read() * xunit_old.express(xunit)
y = node_y.mean.read() * yunit_old.express(yunit)
@@ -616,6 +635,8 @@ class Plotter(Aggregator, BaseProcessor):
yerr_min[mask],
yerr_max[mask],
)
if not run is None:
label = self._label_run(run, node_y, label, nml_key)
base_line, _, _ = P.errorbar(
x, y, yerr=[y - yerr_min, yerr_max - y], label=label, **kwargs
)
@@ -806,6 +827,11 @@ class Plotter(Aggregator, BaseProcessor):
"P_pdf": PlotRule(
self, partial(self._plot_hist, "P_pdf"), "P-PDF", dependencies=["P_pdf"]
),
"rho_prof": PlotRule(
self,
partial(self._plot, "/profile/axis", "/profile/rho_prof"),
dependencies=["axis", "rho_prof"],
),
}
averageables = ["coldens", "rho", "T", "Q"]