Skip to content

Commit

Permalink
Merge branch 'main' of github.com:EnMAP-Box/enmap-box
Browse files Browse the repository at this point in the history
  • Loading branch information
janzandr committed Sep 5, 2023
2 parents 9d42f1d + 4b81313 commit 3dbeb66
Show file tree
Hide file tree
Showing 69 changed files with 1,007 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ def processAlgorithm(
assert ds is not None

# allow counter variables for band names (see issue #539)
if '{bandNo}' in parameters[self.P_NAMES] or '{bandName}' in parameters[self.P_NAMES]:
reader = RasterReader(source)
bandNames = [reader.bandName(bandNo) for bandNo in reader.bandNumbers()]
parameters[self.P_NAMES] = \
f"[f'{parameters[self.P_NAMES]}' for bandNo, bandName in enumerate({bandNames}, 1)]"
if self.P_NAMES in parameters:
if '{bandNo}' in parameters[self.P_NAMES] or '{bandName}' in parameters[self.P_NAMES]:
reader = RasterReader(source)
bandNames = [reader.bandName(bandNo) for bandNo in reader.bandNumbers()]
parameters[self.P_NAMES] = \
f"[f'{parameters[self.P_NAMES]}' for bandNo, bandName in enumerate({bandNames}, 1)]"

names = self.parameterAsStringValues(parameters, self.P_NAMES, context)
wavelengths = self.parameterAsFloatValues(parameters, self.P_WAVELENGTHS, context)
Expand Down
6 changes: 5 additions & 1 deletion enmapboxprocessing/algorithm/importenmapl2aalgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,18 @@ def processAlgorithm(
int(text) for text in root.find('specific/swirProductQuality/expectedChannelsList').text.split(',')
]

overlapStart = wavelength[swirBandNumbers[0]]
overlapEnd = wavelength[vnirBandNumbers[-1]]
if detectorOverlap == self.OrderByDetectorOverlapOption:
bandList = vnirBandNumbers + swirBandNumbers
elif detectorOverlap == self.OrderByWavelengthOverlapOption:
bandList = list(range(1, len(wavelength) + 1))
elif detectorOverlap == self.VnirOnlyOverlapOption:
bandList = vnirBandNumbers
bandList.extend([bandNo for bandNo in swirBandNumbers if wavelength[bandNo - 1] > overlapEnd])
elif detectorOverlap == self.SwirOnlyOverlapOption:
bandList = swirBandNumbers
bandList = [bandNo for bandNo in vnirBandNumbers if wavelength[bandNo - 1] < overlapStart]
bandList.extend(swirBandNumbers)
else:
raise ValueError()

Expand Down
4 changes: 2 additions & 2 deletions scripts/EnFireMAP/ingest_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from enmapboxprocessing.algorithm.importenmapl2aalgorithm import ImportEnmapL2AAlgorithm
from enmapboxprocessing.driver import Driver
from enmapboxprocessing.rasterreader import RasterReader
from qgis._core import QgsVectorLayer
from qgis.core import QgsVectorLayer

rootData = r'D:\data\EnFireMap\data'
rootCube = r'D:\data\EnFireMap\cube'
Expand Down Expand Up @@ -48,7 +48,7 @@ def ingestData():
try:
prefix, datestamp, sceneNo = scene.split('_')
assert prefix == 'nc'
except:
except Exception:
continue
scenesByDate[datestamp].append(scene)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sklearn.decomposition import PCA
from sklearn.preprocessing import RobustScaler, MinMaxScaler

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.rasterreader import RasterReader
from enmapboxprocessing.testcase import TestCase
from enmapboxprocessing.utils import Utils
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.aggregaterasterbandsalgorithm import AggregateRasterBandsAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxprocessing.rasterreader import RasterReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from enmapbox.exampledata import enmap, landcover_polygon
from enmapboxtestdata import enmap, landcover_polygon
from enmapboxprocessing.algorithm.applymaskalgorithm import ApplyMaskAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxprocessing.rasterreader import RasterReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.build3dcubealgorithm import Build3dCubeAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_50p_coverage(self):
}
self.runalg(alg, parameters)
reader = RasterReader(parameters[alg.P_OUTPUT_FRACTION_RASTER])
self.assertAlmostEqual(247.589, np.mean(reader.array()), 3)
self.assertAlmostEqual(249.092, np.mean(reader.array()), 3)

