Commit d3d617a9 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Added Quadratic Regression as possible algorithm for spectral homogenization.

Added more Ridge Regression classifiers for different alpha values.
parent 144a5e5e
......@@ -177,7 +177,20 @@ class Test_Classifier_Generator(unittest.TestCase):
CG = Classifier_Generator([refcube_l8, refcube_l5])
CG.create_classifiers(outDir=self.tmpOutdir.name, method='RR')
outpath_cls = os.path.join(self.tmpOutdir.name, 'RR__Landsat-8__OLI_TIRS.dill')
outpath_cls = os.path.join(self.tmpOutdir.name, 'RR_alpha1.0__Landsat-8__OLI_TIRS.dill')
self.assertTrue(os.path.exists(outpath_cls))
with open(outpath_cls, 'rb') as inF:
undilled = dill.load(inF)
self.assertIsInstance(undilled, dict)
self.assertTrue(bool(undilled), msg='Generated classifier collection is empty.')
def test_create_classifiers_QR(self):
"""Test creation of quadratic regression classifiers."""
CG = Classifier_Generator([refcube_l8, refcube_l5])
CG.create_classifiers(outDir=self.tmpOutdir.name, method='QR')
outpath_cls = os.path.join(self.tmpOutdir.name, 'QR__Landsat-8__OLI_TIRS.dill')
self.assertTrue(os.path.exists(outpath_cls))
with open(outpath_cls, 'rb') as inF:
......@@ -246,3 +259,21 @@ class Test_SpectralHomogenizer(unittest.TestCase):
self.assertIsInstance(errors, np.ndarray)
self.assertEqual(errors.shape, (50, 50, 13))
self.assertEqual(errors.dtype, np.int16)
def test_predict_by_machine_learner__QR_L8_S2(self):
"""Test quadratic regression from Landsat-8 to Sentinel-2A."""
predarr, errors = self.SpH.predict_by_machine_learner(
self.testArr_L8, method='QR',
src_satellite='Landsat-8', src_sensor='OLI_TIRS',
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)
self.assertIsInstance(predarr, GeoArray)
self.assertEqual(predarr.shape, (50, 50, 13))
self.assertEqual(predarr.dtype, np.int16)
self.assertIsInstance(errors, np.ndarray)
self.assertEqual(errors.shape, (50, 50, 13))
self.assertEqual(errors.dtype, np.int16)
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