Commit 519f8838 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed linting issues.



Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent cd041b17
......@@ -35,6 +35,9 @@ Features
Credits
-------
The specclassify package was developed within the context of the GeoMultiSens project funded
by the German Federal Ministry of Education and Research (project grant code: 01 IS 14 010 A-C)
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
......
......@@ -37,3 +37,19 @@ from .classify import classify_image
__author__ = """Daniel Scheffler"""
__email__ = 'daniel.scheffler@gfz-potsdam.de'
__all__ = [
'MinimumDistance_Classifier',
'kNN_MinimumDistance_Classifier',
'kNN_Classifier',
'SAM_Classifier',
'kNN_SAM_Classifier',
'SID_Classifier',
'FEDSA_Classifier',
'kNN_FEDSA_Classifier',
'RF_Classifier',
'classify_image',
'__author__',
'__email__',
'__version__',
'__versionalias__'
]
......@@ -21,9 +21,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Base classes for specclassify.
"""
"""Base classes for specclassify."""
import numpy as np
from typing import Union, List # noqa F401 # flake8 issue
......@@ -38,6 +36,7 @@ from .misc import initializer
class _ImageClassifier(object):
"""Base class for GMS image classifiers."""
def __init__(self, train_spectra, train_labels, CPUs=1):
# type: (np.ndarray, Union[np.ndarray, List[int]], Union[int, None]) -> None
self.CPUs = CPUs
......@@ -55,7 +54,7 @@ class _ImageClassifier(object):
raise NotImplementedError('This method has to be implemented by the subclass.')
def classify(self, image_cube, in_nodataVal=None, cmap_nodataVal=None, tiledims=(100, 100)):
"""
"""Classify the image.
:param image_cube:
:param in_nodataVal:
......
......@@ -21,6 +21,4 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""
The classifiers module of specclassify (contains all the classifiers for multi- or hyperspectral image classification.
"""
"""The classifiers module of specclassify (contains all classifiers for multi- or hyperspectral image classification."""
......@@ -21,9 +21,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Classifiers using euclidian distance as measure for class distances.
"""
"""Classifiers using euclidian distance as measure for class distances."""
import numpy as np
from typing import Union, List # noqa F401 # flake8 issue
......@@ -45,8 +43,8 @@ class MinimumDistance_Classifier(_ImageClassifier):
NOTE: - distance equation: D² = sqrt(sum((Xvi - Xvj)²)
NOTE: - NearestCentroid parallelizes automatically but as long as the tile size is below 100 x 100,
Python multiprocessing is faster
"""
def __init__(self, train_spectra, train_labels, CPUs=1, **kwargs):
# type: (np.ndarray, Union[np.ndarray, List[int]], Union[int, None], dict) -> None
super(MinimumDistance_Classifier, self).__init__(train_spectra, train_labels, CPUs=CPUs)
......
......@@ -21,9 +21,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Classifiers using a combination of different measures for class distances.
"""
"""Classifiers using a combination of different measures for class distances."""
import numpy as np
from typing import Union # noqa F401 # flake8 issue
......
......@@ -21,9 +21,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Classifiers using random forest algorithms for class separation.
"""
"""Classifiers using random forest algorithms for class separation."""
import numpy as np
from typing import Union, List # noqa F401 # flake8 issue
......
......@@ -21,9 +21,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Classifiers using spectral angle as measure for class distances.
"""
"""Classifiers using spectral angle as measure for class distances."""
import numpy as np
from typing import Union # noqa F401 # flake8 issue
......@@ -143,7 +141,8 @@ class kNN_SAM_Classifier(SAM_Classifier):
def label_unclassified_pixels(self, label_unclassified, threshold):
# type: (int, Union[str, int, float]) -> GeoArray
cmap_labelled0 = self._label_unclassified_pixels(
GeoArray(self.cmap[:, :, 0], nodata=self.cmap.nodata), label_unclassified, threshold, self.angles_deg[:, :, 0]
GeoArray(self.cmap[:, :, 0], nodata=self.cmap.nodata),
label_unclassified, threshold, self.angles_deg[:, :, 0]
)
cmap = self.cmap
if label_unclassified in cmap_labelled0[:]:
......
......@@ -21,9 +21,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Classifiers using spectral information divergence as measure for class distances.
"""
"""Classifiers using spectral information divergence as measure for class distances."""
import numpy as np
from typing import Union # noqa F401 # flake8 issue
......
......@@ -21,15 +21,15 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Algorithms for multispectral image classification.
"""
"""Algorithms for multispectral image classification."""
import numpy as np
from typing import Union, List, Tuple # noqa F401 # flake8 issue
from geoarray import GeoArray
from . import *
from specclassify import \
MinimumDistance_Classifier, kNN_MinimumDistance_Classifier, kNN_Classifier, SAM_Classifier, kNN_SAM_Classifier, \
FEDSA_Classifier, kNN_FEDSA_Classifier, SID_Classifier, RF_Classifier
global_shared_endmembers = None # type: Union[None, np.ndarray]
global_shared_im2classify = None # type: Union[None, GeoArray]
......
......@@ -21,9 +21,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Functions commonly used by specclassify modules.
"""
"""Functions commonly used by specclassify modules."""
import numpy as np
from typing import Union, Tuple # noqa F401 # flake8 issue
......
......@@ -21,9 +21,7 @@
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Classifiers using euclidian distance as measure for class distances.
"""
"""Classifiers using euclidian distance as measure for class distances."""
import numpy as np
......@@ -46,7 +44,6 @@ def calc_sam(s1_norm, s2_norm, axis=0):
def calc_sid(s1_norm, s2_norm, axis=0):
"""Compute the spectral information divergence between two vectors or images."""
def get_sum(x, axis=0):
s = np.sum(x, axis=axis)
s[s == 0] = 1e-10
......
Supports Markdown
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