formatting
This commit is contained in:
@@ -107,6 +107,7 @@ class Cache:
|
||||
return data
|
||||
|
||||
wrapped.cached_only = cached_only
|
||||
wrapped.func = func
|
||||
|
||||
return wrapped
|
||||
|
||||
|
||||
@@ -259,20 +259,28 @@ class NoiseMeasurement:
|
||||
time = np.arange(len(signal)) / fs
|
||||
return time, signal
|
||||
|
||||
def root_integrated(self) -> np.ndarray:
|
||||
def root_integrated(self, from_right: bool = True) -> np.ndarray:
|
||||
"""
|
||||
returns the sqrt of the integrated spectrum
|
||||
The 0th component is the total RIN in the frequency range covered by the measurement
|
||||
Caution! this may be 0 frequency
|
||||
|
||||
Parameters
|
||||
----------
|
||||
from_right : bool, optional
|
||||
start integration at f[-1], by default True.
|
||||
"""
|
||||
return integrated_noise(self.freq, self.psd)
|
||||
return integrated_noise(self.freq, self.psd, from_right)
|
||||
|
||||
|
||||
def integrated_noise(freq: np.ndarray, psd: np.ndarray) -> float:
|
||||
def integrated_noise(freq: np.ndarray, psd: np.ndarray, from_right: bool = True) -> np.ndarray:
|
||||
"""
|
||||
given a normalized spectrum, computes the total rms RIN in the provided frequency window
|
||||
"""
|
||||
return np.sqrt(cumulative_trapezoid(np.abs(psd)[::-1], -freq[::-1], initial=0)[::-1])
|
||||
s = slice(None, None, -1) if from_right else slice(None)
|
||||
return np.sqrt(
|
||||
cumulative_trapezoid(np.abs(psd)[s], (1 - 2 * from_right) * freq[s], initial=0)[s]
|
||||
)
|
||||
|
||||
|
||||
def quantum_noise_limit(wavelength: float, power: float) -> float:
|
||||
|
||||
@@ -58,9 +58,7 @@ def dispersion_parameter_to_beta2(dispersion_parameter: float, wavelength: T) ->
|
||||
def dispersion_slope_to_beta3(
|
||||
dispersion_parameter: float, dispersion_slope: float, wavelength
|
||||
) -> float:
|
||||
return (wavelength**2 / pi2c) ** 2 * (
|
||||
dispersion_slope + 2 * dispersion_parameter / wavelength
|
||||
)
|
||||
return (wavelength**2 / pi2c) ** 2 * (dispersion_slope + 2 * dispersion_parameter / wavelength)
|
||||
|
||||
|
||||
def handle_dispersion_parameter(
|
||||
@@ -598,18 +596,8 @@ def saitoh_paramters(pcf_pitch_ratio: float) -> tuple[float, float]:
|
||||
di2 = np.array([9, 6.58, 10, 0.41])
|
||||
di3 = np.array([10, 24.8, 15, 6])
|
||||
|
||||
A = (
|
||||
ai0
|
||||
+ ai1 * pcf_pitch_ratio**bi1
|
||||
+ ai2 * pcf_pitch_ratio**bi2
|
||||
+ ai3 * pcf_pitch_ratio**bi3
|
||||
)
|
||||
B = (
|
||||
ci0
|
||||
+ ci1 * pcf_pitch_ratio**di1
|
||||
+ ci2 * pcf_pitch_ratio**di2
|
||||
+ ci3 * pcf_pitch_ratio**di3
|
||||
)
|
||||
A = ai0 + ai1 * pcf_pitch_ratio**bi1 + ai2 * pcf_pitch_ratio**bi2 + ai3 * pcf_pitch_ratio**bi3
|
||||
B = ci0 + ci1 * pcf_pitch_ratio**di1 + ci2 * pcf_pitch_ratio**di2 + ci3 * pcf_pitch_ratio**di3
|
||||
return A, B
|
||||
|
||||
|
||||
|
||||
@@ -179,20 +179,13 @@ class Spectrum(np.ndarray):
|
||||
|
||||
@property
|
||||
def wl_amp(self):
|
||||
return (
|
||||
np.sqrt(
|
||||
units.to_WL(
|
||||
math.abs2(self),
|
||||
self.l,
|
||||
)
|
||||
)
|
||||
* self
|
||||
/ np.abs(self)
|
||||
)[..., self.l_order]
|
||||
return (np.sqrt(units.to_WL(math.abs2(self), self.l)) * self / np.abs(self))[
|
||||
..., self.l_order
|
||||
]
|
||||
|
||||
@property
|
||||
def afreq_amp(self):
|
||||
return self[..., self.w_order[::-1]] * self.spectrum_factor
|
||||
return self[..., self.w_order] * self.spectrum_factor
|
||||
|
||||
@property
|
||||
def time_amp(self):
|
||||
@@ -242,7 +235,10 @@ class Spectrum(np.ndarray):
|
||||
band = peak * np.exp(-(((self.l - pos) / (pulse.fwhm_to_T0_fac["gaussian"] * width)) ** 2))
|
||||
if shot_noise:
|
||||
sn = np.reshape(
|
||||
[pulse.shot_noise(self.w, *shot_noise) for _ in range(np.prod(self.shape[:-1]))],
|
||||
[
|
||||
pulse.shot_noise(self.w, *shot_noise)
|
||||
for _ in range(np.prod(self.shape[:-1] + (1,)))
|
||||
],
|
||||
self.shape,
|
||||
)
|
||||
return self * band + np.sqrt(1 - band**2) * sn
|
||||
|
||||
Reference in New Issue
Block a user