Grid Class¶
General Grids¶
- class emiproc.grids.Grid¶
Abstract base class for a grid.
Derive your own grid implementation from this and make sure to provide an appropriate implementation of the required methods.
- Parameters:
name (str) – Name of the grid.
crs (int | str | pyproj.CRS) – The coordinate reference system of the grid.
gdf (gpd.GeoDataFrame) – A geopandas dataframe containing the grid cells as geometries.
cells_as_polylist (list[shapely.geometry.Polygon]) – A list of polygons representing the grid cells.
nx (int) – Number of cells in the x direction.
ny (int) – Number of cells in the y direction. Set this to 1 for non-regular grids.
shape (tuple[int, int]) – The shape of the grid as a tuple (nx, ny).
corners (np.ndarray | None) – Corners of the cells.
centers (gpd.GeoSeries) – Centers of the cells, as a GeoSeries of Points. You can use grid.centers.x and grid.centers.y to get the x and y coordinates.
cell_areas (Iterable[float]) – Area of the cells in m^2.
- __init__(name: str | None, crs: int | str = 4326)¶
Parameters¶
name : Name of the grid. crs : The coordinate reference system of the grid.
- classmethod __new__(*args, **kwargs)¶
- class emiproc.grids.RegularGrid¶
Regular grid a grids with squared cells.
This allows for some capabilities that are not available for irregular grids (rasterization, image like plotting).
To create the grid, one mandatory parameter is the reference:
- Parameters:
xmin/ymin – The minimum x and y coordinate of the grid.
Then you need two of the three following:
- Parameters:
xmax/ymax – The maximum x and y coordinate of the grid.
nx/ny – The number of cells in both directions.
dx/dy – The size of the cells. The number of decimals specified is used to round the coordinates.
The grid will be constructed to fit the given parameters.
- __init__(
- xmin: float,
- ymin: float,
- xmax: float | None = None,
- ymax: float | None = None,
- nx: int | None = None,
- ny: int | None = None,
- dx: float | None = None,
- dy: float | None = None,
- name: str | None = None,
- crs: int | str = 4326,
Parameters¶
name : Name of the grid. crs : The coordinate reference system of the grid.
- classmethod __new__(*args, **kwargs)¶
- classmethod from_centers(
- x_centers: ndarray,
- y_centers: ndarray,
- name=None,
- crs=4326,
- rounding: int | None = None,
Create a regular grid from the center points of the cells.
- Parameters:
x_centers – The x-coordinates of the cell centers.
y_centers – The y-coordinates of the cell centers.
name – The name of the grid.
crs – The coordinate reference system of the grid.
rounding – The number of decimal places to round the dx and dy. This is useful to correct floating point errors.
- class emiproc.grids.HexGrid¶
A grid with hexagonal cells.
The grid is similar to a regular grid, but the cells are hexagons. This implies that the lines of the grid are not all parallel.
For the arguments, look at
RegularGrid. Note that dx and dy have been replaced by spacing parameter,- Parameters:
spacing – The distance between the centers of two adjacent hexagons on a row. This is also the diameter of the circle inscribed in the hexagon.
oriented_north – If True, the hexagons are oriented with the top and bottom sides parallel on the y-axis. If False, the hexagons are oriented with the left and right sides parallel on the x-axis.
- __init__(
- xmin: float,
- ymin: float,
- xmax: float | None = None,
- ymax: float | None = None,
- nx: int | None = None,
- ny: int | None = None,
- spacing: float | None = None,
- oriented_north: bool = True,
- name: str | None = None,
- crs: int | str = 4326,
Parameters¶
name : Name of the grid. crs : The coordinate reference system of the grid.
- classmethod __new__(*args, **kwargs)¶
- class emiproc.grids.GeoPandasGrid¶
A grid that can be easily constructed on a geopandas dataframe.
- __init__(
- gdf: GeoDataFrame | GeoSeries,
- name: str = 'gpd_grid',
- shape: tuple[int, int] | None = None,
Parameters¶
name : Name of the grid. crs : The coordinate reference system of the grid.
- classmethod __new__(*args, **kwargs)¶
Model Grids¶
- class emiproc.exports.wrf.WRF_Grid¶
Grid of the wrf model.
The grid is a pseudo regular grid, in the sense that the grid is regular under a certain projection, but is never given in that projection, but on a WG84 projection.
The grid is constucted from the wrfinput file.
- __init__(grid_filepath: PathLike, engine: str | None = None) None¶
Initialize the grid.
Parameters¶
- grid_filepathPathlike
The path to the grid file.
- engine: str | None
The engine to use by xarray to read the grid file. See xarray.open_dataset for more info.
- classmethod __new__(*args, **kwargs)¶
- class emiproc.grids.ICONGrid¶
Class to manage an ICON-domain
This grid is defined as an unstuctured triangular grid (1D). The cells are ordered in a deliberate way and indexed with ascending integer numbers. The grid file contains variables like midpoint coordinates etc as a fct of the index.
- __init__(dataset_path, name: str = None)¶
Open the netcdf-dataset and read the relevant grid information.
Parameters¶
dataset_path : str name : str, optional
- classmethod __new__(*args, **kwargs)¶