This commit is contained in:
Benoît Sierro
2021-07-30 15:03:01 +02:00
parent 0186155885
commit 00294bd104
2 changed files with 7 additions and 2 deletions

View File

@@ -269,6 +269,7 @@ def propagation_plot(
vmin: float = None, vmin: float = None,
vmax: float = None, vmax: float = None,
transpose: bool = False, transpose: bool = False,
skip: int = 1,
cbar_label: Optional[str] = "normalized intensity (dB)", cbar_label: Optional[str] = "normalized intensity (dB)",
cmap: str = None, cmap: str = None,
) -> tuple[plt.Figure, plt.Axes, plt.Line2D, np.ndarray, np.ndarray]: ) -> tuple[plt.Figure, plt.Axes, plt.Line2D, np.ndarray, np.ndarray]:
@@ -290,6 +291,8 @@ def propagation_plot(
maximum value, by default None maximum value, by default None
transpose : bool, optional transpose : bool, optional
whether to transpose the plot (rotate the plot 90° counterclockwise), by default False whether to transpose the plot (rotate the plot 90° counterclockwise), by default False
skip : int, optional
only plot one every skip values along the x axis (y if transposed), by default 1
cbar_label : Optional[str], optional cbar_label : Optional[str], optional
label of the colorbar. No colorbar is drawn if this is set to None, by default "normalized intensity (dB)" label of the colorbar. No colorbar is drawn if this is set to None, by default "normalized intensity (dB)"
cmap : str, optional cmap : str, optional
@@ -298,7 +301,7 @@ def propagation_plot(
Axes obj on which to draw, by default None Axes obj on which to draw, by default None
""" """
x_axis, y_axis, values = transform_2D_propagation(values, plt_range, params, log) x_axis, y_axis, values = transform_2D_propagation(values, plt_range, params, log, skip)
if log is not False: if log is not False:
vmax = defaults["vmax"] if vmax is None else vmax vmax = defaults["vmax"] if vmax is None else vmax
vmin = defaults["vmin"] if vmin is None else vmin vmin = defaults["vmin"] if vmin is None else vmin
@@ -417,6 +420,7 @@ def transform_2D_propagation(
plt_range: Union[units.PlotRange, RangeType], plt_range: Union[units.PlotRange, RangeType],
params: BareParams, params: BareParams,
log: Union[int, float, bool, str] = "1D", log: Union[int, float, bool, str] = "1D",
skip: int = 1,
) -> tuple[np.ndarray, np.ndarray, np.ndarray]: ) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
if values.ndim != 2: if values.ndim != 2:
@@ -430,7 +434,7 @@ def transform_2D_propagation(
x_axis, values = uniform_axis(x_axis, values, plt_range) x_axis, values = uniform_axis(x_axis, values, plt_range)
y_axis, values.T[:] = uniform_axis(y_axis, values.T, None) y_axis, values.T[:] = uniform_axis(y_axis, values.T, None)
values = apply_log(values, log) values = apply_log(values, log)
return x_axis, y_axis, values return x_axis[::skip], y_axis, values[:, ::skip]
def mean_values_plot( def mean_values_plot(

View File

@@ -47,6 +47,7 @@ def plot_all(sim_dir: Path, limits: list[str], show=False, **opts):
+ f"{left:.1f}{PARAM_SEPARATOR}{right:.1f}{PARAM_SEPARATOR}{unit}" + f"{left:.1f}{PARAM_SEPARATOR}{right:.1f}{PARAM_SEPARATOR}{unit}"
) )
) )
fig.suptitle(p.name)
pulse.plot_2D( pulse.plot_2D(
left, left,
right, right,