Skip to content

Commit 39680d0

Browse files
committed
Adjust to multiple lines
1 parent 5e939ac commit 39680d0

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

src/aspire/image/__init__.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,10 @@ def downsample(self, ds_res):
204204
mask = (np.abs(grid["x"]) < ds_res / self.res) & (
205205
np.abs(grid["y"]) < ds_res / self.res
206206
)
207-
im = np.real(
208-
xp.asnumpy(
209-
fft.centered_ifft2(
210-
fft.centered_fft2(xp.asarray(self.data)) * xp.asarray(mask)
211-
)
212-
)
207+
im_shifted = fft.centered_ifft2(
208+
fft.centered_fft2(xp.asarray(self.data)) * xp.asarray(mask)
213209
)
210+
im = np.real(xp.asnumpy(im_shifted))
214211

215212
for s in range(im_ds.shape[0]):
216213
interpolator = RegularGridInterpolator(
@@ -274,16 +271,10 @@ def _im_translate(self, shifts):
274271

275272
L = self.res
276273
im_f = xp.asnumpy(fft.fft2(xp.asarray(im)))
277-
grid_1d = (
278-
xp.asnumpy(
279-
fft.ifftshift(
280-
xp.asarray(np.ceil(np.arange(-L / 2, L / 2, dtype=self.dtype)))
281-
)
282-
)
283-
* 2
284-
* np.pi
285-
/ L
274+
grid_shifted = fft.ifftshift(
275+
xp.asarray(np.ceil(np.arange(-L / 2, L / 2, dtype=self.dtype)))
286276
)
277+
grid_1d = xp.asnumpy(grid_shifted) * 2 * np.pi / L
287278

288279
om_x, om_y = np.meshgrid(grid_1d, grid_1d, indexing="ij")
289280

src/aspire/utils/preprocess.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,11 @@ def downsample(insamples, szout, mask=None):
148148
# stack of one dimension objects
149149

150150
for idata in range(ndata):
151-
imsample_shifted = fft.fftshift(fft.fft(xp.asarray(insamples[idata])))
152-
insamples_fft = crop_pad(imsample_shifted, L_out) * mask
151+
insamples_shifted = fft.fftshift(fft.fft(xp.asarray(insamples[idata])))
152+
insamples_fft = crop_pad(insamples_shifted, L_out) * mask
153153

154-
outsammples_shifted = fft.ifft(fft.ifftshift(xp.asarray(insamples_fft)))
155-
outsamples[idata] = np.real(
156-
xp.asnumpy(outsammples_shifted) * (L_out / L_in)
157-
)
154+
outsamples_shifted = fft.ifft(fft.ifftshift(xp.asarray(insamples_fft)))
155+
outsamples[idata] = np.real(xp.asnumpy(outsamples_shifted) * (L_out / L_in))
158156

159157
elif insamples.ndim == 3:
160158
# stack of two dimension objects

0 commit comments

Comments
 (0)