Implement SimuMicroscope stage speed and generalize motion calibration#161
Merged
Merged
Conversation
SimuMicroscope stage speed and generalize motion calibration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
I am working on the instamatic TEM emulator, removing bugs and making it as functional as a physical TEM. The emulator is mostly its own thing, however, to avoid code duplication, it does use Instamatic as a dependency; for example, the TEM object used to store the state of the microscope is simply the default
SimuMicroscopeclass fromsrc/instamatic/microscope/interface/simu_microscope.py.The aim of the
SimuMicroscopeclass is first and foremost to provide an elegant fallback or test case when attempting to connect one's machine, accessing camera only, debugging etc. Therefore, it should be as simple as possible. However, it still should behave consistently, which now is not the case. For example, currentSimuMicroscopeimplementssetRotationSpeed, but ignoresspeedinsetStagePosition. As a result, tilting the stage usingstage.set(speed=x)vswith stage.rotation_speed(x): stage.setbehaves completely differently.This PR implements a long-missing functionality to move stage with speed. This is done via a new context manager
stage._speed_setting, which temporarily changes thespeedandspeed_settingfor given axis. Implementation ofsetStagePositionis updated to reflect this change:While at it, I have unified the speed of the stage to behave consistently. Previously, fresh stage would start up with tilt
speedof 20.0 deg / second and tiltspeed_settingof 12; however, as soon as thespeed_settingwas "updated" to the same value of 12, thespeedwould fall to 10 because the equations were inconsistent. I unified the default translation speed to 100 000 nm/s and rotation speed to 20 deg/s, given setting 12.Resulting simulated stage can now properly interpret
stage.set_with_speed, and thus can be calibrated:The
calib_stage_translation_x.yamlproduced by theinstamatic.calibrate_stage_translationexecuted on theinstamatic-TEM-emulatorimporting the updatedSimuMicroscopecan look something like this:Finally, I am working on compatibility with JEOL microscopes. Without goniotool, their stage translation and rotation speed can not be set, but it should still be calculable. Calibrating without setting speed is now done automatically by the updated scripts if setting speed is not possible. Same behavior can be also enforced: a lone
-sadded to any of the motion calibration scripts will force it to calibrate at the default speed, usingsetinstead ofset_with_speed. This way rotation speed can be calibrated, and FastADT run, on goniotool-less JEOL TEMs.Changes
stage.set(speed=...).instamatic.calibrate_rotation_speedandinstamatic.calibrate_rotation_speedcan now both calculate motion speed, even if speed is constant and not settable; this is detected automatically or can be forced via-s.This PR could use some tests; however, I'm leaving for a secondment soon and prefer to merge it before Friday.