Skip to content

Commit

Permalink
Merge 6d1cb75 into c302f9f
Browse files Browse the repository at this point in the history
  • Loading branch information
johntruckenbrodt committed Jan 28, 2019
2 parents c302f9f + 6d1cb75 commit 8bb4766
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 80 deletions.
3 changes: 2 additions & 1 deletion docs/pyroSAR.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GAMMA Processing
================

.. automodule:: pyroSAR.gamma
:members: geocode, convert2gamma, ISPPar, process, ovs, S1_deburst, correctOSV, multilook
:members: geocode, convert2gamma, ISPPar, process, ovs, S1_deburst, correctOSV, multilook, par2hdr
:undoc-members:
:show-inheritance:

Expand All @@ -58,6 +58,7 @@ GAMMA Processing
ovs
process
S1_deburst
par2hdr

SRTM tools
----------
Expand Down
29 changes: 26 additions & 3 deletions pyroSAR/gamma/auxil.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def envidict(self, nodata=None):
return out


def par2hdr(parfile, hdrfile, nodata=None):
def par2hdr(parfile, hdrfile, modifications=None, nodata=None):
"""
Create an ENVI HDR file from a Gamma PAR file
Expand All @@ -181,15 +181,32 @@ def par2hdr(parfile, hdrfile, nodata=None):
the Gamma parfile
hdrfile: str
the ENVI HDR file
modifications: dict or None
a dictionary containing value deviations to write to the HDR file
nodata: str or None
a no data value to write to the HDR file via attribute 'data ignore value'
Returns
-------
Examples
--------
>>> from pyroSAR.gamma.auxil import par2hdr
>>> par2hdr('dem_seg.par', 'inc.hdr')
# write a HDR file for byte data based on a parfile of float data
>>> par2hdr('dem_seg.par', 'ls_map.hdr', modifications={'data_type': 1})
See Also
--------
:class:`spatialist.envi.HDRobject`
:func:`spatialist.envi.hdr`
"""

with ISPPar(parfile) as par:
hdr(par.envidict(nodata), hdrfile)
items = par.envidict(nodata)
if modifications is not None:
items.update(modifications)
hdr(items, hdrfile)


class UTM(object):
Expand Down Expand Up @@ -296,6 +313,9 @@ def __init__(self, directory, basename):
self.__outdir = directory
self.__reg = []

def __getitem__(self, item):
return getattr(self, item.replace('.', '_'))

def appreciate(self, keys):
for key in keys:
setattr(self, key.replace('.', '_'), os.path.join(self.__outdir, self.__base + '_' + key))
Expand Down Expand Up @@ -326,6 +346,9 @@ def isappreciated(self, key):
return True
return False

def isfile(self, key):
return hasattr(self, key) and os.path.isfile(getattr(self, key))

def get(self, key):
return getattr(self, key)

Expand Down
3 changes: 2 additions & 1 deletion pyroSAR/gamma/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def gammaErrorHandler(out, err):
'no OPOD state vector found with the required start time!': RuntimeError,
'gc_map operates only with slant range geometry, image geometry in SLC_par: GROUND_RANGE': RuntimeError,
'OPOD state vector data ends before start of the state vector time window': RuntimeError,
'non-zero exit status': RuntimeError}
'non-zero exit status': RuntimeError,
'unsupported DEM projection': RuntimeError}

# check if the error message is known and throw the mapped error from knownErrors accordingly.
# Otherwise throw an GammaUnknownError.
Expand Down
Loading

0 comments on commit 8bb4766

Please sign in to comment.