Point pattern
The class PointPattern
is designed to encapsulate one realization of a point process, along with the observation window, and the intensity of the point process.
restrict_to_window()
: Restrict the point pattern to a specific window.convert_to_spatstat_ppp()
: Converts the point pattern into aspatstat.geom.ppp
R object.plot()
: Plots the point pattern.
- class structure_factor.point_pattern.PointPattern(points, window, intensity=None, **params)[source]
Bases:
object
Encapsulate one realization of a point process, the corresponding observation window, and the intensity of the underlying point process.
Example
import matplotlib.pyplot as plt from structure_factor.point_pattern import PointPattern from structure_factor.point_processes import HomogeneousPoissonPointProcess from structure_factor.spatial_windows import BoxWindow point_process = HomogeneousPoissonPointProcess(intensity=1) window = BoxWindow([[-50, 50], [-50, 50]]) points = point_process.generate_sample(window=window) point_pattern = PointPattern( points=points, window=window, intensity=point_process.intensity ) ax = point_pattern.plot() ax.set_aspect("equal", "box") plt.tight_layout(pad=1)
(Source code, png, hires.png, pdf)
- __init__(points, window, intensity=None, **params)[source]
Initialize the object from a realization
points
of the underlying point process with intensityintensity
observed inwindow
.- Parameters
points (numpy.ndarray) – \(N \times d\) array collecting \(N\) points in dimension \(d\) consisting of a realization of a point process.
window (
AbstractSpatialWindow
, optional) – Observation window containing thepoints
.intensity (float, optional) – Intensity of the point process. If None, the intensity of the point process is approximated by the ratio of the number of point to the window volume. Defaults to None.
- Keyword Arguments
params – Possible additional parameters of the point process.
- property dimension
Ambient dimension of the space where the points live.
- restrict_to_window(window)[source]
Return a new instance of
PointPattern
with the following attributes,points: points of the original object that fall inside the prescribed
window
,window: prescribed
window
,intensity: intensity of the original object.
- Parameters
window (
AbstractSpatialWindow
) – New observation window to restrict to.- Returns
Restriction of the initial
PointPattern
instance to the prescribedwindow
.- Return type
Example
import matplotlib.pyplot as plt from structure_factor.point_processes import HomogeneousPoissonPointProcess from structure_factor.spatial_windows import BallWindow, BoxWindow point_process = HomogeneousPoissonPointProcess(intensity=1) window = BoxWindow([[-50, 50], [-50, 50]]) point_pattern = point_process.generate_point_pattern(window=window) # Restrict to a BallWindow ball = BallWindow(center=[0, 0], radius=30) restricted_point_pattern = point_pattern.restrict_to_window(ball) ax = restricted_point_pattern.plot() ax.set_aspect("equal", "box") plt.tight_layout(pad=1)
(Source code, png, hires.png, pdf)
See also
- convert_to_spatstat_ppp(**params)[source]
Convert the object into a point pattern
spatstat.geom.ppp
R object.- Keyword Arguments
params (dict) – Optional keyword arguments passed to
spatstat.geom.ppp
.- Returns
Point pattern R object of type
spatstat.geom.ppp
.
- plot(axis=None, window=None, show_window=False, file_name='', **kwargs)[source]
Scatter plot of
points
.- Parameters
axis (plt.Axes, optional) – Support axis of the plot. Defaults to None.
window (
AbstractSpatialWindow
, optional) – Output observation window. Defaults to None.show_window (bool, optional) – Display the
window
, ambient dimension should be 2.
- Returns
Plot axis.
- Return type
plt.Axes