auto-generate deflator files from inflation_default.csv#63
Open
merveturan wants to merge 6 commits intomainfrom
Open
auto-generate deflator files from inflation_default.csv#63merveturan wants to merge 6 commits intomainfrom
merveturan wants to merge 6 commits intomainfrom
Conversation
- 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
| @@ -1,4 +1,5 @@ | |||
| DEFAULT_DOLLAR_YEAR = 2024 | |||
| DEFAULT_DOLLAR_BASED_YEAR = 2004 | |||
Contributor
There was a problem hiding this comment.
This value is already specified in the dollar_year switch in cases.csv, so should be read from there:
Line 64 in 3a3bd81
| 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)" |
Contributor
There was a problem hiding this comment.
It would be nice to avoid setting the same value in multiple places. This value is also set in bokeh:
)I would either use the value from bokeh or remove it from bokeh and read it from here.
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 |
Contributor
There was a problem hiding this comment.
You could instead use the existing get_inflatable() function:
inflatable = reeds.io.get_inflatable()
deflator = 1 / inflatable[2004].loc[2004:2024]Updated the description for 'dollar_year' to clarify its purpose.
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
This PR resolves #46 by auto-generating deflator values directly within
copy_files.pyfrominputs/inflation_default.csv, eliminating the need to manually maintain a separateinputs/deflators.csvfile. Previously,deflators.csvhad 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 readsinputs/inflation_default.csvand derives the full deflator time series from it automatically. The previously hand-maintainedinputs/deflators.csvfile 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_yearswitch has been relocated from cases toscalers.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 scalardollar_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 resultsReEDS_DOLLAR_YEAR— the modeled dollar year as defined in the modelBoth are centralized in
\postprocessing\bokehpivot\defaults.py. Going forward, if the modeled dollar year needs to change, developers only need to updatescalers.csvand\postprocessing\bokehpivot\defaults.py.Additional changes
inputs/deflators.csvremoved from the repository.Switches added/removed/changed
The
dollar_yearswitch has been relocated from cases toscalers.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.
Checklist for author
Details to double-check
hourlize/resource.pywas rerun to regenerate the existing/prescribed VRE capacity dataGeneral information to guide review
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