Commit 221103d0 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Added a lot of docstrings.

Updated __version__ and __versionalias__.
parent 68472715
Pipeline #826 passed with stages
in 6 minutes and 11 seconds
......@@ -3,7 +3,7 @@ History
=======
0.2.0 (2017-08-24)
-----------------
------------------
New features:
......@@ -14,6 +14,6 @@ New features:
0.1.0 (2017-05)
------------------
---------------
* Initial development started.
......@@ -13,7 +13,6 @@ Contents:
installation
usage
modules
scripts
contributing
development
authors
......
Scripts
=======
A collection of scripts exists.
test_script_enpt
----------------
.. argparse::
:filename: ./../bin/test_script_enpt.py
:func: get_parser
:prog: test_script_enpt.py
......@@ -3,5 +3,5 @@
__author__ = """Karl Segl"""
__email__ = 'segl@gfz-potsdam.de'
__version__ = '0.2.3'
__versionalias__ = '2017-08-24_04'
__version__ = '0.2.4'
__versionalias__ = '2017-08-24_05'
# -*- coding: utf-8 -*-
"""EnPT module 'execution', containing everything related to the execution and controlling of the processing chain."""
......@@ -6,12 +6,11 @@ from ..processors.radiometric_transform import TOARad2TOARef_Transformer
class EnPT_controller(object):
"""Class of EnPT process controller"""
"""Class of EnPT process controller."""
def __init__(self, entity_ID):
# type: (str) -> None
"""Initialize the Process Controller
"""Initialize the Process Controller.
:param entity_ID: ID of the scene to be processed, e.g. 'EM_20170515_12345'
"""
......
# -*- coding: utf-8 -*-
"""Reader module for reading all kinds of EnMAP images."""
from datetime import datetime
import logging
......@@ -11,13 +12,14 @@ class L1B_Reader(object):
"""Reader for EnMAP Level-1B products."""
def __init__(self, logger=None, **user_inputs):
"""Get an instance of L1B_Reader."""
self.logger = logger or logging.getLogger(__name__)
self.cfg = user_inputs
@staticmethod
def read_inputdata(root_dir, observation_time: datetime, lon_lat_smpl=(15, 15), nsmile_coef=4):
# TODO move to init?
"""Read L1B, DEM and spatial reference data
"""Read L1B, DEM and spatial reference data.
:param root_dir: Root directory of EnMAP Level-1B product
:param observation_time: datetime of observation time (currently missing in metadata)
......@@ -54,7 +56,9 @@ class L1B_Reader(object):
return L1_obj
def validate_input(self):
"""Validate user inputs."""
pass
def validate_output(self):
"""Validate outputs of L1B_Reader."""
pass
# -*- coding: utf-8 -*-
"""EnPT module 'model', containing all kinds of data models."""
# -*- coding: utf-8 -*-
"""EnPT images module. All EnMAP image objects are defined here."""
import logging
from types import SimpleNamespace
......@@ -63,7 +64,7 @@ class _EnMAP_Image(object):
@property
def logger(self):
"""Get a an instance of enpt.utils.logging.EnPT_Logger!
"""Get a an instance of enpt.utils.logging.EnPT_Logger.
NOTE:
- The logging level will be set according to the user inputs of EnPT.
......@@ -99,10 +100,10 @@ class _EnMAP_Image(object):
@property # FIXME does not work yet
def log(self):
"""Returns a string of all logged messages until now.
NOTE: self.log can also be set to a string."""
"""Return a string of all logged messages until now.
NOTE: self.log can also be set to a string.
"""
return self._log
@log.setter
......@@ -112,8 +113,9 @@ class _EnMAP_Image(object):
@property
def data(self):
"""Returns an instance of geoarray.GeoArray representing the actual EnMAP image data, bundled with all the
corresponding metadata:
"""Return the actual EnMAP image data.
Bundled with all the corresponding metadata.
Attributes and functions (most important; for a full list check help(self.data)!):
- ALL attributes of numpy.ndarray!
......@@ -174,8 +176,9 @@ class _EnMAP_Image(object):
@property
def mask_nodata(self):
"""Returns an instance of geoarray.NoDataMask representing the no data mask, bundled with all the
corresponding metadata.
"""Return the no data mask.
Bundled with all the corresponding metadata.
For usage instructions and a list of attributes refer to help(self.data).
self.mask_nodata works in the same way.
......@@ -208,8 +211,9 @@ class _EnMAP_Image(object):
@property
def mask_clouds(self):
"""Returns an instance of geoarray.CloudMask representing the cloud mask, bundled with all the
corresponding metadata.
"""Return the cloud mask.
Bundled with all the corresponding metadata.
For usage instructions and a list of attributes refer to help(self.data).
self.mask_clouds works in the same way.
......@@ -238,8 +242,9 @@ class _EnMAP_Image(object):
@property
def mask_clouds_confidence(self):
"""Returns an instance of geoarray.GeoArray representing pixelwise information on the cloud mask confidence,
bundled with all the corresponding metadata.
"""Return pixelwise information on the cloud mask confidence.
Bundled with all the corresponding metadata.
For usage instructions and a list of attributes refer to help(self.data).
self.mask_clouds_confidence works in the same way.
......@@ -272,11 +277,10 @@ class _EnMAP_Image(object):
@property
def dem(self):
"""Returns an SRTM DEM in the exact dimension an pixel grid of self.arr as an instance of GeoArray.
"""Return an SRTM DEM in the exact dimension an pixel grid of self.arr.
:return: geoarray.GeoArray
"""
if self._dem is None:
raise NotImplementedError('An automatic DEM getter is not yet implemented.')
return self._dem
......@@ -303,11 +307,10 @@ class _EnMAP_Image(object):
@property
def ac_errors(self):
"""Returns an instance of GeoArray containing error information calculated by the atmospheric correction.
"""Return error information calculated by the atmospheric correction.
:return: geoarray.GeoArray
"""
return self._ac_errors # FIXME should give a warning if None
@ac_errors.setter
......@@ -335,8 +338,9 @@ class _EnMAP_Image(object):
@property
def deadpixelmap(self):
"""Returns an instance of geoarray.GeoArray representing dead pixel map of the _EnMAP_Image instance,
bundled with all the corresponding metadata. Dimensions: (bands x columns).
"""Return the dead pixel map.
Bundled with all the corresponding metadata. Dimensions: (bands x columns).
For usage instructions and a list of attributes refer to help(self.data).
self.mask_clouds_confidence works in the same way.
......@@ -363,13 +367,12 @@ class _EnMAP_Image(object):
self._deadpixelmap = None
def calc_mask_nodata(self, fromBand=None, overwrite=False):
"""Calculates a no data mask with (values: 0=nodata; 1=data)
"""Calculate a no data mask with (values: 0=nodata; 1=data).
:param fromBand: <int> index of the band to be used (if None, all bands are used)
:param overwrite: <bool> whether to overwrite existing nodata mask that has already been calculated
:return:
"""
self.logger.info('Calculating nodata mask...')
if self._mask_nodata is None or overwrite:
......@@ -379,10 +382,10 @@ class _EnMAP_Image(object):
class _EnMAP_Detector_SensorGeo(_EnMAP_Image):
"""Base class representing a single detector of an EnMAP image (as sensor geometry). Inherits all attributes from
_EnMAP_Image class.
"""Base class representing a single detector of an EnMAP image (as sensor geometry).
NOTE:
- Inherits all attributes from _EnMAP_Image class.
- All functionality that VNIR and SWIR detectors (sensor geometry) have in common is to be implemented here.
- All EnMAP image subclasses representing a specific EnMAP detector (sensor geometry) should inherit from
_EnMAP_Detector_SensorGeo.
......@@ -393,7 +396,7 @@ class _EnMAP_Detector_SensorGeo(_EnMAP_Image):
"""
def __init__(self, detector_name: str, root_dir: str, logger=None):
"""Get an instance of _EnMAP_Detector_SensorGeo
"""Get an instance of _EnMAP_Detector_SensorGeo.
:param detector_name: 'VNIR' or 'SWIR'
:param root_dir:
......@@ -431,8 +434,10 @@ class _EnMAP_Detector_SensorGeo(_EnMAP_Image):
return paths
def DN2TOARadiance(self):
"""Convert the radiometric unit of _EnMAP_Detector_SensorGeo.data from digital numbers to top-of-atmosphere
radiance."
"""Convert DNs to TOA radiance.
Convert the radiometric unit of _EnMAP_Detector_SensorGeo.data from digital numbers to top-of-atmosphere
radiance.
:return: None
"""
......@@ -449,10 +454,10 @@ class _EnMAP_Detector_SensorGeo(_EnMAP_Image):
class _EnMAP_Detector_MapGeo(_EnMAP_Image):
"""Base class representing a single detector of an EnMAP image (as map geometry). Inherits all attributes from
_EnMAP_Image class.
"""Base class representing a single detector of an EnMAP image (as map geometry).
NOTE:
- Inherits all attributes from _EnMAP_Image class.
- All functionality that VNIR and SWIR detectors (map geometry) have in common is to be implemented here.
- All EnMAP image subclasses representing a specific EnMAP detector (sensor geometry) should inherit from
_EnMAP_Detector_SensorGeo.
......@@ -461,8 +466,9 @@ class _EnMAP_Detector_MapGeo(_EnMAP_Image):
- to be listed here. Check help(_EnMAP_Detector_SensorGeo) in the meanwhile!
"""
def __init__(self, detector_name: str, logger=None):
"""Get an instance of _EnMAP_Detector_MapGeo
"""Get an instance of _EnMAP_Detector_MapGeo.
:param detector_name: 'VNIR' or 'SWIR'
:param logger:
......@@ -480,6 +486,8 @@ class _EnMAP_Detector_MapGeo(_EnMAP_Image):
class EnMAP_VNIR_SensorGeo(_EnMAP_Detector_SensorGeo):
"""Class for EnPT EnMAP VNIR object in sensor geometry."""
def __init__(self, root_dir: str):
"""Get an instance of the VNIR of an EnMAP data Level-1B product.
......@@ -490,6 +498,8 @@ class EnMAP_VNIR_SensorGeo(_EnMAP_Detector_SensorGeo):
class EnMAP_SWIR_SensorGeo(_EnMAP_Detector_SensorGeo):
"""Class for EnPT EnMAP SWIR object in sensor geometry."""
def __init__(self, root_dir: str):
"""Get an instance of the SWIR of an EnMAP data Level-1B product.
......@@ -500,7 +510,7 @@ class EnMAP_SWIR_SensorGeo(_EnMAP_Detector_SensorGeo):
class EnMAPL1Product_SensorGeo(object):
"""Class for EnPT EnMAP object in sensor geometry
"""Class for EnPT EnMAP object in sensor geometry.
Attributes:
- logger:
......@@ -514,8 +524,10 @@ class EnMAPL1Product_SensorGeo(object):
- meta:
- instance of EnMAP_Metadata_SensorGeo class
- detector_attrNames:
- list of attribute names for VNIR and SWIR detectors
- list of attribute names for VNIR and SWIR detectors,
"""
def __init__(self, root_dir: str, logger=None):
"""Get instance of EnPT EnMAP object in sensor geometry.
......@@ -543,8 +555,7 @@ class EnMAPL1Product_SensorGeo(object):
return paths
def DN2TOARadiance(self):
"""Convert the radiometric unit of self.vnir.data and self.swir.data from digital numbers to top-of-atmosphere
radiance."
"""Convert self.vnir.data and self.swir.data from digital numbers to top-of-atmosphere radiance.
:return: None
"""
......@@ -558,20 +569,24 @@ class EnMAPL1Product_SensorGeo(object):
class EnMAP_VNIR_MapGeo(_EnMAP_Detector_MapGeo):
"""This class represents an EnPT EnMAP VNIR image in map geometry including all metadata and associated aux-data
(masks, DEM, etc.).
"""Class for EnMAP VNIR image in map geometry including all metadata and associated aux-data (masks, DEM, etc.).
All attributes commonly used among different EnMAP images are inherited from the _EnMAP_Detector_MapGeo class.
All VNIR_MapGeo specific modifications are to be implemented here."""
All VNIR_MapGeo specific modifications are to be implemented here.
"""
def __init__(self, logger=None):
"""Get an instance of the VNIR of an EnMAP data Level-1B product (map geometry)."""
super(EnMAP_VNIR_MapGeo, self).__init__('VNIR', logger=logger)
class EnMAP_SWIR_MapGeo(_EnMAP_Detector_MapGeo):
"""This class represents an EnPT EnMAP SWIR image in map geometry including all metadata and associated aux-data
(masks, DEM, etc.).
"""Class for EnMAP SWIR image in map geometry including all metadata and associated aux-data (masks, DEM, etc.).
All attributes commonly used among different EnMAP images are inherited from the _EnMAP_Detector_MapGeo class.
All SWIR_MapGeo specific modifications are to be implemented here."""
All SWIR_MapGeo specific modifications are to be implemented here.
"""
def __init__(self, logger=None):
"""Get an instance of the SWIR of an EnMAP data Level-1B product (map geometry)."""
super(EnMAP_SWIR_MapGeo, self).__init__('SWIR', logger=logger)
......@@ -30,13 +30,13 @@ class _EnMAP_Metadata_Detector_SensorGeo(object):
_EnMAP_Metadata_Detector_SensorGeo.
"""
def __init__(self, detector_name: str, logger: logging.Logger=None):
"""
"""Get a metadata object containing the metadata of a single EnMAP detector in sensor geometry.
:param detector_name: Name of the detector (VNIR or SWIR)
:param logger:
"""
self.detector_name = detector_name # type: str
self.logger = logger or logging.getLogger()
......@@ -108,6 +108,7 @@ class _EnMAP_Metadata_Detector_SensorGeo(object):
def calc_smile(self):
"""Compute smile for each EnMAP column.
The sum in (1) is expressed as inner product of two arrays with inner dimension as the polynomial smile
coefficients shape = (ncols, nsmile_coef) of polynomial x
......@@ -120,7 +121,7 @@ class _EnMAP_Metadata_Detector_SensorGeo(object):
) # shape = (ncols, nwvl)
def calc_snr(self, data: np.ndarray):
"""Compute EnMAP snr from radiance data.
"""Compute EnMAP SNR from radiance data.
:param data: Numpy array with radiance for scene
"""
......@@ -148,15 +149,16 @@ class _EnMAP_Metadata_Detector_SensorGeo(object):
class EnMAP_Metadata_SensorGeo(object):
"""EnMAP Metadata class holding the metadata of the complete EnMAP product in sensor geometry
including VNIR and SWIR detector.
"""EnMAP Metadata class holding the metadata of the complete EnMAP product in sensor geometry incl. VNIR and SWIR.
Attributes:
- logger(logging.Logger): None or logging instance
- observation_datetime(datetime.datetime): datetime of observation time (currently missing in metadata)
- vnir(EnMAP_Metadata_VNIR_SensorGeo)
- swir(EnMAP_Metadata_SWIR_SensorGeo)
"""
def __init__(self, path_metaxml, logger=None):
self.logger = logger or logging.getLogger()
self._path_xml = path_metaxml
......@@ -185,6 +187,7 @@ class EnMAP_Metadata_VNIR_SensorGeo(_EnMAP_Metadata_Detector_SensorGeo):
NOTE:
- inherits all attributes from base class _EnMAP_Metadata_Detector_SensorGeo.
"""
def __init__(self, path_metaxml, logger=None):
# get all attributes from base class '_EnMAP_Metadata_Detector_SensorGeo'
super(EnMAP_Metadata_VNIR_SensorGeo, self).__init__('VNIR', logger=logger)
......@@ -202,6 +205,7 @@ class EnMAP_Metadata_SWIR_SensorGeo(_EnMAP_Metadata_Detector_SensorGeo):
NOTE:
- inherits all attributes from base class _EnMAP_Metadata_Detector_SensorGeo.
"""
def __init__(self, path_metaxml, logger=None):
# get all attributes from base class '_EnMAP_Metadata_Detector_SensorGeo'
super(EnMAP_Metadata_SWIR_SensorGeo, self).__init__('SWIR', logger=logger)
......
# -*- coding: utf-8 -*-
"""EnPT 'processors' module containing all EnPT processor sub-modules."""
# -*- coding: utf-8 -*-
"""EnPT 'atmospheric correction module."""
# -*- coding: utf-8 -*-
"""EnPT 'atmospheric correction module.
"""
performs the atmospheric correction of EnMAP L1B data.
Performs the atmospheric correction of EnMAP L1B data.
"""
# -*- coding: utf-8 -*-
"""EnPT cloud screening module containing everythin related to cloud detection and classification."""
# -*- coding: utf-8 -*-
"""
creates the EnMAP Cloud Mask.
Creates the EnMAP Cloud Mask.
1. Version: reads EnMAP mask or user's mask.
"""
# -*- coding: utf-8 -*-
"""EnPT 'dead pixel correction' module for detecting and correcting dead pixels."""
# -*- coding: utf-8 -*-
"""EnPT 'dead pixel correction' module.
"""
performs the Dead Pixel Correction using a linear interpolation in spectral dimension
Performs the Dead Pixel Correction using a linear interpolation in spectral dimension.
"""
# -*- coding: utf-8 -*-
"""EnPT image correction module."""
# -*- coding: utf-8 -*-
"""
Image Correction
EnPT image correction module.
improves the image quality in case of image striping
......
# -*- coding: utf-8 -*-
"""EnPT 'radiometric transform' module containing eveything related to radiometric transformations."""
from .radiometric_transform import TOARad2TOARef_Transformer
......
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