def test_add_overlay_basic_l(self): """Test basic add_overlay usage with L data.""" from satpy.writers import add_overlay new_img = add_overlay(self.orig_l_img, self.area_def, '', fill_value=0) self.assertEqual('RGB', new_img.mode) new_img = add_overlay(self.orig_l_img, self.area_def, '') self.assertEqual('RGBA', new_img.mode)
def test_add_overlay_basic_rgb(self): """Test basic add_overlay usage with RGB data.""" from satpy.writers import add_overlay, _burn_overlay from pycoast import ContourWriterAGG coast_dir = '/path/to/coast/data' with mock.patch.object(self.orig_rgb_img, "apply_pil") as apply_pil: apply_pil.return_value = self.orig_rgb_img new_img = add_overlay(self.orig_rgb_img, self.area_def, coast_dir, fill_value=0) self.assertEqual(self.orig_rgb_img.mode, new_img.mode) new_img = add_overlay(self.orig_rgb_img, self.area_def, coast_dir) self.assertEqual(self.orig_rgb_img.mode + 'A', new_img.mode) with mock.patch.object(self.orig_rgb_img, "convert") as convert: convert.return_value = self.orig_rgb_img overlays = {'coasts': {'outline': 'red'}} new_img = add_overlay(self.orig_rgb_img, self.area_def, coast_dir, overlays=overlays, fill_value=0) pil_args = None pil_kwargs = {'fill_value': 0} fun_args = (self.orig_rgb_img.data.area, ContourWriterAGG.return_value, overlays) fun_kwargs = None apply_pil.assert_called_with(_burn_overlay, self.orig_rgb_img.mode, pil_args, pil_kwargs, fun_args, fun_kwargs) ContourWriterAGG.assert_called_with(coast_dir) # test legacy call grid = {'minor_is_tick': True} color = 'red' expected_overlays = {'coasts': {'outline': color, 'width': 0.5, 'level': 1}, 'borders': {'outline': color, 'width': 0.5, 'level': 1}, 'grid': grid} with warnings.catch_warnings(record=True) as wns: warnings.simplefilter("always") new_img = add_overlay(self.orig_rgb_img, self.area_def, coast_dir, color=color, grid=grid, fill_value=0) assert len(wns) == 1 assert issubclass(wns[0].category, DeprecationWarning) assert "deprecated" in str(wns[0].message) pil_args = None pil_kwargs = {'fill_value': 0} fun_args = (self.orig_rgb_img.data.area, ContourWriterAGG.return_value, expected_overlays) fun_kwargs = None apply_pil.assert_called_with(_burn_overlay, self.orig_rgb_img.mode, pil_args, pil_kwargs, fun_args, fun_kwargs) ContourWriterAGG.assert_called_with(coast_dir)
def get_image(self, sector_def): local = self.scene.resample(sector_def) img = to_image(local[self.product].squeeze()) self.enhance_image(img) img = add_overlay(img, area=sector_def, coast_dir=COAST_DIR, color=GOLDENROD, fill_value=0) pilimg = img.pil_image() self.decorate_pilimg(pilimg) return pilimg
def test_add_overlay_basic_rgb(self): """Test basic add_overlay usage with RGB data.""" from satpy.writers import add_overlay new_img = add_overlay(self.orig_rgb_img, self.area_def, '') self.assertEqual('RGBA', new_img.mode)
'bg': 'white', 'bg_opacity': 0, 'line': 'white' } }] } img = add_decorate(img, **decorate) #, fill_value='black' img = add_overlay(img, area, '/data/OWARNA/hau/maps_pytroll/', color='red', width=0.5, resolution='i', level_coast=1, level_borders=1, fill_value=None) #from satpy.writers import compute_writer_results #res1 = scn.save_datasets(filename="/tmp/{name}.png", # writer='simple_image', # compute=False) #res2 = scn.save_datasets(filename="/tmp/{name}.tif", # writer='geotiff', # compute=False) #results = [res1, res2] #compute_writer_results(results)