Ejemplo n.º 1
0
def main(iargs=None):
    inps = cmd_line_parse(iargs)

    print('single track!')
    inps.startDate, inps.endDate = multitrack_utilities.find_start_end_date(
        os.getcwd(), inps)

    # set output dir
    inps.outdir = multitrack_utilities.set_outdir(inps, 'geodmod')
    print(inps)

    if str.find(inps.file, 'ifgramStack') != -1:
        process_ifgramStack(inps)
    elif str.find(inps.file, 'velocity') != -1:
        process_geocode(inps)
        process_velocity(inps)
    elif str.find(inps.file, 'timeseries') != -1:
        process_geocode(inps)
        process_timeseries(inps)
    else:
        process_HDFEOS(inps)
    # rename *.rsc1 to *.rsc
    outfile = multitrack_utilities.seperate_str_byspace(['srtm.dem' + '.rsc'])
    write_rsc_file(
        inps, outfile,
        multitrack_utilities.seperate_str_byspace(['srtm.dem' + '.rsc1']))
    os.remove(outfile)
    print('rename *.rsc1 to *.rsc')
    os.rename(
        multitrack_utilities.seperate_str_byspace(['srtm.dem' + '.rsc1']),
        outfile)
    # generate dem.jpeg
    dem_jpeg('srtm.dem')
Ejemplo n.º 2
0
def geodmod(inpsdict):
    """prepare data for geodmod software"""
    if inpsdict['mimtpy.geodmod'] == 'yes':
        Dataset = inpsdict['mimtpy.geodmod.DataSet']
        Dataset = list(tuple([i for i in Dataset.split(',')]))
        for dataset in Dataset:
            print(
                '\n***********************Start processing {} dataset***********************'
                .format(dataset))
            # go to dataset_dir
            dataset_dir = os.path.abspath(
                os.path.join(os.getenv('SCRATCHDIR'), dataset, 'mintpy'))
            if not os.path.isdir(dataset_dir):
                raise Exception('Error! No such dir : {}'.format(dataset_dir))
            print('\nGo to project dir:', dataset_dir)
            os.chdir(dataset_dir)

            # create geodmod dir
            software = 'geodmod'
            outdir = os.path.abspath(os.path.join(dataset_dir, software))
            if not os.path.isdir(outdir):
                os.makedirs(outdir)

            # find the HDFEOS file name
            HDFEOS_file = mu.find_HDFEOS_fullname(dataset_dir)
            print('\nThe HDFEOS file is {}'.format(HDFEOS_file))
            atr = readfile.read_attribute(HDFEOS_file)

            # get the startdate and enddate
            startDate, endDate = mu.find_start_end_date(
                dataset_dir, inpsdict['mimtpy.geodmod.startDate'],
                inpsdict['mimtpy.geodmod.endDate'])
            if startDate == 'None':
                startDate = atr['START_DATE']
            if endDate == 'None':
                endDate = atr['END_DATE']

            # go to geodmod dir
            print('\nGo to geodmod dir:', outdir)
            os.chdir(outdir)

            # generate parameter list for HDFEOS_to_geotiff.py
            if inpsdict['mimtpy.geodmod.SNWE'] == 'None':
                scp_args = [
                    '../' + HDFEOS_file, '-s', startDate, '-e', endDate
                ]
            else:
                SNWE = inpsdict['mimtpy.geodmod.SNWE']
                SNWE = list(tuple([float(i) for i in SNWE.split(',')]))
                scp_args = [
                    '../' + HDFEOS_file, '-s', startDate, '-e', endDate,
                    '--bbox', SNWE
                ]

            scp_args = mu.seperate_str_byspace(scp_args)
            # run save_geodmod.py
            print('save_geodmod.py', scp_args)
            mimtpy.save_geodmod.main(scp_args.split())
    else:
        print('\nSkip geodmod step')
Ejemplo n.º 3
0
def main(iargs=None):
    inps = cmd_line_parse(iargs)
    print(inps)

    # if datatype is S1,first judge whether they have same lat_step and lon_step
    if inps.DataType == 'HDFEOS':
        flag = multitrack_utilities.check_X_Y_step(inps.DataSet)
    # get project name
    project_name, project_length = multitrack_utilities.find_intersection_part(
        inps.DataSet[0], inps.DataSet[1])
    # generate outdir
    outdir = generate_outdir_name(inps, project_name)
    # run each track
    for project in inps.DataSet:
        print(project)
        # get project and track name
        ret = re.findall(r"^(.+?)(\d+)$", project)
        satellite = project_name[-3:]
        track_No = ret[0][1]

        # set parameter for each track
        os.chdir(os.getenv('SCRATCHDIR') + '/' + project + '/mintpy/')
        startDate, endDate = multitrack_utilities.find_start_end_date(
            os.getcwd(), inps)
        tmpdir = outdir + satellite + track_No + '/'

        # process data
        if inps.DataType == 'ifgramStack':
            process_ifgramStack(inps, project, startDate, endDate, outdir,
                                tmpdir)
        elif inps.DataType == 'velocity':
            atr_asc = process_velocity(inps, project, startDate, endDate,
                                       outdir, tmpdir)
        elif inps.DataType == 'timeseries':
            process_timeseries(inps, project, startDate, endDate, outdir,
                               tmpdir)
        else:
            if flag:
                process_HDFEOS(inps, project, startDate, endDate, outdir,
                               tmpdir)
    # generate horizontal and vertical deformation
    if inps.DataType == 'velocity':
        calculate_hozrvert_velocity(atr_asc, outdir, inps)
    calculate_horzvert_displacement(inps, outdir)
