コード例 #1
0
ファイル: S1_setup_master.py プロジェクト: shlpu/RapidSAR
def geocode_dem(datadir, masterdate, dem_width):
    mli = os.path.join(datadir, 'SLC', masterdate, masterdate + '.mli')
    geodir = os.path.join(datadir, 'Geo')
    res = grep('range_samples', '{mli}.par'.format(mli=mli))
    width = np.int32(res.split(':')[1].strip())
    res = grep('nlines', '{gd}/{md}.dem.par'.format(gd=geodir, md=masterdate))
    dem_length = np.int32(res.split(':')[1].strip())
    res = grep('azimuth_lines', '{mli}.par'.format(mli=mli))
    length = np.int32(res.split(':')[1].strip())

    exe_str = 'geocode_back {mli} {w} {gd}/{md}.lut_fine '.format(
        mli=mli, w=width, gd=geodir, md=masterdate)
    exe_str += '{gd}/DEM.{md}.mli {dw} {dl} 2 0'.format(gd=geodir,
                                                        md=masterdate,
                                                        dw=dem_width,
                                                        dl=dem_length)
    os.system(exe_str)

    exe_str = 'geocode {gd}/{md}.lut_fine {gd}/{md}.dem '.format(gd=geodir,
                                                                 md=masterdate)
    exe_str += '{wd} {gd}/{md}.hgt {w} {l} 2 0'.format(wd=dem_width,
                                                       gd=geodir,
                                                       md=masterdate,
                                                       w=width,
                                                       l=length)
    os.system(exe_str)

    exe_str = 'rashgt {gd}/{md}.hgt {mli} {w} - - - - - 500'.format(
        gd=geodir, md=masterdate, mli=mli, w=width)
    os.system(exe_str)

    exe_str = 'rashgt {gd}/{md}.dem {gd}/DEM.{md}.mli {wd} - - - - - 500'.format(
        gd=geodir, md=masterdate, wd=dem_width)
    os.system(exe_str)
コード例 #2
0
def geocode_dem(datadir,masterdate,dem_width):
    mli = os.path.join(datadir,'SLC',masterdate,masterdate+'.mli')
    geodir=os.path.join(datadir,'Geo')
    res = grep('range_samples','{mli}.par'.format(mli=mli))
    width = np.int32(res.split(':')[1].strip())
    res = grep('nlines','{gd}/{md}.dem.par'.format(gd=geodir,md=masterdate))
    dem_length = np.int32(res.split(':')[1].strip())
    res = grep('azimuth_lines','{mli}.par'.format(mli=mli))
    length = np.int32(res.split(':')[1].strip())
    
    exe_str = 'geocode_back {mli} {w} {gd}/{md}.lut_fine '.format(mli=mli,
                                                                   w=width,
                                                                   gd=geodir,
                                                                   md=masterdate)
    exe_str += '{gd}/DEM.{md}.mli {dw} {dl} 2 0'.format(gd=geodir,
                                                        md=masterdate,
                                                        dw=dem_width,
                                                        dl=dem_length)
    os.system(exe_str)
    
    exe_str = 'geocode {gd}/{md}.lut_fine {gd}/{md}.dem '.format(gd=geodir,
                                                                 md=masterdate)
    exe_str += '{wd} {gd}/{md}.hgt {w} {l} 2 0'.format(wd=dem_width,
                                                       gd=geodir,
                                                       md=masterdate,
                                                       w=width,
                                                       l=length)
    os.system(exe_str)
    
    exe_str = 'rashgt {gd}/{md}.hgt {mli} {w} - - - - - 500'.format(gd=geodir,
                                                                    md=masterdate,
                                                                    mli=mli,
                                                                    w=width)
    os.system(exe_str)
    
    exe_str = 'rashgt {gd}/{md}.dem {gd}/DEM.{md}.mli {wd} - - - - - 500'.format(gd=geodir,
                                                                                  md=masterdate,
                                                                                  wd=dem_width)
    os.system(exe_str)
コード例 #3
0
def calc_fine_dem_lut(datadir,masterdate):
    mli = os.path.join(datadir,'SLC',masterdate,masterdate+'.mli')
    geodir=os.path.join(datadir,'Geo')
    res = grep('width','{gd}/{md}.dem.par'.format(gd=geodir,md=masterdate))
    dem_width = np.int32(res.split(':')[1].strip())
    
    exe_str = 'gc_map_fine {gd}/{md}.lut {dw} '.format(gd=geodir,
                                                       md=masterdate,
                                                       dw=dem_width)
    exe_str += '{gd}/{md}.diff.par {gd}/{md}.lut_fine 1'.format(gd=geodir,
                                                                md=masterdate)

    os.system(exe_str)
    return dem_width        
