From ef7fe36cae37c0e0d67f5778deb87f990b30708b Mon Sep 17 00:00:00 2001 From: Andreas Janz Date: Thu, 7 Mar 2024 15:20:11 +0100 Subject: [PATCH] small fix in EnFireMap ingest_data script --- enmapboxprocessing/algorithm/translaterasteralgorithm.py | 8 ++++++-- scripts/EnFireMAP/bad_wavelengths.txt | 2 ++ scripts/EnFireMAP/ingest_data.py | 4 +--- .../algorithm/test_TranslateRasterAlgorithm.py | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/enmapboxprocessing/algorithm/translaterasteralgorithm.py b/enmapboxprocessing/algorithm/translaterasteralgorithm.py index 0cd6910b..7e976c3f 100644 --- a/enmapboxprocessing/algorithm/translaterasteralgorithm.py +++ b/enmapboxprocessing/algorithm/translaterasteralgorithm.py @@ -234,8 +234,12 @@ def isBadBand(bandNo: int) -> bool: spectralBandList = [i + 1 for i in range(spectralRaster.bandCount())] wavelength = np.array([reader.wavelength(bandNo) for bandNo in bandList]) - bandList = [int(np.argmin(np.abs(wavelength - spectralReader.wavelength(bandNo))) + 1) - for bandNo in spectralBandList] + + bandList = list() + for targetBandNo in spectralBandList: + targetWavelength = spectralReader.wavelength(targetBandNo) + bandNo = int(np.argmin(np.abs(wavelength - targetWavelength)) + 1) + bandList.append(bandNo) if bandList is None: nBands = raster.bandCount() diff --git a/scripts/EnFireMAP/bad_wavelengths.txt b/scripts/EnFireMAP/bad_wavelengths.txt index 7a4dfbd2..8beb49dd 100644 --- a/scripts/EnFireMAP/bad_wavelengths.txt +++ b/scripts/EnFireMAP/bad_wavelengths.txt @@ -3,3 +3,5 @@ 1366.69 1378.6 1390.48 +1461.1 +1759.51 \ No newline at end of file diff --git a/scripts/EnFireMAP/ingest_data.py b/scripts/EnFireMAP/ingest_data.py index 161d5bf8..f65aa764 100644 --- a/scripts/EnFireMAP/ingest_data.py +++ b/scripts/EnFireMAP/ingest_data.py @@ -15,7 +15,6 @@ from enmapboxprocessing.rasterreader import RasterReader from enmapboxprocessing.rasterwriter import RasterWriter from enmapboxprocessing.utils import Utils - from qgis.core import QgsPointXY, QgsCoordinateReferenceSystem, QgsCoordinateTransform, \ QgsProject, QgsVectorLayer, QgsGeometry, Qgis, QgsRectangle @@ -60,7 +59,7 @@ def prepareSpectralImages(): alg = ImportEnmapL2AAlgorithm() parameters = { alg.P_FILE: xmlFilename, - alg.P_SET_BAD_BANDS: True, + alg.P_SET_BAD_BANDS: False, alg.P_EXCLUDE_BAD_BANDS: False, alg.P_DETECTOR_OVERLAP: alg.OrderByWavelengthOverlapOption, alg.P_OUTPUT_RASTER: xmlFilename.replace('METADATA.XML', 'SPECTRAL_IMAGE_FULL.vrt'), @@ -220,4 +219,3 @@ def auxDeriveSceneBoundingPolygon(xmlFilename) -> QgsGeometry: prepareSpectralImages() copyMetadataXml() ingestData() -print('done') diff --git a/tests/enmap-box/enmapboxprocessing/algorithm/test_TranslateRasterAlgorithm.py b/tests/enmap-box/enmapboxprocessing/algorithm/test_TranslateRasterAlgorithm.py index 99563178..baa249ee 100644 --- a/tests/enmap-box/enmapboxprocessing/algorithm/test_TranslateRasterAlgorithm.py +++ b/tests/enmap-box/enmapboxprocessing/algorithm/test_TranslateRasterAlgorithm.py @@ -3,11 +3,11 @@ import numpy as np from osgeo import gdal -from enmapboxtestdata import enmap, hires from enmapboxprocessing.algorithm.testcase import TestCase from enmapboxprocessing.algorithm.translaterasteralgorithm import TranslateRasterAlgorithm from enmapboxprocessing.rasterreader import RasterReader from enmapboxprocessing.utils import Utils +from enmapboxtestdata import enmap, hires from enmapboxtestdata import water_mask_30m, enmap_grid_300m from qgis.core import QgsRectangle, QgsCoordinateReferenceSystem, QgsRasterLayer, QgsRasterRenderer, Qgis