csep.core.regions.CartesianGrid2D

class csep.core.regions.CartesianGrid2D(polygons, dh, name='cartesian2d')[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.

__init__(polygons, dh, name='cartesian2d')[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(polygons, dh[, name])

Initialize self.

from_dict(adict)

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_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

to_dict()

Attributes

num_nodes

Number of polygons in region