EVALIDator API¶
Client for validating PyFIA estimates against official USFS values.
Overview¶
EVALIDator is the USFS online tool for FIA estimates. PyFIA includes a client to fetch official estimates for validation.
from pyfia import EVALIDatorClient, validate_pyfia_estimate
# Get official estimate
client = EVALIDatorClient()
official = client.get_forest_area("GA", 2022)
# Compare with PyFIA
validation = validate_pyfia_estimate(pyfia_result, official)
print(f"Difference: {validation.percent_difference:.2f}%")
Client Class¶
EVALIDatorClient
¶
Client for the USFS EVALIDator API.
This client provides methods to retrieve official FIA population estimates for comparison with pyFIA calculations.
| PARAMETER | DESCRIPTION |
|---|---|
timeout
|
Request timeout in seconds. Default is 30.
TYPE:
|
Example
client = EVALIDatorClient() result = client.get_forest_area(state_code=37, year=2023) print(f"Forest area: {result.estimate:,.0f} acres (SE: {result.sampling_error_pct:.1f}%)")
Source code in src/pyfia/evalidator/client.py
get_forest_area
¶
get_forest_area(state_code: int, year: int, land_type: str = 'forest') -> EVALIDatorEstimate
Get forest area estimate from EVALIDator.
| PARAMETER | DESCRIPTION |
|---|---|
state_code
|
State FIPS code (e.g., 37 for North Carolina)
TYPE:
|
year
|
Inventory year (e.g., 2023)
TYPE:
|
land_type
|
"forest" for all forestland, "timber" for timberland only
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EVALIDatorEstimate
|
Official estimate with sampling error |
Source code in src/pyfia/evalidator/client.py
get_volume
¶
get_volume(state_code: int, year: int, vol_type: str = 'net') -> EVALIDatorEstimate
Get volume estimate from EVALIDator.
| PARAMETER | DESCRIPTION |
|---|---|
state_code
|
State FIPS code
TYPE:
|
year
|
Inventory year
TYPE:
|
vol_type
|
Volume type: "net" for net merchantable, "sawlog" for board feet
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EVALIDatorEstimate
|
Official volume estimate |
Source code in src/pyfia/evalidator/client.py
get_biomass
¶
get_biomass(state_code: int, year: int, component: str = 'ag', min_diameter: float = 0.0) -> EVALIDatorEstimate
Get biomass estimate from EVALIDator.
| PARAMETER | DESCRIPTION |
|---|---|
state_code
|
State FIPS code
TYPE:
|
year
|
Inventory year
TYPE:
|
component
|
"ag" for aboveground, "bg" for belowground, "total" for both
TYPE:
|
min_diameter
|
Minimum DBH threshold. Use 0.0 for all trees, 5.0 for trees >=5" DBH.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EVALIDatorEstimate
|
Official biomass estimate in dry short tons |
Source code in src/pyfia/evalidator/client.py
get_tree_count
¶
get_tree_count(state_code: int, year: int, min_diameter: float = 1.0, land_type: str = 'forest') -> EVALIDatorEstimate
Get tree count estimate from EVALIDator.
| PARAMETER | DESCRIPTION |
|---|---|
state_code
|
State FIPS code
TYPE:
|
year
|
Inventory year
TYPE:
|
min_diameter
|
Minimum DBH in inches (1.0 or 5.0). Note: 5" threshold returns growing-stock trees (TREECLCD=2) only, while 1" threshold returns all live trees.
TYPE:
|
land_type
|
"forest" for forest land, "timber" for timberland only
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EVALIDatorEstimate
|
Official tree count estimate |
Notes
snum values used: - snum=4: Live trees >=1" d.b.h. on forest land (all tree classes) - snum=5: Growing-stock trees >=5" d.b.h. on forest land (TREECLCD=2) - snum=7: Live trees >=1" d.b.h. on timberland (all tree classes) - snum=8: Growing-stock trees >=5" d.b.h. on timberland (TREECLCD=2)
Source code in src/pyfia/evalidator/client.py
Data Classes¶
EVALIDatorEstimate¶
Container for EVALIDator API results.
EVALIDatorEstimate
dataclass
¶
EVALIDatorEstimate(estimate: float, sampling_error: float, sampling_error_pct: float, variance: float, plot_count: int, units: str, estimate_type: str, state_code: int, year: int, grouping: Optional[Dict[str, Any]] = None, raw_response: Optional[Dict[str, Any]] = None)
Container for an EVALIDator estimate result.
ValidationResult¶
Container for validation comparison results.
ValidationResult
dataclass
¶
ValidationResult(pyfia_estimate: float, pyfia_se: float, evalidator_estimate: float, evalidator_se: float, evalidator_variance: float, evalidator_plot_count: int, pyfia_plot_count: Optional[int], absolute_diff: float, pct_diff: float, within_1se: bool, within_2se: bool, estimate_type: str, state_code: int, year: int, passed: bool, message: str)
Result of comparing pyFIA estimate with EVALIDator.
Estimate Types¶
EstimateType¶
Predefined constants for EVALIDator estimate types.
EstimateType
¶
EVALIDator estimate type codes (snum parameter values).
Categories:
| Category | Constants |
|---|---|
| Area | AREA_FOREST, AREA_TIMBERLAND, AREA_SAMPLED |
| Volume | VOLUME_NET_GROWINGSTOCK, VOLUME_NET_ALLSPECIES, VOLUME_SAWLOG_* |
| Biomass | BIOMASS_AG_LIVE, BIOMASS_BG_LIVE, BIOMASS_AG_LIVE_5INCH |
| Carbon | CARBON_AG_LIVE, CARBON_TOTAL_LIVE, CARBON_POOL_* |
| Change | GROWTH_NET_VOLUME, REMOVALS_VOLUME, MORTALITY_VOLUME |
Validation Functions¶
validate_pyfia_estimate¶
validate_pyfia_estimate
¶
validate_pyfia_estimate(pyfia_result, state_code: int, year: int, estimate_type: str, client: Optional[EVALIDatorClient] = None, **kwargs) -> ValidationResult
Validate a pyFIA estimate against EVALIDator.
This is a convenience function that fetches the EVALIDator estimate and performs the comparison in one step.
| PARAMETER | DESCRIPTION |
|---|---|
pyfia_result
|
pyFIA estimation result DataFrame with estimate and SE columns
TYPE:
|
state_code
|
State FIPS code
TYPE:
|
year
|
Inventory year
TYPE:
|
estimate_type
|
Type of estimate: "area", "volume", "biomass", "carbon", "tpa"
TYPE:
|
client
|
Existing client instance (creates new one if not provided)
TYPE:
|
**kwargs
|
Additional arguments passed to the EVALIDator API call
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
ValidationResult
|
Comparison result |
Example
from pyfia import FIA, area from pyfia.evalidator import validate_pyfia_estimate
with FIA("path/to/db.duckdb") as db: ... db.clip_by_state(37) ... db.clip_most_recent(eval_type="EXPALL") ... result = area(db, land_type="forest")
validation = validate_pyfia_estimate( ... result, state_code=37, year=2023, estimate_type="area" ... ) print(validation.message)
Source code in src/pyfia/evalidator/validation.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
compare_estimates¶
compare_estimates
¶
compare_estimates(pyfia_value: float, pyfia_se: float, evalidator_result: EVALIDatorEstimate, tolerance_pct: float = 5.0, pyfia_plot_count: Optional[int] = None) -> ValidationResult
Compare a pyFIA estimate with an EVALIDator official estimate.
| PARAMETER | DESCRIPTION |
|---|---|
pyfia_value
|
The pyFIA estimate value
TYPE:
|
pyfia_se
|
The pyFIA standard error
TYPE:
|
evalidator_result
|
The EVALIDator official estimate
TYPE:
|
tolerance_pct
|
Acceptable percentage difference (default 5%)
TYPE:
|
pyfia_plot_count
|
Number of plots used by pyFIA (for plot count validation)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ValidationResult
|
Comparison results including pass/fail status |
Example
result = compare_estimates( ... pyfia_value=18500000, ... pyfia_se=450000, ... evalidator_result=official_estimate, ... pyfia_plot_count=1500 ... ) print(f"Validation {'PASSED' if result.passed else 'FAILED'}: {result.message}")
Source code in src/pyfia/evalidator/validation.py
Examples¶
Validate Forest Area¶
from pyfia import EVALIDatorClient, validate_pyfia_estimate
# Get PyFIA estimate
pyfia_area = pyfia.area(db, land_type="forest")
# Get official estimate
client = EVALIDatorClient()
official = client.get_forest_area("GA", 2022)
# Validate
result = validate_pyfia_estimate(pyfia_area, official)
print(f"PyFIA: {pyfia_area['estimate'][0]:,.0f} acres")
print(f"Official: {official.estimate:,.0f} acres")
print(f"Difference: {result.percent_difference:.2f}%")
print(f"Within CI: {result.within_confidence_interval}")
Validate Volume Estimate¶
# PyFIA net volume
pyfia_vol = pyfia.volume(db, vol_type="net", tree_type="gs")
# Official growing stock volume
official = client.get_volume("GA", 2022, volume_type="net_growingstock")
result = validate_pyfia_estimate(pyfia_vol, official)
Batch Validation¶
estimates = [
("area", pyfia.area(db), client.get_forest_area("GA", 2022)),
("volume", pyfia.volume(db), client.get_volume("GA", 2022)),
("biomass", pyfia.biomass(db), client.get_biomass("GA", 2022)),
]
for name, pyfia_est, official in estimates:
result = validate_pyfia_estimate(pyfia_est, official)
print(f"{name}: {result.percent_difference:.2f}% diff")