Exemplo n.º 1
0
def process_handler(config_file, rows, cols):
    """
    Time series and linear rate computation.
    """
    config_file = os.path.abspath(config_file)
    _, dest_paths, params = cf.get_ifg_paths(config_file, step=PROCESS)
    process.process_ifgs(sorted(dest_paths), params, rows, cols)
Exemplo n.º 2
0
def merge_handler(config_file, rows, cols):
    """
    Reassemble computed tiles and save as geotiffs.
    """
    config_file = os.path.abspath(config_file)
    _, _, params = cf.get_ifg_paths(config_file, step=MERGE)
    merge.main(params, rows, cols)
Exemplo n.º 3
0
    def setUpClass(cls):
        # read in the params
        _, _, params = cf.get_ifg_paths(TEST_CONF_GAMMA)
        glob_prefix = "*utm_unw_1rlks_1cr.tif"

        # SERIAL
        cls.serial_dir = tempfile.mkdtemp()
        params[cf.OUT_DIR] = cls.serial_dir
        params[cf.PARALLEL] = False
        shared.mkdir_p(cls.serial_dir)

        gtif_paths = conv2tif.main(params)
        prepifg.main(params)

        serial_df = glob.glob(os.path.join(cls.serial_dir, glob_prefix))
        cls.serial_ifgs = small_data_setup(datafiles=serial_df)

        # Clean up serial converted tifs so we can test parallel conversion
        common.remove_tifs(SML_TEST_GAMMA)

        # PARALLEL
        cls.parallel_dir = tempfile.mkdtemp()
        params[cf.OUT_DIR] = cls.parallel_dir
        params[cf.PARALLEL] = True
        shared.mkdir_p(cls.parallel_dir)

        gtif_paths = conv2tif.main(params)
        prepifg.main(params)

        para_df = glob.glob(os.path.join(cls.parallel_dir, glob_prefix))
        cls.para_ifgs = small_data_setup(datafiles=para_df)
Exemplo n.º 4
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],
                                               params[cf.OBS_DIR])

    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])

    if params[cf.DEM_FILE] is not None:  # optional DEM conversion
        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])

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

    process_base_ifgs_paths = np.array_split(base_ifg_paths,
                                             mpiops.size)[mpiops.rank]
    gtiff_paths = [
        shared.output_tiff_filename(f, params[cf.OBS_DIR])
        for f in process_base_ifgs_paths
    ]
    do_prepifg(gtiff_paths, params)
    log.info("Finished prepifg")
Exemplo n.º 5
0
    def check_gamma(self, conf_file):
        data_paths = glob.glob(
            os.path.join(self.SMLNEY_GAMMA_TEST, "*_utm.unw"))

        self.make_gamma_input_files(data_paths)
        sys.argv = ['pyrate', 'prepifg', conf_file]

        base_ifg_paths, dest_paths, params = cf.get_ifg_paths(conf_file)
        dest_base_ifgs = [
            os.path.join(
                params[cf.OBS_DIR],
                os.path.basename(q).split('.')[0] + '_' +
                os.path.basename(q).split('.')[1] + '.tif')
            for q in base_ifg_paths
        ]
        sys.argv = ['pyrate', 'conv2tif', conf_file]
        conv2tif.main()
        sys.argv = ['pyrate', 'prepifg', conf_file]
        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))