Exemplo n.º 1
0
def process_ifgramStack(inps, track, startDate, endDate, outdir, tmpdir):
    """process ifgramStack.h5 file"""
    if os.path.exists("".join(tmpdir)) == False:
        os.makedirs("".join(tmpdir))

    atr_asc = ['./inputs/' + str(inps.DataType) + '.h5']
    # mask
    if inps.maskfile and inps.maskfile != 'None':
        date_msk1 = re.split(r'[_.]', str(inps.maskfile))[0]
        date_msk1f = multitrack_utilities.find_nearest_date(
            os.getcwd(), str(date_msk1))
        date_msk2 = re.split(r'[_.]', str(inps.maskfile))[1]
        date_msk2f = multitrack_utilities.find_nearest_date(
            os.getcwd(), str(date_msk2))
        maskfile = date_msk1f + '_' + date_msk2f + '.cor'
        cmd_args = [atr_asc, '-m', maskfile]
        print('mask.py', cmd_args)
        args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
        os.system(
            multitrack_utilities.seperate_str_byspace(
                ['mask.py', args_str.split()]))
        atr_asc = './inputs/' + multitrack_utilities.seprate_filename_extension(
            "".join(atr_asc))[1] + '_msk.h5'

    #geocode ifgramStack file

    cmd_args = [
        atr_asc, '-b', inps.SNWE, '-y', inps.latStep, '-x', inps.lonStep,
        '--outdir', "".join(tmpdir)
    ]
    print("geocode.py", cmd_args)
    args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    mintpy.geocode.main(args_str.split())

    #save dataset of unw
    os.chdir("".join(tmpdir))
    filename, extension = multitrack_utilities.seprate_filename_extension(
        "".join(atr_asc))[1:3]
    cmd_args = [
        'geo_' + filename + extension,
        "".join(['unwrapPhase-', startDate, '_', endDate])
    ]
    print("save_roipac.py", cmd_args)
    args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', args_str.split()]))

    copy_file('geo', 'unw', outdir)
    shutil.rmtree(tmpdir)
Exemplo n.º 2
0
def process_HDFEOS(inps):
    """process S1*.h5 file"""

    atr_asc = inps.file

    #save dataset of unw and geometry
    filename, extension = multitrack_utilities.seprate_filename_extension(
        "".join(atr_asc))[1:3]
    cmd_args = [
        filename + extension,
        "".join(['displacement-', inps.startDate, '_', inps.endDate]), '-o',
        "".join(['geo_', inps.startDate, '_', inps.endDate, '.unw'])
    ]
    print("save_roipac.py", cmd_args)
    asct_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', asct_str.split()]))

    #mv
    if os.path.exists(inps.outdir) == False:
        os.makedirs(inps.outdir)
    else:
        shutil.rmtree(inps.outdir)
        os.makedirs(inps.outdir)
    key1 = 'geo_'
    for file in os.listdir(os.getcwd()):
        if str.find(file, key1) != -1:
            shutil.move(file, inps.outdir)
Exemplo n.º 3
0
def process_ifgramStack(inps):
    """process ifgramStack.h5 file"""
    if os.path.exists("".join(inps.outdir)) == False:
        os.makedirs("".join(inps.outdir))

    #ifgramStack file
    atr_asc = ['./inputs/' + inps.file]
    cmd_args = [
        atr_asc, '-b', inps.SNWE, '-y', inps.latStep, '-x', inps.lonStep,
        '--outdir', "".join(inps.outdir)
    ]
    print("geocode.py", cmd_args)
    args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    mintpy.geocode.main(args_str.split())

    #save dataset of unw
    os.chdir("".join(inps.outdir))
    filename, extension = multitrack_utilities.seprate_filename_extension(
        "".join(atr_asc))[1:3]

    cmd_args = [
        'geo_' + filename + extension,
        "".join(['unwrapPhase-', inps.startDate, '_', inps.endDate])
    ]
    print("save_roipac.py", cmd_args)
    asct_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', asct_str.split()]))
Exemplo n.º 4
0
def process_timeseries(inps):
    """geocode timeseries**.h5 file and get the deformation field of two time periods"""
    atr_asc = inps.file

    #unw file
    cmd_args = [
        atr_asc, '-b', inps.SNWE, '-y', inps.latStep, '-x', inps.lonStep,
        '--outdir', "".join(inps.outdir)
    ]
    print("geocode.py", cmd_args)
    args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    mintpy.geocode.main(args_str.split())

    #save dataset of unw
    os.chdir("".join(inps.outdir))
    filename, extension = multitrack_utilities.seprate_filename_extension(
        "".join(atr_asc))[1:3]

    cmd_args = [
        'geo_' + filename + extension,
        "".join([inps.startDate, '_', inps.endDate])
    ]
    print("save_roipac.py", cmd_args)
    asct_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', asct_str.split()]))
