def example_4(): # Collect a Grid grid_1 = Grid.read_envira( '../tests/data/MER2019 H_500_doc29_VVR/MER2018 - Doc29 - Lden y1974.dat' ) # Collect a Grid to compare grid_2 = Grid.read_envira( '../tests/data/H_500_00_doc29/MER2015 - Doc29 - Lden y1974.dat') # Create a figure plot = GridPlot(grid_1) # Add the background plot.add_background('../data/Schiphol_RD900dpi.png') # Add a scale plot.add_scale() # Add the comparison heatmap plot.add_comparison_heatmap(grid_2, vmin=-3, vmax=3) # Add a colorbar plot.add_colorbar() # Save the figure plot.save('figures/plot_grid_example_4.pdf') # And show the plot plot.show()
def example_1(): # Collect a Grid grid = Grid.read_envira('../tests/data/MER2015 - Doc29 - Lden y1974.dat') # Create a figure plot = GridPlot(grid) # Add the background plot.add_background('../data/Schiphol_RD900dpi.png') # Add a scale plot.add_scale() # Add the terrain plot.add_terrain('../data/2013-spl-luchtvaartterrein.shp') # Add the place names plot.add_place_names('../data/plaatsnamen.csv') # Add the 58dB contour plot.add_contours(58, default['kleuren']['schemergroen'], default['kleuren']['wolkengrijs_1']) # Add the 48dB contour plot.add_contours(48, default['kleuren']['schipholblauw'], default['kleuren']['middagblauw']) # Save the figure plot.save('figures/plot_grid_example_1.pdf') # And show the plot plot.show()
def test_interpolation_function_nan(): # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) grid.data = np.nan grid.interpolation_function()
def test_refine_value(): # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) factor = np.nan grid.refine(factor)
def test_read_envira_other_shape(): # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016h.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) assert grid.data.shape == (grid.info['y_number'], grid.info['x_number'])
def test_to_shapefile(): # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) # Refine the grid and export as shapefile grid.refine(20).to_shapefile(abs_path('data/GP2018 - Lnight y2016.shp'), 48)
def test_interpolation_function_nominal(): # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) interpolation = grid.interpolation_function() assert isinstance(interpolation, RectBivariateSpline)
def test_refine_type(): # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) grid.data = [] grid.refine(2)
def test_hg(): # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) # Calculate the Hoeveelheid Geluid hg = grid.hg() assert isinstance(hg, float)
def test_to_envira(): # Get the path from the original Envira file original_file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid = Grid.read_envira(original_file_path) # Set the path to the new Envira file new_file_path = abs_path('data/envira-test.dat') # Export the grid to the new file grid.to_envira(new_file_path) # Create a grid object from the new data file grid_new = Grid.read_envira(new_file_path) # Test if the headers of the files are the same assert grid_new.info == grid.info # Check if the data is still correct np.testing.assert_equal(grid_new.data, grid.data)
def test_refine(): """ Test various use cases for consistency """ # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid2 = Grid.read_envira(file_path) # Refine the grid with a factor 2 grid2.refine(2) # Check if the shape of the data matches the changed input assert grid2.data.shape == (285, 285) assert grid2.shape.x_number == 285 assert grid2.shape.y_number == 285 # Create a grid object from the data file grid05 = Grid.read_envira(file_path) # Refine the grid with a factor 0.5 grid05.refine(0.5) # Check if the shape of the data matches the changed input assert grid05.data.shape == (72, 72) assert grid05.shape.x_number == 72 assert grid05.shape.y_number == 72 # Create a grid object from the data file grid35 = Grid.read_envira(file_path) # Refine the grid with a factor 3.5 grid35.refine(3.5) assert grid35.data.shape == (498, 498) assert grid35.shape.x_number == 498 assert grid35.shape.y_number == 498
def test_scale(): # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) # Copy the data d = grid.data.copy() # Calculate the meteotoeslag grid.scale(2.) np.testing.assert_equal(grid.data, d + 10 * np.log10(2))
def test_add_noise_from_grid_lden_lnight(): # Get the path to the WBS file file_path = abs_path('../data/wbs2005.h5') # Create a wbs object from the data file wbs = WBS.read_file(file_path) # Get the path to the Lden Envira file file_path = abs_path('data/MER2015 - Doc29 - Lden y1974.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) # Add the interpolated Lden values from the grid wbs.add_noise_from_grid(grid) # Get the path to the Lnight Envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) # Add the interpolated Lnight values from the grid wbs.add_noise_from_grid(grid)
def test_select_above_wrong_unit(): # Get the path to the WBS file file_path = abs_path('../data/wbs2005.h5') # Create a wbs object from the data file wbs = WBS.read_file(file_path) # Get the path to the Envira file file_path = abs_path('data/MER2015 - Doc29 - Lden y1974.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) # Add the interpolated Lden values from the grid wbs.add_noise_from_grid(grid) # Select the Lnight values above 48 wbs.select_above('Lnight', 40)
def test_select_above(): # Get the path to the WBS file file_path = abs_path('../data/wbs2005.h5') # Create a wbs object from the data file wbs = WBS.read_file(file_path) # Get the path to the Envira file file_path = abs_path('data/MER2015 - Doc29 - Lden y1974.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) # Add the interpolated Lden values from the grid wbs.add_noise_from_grid(grid) # Select the Lden values above 40 s = wbs.select_above(40, 'Lden').values assert isinstance(s, np.ndarray)
def test_count_sleep_disturbed_people(): # Get the path to the WBS file file_path = abs_path('../data/wbs2005.h5') # Create a wbs object from the data file wbs = WBS.read_file(file_path) # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) # Add the interpolated Lnight values from the grid wbs.add_noise_from_grid(grid) # Count the sleep disturbed people s = wbs.count_sleep_disturbed_people() assert isinstance(s, float)
def test_count_annoyed_people(): # Get the path to the WBS file file_path = abs_path('../data/wbs2005.h5') # Create a wbs object from the data file wbs = WBS.read_file(file_path) # Get the path to the Envira file file_path = abs_path('data/MER2015 - Doc29 - Lden y1974.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) # Add the interpolated Lden values from the grid wbs.add_noise_from_grid(grid) # Count the annoyed people s = wbs.count_annoyed_people() assert isinstance(s, float)
def test_resize(): # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path) # Create an alternative shape shape = grid.shape.copy() # Change a few settings shape.set_x_number(201) shape.set_y_number(79) # Resize the grid grid.resize(shape) # Check if the shape of the data matches the changed input assert grid.data.shape == (79, 201) assert grid.shape.x_number == 201 assert grid.shape.y_number == 79 assert isinstance(grid.info, dict)
def example_3(): # Collect a Grid grid = Grid.read_envira('../tests/data/MER2015 - Doc29 - Lden y1974.dat') # Create a figure plot = GridPlot(grid) # Add the background plot.add_background('../data/Schiphol_RD900dpi.png') # Add a scale plot.add_scale() # Add the heatmap plot.add_heatmap(vmin=46, vmax=70) # Add a colorbar plot.add_colorbar() # Save the figure plot.save('figures/plot_grid_example_3.pdf') # And show the plot plot.show()
def test_read_envira_header_incorrect(): # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016e.dat') # Create a grid object from the data file Grid.read_envira(file_path)
def test_read_envira_row_missing(): # Get the path to the Envira file file_path = abs_path('data/GP2018 - Lnight y2016r.dat') # Create a grid object from the data file grid = Grid.read_envira(file_path)