Ejemplo n.º 1
0
def follow_generated_consumption_profile(
    start: datetime,
    end: datetime,
    resolution: timedelta,
    max_capacity: float,
    dispatch_factor: float = None,
    profile: Series = None,
) -> DataFrame:
    """Can be used to model a device with the artificially generatred consumption or production profiles."""

    if profile is None:
        full_year_monthly_profile = (
            cos(2 * pi / 12 * linspace(0, 11, 12)) * 50 + 100) * 0.75
        full_year_monthly_load_profile = el.make_timeseries(
            full_year_monthly_profile)
        dummy_index = DatetimeIndex(
            start=datetime(year=2018, month=1, day=1),
            end=datetime(year=2019, month=1, day=1, hour=0),
            freq="H",
        )
        dummy_index = dummy_index.drop(dummy_index[-1])

        weight = uniform(0.5, 0.8)
        daily_load_working = el.gen_daily_stoch_el()
        daily_load_non_working = el.gen_daily_stoch_el()
        profile = el.gen_load_from_daily_monthly(
            full_year_monthly_load_profile,
            daily_load_working,
            daily_load_non_working,
            weight,
        )
        profile_noized = el.add_noise(profile, 3, 0.25)
        profile_noized.index = dummy_index

        if int(resolution.seconds / 3600) == 1.0:
            pass
        else:
            profile_noized = (profile_noized.drop(
                index=profile_noized.index[-1]).resample(rule="15T").mean())
            profile_noized = profile_noized.interpolate(method="linear").drop(
                index=profile_noized.index[-1])
            profile_noized = profile_noized + abs(
                normal(0, 0.05, [len(profile_noized.index)]))
        profile = profile_noized * max_capacity

    else:
        pass

    df = limited_consumption_profile(start=start,
                                     end=end,
                                     resolution=resolution,
                                     capacity=max_capacity)

    df["derivative equals"] = profile.loc[start:end - resolution].values

    if dispatch_factor is not None:
        if dispatch_factor == 0:
            pass

        if dispatch_factor == 1:
            df["derivative max"] = df["derivative equals"]
            df["derivative equals"] = nan

        else:
            df["derivative max"] = df["derivative equals"]
            df["derivative equals"] = df["derivative equals"] * (
                1 - dispatch_factor)
            # print(df)
            # print("consumption")
    return df
Ejemplo n.º 2
0
def follow_generated_production_profile(
    start: datetime,
    end: datetime,
    resolution: timedelta,
    max_capacity: float,
    dispatch_factor: float = None,
    profile: Series = None,
) -> DataFrame:

    if profile is None:
        dummy_index = DatetimeIndex(
            start=datetime(year=2018, month=1, day=1),
            end=datetime(year=2019, month=1, day=1, hour=0),
            freq="15T",
        )
        dummy_index = dummy_index.drop(dummy_index[-96])

        mu, sigma = 1, 0.01
        s = normal(mu, sigma, 5000)
        count, bins, ignored = hist(s, 72, normed=False)
        daily_profile = count / count.max()
        yearly_curve = (
            -cos(2 * pi / 35040 * linspace(0, 35039, 35040) + 0.2) * 50 +
            100) * 0.75

        stacks = []

        for i in range(1, 366):
            s = Series(index=RangeIndex(start=1, stop=97, step=1), data=0)
            s[12:84] = el.add_noise(daily_profile,
                                    mode=3,
                                    st=0.05,
                                    Lmin=0,
                                    r=0.01).values
            stacks.append(list(s.values))

        stacks = [item for sublist in stacks for item in sublist]
        full_year_profile = stacks * yearly_curve
        full_year_profile = full_year_profile / full_year_profile.max()
        profile = Series(data=full_year_profile, index=dummy_index)
        profile *= max_capacity
    else:
        pass

    df = limited_production_profile(start=start,
                                    end=end,
                                    resolution=resolution,
                                    capacity=max_capacity)
    df["derivative equals"] = -profile.loc[start:end - resolution].values

    if dispatch_factor is not None:
        if dispatch_factor == 0:
            pass

        if dispatch_factor == 1:
            df["derivative min"] = df["derivative equals"]
            df["derivative equals"] = nan

        else:
            df["derivative min"] = df["derivative equals"]
            df["derivative equals"] = df["derivative equals"] * (
                1 - dispatch_factor)
            # print("generation")
            # print(df)
    return df