[plotter] deal with no sinks snaps (+ cosmetics)
This commit is contained in:
+36
-25
@@ -378,9 +378,7 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
|
||||
return datafiles
|
||||
|
||||
def _plot_rule(
|
||||
self, rule, arg, plot_filename, overwrite, ax, close=True, **kwargs
|
||||
):
|
||||
def _plot_rule(self, rule, arg, plot_filename, overwrite, ax, close=True, **kwargs):
|
||||
"""
|
||||
Once all dependencies are met, actually process the rule
|
||||
"""
|
||||
@@ -492,7 +490,7 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
if os.path.basename(node_name) in self.label_convert:
|
||||
label = self.label_convert[os.path.basename(node_name)]
|
||||
else:
|
||||
label = os.path.basename(node_name)
|
||||
label = os.path.basename(node_name)
|
||||
|
||||
try:
|
||||
unit_old = self.current_processor.get_attribute(node_name, "unit")
|
||||
@@ -610,12 +608,12 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
scalebar = AnchoredSizeBar(
|
||||
plt.gca().transData,
|
||||
scalebar_size,
|
||||
f'{scalebar_size} {unit_str(unit_space)[2:-1]}',
|
||||
'lower left',
|
||||
f"{scalebar_size} {unit_str(unit_space)[2:-1]}",
|
||||
"lower left",
|
||||
pad=1,
|
||||
color='white',
|
||||
color="white",
|
||||
frameon=False,
|
||||
size_vertical=1
|
||||
size_vertical=1,
|
||||
)
|
||||
plt.gca().add_artist(scalebar)
|
||||
|
||||
@@ -635,12 +633,14 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
|
||||
if colorbar:
|
||||
if embeded:
|
||||
cbaxes = inset_axes(ax, width="10%", height="100%", loc="right", borderpad=0)
|
||||
cbar = plt.colorbar(cax=cbaxes, orientation='vertical')
|
||||
cbaxes.yaxis.set_ticks_position('left')
|
||||
cbaxes.yaxis.set_label_position('left')
|
||||
cbaxes = inset_axes(
|
||||
ax, width="10%", height="100%", loc="right", borderpad=0
|
||||
)
|
||||
cbar = plt.colorbar(cax=cbaxes, orientation="vertical")
|
||||
cbaxes.yaxis.set_ticks_position("left")
|
||||
cbaxes.yaxis.set_label_position("left")
|
||||
cbaxes.yaxis.set_tick_params(color="white", which="both")
|
||||
plt.setp(plt.getp(cbaxes.axes, 'yticklabels'), color="white")
|
||||
plt.setp(plt.getp(cbaxes.axes, "yticklabels"), color="white")
|
||||
cbar.outline.set_edgecolor("white")
|
||||
cbaxes.tick_params(axis="y", direction="in", pad=-25)
|
||||
plt.sca(ax)
|
||||
@@ -715,7 +715,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
"""
|
||||
Add an overlay : contour of other map
|
||||
"""
|
||||
map_contour = self.current_processor.get_value("/maps/{}_{}".format(map_name, ax_los))
|
||||
map_contour = self.current_processor.get_value(
|
||||
"/maps/{}_{}".format(map_name, ax_los)
|
||||
)
|
||||
if log:
|
||||
map_contour = np.log10(map_contour)
|
||||
# Computing linewidths
|
||||
@@ -774,9 +776,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
im_extent,
|
||||
unit_space=U.pc,
|
||||
center_space=False,
|
||||
parts = True,
|
||||
sinks = False,
|
||||
**kwargs
|
||||
parts=True,
|
||||
sinks=False,
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
Add an overlay with particles data
|
||||
@@ -785,11 +787,17 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
unit_length = self.current_processor.info["unit_length"]
|
||||
|
||||
if sinks:
|
||||
self.current_processor.sinks()
|
||||
sinks = pd.DataFrame(self.current_processor.get_value("/datasets/sinks"))
|
||||
part_pos = sinks[["x", "y", "z"]].values
|
||||
mass = sinks.M
|
||||
unit_length /= self.current_processor.lbox
|
||||
try:
|
||||
self.current_processor.sinks()
|
||||
sinks = pd.DataFrame(
|
||||
self.current_processor.get_value("/datasets/sinks")
|
||||
)
|
||||
part_pos = sinks[["x", "y", "z"]].values
|
||||
mass = sinks.M
|
||||
unit_length /= self.current_processor.lbox
|
||||
except KeyError:
|
||||
self.current_processor._log("No sinks particles", "WARNING")
|
||||
return
|
||||
elif parts:
|
||||
# Open particle HDF5 filetype_from_ext
|
||||
self.current_processor.load_parts(keys=["pos", "mass"])
|
||||
@@ -830,7 +838,7 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
part_v = part_v[mask]
|
||||
|
||||
# Scatter plot
|
||||
plt.scatter(part_h, part_v, s=mass/5e3, **kwargs)
|
||||
plt.scatter(part_h, part_v, s=mass / 5e3, **kwargs)
|
||||
|
||||
def _overlay_speed(
|
||||
self, ax_los, im_extent, unit=U.km_s, unit_coeff=1.0, key_v=None, **kwargs
|
||||
@@ -841,7 +849,9 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
dmap_vh = self.current_processor.get_value("/maps/speed_h_{}".format(ax_los))
|
||||
dmap_vv = self.current_processor.get_value("/maps/speed_v_{}".format(ax_los))
|
||||
|
||||
label, unit_old, unit = self._ax_label_unit(f"/maps/speed_h_{ax_los}", "", unit, unit_coeff)
|
||||
label, unit_old, unit = self._ax_label_unit(
|
||||
f"/maps/speed_h_{ax_los}", "", unit, unit_coeff
|
||||
)
|
||||
|
||||
vel_red = self.params.plot.vel_red
|
||||
|
||||
@@ -1187,7 +1197,8 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
color = colors[run]
|
||||
elif nml_color == "time":
|
||||
time = (
|
||||
self.current_processor.time * self.current_processor.info["unit_time"]
|
||||
self.current_processor.time
|
||||
* self.current_processor.info["unit_time"]
|
||||
).express(unit_time)
|
||||
color = colors(time)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user