コード例 #4
0
ファイル: S1_setup_master.py プロジェクト: shlpu/RapidSAR
def calc_fine_dem_lut(datadir, masterdate):
    mli = os.path.join(datadir, 'SLC', masterdate, masterdate + '.mli')
    geodir = os.path.join(datadir, 'Geo')
    res = grep('width', '{gd}/{md}.dem.par'.format(gd=geodir, md=masterdate))
    dem_width = np.int32(res.split(':')[1].strip())

    exe_str = 'gc_map_fine {gd}/{md}.lut {dw} '.format(gd=geodir,
                                                       md=masterdate,
                                                       dw=dem_width)
    exe_str += '{gd}/{md}.diff.par {gd}/{md}.lut_fine 1'.format(gd=geodir,
                                                                md=masterdate)

    os.system(exe_str)
    return dem_width
コード例 #5
0
def geocode_mli(datadir,masterdate,dem_width):
    geodir = os.path.join(datadir,'Geo')
    dempar = os.path.join(geodir,masterdate+'.dem.par')
    res = grep('corner_lat',dempar)
    demlat = np.float32(res.split(':')[1].strip().split(' ')[0])
    res = grep('corner_lon',dempar)
    demlon = np.float32(res.split(':')[1].strip().split(' ')[0])
    res = grep('post_lat',dempar) 
    latstep = np.float32(res.split(':')[1].strip().split(' ')[0])
    res = grep('post_lon',dempar) 
    lonstep = np.float32(res.split(':')[1].strip().split(' ')[0])
    res = grep('nlines',dempar) 
    dem_length = np.int32(res.split(':')[1].strip())

    mlipar = os.path.join(datadir,'SLC',masterdate,masterdate+'.mli.par')
    res = grep('range_samples',mlipar)
    mliwidth = np.int32(res.split(':')[1].strip())
    res = grep('azimuth_lines',mlipar)
    mlilength = np.int32(res.split(':')[1].strip())    
    
    lat = np.arange(demlat,demlat+dem_length*latstep,latstep)
    lat = lat[:dem_length]
    
    lon = np.arange(demlon,demlon+dem_width*lonstep,lonstep)
    lon = lon[:dem_width]

    LON,LAT = np.meshgrid(lon,lat)
    
    np.float32(LON).byteswap().tofile(geodir+'/lon_dem')
    np.float32(LAT).byteswap().tofile(geodir+'/lat_dem')
    exe_str = 'geocode {0}/{1}.lut_fine {0}/lon_dem {2} {0}/lon_mli {3} {4}'.format(geodir,
                                                                                   masterdate,
                                                                                   dem_width,
                                                                                   mliwidth,
                                                                                   mlilength)
    os.system(exe_str)
    exe_str = 'geocode {0}/{1}.lut_fine {0}/lat_dem {2} {0}/lat_mli {3} {4}'.format(geodir,
                                                                                   masterdate,
                                                                                   dem_width,
                                                                                   mliwidth,
                                                                                   mlilength)
    os.system(exe_str)
    return mliwidth, mlilength
コード例 #6
0
ファイル: S1_setup_master.py プロジェクト: shlpu/RapidSAR
def geocode_mli(datadir, masterdate, dem_width):
    geodir = os.path.join(datadir, 'Geo')
    dempar = os.path.join(geodir, masterdate + '.dem.par')
    res = grep('corner_lat', dempar)
    demlat = np.float32(res.split(':')[1].strip().split(' ')[0])
    res = grep('corner_lon', dempar)
    demlon = np.float32(res.split(':')[1].strip().split(' ')[0])
    res = grep('post_lat', dempar)
    latstep = np.float32(res.split(':')[1].strip().split(' ')[0])
    res = grep('post_lon', dempar)
    lonstep = np.float32(res.split(':')[1].strip().split(' ')[0])
    res = grep('nlines', dempar)
    dem_length = np.int32(res.split(':')[1].strip())

    mlipar = os.path.join(datadir, 'SLC', masterdate, masterdate + '.mli.par')
    res = grep('range_samples', mlipar)
    mliwidth = np.int32(res.split(':')[1].strip())
    res = grep('azimuth_lines', mlipar)
    mlilength = np.int32(res.split(':')[1].strip())

    lat = np.arange(demlat, demlat + dem_length * latstep, latstep)
    lat = lat[:dem_length]

    lon = np.arange(demlon, demlon + dem_width * lonstep, lonstep)
    lon = lon[:dem_width]

    LON, LAT = np.meshgrid(lon, lat)

    np.float32(LON).byteswap().tofile(geodir + '/lon_dem')
    np.float32(LAT).byteswap().tofile(geodir + '/lat_dem')
    exe_str = 'geocode {0}/{1}.lut_fine {0}/lon_dem {2} {0}/lon_mli {3} {4}'.format(
        geodir, masterdate, dem_width, mliwidth, mlilength)
    os.system(exe_str)
    exe_str = 'geocode {0}/{1}.lut_fine {0}/lat_dem {2} {0}/lat_mli {3} {4}'.format(
        geodir, masterdate, dem_width, mliwidth, mlilength)
    os.system(exe_str)
    return mliwidth, mlilength
