def activate_variability(self, variability_band: int):
        """
        Use variable wakeup and sleeptime hour per day.

        :param variability_band: defining range of hours +/-; resulting hour is trimmed to 0...23h
        :return: nothing, values per day are cached
        """
        self.wakeup_hour_daily = profile_variability.randomize_vertical(
            values=self.__get_wakeup_year_prof_daily_nom(),
            band=variability_band,
            min_value=MIN_HOUR_OF_DAY,
            max_value=MAX_HOUR_OF_DAY,
        )
        self.wakeup_hour_daily = [round(x, 0) for x in self.wakeup_hour_daily]
        self.sleeptime_hour_daily = profile_variability.randomize_vertical(
            values=self.__get_sleeptime_year_prof_daily_nom(),
            band=variability_band,
            min_value=MIN_HOUR_OF_DAY,
            max_value=MAX_HOUR_OF_DAY,
        )
        self.sleeptime_hour_daily = [
            round(x, 0) for x in self.sleeptime_hour_daily
        ]
        assert all(
            wake < sleep for wake, sleep in zip(self.wakeup_hour_daily,
                                                self.sleeptime_hour_daily)
        ), "variability band too big, wakeup is after sleep time for some days... please adjust variability_band for activate_variability()"
def test_randomize_vertical_limit_max():
    max = 0.95
    variable_vals = profile_variability.randomize_vertical([0.9] * 100,
                                                           0.3,
                                                           max_value=max)
    for val in variable_vals:
        assert val <= max
    def __gen_app_prof_for_room_variable(self, room_type,
                                         vertical_variability: float,
                                         do_horizontal_variability: bool):

        appliance_profile = profile_generation.expand_year_profile_monthly_to_hourly(
            self.get_year_profile_variation_monthly_for_room_method(room_type),
            self.base_data.get_appliance_day_profile_hourly(room_type),
        )

        if vertical_variability > 0:
            min_value = self.base_data.get_appliance_profile_min_value_allowed(
                room_type)
            appliance_profile = profile_variability.randomize_vertical(
                appliance_profile, vertical_variability, min_value,
                self.profile_max_value)

        # target for "weekend correction" are non residential buildings, thus fixed value without randomization is ok.
        appliance_profile = profile_generation.correct_weekends(
            appliance_profile,
            self.base_data.get_nr_of_rest_days_per_week(room_type).m,
            weekend_value=self.base_data.
            get_appliance_profile_fixed_weekend_value(room_type),
            start_date=self._profile_start_date,
        )

        if do_horizontal_variability:
            horizontal_breaks = self.base_data.get_horizontal_breaks_appliances(
                room_type)
            appliance_profile = profile_variability.horizontal_variability(
                appliance_profile, horizontal_breaks)

        return appliance_profile
    def __generate_occupancy_profile_variable_for_room(
            self, room_type, vertical_variability: float,
            do_horizontal_variability: bool):
        """
        Generates occupancy profile with vertical and horizontal variability as configured by the parameters for the given room type of the building

        :param room_type: room type in building for which to generate the profile
        :param vertical_variability: vertical variability, for no vertical variability set to 0
        :param do_horizontal_variability: True if horizontal variability/shuffling should be applied, false otherwise
        :return: occupancy profile for one year, hourly values for given room
        """

        # might or might not have monthly variation according to passed method
        occupancy_prof_hourly = self.__generate_base_occupancy_profile(
            room_type)

        if vertical_variability > 0:
            # randomize  to avoid having the same profile for each day of a month
            occupancy_prof_hourly = profile_variability.randomize_vertical(
                occupancy_prof_hourly, vertical_variability)

        # target for "weekend correction" are non residential buildings - on a weekend a fixed value is used
        occupancy_prof_hourly = self.__handle_restdays(occupancy_prof_hourly,
                                                       room_type)

        if do_horizontal_variability:
            horizontal_breaks = self.base_data.get_horizontal_breaks_occupancy(
                room_type)  # empty means no horizontal variability / shuffling
            occupancy_prof_hourly = profile_variability.horizontal_variability(
                occupancy_prof_hourly, horizontal_breaks)

        if self.base_data.is_occupancy_nominal_during_night(room_type):
            occupancy_prof_hourly = profile_generation.combine_day_and_nighttime_profiles(
                occupancy_prof_hourly, occupancy_prof_hourly,
                self.nighttime_pattern_year_profile_bldg_hourly)

        return occupancy_prof_hourly
def test_randomize_vertical():
    variable_vals = profile_variability.randomize_vertical([0.8] * 12, 0.15)
    assert len(variable_vals) == 12
    for val in variable_vals:
        assert 0.8 - 0.15 <= val and 0.8 + 0.15 > val
Ejemplo n.º 6
0
 def __generate_monthly_variation_variable(self, room_type,
                                           vertical_variability):
     monthly_variation_nom = self.base_data.get_monthly_variation(room_type)
     return profile_variability.randomize_vertical(
         values=monthly_variation_nom, band=vertical_variability)