Add create_canopy_fuel_grid_from_inventory to v2 SDK - #206
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wraps the generated
create_inventory_canopy_gridendpoint in the hand-written v2 grids surface (fastfuels_sdk/v2/grids.py), following thecreate_<thing>_grid_from_<source>convention.What
create_canopy_fuel_grid_from_inventory(inventory, ...)derives canopy fuel bands (cbd,cbh,chm,cc, and optionallycfl) for each cell directly from a completed tree inventory (live trees only, matching FuelCalc). It accepts anInventoryobject (its domain is read from the object) and returns a pendingGrid.The endpoint's many method choices are exposed as friendly kwargs with sensible defaults that map onto the generated union models:
biomass_equations(nsvb / jenkins / brown_1978) vs.biomass_column(precomputed available fuel)foliage_fraction,branchwood_fraction,branchwood_size_partitionmax_crown_radius_equationsvs.max_crown_radius_columncbd/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 parametersoutput_resolution_m/align_to/resampling(nativeis not supported by this endpoint)Generated client code is imported, not modified. The function is exported through
ff.grids.*viagrids.py's__all__.Tests
tests/v2/test_grids.pygainsTestCreateCanopyFuelGridFromInventory, mirroring the DUET test structure: offline request-building/validation tests (monkeypatched endpoint) plus a live end-to-end test.blackandflake8pass (pre-commit clean).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 thecbdarray.Closes #196