コード例 #1
0
def grdFrameImport(inFile, outFile, logFile, polar='VV,VH,HH,HV'):
    '''
    Import a single S1 GRD acquisition

    :param inFile: original file (zip or manifest) or swath assembled product
    :param outFile:
    :return:
    '''

    print(' INFO: Importing {} by applying precise orbit file and'
          ' removing thermal noise'.format(os.path.basename(inFile)))

    graph = ('/'.join(('graphs', 'S1_GRD2ARD', '1_AO_TNR.xml')))
    graph = pkg_resources.resource_filename(package, graph)

    frameImportCmd = '{} {} -x -q {} -Pinput={} -Ppolar={} \
                      -Poutput={}'.format(gpt_file, graph, os.cpu_count(),
                                          inFile, polar, outFile)
    rc = helpers.runCmd(frameImportCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Frame import exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(102)
コード例 #2
0
def sliceAssembly(fileList, outFile, logFile, polar='VV,VH,HH,HV'):
    """
    This function assembles consecutive frames acquired at the same date.
    Can be either GRD or SLC products

    :param fileList: a list of the frames to be assembled
    :param outFile: the assembled file
    :return:
        
    """

    # get gpt file
    gptFile = h.getGPT()

    print(" INFO: Assembling consecutive frames:")
    sliceAssemblyCmd = '{} SliceAssembly -x -q {} -PselectedPolarisations={} \
                       -t {} {}'.format(gptFile, os.cpu_count(), polar,
                                        outFile, fileList)

    # run command
    rc = h.runCmd(sliceAssemblyCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully assembled products')
    else:
        print(' ERROR: Slice Assembly exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(111)
コード例 #3
0
def slcCoherence(inFile, outFile, logFile):
    """
    This is a wrapper of S1TBX for the creation of interferometric coherence
    It includes Coherence (10x3 window) and deburst of the input product.
    """

    # get gpt file
    gptFile = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]
    graph = opj(rootPath, 'graphs', 'S1_SLC2ARD', 'S1_SLC_Coh_Deb.xml')

    print(' INFO: Coherence estimation')
    cohCmd = '{} {} -x -q {} -Pinput={} -Poutput={}' \
        .format(gptFile, graph, 2 * os.cpu_count(), inFile, outFile)

    rc = h.runCmd(cohCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully created Coherence product')
    else:
        print(' ERROR: Coherence exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(121)
コード例 #4
0
def texture(inFile, outFile, logFile):
    """
    This is a wrapper of S1TBX for the creation of the GLCM texture layers.
    Input should be an GTC or RTC product,
    """

    # get gpt file
    gptFile = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]
    graph = opj(rootPath, 'graphs', 'S1_SLC2ARD', 'S1_SLC_Tex.xml')

    print(" INFO: Calculating texture measures")
    texCmd = '{} {} -x -q {} -Pinput={} -Poutput={}' \
        .format(gptFile, graph, 2 * os.cpu_count(), inFile, outFile)

    rc = h.runCmd(texCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Geocoding exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(123)
コード例 #5
0
def slcLSMap(inFile, outFile, logFile, resol=20):
    """
    This function is a wrapper function of the SNAP toolbox for the creation of
    a layover/shadow mask.
    """

    # get gpt file
    gptFile = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]
    graph = opj(rootPath, 'graphs', 'S1_SLC2ARD', 'S1_SLC_LS_TC.xml')

    print(" INFO: Compute Layover/Shadow mask")
    lsCmd = '{} {} -x -q {} -Pinput={} -Presol={} -Poutput={}' \
        .format(gptFile, graph, 2 * os.cpu_count(), inFile, resol, outFile)

    rc = h.runCmd(lsCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully created Layover/Shadow mask')
    else:
        print(' ERROR: Layover/Shadow mask creation exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(121)
コード例 #6
0
def slcCoregESD(fileList, outFile, logFile):
    """
    This function co-registers a set of Sentinel-1 images (or subswaths)
    based on the backgeocoding and the Enhanced-Spectral-Diversity (ESD).
    """

    # get gpt file
    gptFile = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]
    graph = opj(rootPath, 'graphs', 'S1_SLC2ARD', 'S1_SLC_BGD_ESD.xml')

    print(" INFO: Co-registering with Enhanced Spectral Diversity")
    coregCmd = '{} {} -x -q {} -Pfilelist={} -Poutput={}' \
        .format(gptFile, graph, 2 * os.cpu_count(), fileList, outFile)

    rc = h.runCmd(coregCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully coregistered product')
    else:
        print(' ERROR: Co-registration exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(112)
コード例 #7
0
def slcFrameImport(inFile, outPrefix, logFile, polar='VV,VH,HH,HV'):
    """
    This function imports a raw SLC file,
    applies the precise orbit file (if available)
    and splits the subswaths into separate files for further processing.
    """

    # get gpt file
    gptFile = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]
    graph = opj(rootPath, 'graphs', 'S1_SLC2ARD', 'S1_SLC_AO_Split.xml')

    print(' INFO: Importing {} by applying the precise orbit file and'
          ' split into the subswaths'.format(os.path.basename(inFile)))
    frameImportCmd = '{} {} -x -q {} -Pinput={} -Ppolar={} -Piw1={}_iw1 \
                      -Piw2={}_iw2 -Piw3={}_iw3' \
        .format(gptFile, graph, os.cpu_count(), inFile, polar,
                outPrefix, outPrefix, outPrefix)

    rc = h.runCmd(frameImportCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Frame import exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(112)
コード例 #8
0
def grdLSMap(inFile, lsFile, logFile, resol):
    '''

    '''

    # get gpt file
    gpt_file = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]

    print(" INFO: Creating the Layover/Shadow mask")
    # get path to workflow xml
    graph = opj(rootPath, 'graphs', 'S1_GRD2ARD', '3_LSmap.xml')

    # construct command string
    lsCmd = '{} {} -x -q {} -Pinput=\'{}\' -Presol={} \
             -Poutput=\'{}\''.format(gpt_file, graph, 2 * os.cpu_count(),
                                     inFile, resol, lsFile)

    # run command
    rc = h.runCmd(lsCmd, logFile)

    # handle errors and logs
    if rc == 0:
        print(' INFO: Succesfully create a layover shadow mask')
    else:
        print(' ERROR: Lazover&Shadow Mask creation exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(112)
コード例 #9
0
def grdFrameImport(inFile, outFile, logFile, polar='VV,VH,HH,HV'):
    '''
    Import a single S1 GRD acquisition

    :param inFile: original file (zip or manifest) or swath assembled product
    :param outFile:
    :return:
    '''

    print(' INFO: Importing {} by applying precise orbit file and'
          ' removing thermal noise'.format(os.path.basename(inFile)))

    # get gpt file
    gpt_file = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]
    graph = opj(rootPath, 'graphs', 'S1_GRD2ARD', '1_AO_TNR.xml')

    # construct command
    frameImportCmd = '{} {} -x -q {} -Pinput=\'{}\' -Ppolar={} \
                      -Poutput=\'{}\''.format(gpt_file, graph, os.cpu_count(),
                                              inFile, polar, outFile)

    # run command
    rc = h.runCmd(frameImportCmd, logFile)

    # handle errors and logs
    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Frame import exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(102)
コード例 #10
0
def grdTC(inFile, outFile, logFile, resol):
    '''

    '''

    # get gpt file
    gpt_file = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]
    print(" INFO: Geocoding the calibrated product")
    # calculate the multi-look factor
    mlFactor = int(int(resol) / 10)

    graph = opj(rootPath, 'graphs', 'S1_GRD2ARD', '3_ML_TC.xml')

    # construct command string
    geocodeCmd = '{} {} -x -q {} -Pinput=\'{}\' -Presol={} -Pml={} \
                 -Poutput=\'{}\''.format(gpt_file, graph, 2 * os.cpu_count(),
                                         inFile, resol, mlFactor, outFile)

    # run command
    rc = h.runCmd(geocodeCmd, logFile)

    # handle errors and logs
    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Frame import exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(112)
コード例 #11
0
def slcTC(inFile, outFile, logFile, resolution=20):
    """
    This is a wrapper of S1TBX for the creation of a multi-looked, terrain-corrected product.
    """

    # get gpt file
    gptFile = h.getGPT()

    # get path to graph
    #rootPath = imp.find_module('ost')[1]
    #graph = opj(rootPath, 'graphs', 'S1_SLC2ARD',  'S1_SLC_ML_TC.xml')

    print(" INFO: Geocoding input scene")
    #tcCmd = '{} {} -x -q {} -Pinput={} -Presol={} -Poutput={}' \
    #   .format(gptFile, SLC_tc_xml, 2 * os.cpu_count(),
    #           inFile, resolution, outFile)

    tcCmd = '{} Terrain-Correction -x -q {} \
            -PdemResamplingMethod=\'BILINEAR_INTERPOLATION\' \
            -PimgResamplingMethod=\'BILINEAR_INTERPOLATION\' \
            -PnodataValueAtSea=\'false\' \
            -PpixelSpacingInMeter=\'{}\' \
            -t {} {}' \
            .format(gptFile, 2 * os.cpu_count(), resolution, outFile, inFile)

    rc = h.runCmd(tcCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Geocoding exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(122)
コード例 #12
0
def slcHalpha(inFile, outFile, logFile):
    """
    This is a wrapper of S1TBX for the creation of the H-alpha dual-pol decomposition.
    Input should be a frame imported product. Processing includes the deburst
    and Polarimetric Speckle Filtering (Improved Lee Sigma) and the H-alpha dual-pol decomposition.
    """

    # get gpt file
    gptFile = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]
    graph = opj(rootPath, 'graphs', 'S1_SLC2ARD', 'S1_SLC_Deb_Halpha.xml')

    print(" INFO: Calculating the H-alpha dual polarisation")
    alphaCmd = '{} {} -x -q {} -Pinput={} -Poutput={}' \
        .format(gptFile, graph, 2 * os.cpu_count(), inFile, outFile)

    rc = h.runCmd(alphaCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully created H/Alpha product')
    else:
        print(' ERROR: H/Alpha exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(121)
コード例 #13
0
def grdSpkFlt(inFile, outFile, logFile):

    print(" INFO: Applying the Lee-Sigma Speckle Filter")
    spkCmd = '{} Speckle-Filter -x -q {} -PestimateENL=true \
           -t {} {}'.format(gpt_file, 2 * os.cpu_count(), outFile, inFile)
    rc = helpers.runCmd(spkCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Speckle Filtering exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(111)
コード例 #14
0
def grdBackscatter(inFile, outFile, logFile, prType='GTCgamma'):
    '''
    This function is a wrapper for the calibration of Sentinel-1
    GRD backscatter data. 3 different calibration modes are supported.
        - Radiometrically terrain corrected Gamma nought (RTC)
        - ellipsoid based Gamma nought (GTCgamma)
        - Sigma nought (GTCsigma).

    :param inFile: an imported Sentinel-1 file
    :param outFile: the calibrated file
    :param prType: the product type (RTC, GTCgamma or GTCsigma)
    :return:
    '''

    # get gpt file
    gpt_file = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]

    if prType == 'RTC':
        print(' INFO: Calibrating the product to a RTC product.')
        graph = opj(rootPath, 'graphs', 'S1_GRD2ARD', '2_CalBeta_TF.xml')
    elif prType == 'GTCgamma':
        print(' INFO: Calibrating the product to a GTC product (Gamma0).')
        graph = opj(rootPath, 'graphs', 'S1_GRD2ARD', '2_CalGamma.xml')
    elif prType == 'GTCsigma':
        print(' INFO: Calibrating the product to a GTC product (Sigma0).')
        graph = opj(rootPath, 'graphs', 'S1_GRD2ARD', '2_CalSigma.xml')
    else:
        print(' ERROR: Wrong product type selected.')
        exit
    # create system command
    #graph = pkg_resources.resource_filename(package, graph)
    # construct command sring
    calibrationCmd = '{} {} -x -q {} -Pinput=\'{}\' \
                      -Poutput=\'{}\''.format(gpt_file, graph,
                                              2 * os.cpu_count(), inFile,
                                              outFile)
    # run command
    rc = h.runCmd(calibrationCmd, logFile)

    # handle errors and logs
    if rc == 0:
        print(' INFO: Succesfully calibrated product')
    else:
        print(' ERROR: Backscatter calibration exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(103)
コード例 #15
0
def grdSubsetRegion(inFile, outFile, logFile, region):

    gpt_file = '/usr/bin/gpt'
    region = ','.join([str(int(x)) for x in region])
    # extract window from scene
    subsetCmd = '{} Subset -x -q {} -Pregion={} -t {}\
                 {}'.format(gpt_file, os.cpu_count(), region, outFile, inFile)

    rc = helpers.runCmd(subsetCmd, logFile)
    rc = 0
    if rc == 0:
        print(' INFO: Succesfully subsetted product')
    else:
        print(' ERROR: Subsetting exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(107)
コード例 #16
0
def grdSubsetGeoRegion(inFile, outFile, logFile, geoRegion):

    # get Snap's gpt file
    gpt_file = h.getGPT()

    # extract window from scene
    subsetCmd = '{} Subset -x -q {} -Ssource=\'{}\' -t \'{}\' -PcopyMetadata=true \
                 -PgeoRegion=\'{}\''.format(gpt_file, os.cpu_count(), inFile,
                                            outFile, geoRegion)

    rc = h.runCmd(subsetCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully subsetted product')
    else:
        print(' ERROR: Subsetting exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(107)
コード例 #17
0
def grdSubsetRegion(inFile, outFile, logFile, region):

    # get Snap's gpt file
    gpt_file = h.getGPT()
    region = ','.join([str(int(x)) for x in region])
    # extract window from scene
    subsetCmd = '{} Subset -x -q {} -Pregion={} -t \'{}\'\
                 \'{}\''.format(gpt_file, os.cpu_count(), region, outFile,
                                inFile)

    rc = h.runCmd(subsetCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully subsetted product')
    else:
        print(' ERROR: Subsetting exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(107)
コード例 #18
0
def grdLSMap(inFile, lsFile, logFile, resol):
    '''

    '''

    print(" INFO: Creating the Layover/Shadow mask")
    graph = ('/'.join(('graphs', 'S1_GRD2ARD', '3_LSmap.xml')))
    graph = pkg_resources.resource_filename(package, graph)

    lsCmd = '{} {} -x -q {} -Pinput={} -Presol={} \
             -Poutput={}'.format(gpt_file, graph, 2 * os.cpu_count(), inFile,
                                 resol, lsFile)
    rc = helpers.runCmd(lsCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Lazover&Shadow Mask creation exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(112)
コード例 #19
0
def slcTerrainFlattening(inFile, outFile, logFile, reGrid=True):

    # get gpt file
    gptFile = h.getGPT()

    print(
        ' INFO: Correcting for the illumination along slopes (Terrain Flattening).'
    )
    tfCmd = '{} Terrain-Flattening -x -q {} -PreGridMethod={} \
             -PadditionalOverlap=0.2 -PoversamplingMultiple=1.5 -t {} {}' \
        .format(gptFile, 2 * os.cpu_count(), reGrid, outFile, inFile)

    rc = h.runCmd(tfCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Terrain Flattening exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(121)
コード例 #20
0
def grdSpkFlt(inFile, outFile, logFile):

    # get gpt file
    gpt_file = h.getGPT()

    print(" INFO: Applying the Lee-Sigma Speckle Filter")
    # contrcut command string
    spkCmd = '{} Speckle-Filter -x -q {} -PestimateENL=true \
              -t \'{}\' \'{}\''.format(gpt_file, 2 * os.cpu_count(), outFile,
                                       inFile)

    # run command
    rc = h.runCmd(spkCmd, logFile)

    # hadle errors and logs
    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Speckle Filtering exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(111)
コード例 #21
0
def grdBackscatter(inFile, outFile, logFile, prType='GTCgamma'):
    '''
    This function is a wrapper for the calibration of Sentinel-1
    GRD backscatter data. 3 different calibration modes are supported.
        - Radiometrically terrain corrected Gamma nought (RTC)
        - ellipsoid based Gamma nought (GTCgamma)
        - Sigma nought (GTCsigma).

    :param inFile: an imported Sentinel-1 file
    :param outFile: the calibrated file
    :param prType: the product type (RTC, GTCgamma or GTCsigma)
    :return:
    '''

    if prType == 'RTC':
        print(' INFO: Calibrating the product to a RTC product.')
        graph = ('/'.join(('graphs', 'S1_GRD2ARD', '2_CalBeta_TF.xml')))
    elif prType == 'GTCgamma':
        print(' INFO: Calibrating the product to a GTC product (Gamma0).')
        graph = ('/'.join(('graphs', 'S1_GRD2ARD', '2_CalGamma.xml')))
    elif prType == 'GTCsigma':
        print(' INFO: Calibrating the product to a GTC product (Sigma0).')
        graph = ('/'.join(('graphs', 'S1_GRD2ARD', '2_CalSigma.xml')))
    else:
        print(' ERROR: Wrong product type selected.')
        exit
    # create system command
    graph = pkg_resources.resource_filename(package, graph)
    calibrationCmd = '{} {} -x -q {} -Pinput={} \
                      -Poutput={}'.format(gpt_file, graph, 2 * os.cpu_count(),
                                          inFile, outFile)

    rc = helpers.runCmd(calibrationCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Backscatter calibration exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(103)
コード例 #22
0
def slcBackscatter(inFile, outFile, logFile, prType='GTCgamma'):
    """
    This function is a wrapper function of the SNAP toolbox for the creation of
    radiometrically terrain corrected product.
    """

    # get gpt file
    gptFile = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]

    if prType == 'RTC':
        print(' INFO: Calibrating the product to a RTC product.')
        graph = opj(rootPath, 'graphs', 'S1_SLC2ARD',
                    'S1_SLC_TNR_Calbeta_Deb.xml')
    elif prType == 'GTCgamma':
        print(' INFO: Calibrating the product to a GTC product (Gamma0).')
        graph = opj(rootPath, 'graphs', 'S1_SLC2ARD',
                    'S1_SLC_TNR_CalGamma_Deb.xml')
    elif prType == 'GTCsigma':
        print(' INFO: Calibrating the product to a GTC product (Sigma0).')
        graph = opj(rootPath, 'graphs', 'S1_SLC2ARD',
                    'S1_SLC_TNR_CalSigma_Deb.xml')
    else:
        print(' ERROR: Wrong product type selected.')
        exit

    print(" INFO: Removing thermal noise, calibrating and debursting")
    calCmd = '{} {} -x -q {} -Pinput={} -Poutput={}' \
        .format(gptFile, graph, 2 * os.cpu_count(), inFile, outFile)

    rc = h.runCmd(calCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Frame import exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(121)
コード例 #23
0
def slcBurstImport(inFile,
                   outPrefix,
                   logFile,
                   swath,
                   burst,
                   polar='VV,VH,HH,HV'):
    """
    This function imports a raw SLC file,
    applies the precise orbit file (if available)
    and splits the subswaths into separate files for further processing.

    :param
    :param
    :return
    """

    # get gpt file
    gptFile = h.getGPT()

    # get path to graph
    rootPath = imp.find_module('ost')[1]
    graph = opj(rootPath, 'graphs', 'S1_SLC2ARD', 'S1_SLC_BurstSplit_AO.xml')

    print(' INFO: Importing Burst {} from Swath {}'
          ' from scene {}'.format(burst, swath, os.path.basename(inFile)))

    burstImportCmd = '{} {} -x -q {} -Pinput={} -Ppolar={} -Pswath={}\
                      -Pburst={} -Poutput={}' \
        .format(gptFile, graph, os.cpu_count(), inFile, polar, swath,
                burst, outPrefix)

    rc = h.runCmd(burstImportCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Frame import exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(119)
コード例 #24
0
def grdTC(inFile, outFile, logFile, resol):
    '''

    '''

    print(" INFO: Geocoding the calibrated product")
    # calculate the multi-look factor
    mlFactor = int(int(resol) / 10)

    graph = ('/'.join(('graphs', 'S1_GRD2ARD', '3_ML_TC.xml')))
    graph = pkg_resources.resource_filename(package, graph)

    geocodeCmd = '{} {} -x -q {} -Pinput={} -Presol={} -Pml={} \
                 -Poutput={}'.format(gpt_file, graph, 2 * os.cpu_count(),
                                     inFile, resol, mlFactor, outFile)
    rc = helpers.runCmd(geocodeCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully imported product')
    else:
        print(' ERROR: Frame import exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(112)
コード例 #25
0
def mtSpeckle(inStack, outStack, logFile):
    """

    :param inStack:
    :param outStack:
    :return:
    """

    graph = ('/'.join(('graphs', 'S1_TS', '2_MT_Speckle.xml')))
    graph = pkg_resources.resource_filename(package, graph)

    print(" INFO: Applying the multi-temporal speckle-filtering")
    mtSpkFltCmd = '{} {} -x -q {} -Pinput={} \
                   -Poutput={}'.format(gpt_file, graph, os.cpu_count(),
                                       inStack, outStack)

    rc = helpers.runCmd(mtSpkFltCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully applied multi-temporal speckle filtering')
    else:
        print(' ERROR: Multi-temporal speckle filtering exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(202)
コード例 #26
0
def createStackPol(fileList, polarisation, outStack, logFile, wkt=None):
    '''

    :param fileList: list of single Files (space separated)
    :param outFile: the stack that is generated
    :return:
    '''

    if wkt is None:
        graph = ('/'.join(('graphs', 'S1_TS', '1_BS_Stacking.xml')))
        graph = pkg_resources.resource_filename(package, graph)

        print(" INFO: Creating multi-temporal stack of images")
        stackCmd = '{} {} -x -q {} -Pfilelist={} -Ppol={} \
               -Poutput={}'.format(gpt_file, graph, os.cpu_count(), fileList,
                                   polarisation, outStack)
    else:
        # does not work with gpt at the moment
        graph = ('/'.join(('graphs', 'S1_TS', '1_BS_Stacking_Subset.xml')))
        graph = pkg_resources.resource_filename(package, graph)

        print(" INFO: Creating multi-temporal stack of images")
        stackCmd = '{} {} -x -q {} -Pfilelist={} -Ppol={} \
               -Pwkt=\'{}\' -Poutput={}'.format(gpt_file, graph,
                                                os.cpu_count(), fileList,
                                                polarisation, wkt, outStack)

    #print(stackCmd)
    rc = helpers.runCmd(stackCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully created multi-temporal stack')
    else:
        print(' ERROR: Stack creation exited with an error.'
              ' See {} for Snap Error output'.format(logFile))
        sys.exit(201)
コード例 #27
0
def sliceAssembly(fileList, outFile, logFile, polar='VV,VH,HH,HV'):
    '''
    This function assembles consecutive frames acquired at the same date.
    Can be either GRD or SLC products

    :param fileList: a list of Sentinel-1 product slices to be assembled
    :param outFile: the assembled file
    :return:
    '''

    print(" INFO: Assembling consecutive frames:")
    #print([file for file in os.path.basename(fileList)])
    sliceAssemblyCmd = '{} SliceAssembly -x -q {} -PselectedPolarisations={} \
                       -t {} {}'.format(gpt_file, os.cpu_count(), polar,
                                        outFile, fileList)

    rc = helpers.runCmd(sliceAssemblyCmd, logFile)

    if rc == 0:
        print(' INFO: Succesfully assembled products')
    else:
        print(' ERROR: Slice Assembly exited with an error. \
                See {} for Snap Error output'.format(logFile))
        sys.exit(101)