Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed that save_dataset does not propagate fill_value #423

Merged
merged 2 commits into from
Sep 25, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 9 additions & 8 deletions satpy/writers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 !
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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()

Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo fill_value versus fille_value.


return img

Expand Down Expand Up @@ -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)

Expand Down