Skip to content

Commit

Permalink
fixed bug in weekly plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasFrankenQ committed Aug 13, 2023
1 parent a1dbea8 commit 4bc19ea
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 17 deletions.
22 changes: 12 additions & 10 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ scenario:
- 'eso' # regions can be 'eso' zones (emphasizing grid conjestion), or 'dno'
fes: # Future energy scenario considered, can be
# - 'CT' # Consumer Transformation
- 'FS' # Falling Short
# - 'LW' # Leading the Way
# - 'FS' # Falling Short
- 'LW' # Leading the Way
# - 'ST' # System Transformation
year: # investment years for myopic and perfect; for overnight, year of cost assumptions can be different and is defined under 'costs'
- 2023
Expand Down Expand Up @@ -65,7 +65,7 @@ flexibility:
winter_months: [12, 1, 2]
event_start_hour: 17
event_end_hour: 19
heat_share_smart_tariff: 0.5 # share of consumers with heat pumps that have a smart tariff
smart_heat_rollout_completion: 2030 # year where all heat pumps contribute to smart heat
heat_shift_size: 3 # hours
heat_flex_windows:
morning:
Expand Down Expand Up @@ -122,15 +122,17 @@ flexibility:
freq: h
month: 1
year:
freq: d
freq: w
shortweek:
freq: h
start: 2022-01-21
end: 2022-01-27
start_month: 1
start_day: 21
end_month: 1
end_day: 27
longweek:
freq: h
start: 2022-10-28
end: 2022-11-04
start_month: 10
start_day: 28
end_month: 11
end_day: 4
do_group: true
do_group_flex: false
add_kirchhoff: true
Expand Down
29 changes: 23 additions & 6 deletions scripts/plot_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ def make_co2_barplot(n):
plt.show()


def get_timeseries_subset(*args , timeseries_mode="month", config=None):
def get_timeseries_subset(*args, timeseries_mode="month", config=None):

assert args, "No dataframes passed"

assert sum(
[isinstance(arg, pd.DataFrame) or
isinstance(arg, pd.Series) for arg in args]) == len(args), "Only one DataFrame can be passed as argument"

assert config is not None, "kwarg config has to be passed as non-None value"

if (mode := timeseries_mode) in ["month", "year"]:
freq = config["flexibility"]["timeseries_params"][mode].get("freq", "1H")
month = config["flexibility"]["timeseries_params"][mode].get("month", range(1, 13))
Expand All @@ -207,15 +207,29 @@ def get_timeseries_subset(*args , timeseries_mode="month", config=None):


elif mode in ["shortweek", "longweek"]:
start = config["flexibility"]["timeseries_params"][mode]["start"]
end = config["flexibility"]["timeseries_params"][mode]["end"]

s = args[0].index[(args[0].index >= pd.Timestamp(start)) & (args[0].index <= pd.Timestamp(end))]
frame = config["flexibility"]["timeseries_params"][mode]

start = pd.Timestamp(
year=2022,
month=frame["start_month"],
day=frame["start_day"]
)

end = pd.Timestamp(
year=2022,
month=frame["end_month"],
day=frame["end_day"]
)

s = args[0].index[(args[0].index >= start) & (args[0].index <= end)]

args = list(map(lambda x: x.loc[s], args))

else:
raise ValueError(f"Unknown mode {mode}, should be one of 'month', 'year', 'shortweek', 'longweek'")

return args


if __name__ == "__main__":
Expand Down Expand Up @@ -274,6 +288,9 @@ def get_timeseries_subset(*args , timeseries_mode="month", config=None):
# def get_timeseries_subset(*args , timeseries_mode="month", config=None):

ts_mode = snakemake.wildcards["timeseries_mode"]

logger.info(f"Found time series mode {ts_mode}.")

inflow, outflow = get_timeseries_subset(inflow, outflow,
timeseries_mode=ts_mode,
config=snakemake.config,
Expand Down
2 changes: 1 addition & 1 deletion scripts/prepare_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def add_heat_pump_load(

complete_rollout_year = snakemake.config["flexibility"]["heat_shift_size"]
share_smart_tariff = np.interp(
year,
year,
[2023, complete_rollout_year],
[0., 1.]
)
Expand Down

0 comments on commit 4bc19ea

Please sign in to comment.