From bc91a996e2b5c00b9abc943da06191b7c94535f7 Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Thu, 9 Nov 2023 10:30:27 -0500 Subject: [PATCH] Fix for round-off errors in square images. Addresses #178. @Joeybraspenning can you give this branch a go? --- swiftsimio/visualisation/projection.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/swiftsimio/visualisation/projection.py b/swiftsimio/visualisation/projection.py index e2d97c8f..1a92730f 100644 --- a/swiftsimio/visualisation/projection.py +++ b/swiftsimio/visualisation/projection.py @@ -3,7 +3,7 @@ """ from typing import Union -from math import sqrt +from math import sqrt, ceil from numpy import ( float64, float32, @@ -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]