Skip to content

chore: move STATISTICAL livestock production into attribute, anchor to FAOSTAT ids - #28

Merged
jeffseif merged 5 commits into
mainfrom
jeffseif/livestock-and-taxonomy-into-trace
Nov 6, 2026
Merged

jeffseif merged 5 commits into
mainfrom
jeffseif/livestock-and-taxonomy-into-trace

Conversation

@jeffseif

@jeffseif jeffseif commented Nov 6, 2026

Copy link
Copy Markdown
Member

Background

This is mainly a refactor to get the S and JD attributions lined up to a common approach before we implement trace for JDP. This was originally going to be one big 'ol branch but this preparation work became larger.

The changes

  1. 23ca2eb Move S livestock production from attribute to trace. The design was to have attribute only allocate emissions and for trace to join those onto productions and rollup over jurisdictions. When we implemented livestock, it was convenient to do all of livestock's production within attribute since that depended on both map data (GPW's head raster) and tabular data (FAOSTAT's livestock patterns). We wanted to avoid passing head counts over time as new columns in attribute, causing JD and S attribute schemas to drift apart ... but today we decided to swap that tradeoff.
  2. b1bdf22 Stand up JD's mapping from USDA/NASS/CDL crops to FAOSTAT commodities, including three negative custom ones for DROPPED, UNATTRIBUTED, and PASTURE which understandably don't have items in FAOSTAT. So far this isn't used
  3. 3fea6ad ^^ for S (including custom negative ids for OTHER_OILCROPS and OTHER_PULSES) and then plug the new taxonomy mappings into trace. This also changes the schema for trace so that the pkey switches from commodity_name: str to commodity_id: int, causing the former to become a fact column with the FAOSTAT name. Also ensure the tools are brought along
  4. f58ed2b have validation use the taxonomy mappings too
  5. af2cb8f update docs to reflect all of this

Manual testing

  1. Ran trace for HND and verified its schema and new FAOSTAT values
  2. Compared numerical values against recent caches and found they matched within float epsilon

… (like JD)

Instead of production, pass heads from attribute to trace
Use commodity taxonomies in trace
Change trace's pkey from `commodity_name: str` to `commodity_id: int`
@jeffseif
jeffseif requested a review from blallen November 6, 2026 00:19
Comment thread jdluc/taxonomy.py Resolved
Comment thread jdluc/taxonomy.py Resolved

@blallen blallen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did a peer program, looks good

@jeffseif
jeffseif merged commit c0fb7d5 into main Nov 6, 2026
2 checks passed
@jeffseif
jeffseif deleted the jeffseif/livestock-and-taxonomy-into-trace branch November 6, 2026 22:09
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.

2 participants