misc
This commit is contained in:
@@ -126,7 +126,7 @@ def initial_field(t, shape, t0, peak_power):
|
||||
raised when shape is not recognized
|
||||
"""
|
||||
if shape == "gaussian":
|
||||
return gauss_pulse(t, t0, peak_power)
|
||||
return gaussian_pulse(t, t0, peak_power)
|
||||
elif shape == "sech":
|
||||
return sech_pulse(t, t0, peak_power)
|
||||
else:
|
||||
@@ -352,7 +352,7 @@ def sech_pulse(t, t0, P0, offset=0):
|
||||
return np.sqrt(P0) / np.cosh((t - offset) / t0)
|
||||
|
||||
|
||||
def gauss_pulse(t, t0, P0, offset=0):
|
||||
def gaussian_pulse(t, t0, P0, offset=0):
|
||||
return np.sqrt(P0) * np.exp(-(((t - offset) / t0) ** 2))
|
||||
|
||||
|
||||
@@ -774,7 +774,7 @@ def find_lobe_limits(x_axis, values, debug="", already_sorted=True):
|
||||
)
|
||||
|
||||
good_roots, left_lim, right_lim = _select_roots(d_spline, d_roots, dd_roots, fwhm_pos)
|
||||
|
||||
if debug != "":
|
||||
ax.scatter(
|
||||
[left_lim, right_lim],
|
||||
spline_4([left_lim, right_lim]),
|
||||
@@ -885,14 +885,19 @@ def _detailed_find_lobe_limits(
|
||||
# if measurement of the peak is not straightforward, we plot the situation to see
|
||||
# if the final measurement is good or not
|
||||
|
||||
out_path, fig, ax = plot_setup(out_path=f"measurement_errors_plots/it_{iterations}_{debug}")
|
||||
out_path, fig, ax = (
|
||||
plot_setup(out_path=f"measurement_errors_plots/it_{iterations}_{debug}")
|
||||
if debug != ""
|
||||
else (None, None, None)
|
||||
)
|
||||
|
||||
new_fwhm_pos = np.array([np.max(left_pos), np.min(right_pos)])
|
||||
|
||||
# PLOT
|
||||
|
||||
newx = np.linspace(*span(x_axis[l_ind : r_ind + 1]), 1000)
|
||||
color = default_plotting["color_cycle"]
|
||||
if debug != "":
|
||||
newx = np.linspace(*span(x_axis[l_ind : r_ind + 1]), 1000)
|
||||
ax.plot(x_axis[l_ind - 5 : r_ind + 6], values[l_ind - 5 : r_ind + 6], c=color[0])
|
||||
ax.plot(newx, spline_5(newx), c=color[1])
|
||||
ax.scatter(fwhm_pos, spline_4(fwhm_pos), marker="+", label="all fwhm", c=color[2])
|
||||
|
||||
@@ -422,6 +422,35 @@ def transform_2D_propagation(
|
||||
log: Union[int, float, bool, str] = "1D",
|
||||
skip: int = 1,
|
||||
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
||||
"""transforms raws values into plottable values
|
||||
|
||||
Parameters
|
||||
----------
|
||||
values : np.ndarray, shape (n, nt)
|
||||
values to transform
|
||||
plt_range : Union[units.PlotRange, RangeType]
|
||||
range
|
||||
params : BareParams
|
||||
parameters of the simulation
|
||||
log : Union[int, float, bool, str], optional
|
||||
see apply_log, by default "1D"
|
||||
skip : int, optional
|
||||
take one every skip values, by default 1
|
||||
|
||||
Returns
|
||||
-------
|
||||
np.ndarray
|
||||
x_axis
|
||||
np.ndarray
|
||||
y_axis
|
||||
np.ndarray
|
||||
values
|
||||
|
||||
Raises
|
||||
------
|
||||
ValueError
|
||||
incorrect shape
|
||||
"""
|
||||
|
||||
if values.ndim != 2:
|
||||
raise ValueError(f"shape was {values.shape}. Can only plot 2D array")
|
||||
|
||||
@@ -216,7 +216,7 @@ def format_value(name: str, value) -> str:
|
||||
except AttributeError:
|
||||
return format(value, ".9g")
|
||||
elif isinstance(value, (list, tuple, np.ndarray)):
|
||||
return "-".join([format_value(v) for v in value])
|
||||
return "-".join([str(v) for v in value])
|
||||
elif isinstance(value, str):
|
||||
p = Path(value)
|
||||
if p.exists():
|
||||
|
||||
Reference in New Issue
Block a user