Skip to content

[Econ] Add partial budget breakdown output - #3252

Merged
matthew7838 merged 4 commits into
refactor_preprocessfrom
budget-analysis
Sep 16, 2026
Merged

matthew7838 merged 4 commits into
refactor_preprocessfrom
budget-analysis

Conversation

@matthew7838

Copy link
Copy Markdown
Collaborator

Adds a flat partial budget line item breakdown so each economics cost and revenue can be audited from one CSV or JSON output.

Context

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

What

  • New econ_pba_breakdown output with one entry per line item and scenario: module, flow_type, item, scenario, biophysical_aggregate, price_aggregate, line_item_value.
  • Exported by PartialBudget.export_line_item_breakdown, called from EconomicFramework.run_economic_analysis, so it is produced whenever economics runs.
  • The totals and the breakdown share the same line item iteration and value coercion, so summing line_item_value by flow_type reproduces econ_pba_cost_total and econ_pba_revenue_total.

Test plan

  • New unit tests cover the row contents, reconciliation with the PBA totals, the framework wiring, and the OutputManager CSV rendering. Full test suite passes.
  • 7-year freestall example: 54 rows; cost rows sum to $934,403.23 and revenue rows to $8,767,205.38, matching econ_pba_cost_total / econ_pba_revenue_total (unchanged from the base branch). biophysical_aggregate x price_aggregate reproduces every line item value, and the JSON-vs-CSV comparison script attached to [Econ] Add partial budget analysis breakdown to ouput manager #3211 reports zero difference.

Input Changes

  • N/A

Output Changes

  • partial_budget.export_line_item_breakdown.econ_pba_breakdown: partial budget line item table described above.

Filter

Save as output/output_filters/csv_econ_partial_budget.txt to get the breakdown and the PBA totals in one CSV:

econ_pba_

Exports econ_pba_breakdown from the economics framework: one entry per
line item and scenario with the biophysical module, cost/revenue flow
type, item name, biophysical aggregate, price aggregate, and line item
value, so the partial budget totals can be audited line by line from a
single CSV or JSON output (issue #3211). PartialBudget shares the line
item iteration and value coercion between the totals and the breakdown,
so the two reconcile by construction. Verified on the 7-year freestall
example: 54 rows whose cost and revenue sums match econ_pba_cost_total
and econ_pba_revenue_total, unchanged from the base branch.
@matthew7838 matthew7838 linked an issue Sep 3, 2026 that may be closed by this pull request

@JoeWaddell JoeWaddell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks to be working well! The only thing I got hung up on was the baseline notation: want to confirm that having alternative scenarios is waiting to be implemented in another PR, correct?

@matthew7838

Copy link
Copy Markdown
Collaborator Author

This looks to be working well! The only thing I got hung up on was the baseline notation: want to confirm that having alternative scenarios is waiting to be implemented in another PR, correct?

Yes, I think whoever takes on #3212 and takes a deeper look into it can decide whether it's worth creating a separate issue to track it. I do think this PR should be kept within scope as it is.

Comment thread RUFAS/EEE/economics/partial_budget.py Outdated
Comment on lines +15 to +17
# Units for each field of the ``econ_pba_breakdown`` rows exported by
# ``PartialBudget.export_line_item_breakdown``. Biophysical quantities and prices mix units
# across line items (kg, head, hours, ...), so they are reported as unitless.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Units for each field of the ``econ_pba_breakdown`` rows exported by
# ``PartialBudget.export_line_item_breakdown``. Biophysical quantities and prices mix units
# across line items (kg, head, hours, ...), so they are reported as unitless.

Comment thread RUFAS/EEE/economics/partial_budget.py Outdated
Comment on lines +110 to +114
# Supporting multi-year scenarios will require accumulating results across
# scenarios as outlined in `Documentation of Economic Data and Analytical
# Methods (2).pdf`.

def _calculate_from_preprocessed(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# Supporting multi-year scenarios will require accumulating results across
# scenarios as outlined in `Documentation of Economic Data and Analytical
# Methods (2).pdf`.
def _calculate_from_preprocessed(
def _calculate_from_preprocessed(

@matthew7838
matthew7838 merged commit e1cbc87 into refactor_preprocess Sep 16, 2026
@matthew7838
matthew7838 deleted the budget-analysis branch September 16, 2026 04:33
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] Add partial budget analysis breakdown to ouput manager

3 participants