Exemple #1
0
def main(argv):
    start_time = time.time()
    inps = cmdLineParse()
    projectName = inps.projectName
    scratchDir = os.getenv('SCRATCHDIR')
    projectDir = scratchDir + '/' + projectName
    slcDir = scratchDir + '/' + projectName + '/SLC'
    rslcDir = scratchDir + '/' + projectName + '/RSLC'
    if not os.path.isdir(rslcDir): os.mkdir(rslcDir)

    cmd_command = 'generate_multilook_amp.py'

    err_txt = scratchDir + '/' + projectName + '/generate_amp_all.err'
    if os.path.isfile(err_txt): os.remove(err_txt)

    data_para = []
    slc_list = [
        os.path.basename(fname) for fname in sorted(glob.glob(rslcDir + '/*'))
    ]
    #slc_list = ut.get_project_slcList(projectName)
    for i in range(len(slc_list)):
        rslcPar = rslcDir + '/' + slc_list[i] + '/' + slc_list[i] + '.rslc.par'
        #print(rslcPar)
        workDir0 = rslcDir + '/' + slc_list[i]
        BB = glob.glob(workDir0 + '/*.EOF')
        if len(BB) == 0:
            Sensor = ut.read_gamma_par(rslcPar, 'read', 'sensor')
            if 'A' in Sensor: satellite = 'A'
            else: satellite = 'B'
            ut.download_s1_orbit(slc_list[i], workDir0, satellite=satellite)

            BB = glob.glob(workDir0 + '/*.EOF')
            if len(BB) > 0:
                orb_file = BB[0]

                call_str = 'S1_OPOD_vec ' + rslcPar + ' ' + orb_file + ' 31'
                os.system(call_str)

    print("Using precise orbit data for all rslcs is done! ")
    ut.print_process_time(start_time, time.time())

    sys.exit(1)
