def test_transform_PlateCarree_shortcut(): src = ccrs.PlateCarree(central_longitude=0) target = ccrs.PlateCarree(central_longitude=180) # of the 3 paths, 2 of them cannot be short-cutted. pth1 = mpath.Path([[0.5, 0], [10, 10]]) pth2 = mpath.Path([[0.5, 91], [10, 10]]) pth3 = mpath.Path([[-0.5, 0], [10, 10]]) trans = InterProjectionTransform(src, target) counter = CallCounter(target, 'project_geometry') with counter: trans.transform_path(pth1) # pth1 should allow a short-cut. assert counter.count == 0 with counter: trans.transform_path(pth2) assert counter.count == 1 with counter: trans.transform_path(pth3) assert counter.count == 2
def test_transform_PlateCarree_shortcut(): src = ccrs.PlateCarree(central_longitude=0) target = ccrs.PlateCarree(central_longitude=180) # of the 3 paths, 2 of them cannot be short-cutted. pth1 = mpath.Path([[0.5, 0], [10, 10]]) pth2 = mpath.Path([[0.5, 91], [10, 10]]) pth3 = mpath.Path([[-0.5, 0], [10, 10]]) trans = InterProjectionTransform(src, target) with mock.patch.object(target, 'project_geometry', wraps=target.project_geometry) as counter: trans.transform_path(pth1) # pth1 should allow a short-cut. counter.assert_not_called() with mock.patch.object(target, 'project_geometry', wraps=target.project_geometry) as counter: trans.transform_path(pth2) counter.assert_called_once() with mock.patch.object(target, 'project_geometry', wraps=target.project_geometry) as counter: trans.transform_path(pth3) counter.assert_called_once()
def test_transform_PlateCarree_shortcut(): src = ccrs.PlateCarree(central_longitude=0) target = ccrs.PlateCarree(central_longitude=180) # of the 3 paths, 2 of them cannot be short-cutted. pth1 = mpath.Path([[0.5, 0], [10, 10]]) pth2 = mpath.Path([[0.5, 91], [10, 10]]) pth3 = mpath.Path([[-0.5, 0], [10, 10]]) trans = InterProjectionTransform(src, target) counter = CallCounter(target, 'project_geometry') with counter: trans.transform_path(pth1) # pth1 should allow a short-cut. assert_equal(counter.count, 0) with counter: trans.transform_path(pth2) assert_equal(counter.count, 1) with counter: trans.transform_path(pth3) assert_equal(counter.count, 2)
def rob_2_rob_shifted(self): return InterProjectionTransform(ccrs.Robinson(), ccrs.Robinson(central_longitude=0))
def pc_2_rob(self): return InterProjectionTransform(ccrs.PlateCarree(), ccrs.Robinson())
def pc_2_pc(self): return InterProjectionTransform(ccrs.PlateCarree(), ccrs.PlateCarree())