Esempio n. 1
0
def test_process_treats_prepif_outputs_readonly(gamma_conf, tempdir, coh_mask):
    from pyrate.configuration import Configuration
    tdir = Path(tempdir())
    params = common.manipulate_test_conf(gamma_conf, tdir)
    params[cf.COH_MASK] = coh_mask
    params[cf.PARALLEL] = 0
    output_conf = tdir.joinpath('conf.cfg')
    pyrate.configuration.write_config_file(params=params,
                                           output_conf_file=output_conf)
    params = Configuration(output_conf).__dict__
    conv2tif.main(params)
    tifs = list(Path(params[cf.OUT_DIR]).glob('*_unw.tif'))
    assert len(tifs) == 17

    if params[cf.COH_FILE_LIST] is not None:
        coh_tifs = list(Path(params[cf.OUT_DIR]).glob('*_cc.tif'))
        assert len(coh_tifs) == 17

    params = Configuration(output_conf).__dict__
    prepifg.main(params)
    cropped_coh = list(Path(params[cf.OUT_DIR]).glob('*_coh.tif'))
    cropped_ifgs = list(Path(params[cf.OUT_DIR]).glob('*_ifg.tif'))
    dem_ifgs = list(Path(params[cf.OUT_DIR]).glob('*_dem.tif'))

    if params[cf.COH_FILE_LIST] is not None:  # 17 + 1 dem + 17 coh files
        assert len(cropped_coh) + len(cropped_ifgs) + len(dem_ifgs) == 35
    else:  # 17 + 1 dem
        assert len(cropped_coh) + len(cropped_ifgs) + len(dem_ifgs) == 18
    # check all tifs from conv2tif are still readonly
    for t in tifs:
        assert t.stat().st_mode == 33060

    # check all prepifg outputs are readonly
    for c in cropped_coh + cropped_ifgs:
        assert c.stat().st_mode == 33060

    params = Configuration(output_conf).__dict__
    correct.main(params)

    # check all after correct steps multilooked files are still readonly
    for c in cropped_coh + cropped_ifgs + dem_ifgs:
        assert c.stat().st_mode == 33060
    shutil.rmtree(params[cf.OUT_DIR])
Esempio n. 2
0
#   See the License for the specific language governing permissions and
#   limitations under the License.
"""
This script creates the pycallgraph file output_file='pyrate_with_roipac.png'.
This script can be run from the 'PyRate' directory.
Change the name of the config file as required.
"""

import sys
from pycallgraph import PyCallGraph
from pycallgraph import Config
from pycallgraph import GlobbingFilter
from pycallgraph.output import GraphvizOutput
from pyrate import correct

config = Config()
config.trace_filter = GlobbingFilter(exclude=[
    'pycallgraph.*',
    '*.secret_function',
])

graphviz = GraphvizOutput(output_file='pyrate_with_roipac.png')
config = Config(max_depth=6, groups=False, threaded=True)

# sys.argv[0]: name of this script
# sys.argv[1]: name of the config file
sys.argv = ['pyrate_profile.py', 'pyrate.conf']

with PyCallGraph(output=graphviz, config=config):
    correct.main()
Esempio n. 3
0
def main():
    start_time = time.time()

    parser = argparse.ArgumentParser(prog='pyrate', description=CLI_DESCRIPTION, add_help=True,
                                     formatter_class=RawTextHelpFormatter)
    parser.add_argument('-v', '--verbosity', type=str, default='INFO', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR'],
                        help="Increase output verbosity")

    subparsers = parser.add_subparsers(dest='command')
    subparsers.required = True

    parser_conv2tif = subparsers.add_parser('conv2tif', help='<Optional> Convert interferograms to geotiff.',
                                            add_help=True)

    parser_prepifg = subparsers.add_parser(
        'prepifg', help='Perform multilooking, cropping and coherence masking to interferogram geotiffs.',
        add_help=True)

    parser_correct = subparsers.add_parser(
        'correct', help='Calculate and apply corrections to interferogram phase data.',
        add_help=True)

    parser_ts = subparsers.add_parser(
        'timeseries', help='<Optional> Timeseries inversion of interferogram phase data.', add_help=True
    )

    parser_stack = subparsers.add_parser('stack', help='<Optional> Stacking of interferogram phase data.',
                                         add_help=True)

    parser_merge = subparsers.add_parser(
        'merge', help="Reassemble computed tiles and save as geotiffs.",
        add_help=True)

    parser_workflow = subparsers.add_parser(
        'workflow', help="<Optional> Sequentially run all the PyRate processing steps.",
        add_help=True)
    for p in [parser_conv2tif, parser_prepifg, parser_correct, parser_merge, parser_ts, parser_stack, parser_workflow]:
        p.add_argument('-f', '--config_file', action="store", type=str, default=None,
                       help="Pass configuration file", required=False)

    args = parser.parse_args()

    params = mpiops.run_once(_params_from_conf, args.config_file)

    configure_stage_log(args.verbosity, args.command, Path(params[C.OUT_DIR]).joinpath('pyrate.log.').as_posix())

    log.debug("Starting PyRate")
    log.debug("Arguments supplied at command line: ")
    log.debug(args)

    if args.verbosity:
        log.setLevel(args.verbosity)
        log.info("Verbosity set to " + str(args.verbosity) + ".")

    if args.command == "conv2tif":
        conv2tif.main(params)

    if args.command == "prepifg":
        prepifg.main(params)

    if args.command == "correct":
        config_file = os.path.abspath(args.config_file)
        config = Configuration(config_file)
        correct.main(config)

    if args.command == "timeseries":
        config_file = os.path.abspath(args.config_file)
        config = Configuration(config_file)
        timeseries(config)

    if args.command == "stack":
        config_file = os.path.abspath(args.config_file)
        config = Configuration(config_file)
        stack(config)

    if args.command == "merge":
        merge.main(params)

    if args.command == "workflow":
        log.info("***********CONV2TIF**************")
        conv2tif.main(params)

        log.info("***********PREPIFG**************")
        params = mpiops.run_once(_params_from_conf, args.config_file)
        prepifg.main(params)

        log.info("***********CORRECT**************")
        # reset params as prepifg modifies params
        config_file = os.path.abspath(args.config_file)
        config = Configuration(config_file)
        correct.main(config)

        log.info("***********TIMESERIES**************")
        config = Configuration(config_file)
        timeseries(config)

        log.info("***********STACK**************")
        config = Configuration(config_file)
        stack(config)

        log.info("***********MERGE**************")
        params = mpiops.run_once(_params_from_conf, args.config_file)
        merge.main(params)

    log.info("--- Runtime = %s seconds ---" % (time.time() - start_time))