Remove log in Brho, clean and comment
This commit is contained in:
+55
-3
@@ -142,7 +142,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
self.save = None
|
||||
|
||||
def _not_self_dep(self, name, dep, dep_arg, overwrite, **kwargs):
|
||||
""""""
|
||||
"""
|
||||
Check if the dependency belongs to the plotter object or to another one (comp, pp, ..)
|
||||
"""
|
||||
if dep in self.comp.rules:
|
||||
done = self.comp.process(dep, dep_arg, overwrite, overwrite)
|
||||
self.just_done.extend(done)
|
||||
@@ -150,6 +152,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
super(Plotter, self)._not_self_dep(name, dep, dep_arg, overwrite, **kwargs)
|
||||
|
||||
def _needs_computation(self, overwrite, plot_filename):
|
||||
"""
|
||||
Returns true if the plot needs to be redone
|
||||
"""
|
||||
return (
|
||||
self.pp_params.out.interactive
|
||||
or overwrite
|
||||
@@ -167,6 +172,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
from_cells=False,
|
||||
**kwargs
|
||||
):
|
||||
"""
|
||||
Generic method to process a rule, with its dependencies
|
||||
"""
|
||||
if not arg is None:
|
||||
name_full = name + "_" + str(arg)
|
||||
else:
|
||||
@@ -262,6 +270,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
self._log("{} is not valid in this context".format(name_full), "ERROR")
|
||||
|
||||
def _plot_rule(self, rule, save, arg, plot_filename, overwrite, ax, **kwargs):
|
||||
"""
|
||||
Once all dependencies are met, actually process the rule
|
||||
"""
|
||||
P.sca(ax)
|
||||
if self._needs_computation(overwrite, plot_filename):
|
||||
rule.plot(save, arg, **kwargs)
|
||||
@@ -278,7 +289,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
self._log("Plot {} is already done, skipping...".format(plot_filename))
|
||||
|
||||
def _find_filename(self, name_full, run=None, num=None, fmt=None):
|
||||
|
||||
"""
|
||||
Determine a filename based on rule name, run, output and parameters
|
||||
"""
|
||||
tag_name = self.pp_params.out.tag
|
||||
|
||||
if fmt is None and self.pp_params.out.fmt == "":
|
||||
@@ -309,6 +322,10 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
)
|
||||
|
||||
def _label_run(self, run, node, label, nml_key):
|
||||
"""
|
||||
Set up a label for the run from the namelist and parameters
|
||||
"""
|
||||
|
||||
def get_label_nml(nml_key):
|
||||
prop_name = os.path.basename(nml_key)
|
||||
if prop_name in self.label_convert:
|
||||
@@ -344,6 +361,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
return label_run
|
||||
|
||||
def _ax_label_unit(self, node, label, unit, unit_coeff):
|
||||
"""
|
||||
Find appropriate labels for axis
|
||||
"""
|
||||
if label is None:
|
||||
if "label" in node._v_attrs:
|
||||
label = node._v_attrs.label
|
||||
@@ -393,6 +413,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
autoscale=True,
|
||||
**kwargs
|
||||
):
|
||||
"""
|
||||
Plot data on a map
|
||||
"""
|
||||
|
||||
ax_h = self._axes_h[ax_los]
|
||||
ax_v = self._axes_v[ax_los]
|
||||
@@ -457,6 +480,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
plot_overlay(ax_los)
|
||||
|
||||
def _overlay_levels(self, ax_los):
|
||||
"""
|
||||
Add an overlay : AMR levels
|
||||
"""
|
||||
map_level = self.save.get_node("/maps/{}_{}".format("levels", ax_los)).read()
|
||||
# Computing linewidths
|
||||
levels_ar = np.arange(np.min(map_level), np.max(map_level) + 1)
|
||||
@@ -482,6 +508,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
def _overlay_speed(
|
||||
self, ax_los, unit=cst.km_s, unit_coeff=1.0, key_v=None, **kwargs
|
||||
):
|
||||
"""
|
||||
Add an overlay : velocity vector field
|
||||
"""
|
||||
ax_h = self._axes_h[ax_los]
|
||||
ax_v = self._axes_v[ax_los]
|
||||
dmap_vh_node = self.save.get_node("/maps/speed_h_{}".format(ax_los))
|
||||
@@ -524,6 +553,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
)
|
||||
|
||||
def _overlay_B(self, ax_los, **kwargs):
|
||||
"""
|
||||
Add an overlay : magnetic streamlines
|
||||
"""
|
||||
ax_h = self._axes_h[ax_los]
|
||||
ax_v = self._axes_v[ax_los]
|
||||
dmap_Bh_node = self.save.get_node("/maps/B_h_{}".format(ax_los))
|
||||
@@ -552,6 +584,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
P.streamplot(hh, vv, map_Bh_red, map_Bv_red)
|
||||
|
||||
def _plot_radial(self, name, ax_los, label=None, xlog=False, ylog=False):
|
||||
"""
|
||||
Plot a radial profile (for disks, OUTDATED)
|
||||
"""
|
||||
|
||||
radial_bins = self.save.get_node("/radial/radial_bins_" + ax_los).read()
|
||||
bin_centers = 0.5 * (radial_bins[1:] + radial_bins[:-1])
|
||||
@@ -593,7 +628,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
fitlabel=None,
|
||||
**kwargs
|
||||
):
|
||||
|
||||
"""
|
||||
Plot an histogram (PDF, etc ...)
|
||||
"""
|
||||
if not ax_los is None:
|
||||
name = name + "_" + ax_los
|
||||
|
||||
@@ -707,6 +744,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
subname_y=None,
|
||||
**kwargs
|
||||
):
|
||||
"""
|
||||
Generic plot routine, with name_x and name_y two path in the hdf5 file
|
||||
"""
|
||||
|
||||
if not node_arg is None:
|
||||
name_x, name_y = name_x + "_" + node_arg, name_y + "_" + node_arg
|
||||
@@ -856,12 +896,18 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
hdf5_y.close()
|
||||
|
||||
def _pspec(self, name, **kwargs):
|
||||
"""
|
||||
Plot power spectrum
|
||||
"""
|
||||
del kwargs["run"]
|
||||
file_pspec = self.save.get_node("/hdf5/pspec").read()
|
||||
num = self.save.root._v_attrs.num
|
||||
getattr(pspec_read, "pspec_" + name)(file_pspec, ".", num, **kwargs)
|
||||
|
||||
def _overlay_fit(self, x, y, yerr=None, kind="linear", label=None, **kwargs):
|
||||
"""
|
||||
Add an overlay : fit a curve, linear or powerlaw
|
||||
"""
|
||||
if kind == "linear":
|
||||
if yerr is None:
|
||||
(a, b, rho, _map_rule, stderr) = linregress(x, y)
|
||||
@@ -917,6 +963,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
P.plot(x, (10 ** b) * x ** a, label=label, **kwargs)
|
||||
|
||||
def overlay_kennicutt(self, n0, step):
|
||||
"""
|
||||
Add an overlay : kennicutt mass accretion
|
||||
"""
|
||||
P.grid(False)
|
||||
ylim = P.ylim()
|
||||
(tmin, tmax) = P.xlim()
|
||||
@@ -934,6 +983,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
P.ylim(ylim)
|
||||
|
||||
def def_rules(self):
|
||||
"""
|
||||
That is where rules are defined
|
||||
"""
|
||||
self.rules = {
|
||||
# Generic rules
|
||||
"plot": PlotRule(
|
||||
|
||||
Reference in New Issue
Block a user