コード例 #7
0
ファイル: S1_process_slaves.py プロジェクト: shlpu/RapidSAR
                        dt.datetime(int(l[:4]), int(l[4:6]), int(l[6:])))
    else:
        for l in os.listdir(os.path.join(datadir, 'SLC')):
            if l != str(masterdate) and l[0] == '2':
                slavelist.append(
                    dt.datetime(int(l[:4]), int(l[4:6]), int(l[6:])))

    masterdate = dt.datetime(int(str(masterdate)[:4]),
                             int(str(masterdate)[4:6]),
                             int(str(masterdate)[6:]))

    tempbaseline = [abs(masterdate - sd) for sd in slavelist]
    sortix = np.argsort(tempbaseline)
    swathlist, pol = get_swath_pol(datadir, masterdate.strftime('%Y%m%d'))
    res = grep(
        'range_samples',
        os.path.join(datadir, 'SLC', masterdate.strftime('%Y%m%d'),
                     '{md}.mli.par'.format(md=masterdate.strftime('%Y%m%d'))))
    mliwidth = np.int32(res.split(':')[1].strip())

    for i in sortix:
        process_slave(datadir, masterdate.strftime('%Y%m%d'),
                      slavelist[i].strftime('%Y%m%d'), tempbaseline[i],
                      swathlist, pol, mliwidth)


def process_slave(datadir, masterdate, slavedate, masterbaseline, swathlist,
                  pol, mliwidth):
    derive_lut(datadir, masterdate, slavedate, swathlist, pol)
    calc_offset(datadir, masterdate, slavedate, '')
    calc_offset(datadir, masterdate, slavedate, 1)
    if masterbaseline <= dt.timedelta(days=60):
コード例 #8
0
ファイル: S1_clear_hopper.py プロジェクト: shlpu/RapidSAR
            c.execute(query)
            res = c.fetchall()
            slavedate_dt = dt.datetime(int(slavedate[:4]),int(slavedate[4:6]),int(slavedate[6:]))
            if res:
                for procdir in res[0]:
                    with open(os.path.join(procdir,'burstid.list')) as f:
                        burstidlist = f.read().strip().split('\n')
                    make_image(procdir,burstidlist,slavedate,c,orbitdbfilename)
                    for f in os.listdir(os.path.join(procdir,'Geo')):
                        if f[-4:] == '.dem' and f[0] == '2':
                            masterdate = f.split('.')[0]
                            masterdate_dt = dt.datetime(int(masterdate[:4]),int(masterdate[4:6]),int(masterdate[6:]))
                            break
                    masterbaseline = abs(masterdate_dt-slavedate_dt)
                    swathlist, pol = get_swath_pol(procdir,masterdate)
                    res = grep('range_samples',os.path.join(procdir,'SLC',masterdate,'{md}.mli.par'.format(md=masterdate)))
                    mliwidth = np.int32(res.split(':')[1].strip())
                    process_slave(procdir,masterdate,slavedate,masterbaseline,swathlist,pol,mliwidth)
    conn.close()

def distribute_data(datadir,hopperdir,c,conn):
    datalist = os.listdir(hopperdir)
    tracklist = []
    datelist = []
    for d in datalist:
        if os.path.isdir(os.path.join(hopperdir,d)) and d[-5:] == '.SAFE':
            orbnumber = get_orbit(os.path.join(hopperdir,d))
            orbdir = os.path.join(datadir,'T'+orbnumber)
            if not os.path.exists(orbdir):
                os.mkdir(orbdir)
            if not os.path.exists(os.path.join(orbdir,d)):
コード例 #9
0
    if slavelistname:
        with open(slavelistname) as f:
            for l in f:
                if l.strip() != str(masterdate) and len(l) > 0:
                    slavelist.append(dt.datetime(int(l[:4]),int(l[4:6]),int(l[6:])))
    else:
        for l in os.listdir(os.path.join(datadir,'SLC')):
            if l != str(masterdate) and l[0] == '2':
                slavelist.append(dt.datetime(int(l[:4]),int(l[4:6]),int(l[6:])))
    
    masterdate = dt.datetime(int(str(masterdate)[:4]),int(str(masterdate)[4:6]),int(str(masterdate)[6:]))

    tempbaseline = [abs(masterdate-sd) for sd in slavelist] 
    sortix = np.argsort(tempbaseline)
    swathlist, pol = get_swath_pol(datadir,masterdate.strftime('%Y%m%d'))
    res = grep('range_samples',os.path.join(datadir,'SLC',masterdate.strftime('%Y%m%d'),'{md}.mli.par'.format(md=masterdate.strftime('%Y%m%d'))))
    mliwidth = np.int32(res.split(':')[1].strip())

    for i in sortix:
        process_slave(datadir,masterdate.strftime('%Y%m%d'),slavelist[i].strftime('%Y%m%d'),tempbaseline[i],swathlist,pol,mliwidth)


def process_slave(datadir,masterdate,slavedate,masterbaseline,swathlist,pol,mliwidth):
    derive_lut(datadir,masterdate,slavedate,swathlist,pol)
    calc_offset(datadir,masterdate,slavedate,'')
    calc_offset(datadir,masterdate,slavedate,1)
    if masterbaseline <= dt.timedelta(days=60):
        #No auxiliary image used if tempbaseline is less than 60 days
        coreg_overlap(datadir,masterdate,slavedate,[],1)
        coreg_overlap(datadir,masterdate,slavedate,[],2)
    else: