Skip to content

Commit

Permalink
calibration: allow plotting driving peak
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepVanlier committed Oct 2, 2024
1 parent 011b2a2 commit ba1a1a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Added parameter `titles` to customize title of each subplot in [`Kymo.plot_with_channels()`](https://lumicks-pylake.readthedocs.io/en/latest/_api/lumicks.pylake.kymo.Kymo.html#lumicks.pylake.kymo.Kymo.plot_with_channels).
* Added [`KymoTrack.sample_from_channel()`](https://lumicks-pylake.readthedocs.io/en/latest/_api/lumicks.pylake.kymotracker.kymotrack.KymoTrack.html#lumicks.pylake.kymotracker.kymotrack.KymoTrack.sample_from_channel) to downsample channel data to the time points of a kymotrack.
* Allow showing the ranges that were excluded from a power spectrum by passing `show_excluded=True` to [`PowerSpectrum.plot()`](https://lumicks-pylake.readthedocs.io/en/latest/_api/lumicks.pylake.force_calibration.power_spectrum.PowerSpectrum.html#lumicks.pylake.force_calibration.power_spectrum.PowerSpectrum.plot).
* Allow plotting the ranges that were excluded from fitting and the active calibration peak when plotting a calibration result using `show_excluded=True` and `show_active_peak=True` in [`CalibrationResults.plot()`](https://lumicks-pylake.readthedocs.io/en/latest/_api/lumicks.pylake.force_calibration.power_spectrum_calibration.CalibrationResults.html#lumicks.pylake.force_calibration.power_spectrum_calibration.CalibrationResults.plot).

## v1.5.2 | 2024-07-24

Expand Down
21 changes: 18 additions & 3 deletions lumicks/pylake/force_calibration/calibration_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,27 @@ def number_of_samples(self):
"""Number of fitted samples (-)."""
return self.ps_data.total_sampled_used

def plot(self):
"""Plot the fitted spectrum"""
def plot(self, show_excluded=False, show_active_peak=False):
"""Plot the fitted spectrum
Parameters
----------
show_excluded : bool
Show fitting regions excluded from the fit
show_active_peak : bool
Show active calibration peak when available
"""
import matplotlib.pyplot as plt

self.ps_data.plot(label="Data")
if show_active_peak and not hasattr(self.model, "output_power"):
raise ValueError("This is not an active calibration")

self.ps_data.plot(label="Data", show_excluded=show_excluded)
self.ps_model.plot(label="Model")

if show_active_peak:
self.model.output_power.ps.plot(label="Active peak")

plt.legend()

def plot_spectrum_residual(self):
Expand Down

0 comments on commit ba1a1a5

Please sign in to comment.