コード例 #1
0
def s1_preprocessing(archive, maxdate, processdir, sensor, product, resolution,
                     recursive, polarization, acquisition_mode, verbose):
    """Preprocess Sentinel-1 scenes"""
    from pyroSAR import Archive, identify
    from pyroSAR.snap import geocode
    from datetime import datetime

    archive = Archive(archive)

    if maxdate == None:
        maxdate = datetime.now().strftime("%Y%m%dT%H%M%S")

    selection_proc = archive.select(processdir=processdir,
                                    recursive=recursive,
                                    polarizations=polarization,
                                    maxdate=maxdate,
                                    sensor=sensor,
                                    product=product,
                                    acquisition_mode=acquisition_mode,
                                    verbose=verbose)
    archive.close()
    print(selection_proc)

    for scene in selection_proc:
        geocode(infile=scene, outdir=processdir, tr=resolution, scaling='db')

    click.echo("eo2cube s1_create_archive")
コード例 #2
0
def s1_create_archive(input_dir, db_name):
    """Create Sentinel-1 archive"""
    from pyroSAR import Archive, identify
    import glob

    dbfile = db_name

    files = glob.glob(input_dir + "/S1A*.zip")
    n = len(files)

    print('Found ' + str(n) + ' scenes')

    with Archive(dbfile) as archive:
        for name in files:
            scene = identify(name)
            archive.insert(scene)

    click.echo("eo2cube s1_create_archive")
コード例 #3
0
def worker(sitename):
    #######################################################################################
    # setup general processing parameters

    resolution = 20
    #######################################################################################
    # define the directories for writing temporary and final results
    sitedir = os.path.join(maindir, sitename)
    outdir = os.path.join(sitedir, 'proc_out')
    #######################################################################################
    # load the test site geometry into a vector object
    sites = vector.Vector('/.../testsites.shp')

    # query the test site by name; a column name 'Site_Name' must be saved in your shapefile
    site = sites["Site_Name='{}'".format(sitename)]
    #######################################################################################
    # query the database for scenes to be processed
    with Archive(dbfile) as archive:
        selection_proc = archive.select(vectorobject=site,
                                        processdir=outdir,
                                        sensor=('S1A', 'S1B'),
                                        product='GRD',
                                        acquisition_mode='IW',
                                        vv=1)

    print('{0}: {1} scenes found for site {2}'.format(socket.gethostname(),
                                                      len(selection_proc),
                                                      sitename))
    #######################################################################################
    # call to processing utility
    if len(selection_proc) > 1:
        print('start processing')

        for scene in selection_proc:
            geocode(infile=scene, outdir=outdir, tr=resolution, scaling='db')
    return len(selection_proc)
コード例 #4
0
                                        product='GRD',
                                        acquisition_mode='IW',
                                        vv=1)

    print('{0}: {1} scenes found for site {2}'.format(socket.gethostname(),
                                                      len(selection_proc),
                                                      sitename))
    #######################################################################################
    # call to processing utility
    if len(selection_proc) > 1:
        print('start processing')

        for scene in selection_proc:
            geocode(infile=scene, outdir=outdir, tr=resolution, scaling='db')
    return len(selection_proc)


if __name__ == '__main__':
    #######################################################################################
    # update Sentinel-1 GRD scene archive database

    # define a directory containing zipped scene archives and list all files starting with 'S1A' or 'S1B'
    archive_s1 = '/.../sentinel1/GRD'
    scenes_s1 = finder(archive_s1, ['^S1[AB]'], regex=True, recursive=False)

    with Archive(dbfile) as archive:
        archive.insert(scenes_s1)
    #######################################################################################
    # start the processing
    results = list(futures.map(worker, sites))
コード例 #5
0
def worker(sitename):
    #######################################################################################
    # setup general processing parameters

    resolution = 20

    # number of processes for Python pathos framework (multiple scenes in parallel)
    parallel1 = 6

    # number of parallel OpenMP threads; this is used by GAMMA internally
    parallel2 = 6
    os.environ['OMP_NUM_THREADS'] = str(parallel2)
    #######################################################################################
    # get the maximum date of the precise orbit files
    # as type also 'RES' can be selected. These files are not as precise as POE and thus geocoding might not be
    # quite as accurate
    with OSV(osvdir) as osv:
        maxdate = osv.maxdate(osvtype='POE', datetype='stop')
    #######################################################################################
    # define the directories for writing temporary and final results
    sitedir = os.path.join(maindir, sitename)
    tempdir = os.path.join(sitedir, 'proc_in')
    outdir = os.path.join(sitedir, 'proc_out')
    #######################################################################################
    # load the test site geometry into a vector object
    sites = vector.Vector('/.../testsites.shp')

    # query the test site by name; a column name 'Site_Name' must be saved in your shapefile
    site = sites["Site_Name='{}'".format(sitename)]
    #######################################################################################
    # query the database for scenes to be processed
    with Archive(dbfile) as archive:
        selection_proc = archive.select(vectorobject=site,
                                        processdir=outdir,
                                        maxdate=maxdate,
                                        sensor=('S1A', 'S1B'),
                                        product='GRD',
                                        acquisition_mode='IW',
                                        vv=1)

    print('{0}: {1} scenes found for site {2}'.format(socket.gethostname(), len(selection_proc), sitename))
    #######################################################################################
    # define the DEM file
    demfile = '{0}/{1}/DEM/{1}_srtm_utm'.format(maindir, sitename)
    if not os.path.isfile(demfile):
        print('DEM missing for site {}'.format(sitename))
        return
    #######################################################################################
    # call to processing utility
    if len(selection_proc) > 1:
        print('start processing')
    if len(selection_proc) > 1:
        if len(selection_proc) < parallel1:
            parallel1 = len(selection_proc)
        # run the function on multiple cores in parallel
        multicore(geocode, cores=parallel1, multiargs={'scene': selection_proc}, dem=demfile,
                  tempdir=tempdir, outdir=outdir,
                  targetres=resolution, scaling='db',
                  func_geoback=2, func_interp=0, sarSimCC=False, osvdir=osvdir, cleanup=True, allow_RES_OSV=False)
    elif len(selection_proc) == 1:
        scene = selection_proc[0]
        # run the function on a single core
        geocode(scene, dem=demfile,
                tempdir=tempdir, outdir=outdir,
                targetres=resolution, scaling='db',
                func_geoback=2, func_interp=0, sarSimCC=False, osvdir=osvdir, cleanup=True, allow_RES_OSV=False)
    return len(selection_proc)