From 1918b8c89fd50332f0e394c3f96e8dfc5009807d Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Mon, 28 Aug 2023 07:28:12 -0700 Subject: [PATCH] Wrap cast to uint8 to ignore invalid warnings. --- python/lsst/pipe/tasks/hips.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/lsst/pipe/tasks/hips.py b/python/lsst/pipe/tasks/hips.py index c7e7e5d28..6718b1e2f 100644 --- a/python/lsst/pipe/tasks/hips.py +++ b/python/lsst/pipe/tasks/hips.py @@ -1152,7 +1152,9 @@ def _write_hips_image(self, hips_base_path, order, pixel, image, png_mapping, sh # And make a grayscale png as well - vals = 255 - png_mapping.map_intensity_to_uint8(image.array).astype(np.uint8) + with np.errstate(invalid="ignore"): + vals = 255 - png_mapping.map_intensity_to_uint8(image.array).astype(np.uint8) + vals[~np.isfinite(image.array) | (image.array < 0)] = 0 im = Image.fromarray(vals[::-1, :], "L")