Commit 00490e67 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

PEP8 editing.

Former-commit-id: 684ce544
Former-commit-id: 383682c2
parent 5f08e2ae
This diff is collapsed.
# -*- coding: utf-8 -*-
###############################################################################
#
# Level 2B Processor:
# Spectral homogenization
#
###############################################################################
"""
Level 2B Processor: Spectral homogenization
"""
__author__='Daniel Scheffler'
import numpy as np
......@@ -17,7 +15,7 @@ from .L2A_P import L2A_object
class L2B_object(L2A_object):
def __init__(self, L2A_obj=None):
super().__init__()
super(L2B_object, self).__init__()
if L2A_obj:
# populate attributes
......@@ -52,5 +50,17 @@ class L2B_object(L2A_object):
orig_CWLs, target_CWLs = np.array(source_CWLs), np.array(target_CWLs)
outarr = interp1d(np.array(orig_CWLs), arrcube, axis=2, kind='linear', fill_value='extrapolate')(target_CWLs)
outarr = outarr.astype(np.int16)
assert outarr.shape == (arrcube.shape[:2]+(len(target_CWLs),))
assert outarr.shape == (arrcube.shape[:2] + (len(target_CWLs), ))
return outarr
class SpectralResampler2D(object):
def __init__(self, wvl_src, srf_tgt=None, ):
self.wvl_src = wvl_src
self.srf_tgt = srf_tgt
def resample(self, spectrum):
# type: (np.ndarray) -> np.ndarray
assert spectrum.shape == self.wvl_src.shape
This diff is collapsed.
......@@ -38,7 +38,6 @@ Program edited in July 2017.
__author__ = 'Daniel Scheffler' # edited by Jessica Palka.
# Imports from the python standard library.
import itertools
import logging
......@@ -59,20 +58,19 @@ from gms_preprocessing.algorithms.L2C_P import L2C_object
from gms_preprocessing.misc.database_tools import get_info_from_postgreSQLdb
# Rootpath of the gms_preprocessing-repository.
gmsRepo_rootpath = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
# Defining the configurations needed to start a job containing the different dataset scenes.
# TODO Change the job-configurations for selected datasets.
job_config_kwargs = dict(is_test = True)
###################################################################################
##########################
# Test case: BaseTestCases
##########################
class BaseTestCases:
"""
......@@ -101,37 +99,31 @@ class BaseTestCases:
[cls.validate_db_entry(ds['filename']) for ds in cls.PC.usecase.data_list]
def test_L1A_processing(self):
self.L1A_newObjects = self.PC.L1A_processing()
self.assertIsInstance(self.L1A_newObjects, list)
self.assertIsInstance(self.L1A_newObjects[0], L1A_object)
def test_L1B_processing(self):
self.L1B_newObjects = self.PC.L1B_processing()
self.assertIsInstance(self.L1B_newObjects, list)
self.assertIsInstance(self.L1B_newObjects[0], L1B_object)
def test_L1C_processing(self):
self.L1C_newObjects = self.PC.L1C_processing()
self.assertIsInstance(self.L1C_newObjects, list)
self.assertIsInstance(self.L1C_newObjects[0], L1C_object)
def test_L2A_processing(self):
self.L2A_newObjects = self.PC.L2A_processing()
self.assertIsInstance(self.L2A_newObjects, list)
self.assertIsInstance(self.L2A_newObjects[0], L2A_object)
def test_L2B_processing(self):
self.L2B_newObjects = self.PC.L2B_processing()
self.assertIsInstance(self.L2B_newObjects, list)
self.assertIsInstance(self.L2B_newObjects[0], L2B_object)
def test_L2C_processing(self):
self.L2C_newObjects = self.PC.L2C_processing()
self.assertIsInstance(self.L2C_newObjects, list)
......@@ -141,7 +133,6 @@ class BaseTestCases:
# self.PC.job.status = "finished" # FIXME after updating the job.status-attribute for the level-processes, delete the code that is commented out.
###################################################################################
# Test cases 1-9: Test_<Satelite-Dataset>_<PreCollection or Collection>Data
# Test case 10: Test_MultipleDatasetsInOneJob
......@@ -166,6 +157,7 @@ class Test_Landsat5_PreCollectionData(BaseTestCases.TestAll):
# def setUpClass(cls):
# cls.create_job(26186263, job_config_kwargs) # FIXME job_ID!
class Test_Landsat7_SLC_on_PreCollectionData(BaseTestCases.TestAll):
"""
Parametrized testclass. Tests the level-processes on a Landsat-7 ETM+_SLC_ON scene (pre-collection data).
......@@ -175,6 +167,7 @@ class Test_Landsat7_SLC_on_PreCollectionData(BaseTestCases.TestAll):
def setUpClass(cls):
cls.create_job(26186262, job_config_kwargs)
class Test_Landsat7_SLC_off_PreCollectionData(BaseTestCases.TestAll):
"""
Parametrized testclass. Tests the level-processes on a Landsat-7 ETM+_SLC_OFF scene (pre-collection data).
......@@ -184,6 +177,7 @@ class Test_Landsat7_SLC_off_PreCollectionData(BaseTestCases.TestAll):
def setUpClass(cls):
cls.create_job(26186267, job_config_kwargs)
# class Test_Landsat7_SLC_off_CollectionData(BaseTestCases.TestAll):
# """
# Parametrized testclass. Tests the level-processes on a Landsat-7 ETM+_SLC_OFF scene (collection data).
......@@ -193,6 +187,7 @@ class Test_Landsat7_SLC_off_PreCollectionData(BaseTestCases.TestAll):
# def setUpClass(cls):
# cls.create_job(26186267, job_config_kwargs) # FIXME job_ID!
class Test_Landsat8_PreCollectionData(BaseTestCases.TestAll):
"""
Parametrized testclass. Tests the level-processes on a Landsat-8 OLI_TIRS scene (pre-collection data).
......@@ -202,6 +197,7 @@ class Test_Landsat8_PreCollectionData(BaseTestCases.TestAll):
def setUpClass(cls):
cls.create_job(26186196, job_config_kwargs)
class Test_Landsat8_CollectionData(BaseTestCases.TestAll):
"""
Parametrized testclass. Tests the level-processes on a Landsat-8 OLI_TIRS scene (collection data).
......@@ -211,6 +207,7 @@ class Test_Landsat8_CollectionData(BaseTestCases.TestAll):
def setUpClass(cls):
cls.create_job(26186261, job_config_kwargs)
class Test_Sentinel2A_CollectionData(BaseTestCases.TestAll):
"""
Parametrized testclass. Tests the level-processes on a Sentinel-2A MSI scene (pre-collection data).
......@@ -220,6 +217,7 @@ class Test_Sentinel2A_CollectionData(BaseTestCases.TestAll):
def setUpClass(cls):
cls.create_job(26186268, job_config_kwargs)
class Test_Sentinel2A_PreCollectionData(BaseTestCases.TestAll):
"""
Parametrized testclass. Tests the level-processes on a Sentinel-2A MSI scene (collection data).
......@@ -229,6 +227,7 @@ class Test_Sentinel2A_PreCollectionData(BaseTestCases.TestAll):
def setUpClass(cls):
cls.create_job(26186272, job_config_kwargs)
class Test_MultipleDatasetsInOneJob(BaseTestCases.TestAll):
"""
Parametrized testclass. Tests the level-processes on a job containing a Landsat-5 (pre-collection data),
......@@ -239,7 +238,6 @@ class Test_MultipleDatasetsInOneJob(BaseTestCases.TestAll):
cls.create_job(26186273, job_config_kwargs)
###################################################################################
# Summarizing the information regarding the test datasets.
......@@ -249,10 +247,10 @@ class Test_MultipleDatasetsInOneJob(BaseTestCases.TestAll):
# 3-letter code:
# UKR-Ukraine, KGZ-Kyrgyztan, POL-Poland, AUT-Austria, JPN-Japan, BOL-Bolivia, TUR-Turkey, DEU-Germany, CHE-Switzerland.
testdata_scenes = {'Landsat5_PreCollectionData' : list(['UKR', 'City region, forest', 'Sparsely', 'Zone 34/35']),
#'Landsat5_CollectionData' : list(['KGZ', 'Snowy Mountains', 'Yes', 'None']),
# 'Landsat5_CollectionData' : list(['KGZ', 'Snowy Mountains', 'Yes', 'None']),
'Landsat7_SLC_on_PreCollectionData' : list(['POL', 'City region, lakes', 'Yes', 'None']),
'Landsat7_SLC_off_PreCollectionData': list(['AUT', 'Stripes (partly), Mountains', 'None', 'None']),
#'Landsat7_SLC_off_CollectionData' : list(['JPN', 'Stripes (completly), Mountains', 'Yes', 'Zone 53/54']),
# 'Landsat7_SLC_off_CollectionData' : list(['JPN', 'Stripes (completly), Mountains', 'Yes', 'Zone 53/54']),
'Landsat8_PreCollectionData' : list(['BOL', 'Forest', 'Yes', 'None']),
'Landsat8_CollectionData' : list(['TUR', 'Snowy Mountains', 'Yes', 'None']),
'Sentinel2A_PreCollectionData' : list(['DEU', 'Potsdam', 'Sparsely', 'None']),
......@@ -265,7 +263,6 @@ testdata = list(testdata_scenes.keys())
testdata.append('MultipleDatasetsInOneJob')
###################################################################################
# Parametrizing the test cases and creating a summary of the testresults.
......@@ -287,8 +284,7 @@ if __name__ == '__main__':
summary_failures.append(testResult.failures)
summary_skipped.append(testResult.skipped)
#jobstatus.append(eval("Test_"+items).PC.job.status) # FIXME: If the job.status-issue is fixed, the commented out section can be nullified.
# jobstatus.append(eval("Test_"+items).PC.job.status) # FIXME: If the job.status-issue is fixed, the commented out section can be nullified.
# Part 3: Summarizing the testresults of each testsuite and outputting the results in an orderly fashion on the
......@@ -352,7 +348,6 @@ if __name__ == '__main__':
testdata_index = ["Test_" + item for item in testdata]
logger.info(pandas.DataFrame(summary_testResults, columns= results, index=testdata_index))
# If errors, failures or skips (there is yet nothing to skip in the code) occurres, the respective message will
# be printed.
logger.info("\n***************************************************************************************")
......@@ -388,7 +383,6 @@ if __name__ == '__main__':
else:
pass
# Checking, if the job.status of each job is set to "finished". Is it not set to "finished", a dataframe is created
# containing the test-name with and the different job.status itself.
# FIXME: If the job.status-issue is fixed, the commented out section can be nullified.
......@@ -405,7 +399,6 @@ if __name__ == '__main__':
# else:
# pass
logger.info("END.") # OUTPUT, END.
# Delete the handlers added to the "log_Test"-logger to ensure that no message is outputted twice in a row, when
......
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