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

replace interp2d in utils_findsat_mrt #210

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Changes from all commits
Commits
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
18 changes: 13 additions & 5 deletions acstools/utils_findsat_mrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1432,16 +1432,24 @@ def create_mrt_line_kernel(width, sigma, outfile=None, shape=(1024, 2048),
LOG.info('Inteprolating onto new grid to center kernel')
theta_arr = np.arange(cutout.shape[1])
rho_arr = np.arange(cutout.shape[0])
theta_grid, rho_grid = np.meshgrid(theta_arr, rho_arr)

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

# inteprolate onto new grid
f = interpolate.interp2d(theta_grid, rho_grid, cutout.data,
kind='cubic')
cutout = f(new_theta_arr, new_rho_arr) # overwrite old cutout
f = interpolate.RegularGridInterpolator((rho_arr, theta_arr),
cutout.data,
bounds_error=False,
fill_value=0,
method='cubic')

# unable to provide 2D grid of points for interpolation. Switching to
# 1D, and then will switch back
points = [[r, t] for r, t in zip(np.ravel(new_rho_grid),
np.ravel(new_theta_grid))]

# return to original shape and replace the old cutout
cutout = np.reshape(f(points), cutout.data.shape)

if ax:
fig4, ax4 = plt.subplots()
Expand Down