Exemple #2
0
def main(argv):

    inps = cmdLineParse()
    raw_file = inps.s1_raw
    root_dir = inps.root_path
    satellite = get_satellite(raw_file)
    date = get_s1_date(raw_file)
    if not os.path.isdir(root_dir):
        os.mkdir(root_dir)

    slc_dir = root_dir + '/' + date
    if not os.path.isdir(slc_dir):
        os.mkdir(slc_dir)

    if len(os.path.dirname(raw_file)) == 0:
        raw_file_dir = os.getcwd()
    else:
        raw_file_dir = os.path.dirname(raw_file)

    raw_dir = raw_file.replace('.zip', '.SAFE')

    #     MEASURE = glob.glob(measureDir + '/*vv*tiff')
    #    ANNOTAT = glob.glob(annotatDir + '/*vv*xml' )
    #    CALIBRA = glob.glob(calibraDir+'/calibration*vv*')
    #    NOISE = glob.glob(calibraDir+'/noise*vv*')

    SLC_Tab = slc_dir + '/' + date + '_SLC_Tab'
    TEST = slc_dir + '/' + date + '.IW3.slc.par'
    k0 = 0
    if os.path.isfile(TEST):
        if os.path.getsize(TEST) > 0:
            k0 = 1

    if k0 == 0:
        if not os.path.isdir(raw_dir):
            call_str = 'unzip ' + raw_file + ' -d ' + raw_file_dir
            os.system(call_str)

        measureDir = raw_dir + '/measurement'
        annotatDir = raw_dir + '/annotation'
        calibraDir = raw_dir + '/annotation/calibration'
        MM = glob.glob(measureDir + '/*vv*tiff')

        if os.path.isfile(SLC_Tab):
            os.remove(SLC_Tab)
        for kk in range(len(MM)):
            SLC = slc_dir + '/' + date + '.IW' + str(kk + 1) + '.slc'
            SLCPar = slc_dir + '/' + date + '.IW' + str(kk + 1) + '.slc.par'
            TOPPar = slc_dir + '/' + date + '.IW' + str(kk +
                                                        1) + '.slc.TOPS_par'
            BURST = slc_dir + '/' + date + '.IW' + str(kk + 1) + '.burst.par'

            if os.path.isfile(BURST):
                os.remove(BURST)
            call_str = 'echo ' + SLC + ' ' + SLCPar + ' ' + TOPPar + ' >> ' + SLC_Tab
            os.system(call_str)

            MEASURE = glob.glob(measureDir + '/*iw' + str(kk + 1) + '*vv*tiff')
            ANNOTAT = glob.glob(annotatDir + '/*iw' + str(kk + 1) + '*vv*xml')
            CALIBRA = glob.glob(calibraDir + '/calibration*' + 'iw' +
                                str(kk + 1) + '*vv*')
            NOISE = glob.glob(calibraDir + '/noise*' + 'iw' + str(kk + 1) +
                              '*vv*')

            #call_str = 'S1_burstloc ' + ANNOTAT[0] + '> ' +BURST
            #os.system(call_str)

            if not os.path.isfile(NOISE[0]):
                call_str = 'par_S1_SLC ' + MEASURE[0] + ' ' + ANNOTAT[
                    0] + ' ' + CALIBRA[
                        0] + ' - ' + SLCPar + ' ' + SLC + ' ' + TOPPar
            else:
                call_str = 'par_S1_SLC ' + MEASURE[0] + ' ' + ANNOTAT[
                    0] + ' ' + CALIBRA[0] + ' ' + NOISE[
                        0] + ' ' + SLCPar + ' ' + SLC + ' ' + TOPPar

            #if int(date) > 180311:
            #    call_str = 'par_S1_SLC ' + MEASURE[0] + ' ' + ANNOTAT[0] + ' ' + CALIBRA[0] + ' - ' + SLCPar + ' ' + SLC + ' ' + TOPPar
            #else:
            #    call_str = 'par_S1_SLC ' + MEASURE[0] + ' ' + ANNOTAT[0] + ' ' + CALIBRA[0] + ' ' + NOISE[0] + ' ' + SLCPar + ' ' + SLC + ' ' + TOPPar

            os.system(call_str)

            call_str = 'SLC_burst_corners ' + SLCPar + ' ' + TOPPar + ' > ' + BURST
            os.system(call_str)

        # orbit correction
        slc_pars = glob.glob(slc_dir + '/*.IW*.slc.par')
        orbit_file0 = ut.download_s1_orbit(date, slc_dir, satellite=satellite)
        orbit_file = slc_dir + '/' + orbit_file0

        for i in range(len(slc_pars)):
            call_str = 'S1_OPOD_vec ' + slc_pars[i] + ' ' + orbit_file
            os.system(call_str)

    # generate amp file for check image quality
    #TSLC = slc_dir + '/' + date + '.slc'
    #TSLCPar = slc_dir + '/' + date + '.slc.par'

    #TMLI =  slc_dir + '/' + date + '_40rlks.amp'
    #TMLIPar = slc_dir + '/' + date + '_40rlks.amp.par'

    #call_str = 'SLC_mosaic_S1_TOPS ' +  SLC_Tab + ' ' + TSLC + ' ' + TSLCPar + ' 10 2'
    #os.system(call_str)

    #call_str = 'multi_look ' + TSLC + ' ' + TSLCPar + ' ' + TMLI + ' ' + TMLIPar + ' 40 8'
    #os.system(call_str)

    #nWidth = ut.read_gamma_par(TMLIPar, 'read','range_samples:')
    #call_str = 'raspwr ' + TMLI + ' ' + nWidth + ' - - - - - - - '
    #os.system(call_str)

    if os.path.isdir(raw_dir):
        call_str = 'rm -rf ' + raw_dir
        os.system(call_str)

    print("Down to SLC for %s is done! " % date)
    sys.exit(1)
