spectrum scaling correction
This commit is contained in:
@@ -56,6 +56,7 @@ class Spectrum(np.ndarray):
|
||||
obj.ifft = ifft
|
||||
obj.l = 2 * np.pi * units.c / obj.w
|
||||
obj.l_order = np.argsort(obj.l)
|
||||
obj.spectrum_factor = (obj.t[1] - obj.t[0]) / np.sqrt(2 * np.pi)
|
||||
|
||||
if not (len(obj.w) == len(obj.t) == len(obj.l) == obj.shape[-1]):
|
||||
raise ValueError(
|
||||
@@ -75,6 +76,7 @@ class Spectrum(np.ndarray):
|
||||
self.l = getattr(obj, "l", None)
|
||||
self.w_order = getattr(obj, "w_order", None)
|
||||
self.l_order = getattr(obj, "l_order", None)
|
||||
self.spectrum_factor = getattr(obj, "spectrum_factor", None)
|
||||
self.ifft = getattr(obj, "ifft", None)
|
||||
|
||||
def __getitem__(self, key) -> "Spectrum":
|
||||
@@ -90,15 +92,11 @@ class Spectrum(np.ndarray):
|
||||
|
||||
@property
|
||||
def wl_int(self):
|
||||
return units.to_WL(math.abs2(self), self.l)[..., self.l_order]
|
||||
|
||||
@property
|
||||
def freq_int(self):
|
||||
return math.abs2(self.freq_amp)
|
||||
return units.to_WL(math.abs2(self * self.spectrum_factor), self.l)[..., self.l_order]
|
||||
|
||||
@property
|
||||
def afreq_int(self):
|
||||
return math.abs2(self.freq_amp)
|
||||
return math.abs2(self.afreq_amp)
|
||||
|
||||
@property
|
||||
def time_int(self):
|
||||
@@ -117,13 +115,9 @@ class Spectrum(np.ndarray):
|
||||
/ np.abs(self)
|
||||
)[..., self.l_order]
|
||||
|
||||
@property
|
||||
def freq_amp(self):
|
||||
return self[..., self.w_order[::-1]]
|
||||
|
||||
@property
|
||||
def afreq_amp(self):
|
||||
return self[..., self.w_order[::-1]]
|
||||
return self[..., self.w_order[::-1]] * self.spectrum_factor
|
||||
|
||||
@property
|
||||
def time_amp(self):
|
||||
@@ -132,7 +126,7 @@ class Spectrum(np.ndarray):
|
||||
@property
|
||||
def wl_max(self):
|
||||
if self.ndim == 1:
|
||||
return self.l[np.argmax(self.wl_int, axis=-1)]
|
||||
return self.wl_disp[np.argmax(self.wl_int, axis=-1)]
|
||||
return np.array([s.wl_max for s in self])
|
||||
|
||||
@property
|
||||
@@ -149,6 +143,9 @@ class Spectrum(np.ndarray):
|
||||
def measure(self) -> tuple[float, float, float]:
|
||||
return pulse.measure_field(self.t, self.time_amp)
|
||||
|
||||
freq_int = afreq_int
|
||||
freq_amp = afreq_amp
|
||||
|
||||
|
||||
class Propagation(Generic[ParamsOrNone]):
|
||||
io: PropagationIOHandler
|
||||
|
||||
Reference in New Issue
Block a user