Exemplo n.º 5
0
def process_velocity(inps, track, startDate, endDate, outdir, tmpdir):
    """process velocity.h5 file"""
    if os.path.exists("".join(tmpdir)) == False:
        os.makedirs("".join(tmpdir))

    atr_asc = "".join([str(inps.DataType) + '.h5'])

    # mask
    if inps.maskfile and inps.maskfile != 'None':
        cmd_args = [atr_asc, '-m', inps.maskfile]
        print('mask.py', cmd_args)
        args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
        os.system(
            multitrack_utilities.seperate_str_byspace(
                ['mask.py', args_str.split()]))
        atr_asc = multitrack_utilities.seprate_filename_extension(
            atr_asc)[1] + '_msk.h5'
        print(atr_asc)
    #geocode velocity file
    cmd_args = [
        atr_asc, '-b', inps.SNWE, '-y', inps.latStep, '-x', inps.lonStep,
        '--outdir', "".join(tmpdir)
    ]
    print("geocode.py", cmd_args)
    args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    mintpy.geocode.main(args_str.split())

    # save dataset of unw
    os.chdir("".join(tmpdir))
    print('save unw file')
    atr_asc = 'geo_' + atr_asc
    velocity_displacement(atr_asc, startDate, endDate)

    copy_file('geo', 'unw', outdir)
    return atr_asc
Exemplo n.º 6
0
def process_HDFEOS(inps, track, startDate, endDate, outdir, tmpdir):
    """process S1*.h5 file"""

    atr_asc = multitrack_utilities.find_HDFEOS_fullname("".join(
        [os.getenv('SCRATCHDIR') + '/' + track + '/mintpy/']))

    #save dataset of unw
    filename, extension = multitrack_utilities.seprate_filename_extension(
        "".join(atr_asc))[1:3]
    cmd_args = [
        filename + extension,
        "".join(['displacement-', startDate, '_', endDate]), '-o',
        "".join(['geo_', startDate, '_', endDate, '.unw'])
    ]
    print("save_roipac.py", cmd_args)
    args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', args_str.split()]))

    # mv
    if os.path.exists(tmpdir) == False:
        os.makedirs(tmpdir)
    else:
        shutil.rmtree(tmpdir)
        os.makedirs(tmpdir)
    key1 = 'geo_'
    for file in os.listdir(os.getcwd()):
        if str.find(file, key1) != -1:
            shutil.move(file, tmpdir)

    copy_file('geo', 'unw', outdir)
    shutil.rmtree(tmpdir)
Exemplo n.º 7
0
def process_timeseries(inps, track, startDate, endDate, outdir, tmpdir):
    """geocode timeseries**.h5 file and get the deformation field of two time periods"""
    if os.path.exists("".join(tmpdir)) == False:
        os.makedirs("".join(tmpdir))

    atr_asc = multitrack_utilities.find_timeseries_horzvert("".join(
        [os.getenv('SCRATCHDIR') + '/' + track + '/mintpy/']))

    # mask
    if inps.maskfile and inps.maskfile != 'None':
        cmd_args = [atr_asc, '-m', inps.maskfile]
        print('mask.py', cmd_args)
        args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
        os.system(
            multitrack_utilities.seperate_str_byspace(
                ['mask.py', args_str.split()]))
        atr_asc = multitrack_utilities.seprate_filename_extension(
            atr_asc)[1] + '_msk.h5'

    #geocode timeseries file
    cmd_args = [
        atr_asc, '-b', inps.SNWE, '-y', inps.latStep, '-x', inps.lonStep,
        '--outdir', tmpdir
    ]
    print("geocode.py", cmd_args)
    args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    mintpy.geocode.main(args_str.split())

    #save dataset of unw
    os.chdir("".join(tmpdir))
    filename, extension = multitrack_utilities.seprate_filename_extension(
        "".join(atr_asc))[1:3]
    cmd_args = [
        'geo_' + filename + extension, "".join([startDate, '_', endDate])
    ]
    print("save_roipac.py", cmd_args)
    args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', args_str.split()]))

    copy_file('geo', 'unw', outdir)
    shutil.rmtree(tmpdir)
Exemplo n.º 8
0
def process_HDFEOS(inps):
    """process *.he5 file"""
    atr_asc = inps.file

    #save dataset of unw cor and dem
    filename, extension = multitrack_utilities.seprate_filename_extension(
        "".join(atr_asc))[1:3]
    cmd_args = [
        filename + extension,
        "".join(['displacement-', inps.startDate, '_', inps.endDate]), '-o',
        "".join(['geo_', inps.startDate, '_', inps.endDate, '.unw'])
    ]
    print("save_roipac.py", cmd_args)
    asct_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', asct_str.split()]))

    cmd_args = [
        filename + extension, 'temporalCoherence', '-o',
        "".join(['geo_', inps.startDate, '_', inps.endDate, '.cor'])
    ]
    print("save_roipac.py", cmd_args)
    asct_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    completion_status = os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', asct_str.split()]))

    cmd_args = [filename + extension, 'height', '-o', 'srtm.dem']
    print("save_roipac.py", cmd_args)
    asct_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', asct_str.split()]))

    # mv
    if os.path.exists(inps.outdir) == False:
        os.makedirs(inps.outdir)
    else:
        shutil.rmtree(inps.outdir)
        os.makedirs(inps.outdir)
    key1 = 'geo_'
    key2 = 'srtm'
    for file in os.listdir(os.getcwd()):
        if str.find(file, key1) != -1 or str.find(file, key2) != -1:
            shutil.move(file, inps.outdir)
    os.chdir("".join(inps.outdir))

    multitrack_utilities.delete_tmpgeo(inps.outdir, 'geo_', '.h5')
