Ejemplo n.º 1
0
def calculate_stack_rate(ifgs, params, vcmt, mst_mat=None):
    # log.info('Calculating stacked rate')
    res = stack.stack_rate_array(ifgs, params, vcmt, mst_mat)
    for r in res:
        if r is None:
            raise ValueError('TODO: bad value')

    r, e, samples = res
    rate, error = stack.mask_rate(r, e, params['maxsig'])
    write_stackrate_tifs(ifgs, params, res)
    # log.info('Stacked rate calculated')
    return rate, error, samples
Ejemplo n.º 2
0
def _merge_stack(params: dict) -> None:
    """
    Merge stacking outputs
    """
    shape, tiles, ifgs_dict = __merge_setup(params)

    log.info('Merging and writing Stack Rate product geotiffs')

    # read and assemble tile outputs
    rate = assemble_tiles(shape,
                          params[C.TMPDIR],
                          tiles,
                          out_type='stack_rate')
    error = assemble_tiles(shape,
                           params[C.TMPDIR],
                           tiles,
                           out_type='stack_error')
    samples = assemble_tiles(shape,
                             params[C.TMPDIR],
                             tiles,
                             out_type='stack_samples')

    # mask pixels according to threshold
    if params[C.LR_MAXSIG] > 0:
        log.info(
            f"Masking stack_rate and stack_error maps where error is greater than {params[C.LR_MAXSIG]} millimetres"
        )
        rate, error = stack.mask_rate(rate, error, params[C.LR_MAXSIG])
    else:
        log.info('Skipping stack product masking (maxsig = 0)')

    # save geotiff and numpy array files
    for out, ot in zip([rate, error, samples],
                       ['stack_rate', 'stack_error', 'stack_samples']):
        __save_merged_files(ifgs_dict,
                            params,
                            out,
                            ot,
                            savenpy=params["savenpy"])
Ejemplo n.º 3
0
def _merge_stack(rows, cols, params):
    """
    Merge stacking outputs
    """
    shape, tiles, ifgs_dict = _merge_setup(rows, cols, params)

    log.info('Merging and writing Stack Rate product geotiffs')

    # read and assemble tile outputs
    rate = assemble_tiles(shape,
                          params[cf.TMPDIR],
                          tiles,
                          out_type='stack_rate')
    error = assemble_tiles(shape,
                           params[cf.TMPDIR],
                           tiles,
                           out_type='stack_error')
    samples = assemble_tiles(shape,
                             params[cf.TMPDIR],
                             tiles,
                             out_type='stack_samples')

    # mask pixels according to threshold
    if params[cf.LR_MAXSIG] > 0:
        rate, error = stack.mask_rate(rate, error, params[cf.LR_MAXSIG])
    else:
        log.info('Skipping stack product masking (maxsig = 0)')

    # save geotiff and numpy array files
    for out, ot in zip([rate, error, samples],
                       ['stack_rate', 'stack_error', 'stack_samples']):
        _save_merged_files(ifgs_dict,
                           params[cf.OUT_DIR],
                           out,
                           ot,
                           savenpy=params["savenpy"])
Ejemplo n.º 4
0
 def test_mask_rate_maxsig3(self):
     # No values masked in rate or error
     rate, error = mask_rate(self.r, self.e, 3)
     assert_array_equal(rate, self.r)
     assert_array_equal(error, self.e)
Ejemplo n.º 5
0
 def test_mask_rate_maxsig2(self):
     # one rate and one error masked
     rate, error = mask_rate(self.r, self.e, 2)
     assert_array_equal(rate, array([5.0, nan]))
     assert_array_equal(error, array([1.1, nan]))
Ejemplo n.º 6
0
 def test_mask_rate_maxsig1(self):
     # both rate and error values masked
     rate, error = mask_rate(self.r, self.e, 1)
     assert_array_equal(rate, array([nan, nan]))
     assert_array_equal(error, array([nan, nan]))