Ejemplo n.º 4
0
def main(iargs=None):
    inps = cmd_line_parse(iargs)

    print('single track!')
    inps.startDate, inps.endDate = multitrack_utilities.find_start_end_date(
        os.getcwd(), inps)
    print(inps)

    if str.find(inps.file, 'ifgramStack') != -1:
        process_geocode(inps)
        process_ifgramStack(inps)
    elif str.find(inps.file, 'velocity.') != -1:
        process_geocode(inps)
        process_velocity(inps)
    elif str.find(inps.file, 'timeseries') != -1:
        process_geocode(inps)
        process_timeseries(inps)
    else:
        process_HDFEOS(inps)
    prep_gbis(inps)
    save2mat(inps)
Ejemplo n.º 5
0
def velcumu(inpsdict):
    """generate velocity.h5 and velocity.tiff file or generate cumudisp_date1_date2.h5 and cumudisp_date1_date2_tiff."""
    if inpsdict['mimtpy.velcumu'] == 'yes':
        Dataset = inpsdict['mimtpy.velcumu.DataSet']
        Dataset = list(tuple([i for i in Dataset.split(',')]))
        for dataset in Dataset:
            print(
                '\n***********************Start processing {} dataset***********************'
                .format(dataset))
            # go to dataset_dir
            dataset_dir = os.path.abspath(
                os.path.join(os.getenv('SCRATCHDIR'), dataset, 'mintpy'))
            if not os.path.isdir(dataset_dir):
                raise Exception('Error! No such dir : {}'.format(dataset_dir))
            os.chdir(dataset_dir)
            print('\nGo to project dir:', dataset_dir)

            # create velocity or cumulative dir
            filetype = inpsdict['mimtpy.velcumu.type']
            outdir = os.path.abspath(os.path.join(dataset_dir, filetype))
            if not os.path.isdir(outdir):
                os.makedirs(outdir)
            print('\nthe output dir for {} is {}.\n'.format(filetype, outdir))

            # find the HDFEOS file name
            HDFEOS_file = mu.find_HDFEOS_fullname(dataset_dir)
            print('\nThe HDFEOS file is {}'.format(HDFEOS_file))
            atr = readfile.read_attribute(HDFEOS_file)

            # get the startdate and enddate
            startDate, endDate = mu.find_start_end_date(
                dataset_dir, inpsdict['mimtpy.velcumu.startDate'],
                inpsdict['mimtpy.velcumu.endDate'])
            if startDate == 'None':
                startDate = atr['START_DATE']
            if endDate == 'None':
                endDate = atr['END_DATE']

            # generate parameter list for HDFEOS_to_geotiff.py
            if inpsdict['mimtpy.velcumu.SNWE'] == 'None':
                if inpsdict['mimtpy.velcumu.mask'] == 'y':
                    scp_args = [
                        HDFEOS_file, filetype, '--date',
                        startDate + '_' + endDate, '--mask', '--outdir', outdir
                    ]
                else:
                    scp_args = [
                        HDFEOS_file, filetype, '--date',
                        startDate + '_' + endDate, '--outdir', outdir
                    ]
            else:
                SNWE = inpsdict['mimtpy.velcumu.SNWE']
                SNWE = list(tuple([float(i) for i in SNWE.split(',')]))
                if inpsdict['mimtpy.velcumu.mask'] == 'y':
                    scp_args = [
                        HDFEOS_file, filetype, '--date',
                        startDate + '_' + endDate, '--mask', '--bbox', SNWE,
                        '--outdir', outdir
                    ]
                else:
                    scp_args = [
                        HDFEOS_file, filetype, '--date',
                        startDate + '_' + endDate, '--bbox', SNWE, '--outdir',
                        outdir
                    ]

            scp_args = mu.seperate_str_byspace(scp_args)
            # run HDFEOS_to_geotiff.py
            print('HDFEOS_to_geotiff.py', scp_args)
            mimtpy.HDFEOS_to_geotiff.main(scp_args.split())
    else:
        print('\nSkip velcumu process')

    return