Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cases.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion docs/sources.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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,,,,,,
Expand Down
23 changes: 0 additions & 23 deletions inputs/financials/deflator.csv

This file was deleted.

1 change: 1 addition & 0 deletions inputs/scalars.csv
Original file line number Diff line number Diff line change
Expand Up @@ -24,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,"--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"
Expand Down
12 changes: 9 additions & 3 deletions postprocessing/bokehpivot/reeds2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
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

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)
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.

Since you're already reading from the ReEDS repo here, I think it would be cleaner to just read dollar_year from scalars.csv too. Then you wouldn't need to hard-code a copy of it as REEDS_DOLLAR_YEAR in defaults.py.

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']
Expand Down Expand Up @@ -70,8 +72,12 @@ 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']))
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

def gather_cost_types(df):
#Gather lists of capital and operation labels
cost_cats_df = df['cost_cat'].unique().tolist()
Expand Down
9 changes: 4 additions & 5 deletions postprocessing/compare_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@
discountrate_scghg = 0.02
assert discountrate_scghg in [0.015, 0.02, 0.025]
central_health = {'cr':'ACS', 'model':'EASIUR'}
reeds_dollaryear = 2004
output_dollaryear = DEFAULT_DOLLAR_YEAR
startyear_notes = DEFAULT_PV_YEAR
dollar_year = int(reeds.io.get_scalars().dollar_year)

colors_social = {
'CO2': plt.cm.tab20b(4),
Expand Down Expand Up @@ -317,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_dollaryear, output_dollaryear]
inflator = inflatable[dollar_year, DEFAULT_DOLLAR_YEAR]

scghg = pd.read_csv(
os.path.join(reeds_path, 'postprocessing', 'plots', 'scghg_annual.csv'),
Expand All @@ -331,7 +330,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
Expand Down Expand Up @@ -527,7 +526,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 dollar_year (2004) to bokeh DEFAULT_DOLLAR_YEAR (2024)
* inflator
### Convert to $B
/ 1e9
Expand Down
3 changes: 2 additions & 1 deletion postprocessing/input_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion postprocessing/retail_rate_module/ferc_distadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
import pandas as pd
import numpy as np
import os
import sys

from pathlib import Path
sys.path.append(str(Path(__file__).parent.parent.parent))
import reeds

dollar_year = int(reeds.io.get_scalars().dollar_year)


#################
Expand Down Expand Up @@ -172,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=2004):
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.
Expand Down
9 changes: 7 additions & 2 deletions postprocessing/retail_rate_module/mean_bias_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
import pandas as pd
import os
import io
import sys
import argparse
import retail_rate_calculations

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

Expand All @@ -40,16 +45,16 @@
#%% Inputs ###

validationyears = list(range(2010,2020))
data_dollar_year = 2004

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[
data_dollar_year+1:out_dollar_year,
dollar_year+1:out_dollar_year,
'inflation_rate'
].cumprod()[out_dollar_year]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
### Local imports
import ferc_distadmin
import calculate_historical_capex

sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
import reeds
from reeds import plots
Expand Down Expand Up @@ -371,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(
Expand Down Expand Up @@ -1018,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[2024, 2004]
).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(
Expand Down
2 changes: 1 addition & 1 deletion reeds/input_processing/calc_financial_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,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)


Expand Down
32 changes: 26 additions & 6 deletions reeds/input_processing/copy_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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)
Comment thread
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 = (
Expand All @@ -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
Expand Down Expand Up @@ -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)

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 can move the write here:

Suggested change
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)
Expand Down
2 changes: 1 addition & 1 deletion reeds/input_processing/mcs_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
source_deflator_map = copy_files.get_source_deflator_map(reeds_path,inputs_case,False)

hierarchy_file = get_hierarchy_file(inputs_case, sw['GSw_RegionResolution'])

Expand Down
2 changes: 1 addition & 1 deletion reeds/input_processing/runfiles.csv
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ csapr_ozone_season.csv,inputs/emission_constraints/csapr_ozone_season.csv,int(sw
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,,,,,,
Expand Down
7 changes: 4 additions & 3 deletions reeds/input_processing/transmission.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__,
Expand All @@ -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:])
Expand Down
10 changes: 5 additions & 5 deletions reeds/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ def calc_h2prod(case):

return df

def inflate_series(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(reeds_path, 'inputs', 'financials', 'deflator.csv'),
index_col=0,
os.path.join(inputs_case, 'deflator.csv'),
index_col=0
)
return dfin * 1 / df_deflator.loc[to_dollar_year, 'Deflator']

Expand Down Expand Up @@ -342,7 +342,7 @@ def calc_systemcost(
df = systemcost.copy()

# Apply inflation
df['Value'] = inflate_series(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)
Expand Down Expand Up @@ -388,7 +388,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(inputs_case,df_capex_hist))

# Insert into full cost table
df = df.join(df_capex_hist, on=['year','r'])
Expand Down
Loading