Skip to content

Commit

Permalink
tentative fix (may be worse than previous commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Oct 31, 2024
1 parent 9bc3228 commit 4553634
Showing 1 changed file with 11 additions and 67 deletions.
78 changes: 11 additions & 67 deletions yt/utilities/lib/pixelization_routines.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -692,78 +692,22 @@ def pixelize_cylinder(np.float64_t[:,:] buff,
if pi >= 0 and pi < buff.shape[0] and \
pj >= 0 and pj < buff.shape[1]:
# we got a pixel that intersects the grid cell
if (i == 0 or i == radius.shape[0] - 1) and (
not pixel_is_completely_contained_within_cylindrical_box(
box_rmin=rmin, box_rmax=rmax,
box_thetamin=tmin, box_thetamax=tmax,
img_x0=x0, img_y0=y0,
img_dx=dx, img_dy=dy,
pixel_i=pi, pixel_j=pj,
)
):
r_i += r_inc
continue
buff[pi, pj] = field[i]
mask[pi, pj] = 1

r_i += r_inc
theta_i += theta_inc

# now let's refine bounding box detection accuracy
# and clear pixels that intesect only partially with the bounding box
# We'll perform 4 loops, one for each axis/direction pair
cdef np.float64_t fillvalue = np.nan # TODO: make sure this value makes sense
for pi in range(mask.shape[0]):
pj = 0
while pj < (mask.shape[1] - 1) and mask[pi, pj] == 0:
pj += 1
if mask[pi, pj] == 1 and not (
pixel_is_completely_contained_within_cylindrical_box(
box_rmin=rmin, box_rmax=rmax,
box_thetamin=tmin, box_thetamax=tmax,
img_x0=x0, img_y0=y0,
img_dx=dx, img_dy=dy,
pixel_i=pi, pixel_j=pj,
)
):
buff[pi, pj] = fillvalue
mask[pi, pj] = 0

pj = mask.shape[1] - 1
while pj > 0 and mask[pi, pj] == 0:
pj -= 1
if mask[pi, pj] == 1 and not (
pixel_is_completely_contained_within_cylindrical_box(
box_rmin=rmin, box_rmax=rmax,
box_thetamin=tmin, box_thetamax=tmax,
img_x0=x0, img_y0=y0,
img_dx=dx, img_dy=dy,
pixel_i=pi, pixel_j=pj,
)
):
buff[pi, pj] = fillvalue
mask[pi, pj] = 0

for pj in range(mask.shape[1]):
pi = 0
while pi < (mask.shape[0] - 1) and mask[pi, pj] == 0:
pi += 1
if mask[pi, pj] == 1 and not (
pixel_is_completely_contained_within_cylindrical_box(
box_rmin=rmin, box_rmax=rmax,
box_thetamin=tmin, box_thetamax=tmax,
img_x0=x0, img_y0=y0,
img_dx=dx, img_dy=dy,
pixel_i=pi, pixel_j=pj,
)
):
buff[pi, pj] = fillvalue
mask[pi, pj] = 0

pi = mask.shape[0] - 1
while pi > 0 and mask[pi, pj] == 0:
pi -= 1
if mask[pi, pj] == 1 and not (
pixel_is_completely_contained_within_cylindrical_box(
box_rmin=rmin, box_rmax=rmax,
box_thetamin=tmin, box_thetamax=tmax,
img_x0=x0, img_y0=y0,
img_dx=dx, img_dy=dy,
pixel_i=pi, pixel_j=pj,
)
):
buff[pi, pj] = fillvalue
mask[pi, pj] = 0

if return_mask:
return mask_arr.astype("bool")

Expand Down

0 comments on commit 4553634

Please sign in to comment.