Skip to content

Commit 26ab8be

Browse files
authored
replace interp2d in utils_findsat_mrt (#210)
* replace interp2d with RegularGridInterpolator * pep8 and flake8 formatting fixes
1 parent 29974b0 commit 26ab8be

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

acstools/utils_findsat_mrt.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,16 +1432,24 @@ def create_mrt_line_kernel(width, sigma, outfile=None, shape=(1024, 2048),
14321432
LOG.info('Inteprolating onto new grid to center kernel')
14331433
theta_arr = np.arange(cutout.shape[1])
14341434
rho_arr = np.arange(cutout.shape[0])
1435-
theta_grid, rho_grid = np.meshgrid(theta_arr, rho_arr)
14361435

14371436
new_theta_arr = theta_arr + theta_shift
14381437
new_rho_arr = rho_arr + rho_shift
14391438
new_theta_grid, new_rho_grid = np.meshgrid(new_theta_arr, new_rho_arr)
14401439

1441-
# inteprolate onto new grid
1442-
f = interpolate.interp2d(theta_grid, rho_grid, cutout.data,
1443-
kind='cubic')
1444-
cutout = f(new_theta_arr, new_rho_arr) # overwrite old cutout
1440+
f = interpolate.RegularGridInterpolator((rho_arr, theta_arr),
1441+
cutout.data,
1442+
bounds_error=False,
1443+
fill_value=0,
1444+
method='cubic')
1445+
1446+
# unable to provide 2D grid of points for interpolation. Switching to
1447+
# 1D, and then will switch back
1448+
points = [[r, t] for r, t in zip(np.ravel(new_rho_grid),
1449+
np.ravel(new_theta_grid))]
1450+
1451+
# return to original shape and replace the old cutout
1452+
cutout = np.reshape(f(points), cutout.data.shape)
14451453

14461454
if ax:
14471455
fig4, ax4 = plt.subplots()

0 commit comments

Comments
 (0)