def test_100p_coverage(self):
alg = ClassFractionFromCategorizedVectorAlgorithm()
Expand All @@ -93,4 +93,4 @@ def test_100p_coverage(self):
}
self.runalg(alg, parameters)
reader = RasterReader(parameters[alg.P_OUTPUT_FRACTION_RASTER])
self.assertAlmostEqual(247.589, np.mean(reader.array()), 3)
self.assertAlmostEqual(250.711, np.mean(reader.array()), 3)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from math import isnan

from enmapbox.exampledata import landcover_polygon
from enmapboxtestdata import landcover_polygon
from enmapboxprocessing.algorithm.classificationperformancesimplealgorithm import \
ClassificationPerformanceSimpleAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from enmapbox.exampledata import landcover_polygon
from enmapboxtestdata import landcover_polygon
from enmapboxprocessing.algorithm.classificationperformancestratifiedalgorithm import (
stratifiedAccuracyAssessment, ClassificationPerformanceStratifiedAlgorithm
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sklearn.base import ClassifierMixin

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.classificationworkflowalgorithm import ClassificationWorkflowAlgorithm
from enmapboxprocessing.algorithm.fitclassifieralgorithmbase import FitClassifierAlgorithmBase
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.convexhullalgorithm import ConvexHullAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxprocessing.algorithm.translaterasteralgorithm import TranslateRasterAlgorithm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from enmapbox.exampledata import hires
from enmapboxtestdata import hires
from enmapboxprocessing.algorithm.convolutionfilteralgorithmbase import ConvolutionFilterAlgorithmBase
from enmapboxprocessing.algorithm.spatialconvolutionairydisk2dalgorithm import SpatialConvolutionAiryDisk2DAlgorithm
from enmapboxprocessing.algorithm.spatialconvolutionbox2dalgorithm import SpatialConvolutionBox2DAlgorithm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.creategridalgorithm import CreateGridAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from qgis.core import QgsRasterLayer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from enmapbox.exampledata import hires
from enmapboxtestdata import hires
from enmapboxprocessing.algorithm.createmaskalgorithm import CreateMaskAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxprocessing.rasterreader import RasterReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from sklearn.base import ClassifierMixin

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.creatergbimagefromclassprobabilityalgorithm import \
CreateRgbImageFromClassProbabilityAlgorithm
from enmapboxprocessing.algorithm.fitclassifieralgorithmbase import FitClassifierAlgorithmBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from osgeo import gdal

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.createspectralindicesalgorithm import CreateSpectralIndicesAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxprocessing.rasterreader import RasterReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sklearn.base import ClusterMixin, TransformerMixin

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.fitaffinitypropagationalgorithm import FitAffinityPropagationAlgorithm
from enmapboxprocessing.algorithm.fitbirchalgorithm import FitBirchAlgorithm
from enmapboxprocessing.algorithm.fitclustereralgorithmbase import FitClustererAlgorithmBase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sklearn.base import TransformerMixin

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.fitfactoranalysisalgorithm import FitFactorAnalysisAlgorithm
from enmapboxprocessing.algorithm.fitfasticaalgorithm import FitFastIcaAlgorithm
from enmapboxprocessing.algorithm.fitfeatureagglomerationalgorithm import FitFeatureAgglomerationAlgorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def test(self):
}
result = self.runalg(alg, parameters)
self.assertAlmostEqual(
-11535788939.968838,
np.sum(RasterReader(result[alg.P_OUTPUT_RASTER]).array(bandList=[1]), dtype=float)
-11535788939.969,
np.sum(RasterReader(result[alg.P_OUTPUT_RASTER]).array(bandList=[1]), dtype=float), 3
)

