Skip to content

Commit a2099e8

Browse files
committed
Merge branch 'main' into video_services
2 parents 6268a10 + e714b68 commit a2099e8

File tree

8 files changed

+407
-6
lines changed

8 files changed

+407
-6
lines changed

docs/programs.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ These tools help calibrate instamatic for some experiments.
2828
- [instamatic.calibrate_movie_delays](#instamaticcalibrate_movie_delays) (`instamatic.calibrate.calibrate_movie_delays:main_entry`)
2929
- [instamatic.flatfield](#instamaticflatfield) (`instamatic.processing.flatfield:main_entry`)
3030
- [instamatic.stretch_correction](#instamaticstretch_correction) (`instamatic.processing.stretch_correction:main_entry`)
31+
- [instamatic.calibrate_stage_rotation](#instamaticcalibrate_stage_rotation) (`instamatic.calibrate.calibrate_stage_lowmag:main_entry`)
32+
3133

3234
**Tools**
3335

@@ -176,6 +178,32 @@ instamatic.calibrate_stage_lowmag [-h] [IMG [IMG ...]]
176178
`-h`, `--help`
177179
: Show this help message and exit
178180
181+
## instamatic.calibrate_stage_rotation
182+
183+
Program to calibrate and plan the rotation pace (in seconds / angle) against speed settings available on the microscope.
184+
185+
**Usage:**
186+
```bash
187+
instamatic.calibrate_stage_rotation [-h] [-a ALPHAS] [-s SPEEDS] [-m MODE] [-o OUTDIR]
188+
```
189+
190+
**Optional arguments:**
191+
192+
`-h`, `--help`
193+
: Show this help message and exit
194+
195+
`-a ALPHAS`, `--alphas ALPHAS`
196+
: Comma-delimited list of alpha spans to calibrate (default: "1,2,3,4,5,6,7,8,9,10").
197+
198+
`-s SPEEDS`, `--speeds SPEEDS`
199+
: Comma-delimited list of speed settings to calibrate (default: "0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0" or "1,2,3,4,5,6,7,8,9,10,11,12", whichever is accepted by the microscope).
200+
201+
`-m MODE`, `--mode MODE`
202+
: Calibration mode to be used: "auto" - auto-determine upper and lower speed limits based on TEM response (default); "limited" - restrict TEM goniometer speed limits between min and max of --speeds; or "listed" - restrict TEM goniometer speed settings exactly to --speeds provided.
203+
204+
`-o OUTDIR`, `--outdir OUTDIR`
205+
: Path to the directory where calibration file should be output (default: "%appdata%/calib" on Windows or "$AppData/calib" on Unix).
206+
179207
180208
## instamatic.calibrate_stage_mag1
181209

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ publishing = [
104104
"instamatic.calibrate_movie_delays" = "instamatic.calibrate.calibrate_movie_delays:main_entry"
105105
"instamatic.flatfield" = "instamatic.processing.flatfield:main_entry"
106106
"instamatic.stretch_correction" = "instamatic.processing.stretch_correction:main_entry"
107+
"instamatic.calibrate_stage_rotation" = "instamatic.calibrate.calibrate_stage_rotation:main_entry"
107108
# tools
108109
"instamatic.browser" = "scripts.browser:main"
109110
"instamatic.viewer" = "scripts.viewer:main"

src/instamatic/calibrate/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
from .calibrate_directbeam import CalibDirectBeam
66
from .calibrate_movie_delays import CalibMovieDelays
77
from .calibrate_stage_lowmag import CalibStage
8+
from .calibrate_stage_rotation import CalibStageRotation
89

910
# from .calibrate_stage_mag1 import CalibStageMag1

src/instamatic/calibrate/calibrate_movie_delays.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ def from_file(
7373
calib_conditions = (exposure, header_keys, header_keys_common)
7474
calib = calib_map.get(calib_conditions, None)
7575
if calib is None:
76+
header_keys_str = ','.join(header_keys)
77+
header_keys_common_str = ','.join(header_keys_common)
7678
raise KeyError(
7779
f'Calibration for conditions {calib_conditions} not found. '
7880
f"Please run 'instamatic.calibrate_movie_delays -e {exposure:.6f} "
79-
f"-a {header_keys} -c {header_keys_common}' first."
81+
f'-a "{header_keys_str}" -c "{header_keys_common_str}" first.'
8082
)
8183
return calib
8284

@@ -188,8 +190,8 @@ def from_file(cls, path: Optional[str] = None) -> Self:
188190
if path is None:
189191
path = Path(calibration_drc) / CALIB_MOVIE_DELAYS
190192
try:
191-
with open(Path(path), 'r') as json_file:
192-
return cls.from_list(yaml.safe_load(json_file))
193+
with open(Path(path), 'r') as yaml_file:
194+
return cls.from_list(yaml.safe_load(yaml_file))
193195
except OSError as e:
194196
prog = 'instamatic.calibrate_movie_delays'
195197
raise OSError(f'{e.strerror}: {path}. Please run {prog} first.')
@@ -200,6 +202,7 @@ def to_file(self, path: Optional[str] = None) -> None:
200202
path = Path(calibration_drc) / CALIB_MOVIE_DELAYS
201203
with open(Path(path), 'w') as json_file:
202204
yaml.safe_dump(self.to_list(), json_file)
205+
log(f'{self} saved to {path}.')
203206

204207

205208
class MovieTimes:

0 commit comments

Comments
 (0)