Example #1
0
pixels = 1317

pg.offset_tracking(offsets, ccp, a_par_file, off_par, disp_map, 2, '-', 0)

pg.lin_comb_cpx(1, disp_map, 0, 0, 0.16667, 0, gnd, pixels, 1, 0, 1, 1, 1)

geocoded_width = 3138

#convert complex offsets to real magnitude
pg.cpx_to_real(gnd,\
               #input complex data

               offsets_real,\
               #output real data

               pixels,\
               #Pixels 1317?

               3) #Magnitude

pg.gc_map(coreg_slc_par, off_par, dem_par_name, dem_name, dem_seg_par,
          vel_dem_seg, vel_lut)

pg.geocode_back(offsets_real, pixels, vel_lut, vel_geo, geocoded_width, '-', 3,
                0)

pg.swap_bytes(vel_geo, vel_geo_swab, 4)

pg.data2geotiff(dem_seg_par, vel_geo_swab, 2, vel_tif)
def Tide_correct(pair):
    
    
    os.chdir(path + pair)
    
    pre_date_str = pair[7:22]
    pre_date = datetime.strptime(pre_date_str,'%Y%m%d_%H%M%S') #
    post_date_str = pair[41:56]
    post_date = datetime.strptime(post_date_str,'%Y%m%d_%H%M%S')
    timedelta_between = post_date - pre_date
    interval = 1/(timedelta_between / timedelta (days=1)) # Returns Fraction to multiply by for meters per day
    print(interval)
    pair_delay = timedelta_between.days
    
    images = [f for f in os.listdir(os.curdir) if os.path.isdir(f)]
    
    def date(x):
            return(x[7:15])
        
    images = sorted(images, key = date) 
    image_a = images[0]
    image_b = images[1]
    
    
    mli_par = image_a + '/' + image_a + '.mli_50_par'
    mli_parfile = pg.ParFile(mli_par)
    
    pixels = mli_parfile.get_value('range_samples')
    lines = mli_parfile.get_value('azimuth_lines')
    
    dem_seg_par_file =  image_a + '/dem_seg_par'
    seg_dem_par = pg.ParFile(dem_seg_par_file)

    geo_width = seg_dem_par.get_value('width', dtype = int)
    geo_lines = seg_dem_par.get_value('nlines', dtype = int)
    
    tide_path = '/geog/data/whale/alpha/jizzard/S1/Ferrigno/tide/'
    vel_map = pair + '.filt.disp' #fcomplex
    #tide_dz_sar_flip = pair + '.sar.tide_dz.flip'
    tide_dz_sar = pair + '.sar.tide_dz'
    inc_angle_sar= image_a + '/' + image_a + '.inc_ang.sar' #float, radians
    vel_out =  pair + '.gnd_detide' #fcomplex
    
    
 
    
    vel_detide_real = pair + '.detide.real'
    vel_out_perday = pair + '.vel.detide.gnd'
    
    os.system(tide_path + 'remove_tidal_offset ' + vel_map + ' ' + tide_dz_sar + ' '\
              + inc_angle_sar + ' ' + str(pair_delay) + ' ' + vel_out + ' '\
              + str(pixels) + ' ' + str(lines))
    
        
    pg.lin_comb_cpx(1, vel_out, 0, 0, interval, 0, vel_out_perday, pixels, 1, 0, 1, 1, 1)
    
    pg.cpx_to_real(vel_out_perday, vel_detide_real, pixels, 3)
    pg.ras_linear(vel_detide_real,pixels,1,'-',1,1,0.0,1.0,1,vel_detide_real + '.bmp' ) 
    
    
    dem2sar_lut = image_a + '/' + image_a + '.dem2sar.lut'
    
    vel_detide_real_geo = vel_detide_real + '.geo'
    vel_detide_real_geo_swab = vel_detide_real_geo + '.swab'
    vel_detide_tif = vel_detide_real_geo + '.tif'    

    
    
    
    
    pg.geocode_back(vel_detide_real, pixels, dem2sar_lut, vel_detide_real_geo, geo_width, '-', '-', 0)
    
    pg.ras_linear(vel_detide_real_geo, geo_width ,1,'-',1,1,0.0,1.0,1,vel_detide_real_geo + '.bmp' ) 
    
    pg.swap_bytes(vel_detide_real_geo, vel_detide_real_geo_swab, 4)
    
    dem_seg_par = image_a + '/dem_seg_par'
    
    pg.data2geotiff(dem_seg_par, vel_detide_real_geo_swab, 2, vel_detide_tif)
    
    geo_tide_dz = pair + '.geo.tide_dz'
    geo_tide_diz_tif = geo_tide_dz + '.tif'
    tide_dz_swab = geo_tide_dz + '.swab'
    pg.swap_bytes(geo_tide_dz, tide_dz_swab, 4)
    pg.data2geotiff(dem_seg_par, tide_dz_swab, 2, geo_tide_diz_tif)