def test_OrderByDetectorOverlapOption(self):
Expand Down Expand Up @@ -65,7 +65,7 @@ def test_VnirOnlyOverlapOption(self):
}
result = self.runalg(alg, parameters)
reader = RasterReader(result[alg.P_OUTPUT_RASTER])
self.assertEqual(91, reader.bandCount())
self.assertEqual(214, reader.bandCount())

def test_SwirOnlyOverlapOption(self):
if sensorProductsRoot() is None:
Expand All @@ -80,7 +80,7 @@ def test_SwirOnlyOverlapOption(self):
}
result = self.runalg(alg, parameters)
reader = RasterReader(result[alg.P_OUTPUT_RASTER])
self.assertEqual(133, reader.bandCount())
self.assertEqual(212, reader.bandCount())

def test_MovingAverageFilterOverlapOption(self):
if sensorProductsRoot() is None:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from enmapbox.exampledata import enmap, landcover_polygon
from enmapboxtestdata import enmap, landcover_polygon
from enmapboxprocessing.algorithm.layertomaskalgorithm import LayerToMaskAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxprocessing.rasterreader import RasterReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from sklearn.base import ClassifierMixin

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.fitclassifieralgorithmbase import FitClassifierAlgorithmBase
from enmapboxprocessing.algorithm.predictclassprobabilityalgorithm import PredictClassPropabilityAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from sklearn.base import ClassifierMixin

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.fitclassifieralgorithmbase import FitClassifierAlgorithmBase
from enmapboxprocessing.algorithm.predictclassificationalgorithm import PredictClassificationAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.predictregressionalgorithm import PredictRegressionAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxprocessing.rasterreader import RasterReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import library_gpkg
from enmapboxtestdata import library_gpkg
from enmapboxprocessing.algorithm.prepareclassificationdatasetfromcategorizedlibraryalgorithm import \
PrepareClassificationDatasetFromCategorizedLibraryAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import enmap_potsdam
from enmapboxtestdata import enmap_potsdam
from enmapboxprocessing.algorithm.prepareclassificationdatasetfromcategorizedrasteralgorithm import \
PrepareClassificationDatasetFromCategorizedRasterAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from enmapbox.exampledata import enmap_potsdam, landcover_potsdam_polygon
from enmapboxprocessing.algorithm.prepareclassificationdatasetfromcategorizedvectoralgorithm import \
PrepareClassificationDatasetFromCategorizedVectorAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxprocessing.typing import ClassifierDump
from enmapboxprocessing.utils import Utils
from enmapboxtestdata import points_in_no_data_region, enmap, landcover_polygon, landcover_point
from enmapboxtestdata import points_in_no_data_region, enmap, landcover_polygon, landcover_point, enmap_potsdam, \
landcover_potsdam_polygon


