Example #1
0
def linrate(config_file, rows, cols):
    """
    Main PyRate workflow including time series and linear rate computation
    """
    config_file = os.path.abspath(config_file)
    _, dest_paths, params = cf.get_ifg_paths(config_file)
    log.info('This job was run with the following parameters:')
    log.info(json.dumps(params, indent=4, sort_keys=True))
    run_pyrate.process_ifgs(sorted(dest_paths), params, rows, cols)
Example #2
0
def main(params=None):
    """
    xxxx
    
    :param params: Parameters dictionary read in from the config file
    
    :return xxxx
    """
    # TODO: looks like base_ifg_paths are ordered according to ifg list
    # This probably won't be a problem because input list won't be reordered
    # and the original gamma generated list is ordered) this may not affect
    # the important pyrate stuff anyway, but might affect gen_thumbs.py.
    # Going to assume base_ifg_paths is ordered correcly

    usage = 'Usage: pyrate prepifg <config_file>'
    if mpiops.size > 1:  # Over-ride input options if this is an MPI job
        params[cf.LUIGI] = False
        params[cf.PARALLEL] = False

    if params:
        base_ifg_paths = cf.original_ifg_paths(params[cf.IFG_FILE_LIST])
        use_luigi = params[cf.LUIGI]  # luigi or no luigi
        if use_luigi:
            raise cf.ConfigException('params can not be provided with luigi')
    else:  # if params not provided read from config file
        if (not params) and (len(sys.argv) < 3):
            print(usage)
            return
        base_ifg_paths, _, params = cf.get_ifg_paths(sys.argv[2])
        use_luigi = params[cf.LUIGI]  # luigi or no luigi
        raw_config_file = sys.argv[2]

    base_ifg_paths.append(params[cf.DEM_FILE])
    processor = params[cf.PROCESSOR]  # roipac or gamma
    if processor == GAMMA:  # Incidence/elevation only supported for GAMMA
        if params[cf.APS_INCIDENCE_MAP]:
            base_ifg_paths.append(params[cf.APS_INCIDENCE_MAP])
        if params[cf.APS_ELEVATION_MAP]:
            base_ifg_paths.append(params[cf.APS_ELEVATION_MAP])

    if use_luigi:
        log.info("Running prepifg using luigi")
        luigi.configuration.LuigiConfigParser.add_config_path(
            pythonify_config(raw_config_file))
        luigi.build([PrepareInterferograms()], local_scheduler=True)
    else:
        process_base_ifgs_paths = \
            np.array_split(base_ifg_paths, mpiops.size)[mpiops.rank]
        if processor == ROIPAC:
            roipac_prepifg(process_base_ifgs_paths, params)
        elif processor == GAMMA:
            gamma_prepifg(process_base_ifgs_paths, params)
        else:
            raise prepifg.PreprocessError('Processor must be ROI_PAC (0) or '
                                          'GAMMA (1)')
    log.info("Finished prepifg")
Example #3
0
def main(config_file, rows, cols):
    """
    PyRate post-processing main function. Assembles product tiles in to
    single geotiff files
    """
    # setup paths
    _, _, params = cf.get_ifg_paths(config_file)
    _postprocess_linrate(rows, cols, params)
    if params[cf.TIME_SERIES_CAL]:
        _postprocess_timeseries(rows, cols, params)
Example #4
0
def main(config_file, rows, cols):
    """ 
    Post-processing main function.
    
    :param config_file: xxxxx
    :param rows: xxxx
    :param cols: xxxx
    """
    # setup paths
    _, _, params = cf.get_ifg_paths(config_file)
    postprocess_linrate(rows, cols, params)
    if params[cf.TIME_SERIES_CAL]:
        postprocess_timeseries(rows, cols, params)
Example #5
0
def main(params=None):
    """
    Main workflow function for preparing interferograms for PyRate.

    :param dict params: Parameters dictionary read in from the config file
    """
    # TODO: looks like base_ifg_paths are ordered according to ifg list
    # This probably won't be a problem because input list won't be reordered
    # and the original gamma generated list is ordered) this may not affect
    # the important pyrate stuff anyway, but might affect gen_thumbs.py.
    # Going to assume base_ifg_paths is ordered correcly
    # pylint: disable=too-many-branches

    usage = 'Usage: pyrate prepifg <config_file>'
    if mpiops.size > 1:  # Over-ride input options if this is an MPI job
        params[cf.PARALLEL] = False

    if params:
        base_ifg_paths = cf.original_ifg_paths(params[cf.IFG_FILE_LIST])
    else:
        # if params not provided read from config file
        if (not params) and (len(sys.argv) < 3):
            print(usage)
            return
        base_ifg_paths, _, params = cf.get_ifg_paths(sys.argv[2])

    base_ifg_paths.append(params[cf.DEM_FILE])
    processor = params[cf.PROCESSOR]  # roipac or gamma
    if processor == GAMMA:  # Incidence/elevation only supported for GAMMA
        if params[cf.APS_INCIDENCE_MAP]:
            base_ifg_paths.append(params[cf.APS_INCIDENCE_MAP])
        if params[cf.APS_ELEVATION_MAP]:
            base_ifg_paths.append(params[cf.APS_ELEVATION_MAP])

    mkdir_p(params[cf.OUT_DIR])  # create output dir

    process_base_ifgs_paths = np.array_split(base_ifg_paths,
                                             mpiops.size)[mpiops.rank]
    if processor == ROIPAC:
        roipac_prepifg(process_base_ifgs_paths, params)
    elif processor == GAMMA:
        gamma_prepifg(process_base_ifgs_paths, params)
    else:
        raise prepifg.PreprocessError(
            'Processor must be ROI_PAC (0) or GAMMA (1)')
    log.info("Finished prepifg")
Example #6
0
    def setUpClass(cls):

        cls.serial_dir = tempfile.mkdtemp()
        cls.parallel_dir = tempfile.mkdtemp()
        unw_paths = glob.glob(os.path.join(SML_TEST_GAMMA, "*_utm.unw"))

        # read in the params
        _, _, params = cf.get_ifg_paths(TEST_CONF_GAMMA)
        params[cf.OUT_DIR] = cls.serial_dir
        params[cf.PARALLEL] = False

        shared.mkdir_p(cls.serial_dir)
        run_prepifg.gamma_prepifg(unw_paths, params)

        params[cf.OUT_DIR] = cls.parallel_dir
        params[cf.PARALLEL] = True
        shared.mkdir_p(cls.parallel_dir)
        run_prepifg.gamma_prepifg(unw_paths, params)
Example #7
0
    def common_check(self, conf_file):
        data_paths = glob.glob(os.path.join(SML_TEST_GAMMA, "*_utm.unw"))

        self.make_input_files(data_paths)

        base_ifg_paths, dest_paths, params = cf.get_ifg_paths(conf_file)
        dest_base_ifgs = [
            os.path.join(
                params[cf.OUT_DIR],
                os.path.basename(q).split('.')[0] + '_' +
                os.path.basename(q).split('.')[1] + '.tif')
            for q in base_ifg_paths
        ]
        sys.argv = ['pyrate', 'prepifg', conf_file]
        run_prepifg.main()

        for p, q in zip(dest_base_ifgs, dest_paths):
            self.assertTrue(os.path.exists(p), '{} does not exist'.format(p))
            self.assertTrue(os.path.exists(q), '{} does not exist'.format(q))
Example #8
0
def main(config_file, rows, cols):  # pragma: no cover
    """Linear rate and timeseries execution starts here"""
    _, dest_paths, pars = cf.get_ifg_paths(config_file)
    process_ifgs(sorted(dest_paths), pars, rows, cols)