示例#1
0
def get_create_stack_config():
    parameters = HashMap()
    parameters.put("resamplingType", "NONE")
    parameters.put("masterBands", "Sigma0_VH")
    parameters.put("extent", "Master")
    parameters.put("initialOffsetMethod", "Orbit")
    return parameters
示例#2
0
def topsarDeburst(product):

    if debug >= 2:
        print(cyan + "topsarDeburst() : " + bold + green + "Run to SNAP... " +
              endC)

    # Instance de GPF
    GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()

    # Def operateur SNAP
    operator = 'TOPSAR-Deburst'

    # Set des parametres
    parameters = HashMap()

    parameters.put("Polarisations", "VV")

    if debug >= 2:
        print(parameters)

    # Get snappy Operators
    result = GPF.createProduct(operator, parameters, product)

    if debug >= 2:
        print(cyan + "topsarDeburst() : " + bold + green + "Done... " + endC)

    return result
示例#3
0
def do_mosaic(source):
    parameters = HashMap()
    parameters.put('pixelSize', 200.0)
    parameters.put('resamplingMethod', 'BILINEAR_INTERPOLATION')
    parameters.put('mapProjection', "AUTO:42001")
    parameters.put('variables', 'Sigma0_HH')
    output = GPF.createProduct('SAR-Mosaic', parameters, source)
示例#4
0
def get_topsar_split_config(subswath: str, first, last, polarizations):
    parameters = HashMap()
    parameters.put("subswath", subswath)
    parameters.put("selectedPolarisations", polarizations)
    parameters.put("firstBurstIndex", first)
    parameters.put("lastBurstIndex", last)
    return parameters
def TOPSAR_split_s(product):
    parameters = HashMap()
    parameters.put('subswath', 'IW1')
    parameters.put('selectedPolarisations', 'VV')
    parameters.put('firstBurstIndex', 3)
    parameters.put('lastBurstIndex', 6)
    return GPF.createProduct('TOPSAR-Split', parameters, product)
示例#6
0
def do_subset_band(source, wkt):
    print('\tSubsetting...')
    parameters = HashMap()
    parameters.put('geoRegion', wkt)
    #parameters.put('outputImageScaleInDb', True)
    output = GPF.createProduct('Subset', parameters, source)
    return output
示例#7
0
 def terrain_flattening(terflt):
     parameters = HashMap()
     parameters.put('demName', 'SRTM 1Sec HGT')
     parameters.put('demResamplingMethod', 'BICUBIC_INTERPOLATION')
     parameters.put('reGridMethod', True)
     parameters.put('sourceBands', 'Beta0_' + polarization)
     return GPF.createProduct('Terrain-Flattening', parameters, terflt)
示例#8
0
def get_goldstein_phase_filtering_config():
    parameters = HashMap()
    parameters.put("alpha", 1.0)
    parameters.put("FFTSizeString", "128")
    parameters.put("windowSizeString", "3")
    parameters.put("useCoherenceMask", False)
    parameters.put("coherenceThreshold", 0.2)
    return parameters
示例#9
0
def topo_removal(file):
    image = ProductIO.readProduct(file)
    p = HashMap()
    p.put('demName', 'SRTM 1Sec HGT')
    result = GPF.createProduct('TopoPhaseRemoval', p, image)
    # Write to temporary file
    outfile = file.split('.dim')[0] + '_noSRTM.dim'
    ProductIO.writeProduct(result, outfile, 'BEAM-DIMAP')
示例#10
0
def bandMathSnap(input_dim,
                 output_file,
                 expression_list,
                 format_file='float32'):

    if debug >= 2:
        print(cyan + "bandmathSnap() : " + bold + green +
              "Import Dim to SNAP : " + endC + input_dim)

    # Info input file
    product = ProductIO.readProduct(input_dim)
    width = product.getSceneRasterWidth()
    height = product.getSceneRasterHeight()
    name = product.getName()
    description = product.getDescription()
    band_names = product.getBandNames()

    if debug >= 2:
        print(cyan + "bandmathSnap() : " + bold + green +
              "Product: %s, %d x %d pixels, %s" %
              (name, width, height, description) + endC)
        print(cyan + "bandmathSnap() : " + bold + green + "Bands:   %s" %
              (list(band_names)) + endC)

    # Instance de GPF
    GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()

    # Def operateur SNAP
    operator = 'BandMaths'
    BandDescriptor = jpy.get_type(
        'org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor')
    targetBands = jpy.array(
        'org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor',
        len(expression_list))

    # Get des expressions d'entréées
    i = 0
    for expression in expression_list:
        targetBand = BandDescriptor()
        targetBand.name = 'band_' + str(i + 1)
        targetBand.type = format_file
        targetBand.expression = expression
        targetBands[i] = targetBand
        i += 1

    # Set des parametres
    parameters = HashMap()
    parameters.put('targetBands', targetBands)

    # Get snappy Operators
    result = GPF.createProduct(operator, parameters, product)
    ProductIO.writeProduct(result, output_file, 'BEAM-DIMAP')

    if debug >= 2:
        print(cyan + "bandmathSnap() : " + bold + green + "Writing Done : " +
              endC + str(output_file))

    return result
def Convert_to_dB(data, source_band):
    
    print('Converting to dB...')

    parameters = HashMap()

    parameters.put('sourceBands', source_band)

    return GPF.createProduct('LinearToFromdB', parameters, data)
示例#12
0
def topsar_split(product, IW, firstBurstIndex, lastBurstIndex):
    print('Apply TOPSAR Split...')
    parameters = HashMap()
    parameters.put('subswath', IW)
    parameters.put('firstBurstIndex', firstBurstIndex)  # added by me
    parameters.put('lastBurstIndex', lastBurstIndex)  # added by me
    parameters.put('selectedPolarisations', 'VV')
    output = GPF.createProduct("TOPSAR-Split", parameters, product)
    return output
示例#13
0
def do_resampling (source):
    print ('\tResampling ...')
    HashMap = jpy.get_type('java.util.HashMap')
    parameters = HashMap()
    GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()
    parameters.put('targetResolution', 10)

    output = GPF.createProduct('Resample', parameters, source)
    return output
def perform_terrain_flattening(multilook, datestamp):
    params = HashMap()
    params.put('demName', 'SRTM 1Sec HGT')
    params.put('demResamplingMethod', 'BICUBIC_INTERPOLATION')
    params.put('oversamplingMultiple', 1.5)
    params.put('additionalOverlap', 0.1)
    terrain = GPF.createProduct('Terrain-Flattening', params, multilook)
    # write_product(terrain, os.path.join(dest_path, '{}_Orb_Cal_ML_TF'.format(datestamp)))
    return terrain
def perform_multilook(calibration, datestamp, range_look_number=3, azimuth_look_number=3):
    params = HashMap()
    params.put('nRgLooks', range_look_number)
    params.put('nAzLooks', azimuth_look_number)
    params.put('outputIntensity', True)
    params.put('grSquarePixel', True)
    multilook = GPF.createProduct('Multilook', params, calibration)
    # write_product(multilook, os.path.join(dest_path, '{}_Orb_Cal_ML'.format(datestamp)))
    return multilook
示例#16
0
def get_subset_config(wkt, bands=None):
    parameters = HashMap()
    if bands is not None:
        parameters.put("sourceBands", bands)
    if wkt is not None:
        geom = WKTReader().read(wkt)
        parameters.put("geoRegion", geom)
    parameters.put("copyMetadata", True)
    parameters.put("outputImageScaleInDb", False)
    return parameters
示例#17
0
def snaphu_unwrapping(product, target_Product_File, outFolder, filename):
    parameters = HashMap()
    parameters.put('targetProductFile',
                   target_Product_File)  # from SNAPHU_export
    parameters.put('outputFolder', outFolder)
    parameters.put('copyOutputAndDelete', 'Snaphu-unwrapping-after.vm')
    parameters.put('copyFilesTemplate', 'Snaphu-unwrapping-before.vm')
    product = GPF.createProduct('snaphu-unwrapping', parameters, product)
    ProductIO.writeProduct(product, filename + '.dim', 'BEAM-DIMAP')
    print('Phase unwrapping performed successfully …')
示例#18
0
def TOPSAR_Split_config(subswath, firstBurstIndex, lastBurstIndex,
                        polarizations):
    """
    This function ....
    """
    parameters = HashMap()
    parameters.put('subswath', subswath)
    parameters.put('selectedPolarisations', polarizations)
    parameters.put('firstBurstIndex', firstBurstIndex)
    parameters.put('lastBurstIndex', lastBurstIndex)
    return parameters
示例#19
0
def get_band_math_config(band_name, expression):
    parameters = HashMap()
    band_descriptor = jpy.get_type('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor')
    target_band = band_descriptor()
    target_band.name = band_name
    target_band.type = 'float32'
    target_band.expression = expression
    target_bands = jpy.array('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor', 1)
    target_bands[0] = target_band
    parameters.put('targetBands', target_bands)
    return parameters
示例#20
0
def set_no_data_value(product):
    logger = logging.getLogger('root')
    params = HashMap()
    root = xml.etree.ElementTree.parse(home['parameters'] +
                                       '/nodatavalue.xml').getroot()
    for child in root:
        params.put(child.tag, child.text)

    result = GPF.createProduct('SetNoDataValue', params, product)
    logger.info("finished set_no_data_value")
    return (result)
示例#21
0
def calibration(product):
    logger = logging.getLogger('root')
    params = HashMap()
    root = xml.etree.ElementTree.parse(home['parameters'] +
                                       '/calibration.xml').getroot()
    for child in root:
        params.put(child.tag, child.text)

    result = GPF.createProduct('Calibration', params, product)
    logger.info("finished calibration")
    return (result)
示例#22
0
def check_coverage(file, p):
    ## Does the image definitely cover our study areas in Peru / Gabon
    if 'GAB' in file:
        region = 'POLYGON((12.24885799008746368 -0.14350824099999146, 12.24885110630293283 -0.14259615803456555, 12.24975595848531107 -0.14259626696242139, 12.24975584715663501 -0.14353065658873754, 12.24885799008746368 -0.14350824099999146))'
    elif 'PER' in file:
        region = 'POLYGON((-69.72334001018973026 -11.0329910794429793, -69.72334358246895647 -11.03207312025939579, -69.72240573287906784 -11.0320753572009469, -69.7224080470953993 -11.03302282454907512, -69.72334001018973026 -11.0329910794429793))'
    params = HashMap()
    params.put('geoRegion', region)

    fail = 'Empty' in GPF.createProduct('Subset', params, p).getName()
    return not fail
def Calibration(data, band, pol):

    print('Calibrating...')
    
    parameters = HashMap()

    parameters.put('outputSigmaBand', True) 
    parameters.put('sourceBands', band)
    parameters.put('selectedPolarisations', pol)
    parameters.put('outputImageScaleInDb', False)

    return GPF.createProduct('Calibration', parameters, data)
示例#24
0
def remove_border_noise(product):
    logger = logging.getLogger('root')

    params = HashMap()
    root = xml.etree.ElementTree.parse(home['parameters'] +
                                       '/border-noise.xml').getroot()
    for child in root:
        params.put(child.tag, child.text)

    result = GPF.createProduct('Remove-GRD-Border-Noise', params, product)
    logger.info("finished Remove-GRD-Border-Noise")
    return (result)
示例#25
0
def thermal_noise_removal(product):
    logger = logging.getLogger('root')

    params = HashMap()
    root = xml.etree.ElementTree.parse(home['parameters'] +
                                       '/thermal_noise.xml').getroot()
    for child in root:
        params.put(child.tag, child.text)

    result = GPF.createProduct('ThermalNoiseRemoval', params, product)
    logger.info("finished ThermalNoiseRemoval")
    return (result)
示例#26
0
def orbit_correction(product):
    logger = logging.getLogger('root')

    params = HashMap()
    root = xml.etree.ElementTree.parse(home['parameters'] +
                                       '/orbit_correction.xml').getroot()
    for child in root:
        params.put(child.tag, child.text)

    result = GPF.createProduct('Apply-Orbit-File', params, product)
    logger.info("finished orbit correction")
    return (result)
示例#27
0
def createP(function, inputProduct, writeout=False, **kwargs):
    # pythonic version of GPF.createProduct()
    # function is string of SNAP operator
    # inputProduct is SNAP product object
    # kwargs contains any parameters to pass to the operator
    p = HashMap()
    for arg in kwargs:
        p.put(arg, kwargs.get(arg))
    result = GPF.createProduct(function, p, inputProduct)
    if writeout != False:
        ProductIO.writeProduct(result, writeout, 'BEAM-DIMAP')
    else:
        return result
def Terrain_Correction(data, source_band):

    print('Aplying the Range Doppler Terrain Correction...')

    parameters = HashMap()

    parameters.put('demName', 'SRTM 3Sec')
    parameters.put('demResamplingMethod', 'BILINEAR_INTERPOLATION')
    parameters.put('imgResamplingMethod', 'BILINEAR_INTERPOLATION')
    parameters.put('pixelSpacingInMeter', 10.0)
    parameters.put('sourceBands', source_band)

    return GPF.createProduct('Terrain-Correction', parameters, data)
示例#29
0
def speckle_filtering(product):
    ## Speckle filtering
    logger = logging.getLogger('root')

    params = HashMap()
    root = xml.etree.ElementTree.parse(home['parameters'] +
                                       '/speckle_filtering.xml').getroot()
    for child in root:
        params.put(child.tag, child.text)

    result = GPF.createProduct('Speckle-Filter', params, product)
    logger.info("finished speckle filtering")
    return (result)
示例#30
0
def get_multilook_config():
    parameters = HashMap()
    parameters.put("nRgLooks", 6)
    parameters.put("nAzLooks", 2)
    parameters.put("outputIntensity", False)
    parameters.put("grSquarePixel", True)
    return parameters
示例#31
0
targetBand1 = BandDescriptor()
targetBand1.name = 'band_1'
targetBand1.type = 'float32'
targetBand1.expression = '(radiance_10 - radiance_7) / (radiance_10 + radiance_7)'

targetBand2 = BandDescriptor()
targetBand2.name = 'band_2'
targetBand2.type = 'float32'
targetBand2.expression = '(radiance_9 - radiance_6) / (radiance_9 + radiance_6)'

targetBands = jpy.array('org.esa.snap.core.gpf.common.BandMathsOp$BandDescriptor', 2)
targetBands[0] = targetBand1
targetBands[1] = targetBand2

parameters = HashMap()
parameters.put('targetBands', targetBands)

result = GPF.createProduct('BandMaths', parameters, product)

print("Writing...")

ProductIO.writeProduct(result, 'snappy_bmaths_output.dim', 'BEAM-DIMAP')

print("Done.")


"""
   Please note: the next major version of snappy/jpy will be more pythonic in the sense that implicit data type
   conversions are performed. The 'parameters' from above variable could then be given as a Python dict object: