def get_xy_grid_cell_edges(model_name, grid_name=None): """Returns unique x- and y-coordinates of grid-cell edges. M = number of rows (unique y-coordinates of grid points) N = number of columns (unique x-coordinates of grid points) :param model_name: See doc for `check_grid_name`. :param grid_name: Same. :return: grid_cell_edges_x_metres: length-(N + 1) numpy array of x-coordinates. :return: grid_cell_edges_y_metres: length-(M + 1) numpy array of y-coordinates. """ x_spacing_metres, y_spacing_metres = get_xy_grid_spacing( model_name=model_name, grid_name=grid_name) num_rows, num_columns = get_grid_dimensions(model_name=model_name, grid_name=grid_name) return grids.get_xy_grid_cell_edges(x_min_metres=MIN_GRID_POINT_X_METRES, y_min_metres=MIN_GRID_POINT_Y_METRES, x_spacing_metres=x_spacing_metres, y_spacing_metres=y_spacing_metres, num_rows=num_rows, num_columns=num_columns)
def test_get_xy_grid_cell_edges(self): """Ensures correct output from get_xy_grid_cell_edges.""" these_x_coords_metres, these_y_coords_metres = ( grids.get_xy_grid_cell_edges(x_min_metres=X_MIN_METRES, y_min_metres=Y_MIN_METRES, x_spacing_metres=X_SPACING_METRES, y_spacing_metres=Y_SPACING_METRES, num_rows=NUM_XY_ROWS, num_columns=NUM_XY_COLUMNS)) self.assertTrue( numpy.allclose(these_x_coords_metres, EDGE_X_COORDS_METRES, atol=TOLERANCE)) self.assertTrue( numpy.allclose(these_y_coords_metres, EDGE_Y_COORDS_METRES, atol=TOLERANCE))
def test_get_xy_grid_cell_edges(self): """Ensures correct output from get_xy_grid_cell_edges.""" (grid_cell_edge_x_metres, grid_cell_edge_y_metres) = grids.get_xy_grid_cell_edges( x_min_metres=X_MIN_METRES, y_min_metres=Y_MIN_METRES, x_spacing_metres=X_SPACING_METRES, y_spacing_metres=Y_SPACING_METRES, num_rows=NUM_XY_ROWS, num_columns=NUM_XY_COLUMNS) self.assertTrue( numpy.allclose(grid_cell_edge_x_metres, EXPECTED_GRID_CELL_EDGE_X_METRES, atol=TOLERANCE)) self.assertTrue( numpy.allclose(grid_cell_edge_y_metres, EXPECTED_GRID_CELL_EDGE_Y_METRES, atol=TOLERANCE))
def get_xy_grid_cell_edges(model_name, grid_id=None): """Returns unique x- and y-coordinates of grid-cell edges. M = number of rows (unique grid-point y-coordinates) N = number of columns (unique grid-point x-coordinates) :param model_name: Name of model. :param grid_id: ID for model grid. :return: grid_cell_edge_x_metres: length-(N + 1) numpy array with x- coordinates of grid-cell edges. :return: grid_cell_edge_y_metres: length-(M + 1) numpy array with y- coordinates of grid-cell edges. """ x_spacing_metres, y_spacing_metres = get_xy_grid_spacing( model_name, grid_id) num_grid_rows, num_grid_columns = get_grid_dimensions(model_name, grid_id) return grids.get_xy_grid_cell_edges(x_min_metres=MIN_GRID_POINT_X_METRES, y_min_metres=MIN_GRID_POINT_Y_METRES, x_spacing_metres=x_spacing_metres, y_spacing_metres=y_spacing_metres, num_rows=num_grid_rows, num_columns=num_grid_columns)