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

BUG: fix pixelize_cylinder #3782

Merged
merged 2 commits into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
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
17 changes: 9 additions & 8 deletions yt/utilities/lib/pixelization_routines.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ def pixelize_cylinder(np.float64_t[:,:] buff,

cdef np.float64_t x, y, dx, dy, r0, theta0
cdef np.float64_t rmax, x0, y0, x1, y1
cdef np.float64_t r_i, theta_i, dr_i, dtheta_i, dthetamin
cdef np.float64_t r_i, theta_i, dr_i, dtheta_i
cdef np.float64_t r_inc, theta_inc
cdef np.float64_t costheta, sintheta
cdef int i, pi, pj

Expand Down Expand Up @@ -558,9 +559,9 @@ def pixelize_cylinder(np.float64_t[:,:] buff,
rbounds[0] = 0.0
if y0 < 0 and y1 > 0:
rbounds[0] = 0.0
dthetamin = dx / rmax
for i in range(radius.shape[0]):
r_inc = 0.5 * fmin(dx, dy)

for i in range(radius.shape[0]):
r0 = radius[i]
theta0 = theta[i]
dr_i = dradius[i]
Expand All @@ -569,15 +570,15 @@ def pixelize_cylinder(np.float64_t[:,:] buff,
if r0 + dr_i < rbounds[0] or r0 - dr_i > rbounds[1]:
continue
theta_i = theta0 - dtheta_i
# Buffer of 0.5 here
dthetamin = 0.5*dx/(r0 + dr_i)
theta_inc = r_inc / (r0 + dr_i)

while theta_i < theta0 + dtheta_i:
r_i = r0 - dr_i
costheta = math.cos(theta_i)
sintheta = math.sin(theta_i)
while r_i < r0 + dr_i:
if rmax <= r_i:
r_i += 0.5*dx
r_i += r_inc
continue
y = r_i * costheta
x = r_i * sintheta
Expand All @@ -586,8 +587,8 @@ def pixelize_cylinder(np.float64_t[:,:] buff,
if pi >= 0 and pi < buff.shape[0] and \
pj >= 0 and pj < buff.shape[1]:
buff[pi, pj] = field[i]
r_i += 0.5*dx
theta_i += dthetamin
r_i += r_inc
theta_i += theta_inc

cdef int aitoff_Lambda_btheta_to_xy(np.float64_t Lambda, np.float64_t btheta,
np.float64_t *x, np.float64_t *y) except -1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def test_center_3():
@requires_module("scipy")
def find_compare_maxima(expected_maxima, buf, resolution, width):
buf_ndarray = buf.ndarray_view()
max_filter_buf = ndimage.filters.maximum_filter(buf_ndarray, size=5)
max_filter_buf = ndimage.maximum_filter(buf_ndarray, size=5)
maxima = np.isclose(max_filter_buf, buf_ndarray, rtol=1e-09)

# ignore contributions from zones of no smoothing
Expand Down