Skip to content

Commit

Permalink
autoformats
Browse files Browse the repository at this point in the history
  • Loading branch information
bsavitzky committed May 9, 2024
1 parent da0e897 commit 10a5ed9
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions py4DSTEM/braggvectors/probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, data: np.ndarray, name: Optional[str] = "probe"):
)

# initialize metadata params
self.metadata = Metadata(name='params')
self.metadata = Metadata(name="params")
self.alpha = None
self.origin = None

Expand All @@ -55,6 +55,7 @@ def __init__(self, data: np.ndarray, name: Optional[str] = "probe"):
@property
def probe(self):
return self.get_slice("probe").data

@probe.setter
def probe(self, x):
assert x.shape == (self.data.shape[1:])
Expand All @@ -63,24 +64,27 @@ def probe(self, x):
@property
def kernel(self):
return self.get_slice("kernel").data

@kernel.setter
def kernel(self, x):
assert x.shape == (self.data.shape[1:])
self.data[1, :, :] = x

@property
def alpha(self):
return self.metadata['params']['alpha']
return self.metadata["params"]["alpha"]

@alpha.setter
def alpha(self, x):
self.metadata['params']['alpha'] = x
self.metadata["params"]["alpha"] = x

@property
def origin(self):
return self.metadata['params']['origin']
return self.metadata["params"]["origin"]

@origin.setter
def origin(self, x):
self.metadata['params']['origin'] = x
self.metadata["params"]["origin"] = x

# read
@classmethod
Expand Down Expand Up @@ -278,7 +282,7 @@ def measure_disk(
ans = r, x0, y0
if data is None:
self.alpha = r
self.origin = (x0,y0)
self.origin = (x0, y0)
try:
self.calibration.set_probe_param(ans)
except AttributeError:
Expand All @@ -288,28 +292,19 @@ def measure_disk(
pass

if data is None and zero_vacuum:
self.zero_vacuum( alpha_max=alpha_max)
self.zero_vacuum(alpha_max=alpha_max)

# show result
if plot:
show(
im,
circle={
'center' : (x0,y0),
'R' : r,
'fill' : True,
'alpha' : 0.36
}
)
show(im, circle={"center": (x0, y0), "R": r, "fill": True, "alpha": 0.36})

# return
if returncalc:
return ans


def zero_vacuum(
self,
alpha_max = 1.2,
alpha_max=1.2,
):
"""
Sets pixels outside of the probe's central disk to zero.
Expand All @@ -326,20 +321,20 @@ def zero_vacuum(
from the origin are set to zero
"""
# validate inputs
assert(self.alpha is not None), "no probe semiconvergence angle found; try running `Probe.measure_disk`"
assert(self.origin is not None), "no probe origin found; try running `Probe.measure_disk`"
assert (
self.alpha is not None
), "no probe semiconvergence angle found; try running `Probe.measure_disk`"
assert (
self.origin is not None
), "no probe origin found; try running `Probe.measure_disk`"
# make a mask
qyy,qxx = np.meshgrid(
np.arange(self.shape[1]),
np.arange(self.shape[0])
)
qrr = np.hypot(qxx-self.origin[0],qyy-self.origin[1])
mask = qrr < self.alpha*alpha_max
qyy, qxx = np.meshgrid(np.arange(self.shape[1]), np.arange(self.shape[0]))
qrr = np.hypot(qxx - self.origin[0], qyy - self.origin[1])
mask = qrr < self.alpha * alpha_max
# zero the vacuum
self.probe *= mask
pass


# Kernel generation methods

def get_kernel(
Expand Down

0 comments on commit 10a5ed9

Please sign in to comment.