Skip to content

Commit

Permalink
Testing: Add Testing for different microscope modes
Browse files Browse the repository at this point in the history
  • Loading branch information
CSSFrancis committed Oct 8, 2024
1 parent f14c581 commit ae42124
Show file tree
Hide file tree
Showing 6 changed files with 796 additions and 6 deletions.
19 changes: 13 additions & 6 deletions rsciio/mrc/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,28 @@ def read_de_metadata_file(filename, nav_shape=None):
value = value.strip()
original_metadata[key] = value

in_stem_mode = original_metadata.get("Image Project TEMorSTEM Mode", -1)
in_stem_mode = int(original_metadata.get("Image Project TEMorSTEM Mode", -1))
scanning = original_metadata.get("Scan - Enable", "Disable") == "Enable"
raster = original_metadata.get("Scan - Type", "Raster") == "Raster"
if not raster:
if not raster: # pragma: no cover
_logger.warning(
"Non-raster scans are not fully supported yet. Please raise an issue on GitHub"
" if you need this feature."
)
if in_stem_mode == -1:
in_stem_mode = scanning
elif in_stem_mode == 0:
elif in_stem_mode == 0: # 0 -> TEM Mode
in_stem_mode = False

Check warning on line 182 in rsciio/mrc/_api.py

View check run for this annotation

Codecov / codecov/patch

rsciio/mrc/_api.py#L182

Added line #L182 was not covered by tests
else:
in_stem_mode = True

Check warning on line 184 in rsciio/mrc/_api.py

View check run for this annotation

Codecov / codecov/patch

rsciio/mrc/_api.py#L184

Added line #L184 was not covered by tests

has_camera_length = original_metadata.get(
"Instrument Project Camera Length (centimeters)", -1
)
diffracting = (
has_camera_length != -1 or in_stem_mode
) # Force diffracting if in STEM mode

if in_stem_mode and scanning and raster or nav_shape is not None:
axes_scales = np.array(
[
Expand Down Expand Up @@ -225,11 +232,11 @@ def read_de_metadata_file(filename, nav_shape=None):
navigate = [True, False, False]

nav_shape = None # read from the .mrc file
frame_sum = original_metadata.get("Autosave Movie Sum Count", 1)
frame_time = original_metadata.get("Frames Per Second", 1)
frame_sum = float(original_metadata.get("Autosave Movie Sum Count", 1))
frame_time = float(original_metadata.get("Frames Per Second", 1))
sec_per_frame = 1 / (frame_time * frame_sum)
axes_shapes = [-1, -1, -1] # get from the .mrc file
if in_stem_mode:
if diffracting:
axes_scales = np.array(
[
sec_per_frame,
Expand Down
Loading

0 comments on commit ae42124

Please sign in to comment.