Exemple #3
0
def main(argv):
    
    inps = cmdLineParse() 
    projectName = inps.projectName
    date = inps.date
    scratchDir = os.getenv('SCRATCHDIR')
    projectDir = scratchDir + '/' + projectName 
    
    templateDir = os.getenv('TEMPLATEDIR')
    templateFile = templateDir + "/" + projectName + ".template"
    templateDict=ut.update_template(templateFile)
    
    slc_dir =  projectDir + '/SLC'
    rslc_dir =  projectDir + '/RSLC'
    down_dir = projectDir + '/DOWNLOAD'
    opod_dir = projectDir + '/OPOD'
    
    if not os.path.isdir(slc_dir):
        os.mkdir(slc_dir)
    if not os.path.isdir(opod_dir):
        os.mkdir(opod_dir)
        
    work_dir = slc_dir + '/' + date
    if not os.path.isdir(work_dir):
        os.mkdir(work_dir)
    
    os.chdir(work_dir)
    master_burst_numb = down_dir + '/master.burst_numb_table'
    if not os.path.isfile(master_burst_numb):
        call_str = 'get_master_burst_numb.py ' + projectDir
        os.system(call_str)
        
    
    t_date = 't_' + date
    
    call_str = 'ls ' + down_dir + '/S1*' + date + '*.zip > ' + t_date
    os.system(call_str)
  
    start_swath = templateDict['start_swath']
    end_swath = templateDict['end_swath']
    
    
    if (start_swath == '1') and (end_swath == '1'):
        k_swath = '1'
    elif (start_swath == '2') and (end_swath == '2'):
        k_swath = '2'
    elif (start_swath == '3') and (end_swath == '3'):
        k_swath = '3'
    elif (start_swath == '1') and (end_swath == '2'):
        k_swath = '4'
    elif (start_swath == '2') and (end_swath == '3'):
        k_swath = '5' 
    elif (start_swath == '1') and (end_swath == '3'):
        k_swath = '0' 
    
    
    raw_files = ut.read_txt2list(t_date)
    satellite = get_satellite(raw_files[0])
    
    orbit_file = ut.download_s1_orbit(date,opod_dir,satellite=satellite)
    
    call_str = 'S1_import_SLC_from_zipfiles ' + t_date + ' ' + master_burst_numb + ' vv 0 ' + k_swath + ' ' + opod_dir + ' 1 1 '
    os.system(call_str)
    
    os.chdir(work_dir)
    
    call_str = "rename 's/vv.slc.iw1/IW1.slc/g' *"
    os.system(call_str)
    call_str = "rename 's/vv.slc.iw2/IW2.slc/g' *"
    os.system(call_str)
    call_str = "rename 's/vv.slc.iw3/IW3.slc/g' *"
    os.system(call_str)
    
    call_str = "rename 's/.tops_par/.TOPS_par/g' *"
    os.system(call_str)
    
    
    SLC_Tab = work_dir + '/' + date+'_SLC_Tab'
    RSLC_Tab = work_dir + '/' + date+'_RSLC_Tab'
    
    SLC_list = glob.glob(work_dir + '/*IW*.slc') 
    SLC_par_list = glob.glob(work_dir + '/*IW*.slc.par') 
    TOP_par_list = glob.glob(work_dir + '/*IW*.slc.TOPS_par') 
    
    
    if os.path.isfile(SLC_Tab):
        os.remove(SLC_Tab)
    if os.path.isfile(RSLC_Tab):
        os.remove(RSLC_Tab)
    
    SLC_list = sorted(SLC_list)
    SLC_par_list = sorted(SLC_par_list)
    TOP_par_list = sorted(TOP_par_list)
    
    
    for kk in range(len(SLC_list)):
        call_str = 'echo ' + SLC_list[kk] + ' ' + SLC_par_list[kk] + ' ' + TOP_par_list[kk] + ' >> ' + SLC_Tab
        os.system(call_str)
        
        call_str = 'echo ' + rslc_dir + '/' + date + '/' + os.path.basename(SLC_list[kk]).replace('.slc','.rslc') + ' ' + rslc_dir + '/' + date + '/'+ os.path.basename(SLC_par_list[kk]).replace('.slc','.rslc') + ' ' + rslc_dir + '/' + date + '/' + os.path.basename(TOP_par_list[kk]).replace('.slc','.rslc') + ' >> ' + RSLC_Tab
        os.system(call_str)
        
        BURST = SLC_par_list[kk].replace('slc.par','burst.par')
        KML = SLC_par_list[kk].replace('slc.par','kml')
        call_str = 'ScanSAR_burst_corners ' + SLC_par_list[kk] + ' ' +  TOP_par_list[kk] + ' ' + KML + ' > ' +BURST
        os.system(call_str)
 

    print("Down to SLC for %s is done! " % date)
    sys.exit(1)