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

Add keyboard shortcuts and scale bars #12

Merged
merged 33 commits into from
Feb 7, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fbe1b6b
add keyboard commands for moving detectors
sezelt Jan 13, 2024
a4417e0
remove debug prints
sezelt Jan 14, 2024
8a6d744
version bump
sezelt Jan 14, 2024
75fd15e
update python requirement
sezelt Jan 14, 2024
816fb51
working but imperfectly formatted scale bar
sezelt Jan 17, 2024
ed7718d
format scalebar nicely
sezelt Jan 17, 2024
09fcf0a
add scalebar to FFT and fix bug in all scalebars
sezelt Jan 17, 2024
bb77993
attempt to discover calibrations in H5 files for EMD-1.0 and abTEM
sezelt Jan 17, 2024
ed900c2
search for metadata in EMD v1 files instead of Array attrs
sezelt Jan 17, 2024
94b9f84
make scale bar a little smaller
sezelt Jan 22, 2024
b95ccba
add ability to move faster with keyboard using shift
sezelt Feb 2, 2024
b87cea3
add keyboard map help menu
sezelt Feb 2, 2024
3a945f1
update readme with keyboard controls
sezelt Feb 2, 2024
bf4e1ab
format with black
sezelt Feb 2, 2024
8999793
optional EWPC in FFT viewer
sezelt Feb 2, 2024
60a61da
disable pyqtgraph builtin rightclick menu
sezelt Feb 2, 2024
6b7f413
make auto-contrast happen at more sensible times
sezelt Feb 2, 2024
0abe61e
typo
sezelt Feb 2, 2024
ae9c08c
switch text annotations to status bar
sezelt Feb 2, 2024
e80674f
add simple autoscale buttons to bottom bar
sezelt Feb 4, 2024
2a4f289
allow autoscale to be locked on
sezelt Feb 5, 2024
f0ac654
autoscale on by default
sezelt Feb 5, 2024
986cb2e
format with black
sezelt Feb 5, 2024
3fdd242
ensure RAW exports get the unscaled data
sezelt Feb 5, 2024
a993e3e
clarify export type names
sezelt Feb 5, 2024
5611382
tentatively use new DPC name, will eventually in-house
sezelt Feb 5, 2024
db8b82a
fix for new save menu names
sezelt Feb 5, 2024
05172eb
typo
sezelt Feb 5, 2024
3b6c726
reset FFT range when mode switches
sezelt Feb 5, 2024
9e94fe9
scale FFT to have isotropic pixel size even for non square scans
sezelt Feb 6, 2024
54215bd
autorange after fft update
sezelt Feb 6, 2024
1320c4b
update README with description of the controls
sezelt Feb 6, 2024
a156fc1
update comment
sezelt Feb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
attempt to discover calibrations in H5 files for EMD-1.0 and abTEM
  • Loading branch information
sezelt committed Jan 17, 2024
commit bb7799326ad5f80c47e9ef80614966c3c4a7d105
43 changes: 43 additions & 0 deletions src/py4D_browser/menu_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ def load_file(self, filepath, mmap=False, binning=1):
self.datacube = py4DSTEM.DataCube(
datacubes[0] if mmap else datacubes[0][()]
)

R_size, R_units, Q_size, Q_units = find_calibrations(datacubes[0])

self.datacube.calibration.set_R_pixel_size(R_size)
self.datacube.calibration.set_R_pixel_units(R_units)
self.datacube.calibration.set_Q_pixel_size(Q_size)
self.datacube.calibration.set_Q_pixel_units(Q_units)

else:
raise ValueError("No 4D data detected in the H5 file!")
elif extension in [".npy"]:
self.datacube = py4DSTEM.DataCube(np.load(filepath))
else:
Expand Down Expand Up @@ -195,3 +205,36 @@ def get_4D(f, datacubes=None):
elif isinstance(f[k], h5py.Group):
get_4D(f[k], datacubes)
return datacubes


def find_calibrations(dset: h5py.Dataset):
# Attempt to find calibrations from an H5 file
R_size, R_units, Q_size, Q_units = 1.0, "pixels", 1.0, "pixels"

# Does it look like a py4DSTEM file?
try:
if "emd_group_type" in dset.parent.attrs:
R_size = dset.parent["dim0"][1] - dset.parent["dim0"][0]
R_units = dset.parent["dim0"].attrs["units"]

Q_size = dset.parent["dim3"][1] - dset.parent["dim3"][0]
Q_units = dset.parent["dim3"].attrs["units"]
except:
print(
"This file looked like a py4DSTEM dataset but the dim vectors appear malformed..."
)

# Does it look like an abTEM file?
try:
if "sampling" in dset.parent and "units" in dset.parent:
R_size = dset.parent["sampling"][0]
R_units = dset.parent["units"][0].decode()

Q_size = dset.parent["sampling"][3]
Q_units = dset.parent["units"][3].decode()
except:
print(
"This file looked like an abTEM simulation but the calibrations aren't as expected..."
)

return R_size, R_units, Q_size, Q_units