Exemplo n.º 1
0
 def __read_partial_shares(self, bldg_type: BldgType):
     partial_ret_shares = self.__read_raw_df(self._es_cfg["RETROFIT"]["PARTIAL_SHARES"][bldg_type.name])
     idx = partial_ret_shares[self._COL_LABEL_YOC].apply(lambda yoc: AgeClass.from_string(yoc))
     partial_ret_shares.set_index(idx, inplace=True)
     partial_ret_shares.drop(self._COL_LABEL_YOC, axis="columns", inplace=True)
     partial_ret_shares.columns = [int(col_idx) if col_idx != self._COL_LABEL_BLDG_ELEMS else col_idx for col_idx in partial_ret_shares.columns]
     bldg_elem_col = partial_ret_shares[self._COL_LABEL_BLDG_ELEMS].apply(self.__convert_bldg_elems_str_to_enum_array)
     partial_ret_shares.drop(self._COL_LABEL_BLDG_ELEMS, axis="columns", inplace=True)  # remove column to be able to use applymap on all numeric entries...
     partial_ret_shares = partial_ret_shares.applymap(lambda x: x / 100)  # in input files retrofit rates are in % from 0..100
     partial_ret_shares = pd.concat([partial_ret_shares, bldg_elem_col], axis="columns")  # add bldg elem col again
     return partial_ret_shares
Exemplo n.º 2
0
 def __read_full_rates(self, bldg_type: BldgType):
     """
     :param bldg_type:
     :return: pandas df, index is AgeClass() instance, representing year of construction range
     """
     full_ret_rates = self.__read_raw_df(self._es_cfg["RETROFIT"]["FULL_RATES"][bldg_type.name])
     idx = full_ret_rates[self._COL_LABEL_YOC].apply(lambda yoc: AgeClass.from_string(yoc))
     full_ret_rates.set_index(idx, inplace=True)
     full_ret_rates.drop(self._COL_LABEL_YOC, axis="columns", inplace=True)
     ac_to_part_ret_ac = full_ret_rates[self._COL_LABEL_PARTIAL_AC_MAPPING].apply(lambda ac: AgeClass.from_string(ac))
     full_ret_rates.drop(self._COL_LABEL_PARTIAL_AC_MAPPING, axis="columns", inplace=True)
     full_ret_rates.columns = [int(col_idx) for col_idx in full_ret_rates.columns]
     full_ret_rates = full_ret_rates.applymap(lambda x: x / 100)  # in input files retrofit rates are in % from 0..100
     return pd.concat([full_ret_rates, ac_to_part_ret_ac], axis="columns")
Exemplo n.º 3
0
def test_age_class_init_from_string():
    the_ac = AgeClass.from_string(" < 1918")
    assert the_ac.min_age == None
    assert the_ac.max_age == 1917

    the_ac = AgeClass.from_string("<=1922")
    assert the_ac.min_age == None
    assert the_ac.max_age == 1922

    the_ac = AgeClass.from_string("1918-1947")
    assert the_ac.min_age == 1918
    assert the_ac.max_age == 1947

    the_ac = AgeClass.from_string(" 1955  -2020")
    assert the_ac.min_age == 1955
    assert the_ac.max_age == 2020

    the_ac = AgeClass.from_string(">2050")
    assert the_ac.min_age == 2051
    assert the_ac.max_age == None

    the_ac = AgeClass.from_string(">= 2050")
    assert the_ac.min_age == 2050
    assert the_ac.max_age == None