Skip to content

Commit

Permalink
Merge pull request #179 from SWIFTSIM/Fix-non-square-images
Browse files Browse the repository at this point in the history
Fix for round-off errors in square images.
  • Loading branch information
JBorrow authored Nov 9, 2023
2 parents 16cbe91 + bc91a99 commit bcde3ac
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions swiftsimio/visualisation/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from typing import Union
from math import sqrt
from math import sqrt, ceil
from numpy import (
float64,
float32,
Expand Down Expand Up @@ -258,8 +258,8 @@ def project_pixel_grid(
image = backends[backend](**common_arguments)

# determine the effective number of pixels for each dimension
xres = int(resolution * x_range / max_range)
yres = int(resolution * y_range / max_range)
xres = int(ceil(resolution * (x_range / max_range)))
yres = int(ceil(resolution * (y_range / max_range)))

# trim the image to remove empty pixels
return image[:xres, :yres]
Expand Down

0 comments on commit bcde3ac

Please sign in to comment.