Skip to content

Commit

Permalink
calibration: add some convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepVanlier committed Dec 4, 2024
1 parent 722aa52 commit 5f1cdf4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lumicks/pylake/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def stop(self):
return self._src.stop

@property
def data(self) -> npt.ArrayLike:
def data(self) -> npt.NDArray:
"""The primary values of this channel slice"""
return self._src.data

Expand Down Expand Up @@ -778,7 +778,7 @@ def to_dataset(self, parent, name, **kwargs):
return dset

@property
def data(self) -> npt.ArrayLike:
def data(self) -> npt.NDArray:
if self._cached_data is None:
self._cached_data = np.asarray(self._src_data)
return self._cached_data
Expand Down Expand Up @@ -909,7 +909,7 @@ def to_dataset(self, parent, name, **kwargs):
return dset

@property
def data(self) -> npt.ArrayLike:
def data(self) -> npt.NDArray:
if self._cached_data is None:
self._cached_data = np.asarray(self._src_data)
return self._cached_data
Expand Down Expand Up @@ -1024,7 +1024,7 @@ def __len__(self):
return 0

@property
def data(self) -> npt.ArrayLike:
def data(self) -> npt.NDArray:
return np.empty(0)

@property
Expand Down
18 changes: 18 additions & 0 deletions lumicks/pylake/force_calibration/calibration_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections import UserDict

from lumicks.pylake.channel import Slice, Continuous, empty_slice
from lumicks.pylake.force_calibration.convenience import calibrate_force
from lumicks.pylake.force_calibration.calibration_models import DiodeCalibrationModel
from lumicks.pylake.force_calibration.detail.calibration_properties import (
CalibrationPropertiesMixin,
Expand Down Expand Up @@ -183,6 +184,23 @@ def __repr__(self):
)
return f"{self.__class__.__name__}({properties})"

def plot(self):
if not self.voltage:
raise ValueError(
"This calibration item does not contain the raw data. If you still have the "
"timeline force data, you can de-calibrate that and perform the re-calibration"
"manually. See the pylake tutorial on force calibration for more information."
)

calibrate_force(self.voltage.data, **self.calibration_params()).plot()

def recalibrate_with(self, **params):
"""Returns a calibration structure with some parameters overridden.
For a full list of parameters to override, please see
:func:`~lumicks.pylake.calibrate_force()`"""
return calibrate_force(self.voltage.data, **(self.calibration_params() | params))

@_verify_full
def _model_params(self):
"""Returns parameters with which to create an active or passive calibration model"""
Expand Down

0 comments on commit 5f1cdf4

Please sign in to comment.