Merge branch 'dev' into targe_rules
This commit is contained in:
@@ -137,16 +137,16 @@ def run_sim(args):
|
|||||||
|
|
||||||
method = prep_ray()
|
method = prep_ray()
|
||||||
run_simulation(args.config, method=method)
|
run_simulation(args.config, method=method)
|
||||||
if sys.platform == "darwin" and sys.stdout.isatty():
|
# if sys.platform == "darwin" and sys.stdout.isatty():
|
||||||
subprocess.run(
|
# subprocess.run(
|
||||||
[
|
# [
|
||||||
"osascript",
|
# "osascript",
|
||||||
"-e",
|
# "-e",
|
||||||
'tell app "System Events" to display dialog "simulation finished !"',
|
# 'tell app "System Events" to display dialog "simulation finished !"',
|
||||||
],
|
# ],
|
||||||
stdout=subprocess.DEVNULL,
|
# stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL,
|
# stderr=subprocess.DEVNULL,
|
||||||
)
|
# )
|
||||||
|
|
||||||
|
|
||||||
def merge(args):
|
def merge(args):
|
||||||
|
|||||||
@@ -1039,14 +1039,18 @@ def rin_curve(spectra: np.ndarray) -> np.ndarray:
|
|||||||
----------
|
----------
|
||||||
spectra : np.ndarray, shape (n, nt)
|
spectra : np.ndarray, shape (n, nt)
|
||||||
a collection of n spectra from which to compute the RIN
|
a collection of n spectra from which to compute the RIN
|
||||||
|
complex amplitude is automatically converted to intensity
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
rin_curve : np.ndarray
|
rin_curve : np.ndarray
|
||||||
RIN curve
|
RIN curve
|
||||||
"""
|
"""
|
||||||
A2 = abs2(spectra)
|
if np.iscomplexobj(spectra):
|
||||||
return np.std(A2, axis=0) / np.mean(A2, axis=0)
|
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]:
|
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 .const import SPECN_FN
|
||||||
from .logger import get_logger
|
from .logger import get_logger
|
||||||
from .physics import pulse, units
|
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
|
from .utils.parameter import Parameters, PlotRange
|
||||||
|
|
||||||
|
|
||||||
@@ -356,6 +361,35 @@ class Pulse(Sequence):
|
|||||||
vals = vals[sim_ind]
|
vals = vals[sim_ind]
|
||||||
return plt_range, vals
|
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:
|
def z_ind(self, z: float) -> int:
|
||||||
"""return the closest z index to the given target
|
"""return the closest z index to the given target
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user