Skip to content

auto-generate deflator files from inflation_default.csv#63

Open
merveturan wants to merge 6 commits intomainfrom
mt/issue_46
Open

auto-generate deflator files from inflation_default.csv#63
merveturan wants to merge 6 commits intomainfrom
mt/issue_46

Conversation

@merveturan
Copy link
Copy Markdown
Collaborator

@merveturan merveturan commented Apr 28, 2026

Summary

This PR resolves #46 by auto-generating deflator values directly within copy_files.py from inputs/inflation_default.csv, eliminating the need to manually maintain a separate inputs/deflators.csv file. Previously, deflators.csv had to be updated by hand each year whenever inflation values were revised, creating a risk that users would update one file but forget the other. Now, deflator values are computed programmatically at runtime.

It also automates model dollar year definition on model and postprocessing.

Technical details

Implementation notes

The core change is in copy_files.py, which now reads inputs/inflation_default.csv and derives the full deflator time series from it automatically. The previously hand-maintained inputs/deflators.csv file has been removed from the repository entirely. In addition, the current financial year, most recent year that we have inflation value, is determined as a scalar which makes the reference year explicit and easier to update in a single place.

The dollar_year switch has been relocated from cases to scalers.csv, reflecting that it characterizes the model itself rather than individual case runs. On the modeling side, all dollar year variables are now defined automatically from the scalar dollar_year.

On the postprocessing side, two distinct dollar year variables are introduced to clarify their separate roles:

  • DEFAULT_DOLLAR_YEAR — the output dollar year used when presenting results
  • ReEDS_DOLLAR_YEAR — the modeled dollar year as defined in the model

Both are centralized in \postprocessing\bokehpivot\defaults.py. Going forward, if the modeled dollar year needs to change, developers only need to update scalers.csv and \postprocessing\bokehpivot\defaults.py.

Additional changes

  • inputs/deflators.csv removed from the repository.

Switches added/removed/changed

The dollar_year switch has been relocated from cases to scalers.csv.

Issues resolved

Closes #46

Known incompatibilities

Relevant sources or documentation

Validation, testing, and comparison report(s)

The auto-generated deflator values differ from the original hand-maintained values by less than 0.2% across all years (2004–2024), as shown in the table below. These small differences are rounding errors which causes very small difference in model comparisons under Pacific case which are here.

Dollar Year Original Deflator Proposed Deflator Difference
2004 1.000000000 1.00000 0.00000
2005 0.967211529 0.96712 −0.00009
2006 0.936857351 0.93713 +0.00027
2007 0.910896792 0.91160 +0.00070
2008 0.877211857 0.87823 +0.00102
2009 0.880345888 0.88176 +0.00141
2010 0.866482174 0.86787 +0.00139
2011 0.839614509 0.84096 +0.00135
2012 0.822345259 0.82367 +0.00133
2013 0.810192373 0.81149 +0.00130
2014 0.797433438 0.79871 +0.00128
2015 0.796636802 0.79792 +0.00128
2016 0.786413427 0.78768 +0.00127
2017 0.770238420 0.77147 +0.00123
2018 0.752185957 0.75339 +0.00121
2019 0.738886009 0.74007 +0.00118
2020 0.730124515 0.73130 +0.00118
2021 0.697349107 0.69847 +0.00112
2022 0.645693617 0.64673 +0.00104
2023 0.620262841 0.62126 +0.00100
2024 0.602782158 0.60375 +0.00097

Checklist for author

Details to double-check

  • Charge code provided to reviewers
  • Included comparison reports for appropriate test cases
  • Documentation updated if necessary
  • If input data added/modified:
    • Dollar year recorded and converted to 2004$ for GAMS
    • Timeseries are in Central Time
    • Units are specified
    • Preprocessing steps have been documented and committed to ReEDS_Input_Processing
    • New large data files handled with .h5 instead of .csv
    • If spatially resolved inputs are modified, the following visualizations for each file are included in the PR description (time-averaged if the inputs are time-resolved):
      • Map of absolute values before
      • Map of absolute values after
      • Map of differences: (after - before) or (after / before)
    • If entries are added/removed/changed in the EIA-NEMS unit database:
      • Changes have been committed to ReEDS_Input_Processing
      • hourlize/resource.py was rerun to regenerate the existing/prescribed VRE capacity data
  • 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 (runbatch.py, d_solve_iterate.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

Yes, It used in preparing text and coding.

Tag points of contact here if you would like additional review of the relevant parts of the model

- Remove static `deflator.csv` files; update references in runfiles.csv and sources.csv
- Update `get_source_deflator_map()` function to build `deflator.csv` from `inflation_default.csv` in `copy_files.py`
- Add current financial year (most recent inflation value) to scalar.csv
- Update deflators.csv directory path in `output_calc.py`
- Update `inflate_series()` function in reeds2.py  to calculate deflator values from inflation_default.csv
-Add base dollar year to postprocessing defaults.py script
@merveturan merveturan requested a review from wesleyjcole April 28, 2026 06:00
Comment thread postprocessing/bokehpivot/defaults.py Outdated
@@ -1,4 +1,5 @@
DEFAULT_DOLLAR_YEAR = 2024
DEFAULT_DOLLAR_BASED_YEAR = 2004
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.

This value is already specified in the dollar_year switch in cases.csv, so should be read from there:

dollar_year,DO NOT CHANGE FROM 2004 UNTIL ALL FINANCIAL INPUTS HAVE DOLLAR YEAR ADJUSTMENT - Real dollar year for model to calculate and report,2004,2004,

Comment thread inputs/scalars.csv Outdated
cost_upgrade_gasct2h2ct,0.33,"--fraction-- Sets upgrade costs for H2-CT plants based relative to capital cost for Gas-CT."
cost_upgrade_gascc2h2cc,0.28,"--fraction-- Sets upgrade costs for H2-CC plants based relative to capital cost for Gas-CC."
cost_vom_psh,0.375,"--2004$/MWh-- VOM cost for PSH"
current_financial_year,2024,"--year-- most recent financial year to have inflation value (used for inflation adjustments)"
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.

It would be nice to avoid setting the same value in multiple places. This value is also set in bokeh:

DEFAULT_DOLLAR_YEAR = 2024
)
I would either use the value from bokeh or remove it from bokeh and read it from here.

Comment thread input_processing/copy_files.py Outdated
Comment on lines +173 to +179
# Set the initial deflator value for the base year to 1.0
deflator_values: dict[int, float] = {int(sw.dollar_year): 1.0}

# Calculate the deflator values for each year, relative to the base year, using the inflation rates
for y in years[1:]:
rate = inflation_df.loc[inflation_df['t'] == y, 'inflation_rate'].values[0]
deflator_values[y] = deflator_values[y - 1] / rate
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.

You could instead use the existing get_inflatable() function:

inflatable = reeds.io.get_inflatable()
deflator = 1 / inflatable[2004].loc[2004:2024]

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.

Calculate deflator values in calc_financial_inputs.py

2 participants