def test_RegularGrid(): res = Grid.RegularGrid(time_seq=np.arange(2), space_grid=np.array([[0., 5.], [1., 2.]]), silence_level=2).sequence(0) exp = np.array([0., 0., 5., 5.], dtype=np.float32) assert np.allclose(res, exp, atol=1e-04) res = Grid.RegularGrid(time_seq=np.arange(2), space_grid=np.array([[0., 5.], [1., 2.]]), silence_level=2).sequence(1) exp = np.array([1., 2., 1., 2.], dtype=np.float32) assert np.allclose(res, exp, atol=1e-04)
from pyunicorn.core.grid import Grid """ This example code offers an overview of the spatial network code for GeoModel1 and GeoModel2 can be called. Furthermore, with the python versions GeoModel1_py and GeoModel2_py further analysis can be done, to visualize the working of the network operations. """ # Create Random Grids rect_grid_num = 20 # For larger network sizes this might take a while to compute! grid = Grid.RegularGrid(time_seq=np.arange(2), lat_grid=np.random.randint(low=0, high=40, size=rect_grid_num), lon_grid=np.random.randint(low=0, high=40, size=rect_grid_num)) erdos_renyi = sp.SpatialNetwork.ErdosRenyi(grid=grid, n_nodes=int(rect_grid_num**2), link_probability=0.1) geo_model = sp.SpatialNetwork(grid=erdos_renyi.grid, adjacency=erdos_renyi.adjacency) # Apply geoModel code new_link_list = geo_model.GeoModel1(n_steps=int(5e4), tolerance=1, grid_type='euclidean', verbose=False)