Skip to content

Add create_canopy_fuel_grid_from_inventory to v2 SDK - #206

Merged
amarcozzi merged 2 commits into
mainfrom
196-canopy-fuel-grid-from-inventory
Aug 26, 2026
Merged

Add create_canopy_fuel_grid_from_inventory to v2 SDK#206
amarcozzi merged 2 commits into
mainfrom
196-canopy-fuel-grid-from-inventory

Conversation

@amarcozzi

Copy link
Copy Markdown
Contributor

Wraps the generated create_inventory_canopy_grid endpoint in the hand-written v2 grids surface (fastfuels_sdk/v2/grids.py), following the create_<thing>_grid_from_<source> convention.

What

create_canopy_fuel_grid_from_inventory(inventory, ...) derives canopy fuel bands (cbd, cbh, chm, cc, and optionally cfl) for each cell directly from a completed tree inventory (live trees only, matching FuelCalc). It accepts an Inventory object (its domain is read from the object) and returns a pending Grid.

The endpoint's many method choices are exposed as friendly kwargs with sensible defaults that map onto the generated union models:

  • biomass source: biomass_equations (nsvb / jenkins / brown_1978) vs. biomass_column (precomputed available fuel)
  • available fuel (allometry only): foliage_fraction, branchwood_fraction, branchwood_size_partition
  • species inclusion, crown-class adjustment, min_tree_height
  • vertical/horizontal distribution, layer_depth
  • max crown radius source: max_crown_radius_equations vs. max_crown_radius_column
  • per-band reduction methods cbd / cbh / chm / cc: each accepts a method-name string (built with default parameters) or a prebuilt method object (e.g. CanopyCbhPercentile(percentile=25)) for non-default parameters
  • alignment via output_resolution_m / align_to / resampling (native is not supported by this endpoint)

Generated client code is imported, not modified. The function is exported through ff.grids.* via grids.py's __all__.

Tests

tests/v2/test_grids.py gains TestCreateCanopyFuelGridFromInventory, mirroring the DUET test structure: offline request-building/validation tests (monkeypatched endpoint) plus a live end-to-end test.

  • Offline unit tests: 11 passed.
  • black and flake8 pass (pre-commit clean).
  • Live test (test_create_live): passed against the live API (~69s) — creates the grid from the shared tree-inventory fixture, waits to completion, asserts the five bands, and reads the cbd array.

Closes #196

Wrap the create_inventory_canopy_grid endpoint in the hand-written grids
surface, following the create_<thing>_grid_from_<source> convention. The
function derives canopy fuel bands (cbd, cbh, chm, cc, cfl) from a
completed tree inventory.

The many method choices map onto the generated union models through
friendly kwargs with sensible defaults: biomass source (allometry vs
inventory column), available-fuel reduction, species inclusion,
crown-class adjustment, min tree height, vertical/horizontal
distribution, layer depth, max-crown-radius source, and per-band cbd/
cbh/chm/cc reduction methods (a method name string or a prebuilt method
object for non-default parameters).
…from-inventory

# Conflicts:
#	tests/v2/test_grids.py
@amarcozzi
amarcozzi merged commit 40ce6e5 into main Aug 26, 2026
1 of 3 checks passed
@amarcozzi
amarcozzi deleted the 196-canopy-fuel-grid-from-inventory branch August 26, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK: create canopy fuel grid from tree inventory

1 participant