-
Notifications
You must be signed in to change notification settings - Fork 7
auto-generate deflator files from inflation_default.csv #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
merveturan
wants to merge
18
commits into
main
Choose a base branch
from
mt/issue_46
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6dea363
auto-generate deflator files from inflation_default.csv
d4c361f
reeds dollar year automation
045d081
Merge branch 'main' into mt/issue_46
2c52c58
Refactor get_source_deflator_map function parameters
merveturan cf68f3a
Correct typing error
merveturan bbfc075
Remove redundance dollar year
merveturan 6baa3ad
minor edits -- address the comments
fd0faf3
Merge branch 'main' into mt/issue_46
2532660
Merge branch 'main' into mt/issue_46
a84d964
Merge branch 'main' into mt/issue_46
merveturan 4e57cc7
Merge branch 'main' into mt/issue_46
merveturan ed6cf76
Merge branch 'main' into mt/issue_46
wesleyjcole ff21122
Merge branch 'main' into mt/issue_46
merveturan c1f2ab8
Update postprocessing/retail_rate_module/ferc_distadmin.py
merveturan 05a4601
get dollar_year from scalar.csv file in postprocessing scripts
53aa287
Update scalars.csv
d13cc32
revert copy_file.py change
fe68103
Merge branch 'main' into mt/issue_46
merveturan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -148,7 +148,7 @@ def read_runfiles(reeds_path, inputs_case, sw, agglevel_variables): | |||||||
| return runfiles, non_region_files, region_files | ||||||||
|
|
||||||||
|
|
||||||||
| def get_source_deflator_map(reeds_path): | ||||||||
| def get_source_deflator_map(reeds_path,inputs_case,write_out=True): | ||||||||
| """ | ||||||||
| Get the deflator for each input file | ||||||||
| """ | ||||||||
|
|
@@ -157,9 +157,29 @@ def get_source_deflator_map(reeds_path): | |||||||
| os.path.join(reeds_path,'docs','sources.csv'), | ||||||||
| usecols=["RelativeFilePath", "DollarYear"] | ||||||||
| ) | ||||||||
| deflator = pd.read_csv( | ||||||||
| os.path.join(reeds_path,'inputs','financials','deflator.csv'), | ||||||||
| header=0, names=['Dollar.Year','Deflator'], index_col='Dollar.Year').squeeze(1) | ||||||||
|
|
||||||||
| ### Deflator Calculation | ||||||||
| # The deflator values are calculated relative to the reeds dollar year to most recent | ||||||||
| # inputs dollar year by using inflatable. | ||||||||
| # Define the base year and current year for the deflator calculation. | ||||||||
| scalars = reeds.io.get_scalars(full=True) | ||||||||
| reeds_dollar_year=int(scalars.loc['dollar_year', 'value']) | ||||||||
| max_dollar_year = pd.to_numeric(sources_dollaryear['DollarYear'], errors='coerce').max() | ||||||||
|
|
||||||||
| # Define the deflator | ||||||||
| inflatable = reeds.io.get_inflatable() | ||||||||
| deflator =( 1 / inflatable[reeds_dollar_year].loc[reeds_dollar_year:max_dollar_year]).reset_index() | ||||||||
| deflator.columns = ['*Dollar.Year', 'Deflator'] | ||||||||
|
|
||||||||
| # if get_source_deflator_map function is being called from mcs_sampler, | ||||||||
| # we do not want to write out the deflator.csv file as it is only used for | ||||||||
| # the copy_files function. | ||||||||
|
|
||||||||
| if write_out: | ||||||||
| deflator.to_csv(os.path.join(inputs_case, 'deflator.csv'), index=False) | ||||||||
|
|
||||||||
| deflator.rename(columns={'*Dollar.Year': 'Dollar.Year'}, inplace=True) | ||||||||
|
wesleyjcole marked this conversation as resolved.
|
||||||||
|
|
||||||||
| # Create a mapping between inputs' relative filepaths and their deflation | ||||||||
| # multipliers based on the dollar years their monetary values are in | ||||||||
| sources_dollaryear = ( | ||||||||
|
|
@@ -172,7 +192,7 @@ def get_source_deflator_map(reeds_path): | |||||||
| .rename(columns={"DollarYear": "Dollar.Year"}) | ||||||||
| .merge(deflator,on="Dollar.Year",how="left") | ||||||||
| ) | ||||||||
|
|
||||||||
| source_deflator_map = dict(zip(sources_dollaryear["RelativeFilePath"], sources_dollaryear["Deflator"])) | ||||||||
|
|
||||||||
| return source_deflator_map | ||||||||
|
|
@@ -1623,7 +1643,7 @@ def main(reeds_path, inputs_case): | |||||||
| # (gswitches.csv is first written at runreeds.py) | ||||||||
| scalar_csv_to_txt(os.path.join(inputs_case,'gswitches.csv')) | ||||||||
|
|
||||||||
| source_deflator_map = get_source_deflator_map(reeds_path) | ||||||||
| source_deflator_map = get_source_deflator_map(reeds_path,inputs_case) | ||||||||
|
|
||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can move the write here:
Suggested change
|
||||||||
| # Copy non-region files | ||||||||
| write_non_region_files(non_region_files, sw, inputs_case, regions_and_agglevel, source_deflator_map) | ||||||||
|
|
||||||||
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're already reading from the ReEDS repo here, I think it would be cleaner to just read
dollar_yearfromscalars.csvtoo. Then you wouldn't need to hard-code a copy of it asREEDS_DOLLAR_YEARindefaults.py.