Skip to content

_extract_evaluation_year() has same EVALID parsing bug for single-digit FIPS codes #80

@mihiarc

Description

@mihiarc

Bug

_extract_evaluation_year() in src/pyfia/estimation/base.py (line 597-633) has the same fixed-width EVALID parsing bug fixed in #79 for find_evalid().

The method checks len(evalid_str) != 6 and rejects 5-digit EVALIDs from single-digit FIPS codes (AL=1, AR=5) as "invalid format", falling through to the PLOT.INVYR fallback.

if len(evalid_str) != 6:
    logger.debug(f"Invalid EVALID format: '{evalid_str}' ...")
else:
    year_part = int(evalid_str[2:4])  # Breaks for 5-digit EVALIDs

Impact

Low severity — this method is used for year inference in output metadata, not for selecting which evaluation to use. The fallback to max(INVYR) from the PLOT table usually produces a reasonable year. However, it logs misleading "Invalid EVALID format" debug messages for affected states.

Called by 6 estimators: volume, biomass, carbon_pools, site_index, tpa, grm_base.

Suggested fix

Either:

  1. Use END_INVYR from POP_EVAL (consistent with Fix EVALID year parsing for single-digit state FIPS codes #79), or
  2. Parse EVALID arithmetically: evalid % 10000 // 100 extracts the year portion regardless of digit count

Related

Fixed for find_evalid() in #79.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions