From e60aa626fdc47b72cc2aaccf22d537656cfb62a4 Mon Sep 17 00:00:00 2001 From: Trygve Aspenes Date: Mon, 24 Sep 2018 10:59:50 +0000 Subject: [PATCH 1/2] Fixed that save_dataset does not propagate fill_value into get_enhanced_image. Further does not get_enhanced_image propagate fill_value into add_overlay and add_decorate. Those in turn does not propagate fill_value into pil_image. --- satpy/writers/__init__.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/satpy/writers/__init__.py b/satpy/writers/__init__.py index c3f000356f..916dff351f 100644 --- a/satpy/writers/__init__.py +++ b/satpy/writers/__init__.py @@ -179,7 +179,7 @@ def _determine_mode(dataset): def add_overlay(orig, area, coast_dir, color=(0, 0, 0), width=0.5, resolution=None, - level_coast=1, level_borders=1): + level_coast=1, level_borders=1, fill_value=None): """Add coastline and political borders to image, using *color* (tuple of integers between 0 and 255). Warning: Loses the masks ! @@ -224,7 +224,7 @@ def add_overlay(orig, area, coast_dir, color=(0, 0, 0), width=0.5, resolution=No LOG.debug("Automagically choose resolution %s", resolution) - img = orig.pil_image() + img = orig.pil_image(fill_value=fill_value) cw_ = ContourWriterAGG(coast_dir) cw_.add_coastlines(img, area, outline=color, resolution=resolution, width=width, level=level_coast) @@ -277,7 +277,7 @@ def add_logo(orig, dc, img, logo=None): 'bands': list(img.mode)}) -def add_decorate(orig, **decorate): +def add_decorate(orig, fill_value=None, **decorate): """Decorate an image with text and/or logos/images. This call adds text/logos in order as given in the input to keep the @@ -312,7 +312,7 @@ def add_decorate(orig, **decorate): # Need to create this here to possible keep the alignment # when adding text and/or logo with pydecorate - img_orig = orig.pil_image() + img_orig = orig.pil_image(fill_value=fill_value) from pydecorate import DecoratorAGG dc = DecoratorAGG(img_orig) @@ -331,7 +331,8 @@ def get_enhanced_image(dataset, ppp_config_dir=None, enhancement_config_file=None, overlay=None, - decorate=None): + decorate=None, + fill_value=None): if ppp_config_dir is None: ppp_config_dir = get_environ_config_dir() @@ -350,10 +351,10 @@ def get_enhanced_image(dataset, enhancer.apply(img, **dataset.attrs) if overlay is not None: - add_overlay(img, dataset.attrs['area'], **overlay) + add_overlay(img, dataset.attrs['area'], fill_value=fill_value, **overlay) if decorate is not None: - add_decorate(img, **decorate) + add_decorate(img, fille_value=fill_value, **decorate) return img @@ -598,7 +599,7 @@ def save_dataset(self, dataset, filename=None, fill_value=None, """ img = get_enhanced_image( dataset.squeeze(), self.enhancer, overlay=overlay, - decorate=decorate) + decorate=decorate, fill_value=fill_value) return self.save_image(img, filename=filename, compute=compute, fill_value=fill_value, **kwargs) From 7da641dff40aac0724d43ed2e18e18f29b508768 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Tue, 25 Sep 2018 14:24:47 -0500 Subject: [PATCH 2/2] Fix fill_value typo --- satpy/writers/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/satpy/writers/__init__.py b/satpy/writers/__init__.py index 916dff351f..1e44f0d9dc 100644 --- a/satpy/writers/__init__.py +++ b/satpy/writers/__init__.py @@ -354,7 +354,7 @@ def get_enhanced_image(dataset, add_overlay(img, dataset.attrs['area'], fill_value=fill_value, **overlay) if decorate is not None: - add_decorate(img, fille_value=fill_value, **decorate) + add_decorate(img, fill_value=fill_value, **decorate) return img