Skip to content

Commit 501d79f

Browse files
author
landmanbester
committed
comment debugging code
1 parent db437d4 commit 501d79f

File tree

1 file changed

+46
-46
lines changed

1 file changed

+46
-46
lines changed

pfb/utils/misc.py

+46-46
Original file line numberDiff line numberDiff line change
@@ -1444,52 +1444,52 @@ def combine_columns(x, y, dc, dc1, dc2):
14441444
return x
14451445

14461446

1447-
def fft_interp(image, cellxi, cellyi, nxo, nyo,
1448-
cellxo, cellyo, shiftx, shifty):
1449-
'''
1450-
Use non-uniform fft to interpolate image in a flux conservative way
1451-
1452-
image - input image
1453-
cellxi - input x cell-size
1454-
cellyi - input y cell-size
1455-
nxo - number of x pixels in output
1456-
nyo - number of y pixels in output
1457-
cellxo - output x cell size
1458-
cellyo - output y cell size
1459-
shiftx - shift x coordinate by this amount
1460-
shifty - shift y coordinate by this amount
1461-
1462-
All sizes are assumed to be in radians.
1463-
'''
1464-
import matplotlib.pyplot as plt
1465-
from scipy.fft import fftn, ifftn
1466-
Fs = np.fft.fftshift
1467-
iFs = np.fft.ifftshift
1468-
# basic
1469-
nx, ny = image.shape
1470-
imhat = Fs(fftn(image))
1471-
1472-
# imabs = np.abs(imhat)
1473-
# imphase = np.angle(imhat) - 1.0
1474-
# imphase = np.roll(imphase, nx//2, axis=0)
1475-
# imshift = ifftn(iFs(imabs*np.exp(1j*imphase))).real
1476-
1477-
impad = np.pad(imhat, ((nx//2, nx//2), (ny//2, ny//2)), mode='constant')
1478-
imo = ifftn(iFs(impad)).real
1479-
1480-
print(np.sum(image) - np.sum(imo))
1481-
1482-
plt.figure(1)
1483-
plt.imshow(image/image.max(), vmin=0, vmax=1, interpolation=None)
1484-
plt.colorbar()
1485-
plt.figure(2)
1486-
plt.imshow(imo/imo.max(), vmin=0, vmax=1, interpolation=None)
1487-
plt.colorbar()
1488-
# plt.figure(3)
1489-
# plt.imshow(imshift/imshift.max() - image/image.max(), vmin=0, vmax=1, interpolation=None)
1490-
# plt.colorbar()
1491-
1492-
plt.show()
1447+
# def fft_interp(image, cellxi, cellyi, nxo, nyo,
1448+
# cellxo, cellyo, shiftx, shifty):
1449+
# '''
1450+
# Use non-uniform fft to interpolate image in a flux conservative way
1451+
1452+
# image - input image
1453+
# cellxi - input x cell-size
1454+
# cellyi - input y cell-size
1455+
# nxo - number of x pixels in output
1456+
# nyo - number of y pixels in output
1457+
# cellxo - output x cell size
1458+
# cellyo - output y cell size
1459+
# shiftx - shift x coordinate by this amount
1460+
# shifty - shift y coordinate by this amount
1461+
1462+
# All sizes are assumed to be in radians.
1463+
# '''
1464+
# import matplotlib.pyplot as plt
1465+
# from scipy.fft import fftn, ifftn
1466+
# Fs = np.fft.fftshift
1467+
# iFs = np.fft.ifftshift
1468+
# # basic
1469+
# nx, ny = image.shape
1470+
# imhat = Fs(fftn(image))
1471+
1472+
# imabs = np.abs(imhat)
1473+
# imphase = np.angle(imhat) - 1.0
1474+
# # imphase = np.roll(imphase, nx//2, axis=0)
1475+
# imshift = ifftn(iFs(imabs*np.exp(1j*imphase))).real
1476+
1477+
# impad = np.pad(imhat, ((nx//2, nx//2), (ny//2, ny//2)), mode='constant')
1478+
# imo = ifftn(iFs(impad)).real
1479+
1480+
# print(np.sum(image) - np.sum(imo))
1481+
1482+
# plt.figure(1)
1483+
# plt.imshow(image/image.max(), vmin=0, vmax=1, interpolation=None)
1484+
# plt.colorbar()
1485+
# plt.figure(2)
1486+
# plt.imshow(imo/imo.max(), vmin=0, vmax=1, interpolation=None)
1487+
# plt.colorbar()
1488+
# plt.figure(3)
1489+
# plt.imshow(imshift/imshift.max() - image/image.max(), vmin=0, vmax=1, interpolation=None)
1490+
# plt.colorbar()
1491+
1492+
# plt.show()
14931493

14941494
# # coordinates on input grid
14951495
# nx, ny = image.shapeimhat

0 commit comments

Comments
 (0)