Skip to content

Move more inputs to inputs.h5 and add compatibility with forecast.py - #139

Open
patrickbrown4 wants to merge 34 commits into
mainfrom
pb/inputs
Open

Move more inputs to inputs.h5 and add compatibility with forecast.py#139
patrickbrown4 wants to merge 34 commits into
mainfrom
pb/inputs

Conversation

@patrickbrown4

@patrickbrown4 patrickbrown4 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR builds on #61 by moving more inputs to inputs.h5, removing another ~10% (~600 lines) of b_inputs.gms.

Technical details

Implementation notes

Most of the changes are just normalizing headers in input .csv files and changing .to_csv() to reeds.io.write_input_to_h5(). Outputs of the following input-processing scripts are moved to inputs.h5:

  • calc_financial_inputs.py: complete
  • transmission.py: complete
  • copy_files.py: a smattering (not complete)

More substantive changes are:

  • forecast.py is adapted to work for parameters in inputs.h5
    • forecast.py is also moved later in the input-processing pipeline; in its old location it was missing some parameters from transmission.py. The new parameters are added to the bottom of futurefiles.csv.
  • The CO2 storage parameter processing is moved from b_inputs.gms to get_co2_site_char() in transmission.py
    • The t index is removed from cost_co2_stor_bec because it doesn't vary with time
  • The application of GSw_TransCostMult is moved upstream to transmission.py
  • inputs/waterclimate files are reshaped from wide to long
  • overwrite in reeds.io.write_input_to_h5() is turned on by default, making the input-processing scripts easier to debug

Additional changes

  • reedsplots.plot_diff_maps(): A level parameter is added, and when used in compare_cases.py, state resolution is used when runs with different spatial resolution are compared (thanks @kodiobika for the idea and initial implementation)
  • plots.rainbowmapper(): colormap moved to keyword argument

Validation, testing, and comparison report(s)

Only rounding differences for the Pacific test case (expected when moving from .csv to .h5):
results-v20260708_mainM0_Pacific,v20260708_inputsM2_Pacific.pptx

Same for USA_defaults: results-v20260708_mainK0_USA_defaults,v20260708_inputsK1_USA_defaults.pptx

Checklist for author

  • r2x (either write trancap_init_energy to .csv or set up r2x to read from inputs.h5)

Details to double-check

  • Charge code provided to reviewers
  • Included comparison reports for appropriate test cases
  • Code formatting standardized
  • Reusable functions used where possible instead of copy/pasted code

General information to guide review

  • Zero impact on results of default case
  • No large data file(s) added/modified
  • No substantive impact on runtime for full-US reference case
  • No substantive impact on folder size for full-US reference case
  • No change to process flow (runreeds.py, reeds/core/solve/solve.py)
  • No change to code organization
  • No change to package requirements (environment.yml or Project.toml)

Did you use LLM tools (chatbot or copilot) in the preparation of this PR? If so, describe how

No

x.csv,.csv,1,None,9999,None,9999,0,constant,None,None,new,
yearafter.csv,.csv,1,None,9999,None,9999,0,constant,None,None,new,
years_until_endogenous.csv,.csv,1,None,9999,None,9999,0,constant,None,None,done,constant
allh,inputs.h5,1,,,,9999,,,,,,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm looking forward to removing all the entries that are ignored, but let's save that for a followup (and discuss how to make sure new t-dependent parameters are handled if we aren't enforcing (mostly empty) entries for all parameters)

Comment thread cases_test.csv Outdated
GSw_Region,cendiv/Pacific,,country/USA,country/USA,country/USA,,st/ID.WY.NE.IA.IL,st/MA,,,,,,,st/WY,interconnect/western,transreg/PJM,st/NY.VT,st/OR,st/NE.NY.PA,st/NE.NY.PA,st/ID.WY.NE.IA.IL,st/KS,country/USA,country/USA,,,,st/MA.RI.CT.NY.NJ.PA.OH,
endyear,2032,,2050,2050,2050,2029,2060,2026,,,,,,,,,,,2035,2030,2030,2060,2035,2050,2050,,,,,
yearset,,,,,,,2010..2060..10,,,,,,,,,,,,,2010..2050..5,2010..2050..5,2010..2060..10,,,2010_2025_2050,,,,,
yearset,,,,,,,2010..2060..10,,,,,,,,,,,,,2010..2050..5,2010..2050..5,2010..2060..10,,2010..2050..5,2010_2025_2050,,,,,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

USA_fast originally used 5-year steps; I'm not sure when that was dropped but this just changes it back

Comment thread runreeds.py
+ '\n> '.join([c for c in df_cases.columns])
)
raise KeyError(err)
raise ValueError(err)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Prints a prettier message this way

sw['financials_sys_suffix'], inflation_df, modeled_years,
years, year_map, sw['sys_eval_years'], scen_settings, scalars['co2_capture_incentive_length'],scalars['h2_ptc_length'])
financials_sys.to_csv(os.path.join(inputs_case,'financials_sys.csv'),index=False)
financials_sys.to_csv(os.path.join(inputs_case,'financials_sys_full.csv'),index=False)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Avoids errors when restarting this script (since before it was overwriting a file in inputs_case)

@kodiobika
kodiobika requested review from kodiobika and removed request for kodiobika July 9, 2026 18:48
Comment thread reeds/plots.py
Comment thread reeds/input_processing/runfiles.csv
Comment thread inputs/userinput/futurefiles.csv
Comment thread reeds/input_processing/calc_financial_inputs.py Outdated
Comment thread reeds/input_processing/writecapdat.py Outdated

@kodiobika kodiobika left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

patrickbrown4 added a commit that referenced this pull request Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants