Add structure for moving report.gms to Python#142
Open
patrickbrown4 wants to merge 12 commits into
Open
Conversation
…from e_report.gms
… wrong for stress periods before the final year
16 tasks
patrickbrown4
commented
Jul 14, 2026
| (dfs['tran_flow_all_rep'] * g['hours'] / dfs['tran_cap_energy']).groupby(['r','rr','trtype','t']).sum() | ||
| / g['hours'].sum() | ||
| ) | ||
| ## NOTE: We here assume that all solve years use the same total weighting for stress |
Contributor
Author
There was a problem hiding this comment.
The method on main is off for years before the last year; see #146. This implementation fixes it and is self-consistent when stress periods are always weighted at 6 hours per solve year, but if #146 is fixed as suggested, we should instead use hours_h(allh,t) here to make it future-proof in case we switch to nonuniform stress period weights.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Following in the vein of #61 and #139, this PR adds a structure for moving the calculations in
report.gmsto Python and uses it for a couple blocks of outputs as examples.Technical details
Implementation notes
The proposed structure is:
report_data.csv(inreeds/core/terminus){case}/outputs/results.gdxreport_dump.pycalls a newreport_calcs.main(), which returns a dictionary of output parameters calculated in Python. These parameters then get written to{case}/outputs/{param}.csvand/or{case}/outputs/outputs.h5, as usual.report_calcs.main()has some helper functions for common operations at the top, followed by blocks of calculations for the different types of outputs.Some notes given the current mix of standards:
report.gmstoreport_calcs.pyare listed in a block comment at the top ofreport.gms, so searching for them will turn up both scripts.report.gmswill not show up in{case}/outputs/rep_{case}.gdx{case}/outputs/outputs.h5is unchangedreport_calcs.pyAdditional changes
A new
reeds.results.diff_outputs()function has been added. This function works likegdxdiffbut foroutputs.h5files, and can be used to do a global comparison of outputs between pairs of cases.Validation, testing, and comparison report(s)
Zero change for the USA_defaults case: results-v20260708_mainK0_USA_defaults,v20260709_reportK0_USA_defaults.pptx
Checklist for author
Details to double-check
General information to guide review
Did you use LLM tools (chatbot or copilot) in the preparation of this PR? If so, describe how
No