Skip to content

Commit

Permalink
Fix cost conversion bug when running catchall measures
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlangevin authored and trynthink committed Feb 14, 2022
1 parent 6757af6 commit 12e47a9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
32 changes: 12 additions & 20 deletions ecm_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -2626,30 +2626,22 @@ def fill_mkts(self, msegs, msegs_cpl, convert_data, tsv_data_init, opts,
None for n in range(2))
else:
# If applicable, set ECM cost attribute to value previously
# calculated for current microsegment building type, provided
# microsegment does not require re-initiating cost conversions
# for each new technology type (applicable to the residential
# sector, where one conversion for a given building type to
# $/unit will be sufficient across all technologies for that
# building type, and to commercial technologies that don't
# have baseline costs per unit service demand, where no cost
# conversions are required and costs need only be set once)
if mskeys[2] in bldgs_costconverted.keys() and \
not isinstance(self.installed_cost, dict) and (
bldg_sect != "commercial" or sqft_subst == 1 or
"$/ft^2 floor" not in self.cost_units):
# calculated for current microsegment building type, if
# available, provided microsegment does not require
# re-initiating cost conversions for each new technology type
# (cost data are formatted as a dict, or commercial cost data
# are in $/ft^2 floor, which may not be consistent with
# baseline cost units per service demand)
if mskeys[2] in bldgs_costconverted.keys() and not (
isinstance(self.installed_cost, dict) or
isinstance(self.cost_units, dict)) and (
bldg_sect != "commercial" or "$/ft^2 floor"
not in self.cost_units):
cost_meas, cost_units = [x for x in bldgs_costconverted[
mskeys[2]]]
# Re-initialize ECM cost attribute for each new building
# type or technology type if required for the given cost units
elif ind == 0 or any([
x in self.cost_units for x in
self.handyvars.cconv_bybldg_units]) or (
bldg_sect == "commercial" and sqft_subst != 1):
cost_meas, cost_units = [
self.installed_cost, self.cost_units]
elif isinstance(self.installed_cost, dict) or \
isinstance(self.cost_units, dict):
else:
cost_meas, cost_units = [
self.installed_cost, self.cost_units]
# Set lifetime attribute to initial value
Expand Down
11 changes: 5 additions & 6 deletions ecm_prep_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14381,13 +14381,13 @@ def setUpClass(cls):
"lifetime": {"baseline": {"2009": 140, "2010": 140},
"measure": 1}}]
cls.ok_distmeas_out = [
[120.86, 100, 773.92, 100, 1.0, 1,
[120.86, 100, 793.34, 100, 1.0, 1,
{yr: 0.02 for yr in handyvars.aeo_years}, 1],
[11.9, 100, 374.73, 100, 1.28, 100,
[11.15, 100, 372.48, 100, 1.36, 100,
{yr: 0.02 for yr in handyvars.aeo_years}, 1],
[55.44, 100, 6451739849.37, 100, 1.0, 1,
[55.81, 100, 5522144686.13, 100, 1.0, 1,
{yr: 0.02 for yr in handyvars.aeo_years}, 1],
[10.91, 1, 45, 1, 1, 1,
[10.91, 1, 45.0, 1, 1.0, 1,
{yr: 0.06 for yr in handyvars.aeo_years}, 100]]
cls.ok_tpmeas_sitechk_msegout = [{
"stock": {
Expand Down Expand Up @@ -15036,8 +15036,8 @@ def test_mseg_ok_distrib(self):
"""
# Seed random number generator to yield repeatable cost, performance
# and lifetime results
numpy.random.seed(1234)
for idx, measure in enumerate(self.ok_distmeas_in):
numpy.random.seed(1234)
# Generate lists of energy and cost output values
measure.fill_mkts(
self.sample_mseg_in, self.sample_cpl_in,
Expand Down Expand Up @@ -15071,7 +15071,6 @@ def test_mseg_ok_distrib(self):
if ind == 0:
len_test_r = 1
param_r[k] = test_r[k]

# Check mean values and length of output lists to ensure
# correct
self.assertEqual([
Expand Down

0 comments on commit 12e47a9

Please sign in to comment.