From 6de315eee6ff4ac0f1f79881ec8068f486f4f0a4 Mon Sep 17 00:00:00 2001 From: Joep Vanlier Date: Thu, 26 Sep 2024 23:32:13 +0200 Subject: [PATCH] power_spectrum: allow plotting exclusions --- lumicks/pylake/force_calibration/power_spectrum.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lumicks/pylake/force_calibration/power_spectrum.py b/lumicks/pylake/force_calibration/power_spectrum.py index bfc720d0f..529aa240d 100644 --- a/lumicks/pylake/force_calibration/power_spectrum.py +++ b/lumicks/pylake/force_calibration/power_spectrum.py @@ -361,7 +361,7 @@ def with_spectrum(self, power) -> "PowerSpectrum": total_samples_used=self.total_samples_used, ) - def plot(self, **kwargs): + def plot(self, *, show_excluded=False, **kwargs): """Plot power spectrum Parameters @@ -371,6 +371,11 @@ def plot(self, **kwargs): """ import matplotlib.pyplot as plt + if show_excluded: + plt.plot(self.unfiltered_frequency, self.unfiltered_power) + for f_min, f_max in self._excluded_ranges: + plt.axvspan(f_min, f_max, alpha=0.1, label="_") + plt.plot(self.frequency, self.power, **kwargs) plt.xlabel("Frequency [Hz]") plt.ylabel(f"Power [${self.unit}^2/Hz$]")