Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

channel: support recalibrating force data #704

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

JoepVanlier
Copy link
Member

@JoepVanlier JoepVanlier commented Oct 30, 2024

Why this PR?
It is good to be able to recalibrate your force data.

By providing an API to do this, you basically end up with a force slice that can be treated as any other force slice (with a calibration item attached that conforms to a common API).

For instance, a recalibrated force slice can now directly be fed to the piezo tracking API (which reads from the calibration item).

Prior to implementing the new functionality, I removed some old cruftiness from the API that didn't really gel well with the new API. I left this as a separate commit.

Usage example:

  import lumicks.pylake as lk
  f = lk.File("passive_calibration.h5")
  calibration = f.force1x.calibration[1]  # Grab a calibration item for force 1x

  # Slice the data corresponding to the calibration we want to reproduce.
  calib_slice = f.force1x[calibration]

  # De-calibrate to volts using the calibration that was active before this slice.
  previous_calibration = calib_slice.calibration[0]
  calib_slice = calib_slice / previous_calibration.force_sensitivity
  calibration_params = previous_calibration.calibration_params()
  new_calibration = lk.calibrate_force(calib_slice.data, **calibration_params)
  new_calibration.plot()

  # Make a new calibration, but change the amount of blocking
  less_blocking_params = calibration_params | {"num_points_per_block": 200}
  less_blocking = lk.calibrate_force(calib_slice.data, **less_blocking_params)
  less_blocking.plot()

  # Recalibrate the force channels
  recalibrated_force1x = f.force1x.recalibrate_force(less_blocking)

@JoepVanlier JoepVanlier force-pushed the recalibrate_force branch 2 times, most recently from 68df0fe to 7ad1aa0 Compare October 30, 2024 15:15
@JoepVanlier JoepVanlier marked this pull request as ready for review October 31, 2024 13:40
@JoepVanlier JoepVanlier requested review from a team as code owners October 31, 2024 13:40
Copy link
Collaborator

@aafkevandenberg aafkevandenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice addition, this is much easier and cleaner way to recalibrate.

The example you mention would fit well in the force calibration docs. I guess you do that in a separate PR?

@JoepVanlier
Copy link
Member Author

Very nice addition, this is much easier and cleaner way to recalibrate.

The example you mention would fit well in the force calibration docs. I guess you do that in a separate PR?

Yeah. I was considering that too, but I figure, with the big shuffle, it doesn't make a lot of sense to add it now.

However, I could rebase this one on the docs rewrite and just add it there.

@JoepVanlier JoepVanlier force-pushed the recalibrate_force branch 6 times, most recently from 9a652d9 to 9447329 Compare December 2, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants