Skip to content

Commit

Permalink
Change kwarg 'fname' to 'filename'
Browse files Browse the repository at this point in the history
  • Loading branch information
pnuu committed Jun 7, 2019
1 parent 18ce2f3 commit ed42b48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions satpy/composites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,17 +1409,17 @@ def __call__(self, projectables, *args, **kwargs):
class StaticImageCompositor(GenericCompositor):
"""A compositor that loads a static image from disk."""

def __init__(self, name, fname=None, area=None, **kwargs):
def __init__(self, name, filename=None, area=None, **kwargs):
"""Collect custom configuration values.
Args:
fname (str): Filename of the image to load
filename (str): Filename of the image to load
area (str): Name of area definition for the image. Optional
for images with built-in area definitions (geotiff)
"""
if fname is None:
if filename is None:
raise ValueError("No image configured for static image compositor")
self.fname = fname
self.filename = filename
self.area = None
if area is not None:
from satpy.resample import get_area_def
Expand All @@ -1429,7 +1429,7 @@ def __init__(self, name, fname=None, area=None, **kwargs):

def __call__(self, *args, **kwargs):
from satpy import Scene
scn = Scene(reader='generic_image', filenames=[self.fname])
scn = Scene(reader='generic_image', filenames=[self.filename])
scn.load(['image'])
img = scn['image']
# use compositor parameters as extra metadata
Expand Down
14 changes: 7 additions & 7 deletions satpy/tests/compositor_tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,14 +852,14 @@ def test_init(self, get_area_def):
comp = StaticImageCompositor("name")

# No area defined
comp = StaticImageCompositor("name", fname="foo.tif")
self.assertEqual(comp.fname, "foo.tif")
comp = StaticImageCompositor("name", filename="foo.tif")
self.assertEqual(comp.filename, "foo.tif")
self.assertIsNone(comp.area)

# Area defined
get_area_def.return_value = "bar"
comp = StaticImageCompositor("name", fname="foo.tif", area="euro4")
self.assertEqual(comp.fname, "foo.tif")
comp = StaticImageCompositor("name", filename="foo.tif", area="euro4")
self.assertEqual(comp.filename, "foo.tif")
self.assertEqual(comp.area, "bar")
get_area_def.assert_called_once_with("euro4")

Expand All @@ -876,10 +876,10 @@ def load(self, arg):
scn = mock_scene()
scn['image'] = img
Scene.return_value = scn
comp = StaticImageCompositor("name", fname="foo.tif")
comp = StaticImageCompositor("name", filename="foo.tif")
res = comp()
Scene.assert_called_once_with(reader='generic_image',
filenames=[comp.fname])
filenames=[comp.filename])
self.assertTrue("start_time" in res.attrs)
self.assertTrue("end_time" in res.attrs)
self.assertIsNone(res.attrs['sensor'])
Expand All @@ -892,7 +892,7 @@ def load(self, arg):
res = comp()

# Non-georeferenced image, area given
comp = StaticImageCompositor("name", fname="foo.tif", area='euro4')
comp = StaticImageCompositor("name", filename="foo.tif", area='euro4')
res = comp()
self.assertEqual(res.attrs['area'].area_id, 'euro4')

Expand Down

0 comments on commit ed42b48

Please sign in to comment.