# Core

The two realized containers and the windIO persistence
functions. Realization itself is two steps and is documented on the
[Sampling](sampling.md) page. Describe the scenario you want as an
{class}`~oowl.Sampler`, then draw scenarios from that description with
{meth}`~oowl.Sampler.sample` or {meth}`~oowl.Sampler.stream`.

A scenario is a {class}`~oowl.Farm`, whose boundary may be a multipolygon when a
single project holds several lease pieces. A description that sets `n_farms=` or
`domain=` makes a scenario a {class}`~oowl.Cluster` of farms placed next to one
another instead, which carries what belongs to the set rather than to any
member, namely the root seed that replays the arrangement, the placement record,
and one wind resource and surface for the whole set. `Cluster.plot` draws every
member on one shared map, because they were placed in one coordinate frame.
Which of the two a scenario is follows from the description rather than from
what a particular draw rolls, so a population never mixes them.

{func}`~oowl.save` and {func}`~oowl.load` round-trip one farm, turbine or wind
resource, and the windIO document kind fixes which one `load` returns. A
cluster has its own directory format through
{meth}`Cluster.save <oowl.Cluster.save>` and
{meth}`Cluster.load <oowl.Cluster.load>`. A population is an ordinary tuple, so
persisting or plotting one is an ordinary loop.

```python
import oowl
from oowl import boundaries as B
from oowl import layouts as L

farms = oowl.Sampler(
    B.OffshorePolygon, L.Grid, n_turbines=(40, 120), area=(30e6, 90e6), seed=7
).sample(5)
for index, farm in enumerate(farms):
    farm.save(f"dataset/farm_{index:04d}.yaml")
```

```{eval-rst}
.. autosummary::

   oowl.save
   oowl.load
   oowl.Farm
   oowl.Cluster
```

```{eval-rst}
.. autofunction:: oowl.save

.. autofunction:: oowl.load
```

```{eval-rst}
.. autoclass:: oowl.Farm
   :members:

.. autoclass:: oowl.Cluster
   :members:
```
