def test_center(self): gm = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13, size_x=500, size_y=500, use_cache=False) gm.set_roi(shape=get_demo_file('Hintereisferner.shp')) gm.set_subset(toroi=True, margin=10) img = gm.get_vardata() img[np.nonzero(gm.roi == 0)] /= 2. # from scipy.misc import toimage # toimage(img).save(get_demo_file('hef_google_roi.png')) ref = mpl.image.imread(get_demo_file('hef_google_roi.png')) rmsd = np.sqrt(np.mean((ref - img)**2)) self.assertTrue(rmsd < 0.1) # assert_allclose(ref, img, atol=2e-2) gm = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13, size_x=500, size_y=500) gm.set_roi(shape=get_demo_file('Hintereisferner.shp')) gm.set_subset(toroi=True, margin=10) img = gm.get_vardata() img[np.nonzero(gm.roi == 0)] /= 2. rmsd = np.sqrt(np.mean((ref - img)**2)) self.assertTrue(rmsd < 0.1)
def test_center(self): import matplotlib as mpl gm = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13, size_x=500, size_y=500, use_cache=False) gm.set_roi(shape=get_demo_file('Hintereisferner.shp')) gm.set_subset(toroi=True, margin=10) img = gm.get_vardata()[..., :3] img[np.nonzero(gm.roi == 0)] /= 2. # from PIL import Image # Image.fromarray((img * 255).astype(np.uint8)).save( # get_demo_file('hef_google_roi.png')) ref = mpl.image.imread(get_demo_file('hef_google_roi.png')) rmsd = np.sqrt(np.mean((ref - img)**2)) self.assertTrue(rmsd < 0.2) # assert_allclose(ref, img, atol=2e-2) gm = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13, size_x=500, size_y=500) gm.set_roi(shape=get_demo_file('Hintereisferner.shp')) gm.set_subset(toroi=True, margin=10) img = gm.get_vardata()[..., :3] img[np.nonzero(gm.roi == 0)] /= 2. rmsd = np.sqrt(np.mean((ref - img)**2)) self.assertTrue(rmsd < 0.2) gm = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13, size_x=500, size_y=500) gm2 = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13, size_x=500, size_y=500, scale=2) assert (gm.grid.nx * 2) == gm2.grid.nx assert gm.grid.extent == gm2.grid.extent
def test_center(self): gm = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13, size_x=500, size_y=500, use_cache=False) gm.set_roi(shape=get_demo_file("Hintereisferner.shp")) gm.set_subset(toroi=True, margin=10) img = gm.get_vardata() img[np.nonzero(gm.roi == 0)] /= 2.0 # from scipy.misc import toimage # toimage(img).save(get_demo_file('hef_google_roi.png')) ref = mpl.image.imread(get_demo_file("hef_google_roi.png")) rmsd = np.sqrt(np.mean((ref - img) ** 2)) self.assertTrue(rmsd < 0.1) # assert_allclose(ref, img, atol=2e-2) gm = GoogleCenterMap(center_ll=(10.762660, 46.794221), zoom=13, size_x=500, size_y=500) gm.set_roi(shape=get_demo_file("Hintereisferner.shp")) gm.set_subset(toroi=True, margin=10) img = gm.get_vardata() img[np.nonzero(gm.roi == 0)] /= 2.0 rmsd = np.sqrt(np.mean((ref - img) ** 2)) self.assertTrue(rmsd < 0.1)