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")