Boundaries#
Boundary shapes, introduced in Boundary shapes. Boundary, string
and layout modifiers are grouped under oowl.modifiers.
Generated boundaries take area as their size in square meters, and shape
arguments such as rectangle width and height or ellipse semi-axes fix only
proportions. Polygon keeps its source coordinates unless area or center
is given. Modifiers may change the area and centroid afterwards.
|
Abstract wind-farm boundary backed by a Shapely geometry in meters. |
|
One logical boundary formed by the geometric union of other boundaries. |
|
Boundary given by explicit vertices or an existing Shapely geometry. |
|
Rectangle whose |
|
Square of a given |
|
Regular polygon with |
|
Circle of a given |
|
Ellipse whose |
|
Ring whose |
|
Star-shaped polygon given by the radius and angular step of each vertex. |
|
Random star-shaped polygon jittered from a regular |
|
Random smooth outline from a low-frequency Fourier radius function. |
|
Boundary as the hull of random scattered points, convex or concave. |
|
Polygon sampled from a fitted Fourier descriptor model. |
|
Boundary sampled from the morphology of operating offshore wind farms. |
|
A base boundary with an ordered chain of boundary modifiers. |
Boundary geometries for wind farms.
Concrete boundaries subclass Boundary and wrap a Shapely Polygon
or MultiPolygon in meters. Modifiers from oowl.modifiers compose
with every boundary. Union merges several boundaries into one
logical farm.
- class oowl.boundaries.Annulus(outer_radius=1.0, inner_radius=0.4, *, area=None, center=None, n_segments=64)[source]#
Ring whose
outer_radiusandinner_radiusset only the shape.areais the area of the ring itself, excluding the hole. Each circle hasn_segmentsvertices, rounded down to a multiple of four.
- class oowl.boundaries.Boundary[source]#
Abstract wind-farm boundary backed by a Shapely geometry in meters.
Subclasses build an unscaled shape about the origin, which is scaled about its centroid to
target_areaand then moved so its centroid lies atcenter, where either is set. Placing the shape last keeps a site far from the origin, as in UTM coordinates, as accurate as one at it.- property bounds: tuple[float, float, float, float]#
Axis-aligned bounding box as
(min_x, min_y, max_x, max_y)in meters.
- property centroid: tuple[float, float]#
Geometric center of mass as
(x, y)in meters.It may lie outside a concave or multipart boundary. See
interior_point.
- contains(points)[source]#
Test which points lie in the boundary, counting the edge as inside.
- Parameters:
points (ArrayLike) – Array-like of shape
(N, 2), or one point of shape(2,).- Returns:
Boolean array of length
N.- Return type:
- Raises:
TypeError – For points that are not numbers.
ValueError – For another shape or a point that is not finite.
- property geometry: Polygon | MultiPolygon#
The Shapely
PolygonorMultiPolygonof this boundary, in meters.Raises
TypeErrorfor another geometry type andValueErrorfor an empty, zero-area or invalid one.
- property interior_point: tuple[float, float]#
A point inside the boundary, as
(x, y)in meters.The centroid if contained, otherwise Shapely’s representative point.
- modify(*modifiers)[source]#
Return a
Compositeapplyingmodifiersin order.This boundary is left unchanged.
- Parameters:
modifiers (BoundaryModifier)
- Return type:
- property parts: tuple[Boundary, ...]#
The boundaries a farm is built from, this one alone without a partition.
- plot(ax=None, **kwargs)[source]#
Plot the boundary and return its Matplotlib axes.
- Parameters:
ax (matplotlib.axes.Axes | None)
kwargs (Any)
- Return type:
- class oowl.boundaries.Circle(*, area=None, center=None, n_segments=64)[source]#
Circle of a given
area, drawn as a polygon ofn_segmentsvertices.n_segmentsis rounded down to a multiple of four.
- class oowl.boundaries.Composite(base, modifiers, *, area=None)[source]#
A base boundary with an ordered chain of boundary modifiers.
Modifiers apply left to right. A chain holds at most one partition, and modifiers after it apply to each partition cell separately.
areasets the area of the finished boundary in square meters,Noneto leave it as the chain makes it. Composing a composite flattens the chains and keeps its area unlessareais given. RaisesTypeErrorfor a non-boundary base or a non-modifier item.Resizing a composite whose modifiers are given in meters, such as a setback distance, a partition gap or exclusion zones, resizes the base and re-applies the chain to it, so those stay in meters while the result has the requested area to rounding. Where GEOS’s buffer simplification makes the area jump, the nearest size is kept, within a hundredth of the buffered distance times the edge length. A chain without one scales as a whole with its cells.
- Parameters:
base (Boundary)
modifiers (Iterable[BoundaryModifier])
area (float | None)
- modify(*modifiers)[source]#
Return a new composite with
modifiersappended to this chain.- Parameters:
modifiers (BoundaryModifier)
- Return type:
- class oowl.boundaries.ConvexHull(*, area=None, n_points=20, center=None, concavity=None, seed=None)[source]#
Boundary as the hull of random scattered points, convex or concave.
The default
concavity=Nonegives the exact convex hull. A value in(0, 1]is Shapely’sconcave_hullratio. Smaller values wrap the points more tightly and1.0reproduces the convex hull. The shape is always scaled toarea.- Parameters:
area (float | None) – Realized enclosed area in square meters,
Nonefor a unit-size shape to size later.n_points (int) – Number of scattered points to draw, at least 3. A concave hull needs a dense cloud.
center (Point2D | None) – Centroid of the realized boundary.
concavity (float | None) –
Nonefor a convex hull, or a ratio in(0, 1]for a concave one.seed (int | np.random.Generator | None) – Seed or generator for the scattered points, drawn from a standard normal distribution before the hull is moved to
center.
- Raises:
ValueError – If
concavityis outside(0, 1]or not finite, or if the point set admits no valid hull with positive area at that ratio.
- class oowl.boundaries.Ellipse(semi_major=1.0, semi_minor=1.0, *, area=None, center=None, rotation=0.0, n_segments=64)[source]#
Ellipse whose
semi_majorandsemi_minoraxes set only the shape.areasets the size androtationturns the major axis counterclockwise from the x axis, in degrees. The outline hasn_segmentsvertices, rounded down to a multiple of four.
- class oowl.boundaries.FourierPolygon(model=None, *, temperature=2.0, max_attempts=128, area=None, center=None, rotation=None, seed=None)[source]#
Polygon sampled from a fitted Fourier descriptor model.
Each attempt draws PCA scores scaled by
temperature, inverse-FFTs the coefficients to a smooth curve, and simplifies it to a vertex count drawn from the model. Invalid results are retried up tomax_attemptstimes, then aRuntimeErroris raised.modelis a model or.npzpath and defaults to the packaged model. The shape is scaled toareaand moved tocenter. A heading is drawn per sample unlessrotationpins it in degrees.
- class oowl.boundaries.OffshorePolygon(*, area=None, center=None, rotation=None, seed=None, max_attempts=256)[source]#
Boundary sampled from the morphology of operating offshore wind farms.
Sampling is parametric and copies no reference polygon. The shape is scaled to
areaand moved tocenter. A heading is drawn per sample unlessrotationpins it in degrees. RaisesRuntimeErroraftermax_attemptsinvalid draws.
- class oowl.boundaries.Polygon(exterior, holes=None, *, area=None, center=None)[source]#
Boundary given by explicit vertices or an existing Shapely geometry.
exteriorand each ofholesare(N, 2)rings in meters, kept as given unlessareaorcenteris passed to rescale or move the shape. Invalid geometry is never repaired, and building one raisesValueErrornaming what is wrong. A non-numericcenterraisesTypeError, and one other than two finite coordinatesValueError.- Parameters:
exterior (ArrayLike)
holes (Sequence | None)
area (float | None)
center (Point2D | None)
- class oowl.boundaries.RadialPolygon(radii, angular_offsets=None, *, area=None, center=None)[source]#
Star-shaped polygon given by the radius and angular step of each vertex.
Vertex
iof the generating shape lies at distanceradii[i]from its origin and at the cumulative sum ofangular_offsetsup toi, in degrees. The offsets are positive and default to equal steps.radiiset only the shape, sinceareasets the size, andcenterplaces its centroid, which need not be that origin.
- class oowl.boundaries.RandomRadialPolygon(n_vertices=8, *, area=None, radius_jitter=0.35, angular_jitter=0.5, center=None, seed=None)[source]#
Random star-shaped polygon jittered from a regular
n_vertices-gon.Each unit radius is perturbed uniformly by up to
radius_jitterand each equal angular step by up to the fractionangular_jitter, before the steps are rescaled to a full turn. Radii stay positive.
- class oowl.boundaries.Rectangle(width=1.0, height=1.0, *, area=None, center=None, rotation=0.0)[source]#
Rectangle whose
widthandheightset only the aspect ratio.areasets the size in square meters,Nonefor a unit-size shape to size later, androtationturns the rectangle counterclockwise about its center, in degrees.
- class oowl.boundaries.RegularPolygon(n_sides, *, area=None, center=None, rotation=0.0)[source]#
Regular polygon with
n_sidessides, at least 3, and a givenarea.The first vertex lies at
rotationdegrees counterclockwise from the positive x axis.
- class oowl.boundaries.SmoothBlob(*, area=None, n_segments=200, roughness=0.3, n_harmonics=5, center=None, seed=None)[source]#
Random smooth outline from a low-frequency Fourier radius function.
The radius at
n_segmentsequally spaced angles is\[r(\theta) = 1 + \sum_{k=1}^{K} \frac{\rho\,\xi_k}{k}\sin(k\theta + \phi_k)\]with
K = n_harmonics,roughness\(\rho\), standard-normal \(\xi_k\) and uniform phases \(\phi_k\). The radius is clipped at 0.1 to keep it positive.
- class oowl.boundaries.Square(*, area=None, center=None, rotation=0.0)[source]#
Square of a given
area, turned byrotationdegrees.
- class oowl.boundaries.Union(boundaries, *, area=None)[source]#
One logical boundary formed by the geometric union of other boundaries.
Overlapping members merge into a single polygon. Disconnected members remain components of one
MultiPolygonfarm. Each member is scaled to its ownareabefore the union.areathen scales the union to that many square meters,Noneto keep the members’ sizes.Resizing a union with a member whose modifiers are given in meters, such as a setback distance, a partition gap or exclusion zones, scales the bases of all members by one factor about the centroid of the union and re-applies their chains, so those stay in meters while the result has the requested area, as for a
Composite. A union without one scales as a whole.