Commit 1bed4345 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Merge branch...

Merge branch '79-filenotfounderror-when-using-the-official-enmap-test-data-downloaded-from-enmap-org' into 'master'

Resolve "FileNotFoundError when using the official EnMAP test data downloaded from enmap.org."

Closes #79

See merge request !57
parents 31706455 c7992cbd
Pipeline #24653 passed with stages
in 56 minutes and 56 seconds
...@@ -2,6 +2,12 @@ ...@@ -2,6 +2,12 @@
History History
======= =======
0.18.3 (2021-06-18)
-------------------
* Fixed #79 (FileNotFoundError when using the official EnMAP test data downloaded from enmap.org).
0.18.2 (2021-06-17) 0.18.2 (2021-06-17)
------------------- -------------------
......
...@@ -40,6 +40,7 @@ import pickle ...@@ -40,6 +40,7 @@ import pickle
from typing import Optional from typing import Optional
from time import time from time import time
from datetime import timedelta from datetime import timedelta
from glob import glob
from ..options.config import EnPTConfig from ..options.config import EnPTConfig
from ..io.reader import L1B_Reader from ..io.reader import L1B_Reader
...@@ -85,6 +86,15 @@ class EnPT_Controller(object): ...@@ -85,6 +86,15 @@ class EnPT_Controller(object):
with zipfile.ZipFile(path_zipfile, "r") as zf: with zipfile.ZipFile(path_zipfile, "r") as zf:
zf.extractall(outdir) zf.extractall(outdir)
# move the data one level up in case they are within a sub-folder in the zip file
if not self.cfg.is_dummy_dataformat:
content = glob(os.path.join(outdir, '*'))
if len(content) == 1 and os.path.isdir(content[0]):
for fp in glob(os.path.join(outdir, '**', '*')):
shutil.move(fp, outdir)
shutil.rmtree(content[0])
if not os.path.isdir(outdir): if not os.path.isdir(outdir):
raise NotADirectoryError(outdir) raise NotADirectoryError(outdir)
......
...@@ -127,24 +127,25 @@ class L1B_Reader(object): ...@@ -127,24 +127,25 @@ class L1B_Reader(object):
if not files: if not files:
raise RuntimeError("The root directory of the EnMAP image %s is empty." % rootdir_l1b) raise RuntimeError("The root directory of the EnMAP image %s is empty." % rootdir_l1b)
for pattern in ['*-HISTORY.XML', for pattern in [
'*-LOG.XML', # '*-HISTORY.XML', # only included in internal DLR test data, not in the zip archive on enmap.org
'*-METADATA.XML', # '*-LOG.XML', # only included in internal DLR test data, not in the zip archive on enmap.org
'*-QL_PIXELMASK_SWIR.TIF', '*-METADATA.XML',
'*-QL_PIXELMASK_VNIR.TIF', '*-QL_PIXELMASK_SWIR.TIF',
'*-QL_QUALITY_CIRRUS.TIF', '*-QL_PIXELMASK_VNIR.TIF',
'*-QL_QUALITY_CLASSES.TIF', '*-QL_QUALITY_CIRRUS.TIF',
'*-QL_QUALITY_CLOUD.TIF', '*-QL_QUALITY_CLASSES.TIF',
'*-QL_QUALITY_CLOUDSHADOW.TIF', '*-QL_QUALITY_CLOUD.TIF',
'*-QL_QUALITY_HAZE.TIF', '*-QL_QUALITY_CLOUDSHADOW.TIF',
'*-QL_QUALITY_SNOW.TIF', '*-QL_QUALITY_HAZE.TIF',
'*-QL_QUALITY_TESTFLAGS_SWIR.TIF', '*-QL_QUALITY_SNOW.TIF',
'*-QL_QUALITY_TESTFLAGS_VNIR.TIF', '*-QL_QUALITY_TESTFLAGS_SWIR.TIF',
'*-QL_SWIR.TIF', '*-QL_QUALITY_TESTFLAGS_VNIR.TIF',
'*-QL_VNIR.TIF', '*-QL_SWIR.TIF',
'*-SPECTRAL_IMAGE_SWIR.TIF', '*-QL_VNIR.TIF',
'*-SPECTRAL_IMAGE_VNIR.TIF', '*-SPECTRAL_IMAGE_SWIR.TIF',
]: '*-SPECTRAL_IMAGE_VNIR.TIF',
]:
if not filter(files, pattern) and not filter(files, pattern.replace('.TIF', '.GEOTIFF')): if not filter(files, pattern) and not filter(files, pattern.replace('.TIF', '.GEOTIFF')):
raise FileNotFoundError('The root directory of the EnMAP image %s misses a file with the pattern %s.' raise FileNotFoundError('The root directory of the EnMAP image %s misses a file with the pattern %s.'
% (rootdir_l1b, pattern)) % (rootdir_l1b, pattern))
......
...@@ -149,6 +149,9 @@ config_for_testing_dlr = dict( ...@@ -149,6 +149,9 @@ config_for_testing_dlr = dict(
# Arcachon full tile 3, reprocessed 05/2020 # Arcachon full tile 3, reprocessed 05/2020
# 'ENMAP01-____L1B-DT000400126_20170218T110119Z_003_V000204_20200508T124425Z.zip' # 'ENMAP01-____L1B-DT000400126_20170218T110119Z_003_V000204_20200508T124425Z.zip'
# Arcachon tile 3 (full), downloaded from enmap.org
# 'L1B_Arcachon_3__enmap.org.zip',
)), )),
# path_l1b_enmap_image_gapfill=os.path.abspath( # path_l1b_enmap_image_gapfill=os.path.abspath(
# os.path.join(path_enptlib, '..', 'tests', 'data', 'EnMAP_Level_1B', # os.path.join(path_enptlib, '..', 'tests', 'data', 'EnMAP_Level_1B',
......
Supports Markdown
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