Commit 91f75477 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Test cluster homogenization is now done from Landsat-8 without cirrus band.

parent f31273d0
......@@ -238,7 +238,7 @@ class SpectralHomogenizer(object):
# TODO: add LBA validation to .predict()
if 'clust' in method:
PR = RSImage_ClusterPredictor(method=method.split('clust')[0], classifier_rootDir=self.classifier_rootDir,
classif_alg='kNN10') # FIXME hardcoded classif_alg
classif_alg='MinDist') # FIXME hardcoded classif_alg
else:
PR = RSImage_Predictor(method=method, classifier_rootDir=self.classifier_rootDir)
......@@ -1794,7 +1794,7 @@ class RSImage_ClusterPredictor(object):
:param tiledims:
"""
if self.classif_alg.startswith('kNN'):
n_neighbors = int(self.classif_alg.split('kNN')[1]) if self.classif_alg.split('kNN')[1] else None
n_neighbors = int(self.classif_alg.split('kNN')[1]) if self.classif_alg.split('kNN')[1] else 1
clf = kNN_Classifier(
cluster_classifier.cluster_centers,
cluster_classifier.cluster_pixVals,
......@@ -1813,7 +1813,7 @@ class RSImage_ClusterPredictor(object):
CPUs=self.CPUs)
else:
raise NotImplementedError("Currently only the methods 'kNN' and 'MinDist' are implemented.")
raise NotImplementedError("Currently only the methods 'kNN', 'MinDist' and 'SAM' are implemented.")
cmap = clf.classify(image, nodataVal=nodataVal, tiledims=tiledims) # use default tiledims (100 x 100)
......@@ -1865,6 +1865,9 @@ class RSImage_ClusterPredictor(object):
# copy mask_nodata
image_predicted.mask_nodata = image.mask_nodata
# GeoArray(image_predicted).save('/home/gfz-fe/scheffler/temp/SPECHOM_py/image_predicted_clust50_MinDist_noB9.bsq')
# GeoArray(self.classif_map).save('/home/gfz-fe/scheffler/temp/SPECHOM_py/classif_map_clust50_MinDist_noB9.bsq')
return image_predicted
def compute_prediction_errors(self, im_predicted, cluster_classifier, nodataVal=None):
......
......@@ -242,8 +242,10 @@ class Test_SpectralHomogenizer(unittest.TestCase):
# cls.testArr_L8 = GeoArray(np.random.randint(1, 10000, (50, 50, 7), dtype=np.int16)) # no band 9, no pan
# cls.testArr_L8 = GeoArray('/home/gfz-fe/scheffler/temp/'
# 'Landsat-8__OLI_TIRS__LC81940242014072LGN00_L2B__250x250.bsq') # no pan
# cls.testArr_L8 = GeoArray('/home/gfz-fe/scheffler/temp/'
# 'Landsat-8__OLI_TIRS__LC81940242014072LGN00_L2B.bsq') # no pan
cls.testArr_L8 = GeoArray('/home/gfz-fe/scheffler/temp/'
'Landsat-8__OLI_TIRS__LC81940242014072LGN00_L2B.bsq') # no pan
'clusterhomo_sourceL8_full_withoutB9.bsq') # no pan, no cirrus
# cls.cwl_L8 = [442.98, 482.59, 561.33, 654.61, 864.57, 1609.09, 2201.25]
cls.cwl_L8 = [442.98, 482.59, 561.33, 654.61, 864.57, 1373.48, 1609.09, 2201.25]
......@@ -318,10 +320,10 @@ class Test_SpectralHomogenizer(unittest.TestCase):
def test_predict_by_machine_learner__QR_cluster_L8_S2(self):
"""Test quadratic regression in spectral clusters from Landsat-8 to Sentinel-2A."""
predarr, errors = self.SpH.predict_by_machine_learner(
self.testArr_L8, method='QRclust',
self.testArr_L8, method='LRclust',
src_satellite='Landsat-8', src_sensor='OLI_TIRS',
# src_LBA=['1', '2', '3', '4', '5', '6', '7'],
src_LBA=['1', '2', '3', '4', '5', '9', '6', '7'],
src_LBA=['1', '2', '3', '4', '5', '6', '7'],
tgt_satellite='Sentinel-2A', tgt_sensor='MSI',
tgt_LBA=['1', '2', '3', '4', '5', '6', '7', '8', '8A', '9', '10', '11', '12'],
compute_errors=True,
......
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