Commit 4bdf35b9 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Added optional 'basename' parameter.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent f33057ef
Pipeline #26389 passed with stages
in 2 minutes and 34 seconds
......@@ -2,6 +2,12 @@
History
=======
0.14.2 (09.08.2021)
-------------------
* Added optional 'basename' parameter.
0.14.1 (07.08.2021)
-------------------
......
......@@ -64,9 +64,9 @@ class GeoArray(object):
some functions for quickly visualizing the data as a map, a simple image or an interactive image.
"""
def __init__(self, path_or_array, geotransform=None, projection=None, bandnames=None, nodata=None, progress=True,
q=False):
# type: (Union[str, np.ndarray, GeoArray], tuple, str, list, float, bool, bool) -> None
def __init__(self, path_or_array, geotransform=None, projection=None, bandnames=None, nodata=None, basename='',
progress=True, q=False):
# type: (Union[str, np.ndarray, GeoArray], tuple, str, list, float, str, bool, bool) -> None
"""Get an instance of GeoArray.
:param path_or_array: a numpy.ndarray or a valid file path
......@@ -76,6 +76,7 @@ class GeoArray(object):
:param bandnames: names of the bands within the input array, e.g. ['mask_1bit', 'mask_clouds'],
(default: ['B1', 'B2', 'B3', ...])
:param nodata: nodata value
:param basename: a short base name of the dataset (e.g., used in some status messages)
:param progress: show progress bars (default: True)
:param q: quiet mode (default: False)
"""
......@@ -99,16 +100,18 @@ class GeoArray(object):
self.geotransform = geotransform or self.geotransform
self.projection = projection or self.projection
self.bandnames = bandnames or list(self.bandnames.keys())
self.basename = basename or self.basename
self._nodata = nodata if nodata is not None else self._nodata
self.progress = False if progress is False else self.progress
self.q = q if q is not None else self.q
self.q = q or self.q
else:
self._initParams = dict([x for x in locals().items() if x[0] != "self"])
self.arg = path_or_array
self._arr = path_or_array if isinstance(path_or_array, np.ndarray) else None
self.filePath = path_or_array if isinstance(path_or_array, str) and path_or_array else None
self.basename = os.path.splitext(os.path.basename(self.filePath))[0] if not self.is_inmem else 'IN_MEM'
basename_default = os.path.splitext(os.path.basename(self.filePath))[0] if not self.is_inmem else 'IN_MEM'
self.basename = basename or basename_default
self.progress = progress
self.q = q
self._arr_cache = None # dict containing key 'pos' and 'arr_cached'
......
......@@ -20,5 +20,5 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '0.14.1'
__versionalias__ = '20210807.01'
__version__ = '0.14.2'
__versionalias__ = '20210809.01'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment