Exemplo n.º 1
0
    logger.debug(sentinel_1)

    ### APPLY-ORBIT FILE
    apply_orbit_prdt = sp.apply_orbit_file(sentinel_1)

    ### THERMAL NOISE REMOVAL
    noise_rem_prdt = sp.thermal_noise_removal(apply_orbit_prdt)

    ### CALIBRATION
    calibrated_prdt = sp.calibration(apply_orbit_prdt, config.POLARIZATIONS)

    ### SPECKLE FILTER
    speckle_prdt = sp.speckle_filter(calibrated_prdt)

    ### TERRAIN CORRECTION
    terrain_corrected_prdt = sp.terrain_correction(calibrated_prdt,
                                                   snappyconfigs.UTM_WGS84)

    ### SUBSET
    subset_prdt = sp.subset(terrain_corrected_prdt, config.LC_WKT)

    ### Convert datatype
    cnv_prdt = sp.convert_datatype(subset_prdt, "int8")

    ### GLCM
    glcm_prdt = sp.glcm(cnv_prdt)

    ### LinearFromTodB
    db_prdt = sp.linear_from_to_db(subset_prdt)

    ### Band merge
    merged_prdt = sp.band_merge([db_prdt, glcm_prdt])
Exemplo n.º 2
0
def process_SLC_product(master, slave):
    # read list of files from common_file.txt in processing dir (already sorted in chronological order)
    ######################## COREGISTRATION ########################
    # master_file = "S1A_IW_SLC__1SDV_20190519T112034_20190519T112101_027296_03140A_CB6F"
    master_file = master
    timestamp1 = master_file.split("_")[5]
    date1 = timestamp1[:8]

    # input_file_name2 = input_dir + slave_file
    slave_file = slave  # -1 to remove \n at the end
    timestamp2 = slave_file.split("_")[5]
    date2 = timestamp2[:8]

    combined_name = timestamp1 + "_" + timestamp2
    logger.info("Current pair: " + combined_name)
    # Read in the Sentinel-1 data product:
    # sentinel_1_m = ProductIO.readProduct(output_dir + master_file + f"_top_sar_split_{POLARIZATIONS}.dim")
    # sentinel_1_s = ProductIO.readProduct(output_dir + slave_file + f"_top_sar_split_{POLARIZATIONS}.dim")
    sentinel_1_m = ProductIO.readProduct(output_dir + master_file)
    sentinel_1_s = ProductIO.readProduct(output_dir + slave_file)
    logger.info("Read")

    ### BACK-GEOCODING
    back_geocoded_prdt = sp.back_geocoding([sentinel_1_s, sentinel_1_m])

    ### ENHANCED SPECTRAL DIVERSITY
    esd_prdt = sp.enhanced_spectral_diversity(back_geocoded_prdt)

    ######################## INTERFEROGRAM PROCESSING TO GET DINSAR ########################
    ### INTERFEROGRAM
    interferogram_prdt = sp.interferogram(esd_prdt)

    ### TOPSAR DEBURST
    deburst_prdt = sp.top_sar_deburst(interferogram_prdt, POLARIZATIONS)
    deburst_path = interferogram_dir + combined_name + f'_deburst_{POLARIZATIONS}'
    ProductIO.writeProduct(deburst_prdt, deburst_path, "BEAM-DIMAP")
    logger.info('Write done')

    ### TOPO PHASE REMOVAL
    in_deburst_prdt = ProductIO.readProduct(deburst_path + '.dim')
    tpr_prdt = sp.topo_phase_removal(in_deburst_prdt)

    ### MULTILOOK
    multilook_prdt = sp.multilook(tpr_prdt)

    ### GOLDSTEIN PHASE FILTERING
    goldstein_prdt = sp.goldstein_phase_filtering(multilook_prdt)
    goldstein_path = interferogram_dir + combined_name + f'_goldstein_{POLARIZATIONS}'

    ProductIO.writeProduct(goldstein_prdt, goldstein_path, "BEAM-DIMAP")
    logger.info('Write done')

    # ### GET COHERENCE
    # # terrain correction
    # tc_goldstein_prdt = sp.terrain_correction(goldstein_prdt, snappyconfigs.UTM_WGS84, default_pixel_spacing)
    # is_found = False
    # for src_band in tc_goldstein_prdt.getBands():
    #     band_name = src_band.getName()
    #     if band_name.startswith('coh'):
    #         coh_prdt = sp.subset(tc_goldstein_prdt, None, band_name)
    #         coh_path = interferogram_dir + combined_name + f'_coh_{POLARIZATIONS}'
    #         ProductIO.writeProduct(coh_prdt, coh_path, 'GeoTIFF')
    #         is_found = True
    #         break
    # if not is_found:
    #     logger.critical("No coherence band is found in interferogram product!")

    ####################### PHASE UNWRAPPING ########################
    ### SNAPHU EXPORT
    in_goldstein_prdt = ProductIO.readProduct(goldstein_path + '.dim')
    snaphu_output_path = interferogram_dir + SNAPHU_PATH + combined_name + f'_{POLARIZATIONS}' + '\\'
    snaphu_export_prdt = sp.snaphu_export(in_goldstein_prdt,
                                          snaphu_output_path)
    ProductIO.writeProduct(snaphu_export_prdt, snaphu_output_path, "Snaphu")
    logger.info("Snaphu Export done")

    ### Unwrapping
    call_snaphu_command(snaphu_output_path)

    unwrapped_phase_prdt = None
    for file in os.listdir(snaphu_output_path):
        if file.endswith('.hdr') and 'UnwPhase' in file:
            unwrapped_phase_prdt = ProductIO.readProduct(snaphu_output_path +
                                                         file)
    if unwrapped_phase_prdt is None:
        logger.critical(
            f'Unwrapped phase product not found in {snaphu_output_path} for phase unwrapping'
        )
        exit(1)

    # ### SNAPHU IMPORT
    snaphu_import_prdt = sp.snaphu_import(
        [unwrapped_phase_prdt, in_goldstein_prdt])
    snaphu_import_path = interferogram_dir + combined_name + f'_snaphu_import_{POLARIZATIONS}'
    ProductIO.writeProduct(snaphu_import_prdt, snaphu_import_path,
                           "BEAM-DIMAP")

    ### BandMaths
    in_snaphu_import_prdt = ProductIO.readProduct(snaphu_import_path + '.dim')
    unwrapped_phase_prdt_name = re.sub("\\..*$", "",
                                       unwrapped_phase_prdt.getName())
    unwrapped_phase_prdt_name = unwrapped_phase_prdt_name.replace(
        'UnwPhase', 'Unw_Phase')
    unwrapped_phase_prdt_name = unwrapped_phase_prdt_name.replace('_VV', '')
    vert_disp_prdt = sp.band_math(
        in_snaphu_import_prdt, 'vert_disp',
        f'({unwrapped_phase_prdt_name} * 0.056) / (-4 * PI * cos(rad(incident_angle)))'
    )

    ### GEOCODING / TERRAIN CORRECTION
    terrain_corrected_prdt = sp.terrain_correction(vert_disp_prdt,
                                                   snappyconfigs.UTM_WGS84)

    ### SUBSET
    subset_prdt = sp.subset(terrain_corrected_prdt, TEXANA_WKT)
    subset_path = interferogram_dir + combined_name + f'_vert_disp_subset_{POLARIZATIONS}'
    ProductIO.writeProduct(subset_prdt, subset_path, "BEAM-DIMAP")