Skip to content

Commit

Permalink
More quirks from debugging smart thermostats
Browse files Browse the repository at this point in the history
  • Loading branch information
denised committed Oct 23, 2021
1 parent 004a595 commit 4742d2f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion model/emissionsfactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def string_to_emissions_grid_range(text):


class ElectricityGenOnGrid(DataHandler):
def __init__(self, ac, grid_emissions_version=1):
def __init__(self, ac, grid_emissions_version="current"):
self.ac = ac
self.grid_emissions_version = grid_emissions_version

Expand Down
10 changes: 8 additions & 2 deletions model/s_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
from model.data_handler import DataHandler
from model.decorators import data_func

def make_scurve_config(base_year, tamdata, configdict, end_year=2050):
def make_scurve_config(base_year, tamdata, configdict, end_year=2050, use_tam_2014=False):
"""Create a configuration for a standard S-Curve or Bass Diffusion S-Curve. Configdict should contain required parameters
'ref_base_adoption', 'pds_adoption_final_percentage', and for Bass Diffusion S-Curves may also contain 'pds_adoption_s_curve_innovation'
and 'pds_adoption_s_curve_imitation'. These are all AC fields, and can be obtained via ac.asdict()."""
and 'pds_adoption_s_curve_imitation'. These are all AC fields, and can be obtained via ac.asdict().
Parameter use_tam_2014 is a quirks parameter to match a bug in the Excel that uses the TAM from the year 2014 instead of base_year
as it ought to."""
sconfig = pd.DataFrame({'base_year': base_year, 'end_year': end_year}, index=dd.REGIONS)
sconfig['base_adoption'] = pd.Series(configdict['ref_base_adoption'])
sconfig['base_percent'] = sconfig['base_adoption'] / tamdata.loc[base_year]
Expand All @@ -19,6 +21,10 @@ def make_scurve_config(base_year, tamdata, configdict, end_year=2050):
sconfig['innovation'] = pd.Series(configdict['pds_adoption_s_curve_innovation'])
if 'pds_adoption_s_curve_imitation' in configdict:
sconfig['imitation'] = pd.Series(configdict['pds_adoption_s_curve_imitation'])

if use_tam_2014:
# Excel bug calulates base_adoption from TAM[2014] instead of TAM[base_year]. For compatibility, we can do the same
sconfig['base_adoption'] = sconfig['base_percent'] * tamdata.loc[2014]
return sconfig

class SCurve(DataHandler):
Expand Down
4 changes: 3 additions & 1 deletion model/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def initialize_ac(self, scenario_name_or_ac, scenario_list, default_scenario_nam
_pds_ad_sources = None
_pds_ad_settings = { 'main_includes_regional' : False, 'groups_include_hundred_percent': True,
'config_overrides' : None }
_pds_sc_settings = { 'use_tam_2014': True }


def initialize_adoption_bases(self):
Expand Down Expand Up @@ -200,7 +201,8 @@ def initialize_adoption_bases(self):

elif self.ac.soln_pds_adoption_basis in ['Logistic S-Curve', 'Bass Diffusion S-Curve']:
if not self.sc:
sconfig = s_curve.make_scurve_config(self.base_year, self.adoption_limit(), self.ac.as_dict())
sconfig = s_curve.make_scurve_config(self.base_year, self.adoption_limit(), self.ac.as_dict(),
use_tam_2014 = self._pds_sc_settings['use_tam_2014'])
self.sc = s_curve.SCurve(sconfig)
pds_trend = (self.sc.logistic_adoption()
if self.ac.soln_pds_adoption_basis == 'Logistic S-Curve' else
Expand Down
3 changes: 3 additions & 0 deletions tools/solution_xls_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,8 @@ def write_ua(f, wb, is_rrs=True):
if 'Repeated First Cost to Maintaining Implementation Units' in xls(ac_tab, 'A43'):
repeated_cost_for_iunits = convert_bool(xls(ac_tab, 'C43'))
f.write(" repeated_cost_for_iunits=" + str(repeated_cost_for_iunits) + ",\n")
f.write(" # Quirks parameters\n")
f.write(" replacement_period_offset=0,\n")
# If S135 == D135 (for all regions), then it must not be adding in 'Advanced Controls'!C62
bug_cfunits_double_count = False
for i in range(0, 9):
Expand Down Expand Up @@ -1251,6 +1253,7 @@ def extract_source_data(wb, sheet_name, regions, outputdir, prefix):
for col in range(2, tab.max_column):
if tab.cell(line+1, col).value == 'Functional Unit':
break
breakpoint()
case = xls(tab, case_line, col)
if case != '':
case = normalize_case_name(case)
Expand Down

0 comments on commit 4742d2f

Please sign in to comment.