def reproj_roi(self, out_path, lonw, lone, lats, latn): ''' 根据给定的经纬度方位裁剪AMSR2 L3 数据 :param out_path: :param lonw: :param lone: :param lats: :param latn: :return: ''' corner_lon = [lonw, lone, lone, lonw] corner_lat = [lats, lats, latn, latn] corner_xy = self.proj_to_nsidc_sea_ice_stere_n(corner_lon, corner_lat) min_x = corner_xy[0].min() max_x = corner_xy[0].max() min_y = corner_xy[1].min() max_y = corner_xy[1].max() start_x = min_x - self.lu_x end_x = max_x - self.lu_x start_x_pixel = int(start_x / self.gsd) end_x_pixel = int(np.ceil(end_x / self.gsd)) if start_x_pixel < 0: start_x_pixel = 0 if end_x_pixel >= self.data_shape[1]: end_x_pixel = self.data_shape[1] - 1 start_y = self.lu_y - max_y end_y = self.lu_y - min_y start_y_pixel = int(start_y / self.gsd) end_y_pixel = int(np.ceil(end_y / self.gsd)) if start_y_pixel < 0: start_y_pixel = 0 if end_y_pixel >= self.data_shape[0]: end_y_pixel = self.data_shape[0] - 1 # 获得区域内的亮温 sub_nh_89h = self.nh_89h[start_y_pixel:end_y_pixel, start_x_pixel:end_x_pixel].copy() sub_nh_89v = self.nh_89v[start_y_pixel:end_y_pixel, start_x_pixel:end_x_pixel].copy() origin_x = start_x_pixel * self.gsd + self.lu_x origin_y = self.lu_y - start_y_pixel * self.gsd file_format = 'GTiff' driver = gdal.GetDriverByName(file_format) dst_ds = driver.Create(out_path, xsize=sub_nh_89h.shape[1], ysize=sub_nh_89h.shape[0], bands=2, eType=gdal.GDT_Int32) srs = NSR(3411) dst_ds.SetProjection(srs.ExportToWkt()) dst_ds.SetGeoTransform([origin_x, self.gsd, 0, origin_y, 0, -self.gsd]) band1 = dst_ds.GetRasterBand(1) band1.WriteArray(sub_nh_89h) band2 = dst_ds.GetRasterBand(2) band2.WriteArray(sub_nh_89v) dst_ds = None
def test_init_from_wkt(self): nsr = NSR( 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,'\ 'AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,'\ 'AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],'\ 'AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]') self.assertEqual(type(nsr), NSR) self.assertEqual(nsr.Validate(), 0) self.assertTrue('longlat' in nsr.ExportToProj4())
def test_integrated(self): ''' Shall use all developed functions for feature tracking''' lon1pm, lat1pm = np.meshgrid(np.linspace(-3, 2, 50), np.linspace(86.4, 86.8, 50)) sid = SeaIceDrift(self.testFiles[0], self.testFiles[1]) uft, vft, lon1ft, lat1ft, lon2ft, lat2ft = sid.get_drift_FT() upm, vpm, apm, rpm, hpm, lon2pm, lat2pm = sid.get_drift_PM( lon1pm, lat1pm, lon1ft, lat1ft, lon2ft, lat2ft) lon1, lat1 = sid.n1.get_border() lon2, lat2 = sid.n2.get_border() sid.n1.reproject(Domain(NSR().wkt, '-te -3 86.4 2 86.8 -ts 500 500')) s01 = sid.n1['sigma0_HV'] sid.n2.reproject(Domain(NSR().wkt, '-te -3 86.4 2 86.8 -ts 500 500')) s02 = sid.n2['sigma0_HV'] plt.imshow(s01, extent=[-3, 2, 86.4, 86.8], cmap='gray', aspect=12) plt.quiver(lon1ft, lat1ft, uft, vft, color='r', angles='xy', scale_units='xy', scale=0.5) plt.plot(lon2, lat2, '.-r') plt.xlim([-3, 2]) plt.ylim([86.4, 86.8]) plt.savefig('sea_ice_drift_tests_%s_img1_ft.png' % inspect.currentframe().f_code.co_name, dpi=150, bbox_inches='tight', pad_inches=0) plt.close('all') plt.imshow(s02, extent=[-3, 2, 86.4, 86.8], cmap='gray', aspect=12) gpi = rpm > 0.4 plt.quiver(lon1pm[gpi], lat1pm[gpi], upm[gpi], vpm[gpi], rpm[gpi] * hpm[gpi], angles='xy', scale_units='xy', scale=0.5) plt.plot(lon1, lat1, '.-r') plt.xlim([-3, 2]) plt.ylim([86.4, 86.8]) plt.savefig('sea_ice_drift_tests_%s_img2_pm.png' % inspect.currentframe().f_code.co_name, dpi=150, bbox_inches='tight', pad_inches=0) plt.close('all')
def get_drift_vectors(n1, x1, y1, n2, x2, y2, nsr=NSR(), **kwargs): ''' Find ice drift speed m/s Parameters ---------- n1 : First Nansat object x1 : 1D vector - X coordinates of keypoints on image 1 y1 : 1D vector - Y coordinates of keypoints on image 1 n2 : Second Nansat object x1 : 1D vector - X coordinates of keypoints on image 2 y1 : 1D vector - Y coordinates of keypoints on image 2 nsr: Nansat.NSR(), projection that defines the grid Returns ------- u : 1D vector - eastward ice drift speed v : 1D vector - northward ice drift speed lon1 : 1D vector - longitudes of source points lat1 : 1D vector - latitudes of source points lon2 : 1D vector - longitudes of destination points lat2 : 1D vector - latitudes of destination points ''' # convert x,y to lon, lat lon1, lat1 = n1.transform_points(x1, y1) lon2, lat2 = n2.transform_points(x2, y2) # create domain that converts lon/lat to units of the projection d = Domain(nsr, '-te -10 -10 10 10 -tr 1 1') # find displacement in needed units x1, y1 = d.transform_points(lon1, lat1, 1) x2, y2 = d.transform_points(lon2, lat2, 1) return x2 - x1, y1 - y2, lon1, lat1, lon2, lat2
def proj_to_wgs84_nsidc_sea_ice_stere_n(self, x, y, inverse=False): ''' :param x: 1D array -->lon :param y: 1D array -->lat :param iinverse: :return: ''' # WGS84 srs_src = NSR(4326) # WGS 84 / NSIDC Sea Ice Polar Stereographic srs_dst = NSR(3413) src_points = (x, y) if inverse: dst_point = VRT.transform_coordinates(srs_dst, src_points, srs_src) else: dst_point = VRT.transform_coordinates(srs_src, src_points, srs_dst) return dst_point
def test_reproject_gcp_to_stere(self): ''' Shall change projection of GCPs to stere ''' n1pro = reproject_gcp_to_stere(self.n1) self.assertTrue(n1pro.vrt.tps) self.assertTrue(len(n1pro.vrt.dataset.GetGCPs()) > 0) self.assertTrue((NSR(n1pro.vrt.dataset.GetGCPProjection()) .ExportToProj4().startswith('+proj=stere')))
def test_integrated(self, mock_get_invalid_mask): ''' Shall use all developed functions for feature tracking''' invalid_mask = np.zeros((500,500)).astype(bool) invalid_mask[:100,:100] = True mock_get_invalid_mask.return_value = invalid_mask sid = SeaIceDrift(self.testFiles[0], self.testFiles[1]) lon1b, lat1b = sid.n1.get_border() lon1pm, lat1pm = np.meshgrid(np.linspace(lon1b.min(), lon1b.max(), 50), np.linspace(lat1b.min(), lat1b.max(), 50)) uft, vft, lon1ft, lat1ft, lon2ft, lat2ft = sid.get_drift_FT() upm, vpm, apm, rpm, hpm, lon2pm, lat2pm = sid.get_drift_PM( lon1pm, lat1pm, lon1ft, lat1ft, lon2ft, lat2ft) lon1, lat1 = sid.n1.get_border() lon2, lat2 = sid.n2.get_border() ext_str = '-te %s %s %s %s -ts 500 500' % (lon1b.min(), lat1b.min(), lon1b.max(), lat1b.max()) sid.n1.reproject(Domain(NSR().wkt, ext_str)) s01 = sid.n1['sigma0_HV'] sid.n2.reproject(Domain(NSR().wkt, ext_str)) s02 = sid.n2['sigma0_HV'] extent=[lon1b.min(), lon1b.max(), lat1b.min(), lat1b.max()] plt.imshow(s01, extent=extent, cmap='gray', aspect=10) plt.quiver(lon1ft, lat1ft, uft, vft, color='r', angles='xy', scale_units='xy', scale=0.2) plt.plot(lon2, lat2, '.-r') plt.xlim([lon1b.min(), lon1b.max()]) plt.ylim([lat1b.min(), lat1b.max()]) plt.savefig('sea_ice_drift_tests_%s_img1_ft.png' % inspect.currentframe().f_code.co_name, dpi=150, bbox_inches='tight', pad_inches=0) plt.close('all') plt.imshow(s02, extent=extent, cmap='gray', aspect=10) gpi = hpm*rpm > 4 plt.quiver(lon1pm[gpi], lat1pm[gpi], upm[gpi], vpm[gpi], rpm[gpi]*hpm[gpi], angles='xy', scale_units='xy', scale=0.2) plt.plot(lon1, lat1, '.-r') plt.xlim([lon1b.min(), lon1b.max()]) plt.ylim([lat1b.min(), lat1b.max()]) plt.savefig('sea_ice_drift_tests_%s_img2_pm.png' % inspect.currentframe().f_code.co_name, dpi=150, bbox_inches='tight', pad_inches=0) plt.close('all')
def test_crop_gcpproj(self): n1 = Nansat(self.test_file_gcps, log_level=40, mapper=self.default_mapper) n1.reproject_gcps() ext = n1.crop(10, 20, 50, 60) xmed = abs(np.median(np.array([gcp.GCPX for gcp in n1.vrt.dataset.GetGCPs()]))) gcpproj = NSR(n1.vrt.dataset.GetGCPProjection() ).ExportToProj4().split(' ')[0] self.assertTrue(xmed > 360) self.assertTrue(gcpproj=='+proj=stere')
def test_add_labels(self): size, npo = 100, 10 xy = np.random.randint(0, size, npo*2).reshape(npo, 2) z = np.random.randint(0, size, npo) xg, yg = np.meshgrid(range(size), range(size)) zg = griddata(xy, z, np.dstack([xg, yg]), method='nearest') dstDomain = Domain(NSR().wkt, '-te -10 -10 10 10 -ts 100 100') nmap = Nansatmap(dstDomain) nmap.imshow(zg, cmap='random') nmap.add_zone_labels(zg, fontsize=10) tmpfilename = os.path.join(ntd.tmp_data_path, 'nansatmap_zonelables.png') nmap.save(tmpfilename) self.assertTrue(os.path.exists(tmpfilename))
def test_reproject_pure_geolocation(self): n0 = Nansat(self.test_file_gcps) b0 = n0[1] lon0, lat0 = n0.get_geolocation_grids() d1 = Domain.from_lonlat(lon=lon0, lat=lat0) d2 = Domain.from_lonlat(lon=lon0, lat=lat0, add_gcps=False) d3 = Domain(NSR().wkt, '-te 27 70 31 72 -ts 500 500') n1 = Nansat.from_domain(d1, b0) n2 = Nansat.from_domain(d2, b0) n1.reproject(d3) n2.reproject(d3) b1 = n1[1] b2 = n2[1] self.assertTrue(np.allclose(b1, b2))
def test_init_from_none(self): nsr = NSR(None) self.assertEqual(type(nsr), NSR) self.assertEqual(nsr.Validate(), 5)
def test_init_empty(self): nsr = NSR() self.assertEqual(type(nsr), NSR) self.assertEqual(nsr.Validate(), 0)
def test_init_from_proj4(self): nsr = NSR('+proj=longlat') self.assertEqual(type(nsr), NSR) self.assertEqual(nsr.Validate(), 0) self.assertTrue('longlat' in nsr.ExportToProj4())
# user defined grid of points: lon1pm, lat1pm = np.meshgrid(np.linspace(lone, lonw, 50), np.linspace(lats, latn, 50)) # apply Pattern Matching and find sea ice drift speed # for the given grid of points upm, vpm, apm, rpm, hpm, lon2pm, lat2pm = sid.get_drift_PM( lon1pm, lat1pm, lon1ft, lat1ft, lon2ft, lat2ft) # ==== PLOTTING ==== # get coordinates of SAR scene borders lon1, lat1 = sid.n1.get_border() lon2, lat2 = sid.n2.get_border() # prepare projected images with sigma0_HV d = Domain(NSR().wkt, '-te %f %f %f %f -ts 500 500' % (lone, lats, lonw, latn)) sid.n1.reproject(d) s01 = sid.n1['sigma0_HV'] sid.n2.reproject(d) s02 = sid.n2['sigma0_HV'] # plot the projected image from the first SAR scene plt.imshow(s01, extent=[lone, lonw, lats, latn], cmap='gray', aspect=10) # plot vectors of sea ice drift from Feature Tracking plt.quiver(lon1ft, lat1ft, uft, vft, color='r', angles='xy', scale_units='xy',
def reproj_roi(self, out_path, gsd, lonw, lone, lats, latn, res='H'): ''' :param out_path: :param gsd: :param lonw: :param lone: :param lats: :param latn: :return: ''' corner_lon = [lonw, lone, lone, lonw] corner_lat = [lats, lats, latn, latn] corner_xy = self.proj_to_wgs84_nsidc_sea_ice_stere_n( corner_lon, corner_lat) min_x = corner_xy[0].min() max_x = corner_xy[0].max() min_y = corner_xy[1].min() max_y = corner_xy[1].max() img_width = int(np.ceil((max_x - min_x) / gsd)) img_height = int(np.ceil((max_y - min_y) / gsd)) img_pixel_crd_x = np.linspace(min_x, max_x, img_width) img_pixel_crd_y = np.linspace(max_y, min_y, img_height) grid_crd_x, grid_crd_y = np.meshgrid(img_pixel_crd_x, img_pixel_crd_y) grid_lonlat = self.proj_to_wgs84_nsidc_sea_ice_stere_n( grid_crd_x.flatten(), grid_crd_y.flatten(), True) grid_lon = grid_lonlat[0] grid_lat = grid_lonlat[1] grid_lon_idx = (grid_lon - self.min_lon) / self.mask_res grid_lat_idx = (grid_lat - self.min_lat) / self.mask_res grid_lon_idx = grid_lon_idx.astype(np.int) grid_lat_idx = grid_lat_idx.astype(np.int) gpi = self.mask[grid_lat_idx, grid_lon_idx] gpi = gpi.reshape(grid_crd_x.shape) if res == 'H': hr_xy = self.proj_to_wgs84_nsidc_sea_ice_stere_n( self.hr_lon.flatten(), self.hr_lat.flatten()) hr_x = hr_xy[0].reshape(self.hr_shape) hr_y = hr_xy[1].reshape(self.hr_shape) hr_pts = np.asarray(list(zip(hr_x.flatten(), hr_y.flatten()))) hr_value = self.bt_89h.flatten() dst_pts = np.asarray( list(zip(grid_crd_x.flatten(), grid_crd_y.flatten()))) dst_value = interpolate.griddata(hr_pts, hr_value, dst_pts, method='linear', rescale=True) dst_value = dst_value.reshape(grid_crd_x.shape) else: lr_xy = self.proj_to_wgs84_nsidc_sea_ice_stere_n( self.lr_lon.flatten(), self.lr_lat.flatten()) lr_x = lr_xy[0].reshape(self.lr_shape) lr_y = lr_xy[1].reshape(self.lr_shape) lr_pts = np.asarray(list(zip(lr_x.flatten(), lr_y.flatten()))) lr_value = self.bt_36h.flatten() dst_pts = np.asarray( list(zip(grid_crd_x.flatten(), grid_crd_y.flatten()))) dst_value = interpolate.griddata(lr_pts, lr_value, dst_pts, method='cubic', rescale=True) dst_value = dst_value.reshape(grid_crd_x.shape) dst_value[~gpi] = np.nan file_format = 'GTiff' driver = gdal.GetDriverByName(file_format) dst_ds = driver.Create(out_path, xsize=img_width, ysize=img_height, bands=1, eType=gdal.GDT_Byte) srs = NSR(3413) dst_ds.SetProjection(srs.ExportToWkt()) dst_ds.SetGeoTransform([min_x, gsd, 0, max_y, 0, -gsd]) img_uint8 = get_uint8_image(dst_value, None, None, 1, 99) # img_uint8 = unsharp_masking_sharp(img_uint8) # img_uint8 = laplcian_sharp(img_uint8) dst_ds.WriteRaster(0, 0, img_width, img_height, img_uint8.tostring()) dst_ds = None
def test_init_from_0(self): nsr = NSR(0) self.assertEqual(type(nsr), NSR) self.assertEqual(nsr.Validate(), 0)
def test_init_from_EPSG(self): nsr = NSR(4326) self.assertEqual(type(nsr), NSR) self.assertEqual(nsr.Validate(), 0) self.assertTrue('4326' in nsr.ExportToWkt())
def pattern_matching(lon_pm1, lat_pm1, n1, c1, r1, n2, c2, r2, margin=0, img_size=35, threads=5, srs='+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs', **kwargs): ''' Run Pattern Matching Algorithm on two images Parameters --------- lon_pm1 : 1D vector longitudes of destination initial points lat_pm1 : 1D vector latitudes of destination initial points n1 : Nansat the fist image with 2D array c1 : 1D vector initial FT columns on img1 r1 : 1D vector initial FT rows on img2 n2 : Nansat the second image with 2D array c2 : 1D vector final FT columns on img2 r2 : 1D vector final FT rows on img2 img_size : int size of template threads : int number of parallel threads srs: str destination spatial refernce system of the drift vectors (proj4 or WKT) **kwargs : optional parameters for: prepare_first_guess min_fg_pts : int, minimum number of fist guess points min_border : int, minimum searching distance max_border : int, maximum searching distance old_border : bool, use old border selection algorithm? rotate_and_match angles : list - which angles to test mtype : int - type of cross-correlation template_matcher : func - function to use for template matching mcc_norm : bool, normalize MCC by AVG and STD ? get_template rot_order : resampling order for rotation get_hessian hes_norm : bool, normalize Hessian by AVG and STD? hes_smth : bool, smooth Hessian? get_drift_vectors nsr: Nansat.NSR(), projection that defines the grid Returns ------- u : 1D vector eastward ice drift displacement [destination SRS units] v : 1D vector northward ice drift displacement [destination SRS units] a : 1D vector angle that gives the highes MCC r : 1D vector Maximum cross correlation (MCC) h : 1D vector Hessian of CC at MCC point lon2_dst : 1D vector longitude of results on image 2 lat2_dst : 1D vector latitude of results on image 2 ''' t0 = time.time() img1, img2 = n1[1], n2[1] dst_shape = lon_pm1.shape # coordinates of starting PM points on image 2 c2pm1, r2pm1 = n2.transform_points(lon_pm1.flatten(), lat_pm1.flatten(), 1) # integer coordinates of starting PM points on image 2 c2pm1i, r2pm1i = np.round([c2pm1, r2pm1]) # fake cooridinates for debugging #c2pm1, r2pm1 = np.meshgrid(np.arange(c2pm1i.min(), c2pm1i.max(), 25), # np.arange(c2pm1i.min(), c2pm1i.max(), 25)) #dst_shape = c2pm1.shape #c2pm1i, r2pm1i = np.round([c2pm1.flatten(), r2pm1.flatten()]) # coordinates of starting PM points on image 1 (correposond to integer coordinates in img2) lon1i, lat1i = n2.transform_points(c2pm1i, r2pm1i) c1pm1i, r1pm1i = n1.transform_points(lon1i, lat1i, 1) # approximate final PM points on image 2 (the first guess) c2fg, r2fg, brd2 = prepare_first_guess(c2pm1i, r2pm1i, n1, c1, r1, n2, c2, r2, img_size, **kwargs) # find valid input points hws = round(img_size / 2) + 1 hws_hypot = np.hypot(hws, hws) gpi = ((c2fg - brd2 - hws - margin > 0) * (r2fg - brd2 - hws - margin > 0) * (c2fg + brd2 + hws + margin < n2.shape()[1]) * (r2fg + brd2 + hws + margin < n2.shape()[0]) * (c1pm1i - hws_hypot - margin > 0) * (r1pm1i - hws_hypot - margin > 0) * (c1pm1i + hws_hypot + margin < n1.shape()[1]) * (r1pm1i + hws_hypot + margin < n1.shape()[0])) alpha0 = get_initial_rotation(n1, n2) def _init_pool(*args): """ Initialize shared data for multiprocessing """ global shared_args, shared_kwargs shared_args = args[:9] shared_kwargs = args[9] if threads <= 1: # run MCC without threads _init_pool(c1pm1i[gpi], r1pm1i[gpi], c2fg[gpi], r2fg[gpi], brd2[gpi], img1, img2, img_size, alpha0, kwargs) results = [use_mcc_mp(i) for i in range(len(gpi[gpi]))] else: # run MCC in multiple threads p = Pool(threads, initializer=_init_pool, initargs=(c1pm1i[gpi], r1pm1i[gpi], c2fg[gpi], r2fg[gpi], brd2[gpi], img1, img2, img_size, alpha0, kwargs)) results = p.map(use_mcc_mp, range(len(gpi[gpi]))) p.close() p.terminate() p.join() del p print('\n', 'Pattern matching - OK! (%3.0f sec)' % (time.time() - t0)) if len(results) == 0: lon2_dst = np.zeros(dst_shape) + np.nan lat2_dst = np.zeros(dst_shape) + np.nan u = np.zeros(dst_shape) + np.nan v = np.zeros(dst_shape) + np.nan a = np.zeros(dst_shape) + np.nan r = np.zeros(dst_shape) + np.nan h = np.zeros(dst_shape) + np.nan lon_pm2_grd = np.zeros(dst_shape) + np.nan lat_pm2_grd = np.zeros(dst_shape) + np.nan else: results = np.array(results) # coordinates of final PM points on image 2 (correspond to integer intial coordinates) c2pm2i = results[:, 0] r2pm2i = results[:, 1] # coordinatesof final PM points on image 2 (correspond to real intial coordinates) dci, dri, = c2pm1 - c2pm1i, r2pm1 - r2pm1i c2pm2, r2pm2 = c2pm2i + dci[gpi], r2pm2i + dri[gpi] # coordinates of initial PM points on destination grid and coordinates system xpm1, ypm1 = n2.transform_points(c2pm1, r2pm1, 0, NSR(srs)) xpm1_grd = xpm1.reshape(dst_shape) ypm1_grd = ypm1.reshape(dst_shape) # coordinates of final PM points on destination grid and coordinates system xpm2, ypm2 = n2.transform_points(c2pm2, r2pm2, 0, NSR(srs)) xpm2_grd = _fill_gpi(dst_shape, gpi, xpm2) ypm2_grd = _fill_gpi(dst_shape, gpi, ypm2) lon_pm2, lat_pm2 = n2.transform_points(c2pm2, r2pm2, 0) lon_pm2_grd = _fill_gpi(dst_shape, gpi, lon_pm2) lat_pm2_grd = _fill_gpi(dst_shape, gpi, lat_pm2) # speed vectors on destination grid and coordinates system u = xpm2_grd - xpm1_grd v = ypm2_grd - ypm1_grd # angle, correlation and hessian on destination grid a = results[:, 2] r = results[:, 3] h = results[:, 4] a = _fill_gpi(dst_shape, gpi, a) r = _fill_gpi(dst_shape, gpi, r) h = _fill_gpi(dst_shape, gpi, h) return u, v, a, r, h, lon_pm2_grd, lat_pm2_grd
def test_init_from_NSR(self): nsr = NSR(NSR(osr.SRS_WKT_WGS84)) self.assertEqual(type(nsr), NSR) self.assertEqual(nsr.Validate(), 0) self.assertTrue('longlat' in nsr.ExportToProj4())
## ==== PLOTTING ==== ## get coordinates of SAR scene borders lon1, lat1 = sid.n1.get_border() lon2, lat2 = sid.n2.get_border() #specify region regn = 84 regs = 82 regw = 10 rege = 25 ## prepare projected images with sigma0_HV #sid.n1.reproject(Domain(NSR().wkt, '-te -10 82 25 84 -ts 1000 1000')) #s01 = sid.n1['sigma0_HV'] sid.n2.reproject(Domain(NSR().wkt, '-te -10 82 25 84 -ts 1000 1000')) s02 = sid.n2['sigma0_HV'] ## plot the projected image from the first SAR scene #plt.imshow(s01, extent=[regw, rege, regs, regn], cmap='gray', aspect=12) ## plot vectors of sea ice drift from Feature Tracking #plt.quiver(lon1ft, lat1ft, uft, vft, color='r', #angles='xy', scale_units='xy', scale=0.5) ## plot border of the second SAR scene #plt.plot(lon2, lat2, '.-r') ## set X/Y limits of figure #plt.xlim([regw, rege]) #plt.ylim([regs, regn]) #plt.savefig(outpath+'SeaIceDrift_FT_img1_'+date1+'_'+date2+'.png', dpi=500, bbox_inches='tight', pad_inches=0) #plt.close('all')