<commit_before>#!/usr/bin/env python
##############################################################
# universal core routines for processing SAR images is GAMMA
# <NAME> 2014-2016
##############################################################

"""
This script is intended as a set of generalized processing routines for modularized GAMMA work flows.
The function parametrization is intended to be applicable to any kind of situation and input data set. Thus, instead of choosing a specific parametrization for the data at hand,
core parameters are iterated over a set of values in order to find the one best suited for the task.
The approach of the single routines is likely to still have drawbacks and might fail in certain situations. Testing and suggestions on improvements are very welcome.
"""
import os
import re
import math
import envi
import subprocess as sp
from . import ISPPar, Spacing
from .error import gammaErrorHandler
from ancillary import run, Stack, union
from spatial import haversine
import pyroSAR


def process(cmd, outdir=None, logpath=None, inlist=None):
    log = os.path.join(logpath, cmd[0]+'.log') if logpath else None
    out, err = run(cmd, outdir=outdir, logfile=log, inlist=inlist, void=False)
    gammaErrorHandler(err)


# INPUT FILES:
# -master: master image
# -slave: image coregistered to the master
# -off: diffpar parameter file
# OUTPUT FILES:
# -offs: offset estimates (fcomplex)
# -offsets: range and azimuth offsets and cross-correlation data (text format)
# -ccp: cross-correlation of each patch (0.0->1.0) (float)
# -coffs: culled range and azimuth offset estimates (fcomplex)
# -coffsets: culled offset estimates and cross-correlation values (text format)
# FURTHER INPUT:
# -path_log: directory for created logfiles (e.g. offset_pwr will create file path_log/offset_pwr.log)
# -maxwin: maximum (initial) window size for offset search (will be iteratively divided by 2 until the minwin is reached)<commit_msg>function process: addedd void option added function slc_corners<commit_after>#!/usr/bin/env python
##############################################################
# universal core routines for processing SAR images is GAMMA
# <NAME> 2014-2016
##############################################################

"""
This script is intended as a set of generalized processing routines for modularized GAMMA work flows.
The function parametrization is intended to be applicable to any kind of situation and input data set. Thus, instead of choosing a specific parametrization for the data at hand,
core parameters are iterated over a set of values in order to find the one best suited for the task.
The approach of the single routines is likely to still have drawbacks and might fail in certain situations. Testing and suggestions on improvements are very welcome.
"""
import os
import re
import math
import envi
import subprocess as sp
from . import ISPPar, Spacing
from .error import gammaErrorHandler
from ancillary import run, Stack, union
from spatial import haversine
import pyroSAR


def process(cmd, outdir=None, logpath=None, inlist=None, void=True):
    log = os.path.join(logpath, cmd[0]+'.log') if logpath else None
    out, err = run(cmd, outdir=outdir, logfile=log, inlist=inlist, void=void)
    gammaErrorHandler(err)
    if not void:
        return out, err


def slc_corners(parfile):
    out, err = process(['SLC_corners', parfile], void=False)
    pts = {}
    for line in out.split('\n'):
        if line.startswith('min. latitude'):
            pts['ymin'], pts['ymax'] = [float(x) for x in re.findall('[0-9]+\.[0-9]+', line)]
        elif line.startswith('min. longitude'):
            pts['xmin'], pts['xmax'] = [float(x) for x in re.findall('[0-9]+\.[0-9]+', line)]
    return pts


# INPUT FILES:
# -master: master image
# -slave: image coregistered to the master
# -off: diffpar parameter file
# OUTPUT FILES:
# -offs: offset estimates (fcomplex)
# -offsets: range and azimuth offsets and cross-correlation data (text format)
# -ccp: cross-correlation of each patch (0.0->1.0) (float)
# -coffs: culled range and azimuth offset estimates (fcomplex)
# -coffsets: culled offset estimates and cross-correlation values (text format)
# FURTHER INPUT:
# -path_log: directory for created logfiles (e.g. offset_pwr will create file path_log/offset_pwr.log)
# -maxwin: maximum (initial) window size for offset search (will be iteratively divided by 2 until the minwin is reached)
{'fraction_non_alphanumeric': 0.1380009004952724, 'fraction_numerical': 0.00810445745159838, 'mean_word_length': 4.755181347150259, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1916371', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1215, 'n_words': 535}