pyforestry.sweden.simulation.orchestration package#

Submodules#

pyforestry.sweden.simulation.orchestration.runbook module#

Running Sweden’s scenario configurations over real stands.

This module used to emit the artifact contract from a seeded random walk, with every file stamped "synthetic": true and a warning on every call, because nothing existed that could run a configuration for real. That is what pyforestry.simulation.scenario.run_scenario() now does, and this is Sweden’s entry point into it: it supplies the Elfving (2010) growth model, a Brandel (1990) volume reporter and a starting tree list, and hands everything else to the shared runner.

The numbers it writes are a projection. Nothing is stamped synthetic because nothing is.

pyforestry.sweden.simulation.orchestration.runbook.brandel_stand_volume(ctx: SimulationContext) → float[source]#

Return the stand’s standing volume now, in m³/ha, from Brandel (1990).

Summed over the tree list as it currently stands, so a thinning between two growth steps is visible immediately – a reporter that read a value cached at the last model step would report every removal as zero and fold the volume it took back into growth.

Trees too small for the volume functions contribute nothing rather than raising: a stand of saplings has a volume, and it is near enough zero.

pyforestry.sweden.simulation.orchestration.runbook.build_even_aged_stands(n_stands: int, *, species: TreeName | None = None, stems_per_ha: float = 1200.0, mean_dbh_cm: float = 18.0, mean_height_m: float = 16.0, age_years: float = 40.0) → list[StandUnit][source]#

Build n_stands even-aged stands as a starting inventory.

A linear diameter spread around the mean, so the stand has a distribution for a single-tree model to work on rather than one repeated tree. Supply your own StandUnit list for real inventory.

Raises:

ValueError – If n_stands is not positive.

pyforestry.sweden.simulation.orchestration.runbook.run_sweden_scenario(*, global_seed: int, output_dir: Path, config: ScenarioConfig | None = None, stands: Sequence[StandUnit] | None = None, n_stands: int = 8, n_steps: int = 10, step_years: float = 5.0, attrs: Mapping[str, Any] | None = None, valuation: ValuationSettings | None = None, discount_rate: float | None = None, disturbance_rate_per_year: float = 0.0, thin_at_age: Sequence[AgeMeasurement] | None = None, thin_at_year: Sequence[float] | None = None, start_age: AgeMeasurement | None = None, time_to_breast_height: float | None = None, start_year: float = 0.0, forcings: ForcingSet | None = None) → ScenarioRunResult[source]#

Run a Sweden scenario with the Elfving (2010) model and write its artifacts.

Parameters:
  • global_seed – The run’s seed; each stand’s derives from it.

  • output_dir – Where the three artifacts go.

  • config – The scenario configuration. Defaults to the baseline.

  • stands – Stands to project. Defaults to n_stands even-aged spruce stands from build_even_aged_stands().

  • n_stands – How many default stands to build.

  • n_steps – Number of periods.

  • step_years – Period length in years.

  • attrs – Site facts for the growth model, merged over the defaults.

  • valuation – Price list, taper and bucking settings. Required if the configuration declares a "valuation" stage, which Sweden’s baseline does. Build the price list with its PricelistIdentity – Sweden’s example prices ship theirs as MELLANSKOG_2013_IDENTITY – so the manifest records what currency the summary’s money is in and whose prices earned it.

  • discount_rate – The annual rate the summary’s net present value is discounted at. Required alongside valuation for the same reason it is: Sweden’s baseline prices what it cuts, and a net present value in an artifact has to say what it was discounted at. 0.0 states no time preference.

  • disturbance_rate_per_year – Annual share of the stand a scenario disturbance removes, before the scenario’s disturbance_factor. Supplied by the caller; this package ships no rate, because a disturbance rate is a finding and there is no source for one here. Zero, the default, makes the stage an exact no-op.

  • thin_at_age – Stand ages at which the management stage thins, as Age.TOTAL(60) or Age.DBH(47). The one to reach for. Defaults to the age build_even_aged_stands() built the stands at, so a run using the default inventory need only give the ages.

  • thin_at_year – Calendar years at which it thins instead, read against start_year. Mutually exclusive with thin_at_age.

  • start_age – How old the stands are at the start. Defaults to _BASELINE_AGE_YEARS as a total age, which is what build_even_aged_stands() gives its trees; supply it when passing your own stands.

  • time_to_breast_height – Years to 1.3 m, needed only to schedule in one age measure stands described in the other.

  • start_year – Calendar year the projection begins in, which is the year a forcing series is read at.

  • forcings – Named values the run reads per period – a weather correction, a price index. This package ships none.

Returns:

The run result, including the written artifacts.

pyforestry.sweden.simulation.orchestration.runbook.swedish_timber_factory(removal: StemDimensions) → SweTimber[source]#

Build the SweTimber Sweden’s taper functions require.

EdgrenNylinder1949.validate rejects anything that is not a SweTimber, so a Sweden valuation configured with the base Timber the ledger builds by default fails inside the bucker rather than at configuration time. Pass this as ValuationSettings(timber_factory=...).

Serves either kind of removal – an individual stem or a stand’s mean tree – since both report a species, a diameter and a height.

Module contents#

Running Sweden’s scenario configurations over real stands.