From 6dea36348c8b8bba846b04083e3a78d11b590051 Mon Sep 17 00:00:00 2001 From: "Olmez Turan, Merve" Date: Mon, 27 Apr 2026 23:45:37 -0600 Subject: [PATCH 01/10] auto-generate deflator files from inflation_default.csv - 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 --- input_processing/copy_files.py | 39 +++++++++++++++++++++++---- inputs/financials/deflator.csv | 22 --------------- inputs/scalars.csv | 1 + postprocessing/bokehpivot/defaults.py | 1 + postprocessing/bokehpivot/reeds2.py | 12 ++++++--- reeds/output_calc.py | 10 +++---- runfiles.csv | 2 +- sources.csv | 1 - 8 files changed, 50 insertions(+), 38 deletions(-) delete mode 100644 inputs/financials/deflator.csv diff --git a/input_processing/copy_files.py b/input_processing/copy_files.py index 90e22a098..02fdb478a 100644 --- a/input_processing/copy_files.py +++ b/input_processing/copy_files.py @@ -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,sw): """ Get the deflator for each input file """ @@ -157,9 +157,38 @@ def get_source_deflator_map(reeds_path): os.path.join(reeds_path,'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 base year, so the base year deflator is set to 1.0, and the deflator values for other years + # are calculated based on the inflation rates relative to the base year. + # Define the base year and current year for the deflator calculation. + inflation_df = pd.read_csv( + os.path.join(reeds_path,'inputs','financials','inflation_default.csv') + ) + + scalars = reeds.io.get_scalars(full=True) + # years list from the dollar year to the current financial year (inclusive) + years = [y for y in inflation_df.t if y >= int(sw.dollar_year) and y <= int(scalars.loc['current_financial_year', 'value'])] + + # 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 + + deflator = pd.DataFrame( + { + "*Dollar.Year": list(deflator_values.keys()), + "Deflator": [round(v, 9) for v in deflator_values.values()], + } + ).sort_values("*Dollar.Year").reset_index(drop=True) + + deflator.to_csv(os.path.join(inputs_case, 'deflator.csv'), index=False) + + deflator.rename(columns={'*Dollar.Year': 'Dollar.Year'}, inplace=True) + # Create a mapping between inputs' relative filepaths and their deflation # multipliers based on the dollar years their monetary values are in sources_dollaryear = ( @@ -1612,7 +1641,7 @@ def main(reeds_path, inputs_case): # (gswitches.csv is first written at runbatch.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,sw) # Copy non-region files write_non_region_files(non_region_files, sw, inputs_case, regions_and_agglevel, source_deflator_map) diff --git a/inputs/financials/deflator.csv b/inputs/financials/deflator.csv deleted file mode 100644 index 101627347..000000000 --- a/inputs/financials/deflator.csv +++ /dev/null @@ -1,22 +0,0 @@ -*Dollar.Year,Deflator -2004,1 -2005,0.967211529 -2006,0.936857351 -2007,0.910896792 -2008,0.877211857 -2009,0.880345888 -2010,0.866482174 -2011,0.839614509 -2012,0.822345259 -2013,0.810192373 -2014,0.797433438 -2015,0.796636802 -2016,0.786413427 -2017,0.77023842 -2018,0.752185957 -2019,0.738886009 -2020,0.730124515 -2021,0.697349107 -2022,0.645693617 -2023,0.620262841 -2024,0.602782158 \ No newline at end of file diff --git a/inputs/scalars.csv b/inputs/scalars.csv index 3b3d0334b..6e5235598 100644 --- a/inputs/scalars.csv +++ b/inputs/scalars.csv @@ -17,6 +17,7 @@ cost_fom_psh,13030,"--2004$/MW-year-- FOM cost for PSH" 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)" csapr_startyr,2017,"--year-- start year for CSAPR policy" csp_sm_1,2.7,"--fraction-- solar multiple for csp1" csp_sm_2,2.4,"--fraction-- solar multiple for csp2" diff --git a/postprocessing/bokehpivot/defaults.py b/postprocessing/bokehpivot/defaults.py index 1ed66fb42..ed2389537 100644 --- a/postprocessing/bokehpivot/defaults.py +++ b/postprocessing/bokehpivot/defaults.py @@ -1,4 +1,5 @@ DEFAULT_DOLLAR_YEAR = 2024 +DEFAULT_DOLLAR_BASED_YEAR = 2004 DEFAULT_PV_YEAR = 2024 ### Source for default discount rate: ### https://www.whitehouse.gov/wp-content/uploads/2023/11/CircularA-4.pdf diff --git a/postprocessing/bokehpivot/reeds2.py b/postprocessing/bokehpivot/reeds2.py index 7d8d0da49..4288fbb9a 100644 --- a/postprocessing/bokehpivot/reeds2.py +++ b/postprocessing/bokehpivot/reeds2.py @@ -16,12 +16,13 @@ import core import copy from itertools import product +from math import prod ## Inherit the default present value year to use in plot definitions -from defaults import DEFAULT_PV_YEAR +from defaults import DEFAULT_PV_YEAR,DEFAULT_DOLLAR_BASED_YEAR rb_globs = {'output_subdir':'/outputs/', 'test_file':['cap.csv','outputs.h5'], 'report_subdir':'/reeds2'} this_dir_path = os.path.dirname(os.path.realpath(__file__)) -df_deflator = pd.read_csv(os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'inputs/financials/deflator.csv')), index_col=0) +df_inflation = pd.read_csv(os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'inputs/financials/inflation_default.csv')), index_col=0) coststreams = ['eq_gasaccounting_regional','eq_gasaccounting_national','eq_bioused','eq_gasused','eq_objfn_inv','eq_objfn_op'] vf_valstreams = ['eq_supply_demand_balance','eq_reserve_margin','eq_opres_requirement','eq_rec_requirement','eq_curt_gen_balance','eq_curtailment','eq_storage_in_max','eq_storage_in_min'] # valuestreams = ['eq_supply_demand_balance','eq_reserve_margin','eq_opres_requirement','eq_rec_requirement','eq_national_gen','eq_annual_cap','eq_curt_gen_balance','eq_curtailment','eq_storage_in_max','eq_storage_in_min','eq_emit_accounting','eq_mingen_lb','eq_mingen_ub','eq_rps_ofswind'] @@ -70,8 +71,11 @@ def apply_inflation(df, **kw): return df def inflate_series(ser_in): - return ser_in * 1/df_deflator.loc[int(core.GL['widgets']['var_dollar_year'].value), 'Deflator'] - + inflation_dict = dict(zip(df_inflation.index, df_inflation['inflation_rate'])) + deflator_multiplier = prod( inflation_dict[y] + for y in range(int(DEFAULT_DOLLAR_BASED_YEAR) + 1, int(core.GL['widgets']['var_dollar_year'].value) + 1 )) + return ser_in * deflator_multiplier + def gather_cost_types(df): #Gather lists of capital and operation labels cost_cats_df = df['cost_cat'].unique().tolist() diff --git a/reeds/output_calc.py b/reeds/output_calc.py index a641bfe53..0043ceea5 100644 --- a/reeds/output_calc.py +++ b/reeds/output_calc.py @@ -214,13 +214,13 @@ def calc_h2prod(case): return df -def inflate_series(dfin, to_dollar_year=DEFAULT_DOLLAR_YEAR): +def inflate_series(case,dfin, to_dollar_year=DEFAULT_DOLLAR_YEAR): """ Inflate a series of financial data to a specified dollar year. """ df_deflator = pd.read_csv( - os.path.join(reeds_path, 'inputs', 'financials', 'deflator.csv'), - index_col=0, + os.path.join(case, '..', '..', 'inputs_case', 'deflator.csv'), + index_col=0 ) return dfin * 1 / df_deflator.loc[to_dollar_year, 'Deflator'] @@ -346,7 +346,7 @@ def calc_systemcost( df = systemcost.copy() # Apply inflation - df['Value'] = inflate_series(df['Value']) + df['Value'] = inflate_series(case,df['Value']) df.rename(columns={'Value':'Cost (Bil $)'}, inplace=True) cost_cat_map, cap_type_ls, op_type_ls = gather_cost_types(df) @@ -392,7 +392,7 @@ def calc_systemcost( df_capex_hist=df_capex_hist.loc[:firstmodelyear-1,:] # Convert to output dollar year - df_capex_hist = pd.DataFrame(inflate_series(df_capex_hist)) + df_capex_hist = pd.DataFrame(inflate_series(case,df_capex_hist)) # Insert into full cost table df = df.join(df_capex_hist, on=['year','r']) diff --git a/runfiles.csv b/runfiles.csv index 1a60f823d..d59070500 100644 --- a/runfiles.csv +++ b/runfiles.csv @@ -102,7 +102,7 @@ ctus_r_cs_spurlines_200mi.csv,,1,ignore,ignore,,,,,,,1,,,, currency_incentives.csv,inputs/financials/currency_incentives.csv,1,ignore,ignore,,,,,0,,,,,, dac_elec.csv,inputs/consume/dac_elec_{dacscen}.csv,int(sw.GSw_DAC) != 0,ignore,ignore,,,,1,0,,,,,, dac_gas.csv,inputs/consume/dac_gas_{GSw_DAC_Gas_Case}.csv,int(sw.GSw_DAC) != 0,ignore,ignore,,,,1,0,,1,,,, -deflator.csv,inputs/financials/deflator.csv,1,ignore,ignore,,,,,0,,,,,, +deflator.csv,,1,ignore,ignore,,,,,0,,1,,,, degradation_annual.csv,inputs/degradation/degradation_annual_{degrade_suffix}.csv,1,ignore,ignore,,,,,0,,,,,, demonstration_plants.csv,inputs/capacity_exogenous/demonstration_plants.csv,int(sw.GSw_NuclearDemo) != 0,sum,ignore,r,"t,i,coolingwatertech,ctt,wst,notes",i,0,0,,,,,, depreciation_schedules.csv,inputs/financials/depreciation_schedules_{depreciation_schedules_suffix}.csv,1,ignore,ignore,,,,1,0,,,,,, diff --git a/sources.csv b/sources.csv index 3cbf0c3a8..34a64f22d 100644 --- a/sources.csv +++ b/sources.csv @@ -225,7 +225,6 @@ RelativeFilePath,RelativeFolderPath,FileName_new,FileExtension,Description_new,I /inputs/financials/construction_schedules_default.csv,/inputs/financials,construction_schedules_default,.csv,,,,,, /inputs/financials/construction_times_default.csv,/inputs/financials,construction_times_default,.csv,,,,,, /inputs/financials/currency_incentives.csv,/inputs/financials,currency_incentives,.csv,,,,,, -/inputs/financials/deflator.csv,/inputs/financials,deflator,.csv,Dollar year deflator to convert values to 2004$,,,,, /inputs/financials/depreciation_schedules_default.csv,/inputs/financials,depreciation_schedules_default,.csv,,,,,, /inputs/financials/energy_communities.csv,/inputs/financials,energy_communities,.csv,,,,,, /inputs/financials/financials_hydrogen.csv,/inputs/financials,financials_hydrogen,.csv,,,,,, From d4c361ff19893e7e7686646c3937f28fbaed1063 Mon Sep 17 00:00:00 2001 From: "Olmez Turan, Merve" Date: Tue, 5 May 2026 12:53:08 -0600 Subject: [PATCH 02/10] reeds dollar year automation --- cases.csv | 1 - input_processing/calc_financial_inputs.py | 2 +- input_processing/copy_files.py | 28 ++++++------------- input_processing/transmission.py | 7 +++-- inputs/scalars.csv | 2 +- postprocessing/bokehpivot/defaults.py | 2 +- postprocessing/bokehpivot/reeds2.py | 4 +-- postprocessing/compare_cases.py | 4 +-- postprocessing/input_plots.py | 3 +- .../retail_rate_module/ferc_distadmin.py | 6 +++- .../retail_rate_module/mean_bias_error.py | 8 ++++-- .../retail_rate_calculations.py | 6 +++- 12 files changed, 37 insertions(+), 36 deletions(-) diff --git a/cases.csv b/cases.csv index 317faeb06..15d37e808 100644 --- a/cases.csv +++ b/cases.csv @@ -61,7 +61,6 @@ inflation_suffix,File suffix for historical inflation schedule,default,default, ivt_suffix,File suffix for ivt csv file,default; small; step,default, reg_cap_cost_diff_suffix,File suffix for regional capital cost differences,default,default, techs_suffix,File suffix for master list of technologies,default; subsetForTesting,default, -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, sys_eval_years,Number of years that the model evaluates investments on,int,30, numhintage,"number of hintage bins. Enter 'unit' for unit level bins. Enter 'group' to group by unique technology, region, and heatrate combinations",int,6, numbins_windons,Number of interconnection supply curve bins for onshore wind; options are 5 and 1300 (for individual sites lite),int,10, diff --git a/input_processing/calc_financial_inputs.py b/input_processing/calc_financial_inputs.py index c0053265f..b4baf4835 100644 --- a/input_processing/calc_financial_inputs.py +++ b/input_processing/calc_financial_inputs.py @@ -63,7 +63,7 @@ def calc_financial_inputs(inputs_case): # Set up scen_settings object scen_settings = reeds.financials.scen_settings( - dollar_year=int(sw['dollar_year']), tech_groups=tech_groups, inputs_case=inputs_case, + dollar_year=int(scalars['dollar_year']), tech_groups=tech_groups, inputs_case=inputs_case, sw=sw) diff --git a/input_processing/copy_files.py b/input_processing/copy_files.py index 02fdb478a..b1eee1473 100644 --- a/input_processing/copy_files.py +++ b/input_processing/copy_files.py @@ -162,28 +162,16 @@ def get_source_deflator_map(reeds_path,sw): # The deflator values are calculated relative to the base year, so the base year deflator is set to 1.0, and the deflator values for other years # are calculated based on the inflation rates relative to the base year. # Define the base year and current year for the deflator calculation. - inflation_df = pd.read_csv( - os.path.join(reeds_path,'inputs','financials','inflation_default.csv') - ) + # years list from the dollar year to the most recent year in sources.csv (inclusive) + max_dollar_year = pd.to_numeric(sources_dollaryear['DollarYear'], errors='coerce').max() + scalars = reeds.io.get_scalars(full=True) - # years list from the dollar year to the current financial year (inclusive) - years = [y for y in inflation_df.t if y >= int(sw.dollar_year) and y <= int(scalars.loc['current_financial_year', 'value'])] - - # 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 - - deflator = pd.DataFrame( - { - "*Dollar.Year": list(deflator_values.keys()), - "Deflator": [round(v, 9) for v in deflator_values.values()], - } - ).sort_values("*Dollar.Year").reset_index(drop=True) + inflatable = reeds.io.get_inflatable() + + deflator =( 1 / inflatable[int(scalars.loc['dollar_year', 'value'])].loc[int(scalars.loc['dollar_year', 'value']):max_dollar_year]).reset_index() + + deflator.columns = ['*Dollar.Year', 'Deflator'] deflator.to_csv(os.path.join(inputs_case, 'deflator.csv'), index=False) diff --git a/input_processing/transmission.py b/input_processing/transmission.py index 913ea293b..6fbe41319 100644 --- a/input_processing/transmission.py +++ b/input_processing/transmission.py @@ -32,11 +32,8 @@ decimals = 5 drop_canmex = True -dollar_year = 2004 weight = 'cost' -costcol = f'USD{dollar_year}perMW' - #%% Set up logger log = reeds.log.makelog( scriptname=__file__, @@ -46,6 +43,10 @@ #%% Inputs from switches sw = reeds.io.get_switches(inputs_case) +scalars = reeds.io.get_scalars(inputs_case) + +dollar_year = int(scalars['dollar_year']) +costcol = f'USD{dollar_year}perMW' ## networksource must end in a 4-digit year indicating the year represented by the network trans_init_year = int(sw.GSw_TransNetworkSource[-4:]) diff --git a/inputs/scalars.csv b/inputs/scalars.csv index 6e5235598..5dadc77f6 100644 --- a/inputs/scalars.csv +++ b/inputs/scalars.csv @@ -17,7 +17,6 @@ cost_fom_psh,13030,"--2004$/MW-year-- FOM cost for PSH" 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)" csapr_startyr,2017,"--year-- start year for CSAPR policy" csp_sm_1,2.7,"--fraction-- solar multiple for csp1" csp_sm_2,2.4,"--fraction-- solar multiple for csp2" @@ -25,6 +24,7 @@ csp_sm_3,1.3,"--fraction-- solar multiple for csp3" csp_sm_4,1.0,"--fraction-- solar multiple for csp4" csp_sm_baseline,2.4,"--fraction-- baseline solar multiple to normalize other CSP solar multiples by" distloss,0.05,"--fraction-- distribution loss rate from bus to final consumption. A generic estimate of distribution losses taken many years ago from AEO 2006" +dollar_year,2004,"--year00 real dollar year for model to calculate and report - DO NOT CHANGE FROM 2004 UNTIL ALL FINANCIAL INPUTS HAVE DOLLAR YEAR ADJUSTMENT" euros_dollar,1.124,"--USD/Euro-- dollars per euro exchange rate from treasury department (https://fiscal.treasury.gov/files/reports-statements/treasury-reporting-rates-exchange/ratesofexchangeasofdecember312019.pdf)" forced_outage_rate_h2_smr,0.1,"--fraction-- forced outage rate of steam methane reforming" gas_elasticity,0.76,"--fraction-- gas supply curve elasticity. long run price elasticity as estimated by: https://www.diw.de/documents/publikationen/73/diw_01.c.441773.de/dp1372.pdf" diff --git a/postprocessing/bokehpivot/defaults.py b/postprocessing/bokehpivot/defaults.py index ed2389537..fed6a62ab 100644 --- a/postprocessing/bokehpivot/defaults.py +++ b/postprocessing/bokehpivot/defaults.py @@ -1,5 +1,5 @@ DEFAULT_DOLLAR_YEAR = 2024 -DEFAULT_DOLLAR_BASED_YEAR = 2004 +ReEDS_DOLLAR_YEAR=2004 DEFAULT_PV_YEAR = 2024 ### Source for default discount rate: ### https://www.whitehouse.gov/wp-content/uploads/2023/11/CircularA-4.pdf diff --git a/postprocessing/bokehpivot/reeds2.py b/postprocessing/bokehpivot/reeds2.py index 4288fbb9a..3afbfd068 100644 --- a/postprocessing/bokehpivot/reeds2.py +++ b/postprocessing/bokehpivot/reeds2.py @@ -18,7 +18,7 @@ from itertools import product from math import prod ## Inherit the default present value year to use in plot definitions -from defaults import DEFAULT_PV_YEAR,DEFAULT_DOLLAR_BASED_YEAR +from defaults import DEFAULT_PV_YEAR,ReEDS_DOLLAR_YEAR rb_globs = {'output_subdir':'/outputs/', 'test_file':['cap.csv','outputs.h5'], 'report_subdir':'/reeds2'} this_dir_path = os.path.dirname(os.path.realpath(__file__)) @@ -73,7 +73,7 @@ def apply_inflation(df, **kw): def inflate_series(ser_in): inflation_dict = dict(zip(df_inflation.index, df_inflation['inflation_rate'])) deflator_multiplier = prod( inflation_dict[y] - for y in range(int(DEFAULT_DOLLAR_BASED_YEAR) + 1, int(core.GL['widgets']['var_dollar_year'].value) + 1 )) + for y in range(int(ReEDS_DOLLAR_YEAR) + 1, int(core.GL['widgets']['var_dollar_year'].value) + 1 )) return ser_in * deflator_multiplier def gather_cost_types(df): diff --git a/postprocessing/compare_cases.py b/postprocessing/compare_cases.py index 57e21efb5..62e12e01b 100644 --- a/postprocessing/compare_cases.py +++ b/postprocessing/compare_cases.py @@ -19,7 +19,7 @@ from reeds import plots from reeds import reedsplots from reeds.report_utils import SLIDE_HEIGHT, SLIDE_WIDTH -from bokehpivot.defaults import DEFAULT_DOLLAR_YEAR, DEFAULT_PV_YEAR, DEFAULT_DISCOUNT_RATE +from bokehpivot.defaults import DEFAULT_DOLLAR_YEAR,ReEDS_DOLLAR_YEAR, DEFAULT_PV_YEAR, DEFAULT_DISCOUNT_RATE reeds_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) plots.plotparams() @@ -138,7 +138,7 @@ discountrate_scghg = 0.02 assert discountrate_scghg in [0.015, 0.02, 0.025] central_health = {'cr':'ACS', 'model':'EASIUR'} -reeds_dollaryear = 2004 +reeds_dollaryear = ReEDS_DOLLAR_YEAR output_dollaryear = DEFAULT_DOLLAR_YEAR startyear_notes = DEFAULT_PV_YEAR diff --git a/postprocessing/input_plots.py b/postprocessing/input_plots.py index 5507c141a..554ceefa2 100644 --- a/postprocessing/input_plots.py +++ b/postprocessing/input_plots.py @@ -799,6 +799,7 @@ def map_supplycurves( """ ### Get inputs sw = reeds.io.get_switches(case) + scalars = reeds.io.get_scalars(case) dfmap = reeds.io.get_dfmap(case=case) for key in dfmap: if dfmap[key].crs != crs: @@ -844,7 +845,7 @@ def map_supplycurves( ).to_crs(crs) if include_techneutral_adder: inflatable = reeds.io.get_inflatable() - costadder = float(sw.GSw_TransIntraCost) * inflatable[2004, dollaryear] + costadder = float(sw.GSw_TransIntraCost) * inflatable[int(scalars['dollar_year']), dollaryear] else: costadder = 0 ## Convert from point to polygons if desired (raster is 11.52 km but include a little extra) diff --git a/postprocessing/retail_rate_module/ferc_distadmin.py b/postprocessing/retail_rate_module/ferc_distadmin.py index 70c266ee6..c903e1912 100644 --- a/postprocessing/retail_rate_module/ferc_distadmin.py +++ b/postprocessing/retail_rate_module/ferc_distadmin.py @@ -10,6 +10,10 @@ import pandas as pd import numpy as np import os +import sys + +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +from bokehpivot.defaults import ReEDS_DOLLAR_YEAR ################# @@ -172,7 +176,7 @@ def inflatifier(inyear, outyear=2019, inflation=inflation): inflatable = pd.Series(inflatable) return inflatable -def get_excluded_costs(excludecells=excludecells, inflationpath=None, dollar_year=2004): +def get_excluded_costs(excludecells=excludecells, inflationpath=None, dollar_year=ReEDS_DOLLAR_YEAR): """ Get subtracted cells so we can add them back in with special treatment. Returns monetary values in dollar_year dollars. diff --git a/postprocessing/retail_rate_module/mean_bias_error.py b/postprocessing/retail_rate_module/mean_bias_error.py index a5aa94bd8..155e20fc9 100644 --- a/postprocessing/retail_rate_module/mean_bias_error.py +++ b/postprocessing/retail_rate_module/mean_bias_error.py @@ -12,9 +12,13 @@ import pandas as pd import os import io +import sys import argparse import retail_rate_calculations +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +from bokehpivot.defaults import ReEDS_DOLLAR_YEAR + pd.options.display.max_columns = 200 pd.options.display.max_rows = 50 @@ -40,7 +44,7 @@ #%% Inputs ### validationyears = list(range(2010,2020)) -data_dollar_year = 2004 +reeds_dollar_year = ReEDS_DOLLAR_YEAR retailmodulepath = os.path.join(reeds_path,'postprocessing','retail_rate_module','') inputs_default_path = retailmodulepath+'inputs_default.csv' @@ -49,7 +53,7 @@ os.path.join(reeds_path,'inputs','financials','inflation_default.csv'), index_col=['t']) inf_adjust = inflation.loc[ - data_dollar_year+1:out_dollar_year, + reeds_dollar_year+1:out_dollar_year, 'inflation_rate' ].cumprod()[out_dollar_year] diff --git a/postprocessing/retail_rate_module/retail_rate_calculations.py b/postprocessing/retail_rate_module/retail_rate_calculations.py index c8365b99e..79de45e27 100644 --- a/postprocessing/retail_rate_module/retail_rate_calculations.py +++ b/postprocessing/retail_rate_module/retail_rate_calculations.py @@ -13,6 +13,10 @@ ### Local imports import ferc_distadmin import calculate_historical_capex + +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +from bokehpivot.defaults import ReEDS_DOLLAR_YEAR, DEFAULT_DOLLAR_YEAR + sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) import reeds from reeds import plots @@ -1018,7 +1022,7 @@ def main(run_dir, inputpath='inputs.csv', write=True, verbose=0): mdir, 'calc_historical_capex', 'existing_transmission_cost_bystate_USD2024.csv'), index_col='state', - ).squeeze(1).rename('init_trans_capex') * inflatable[2024, 2004] + ).squeeze(1).rename('init_trans_capex') * inflatable[DEFAULT_DOLLAR_YEAR, ReEDS_DOLLAR_YEAR] # This approach assumes the existing transmission capacity was built evently # over the trans_timeframe years prior to 2010 init_trans_capex = pd.concat( From 2c52c5810f9e72ef51c1ce5b5f6bf93cd4d5c135 Mon Sep 17 00:00:00 2001 From: Merve Turan <107019199+merveturan@users.noreply.github.com> Date: Tue, 5 May 2026 13:10:47 -0600 Subject: [PATCH 03/10] Refactor get_source_deflator_map function parameters --- input_processing/copy_files.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/input_processing/copy_files.py b/input_processing/copy_files.py index c6867ba47..a9d9db877 100644 --- a/input_processing/copy_files.py +++ b/input_processing/copy_files.py @@ -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,sw): +def get_source_deflator_map(reeds_path): """ Get the deflator for each input file """ @@ -159,22 +159,18 @@ def get_source_deflator_map(reeds_path,sw): ) ### Deflator Calculation - # The deflator values are calculated relative to the base year, so the base year deflator is set to 1.0, and the deflator values for other years - # are calculated based on the inflation rates relative to the base year. + # 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. - - # years list from the dollar year to the most recent year in sources.csv (inclusive) - max_dollar_year = pd.to_numeric(sources_dollaryear['DollarYear'], errors='coerce').max() - scalars = reeds.io.get_scalars(full=True) - inflatable = reeds.io.get_inflatable() - - deflator =( 1 / inflatable[int(scalars.loc['dollar_year', 'value'])].loc[int(scalars.loc['dollar_year', 'value']):max_dollar_year]).reset_index() + 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'] - deflator.to_csv(os.path.join(inputs_case, 'deflator.csv'), index=False) - deflator.rename(columns={'*Dollar.Year': 'Dollar.Year'}, inplace=True) # Create a mapping between inputs' relative filepaths and their deflation @@ -1629,7 +1625,7 @@ def main(reeds_path, inputs_case): # (gswitches.csv is first written at runbatch.py) scalar_csv_to_txt(os.path.join(inputs_case,'gswitches.csv')) - source_deflator_map = get_source_deflator_map(reeds_path,sw) + source_deflator_map = get_source_deflator_map(reeds_path) # Copy non-region files write_non_region_files(non_region_files, sw, inputs_case, regions_and_agglevel, source_deflator_map) From cf68f3ad901ff08280129c1f58d7d42bde2dbc7e Mon Sep 17 00:00:00 2001 From: Merve Turan <107019199+merveturan@users.noreply.github.com> Date: Tue, 5 May 2026 13:11:51 -0600 Subject: [PATCH 04/10] Correct typing error Updated the description for 'dollar_year' to clarify its purpose. --- inputs/scalars.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inputs/scalars.csv b/inputs/scalars.csv index 3b76da5e6..2cea296cc 100644 --- a/inputs/scalars.csv +++ b/inputs/scalars.csv @@ -24,7 +24,7 @@ csp_sm_3,1.3,"--fraction-- solar multiple for csp3" csp_sm_4,1.0,"--fraction-- solar multiple for csp4" csp_sm_baseline,2.4,"--fraction-- baseline solar multiple to normalize other CSP solar multiples by" distloss,0.05,"--fraction-- distribution loss rate from bus to final consumption. A generic estimate of distribution losses taken many years ago from AEO 2006" -dollar_year,2004,"--year00 real dollar year for model to calculate and report - DO NOT CHANGE FROM 2004 UNTIL ALL FINANCIAL INPUTS HAVE DOLLAR YEAR ADJUSTMENT" +dollar_year,2004,"--year-- real dollar year for model to calculate and report - DO NOT CHANGE FROM 2004 UNTIL ALL FINANCIAL INPUTS HAVE DOLLAR YEAR ADJUSTMENT" euros_dollar,1.124,"--USD/Euro-- dollars per euro exchange rate from treasury department (https://fiscal.treasury.gov/files/reports-statements/treasury-reporting-rates-exchange/ratesofexchangeasofdecember312019.pdf)" forced_outage_rate_h2_smr,0.1,"--fraction-- forced outage rate of steam methane reforming" gas_elasticity,0.76,"--fraction-- gas supply curve elasticity. long run price elasticity as estimated by: https://www.diw.de/documents/publikationen/73/diw_01.c.441773.de/dp1372.pdf" From bbfc075803a295ed5dafcb5cac1bca3a5ae08c5a Mon Sep 17 00:00:00 2001 From: Merve Turan <107019199+merveturan@users.noreply.github.com> Date: Tue, 5 May 2026 13:14:09 -0600 Subject: [PATCH 05/10] Remove redundance dollar year --- postprocessing/retail_rate_module/mean_bias_error.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/postprocessing/retail_rate_module/mean_bias_error.py b/postprocessing/retail_rate_module/mean_bias_error.py index 155e20fc9..61a1f4796 100644 --- a/postprocessing/retail_rate_module/mean_bias_error.py +++ b/postprocessing/retail_rate_module/mean_bias_error.py @@ -44,7 +44,6 @@ #%% Inputs ### validationyears = list(range(2010,2020)) -reeds_dollar_year = ReEDS_DOLLAR_YEAR retailmodulepath = os.path.join(reeds_path,'postprocessing','retail_rate_module','') inputs_default_path = retailmodulepath+'inputs_default.csv' @@ -53,7 +52,7 @@ os.path.join(reeds_path,'inputs','financials','inflation_default.csv'), index_col=['t']) inf_adjust = inflation.loc[ - reeds_dollar_year+1:out_dollar_year, + ReEDS_DOLLAR_YEAR+1:out_dollar_year, 'inflation_rate' ].cumprod()[out_dollar_year] From 6baa3ade3b7080556c076548a11c8dd28d0df8d1 Mon Sep 17 00:00:00 2001 From: "Olmez Turan, Merve" Date: Fri, 8 May 2026 12:42:13 -0600 Subject: [PATCH 06/10] minor edits -- address the comments --- input_processing/copy_files.py | 13 ++++++++++--- input_processing/mcs_sampler.py | 2 +- inputs/scalars.csv | 2 +- postprocessing/bokehpivot/defaults.py | 5 ++++- postprocessing/bokehpivot/reeds2.py | 4 ++-- postprocessing/compare_cases.py | 10 ++++------ postprocessing/retail_rate_module/ferc_distadmin.py | 4 ++-- .../retail_rate_module/mean_bias_error.py | 4 ++-- .../retail_rate_module/retail_rate_calculations.py | 4 ++-- reeds/output_calc.py | 8 ++++---- 10 files changed, 32 insertions(+), 24 deletions(-) diff --git a/input_processing/copy_files.py b/input_processing/copy_files.py index a9d9db877..3aafb8cb9 100644 --- a/input_processing/copy_files.py +++ b/input_processing/copy_files.py @@ -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 """ @@ -170,7 +170,14 @@ def get_source_deflator_map(reeds_path): 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'] - deflator.to_csv(os.path.join(inputs_case, 'deflator.csv'), index=False) + + # 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) # Create a mapping between inputs' relative filepaths and their deflation @@ -1625,7 +1632,7 @@ def main(reeds_path, inputs_case): # (gswitches.csv is first written at runbatch.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) # Copy non-region files write_non_region_files(non_region_files, sw, inputs_case, regions_and_agglevel, source_deflator_map) diff --git a/input_processing/mcs_sampler.py b/input_processing/mcs_sampler.py index 8dd3e5144..affe67b0c 100644 --- a/input_processing/mcs_sampler.py +++ b/input_processing/mcs_sampler.py @@ -483,7 +483,7 @@ def get_dist_instructions(reeds_path: str, inputs_case: str, run_ReEDS: bool = T regions_and_agglevel = copy_files.get_regions_and_agglevel( reeds_path, inputs_case, save_regions_and_agglevel=False) - source_deflator_map = copy_files.get_source_deflator_map(reeds_path) + source_deflator_map = copy_files.get_source_deflator_map(reeds_path,inputs_case,False) hierarchy_file = get_hierarchy_file(inputs_case, sw['GSw_RegionResolution']) diff --git a/inputs/scalars.csv b/inputs/scalars.csv index 2cea296cc..d06b2c964 100644 --- a/inputs/scalars.csv +++ b/inputs/scalars.csv @@ -24,7 +24,7 @@ csp_sm_3,1.3,"--fraction-- solar multiple for csp3" csp_sm_4,1.0,"--fraction-- solar multiple for csp4" csp_sm_baseline,2.4,"--fraction-- baseline solar multiple to normalize other CSP solar multiples by" distloss,0.05,"--fraction-- distribution loss rate from bus to final consumption. A generic estimate of distribution losses taken many years ago from AEO 2006" -dollar_year,2004,"--year-- real dollar year for model to calculate and report - DO NOT CHANGE FROM 2004 UNTIL ALL FINANCIAL INPUTS HAVE DOLLAR YEAR ADJUSTMENT" +dollar_year,2004,"--year-- real dollar year for model to calculate and report - DO NOT CHANGE FROM 2004 UNTIL ALL FINANCIAL INPUTS HAVE DOLLAR YEAR ADJUSTMENT -- This is defined in bokehpivot/defaults.py as REEDS_DOLLAR_YEAR. If the modeled dollar year needs to change, this value also should be updated along with REEDS_DOLLAR_YEAR in defaults.py." euros_dollar,1.124,"--USD/Euro-- dollars per euro exchange rate from treasury department (https://fiscal.treasury.gov/files/reports-statements/treasury-reporting-rates-exchange/ratesofexchangeasofdecember312019.pdf)" forced_outage_rate_h2_smr,0.1,"--fraction-- forced outage rate of steam methane reforming" gas_elasticity,0.76,"--fraction-- gas supply curve elasticity. long run price elasticity as estimated by: https://www.diw.de/documents/publikationen/73/diw_01.c.441773.de/dp1372.pdf" diff --git a/postprocessing/bokehpivot/defaults.py b/postprocessing/bokehpivot/defaults.py index fed6a62ab..537a46606 100644 --- a/postprocessing/bokehpivot/defaults.py +++ b/postprocessing/bokehpivot/defaults.py @@ -1,5 +1,8 @@ DEFAULT_DOLLAR_YEAR = 2024 -ReEDS_DOLLAR_YEAR=2004 +### ReEDS dollar year is 2004, which must match the dollar_year scalar in scalars.csv. +### If the modeled dollar year needs to change, +### developers must update dollar_year in scalars.csv and REEDS_DOLLAR_YEAR here. +REEDS_DOLLAR_YEAR=2004 DEFAULT_PV_YEAR = 2024 ### Source for default discount rate: ### https://www.whitehouse.gov/wp-content/uploads/2023/11/CircularA-4.pdf diff --git a/postprocessing/bokehpivot/reeds2.py b/postprocessing/bokehpivot/reeds2.py index 3afbfd068..2cecba45e 100644 --- a/postprocessing/bokehpivot/reeds2.py +++ b/postprocessing/bokehpivot/reeds2.py @@ -18,7 +18,7 @@ from itertools import product from math import prod ## Inherit the default present value year to use in plot definitions -from defaults import DEFAULT_PV_YEAR,ReEDS_DOLLAR_YEAR +from defaults import DEFAULT_PV_YEAR,REEDS_DOLLAR_YEAR rb_globs = {'output_subdir':'/outputs/', 'test_file':['cap.csv','outputs.h5'], 'report_subdir':'/reeds2'} this_dir_path = os.path.dirname(os.path.realpath(__file__)) @@ -73,7 +73,7 @@ def apply_inflation(df, **kw): def inflate_series(ser_in): inflation_dict = dict(zip(df_inflation.index, df_inflation['inflation_rate'])) deflator_multiplier = prod( inflation_dict[y] - for y in range(int(ReEDS_DOLLAR_YEAR) + 1, int(core.GL['widgets']['var_dollar_year'].value) + 1 )) + for y in range(int(REEDS_DOLLAR_YEAR) + 1, int(core.GL['widgets']['var_dollar_year'].value) + 1 )) return ser_in * deflator_multiplier def gather_cost_types(df): diff --git a/postprocessing/compare_cases.py b/postprocessing/compare_cases.py index 62e12e01b..b843d47be 100644 --- a/postprocessing/compare_cases.py +++ b/postprocessing/compare_cases.py @@ -19,7 +19,7 @@ from reeds import plots from reeds import reedsplots from reeds.report_utils import SLIDE_HEIGHT, SLIDE_WIDTH -from bokehpivot.defaults import DEFAULT_DOLLAR_YEAR,ReEDS_DOLLAR_YEAR, DEFAULT_PV_YEAR, DEFAULT_DISCOUNT_RATE +from bokehpivot.defaults import DEFAULT_DOLLAR_YEAR,REEDS_DOLLAR_YEAR, DEFAULT_PV_YEAR, DEFAULT_DISCOUNT_RATE reeds_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) plots.plotparams() @@ -138,8 +138,6 @@ discountrate_scghg = 0.02 assert discountrate_scghg in [0.015, 0.02, 0.025] central_health = {'cr':'ACS', 'model':'EASIUR'} -reeds_dollaryear = ReEDS_DOLLAR_YEAR -output_dollaryear = DEFAULT_DOLLAR_YEAR startyear_notes = DEFAULT_PV_YEAR colors_social = { @@ -317,7 +315,7 @@ def plot_bars_abs_stacked( inflatable = reeds.io.get_inflatable(os.path.join( reeds_path,'inputs','financials','inflation_default.csv')) -inflator = inflatable[reeds_dollaryear, output_dollaryear] +inflator = inflatable[REEDS_DOLLAR_YEAR, DEFAULT_DOLLAR_YEAR] scghg = pd.read_csv( os.path.join(reeds_path, 'postprocessing', 'plots', 'scghg_annual.csv'), @@ -331,7 +329,7 @@ def plot_bars_abs_stacked( }).set_index(['e','t']) scghg_central = ( scghg[f'2020_{discountrate_scghg*100:.1f}%'].unstack('e') - * inflatable[2020, output_dollaryear] + * inflatable[2020, DEFAULT_DOLLAR_YEAR] ) #%% Colors and mapping @@ -527,7 +525,7 @@ def plot_bars_abs_stacked( .xs(central_health['model'], level='model') .groupby('year').sum() ['damage_$'] - ### Inflate from reeds_dollaryear (2004) to bokeh output_dollaryear (2021) + ### Inflate from REEDS_DOLLAR_YEAR (2004) to bokeh DEFAULT_DOLLAR_YEAR (2024) * inflator ### Convert to $B / 1e9 diff --git a/postprocessing/retail_rate_module/ferc_distadmin.py b/postprocessing/retail_rate_module/ferc_distadmin.py index d73f85a9b..b16c6e4eb 100644 --- a/postprocessing/retail_rate_module/ferc_distadmin.py +++ b/postprocessing/retail_rate_module/ferc_distadmin.py @@ -13,7 +13,7 @@ import sys sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -from bokehpivot.defaults import ReEDS_DOLLAR_YEAR +from bokehpivot.defaults import REEDS_DOLLAR_YEAR ################# @@ -176,7 +176,7 @@ def inflatifier(inyear, outyear=2019, inflation=inflation): inflatable = pd.Series(inflatable) return inflatable -def get_excluded_costs(excludecells=excludecells, inflationpath=None, dollar_year=ReEDS_DOLLAR_YEAR): +def get_excluded_costs(excludecells=excludecells, inflationpath=None, dollar_year=REEDS_DOLLAR_YEAR): """ Get subtracted cells so we can add them back in with special treatment. Returns monetary values in dollar_year dollars. diff --git a/postprocessing/retail_rate_module/mean_bias_error.py b/postprocessing/retail_rate_module/mean_bias_error.py index 61a1f4796..efdfa7e3a 100644 --- a/postprocessing/retail_rate_module/mean_bias_error.py +++ b/postprocessing/retail_rate_module/mean_bias_error.py @@ -17,7 +17,7 @@ import retail_rate_calculations sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -from bokehpivot.defaults import ReEDS_DOLLAR_YEAR +from bokehpivot.defaults import REEDS_DOLLAR_YEAR pd.options.display.max_columns = 200 pd.options.display.max_rows = 50 @@ -52,7 +52,7 @@ os.path.join(reeds_path,'inputs','financials','inflation_default.csv'), index_col=['t']) inf_adjust = inflation.loc[ - ReEDS_DOLLAR_YEAR+1:out_dollar_year, + REEDS_DOLLAR_YEAR+1:out_dollar_year, 'inflation_rate' ].cumprod()[out_dollar_year] diff --git a/postprocessing/retail_rate_module/retail_rate_calculations.py b/postprocessing/retail_rate_module/retail_rate_calculations.py index 79de45e27..b91396e9c 100644 --- a/postprocessing/retail_rate_module/retail_rate_calculations.py +++ b/postprocessing/retail_rate_module/retail_rate_calculations.py @@ -15,7 +15,7 @@ import calculate_historical_capex sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -from bokehpivot.defaults import ReEDS_DOLLAR_YEAR, DEFAULT_DOLLAR_YEAR +from bokehpivot.defaults import REEDS_DOLLAR_YEAR, DEFAULT_DOLLAR_YEAR sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) import reeds @@ -1022,7 +1022,7 @@ def main(run_dir, inputpath='inputs.csv', write=True, verbose=0): mdir, 'calc_historical_capex', 'existing_transmission_cost_bystate_USD2024.csv'), index_col='state', - ).squeeze(1).rename('init_trans_capex') * inflatable[DEFAULT_DOLLAR_YEAR, ReEDS_DOLLAR_YEAR] + ).squeeze(1).rename('init_trans_capex') * inflatable[DEFAULT_DOLLAR_YEAR, REEDS_DOLLAR_YEAR] # This approach assumes the existing transmission capacity was built evently # over the trans_timeframe years prior to 2010 init_trans_capex = pd.concat( diff --git a/reeds/output_calc.py b/reeds/output_calc.py index 0043ceea5..0d32d8725 100644 --- a/reeds/output_calc.py +++ b/reeds/output_calc.py @@ -214,12 +214,12 @@ def calc_h2prod(case): return df -def inflate_series(case,dfin, to_dollar_year=DEFAULT_DOLLAR_YEAR): +def inflate_series(inputs_case,dfin, to_dollar_year=DEFAULT_DOLLAR_YEAR): """ Inflate a series of financial data to a specified dollar year. """ df_deflator = pd.read_csv( - os.path.join(case, '..', '..', 'inputs_case', 'deflator.csv'), + os.path.join(inputs_case, 'deflator.csv'), index_col=0 ) return dfin * 1 / df_deflator.loc[to_dollar_year, 'Deflator'] @@ -346,7 +346,7 @@ def calc_systemcost( df = systemcost.copy() # Apply inflation - df['Value'] = inflate_series(case,df['Value']) + df['Value'] = inflate_series(inputs_case,df['Value']) df.rename(columns={'Value':'Cost (Bil $)'}, inplace=True) cost_cat_map, cap_type_ls, op_type_ls = gather_cost_types(df) @@ -392,7 +392,7 @@ def calc_systemcost( df_capex_hist=df_capex_hist.loc[:firstmodelyear-1,:] # Convert to output dollar year - df_capex_hist = pd.DataFrame(inflate_series(case,df_capex_hist)) + df_capex_hist = pd.DataFrame(inflate_series(inputs_case,df_capex_hist)) # Insert into full cost table df = df.join(df_capex_hist, on=['year','r']) From c1f2ab8bf8a52f91a521122e1e1aebbbe02053c8 Mon Sep 17 00:00:00 2001 From: Merve Turan <107019199+merveturan@users.noreply.github.com> Date: Sun, 31 May 2026 21:22:24 -0600 Subject: [PATCH 07/10] Update postprocessing/retail_rate_module/ferc_distadmin.py Co-authored-by: Patrick Brown <25125211+patrickbrown4@users.noreply.github.com> --- postprocessing/retail_rate_module/ferc_distadmin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/postprocessing/retail_rate_module/ferc_distadmin.py b/postprocessing/retail_rate_module/ferc_distadmin.py index ca6d79742..5eef7f37c 100644 --- a/postprocessing/retail_rate_module/ferc_distadmin.py +++ b/postprocessing/retail_rate_module/ferc_distadmin.py @@ -12,8 +12,11 @@ import os import sys -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -from bokehpivot.defaults import REEDS_DOLLAR_YEAR +from pathlib import Path +sys.path.append(str(Path(__file__).parent.parent.parent)) +import reeds + +dollar_year = int(reeds.io.get_scalars().dollar_year) ################# From 05a460114174c73af9031eca02dd3c8e0521bf5d Mon Sep 17 00:00:00 2001 From: "Olmez Turan, Merve" Date: Sun, 31 May 2026 21:36:23 -0600 Subject: [PATCH 08/10] get dollar_year from scalar.csv file in postprocessing scripts --- postprocessing/bokehpivot/defaults.py | 4 ---- postprocessing/bokehpivot/reeds2.py | 4 +++- postprocessing/compare_cases.py | 7 ++++--- postprocessing/retail_rate_module/ferc_distadmin.py | 2 +- postprocessing/retail_rate_module/mean_bias_error.py | 8 +++++--- .../retail_rate_module/retail_rate_calculations.py | 6 ++---- reeds/input_processing/copy_files.py | 9 ++------- reeds/input_processing/mcs_sampler.py | 2 +- 8 files changed, 18 insertions(+), 24 deletions(-) diff --git a/postprocessing/bokehpivot/defaults.py b/postprocessing/bokehpivot/defaults.py index 537a46606..1ed66fb42 100644 --- a/postprocessing/bokehpivot/defaults.py +++ b/postprocessing/bokehpivot/defaults.py @@ -1,8 +1,4 @@ DEFAULT_DOLLAR_YEAR = 2024 -### ReEDS dollar year is 2004, which must match the dollar_year scalar in scalars.csv. -### If the modeled dollar year needs to change, -### developers must update dollar_year in scalars.csv and REEDS_DOLLAR_YEAR here. -REEDS_DOLLAR_YEAR=2004 DEFAULT_PV_YEAR = 2024 ### Source for default discount rate: ### https://www.whitehouse.gov/wp-content/uploads/2023/11/CircularA-4.pdf diff --git a/postprocessing/bokehpivot/reeds2.py b/postprocessing/bokehpivot/reeds2.py index 053140ef4..04bf866d2 100644 --- a/postprocessing/bokehpivot/reeds2.py +++ b/postprocessing/bokehpivot/reeds2.py @@ -18,11 +18,12 @@ from itertools import product from math import prod ## Inherit the default present value year to use in plot definitions -from defaults import DEFAULT_PV_YEAR,REEDS_DOLLAR_YEAR +from defaults import DEFAULT_PV_YEAR rb_globs = {'output_subdir':'/outputs/', 'test_file':['cap.csv','outputs.h5'], 'report_subdir':'/reeds2'} this_dir_path = os.path.dirname(os.path.realpath(__file__)) df_inflation = pd.read_csv(os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'inputs/financials/inflation_default.csv')), index_col=0) +scalars = pd.read_csv(os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'inputs/scalars.csv'))) coststreams = ['eq_gasaccounting_regional','eq_gasaccounting_national','eq_bioused','eq_gasused','eq_objfn_inv','eq_objfn_op'] vf_valstreams = ['eq_supply_demand_balance','eq_reserve_margin','eq_opres_requirement','eq_rec_requirement','eq_curt_gen_balance','eq_curtailment','eq_storage_in_max','eq_storage_in_min'] # valuestreams = ['eq_supply_demand_balance','eq_reserve_margin','eq_opres_requirement','eq_rec_requirement','eq_national_gen','eq_annual_cap','eq_curt_gen_balance','eq_curtailment','eq_storage_in_max','eq_storage_in_min','eq_emit_accounting','eq_mingen_lb','eq_mingen_ub','eq_rps_ofswind'] @@ -72,6 +73,7 @@ def apply_inflation(df, **kw): def inflate_series(ser_in): inflation_dict = dict(zip(df_inflation.index, df_inflation['inflation_rate'])) + REEDS_DOLLAR_YEAR=scalars.loc[scalars['scalar']=='dollar_year','value'].values[0] deflator_multiplier = prod( inflation_dict[y] for y in range(int(REEDS_DOLLAR_YEAR) + 1, int(core.GL['widgets']['var_dollar_year'].value) + 1 )) return ser_in * deflator_multiplier diff --git a/postprocessing/compare_cases.py b/postprocessing/compare_cases.py index b843d47be..82399b653 100644 --- a/postprocessing/compare_cases.py +++ b/postprocessing/compare_cases.py @@ -19,7 +19,7 @@ from reeds import plots from reeds import reedsplots from reeds.report_utils import SLIDE_HEIGHT, SLIDE_WIDTH -from bokehpivot.defaults import DEFAULT_DOLLAR_YEAR,REEDS_DOLLAR_YEAR, DEFAULT_PV_YEAR, DEFAULT_DISCOUNT_RATE +from bokehpivot.defaults import DEFAULT_DOLLAR_YEAR, DEFAULT_PV_YEAR, DEFAULT_DISCOUNT_RATE reeds_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) plots.plotparams() @@ -139,6 +139,7 @@ assert discountrate_scghg in [0.015, 0.02, 0.025] central_health = {'cr':'ACS', 'model':'EASIUR'} startyear_notes = DEFAULT_PV_YEAR +dollar_year = int(reeds.io.get_scalars().dollar_year) colors_social = { 'CO2': plt.cm.tab20b(4), @@ -315,7 +316,7 @@ def plot_bars_abs_stacked( inflatable = reeds.io.get_inflatable(os.path.join( reeds_path,'inputs','financials','inflation_default.csv')) -inflator = inflatable[REEDS_DOLLAR_YEAR, DEFAULT_DOLLAR_YEAR] +inflator = inflatable[dollar_year, DEFAULT_DOLLAR_YEAR] scghg = pd.read_csv( os.path.join(reeds_path, 'postprocessing', 'plots', 'scghg_annual.csv'), @@ -525,7 +526,7 @@ def plot_bars_abs_stacked( .xs(central_health['model'], level='model') .groupby('year').sum() ['damage_$'] - ### Inflate from REEDS_DOLLAR_YEAR (2004) to bokeh DEFAULT_DOLLAR_YEAR (2024) + ### Inflate from dollar_year (2004) to bokeh DEFAULT_DOLLAR_YEAR (2024) * inflator ### Convert to $B / 1e9 diff --git a/postprocessing/retail_rate_module/ferc_distadmin.py b/postprocessing/retail_rate_module/ferc_distadmin.py index 5eef7f37c..a8c17e5e8 100644 --- a/postprocessing/retail_rate_module/ferc_distadmin.py +++ b/postprocessing/retail_rate_module/ferc_distadmin.py @@ -179,7 +179,7 @@ def inflatifier(inyear, outyear=2019, inflation=inflation): inflatable = pd.Series(inflatable) return inflatable -def get_excluded_costs(excludecells=excludecells, inflationpath=None, dollar_year=REEDS_DOLLAR_YEAR): +def get_excluded_costs(excludecells=excludecells, inflationpath=None, dollar_year=dollar_year): """ Get subtracted cells so we can add them back in with special treatment. Returns monetary values in dollar_year dollars. diff --git a/postprocessing/retail_rate_module/mean_bias_error.py b/postprocessing/retail_rate_module/mean_bias_error.py index 9cf652110..cd674b139 100644 --- a/postprocessing/retail_rate_module/mean_bias_error.py +++ b/postprocessing/retail_rate_module/mean_bias_error.py @@ -16,8 +16,9 @@ import argparse import retail_rate_calculations -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -from bokehpivot.defaults import REEDS_DOLLAR_YEAR +from pathlib import Path +sys.path.append(str(Path(__file__).parent.parent.parent)) +import reeds pd.options.display.max_columns = 200 pd.options.display.max_rows = 50 @@ -47,12 +48,13 @@ retailmodulepath = os.path.join(reeds_path,'postprocessing','retail_rate_module','') inputs_default_path = retailmodulepath+'inputs_default.csv' +dollar_year = int(reeds.io.get_scalars().dollar_year) inflation = pd.read_csv( os.path.join(reeds_path,'inputs','financials','inflation_default.csv'), index_col=['t']) inf_adjust = inflation.loc[ - REEDS_DOLLAR_YEAR+1:out_dollar_year, + dollar_year+1:out_dollar_year, 'inflation_rate' ].cumprod()[out_dollar_year] diff --git a/postprocessing/retail_rate_module/retail_rate_calculations.py b/postprocessing/retail_rate_module/retail_rate_calculations.py index d8ceaef4b..c6d243fa9 100644 --- a/postprocessing/retail_rate_module/retail_rate_calculations.py +++ b/postprocessing/retail_rate_module/retail_rate_calculations.py @@ -14,9 +14,6 @@ import ferc_distadmin import calculate_historical_capex -sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) -from bokehpivot.defaults import REEDS_DOLLAR_YEAR, DEFAULT_DOLLAR_YEAR - sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) import reeds from reeds import plots @@ -375,6 +372,7 @@ def main(run_dir, inputpath='inputs.csv', write=True, verbose=0): modeled_years = load_rt['t'].drop_duplicates() non_modeled_years = list(set(np.arange(first_year,last_year,1)) - set(modeled_years)) years_reeds = np.arange(first_year, last_year+1) + reeds_dollar_year=reeds.io.get_scalars().dollar_year # Ingest inflation inflation = pd.read_csv( @@ -1022,7 +1020,7 @@ def main(run_dir, inputpath='inputs.csv', write=True, verbose=0): mdir, 'calc_historical_capex', 'existing_transmission_cost_bystate_USD2024.csv'), index_col='state', - ).squeeze(1).rename('init_trans_capex') * inflatable[DEFAULT_DOLLAR_YEAR, REEDS_DOLLAR_YEAR] + ).squeeze(1).rename('init_trans_capex') * inflatable[2024, reeds_dollar_year] # This approach assumes the existing transmission capacity was built evently # over the trans_timeframe years prior to 2010 init_trans_capex = pd.concat( diff --git a/reeds/input_processing/copy_files.py b/reeds/input_processing/copy_files.py index be4785cff..eba7d355d 100644 --- a/reeds/input_processing/copy_files.py +++ b/reeds/input_processing/copy_files.py @@ -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,inputs_case,write_out=True): +def get_source_deflator_map(reeds_path,inputs_case): """ Get the deflator for each input file """ @@ -170,13 +170,7 @@ def get_source_deflator_map(reeds_path,inputs_case,write_out=True): 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) @@ -1644,6 +1638,7 @@ def main(reeds_path, inputs_case): scalar_csv_to_txt(os.path.join(inputs_case,'gswitches.csv')) source_deflator_map = get_source_deflator_map(reeds_path,inputs_case) + source_deflator_map.to_csv(os.path.join(inputs_case, 'deflator.csv'), index=False) # Copy non-region files write_non_region_files(non_region_files, sw, inputs_case, regions_and_agglevel, source_deflator_map) diff --git a/reeds/input_processing/mcs_sampler.py b/reeds/input_processing/mcs_sampler.py index 5d80276f7..9b7349123 100644 --- a/reeds/input_processing/mcs_sampler.py +++ b/reeds/input_processing/mcs_sampler.py @@ -611,7 +611,7 @@ def get_dist_instructions(reeds_path: str, inputs_case: str) -> Tuple[pd.DataFra regions_and_agglevel = copy_files.get_regions_and_agglevel( reeds_path, inputs_case, save_regions_and_agglevel=False, overwrite=True) - source_deflator_map = copy_files.get_source_deflator_map(reeds_path,inputs_case,False) + source_deflator_map = copy_files.get_source_deflator_map(reeds_path,inputs_case) hierarchy_file = get_hierarchy_file(inputs_case, sw['GSw_RegionResolution']) From 53aa28718b69032ba73fa6449a1a450a274527af Mon Sep 17 00:00:00 2001 From: "Olmez Turan, Merve" Date: Sun, 31 May 2026 21:38:14 -0600 Subject: [PATCH 09/10] Update scalars.csv --- inputs/scalars.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inputs/scalars.csv b/inputs/scalars.csv index fec8135d9..9f9f75da1 100644 --- a/inputs/scalars.csv +++ b/inputs/scalars.csv @@ -24,7 +24,7 @@ csp_sm_3,1.3,"--fraction-- solar multiple for csp3" csp_sm_4,1.0,"--fraction-- solar multiple for csp4" csp_sm_baseline,2.4,"--fraction-- baseline solar multiple to normalize other CSP solar multiples by" distloss,0.05,"--fraction-- distribution loss rate from bus to final consumption. A generic estimate of distribution losses taken many years ago from AEO 2006" -dollar_year,2004,"--year-- real dollar year for model to calculate and report - DO NOT CHANGE FROM 2004 UNTIL ALL FINANCIAL INPUTS HAVE DOLLAR YEAR ADJUSTMENT -- This is defined in bokehpivot/defaults.py as REEDS_DOLLAR_YEAR. If the modeled dollar year needs to change, this value also should be updated along with REEDS_DOLLAR_YEAR in defaults.py." +dollar_year,2004,"--year-- real dollar year for model to calculate and report - DO NOT CHANGE FROM 2004 UNTIL ALL FINANCIAL INPUTS HAVE DOLLAR YEAR ADJUSTMENT -- euros_dollar,1.124,"--USD/Euro-- dollars per euro exchange rate from treasury department (https://fiscal.treasury.gov/files/reports-statements/treasury-reporting-rates-exchange/ratesofexchangeasofdecember312019.pdf)" forced_outage_rate_h2_smr,0.1,"--fraction-- forced outage rate of steam methane reforming" gas_elasticity,0.76,"--fraction-- gas supply curve elasticity. long run price elasticity as estimated by: https://www.diw.de/documents/publikationen/73/diw_01.c.441773.de/dp1372.pdf" From d13cc324e8385d26b1b27a7e55b61798efecbcde Mon Sep 17 00:00:00 2001 From: Merve OlmezTuran Date: Mon, 1 Jun 2026 22:46:54 -0600 Subject: [PATCH 10/10] revert copy_file.py change --- inputs/scalars.csv | 2 +- reeds/input_processing/copy_files.py | 11 ++++++++--- reeds/input_processing/mcs_sampler.py | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/inputs/scalars.csv b/inputs/scalars.csv index 9f9f75da1..97bd60a6b 100644 --- a/inputs/scalars.csv +++ b/inputs/scalars.csv @@ -24,7 +24,7 @@ csp_sm_3,1.3,"--fraction-- solar multiple for csp3" csp_sm_4,1.0,"--fraction-- solar multiple for csp4" csp_sm_baseline,2.4,"--fraction-- baseline solar multiple to normalize other CSP solar multiples by" distloss,0.05,"--fraction-- distribution loss rate from bus to final consumption. A generic estimate of distribution losses taken many years ago from AEO 2006" -dollar_year,2004,"--year-- real dollar year for model to calculate and report - DO NOT CHANGE FROM 2004 UNTIL ALL FINANCIAL INPUTS HAVE DOLLAR YEAR ADJUSTMENT -- +dollar_year,2004,"--year-- real dollar year for model to calculate and report - DO NOT CHANGE FROM 2004 UNTIL ALL FINANCIAL INPUTS HAVE DOLLAR YEAR ADJUSTMENT --" euros_dollar,1.124,"--USD/Euro-- dollars per euro exchange rate from treasury department (https://fiscal.treasury.gov/files/reports-statements/treasury-reporting-rates-exchange/ratesofexchangeasofdecember312019.pdf)" forced_outage_rate_h2_smr,0.1,"--fraction-- forced outage rate of steam methane reforming" gas_elasticity,0.76,"--fraction-- gas supply curve elasticity. long run price elasticity as estimated by: https://www.diw.de/documents/publikationen/73/diw_01.c.441773.de/dp1372.pdf" diff --git a/reeds/input_processing/copy_files.py b/reeds/input_processing/copy_files.py index eba7d355d..71c3410ea 100644 --- a/reeds/input_processing/copy_files.py +++ b/reeds/input_processing/copy_files.py @@ -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,inputs_case): +def get_source_deflator_map(reeds_path,inputs_case,write_out=True): """ Get the deflator for each input file """ @@ -171,6 +171,12 @@ def get_source_deflator_map(reeds_path,inputs_case): 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) @@ -186,7 +192,7 @@ def get_source_deflator_map(reeds_path,inputs_case): .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 @@ -1638,7 +1644,6 @@ def main(reeds_path, inputs_case): scalar_csv_to_txt(os.path.join(inputs_case,'gswitches.csv')) source_deflator_map = get_source_deflator_map(reeds_path,inputs_case) - source_deflator_map.to_csv(os.path.join(inputs_case, 'deflator.csv'), index=False) # Copy non-region files write_non_region_files(non_region_files, sw, inputs_case, regions_and_agglevel, source_deflator_map) diff --git a/reeds/input_processing/mcs_sampler.py b/reeds/input_processing/mcs_sampler.py index 9b7349123..5d80276f7 100644 --- a/reeds/input_processing/mcs_sampler.py +++ b/reeds/input_processing/mcs_sampler.py @@ -611,7 +611,7 @@ def get_dist_instructions(reeds_path: str, inputs_case: str) -> Tuple[pd.DataFra regions_and_agglevel = copy_files.get_regions_and_agglevel( reeds_path, inputs_case, save_regions_and_agglevel=False, overwrite=True) - source_deflator_map = copy_files.get_source_deflator_map(reeds_path,inputs_case) + source_deflator_map = copy_files.get_source_deflator_map(reeds_path,inputs_case,False) hierarchy_file = get_hierarchy_file(inputs_case, sw['GSw_RegionResolution'])