Exemplo n.º 9
0
def run_software(inpsdict, inps):
    """run save_geodmod/gbis.py in proper directory"""

    if inpsdict['DataSet'][0] == 'None':
        tempfilename = inps.templateFile
        folders = multitrack_utilities.find_folder(
            multitrack_utilities.seprate_filename_extension(tempfilename)[1])
        print(folders)
    else:
        folders = inpsdict['DataSet']
        print(folders)
    # if datatype is HDFEOS,first judge whether they have same lat_step and lon_step
    if inpsdict['DataType'] == 'HDFEOS':
        flag = multitrack_utilities.check_X_Y_step(folders)
        if flag:
            multitrack_run_software(inpsdict, folders, inps)
    else:
        multitrack_run_software(inpsdict, folders, inps)
Exemplo n.º 10
0
def process_HDFEOS(inps):
    """process *.he5 file"""
    atr_asc = inps.file

    #save dataset of unw cor and dem
    filename, extension = mu.seprate_filename_extension("".join(atr_asc))[1:3]
    output_unw = "".join(['geo_', inps.startDate, '_', inps.endDate, '.unw'])
    cmd_args = [
        '../' + filename + extension,
        "".join(['displacement-', inps.startDate, '_',
                 inps.endDate]), '-o', output_unw
    ]
    print("save_roipac.py", cmd_args)
    asct_str = mu.seperate_str_byspace(cmd_args)
    os.system(mu.seperate_str_byspace(['save_roipac.py', asct_str.split()]))

    output_cor = "".join(['geo_', inps.startDate, '_', inps.endDate, '.cor'])
    cmd_args = [
        '../' + filename + extension, 'temporalCoherence', '-o', output_cor
    ]
    print("save_roipac.py", cmd_args)
    asct_str = mu.seperate_str_byspace(cmd_args)
    completion_status = os.system(
        mu.seperate_str_byspace(['save_roipac.py',
                                 asct_str.split()]))

    output_dem = 'srtm.dem'
    cmd_args = ['../' + filename + extension, 'height', '-o', output_dem]
    print("save_roipac.py", cmd_args)
    asct_str = mu.seperate_str_byspace(cmd_args)
    os.system(mu.seperate_str_byspace(['save_roipac.py', asct_str.split()]))

    mask_filter(inps, output_unw)
    mask_filter(inps, output_cor)
    #mask_filter(inps,output_dem)

    if inps.SNWE:
        print('Subset data based on bbox')
        subset_data_based_bbox(inps, output_unw)
        subset_data_based_bbox(inps, output_cor)
        subset_data_based_bbox(inps, output_dem)
Exemplo n.º 11
0
def process_ifgramStack(inps):
    """process ifgramStack.h5 file"""
    if os.path.exists("".join(inps.outdir)) == False:
        os.makedirs("".join(inps.outdir))

    # dem file
    demname = 'geometryRadar.h5'
    if not os.path.isfile(demname):
        demname_f = './inputs/geometryRadar.h5'
    else:
        demname_f = 'geometryRadar.h5'
    cmd_args = [
        demname_f, '-b', inps.SNWE, '-y', inps.latStep, '-x', inps.lonStep,
        '--outdir', "".join(inps.outdir)
    ]
    print("geocode.py", cmd_args)
    args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    mintpy.geocode.main(args_str.split())

    #ifgramStack file
    atr_asc = ['./inputs/' + inps.file]
    cmd_args = [
        atr_asc, '-b', inps.SNWE, '-y', inps.latStep, '-x', inps.lonStep,
        '--outdir', "".join(inps.outdir)
    ]
    print("geocode.py", cmd_args)
    args_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    mintpy.geocode.main(args_str.split())

    #save dataset of unw cor and dem
    os.chdir("".join(inps.outdir))
    filename, extension = multitrack_utilities.seprate_filename_extension(
        "".join(atr_asc))[1:3]

    cmd_args = [
        'geo_' + filename + extension,
        "".join(['unwrapPhase-', inps.startDate, '_', inps.endDate])
    ]
    print("save_roipac.py", cmd_args)
    asct_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', asct_str.split()]))

    cmd_args = [
        'geo_' + filename + extension,
        "".join(['coherence-', inps.startDate, '_', inps.endDate])
    ]
    print("save_roipac.py", cmd_args)
    asct_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    completion_status = os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', asct_str.split()]))

    cmd_args = ['geo_geometryRadar.h5', 'height', '-o', 'srtm.dem']
    print("save_roipac.py", cmd_args)
    asct_str = multitrack_utilities.seperate_str_byspace(cmd_args)
    os.system(
        multitrack_utilities.seperate_str_byspace(
            ['save_roipac.py', asct_str.split()]))

    multitrack_utilities.delete_tmpgeo(inps.outdir, 'geo_', '.h5')