Merge branch 'dev' into targe_rules
This commit is contained in:
@@ -137,16 +137,16 @@ def run_sim(args):
|
||||
|
||||
method = prep_ray()
|
||||
run_simulation(args.config, method=method)
|
||||
if sys.platform == "darwin" and sys.stdout.isatty():
|
||||
subprocess.run(
|
||||
[
|
||||
"osascript",
|
||||
"-e",
|
||||
'tell app "System Events" to display dialog "simulation finished !"',
|
||||
],
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
# if sys.platform == "darwin" and sys.stdout.isatty():
|
||||
# subprocess.run(
|
||||
# [
|
||||
# "osascript",
|
||||
# "-e",
|
||||
# 'tell app "System Events" to display dialog "simulation finished !"',
|
||||
# ],
|
||||
# stdout=subprocess.DEVNULL,
|
||||
# stderr=subprocess.DEVNULL,
|
||||
# )
|
||||
|
||||
|
||||
def merge(args):
|
||||
|
||||
@@ -1039,14 +1039,18 @@ def rin_curve(spectra: np.ndarray) -> np.ndarray:
|
||||
----------
|
||||
spectra : np.ndarray, shape (n, nt)
|
||||
a collection of n spectra from which to compute the RIN
|
||||
complex amplitude is automatically converted to intensity
|
||||
|
||||
Returns
|
||||
-------
|
||||
rin_curve : np.ndarray
|
||||
RIN curve
|
||||
"""
|
||||
A2 = abs2(spectra)
|
||||
return np.std(A2, axis=0) / np.mean(A2, axis=0)
|
||||
if np.iscomplexobj(spectra):
|
||||
A2 = abs2(spectra)
|
||||
else:
|
||||
A2 = spectra
|
||||
return np.std(A2, axis=-2) / np.mean(A2, axis=-2)
|
||||
|
||||
|
||||
def measure_field(t: np.ndarray, field: np.ndarray) -> Tuple[float, float, float]:
|
||||
|
||||
@@ -10,7 +10,12 @@ from . import math
|
||||
from .const import SPECN_FN
|
||||
from .logger import get_logger
|
||||
from .physics import pulse, units
|
||||
from .plotting import mean_values_plot, propagation_plot, single_position_plot
|
||||
from .plotting import (
|
||||
mean_values_plot,
|
||||
propagation_plot,
|
||||
single_position_plot,
|
||||
transform_2D_propagation,
|
||||
)
|
||||
from .utils.parameter import Parameters, PlotRange
|
||||
|
||||
|
||||
@@ -356,6 +361,35 @@ class Pulse(Sequence):
|
||||
vals = vals[sim_ind]
|
||||
return plt_range, vals
|
||||
|
||||
def rin_propagation(
|
||||
self, left: float, right: float, unit: str
|
||||
) -> tuple[np.ndarray, np.ndarray, np.ndarray]:
|
||||
"""returns the RIN as function of unit and z
|
||||
|
||||
Parameters
|
||||
----------
|
||||
left : float
|
||||
left limit in unit
|
||||
right : float
|
||||
right limit in unit
|
||||
unit : str
|
||||
unit descriptor
|
||||
|
||||
Returns
|
||||
-------
|
||||
x : np.ndarray, shape (nt,)
|
||||
x axis
|
||||
y : np.ndarray, shape (z_num, )
|
||||
y axis
|
||||
rin_prop : np.ndarray, shape (z_num, nt)
|
||||
RIN
|
||||
"""
|
||||
spectra = []
|
||||
for spec in np.moveaxis(self.all_spectra(), 1, 0):
|
||||
x, z, tmp = transform_2D_propagation(spec, (left, right, unit), self.params, False)
|
||||
spectra.append(tmp)
|
||||
return x, z, pulse.rin_curve(np.moveaxis(spectra, 0, 1))
|
||||
|
||||
def z_ind(self, z: float) -> int:
|
||||
"""return the closest z index to the given target
|
||||
|
||||
|
||||
Reference in New Issue
Block a user