Merge branch 'master' into dev
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
# flake8: noqa
|
||||
from . import math
|
||||
from .evaluator import Evaluator
|
||||
from .legacy import convert_sim_folder
|
||||
from .math import abs2, argclosest, span
|
||||
from .math import abs2, argclosest, normalized, span
|
||||
from .parameter import Configuration, Parameters
|
||||
from .physics import fiber, materials, pulse, simulate, units
|
||||
from .physics.simulate import RK4IP, parallel_RK4IP, run_simulation
|
||||
@@ -19,4 +20,3 @@ from .plotting import (
|
||||
from .spectra import SimulationSeries, Spectrum
|
||||
from .utils import Paths, _open_config, open_single_config
|
||||
from .variationer import DescriptorDict, VariationDescriptor, Variationer, VariationSpecsError
|
||||
from .evaluator import Evaluator
|
||||
|
||||
@@ -77,6 +77,11 @@ def abs2(z: np.ndarray) -> np.ndarray:
|
||||
return z.real ** 2 + z.imag ** 2
|
||||
|
||||
|
||||
def normalized(z: np.ndarray) -> np.ndarray:
|
||||
ab = abs2(z)
|
||||
return ab / ab.max()
|
||||
|
||||
|
||||
def sigmoid(x):
|
||||
return 1 / (np.exp(-x) + 1)
|
||||
|
||||
|
||||
@@ -1151,3 +1151,7 @@ def remove_2nd_order_dispersion2(
|
||||
opti = minimize_scalar(score, bounds=(-max_gdd * 1e30, max_gdd * 1e30))
|
||||
opti["x"] *= 1e-30
|
||||
return propagate(opti.x * 1e30), opti
|
||||
|
||||
|
||||
def gdd(w: np.ndarray, gdd: float) -> np.ndarray:
|
||||
return np.exp(0.5j * w ** 2 * gdd)
|
||||
|
||||
@@ -1041,12 +1041,20 @@ def measure_and_annotate_fwhm(
|
||||
field = abs2(field)
|
||||
_, (left, right), *_ = pulse.find_lobe_limits(unit.inv(t), field)
|
||||
arrow_label = f"{right - left:.1f} {unit.name}"
|
||||
|
||||
annotate_fwhm(ax, left, right, arrow_label, field.max(), side, arrow_length_pts, arrow_props)
|
||||
return right - left
|
||||
|
||||
|
||||
def annotate_fwhm(
|
||||
ax, left, right, arrow_label, v_max=1, side="right", arrow_length_pts=20.0, arrow_props=None
|
||||
):
|
||||
arrow_dict = dict(arrowstyle="->")
|
||||
if arrow_props is not None:
|
||||
arrow_dict |= arrow_props
|
||||
ax.annotate(
|
||||
"" if side == "right" else arrow_label,
|
||||
(left, field.max() / 2),
|
||||
(left, v_max / 2),
|
||||
xytext=(-arrow_length_pts, 0),
|
||||
ha="right",
|
||||
va="center",
|
||||
@@ -1055,13 +1063,12 @@ def measure_and_annotate_fwhm(
|
||||
)
|
||||
ax.annotate(
|
||||
"" if side == "left" else arrow_label,
|
||||
(right, field.max() / 2),
|
||||
(right, v_max / 2),
|
||||
xytext=(arrow_length_pts, 0),
|
||||
textcoords="offset points",
|
||||
arrowprops=arrow_dict,
|
||||
va="center",
|
||||
)
|
||||
return right - left
|
||||
|
||||
|
||||
def partial_plot(root: os.PathLike):
|
||||
|
||||
Reference in New Issue
Block a user