From 313bb3295ea7141ce9f3c8cca2013b5ed8db3e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Sierro?= Date: Thu, 17 Aug 2023 16:31:03 +0200 Subject: [PATCH] new: pulse center of gravity --- src/scgenerator/spectra.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/scgenerator/spectra.py b/src/scgenerator/spectra.py index a76841d..0976b8a 100644 --- a/src/scgenerator/spectra.py +++ b/src/scgenerator/spectra.py @@ -122,6 +122,11 @@ class Spectrum(np.ndarray): return self.l[np.argmax(self.wl_int, axis=-1)] return np.array([s.wl_max for s in self]) + @property + def center_of_gravity(self): + intensity = self.time_int + return np.sum(intensity * self.t) / np.sum(intensity) + def mask_wl(self, pos: float, width: float) -> Spectrum: """ Filters the spectrum with a bandpass centered at `pos` of FWHM `width`.