def generateAutoriftProduct(indir_m, indir_s, grid_location, init_offset, search_range, chip_size_min, chip_size_max, offset2vx, offset2vy, stable_surface_mask, optical_flag, nc_sensor, mpflag, geogrid_run_info=None): import numpy as np import time # from components.contrib.geo_autoRIFT.autoRIFT import __version__ as version from autoRIFT import __version__ as version if optical_flag == 1: data_m, data_s = loadProductOptical(indir_m, indir_s) # test with lena/Venus image # import scipy.io as sio # conts = sio.loadmat(indir_m) # data_m = conts['I'] # data_s = conts['I1'] else: data_m = loadProduct(indir_m) data_s = loadProduct(indir_s) xGrid = None yGrid = None Dx0 = None Dy0 = None SRx0 = None SRy0 = None CSMINx0 = None CSMINy0 = None CSMAXx0 = None CSMAXy0 = None SSM = None noDataMask = None nodata = None if grid_location is not None: ds = gdal.Open(grid_location) tran = ds.GetGeoTransform() proj = ds.GetProjection() srs = ds.GetSpatialRef() band = ds.GetRasterBand(1) nodata = band.GetNoDataValue() xGrid = band.ReadAsArray() noDataMask = (xGrid == nodata) band = ds.GetRasterBand(2) yGrid = band.ReadAsArray() band = None ds = None if init_offset is not None: ds = gdal.Open(init_offset) band = ds.GetRasterBand(1) Dx0 = band.ReadAsArray() band = ds.GetRasterBand(2) Dy0 = band.ReadAsArray() band = None ds = None if search_range is not None: ds = gdal.Open(search_range) band = ds.GetRasterBand(1) SRx0 = band.ReadAsArray() band = ds.GetRasterBand(2) SRy0 = band.ReadAsArray() band = None ds = None if chip_size_min is not None: ds = gdal.Open(chip_size_min) band = ds.GetRasterBand(1) CSMINx0 = band.ReadAsArray() band = ds.GetRasterBand(2) CSMINy0 = band.ReadAsArray() band = None ds = None if chip_size_max is not None: ds = gdal.Open(chip_size_max) band = ds.GetRasterBand(1) CSMAXx0 = band.ReadAsArray() band = ds.GetRasterBand(2) CSMAXy0 = band.ReadAsArray() band = None ds = None if stable_surface_mask is not None: ds = gdal.Open(stable_surface_mask) band = ds.GetRasterBand(1) SSM = band.ReadAsArray() SSM = SSM.astype('bool') band = None ds = None Dx, Dy, InterpMask, ChipSizeX, ScaleChipSizeY, SearchLimitX, SearchLimitY, origSize, noDataMask = runAutorift( data_m, data_s, xGrid, yGrid, Dx0, Dy0, SRx0, SRy0, CSMINx0, CSMINy0, CSMAXx0, CSMAXy0, noDataMask, optical_flag, nodata, mpflag, geogrid_run_info=geogrid_run_info, ) if optical_flag == 0: Dy = -Dy DX = np.zeros(origSize, dtype=np.float32) * np.nan DY = np.zeros(origSize, dtype=np.float32) * np.nan INTERPMASK = np.zeros(origSize, dtype=np.float32) CHIPSIZEX = np.zeros(origSize, dtype=np.float32) SEARCHLIMITX = np.zeros(origSize, dtype=np.float32) SEARCHLIMITY = np.zeros(origSize, dtype=np.float32) DX[0:Dx.shape[0], 0:Dx.shape[1]] = Dx DY[0:Dy.shape[0], 0:Dy.shape[1]] = Dy INTERPMASK[0:InterpMask.shape[0], 0:InterpMask.shape[1]] = InterpMask CHIPSIZEX[0:ChipSizeX.shape[0], 0:ChipSizeX.shape[1]] = ChipSizeX SEARCHLIMITX[0:SearchLimitX.shape[0], 0:SearchLimitX.shape[1]] = SearchLimitX SEARCHLIMITY[0:SearchLimitY.shape[0], 0:SearchLimitY.shape[1]] = SearchLimitY DX[noDataMask] = np.nan DY[noDataMask] = np.nan INTERPMASK[noDataMask] = 0 CHIPSIZEX[noDataMask] = 0 SEARCHLIMITX[noDataMask] = 0 SEARCHLIMITY[noDataMask] = 0 if SSM is not None: SSM[noDataMask] = False import scipy.io as sio sio.savemat('offset.mat', { 'Dx': DX, 'Dy': DY, 'InterpMask': INTERPMASK, 'ChipSizeX': CHIPSIZEX }) # ##################### Uncomment for debug mode # sio.savemat('debug.mat',{'Dx':DX,'Dy':DY,'InterpMask':INTERPMASK,'ChipSizeX':CHIPSIZEX,'ScaleChipSizeY':ScaleChipSizeY,'SearchLimitX':SEARCHLIMITX,'SearchLimitY':SEARCHLIMITY}) # conts = sio.loadmat('debug.mat') # DX = conts['Dx'] # DY = conts['Dy'] # INTERPMASK = conts['InterpMask'] # CHIPSIZEX = conts['ChipSizeX'] # ScaleChipSizeY = conts['ScaleChipSizeY'] # SEARCHLIMITX = conts['SearchLimitX'] # SEARCHLIMITY = conts['SearchLimitY'] # ##################### netcdf_file = None if grid_location is not None: t1 = time.time() print("Write Outputs Start!!!") # Create the GeoTiff driver = gdal.GetDriverByName('GTiff') outRaster = driver.Create("offset.tif", int(xGrid.shape[1]), int(xGrid.shape[0]), 4, gdal.GDT_Float32) outRaster.SetGeoTransform(tran) outRaster.SetProjection(proj) outband = outRaster.GetRasterBand(1) outband.WriteArray(DX) outband.FlushCache() outband = outRaster.GetRasterBand(2) outband.WriteArray(DY) outband.FlushCache() outband = outRaster.GetRasterBand(3) outband.WriteArray(INTERPMASK) outband.FlushCache() outband = outRaster.GetRasterBand(4) outband.WriteArray(CHIPSIZEX) outband.FlushCache() if offset2vx is not None: ds = gdal.Open(offset2vx) band = ds.GetRasterBand(1) offset2vx_1 = band.ReadAsArray() band = ds.GetRasterBand(2) offset2vx_2 = band.ReadAsArray() band = None ds = None ds = gdal.Open(offset2vy) band = ds.GetRasterBand(1) offset2vy_1 = band.ReadAsArray() band = ds.GetRasterBand(2) offset2vy_2 = band.ReadAsArray() band = None ds = None VX = offset2vx_1 * DX + offset2vx_2 * DY VY = offset2vy_1 * DX + offset2vy_2 * DY VX = VX.astype(np.float32) VY = VY.astype(np.float32) ############ write velocity output in Geotiff format outRaster = driver.Create("velocity.tif", int(xGrid.shape[1]), int(xGrid.shape[0]), 2, gdal.GDT_Float32) outRaster.SetGeoTransform(tran) outRaster.SetProjection(proj) outband = outRaster.GetRasterBand(1) outband.WriteArray(VX) outband.FlushCache() outband = outRaster.GetRasterBand(2) outband.WriteArray(VY) outband.FlushCache() ############ prepare for netCDF packaging if nc_sensor is not None: if geogrid_run_info is None: vxrefname = str.split( runCmd('fgrep "Velocities:" testGeogrid.txt'))[1] vyrefname = str.split( runCmd('fgrep "Velocities:" testGeogrid.txt'))[2] sxname = str.split( runCmd('fgrep "Slopes:" testGeogrid.txt') )[1][:-4] + "s.tif" syname = str.split( runCmd('fgrep "Slopes:" testGeogrid.txt') )[2][:-4] + "s.tif" maskname = str.split( runCmd('fgrep "Slopes:" testGeogrid.txt') )[2][:-8] + "sp.tif" xoff = int( str.split( runCmd( 'fgrep "Origin index (in DEM) of geogrid:" testGeogrid.txt' ))[6]) yoff = int( str.split( runCmd( 'fgrep "Origin index (in DEM) of geogrid:" testGeogrid.txt' ))[7]) xcount = int( str.split( runCmd( 'fgrep "Dimensions of geogrid:" testGeogrid.txt' ))[3]) ycount = int( str.split( runCmd( 'fgrep "Dimensions of geogrid:" testGeogrid.txt' ))[5]) else: vxrefname = geogrid_run_info['vxname'] vyrefname = geogrid_run_info['vyname'] sxname = geogrid_run_info['sxname'] syname = geogrid_run_info['syname'] maskname = geogrid_run_info['maskname'] xoff = geogrid_run_info['xoff'] yoff = geogrid_run_info['yoff'] xcount = geogrid_run_info['xcount'] ycount = geogrid_run_info['ycount'] ds = gdal.Open(vxrefname) band = ds.GetRasterBand(1) VXref = band.ReadAsArray(xoff, yoff, xcount, ycount) ds = None band = None ds = gdal.Open(vyrefname) band = ds.GetRasterBand(1) VYref = band.ReadAsArray(xoff, yoff, xcount, ycount) ds = None band = None ds = gdal.Open(sxname) band = ds.GetRasterBand(1) SX = band.ReadAsArray(xoff, yoff, xcount, ycount) ds = None band = None ds = gdal.Open(syname) band = ds.GetRasterBand(1) SY = band.ReadAsArray(xoff, yoff, xcount, ycount) ds = None band = None ds = gdal.Open(maskname) band = ds.GetRasterBand(1) MM = band.ReadAsArray(xoff, yoff, xcount, ycount) ds = None band = None DXref = offset2vy_2 / ( offset2vx_1 * offset2vy_2 - offset2vx_2 * offset2vy_1 ) * VXref - offset2vx_2 / (offset2vx_1 * offset2vy_2 - offset2vx_2 * offset2vy_1) * VYref DYref = offset2vx_1 / ( offset2vx_1 * offset2vy_2 - offset2vx_2 * offset2vy_1 ) * VYref - offset2vy_1 / (offset2vx_1 * offset2vy_2 - offset2vx_2 * offset2vy_1) * VXref stable_count = np.sum(SSM & np.logical_not(np.isnan(DX)) & (DX - DXref > -5) & (DX - DXref < 5) & (DY - DYref > -5) & (DY - DYref < 5)) if stable_count == 0: stable_shift_applied = 0 else: stable_shift_applied = 1 if stable_shift_applied == 1: temp = DX.copy() - DXref.copy() temp[np.logical_not(SSM)] = np.nan dx_mean_shift = np.median(temp[(temp > -5) & (temp < 5)]) DX = DX - dx_mean_shift temp = DY.copy() - DYref.copy() temp[np.logical_not(SSM)] = np.nan dy_mean_shift = np.median(temp[(temp > -5) & (temp < 5)]) DY = DY - dy_mean_shift else: dx_mean_shift = 0.0 dy_mean_shift = 0.0 VX = offset2vx_1 * DX + offset2vx_2 * DY VY = offset2vy_1 * DX + offset2vy_2 * DY VX = VX.astype(np.float32) VY = VY.astype(np.float32) ######################################################################################## ############ netCDF packaging for Sentinel and Landsat dataset; can add other sensor format as well if nc_sensor == "S": if geogrid_run_info is None: chipsizex0 = float( str.split( runCmd( 'fgrep "Smallest Allowable Chip Size in m:" testGeogrid.txt' ))[-1]) rangePixelSize = float( str.split( runCmd( 'fgrep "Ground range pixel size:" testGeogrid.txt' ))[4]) azimuthPixelSize = float( str.split( runCmd( 'fgrep "Azimuth pixel size:" testGeogrid.txt' ))[3]) dt = float( str.split( runCmd('fgrep "Repeat Time:" testGeogrid.txt')) [2]) epsg = float( str.split( runCmd('fgrep "EPSG:" testGeogrid.txt'))[1]) # print (str(rangePixelSize)+" "+str(azimuthPixelSize)) else: chipsizex0 = geogrid_run_info['chipsizex0'] rangePixelSize = geogrid_run_info['XPixelSize'] azimuthPixelSize = geogrid_run_info['YPixelSize'] dt = geogrid_run_info['dt'] epsg = geogrid_run_info['epsg'] runCmd('topsinsar_filename.py') # import scipy.io as sio conts = sio.loadmat('topsinsar_filename.mat') master_filename = conts['master_filename'][0] slave_filename = conts['slave_filename'][0] master_dt = conts['master_dt'][0] slave_dt = conts['slave_dt'][0] master_split = str.split(master_filename, '_') slave_split = str.split(slave_filename, '_') import netcdf_output as no pair_type = 'radar' detection_method = 'feature' coordinates = 'radar' roi_valid_percentage = int( round( np.sum(CHIPSIZEX != 0) / np.sum(SEARCHLIMITX != 0) * 1000.0)) / 1000 # out_nc_filename = 'Jakobshavn.nc' PPP = roi_valid_percentage * 100 out_nc_filename = f"./{master_filename[0:-4]}_X_{slave_filename[0:-4]}" \ f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc" CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2 from datetime import date d0 = date(np.int(master_split[5][0:4]), np.int(master_split[5][4:6]), np.int(master_split[5][6:8])) d1 = date(np.int(slave_split[5][0:4]), np.int(slave_split[5][4:6]), np.int(slave_split[5][6:8])) date_dt_base = d1 - d0 date_dt = np.float64(np.abs(date_dt_base.days)) if date_dt_base.days < 0: date_ct = d1 + (d0 - d1) / 2 date_center = date_ct.strftime("%Y%m%d") else: date_ct = d0 + (d1 - d0) / 2 date_center = date_ct.strftime("%Y%m%d") IMG_INFO_DICT = { 'mission_img1': master_split[0][0], 'sensor_img1': 'C', 'satellite_img1': master_split[0][1:3], 'acquisition_img1': master_dt, 'absolute_orbit_number_img1': master_split[7], 'mission_data_take_ID_img1': master_split[8], 'product_unique_ID_img1': master_split[9][0:4], 'mission_img2': slave_split[0][0], 'sensor_img2': 'C', 'satellite_img2': slave_split[0][1:3], 'acquisition_img2': slave_dt, 'absolute_orbit_number_img2': slave_split[7], 'mission_data_take_ID_img2': slave_split[8], 'product_unique_ID_img2': slave_split[9][0:4], 'date_dt': date_dt, 'date_center': date_center, 'roi_valid_percentage': roi_valid_percentage, 'autoRIFT_software_version': version } error_vector = np.array( [[0.0356, 0.0501, 0.0266, 0.0622, 0.0357, 0.0501], [0.5194, 1.1638, 0.3319, 1.3701, 0.5191, 1.1628]]) netcdf_file = no.netCDF_packaging( VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SX, SY, offset2vx_1, offset2vx_2, offset2vy_1, offset2vy_2, MM, VXref, VYref, rangePixelSize, azimuthPixelSize, dt, epsg, srs, tran, out_nc_filename, pair_type, detection_method, coordinates, IMG_INFO_DICT, stable_count, stable_shift_applied, dx_mean_shift, dy_mean_shift, error_vector) elif nc_sensor == "L": if geogrid_run_info is None: chipsizex0 = float( str.split( runCmd( 'fgrep "Smallest Allowable Chip Size in m:" testGeogrid.txt' ))[-1]) XPixelSize = float( str.split( runCmd( 'fgrep "X-direction pixel size:" testGeogrid.txt' ))[3]) YPixelSize = float( str.split( runCmd( 'fgrep "Y-direction pixel size:" testGeogrid.txt' ))[3]) epsg = float( str.split( runCmd('fgrep "EPSG:" testGeogrid.txt'))[1]) else: chipsizex0 = geogrid_run_info['chipsizex0'] XPixelSize = geogrid_run_info['XPixelSize'] YPixelSize = geogrid_run_info['YPixelSize'] epsg = geogrid_run_info['epsg'] master_path = indir_m slave_path = indir_s import os master_filename = os.path.basename(master_path) slave_filename = os.path.basename(slave_path) master_split = str.split(master_filename, '_') slave_split = str.split(slave_filename, '_') # master_MTL_path = master_path[:-6]+'MTL.txt' # slave_MTL_path = slave_path[:-6]+'MTL.txt' # # master_time = str.split(str.split(runCmd('fgrep "SCENE_CENTER_TIME" '+master_MTL_path))[2][1:-2],':') # slave_time = str.split(str.split(runCmd('fgrep "SCENE_CENTER_TIME" '+slave_MTL_path))[2][1:-2],':') master_time = ['00', '00', '00'] slave_time = ['00', '00', '00'] from datetime import time as time1 master_time = time1(int(master_time[0]), int(master_time[1]), int(float(master_time[2]))) slave_time = time1(int(slave_time[0]), int(slave_time[1]), int(float(slave_time[2]))) import netcdf_output as no pair_type = 'optical' detection_method = 'feature' coordinates = 'map' roi_valid_percentage = int( round( np.sum(CHIPSIZEX != 0) / np.sum(SEARCHLIMITX != 0) * 1000.0)) / 1000 # out_nc_filename = 'Jakobshavn_opt.nc' PPP = roi_valid_percentage * 100 out_nc_filename = f"./{master_filename[0:-7]}_X_{slave_filename[0:-7]}" \ f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc" CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2 from datetime import date d0 = date(np.int(master_split[3][0:4]), np.int(master_split[3][4:6]), np.int(master_split[3][6:8])) d1 = date(np.int(slave_split[3][0:4]), np.int(slave_split[3][4:6]), np.int(slave_split[3][6:8])) date_dt_base = d1 - d0 date_dt = np.float64(np.abs(date_dt_base.days)) if date_dt_base.days < 0: date_ct = d1 + (d0 - d1) / 2 date_center = date_ct.strftime("%Y%m%d") else: date_ct = d0 + (d1 - d0) / 2 date_center = date_ct.strftime("%Y%m%d") master_dt = master_split[3][0:8] + master_time.strftime( "T%H:%M:%S") slave_dt = slave_split[3][0:8] + slave_time.strftime( "T%H:%M:%S") IMG_INFO_DICT = { 'mission_img1': master_split[0][0], 'sensor_img1': master_split[0][1], 'satellite_img1': np.float64(master_split[0][2:4]), 'correction_level_img1': master_split[1], 'path_img1': np.float64(master_split[2][0:3]), 'row_img1': np.float64(master_split[2][3:6]), 'acquisition_date_img1': master_dt, 'processing_date_img1': master_split[4][0:8], 'collection_number_img1': np.float64(master_split[5]), 'collection_category_img1': master_split[6], 'mission_img2': slave_split[0][0], 'sensor_img2': slave_split[0][1], 'satellite_img2': np.float64(slave_split[0][2:4]), 'correction_level_img2': slave_split[1], 'path_img2': np.float64(slave_split[2][0:3]), 'row_img2': np.float64(slave_split[2][3:6]), 'acquisition_date_img2': slave_dt, 'processing_date_img2': slave_split[4][0:8], 'collection_number_img2': np.float64(slave_split[5]), 'collection_category_img2': slave_split[6], 'date_dt': date_dt, 'date_center': date_center, 'roi_valid_percentage': roi_valid_percentage, 'autoRIFT_software_version': version } error_vector = np.array([57., 57.]) netcdf_file = no.netCDF_packaging( VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SX, SY, offset2vx_1, offset2vx_2, offset2vy_1, offset2vy_2, MM, VXref, VYref, XPixelSize, YPixelSize, None, epsg, srs, tran, out_nc_filename, pair_type, detection_method, coordinates, IMG_INFO_DICT, stable_count, stable_shift_applied, dx_mean_shift, dy_mean_shift, error_vector) elif nc_sensor == "S2": if geogrid_run_info is None: chipsizex0 = float( str.split( runCmd( 'fgrep "Smallest Allowable Chip Size in m:" testGeogrid.txt' ))[-1]) XPixelSize = float( str.split( runCmd( 'fgrep "X-direction pixel size:" testGeogrid.txt' ))[3]) YPixelSize = float( str.split( runCmd( 'fgrep "Y-direction pixel size:" testGeogrid.txt' ))[3]) epsg = float( str.split( runCmd('fgrep "EPSG:" testGeogrid.txt'))[1]) else: chipsizex0 = geogrid_run_info['chipsizex0'] XPixelSize = geogrid_run_info['XPixelSize'] YPixelSize = geogrid_run_info['YPixelSize'] epsg = geogrid_run_info['epsg'] master_path = indir_m slave_path = indir_s master_split = master_path.split('_') slave_split = slave_path.split('_') import os master_filename = master_split[0][ -3:] + '_' + master_split[2] + '_' + master_split[ 4][:3] + '_' + os.path.basename(master_path) slave_filename = slave_split[0][-3:] + '_' + slave_split[ 2] + '_' + slave_split[4][:3] + '_' + os.path.basename( slave_path) master_time = ['00', '00', '00'] slave_time = ['00', '00', '00'] from datetime import time as time1 master_time = time1(int(master_time[0]), int(master_time[1]), int(float(master_time[2]))) slave_time = time1(int(slave_time[0]), int(slave_time[1]), int(float(slave_time[2]))) import netcdf_output as no pair_type = 'optical' detection_method = 'feature' coordinates = 'map' roi_valid_percentage = int( round( np.sum(CHIPSIZEX != 0) / np.sum(SEARCHLIMITX != 0) * 1000.0)) / 1000 PPP = roi_valid_percentage * 100 out_nc_filename = f"./{master_filename[0:-8]}_X_{slave_filename[0:-8]}" \ f"_G{chipsizex0:04.0f}V02_P{np.floor(PPP):03.0f}.nc" CHIPSIZEY = np.round(CHIPSIZEX * ScaleChipSizeY / 2) * 2 from datetime import date d0 = date(np.int(master_split[2][0:4]), np.int(master_split[2][4:6]), np.int(master_split[2][6:8])) d1 = date(np.int(slave_split[2][0:4]), np.int(slave_split[2][4:6]), np.int(slave_split[2][6:8])) date_dt_base = d1 - d0 date_dt = np.float64(np.abs(date_dt_base.days)) if date_dt_base.days < 0: date_ct = d1 + (d0 - d1) / 2 date_center = date_ct.strftime("%Y%m%d") else: date_ct = d0 + (d1 - d0) / 2 date_center = date_ct.strftime("%Y%m%d") master_dt = master_split[2] + master_time.strftime( "T%H:%M:%S") slave_dt = slave_split[2] + slave_time.strftime( "T%H:%M:%S") IMG_INFO_DICT = { 'mission_img1': master_split[0][-3], 'satellite_img1': master_split[0][-2:], 'correction_level_img1': master_split[4][:3], 'acquisition_date_img1': master_dt, 'mission_img2': slave_split[0][-3], 'satellite_img2': slave_split[0][-2:], 'correction_level_img2': slave_split[4][:3], 'acquisition_date_img2': slave_dt, 'date_dt': date_dt, 'date_center': date_center, 'roi_valid_percentage': roi_valid_percentage, 'autoRIFT_software_version': version } error_vector = np.array([57., 57.]) netcdf_file = no.netCDF_packaging( VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SX, SY, offset2vx_1, offset2vx_2, offset2vy_1, offset2vy_2, MM, VXref, VYref, XPixelSize, YPixelSize, None, epsg, srs, tran, out_nc_filename, pair_type, detection_method, coordinates, IMG_INFO_DICT, stable_count, stable_shift_applied, dx_mean_shift, dy_mean_shift, error_vector) elif nc_sensor is None: print('netCDF packaging not performed') else: raise Exception( 'netCDF packaging not supported for the type "{0}"'. format(nc_sensor)) print("Write Outputs Done!!!") print(time.time() - t1) return netcdf_file
'absolute_orbit_number_img2': slave_split[7], 'mission_data_take_ID_img2': slave_split[8], 'product_unique_ID_img2': slave_split[9][0:4], 'date_dt': date_dt, 'date_center': date_center, 'roi_valid_percentage': roi_valid_percentage, 'autoRIFT_software_version': version } error_vector = np.array( [[0.0356, 0.0501, 0.0266, 0.0622, 0.0357, 0.0501], [0.5194, 1.1638, 0.3319, 1.3701, 0.5191, 1.1628]]) no.netCDF_packaging( VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, SSM, SX, SY, offset2vx_1, offset2vx_2, offset2vy_1, offset2vy_2, MM, VXref, VYref, rangePixelSize, azimuthPixelSize, dt, epsg, srs, tran, out_nc_filename, pair_type, detection_method, coordinates, IMG_INFO_DICT, stable_count, stable_shift_applied, dx_mean_shift, dy_mean_shift, error_vector) elif inps.nc_sensor == "L": XPixelSize = float( str.split( runCmd( 'fgrep "X-direction pixel size:" testGeogrid.txt' ))[3]) YPixelSize = float( str.split( runCmd( 'fgrep "Y-direction pixel size:" testGeogrid.txt'
from datetime import date d0 = date(np.int(master_split[5][0:4]),np.int(master_split[5][4:6]),np.int(master_split[5][6:8])) d1 = date(np.int(slave_split[5][0:4]),np.int(slave_split[5][4:6]),np.int(slave_split[5][6:8])) date_dt_base = d1 - d0 date_dt = np.float64(np.abs(date_dt_base.days)) if date_dt_base.days < 0: date_ct = d1 + (d0 - d1)/2 date_center = date_ct.strftime("%Y%m%d") else: date_ct = d0 + (d1 - d0)/2 date_center = date_ct.strftime("%Y%m%d") IMG_INFO_DICT = {'mission_img1':master_split[0][0],'sensor_img1':'C','satellite_img1':master_split[0][1:3],'acquisition_img1':master_split[5][0:8],'absolute_orbit_number_img1':master_split[7],'mission_data_take_ID_img1':master_split[8],'product_unique_ID_img1':master_split[9][0:4],'mission_img2':slave_split[0][0],'sensor_img2':'C','satellite_img2':slave_split[0][1:3],'acquisition_img2':slave_split[5][0:8],'absolute_orbit_number_img2':slave_split[7],'mission_data_take_ID_img2':slave_split[8],'product_unique_ID_img2':slave_split[9][0:4],'date_dt':date_dt,'date_center':date_center,'roi_valid_percentage':roi_valid_percentage,'autoRIFT_software_version':version} no.netCDF_packaging(VX, VY, DX, DY, INTERPMASK, CHIPSIZEX, CHIPSIZEY, rangePixelSize, azimuthPixelSize, dt, epsg, srs, tran, out_nc_filename, pair_type, detection_method, coordinates, IMG_INFO_DICT) elif inps.nc_sensor == "L": XPixelSize = np.abs(float(str.split(runCmd('fgrep "X-direction coordinate:" testGeogrid.txt'))[3])) YPixelSize = np.abs(float(str.split(runCmd('fgrep "Y-direction coordinate:" testGeogrid.txt'))[3])) epsg = float(str.split(runCmd('fgrep "EPSG:" testGeogrid.txt'))[1]) master_filename = inps.indir_m slave_filename = inps.indir_s master_split = str.split(master_filename,'_') slave_split = str.split(slave_filename,'_') import netcdf_output as no version = '1.0.4' pair_type = 'optical'