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

Adaptions to the current file format.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent c061e4e2
Pipeline #7143 passed with stage
in 48 minutes and 17 seconds
......@@ -18,33 +18,33 @@ Segment. After data extraction EnPT expects a folder that includes the following
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-METADATA.XML | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_PIXELMASK_SWIR.GEOTIFF | |
|ENMAP*L1B*-QL_PIXELMASK_SWIR.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_PIXELMASK_VNIR.GEOTIFF | |
|ENMAP*L1B*-QL_PIXELMASK_VNIR.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_QUALITY_CIRRUS.GEOTIFF | |
|ENMAP*L1B*-QL_QUALITY_CIRRUS.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_QUALITY_CLASSES.GEOTIFF | |
|ENMAP*L1B*-QL_QUALITY_CLASSES.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_QUALITY_CLOUD.GEOTIFF | |
|ENMAP*L1B*-QL_QUALITY_CLOUD.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_QUALITY_CLOUDSHADOW.GEOTIFF | |
|ENMAP*L1B*-QL_QUALITY_CLOUDSHADOW.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_QUALITY_HAZE.GEOTIFF | |
|ENMAP*L1B*-QL_QUALITY_HAZE.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_QUALITY_SNOW.GEOTIFF | |
|ENMAP*L1B*-QL_QUALITY_SNOW.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_QUALITY_TESTFLAGS_SWIR.GEOTIFF | |
|ENMAP*L1B*-QL_QUALITY_TESTFLAGS_SWIR.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_QUALITY_TESTFLAGS_VNIR.GEOTIFF | |
|ENMAP*L1B*-QL_QUALITY_TESTFLAGS_VNIR.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_SWIR.GEOTIFF | |
|ENMAP*L1B*-QL_SWIR.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-QL_VNIR.GEOTIFF | |
|ENMAP*L1B*-QL_VNIR.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-SPECTRAL_IMAGE_SWIR.GEOTIFF | |
|ENMAP*L1B*-SPECTRAL_IMAGE_SWIR.TIF | |
+-----------------------------------------------+-----------------+
|ENMAP*L1B*-SPECTRAL_IMAGE_VNIR.GEOTIFF | |
|ENMAP*L1B*-SPECTRAL_IMAGE_VNIR.TIF | |
+-----------------------------------------------+-----------------+
EnPT reads the raster files lazily / on-demand to save memory during execution. Metadata read from the
......
......@@ -61,8 +61,8 @@ is given `here <https://gitext.gfz-potsdam.de/EnMAP/GFZ_Tools_EnMAP_BOX/EnPT/raw
The contents of this zip-archive may change in future.
Open QGIS_, start the EnMAP-Box_ and load the :file:`ENMAP*L1B*-SPECTRAL_IMAGE_VNIR.GEOTIFF` and
:file:`ENMAP*L1B*-SPECTRAL_IMAGE_SWIR.GEOTIFF` image datasets. Some
Open QGIS_, start the EnMAP-Box_ and load the :file:`ENMAP*L1B*-SPECTRAL_IMAGE_VNIR.TIF` and
:file:`ENMAP*L1B*-SPECTRAL_IMAGE_SWIR.TIF` image datasets. Some
general handling instructions regarding the EnMAP-Box_ are given in `Exercise A of the EnMAP-Box tutorials`_.
.. _`Exercise A of the EnMAP-Box tutorials`: https://enmap-box.readthedocs.io/en/latest/usr_section/application_tutorials/urban_unmixing/tutorial.html#exercise-a-urban-land-cover
......@@ -132,7 +132,7 @@ console. After processing, the output directory is indicated in the Log panel.
Inspect the Level-2A data and compare them with Level-1B
--------------------------------------------------------
The output folder contains the EnMAP Level-2A image data :file:`ENMAP*L2A*-SPECTRAL_IMAGE.GEOTIFF` and a couple of
The output folder contains the EnMAP Level-2A image data :file:`ENMAP*L2A*-SPECTRAL_IMAGE.TIF` and a couple of
other files, such as metadata, quality layers, etc.:
.. image:: img/tut__contents_l2a_output.png
......@@ -141,7 +141,7 @@ other files, such as metadata, quality layers, etc.:
The output directory will contain additional layers in future.
Load the :file:`ENMAP*L2A*-SPECTRAL_IMAGE.GEOTIFF` into
Load the :file:`ENMAP*L2A*-SPECTRAL_IMAGE.TIF` into
the EnMAP-Box_. Unfold the entry in the **Data sources** panel to explore some metadata of the Level-2A EnMAP-image.
The image has a dimension of 972 x 378 pixels in x- and y-direction and contains 218 bands. The different image
dimensions compared with Level-1B data are due to the geometric correction / orthorectification applied by EnPT.
......
......@@ -130,24 +130,24 @@ class L1B_Reader(object):
for pattern in ['*-HISTORY.XML',
'*-LOG.XML',
'*-METADATA.XML',
'*-QL_PIXELMASK_SWIR.GEOTIFF',
'*-QL_PIXELMASK_VNIR.GEOTIFF',
'*-QL_QUALITY_CIRRUS.GEOTIFF',
'*-QL_QUALITY_CLASSES.GEOTIFF',
'*-QL_QUALITY_CLOUD.GEOTIFF',
'*-QL_QUALITY_CLOUDSHADOW.GEOTIFF',
'*-QL_QUALITY_HAZE.GEOTIFF',
'*-QL_QUALITY_SNOW.GEOTIFF',
'*-QL_QUALITY_TESTFLAGS_SWIR.GEOTIFF',
'*-QL_QUALITY_TESTFLAGS_VNIR.GEOTIFF',
'*-QL_SWIR.GEOTIFF',
'*-QL_VNIR.GEOTIFF',
'*-SPECTRAL_IMAGE_SWIR.GEOTIFF',
'*-SPECTRAL_IMAGE_VNIR.GEOTIFF',
'*-QL_PIXELMASK_SWIR.TIF',
'*-QL_PIXELMASK_VNIR.TIF',
'*-QL_QUALITY_CIRRUS.TIF',
'*-QL_QUALITY_CLASSES.TIF',
'*-QL_QUALITY_CLOUD.TIF',
'*-QL_QUALITY_CLOUDSHADOW.TIF',
'*-QL_QUALITY_HAZE.TIF',
'*-QL_QUALITY_SNOW.TIF',
'*-QL_QUALITY_TESTFLAGS_SWIR.TIF',
'*-QL_QUALITY_TESTFLAGS_VNIR.TIF',
'*-QL_SWIR.TIF',
'*-QL_VNIR.TIF',
'*-SPECTRAL_IMAGE_SWIR.TIF',
'*-SPECTRAL_IMAGE_VNIR.TIF',
]:
if not filter(files, pattern):
raise FileNotFoundError('The root directory of the EnMAP image %s misses a file with the pattern '
'%s.' % (rootdir_l1b, pattern))
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.'
% (rootdir_l1b, pattern))
def validate_output(self):
"""Validate outputs of L1B_Reader."""
......
......@@ -148,7 +148,7 @@ class EnMAP_Metadata_L1B_Detector_SensorGeo(object):
def read_metadata(self, path_xml):
"""
Read the meadata of a specific EnMAP detector in sensor geometry
Read the metadata of a specific EnMAP detector in sensor geometry
:param path_xml: file path of the metadata file
:return: None
......@@ -161,18 +161,29 @@ class EnMAP_Metadata_L1B_Detector_SensorGeo(object):
# read data filenames
all_filenames = [ele.text for ele in xml.findall("product/productFileInformation/file/name")]
def get_filename(matching_exp: str):
matches = fnmatch.filter(all_filenames, '%s.GEOTIFF' % matching_exp)
if not matches:
matches = fnmatch.filter(all_filenames, '%s.TIF' % matching_exp)
if not matches:
raise FileNotFoundError("Could not find a file that matches the expression '%s'." % matching_exp)
return matches[0]
self.data_filename = xml.find("product/image/%s/name" % lbl).text
self.scene_basename = self.data_filename.split('-SPECTRAL_IMAGE')[0]
self.dead_pixel_filename = fnmatch.filter(all_filenames, '*QL_PIXELMASK_%s.GEOTIFF' % self.detector_name)[0]
self.dead_pixel_filename = get_filename('*QL_PIXELMASK_%s' % self.detector_name)
self.quicklook_filename = xml.find("product/quicklook/%s/name" % lbl).text
# FIXME multiple cloud masks provided. QL_QUALITY_CLASSES.GEOTIFF as combined product?
# - QL_QUALITY_CLOUD.GEOTIFF
# - QL_QUALITY_CIRRUS.GEOTIFF
# - QL_QUALITY_SNOW.GEOTIFF
# - QL_QUALITY_CLOUDSHADOW.GEOTIFF
# - QL_QUALITY_HAZE.GEOTIFF
self.logger.warning('DLR test data provide multiple cloud masks. Added only *QUALITY_CLOUD.GEOTIFF!')
self.cloud_mask_filename = fnmatch.filter(all_filenames, '*QUALITY_CLOUD.GEOTIFF')[0]
# FIXME multiple cloud masks provided. QL_QUALITY_CLASSES as combined product?
# - QL_QUALITY_CLOUD
# - QL_QUALITY_CIRRUS
# - QL_QUALITY_SNOW
# - QL_QUALITY_CLOUDSHADOW
# - QL_QUALITY_HAZE
self.cloud_mask_filename = get_filename('*-QL_QUALITY_CLOUD')
self.logger.warning('DLR test data provide multiple cloud masks. Added only *%s!'
% self.cloud_mask_filename.split(self.scene_basename)[1])
# read some basic information concerning the detector
self.nrows = int(xml.find("product/image/%s/dimension/rows" % lbl).text)
......@@ -746,6 +757,9 @@ class EnMAP_Metadata_L2A_MapGeo(object):
size=sizes[i] if sizes else int(os.path.getsize(fp) / 1024) if not ismeta else '',
version=versions[i] if versions else '',
format='binary' if ext in ['.GEOTIFF',
'.TIF',
'.TIFF',
'.GTIFF',
'.BSQ',
'.BIL',
'.BIP',
......
......@@ -83,22 +83,39 @@ config_for_testing = dict(
config_for_testing_dlr = dict(
path_l1b_enmap_image=os.path.abspath(
os.path.join(path_enptlib, '..', 'tests', 'data', 'EnMAP_Level_1B',
'ENMAP01-____L1B-DT000000987_20130205T105307Z_001_V000101_20190426T143700Z__'
'rows0-99.zip')),
# Alps
'ENMAP01-____L1B-DT000000987_20130205T105307Z_001_V000101_20190426T143700Z__rows0-99.zip'
# Arcachon
# 'ENMAP01-____L1B-DT000400126_20170218T110115Z_002_V000204_20200206T182719Z__rows700-799.zip'
# Arcachon 1000x30
# 'ENMAP01-____L1B-DT000400126_20170218T110115Z_002_V000204_20200206T182719Z__rows700-730.zip'
)),
path_l1b_enmap_image_gapfill=os.path.abspath(
os.path.join(path_enptlib, '..', 'tests', 'data', 'EnMAP_Level_1B',
'ENMAP01-____L1B-DT000000987_20130205T105307Z_001_V000101_20190426T143700Z__'
'rows100-199.zip')),
# Alps
'ENMAP01-____L1B-DT000000987_20130205T105307Z_001_V000101_20190426T143700Z__rows100-199.zip'
# Arcachon
# 'ENMAP01-____L1B-DT000400126_20170218T110115Z_002_V000204_20200206T182719Z__rows800-899.zip'
)),
path_dem=os.path.abspath(
os.path.join(path_enptlib, '..', 'tests', 'data', 'DLR_L2A_DEM_UTM32.bsq')),
os.path.join(path_enptlib, '..', 'tests', 'data',
# Alps
'DLR_L2A_DEM_UTM32.bsq'
# Arcachon
# 'ENMAP01-____L1B-DT000400126_20170218T110115Z_002_V000204_20200206T182719Z__DEM_ASTER.bsq'
)),
log_level='DEBUG',
output_dir=os.path.join(path_enptlib, '..', 'tests', 'data', 'test_outputs'),
n_lines_to_append=50,
disable_progress_bars=True,
disable_progress_bars=False,
is_dummy_dataformat=False,
enable_ac=True,
enable_ice_retrieval=False,
CPUs=32,
CPUs=1,
ortho_resampAlg='gauss',
)
......
......@@ -51,6 +51,7 @@ class DEM_Processor(object):
self.enmapIm_cornerCoords = enmapIm_cornerCoords
self.CPUs = CPUs or cpu_count()
self._set_nodata_if_not_provided()
self._validate_input()
def _validate_input(self):
......@@ -81,6 +82,11 @@ class DEM_Processor(object):
'cover it completely. The minimal needed extent in the provided projection is: \n'
'xmin: %s, xmax: %s, ymin: %s, ymax: %s.' % (overlap_perc, xmin, xmax, ymin, ymax))
def _set_nodata_if_not_provided(self):
# noinspection PyProtectedMember
if self.dem._nodata is None:
self.dem.nodata = -9999
def fill_gaps(self):
pass
......
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