Example #3
0
#calculate Geocoding lut
pg.gec_map(a_par_file,\
           int_off_par,\
           dem_par,\
           0,\
           dem_seg_par,\
           lut) # Output

dem_seg_par_obj = pg.ParFile(dem_seg_par)  #dem_seg_par
geocoded_width = dem_seg_par_obj.get_value('width', dtype=int)
print(geocoded_width)

#Geocode to Map coordinates
pg.geocode_back(int_flt, #input\
                mli_width,#width\
                lut,\
                flt_geo, #Output\
                geocoded_width,0,\
                1, 1)


pg.cpx_to_real(flt_geo,\
               phase_geo,\
               geocoded_width,\
               4)#Phase

pg.swap_bytes(phase_geo, phase_geo_swab, 4)

pg.data2geotiff(dem_seg_par, phase_geo_swab, 2, phase_tif)
def Get_lut(image, dem, dem_par):
    
    os.chdir(unzipped_path + image) 
    
    slc = image + '.slc'
    slc_par = image + '.par.slc'
    mli = image + '.mli_50'
    mli_par = image + '.mli_50_par'
    

    
    pg.multi_look(slc,\
                 slc_par,\
                 mli,\
                 mli_par,\
                 50,10)
    
    #dem_seg_par = image + '.dem_seg_par'
    dem_seg_par=  'dem_seg_par'
    dem_seg = image + '.dem'
    dem2sar_lookup_table = image + '.dem2sar.lut'
    sim_sar = image + '.sim_sar'
    surface_zenith = image + '.zen'
    normal_orientation = image + '.nml_ori'
    inc_angle = image + '.inc_ang'
    proj_angle = image + '.proj_ang'
    area_factor = '-'
    layover_shadow = '-'
    frame = '-'
    ls_mode = 2 #Possibly 1?
    
    
    
    #Maps Slant Range to Ground Range
    pg.gc_map(mli_par,\
              '-',\
              dem_par,\
              dem,\
              dem_seg_par,\
              dem_seg,\
              dem2sar_lookup_table,\
              1,1,\
              sim_sar,\
              surface_zenith,\
              normal_orientation,\
              inc_angle,\
              proj_angle,\
              area_factor,\
              layover_shadow,\
              frame,\
              ls_mode)
    
    
    mli_par_file = pg.ParFile(mli_par)
    mli_pixels = mli_par_file.get_value('range_samples')
    mli_lines = mli_par_file.get_value('azimuth_lines')
    
    print('mli_pixels: {}, mli_lines: {}'.format(mli_pixels, mli_lines))
    
    
    dem_seg_par_file = pg.ParFile(dem_seg_par)
    pixels = dem_seg_par_file.get_value('width')
    lines = dem_seg_par_file.get_value('nlines')
    
    print('pixels: {}, lines = {}'.format(pixels, lines))
    
    
    
    mli_geo = image + ('mli_50_geo')
    
    #geocode mli to ground range
    pg.geocode_back(mli,\
                    mli_pixels,\
                    dem2sar_lookup_table,\
                    mli_geo,\
                    pixels,\
                    lines,\
                    3,0)
        
    pg.ras_linear(mli_geo,\
              pixels,\
              '-','-','-','-','-','-','-',\
              mli_geo + '.bmp')
    
    pg.ras_linear(mli,\
              mli_pixels,\
              '-','-','-','-','-','-','-',\
              mli + '.bmp')   
        
    mli_geo_swab = mli_geo + '.swab'
    
    pg.swap_bytes(mli_geo, mli_geo_swab, 4)
    
    mli_geotif = image + '.mli_50.tif'
    
    pg.data2geotiff(dem_seg_par,\
                    mli_geo_swab,\
                    2,\
                    mli_geotif)
    
    os.remove(mli_geo_swab)
    
    sar2dem_lookup_table = image + '.sar2dem.lut'
    
    
    pg.gc_map_inversion(dem2sar_lookup_table,\
                        pixels,\
                        sar2dem_lookup_table,\
                        mli_pixels,\
                        mli_lines,\
                        1,2)
    
    inc_angle_sar = inc_angle + '.sar'
    

         
    pg.geocode_back(inc_angle,\
                    pixels,\
                    sar2dem_lookup_table,\
                    inc_angle_sar,\
                    mli_pixels,\
                    mli_lines)
        
    
    
    pg.ras_linear(inc_angle,\
              pixels,\
              '-','-','-','-','-','-','-',\
              inc_angle + '.bmp')
        
    pg.ras_linear(inc_angle_sar,\
              mli_pixels,\
              '-','-','-','-','-','-','-',\
              inc_angle_sar + '.bmp')