nemora.synthesis
The synthesis package bundles helper modules for:
tessellation: configuration objects describing the rlandscape-style point processes, seed counts, and editing knobs that inform Voronoi tiling.stands: routines that translate vegetation/age-class distributions into reusable templates (inspired by the FLG Weibull-based workflow).exporters: JSON/GeoJSON convenience functions for persisting synthesis metadata and placeholder geometries while the full CLI matures.
Seed-point configuration helpers for Voronoi-based landscape tiling.
The CJFR rlandscape paper describes a mixture of four point processes and two editing knobs (hole/merge fractions) that collectively control the number of management units, polygon area variation, and vertex-degree statistics. This module captures those inputs so downstream synthesis code (Phase 1 of the plan) can generate repeatable seed sets and share the configuration with docs/tests.
- class nemora.synthesis.tessellation.ClusterConfig(size=6, spread=0.05)[source]
Parameters controlling the cluster point process.
- class nemora.synthesis.tessellation.InhibitionConfig(min_distance=None, max_attempts_per_point=500)[source]
Parameters controlling the inhibition (SSI) process.
- class nemora.synthesis.tessellation.LatticeConfig(resolution=None, jitter=0.0)[source]
Parameters controlling the lattice/grid process.
- class nemora.synthesis.tessellation.MaskGeometry(polygons, name=None, mode=MaskMode.CLIP)[source]
Optional clipping geometry for Voronoi polygons.
- class nemora.synthesis.tessellation.PointProcessMix(uniform=1.0, cluster=0.0, inhibition=0.0, lattice=0.0)[source]
Proportions for the four rlandscape point processes.
- class nemora.synthesis.tessellation.RasterMask(values, threshold=0.0, mode=RasterMode.KEEP, name=None)[source]
Raster-based modifier that keeps or excludes polygons.
- Parameters:
values (ndarray)
threshold (float)
mode (RasterMode)
name (str | None)
- class nemora.synthesis.tessellation.SeedLayoutConfig(mode=SeedLayoutMode.RANDOM, points=None, source=None, geojson_polygons=None)[source]
Deterministic layout configuration (hex grid or imported points).
- Parameters:
mode (SeedLayoutMode)
points (ndarray | None)
source (str | None)
- class nemora.synthesis.tessellation.SeedLayoutMode(value)[source]
Seed placement strategies available to callers/CLI.
- class nemora.synthesis.tessellation.VoronoiEditConfig(hole_fraction=0.0, merge_fraction=0.0)[source]
Placeholder for polygon deletion/merging controls.
- class nemora.synthesis.tessellation.VoronoiMetrics(polygon_count, area_mean, area_cv, vertex_degree_mean, vertex_degree_std)[source]
Summary statistics matching the CJFR target controls.
- class nemora.synthesis.tessellation.VoronoiSeedConfig(count, aspect_ratio=1.0, mix=<factory>, cluster=<factory>, inhibition=<factory>, lattice=<factory>, edit=<factory>, mask=None, mask_overlays=<factory>, raster_masks=<factory>, layout=<factory>, rng=None)[source]
Input knobs for the (future) Voronoi generator.
- Parameters:
count (int)
aspect_ratio (float)
mix (PointProcessMix)
cluster (ClusterConfig)
inhibition (InhibitionConfig)
lattice (LatticeConfig)
edit (VoronoiEditConfig)
mask (MaskGeometry | None)
mask_overlays (list[MaskGeometry])
raster_masks (list[RasterMask])
layout (SeedLayoutConfig)
rng (Generator | None)
- class nemora.synthesis.tessellation.VoronoiSeedResult(points, config, process_counts, hole_points, merge_pairs, polygons, metrics)[source]
Container for the generated seeds plus bookkeeping metadata.
- Parameters:
points (ndarray)
config (VoronoiSeedConfig)
hole_points (ndarray)
merge_pairs (ndarray)
metrics (VoronoiMetrics)
- nemora.synthesis.tessellation.generate_seed_points(config)[source]
Generate provisional seed coordinates for Phase 1 prototypes.
- Return type:
- Parameters:
config (VoronoiSeedConfig)
- nemora.synthesis.tessellation.load_mask_from_geojson(path, *, name=None, mode=MaskMode.CLIP)[source]
Load a simple polygon or multipolygon mask from GeoJSON.
- Return type:
- Parameters:
- nemora.synthesis.tessellation.load_polygons_from_geojson(path)[source]
Return polygon coordinates from a GeoJSON file.
- nemora.synthesis.tessellation.load_raster_mask(path, *, threshold=0.0, mode=RasterMode.KEEP, name=None)[source]
Load a raster (NumPy .npy/.npz or CSV/txt) used to keep/exclude polygons.
- Return type:
- Parameters:
path (Path)
threshold (float)
mode (RasterMode)
name (str | None)
Stand-attribute templates inspired by the FLG workflow.
- class nemora.synthesis.stands.StandAttributeSample(vegetation_type, age_class, area)[source]
Concrete stand attribute sampled from a template.
- class nemora.synthesis.stands.StandAttributeTemplate(vegetation_type, age_class_cdf, patch_weibull)[source]
Reusable patch recipe derived from vegetation/age-class tables.
- Parameters:
- class nemora.synthesis.stands.StandBootstrapAssignment(stand_id, vegetation_type, age_class, area, bootstrap_id)[source]
Resolved bootstrap reference for a stand attribute sample.
- class nemora.synthesis.stands.StandBootstrapLibraryEntry(identifier, source, metadata, dbh_vectors)[source]
Loaded bootstrap payload (metadata + DBH vectors).
- class nemora.synthesis.stands.StandBootstrapManifest(attributes_source, plan_source, assignments, bootstraps)[source]
Resolved bootstrap manifest linking stands to payloads.
- Parameters:
attributes_source (str | None)
plan_source (str | None)
assignments (Sequence[StandBootstrapAssignment])
bootstraps (Mapping[str, StandBootstrapLibraryEntry])
- class nemora.synthesis.stands.StandBootstrapPlan(rules, default_rule=None)[source]
Parsed bootstrap plan describing stand-to-payload rules.
- Parameters:
rules (Sequence[StandBootstrapRule])
default_rule (StandBootstrapRule | None)
- class nemora.synthesis.stands.StandBootstrapRule(identifier, source, vegetation_type, age_class, bootstrap_path=None, analytic_metadata=None)[source]
Rule describing how to attach a bootstrap payload to a stand sample.
- nemora.synthesis.stands.build_bootstrap_assignments(samples, plan, *, id_prefix='stand', start_index=1)[source]
Resolve bootstrap payloads for each stand sample.
- Return type:
tuple[list[StandBootstrapAssignment],dict[str,StandBootstrapLibraryEntry]]- Parameters:
samples (Sequence[StandAttributeSample])
plan (StandBootstrapPlan)
id_prefix (str)
start_index (int)
- nemora.synthesis.stands.build_stand_features(polygons, samples, *, assignments=None, bootstrap_library=None)[source]
Pair Voronoi polygons with sampled attributes and return GeoJSON features.
- Return type:
- Parameters:
samples (Sequence[StandAttributeSample])
assignments (Sequence[StandBootstrapAssignment] | None)
bootstrap_library (Mapping[str, StandBootstrapLibraryEntry] | None)
- nemora.synthesis.stands.build_templates(records)[source]
Convert raw vegetation-type tables into reusable templates.
Each record is expected to expose:
vegetation_type: identifier stringage_classes: sequence of(label, cumulative_probability)patch_weibull:(shape, scale, shift)tuple describing patch areas
- nemora.synthesis.stands.load_bootstrap_manifest(path)[source]
Load a stand→bootstrap manifest produced by the linker CLI.
- Return type:
- Parameters:
path (Path)
- nemora.synthesis.stands.load_bootstrap_plan(path)[source]
Load a bootstrap assignment plan describing stand → payload rules.
- Return type:
- Parameters:
path (Path)
- nemora.synthesis.stands.load_samples_from_json(path)[source]
Load stand attribute samples (vegetation/age/area) from JSON.
- Return type:
- Parameters:
path (Path)
- nemora.synthesis.stands.load_templates_from_json(path)[source]
Load stand templates from a JSON file (list of record dictionaries).
- Return type:
- Parameters:
path (Path)
- nemora.synthesis.stands.sample_stand_attributes(templates, *, total_area, rng=None, weights=None)[source]
Fill
total_areawith sampled stand attributes.- Return type:
- Parameters:
Lightweight exporters for upcoming synthesis artifacts.
- nemora.synthesis.exporters.export_geojson(features, path, crs=None)[source]
Emit a FeatureCollection skeleton for downstream GIS tooling.
- nemora.synthesis.exporters.export_metadata_json(metadata, path)[source]
Write synthesis metadata (control knobs, metrics, provenance) to disk.
- nemora.synthesis.exporters.export_seed_recipe(result, path, *, include_points=True, include_polygons=False)[source]
Persist a seed recipe JSON (config + metadata, optionally raw coordinates).
- Return type:
- Parameters:
result (VoronoiSeedResult)
path (Path)
include_points (bool)
include_polygons (bool)
- nemora.synthesis.exporters.export_stand_geojson_from_polygons(polygons, samples, path, *, crs=None, strict=False, expected_count=None, assignments=None, bootstrap_library=None)[source]
Export a GeoJSON pairing polygons and stand samples.
- Parameters:
polygons (
Sequence[ndarray]) – Iterable of polygon arrays (already filtered to remove empty polygons).samples (
Sequence[StandAttributeSample]) – Stand attribute samples produced by sample_stand_attributes.path (
Path) – Output GeoJSON file path.crs (
str|None) – Optional CRS identifier stored in the GeoJSON metadata.strict (
bool) – When True, require the generated feature count to matchexpected_count(or the min of polygons/samples when the expectation is omitted). A mismatch raisesValueError.expected_count (
int|None) – Optional explicit expected feature count for strict mode.assignments (Sequence[StandBootstrapAssignment] | None)
bootstrap_library (Mapping[str, StandBootstrapLibraryEntry] | None)
- Return type:
- nemora.synthesis.exporters.export_tree_geojson(records, path, *, crs=None)[source]
Export stem records (with DBH/attributes) as a GeoJSON FeatureCollection.
- nemora.synthesis.exporters.export_tree_table(records, path)[source]
Export stem records (flat) to CSV or Parquet based on file suffix.