Skip to content

Commit

Permalink
Merge pull request yt-project#3782 from neutrinoceros/fix_cyl_pix
Browse files Browse the repository at this point in the history
BUG: fix pixelize_cylinder
  • Loading branch information
matthewturk authored and neutrinoceros committed Feb 7, 2022
1 parent 3164dfa commit 7fe92d0
Showing 1 changed file with 9 additions and 8 deletions.
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

0 comments on commit 7fe92d0

Please sign in to comment.