csep.core.regions.CartesianGrid2D
- class csep.core.regions.CartesianGrid2D(polygons, dh, name='cartesian2d', mask=None)[source]
Represents a 2D cartesian gridded region.
The class provides functions to query onto an index 2D Cartesian grid and maintains a mapping between space coordinates defined by polygons and the index into the polygon array.
Custom regions can be easily created by using the from_polygon classmethod. This function will accept an arbitrary closed polygon and return a CartesianGrid class with only points inside the polygon to be valid.
Methods
__init__
(polygons, dh[, name, mask])from_dict
(adict)Creates a region object from a dictionary
from_origins
(origins[, dh, magnitudes, name])Creates instance of class from 2d numpy.array of lon/lat origins.
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
()Compute the area of each polygon in sq.
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.
get_masked
(lons, lats)Returns bool array lons and lats are not included in the spatial region.
midpoints
()Returns midpoints of rectangular polygons in region
origins
()Returns origins of rectangular polygons in region
tight_bbox
([precision])to_dict
()Attributes
num_nodes
Number of polygons in region