enpt package

Subpackages

Submodules

enpt.cli module

EnPT console argument parser.

enpt.cli._str2bool(v)[source]

Convert string parameter to bool.

From: https://stackoverflow.com/a/43357954/2952871

Parameters:

v

Returns:

enpt.cli.get_config(cli_args: Namespace)[source]
enpt.cli.get_enpt_argparser()[source]

Return argument parser for the ‘enpt’ program.

enpt.cli.main(parsed_args: Namespace = None) int[source]

Run the argument parser and forward the arguments to the linked functions.

Parameters:

parsed_args – argparse.Namespace instance of already parsed arguments (allows to call main() from test_cli_parser.py while passing specific arguments)

Returns:

exitcode (0: all fine, >=1: failed)

enpt.cli.parsedArgs_to_user_opts(cli_args: Namespace) dict[source]

Convert argparse Namespace object to dictionary of explicitly given parameters.

NOTE: All options that have not been given explicitly (None values) are removed. Reason: EnPTConfig prefers

directly passed arguments against those that are passed withi a JSON config file. So, e.g., if CPUs=None (default), the ‘CPUs’ parameter given within a JSON config file would be overridden.

=> only override JSON configuration if parameters are explicitly given (e.g., CPUs is set to 10) => if json_opts are given: default options are overridden with the options in the JSON config.

Parameters:

cli_args – options as parsed by the argparse.ArgumentParser

enpt.cli.run_job(config: EnPTConfig)[source]

enpt.version module

Module contents

EnMAP processing tool (EnPT) software package developed by GFZ.

class enpt.EnPTConfig(json_config='', **user_opts)[source]

Bases: object

Create a job configuration.

Parameters:

json_config – path to JSON file containing configuration parameters or a string in JSON format

Key CPUs:

number of CPU cores to be used for processing (default: “None” -> use all available)

Key path_l1b_enmap_image:

input path of the EnMAP L1B image to be processed (zip-archive or root directory; must be given if not contained in –json-config.)

Key path_l1b_enmap_image_gapfill:

input path of an adjacent EnMAP L1B image to be used for gap-filling (zip-archive or root directory)

Key path_dem:

input path of digital elevation model in map or sensor geometry; GDAL compatible file format (must cover the EnMAP L1B data completely if given in map geometry or must have the same pixel dimensions like the EnMAP L1B data if given in sensor geometry)

Key average_elevation:

average elevation in meters above sea level; may be provided if no DEM is available; ignored if DEM is given

Key output_dir:

output directory where processed data and log files are saved

Key output_format:

file format of all raster output files (‘GTiff’: GeoTIFF, ‘ENVI’: ENVI BSQ; default: ‘ENVI’)

Key output_interleave:

raster data interleaving type (default: ‘pixel’)

  • ‘band’: band-sequential (BSQ),

  • ‘line’: data interleaved-by-line (BIL; only usable for ENVI output format),

  • ‘pixel’ data interleaved-by-pixel (BIP)

Key output_nodata_value:

output no-data/background value (should be within the integer 16-bit range, default: -32768)

Key working_dir:

directory to be used for temporary files

Key n_lines_to_append:

number of lines to be added to the main image [if None, use the whole imgap]. Requires ‘path_l1b_enmap_image_gapfill’ to be set.

Key drop_bad_bands:

if set to True (default), the water absorption bands between 1358 and 1453 nm as well as between 1814 and 1961 nm are excluded from processing and will not be contained in the L2A product

Key disable_progress_bars:

whether to disable all progress bars during processing

Key path_earthSunDist:

input path of the earth sun distance model

Key path_solar_irr:

input path of the solar irradiance model

Key scale_factor_toa_ref:

scale factor to be applied to TOA reflectance result

Key enable_keystone_correction:

Enable keystone correction

Key enable_vnir_swir_coreg:

Enable VNIR/SWIR co-registration

Key enable_absolute_coreg:

Enable the co-registration of the EnMAP image to the reference image given with ‘path_reference_image’

Key path_reference_image:

Reference image for co-registration.

Key polymer_root:

Polymer root directory (that contains the subdirectory for ancillary data).

Key enable_ac:

Enable atmospheric correction using SICOR algorithm (default: True). If False, the L2A output contains top-of-atmosphere reflectance.

Key mode_ac:

