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