Пример #1
0
def main(iargs=None):
    inps = cmd_line_parse(iargs)
    if inps.template_file:
        inps = read_template2inps(inps.template_file, inps)

    elif all(not i for i in [
            inps.referenceFile, inps.tempBaseMax, inps.perpBaseMax,
            inps.connNumMax, inps.excludeIfgIndex, inps.excludeDate,
            inps.coherenceBased, inps.startDate, inps.endDate, inps.reset,
            inps.manual
    ]):
        msg = 'No input option found to remove interferogram, exit.\n'
        msg += 'To manually modify network, please use --manual option '
        raise Exception(msg)

    if inps.reset:
        print('--------------------------------------------------')
        reset_network(inps.file)
        return inps.file

    inps.date12_to_drop = get_date12_to_drop(inps)

    if inps.date12_to_drop is not None:
        ifgramStack(inps.file).update_drop_ifgram(
            date12List_to_drop=inps.date12_to_drop)
        print('--------------------------------------------------')
        ut.nonzero_mask(inps.file)
        print('--------------------------------------------------')
        ut.temporal_average(inps.file,
                            datasetName='coherence',
                            updateMode=True)
        # Touch spatial average txt file of coherence if it's existed
        ut.touch(
            os.path.splitext(os.path.basename(inps.file))[0] +
            '_coherence_spatialAvg.txt')

        # Plot result
        if inps.plot:
            print('\nplot modified network and save to file.')
            plotCmd = 'plot_network.py {} --nodisplay'.format(inps.file)
            if inps.template_file:
                plotCmd += ' --template {}'.format(inps.template_file)
            print(plotCmd)
            os.system(plotCmd)
        print('Done.')
    return
Пример #2
0
def main(iargs=None):
    start_time = time.time()
    inps = cmd_line_parse(iargs)
    atr = readfile.read_attribute(inps.file)
    k = atr['FILE_TYPE']
    print('input {} file: {}'.format(k, inps.file))

    # default output filename
    if not inps.outfile:
        if 'temporalCoherence' in inps.file:
            suffix = inps.file.split('temporalCoherence')[1]
            inps.outfile = 'maskTempCoh' + suffix
        else:
            if inps.roipoly:
                inps.outfile = 'maskPoly.h5'
            else:
                inps.outfile = 'mask.h5'
        if inps.file.startswith('geo_'):
            inps.outfile = 'geo_' + inps.outfile

    # default vmin for temporal coherence
    if not inps.vmin and inps.file.endswith('temporalCoherence.h5'):
        inps.vmin = 0.7

    ##### Mask: Non-zero
    if inps.nonzero and k == 'ifgramStack':
        # get dataset name
        if not inps.dset:
            with h5py.File(inps.file, 'r') as f:
                inps.dset = [
                    i for i in ['connectComponent', 'unwrapPhase']
                    if i in f.keys()
                ][0]

        # update mode
        if inps.update_mode and inps.outfile and run_or_skip(inps) == 'skip':
            return inps.outfile

        # run
        inps.outfile = ut.nonzero_mask(inps.file,
                                       out_file=inps.outfile,
                                       datasetName=inps.dset)
        return inps.outfile

    ##### Mask: Threshold
    inps.outfile = create_threshold_mask(inps)

    m, s = divmod(time.time() - start_time, 60)
    print('time used: {:02.0f} mins {:02.1f} secs.'.format(m, s))
    return inps.outfile
Пример #3
0
def main(iargs=None):
    inps = cmd_line_parse(iargs)
    atr = readfile.read_attribute(inps.file)
    k = atr['FILE_TYPE']
    print('input {} file: {}'.format(k, inps.file))

    # default output filename
    if not inps.outfile:
        if inps.file.endswith('temporalCoherence.h5'):
            inps.outfile = 'maskTempCoh.h5'
        else:
            inps.outfile = 'mask.h5'
        if inps.file.startswith('geo_'):
            inps.outfile = 'geo_'+inps.outfile

    ##### Mask: Non-zero
    if inps.nonzero and k == 'ifgramStack':
        inps.outfile = ut.nonzero_mask(inps.file, out_file=inps.outfile, datasetName=inps.dset)
        return inps.outfile

    ##### Mask: Threshold
    inps.outfile = create_threshold_mask(inps)
    return inps.outfile