3 modes to determine which atmospheric correction is applied at which surfaces (default: land):

  • ‘land’: SICOR (developed for land surfaces is applied to land AND water surfaces

  • ‘water’: POLYMER (developed for water surfaces) is applied to water only

    (land surfaces are no included in the L2A product)

  • ‘combined’: SICOR is applied to land and POLYMER is applied to water surfaces;

    NOTE that this may result in edge effects, e.g., at coastlines

Key polymer_additional_results:

Enable the generation of additional results when running ACwater/POLYMER (default: True)

Key auto_download_ecmwf:

Automatically download ECMWF AUX data when running Polymer atmospheric correction for water surfaces

Key scale_factor_boa_ref:

Scale factor to be applied to BOA reflectance result

Key threads:

number of threads for multiprocessing of blocks (see bellow):

  • ‘threads = 0’: for single thread

  • ‘threads < 0’: for as many threads as there are CPUs

  • ‘threads > 0’: gives the number of threads

Key blocksize:

block size for multiprocessing

Key run_smile_P:

Enable extra smile detection and correction (provider smile coefficients are ignored)

Key run_deadpix_P:

Enable dead pixel correction

Key deadpix_P_algorithm:

Algorithm for dead pixel correction (‘spectral’ or ‘spatial’)

Key deadpix_P_interp_spectral:
Spectral interpolation algorithm to be used during dead pixel correction

(‘linear’, ‘quadratic’, ‘cubic’)

Key deadpix_P_interp_spatial:
Spatial interpolation algorithm to be used during dead pixel correction

(‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’)

Key ortho_resampAlg:
Ortho-rectification resampling algorithm (‘nearest’, ‘bilinear’, ‘gauss’, ‘cubic’, ‘cubic_spline’,

‘lanczos’, ‘average’, ‘mode’, ‘max’, ‘min’, ‘med’, ‘q1’, ‘q3’)

Key target_projection_type:

Projection type of the raster output files (‘UTM’, ‘Geographic’) (default: ‘UTM’)

Key target_epsg:

Custom EPSG code of the target projection (overrides target_projection_type)

Key target_coord_grid:

Custom target coordinate grid where the output is resampled to ([x0, x1, y0, y1], e.g., [0, 30, 0, 30])

static absPath(path)[source]
get_json_opts(validate=True)[source]

Get a dictionary of EnPT config parameters.

NOTE: Reads the default options from options_default.json and updates the values with those from database.

get_parameter(key_user_opts, fallback=None)[source]
save(path_outfile)[source]

Save the JobConfig instance to a JSON file in the same structure like the one in options_default.json.

Parameters:

path_outfile – path of the output JSON file

to_dict()[source]

Generate a dictionary in the same structure like the one in options_default.json from the current config.

to_jsonable_dict()[source]
class enpt.EnPT_Controller(config: EnPTConfig = None, **config_kwargs)[source]

Bases: object

Class of EnPT process controller.

Initialize the Process Controller.

Parameters:
  • config – an instance of the EnPTConfig class (overrides config_kwargs)

  • config_kwargs – configuration parameters to be passed to EnPTConfig class

classmethod _cleanup(tempDir, warn_message)[source]

Clean up implicitly (not to be called directly).

_print_received_configuration()[source]
static _write_to_stdout_stderr()[source]

Write to STDOUT and STDERR to reveal Queue.name of these streams to enpt_enmapboxapp.

cleanup()[source]

Clean up (to be called directly).

extract_zip_archive(path_zipfile: str, subdir: str = '') str[source]

Extract the given EnMAP image zip archive and return the L1B image root directory path.

Parameters:
  • path_zipfile – /path/to/zipfile.zip

  • subdir – subdirectory name to be created within temporary directory

Returns:

/tmp/tmpk2qp0yri/rootdir/

read_L1B_data() None[source]

Read the provider L1B data given in config and return an EnMAP image object.

run_all_processors()[source]

Run all processors at once.

run_atmospheric_correction()[source]

Run atmospheric correction only.

run_dem_processor()[source]
run_orthorectification()[source]

Run orthorectification to transform L1 sensor geometry image to L2 map geometry.

run_spatial_optimization()[source]
run_toaRad2toaRef()[source]

Run conversion from TOA radiance to TOA reflectance.

write_output()[source]