Skip to content

[Econ] HomeGrownFeed Revenue and Cost Processing - #3119

Draft
allisterakun wants to merge 2 commits into
economicsfrom
econ_hgf_rev_cost
Draft

[Econ] HomeGrownFeed Revenue and Cost Processing#3119
allisterakun wants to merge 2 commits into
economicsfrom
econ_hgf_rev_cost

Conversation

@allisterakun

@allisterakun allisterakun commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Context

Issue(s) closed by this pull request: closes #3079

What

Why

How

Test plan

Input Changes

Output Changes

  • N/A

Filter

@allisterakun
allisterakun changed the base branch from dev to economics June 29, 2026 13:39
Several farm-grown feeds in the feed storage configs (cereal rye,
triticale, tall fescue, winter wheat variants, and alfalfa baleage)
have no dedicated commodity price series, so their homegrown feed
revenue/cost line items were silently dropped.

Add HOMEGROWN_FEED_PRICE_ALIASES mapping each of these crop names to
the closest available proxy commodity, per the economics SME guidance
(closes #3079 discussion):
  - cereal rye / triticale grain            -> rye_grain
  - cereal rye / triticale / winter wheat
    silage and baleage                      -> barley_silage
  - tall fescue silage and baleage          -> sundan_silage
  - alfalfa baleage                         -> alfalfa_silage
  - any non-alfalfa hay                     -> hay_excluding_alfalfa

_build_feed_id_to_price_file_map now resolves keys via
_resolve_price_file_key, which prefers an exact match and otherwise
falls back to the alias, warning only when neither resolves.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@allisterakun

Copy link
Copy Markdown
Collaborator Author

Resolved the missing commodity-price data for homegrown feeds using the mapping agreed in the email thread with the economics SMEs (Kristan Reed / Braden Limb).

Added HOMEGROWN_FEED_PRICE_ALIASES in mapping.py — feed crops without a dedicated commodity_prices_*_dollar_per_kilogram series now fall back to the closest available proxy commodity:

Feed crop Proxy commodity
cereal_rye_grain, triticale_grain rye_grain
cereal_rye_silage, cereal_rye_baleage, triticale_silage, triticale_baleage, winter_wheat_silage, winter_wheat_baleage barley_silage
tall_fescue_silage, tall_fescue_baleage sundan_silage
alfalfa_baleage alfalfa_silage
cereal_rye_hay, triticale_hay, tall_fescue_hay, winter_wheat_hay hay_excluding_alfalfa

On hay: per Braden, all_hay is inclusive of alfalfa while hay_excluding_alfalfa is all_hay minus the alfalfa data (per USDA, "various grass hays and other forage crops"). All non-alfalfa hay feeds are therefore mapped to hay_excluding_alfalfa for best price/cost accuracy.

_build_feed_id_to_price_file_map now resolves via _resolve_price_file_key, which prefers an exact match and otherwise applies the alias, emitting a MissingHomegrownFeedPriceMapping warning only when neither resolves. Added unit tests covering direct match, alias resolution, unmapped crops, the no-metadata path, and that every alias target resolves.

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.

[Econ] Processing for homegrown "revenue" and "costs"

1 participant