csep.core.regions.QuadtreeGrid2D
- class csep.core.regions.QuadtreeGrid2D(polygons, quadkeys, bounds, name='QuadtreeGrid2d', mask=None)[source]
Respresents a 2D quadtree gridded region. The class provides functionality to generate multi-resolution or single-resolution quadtree grid. It also enables users to load already available quadtree grird. It also provides functions to query onto an index 2D grid ad maintains mapping between space coordinates and defined polygons and the index into the polygon array.
Note: It is replica of CartesianGrid2D class but with quadtree approach, with implementation of all the relevant functions required to CSEP1 tests
- __init__(polygons, quadkeys, bounds, name='QuadtreeGrid2d', mask=None)[source]
- Parameters:
polygons – Represents the object of class “polygons” defined through a collection of vertices. This polygon is 2d and vertices are obtained as corner points of quadtree tile.
quadkeys – Unique identifier of each quadtree tile. Quadkeys of every tile defines a grid cell. This is the first thing computed while acquiring quadtree grid. Rest can be computed from this.
bounds – number of cells x [lon1, lat1, lon2, lat2], corresponding to origin coordinates and top right coordinates fo each grid cell
name – Name of grid
mask – Masked cells. NotImplemented yet. Always keep it none
Methods
__init__(polygons, quadkeys, bounds[, name, ...])from_catalog(catalog, threshold[, zoom, ...])Creates instance of class from 2d numpy.array of lon/lat of Catalog.
from_quadkeys(quadk[, magnitudes, name])Creates instance of class from available quadtree grid.
from_single_resolution(zoom[, magnitudes, name])Creates instance of class at single-resolution using provided zoom-level.
get_bbox()Returns rectangular bounding box around region.
get_cartesian(data)Returns 2d ndrray representation of the data set, corresponding to the bounding box.
get_cell_area()Calls function geographical_area_from_bounds and computes area of each grid cell.
get_index_of(lons, lats)Returns the index of lons, lats in self.polygons
get_location_of(indices)Returns the polygon associated with the index idx.
midpoints()Returns midpoints of rectangular polygons in region
origins()Returns origins of rectangular polygons in region
save_quadtree(filename)Saves the quadtree grid (quadkeys) in a text file
tight_bbox()to_dict()Attributes
num_nodesNumber of polygons in region