class TestPrepareClassificationSampleFromCategorizedVectorAlgorithm(TestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import library_gpkg
from enmapboxtestdata import library_gpkg
from enmapboxprocessing.algorithm.prepareregressiondatasetfromcontinuouslibraryalgorithm import \
PrepareRegressionDatasetFromContinuousLibraryAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import enmap_potsdam
from enmapboxtestdata import enmap_potsdam
from enmapboxprocessing.algorithm.prepareregressiondatasetfromcontinuousrasteralgorithm import \
PrepareRegressionDatasetFromContinuousRasterAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import enmap_potsdam, landcover_potsdam_point
from enmapboxtestdata import enmap_potsdam, landcover_potsdam_point
from enmapboxprocessing.algorithm.prepareregressiondatasetfromcontinuousvectoralgorithm import \
PrepareRegressionDatasetFromContinuousVectorAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import library_gpkg
from enmapboxtestdata import library_gpkg
from enmapboxprocessing.algorithm.prepareunsuperviseddatasetfromlibraryalgorithm import \
PrepareUnsupervisedDatasetFromLibraryAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import enmap_potsdam
from enmapboxtestdata import enmap_potsdam
from enmapboxprocessing.algorithm.prepareunsuperviseddatasetfromrasteralgorithm import \
PrepareUnsupervisedDatasetFromRasterAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.randompointsfrommaskrasteralgorithm import RandomPointsFromMaskRasterAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from qgis.core import QgsRasterLayer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.rasterlayerzonalaggregationalgorithm import RasterLayerZonalAggregationAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxtestdata import landcover_map_l3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from enmapbox.exampledata import enmap, landcover_polygon
from enmapboxtestdata import enmap, landcover_polygon
from enmapboxprocessing.algorithm.rasterizecategorizedvectoralgorithm import RasterizeCategorizedVectorAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxprocessing.rasterreader import RasterReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import enmap, landcover_polygon
from enmapboxtestdata import enmap, landcover_polygon
from enmapboxprocessing.algorithm.rasterizevectoralgorithm import RasterizeVectorAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxprocessing.rasterreader import RasterReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.fitrandomforestregressoralgorithm import FitRandomForestRegressorAlgorithm
from enmapboxprocessing.algorithm.regressionbasedunmixingalgorithm import RegressionBasedUnmixingAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sklearn.base import RegressorMixin

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.fitclassifieralgorithmbase import FitClassifierAlgorithmBase
from enmapboxprocessing.algorithm.regressionworkflowalgorithm import RegressionWorkflowAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import landcover_polygon
from enmapboxtestdata import landcover_polygon
from enmapboxprocessing.algorithm.roccurvealgorithm import RocCurveAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxtestdata import fraction_map_l3, fraction_polygon_l3, landcover_polygon_3classes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import enmap, landcover_polygon
from enmapboxtestdata import enmap, landcover_polygon
from enmapboxprocessing.algorithm.samplerastervaluesalgorithm import SampleRasterValuesAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxtestdata import landcover_points_singlepart_epsg3035
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import library_gpkg
from enmapboxtestdata import library_gpkg
from enmapboxprocessing.algorithm.savelibraryasgeojsonalgorithm import SaveLibraryAsGeoJsonAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from enmapbox.exampledata import enmap, hires
from enmapboxtestdata import enmap, hires
from enmapboxprocessing.algorithm.saverasterlayerasalgorithm import SaveRasterAsAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
from enmapboxprocessing.rasterreader import RasterReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enmapbox.exampledata import hires
from enmapboxtestdata import hires
from enmapboxprocessing.algorithm.spatialgaussiangradientmagnitudealgorithm import \
SpatialGaussianGradientMagnitudeAlgorithm
from enmapboxprocessing.algorithm.spatiallaplacealgorithm import SpatialLaplaceAlgorithm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from enmapbox.exampledata import enmap
from enmapboxtestdata import enmap
from enmapboxprocessing.algorithm.spectralresamplingtodesisalgorithm import SpectralResamplingToDesisAlgorithm
from enmapboxprocessing.algorithm.spectralresamplingtoenmapalgorithm import SpectralResamplingToEnmapAlgorithm
from enmapboxprocessing.algorithm.spectralresamplingtolandsat5algorithm import SpectralResamplingToLandsat5Algorithm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from enmapbox.exampledata import enmap, enmap_srf_library
from enmapboxtestdata import enmap, enmap_srf_library
from enmapboxprocessing.algorithm.spectralresamplingbyresponsefunctionlibraryalgorithm import \
SpectralResamplingByResponseFunctionLibraryAlgorithm
from enmapboxprocessing.algorithm.testcase import TestCase
Expand Down
Loading

0 comments on commit 3dbeb66

Please sign in to comment.