Commit 3af6f375 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Merge branch 'enhancement/make_guiready' into 'master'

Make code ready to work with GUI.

See merge request !55
parents eb9e6cf1 25414fe3
Pipeline #24080 passed with stages
in 29 minutes and 40 seconds
......@@ -8,6 +8,7 @@ History
* Added documentation for pixel value 3 of land/water mask (#73).
* 'make lint' now directly prints errors instead of only logging them to logfiles.
* EnPTConfig and EnPT_Controller are now importable directly from the top level of EnPT.
* Replaced entry point 'enpt-cli.py' with 'enpt' which allows to call the argument parser with 'enpt <args>'.
0.17.2 (2021-03-04)
......
......@@ -31,6 +31,7 @@
"""EnPT console argument parser."""
import argparse
import sys
from enpt import __version__
from enpt.options.config import EnPTConfig
......@@ -40,16 +41,16 @@ __author__ = 'Daniel Scheffler'
def get_enpt_argparser():
"""Return argument parser for enpt_cli.py program."""
"""Return argument parser for the 'enpt' program."""
##########################################################
# CONFIGURE MAIN PARSER FOR THE EnPT PREPROCESSING CHAIN #
##########################################################
parser = argparse.ArgumentParser(
prog='enpt_cli.py',
prog='enpt',
description='=' * 70 + '\n' + 'EnMAP Processing Tool console argument parser. ',
epilog="use '>>> enpt_cli.py -h' for detailed documentation and usage hints.")
epilog="use '>>> enpt -h' for detailed documentation and usage hints.")
add = parser.add_argument
add('--version', action='version', version=__version__)
......@@ -197,8 +198,23 @@ def _str2bool(v):
raise argparse.ArgumentTypeError('Boolean value expected.')
if __name__ == '__main__':
parsed_args = get_enpt_argparser().parse_args()
def main(parsed_args: argparse.Namespace = None) -> int:
"""Run the argument parser and forward the arguments to the linked functions.
:param parsed_args: argparse.Namespace instance of already parsed arguments
(allows to call main() from test_cli_parser.py while passing specific arguments)
:return: exitcode (0: all fine, >=1: failed)
"""
if not parsed_args:
parsed_args = get_enpt_argparser().parse_args() # type: argparse.Namespace
parsed_args.func(get_config(parsed_args))
print('\nready.')
return 0
if __name__ == '__main__':
sys.exit(main()) # pragma: no cover
......@@ -119,15 +119,15 @@ Note, that the processors are built on each other, so the order must be unchange
Command line utilities
**********************
enpt_cli.py
-----------
enpt
----
At the command line, EnPT provides the **enpt_cli.py** command:
At the command line, EnPT provides the **enpt** command:
.. argparse::
:filename: ./../bin/enpt_cli.py
:func: get_enpt_argparser
:prog: enpt_cli.py
:prog: enpt
----
......
......@@ -76,6 +76,7 @@ config_for_testing = dict(
disable_progress_bars=True,
is_dummy_dataformat=True,
enable_ac=False,
ortho_resampAlg='bilinear',
CPUs=16
)
......@@ -348,11 +349,12 @@ class EnPTConfig(object):
EnPTValidator(allow_unknown=True, schema=enpt_schema_config_output).validate(self.to_dict())
# check if given paths point to existing files
paths = {k: v for k, v in self.__dict__.items() if k.startswith('path_')}
for k, fp in paths.items():
if fp and not os.path.isfile(fp):
raise FileNotFoundError("The file path provided at the '%s' parameter does not point to an existing "
"file (%s)." % (k, fp))
if os.getenv('IS_ENPT_GUI_TEST') != "1":
paths = {k: v for k, v in self.__dict__.items() if k.startswith('path_')}
for k, fp in paths.items():
if fp and not os.path.isfile(fp):
raise FileNotFoundError("The file path provided at the '%s' parameter does not point "
"to an existing file (%s)." % (k, fp))
if not self.path_dem:
warnings.warn('No digital elevation model provided. Note that this may cause uncertainties, e.g., '
......
......@@ -59,7 +59,8 @@
},
"smile": {
"run_processor": false
/*FIXME currently not implemented*/
"run_processor": false /*Smile detection and correction (provider smile coefficients are ignored)*/
},
"dead_pixel": {
......@@ -74,7 +75,7 @@
},
"orthorectification": {
"resamp_alg": "bilinear", /*Ortho-rectification resampling algorithm ('nearest', 'bilinear', 'gauss')*/
"resamp_alg": "gauss", /*Ortho-rectification resampling algorithm ('nearest', 'bilinear', 'gauss')*/
"vswir_overlap_algorithm": "swir_only", /*Algorithm how to output the spectral bands in the VNIR/SWIR spectral overlap region
'order_by_wvl': keep spectral bands unchanged, order bands by wavelength
'average': average the spectral information within the overlap
......@@ -84,7 +85,7 @@
"target_projection_type": "UTM", /*projection type of the raster output files (default: 'UTM')
('UTM': Universal Transverse Mercator, 'Geographic': Longitude/Latitude)*/
"target_epsg": "None", /*custom EPSG code of the target projection (overrides target_projection_type)*/
"target_coord_grid": "None" /*custom target coordinate grid where is output is resampled to
"target_coord_grid": "None" /*custom target coordinate grid to which the output is resampled
([x0, x1, y0, y1], e.g., [0, 30, 0, 30])*/
}
}
......
......@@ -85,6 +85,11 @@ setup(
'Programming Language :: Python :: 3.9',
],
description="EnMAP Processing Tool",
entry_points={
'console_scripts': [
'enpt=bin.enpt_cli:main',
],
},
extras_require={
"doc": req_doc,
"test": req_test,
......@@ -102,7 +107,6 @@ setup(
# otherwise they are not included in the PyPi upload content
package_data={"enpt": ["resources/**/**/*"]},
packages=find_packages(exclude=['tests*', 'examples*']), # does not seems to work, therefore use MANIFEST.in
scripts=['bin/enpt_cli.py'],
setup_requires=req_setup,
test_suite='tests',
tests_require=req_test,
......
......@@ -4,7 +4,7 @@ channels: &id1
- conda-forge
dependencies:
- python=3.*.*
- python>=3.7.*
- pip # avoids that conda uses the wrong pip
- enpt
- matplotlib
......@@ -12,7 +12,7 @@ dependencies:
- numba
- numpy
- pyopengl
- qgis
- qgis>=3.16
- scikit-learn
- pip:
......
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