MEOS/LoadProfile.py

46 lines
1.6 KiB
Python

import numpy as np
from Utilities.Time import generate_timestrings, index_peak_times
def get_no_of_peaks(peak_bounds):
peak_occurences = np.random.randint(peak_bounds["min"], peak_bounds["max"], 1)
return peak_occurences
def generate_peak_info(c, dt):
no_of_peaks = get_no_of_peaks(c["site_info"]["no_of_peaks"])
operating_hours = generate_timestrings(
c["site_info"]["operating hours"]["start"],
c["site_info"]["operating hours"]["end"],
dt,
)
peak_times = np.random.choice(operating_hours, no_of_peaks, replace=False)
peak_durations = np.random.randint(
c["site_info"]["peak_duration"]["min"],
c["site_info"]["peak_duration"]["max"],
no_of_peaks,
)
return peak_times, peak_durations
def get_load_profile(c, dt, batch_start_time, batch_process_duration):
# Generate load profile for each site
# c is the configuration dictionary
# dt is the time step in seconds
# batch_start_time is the start time for the batch process in seconds since the epoch
# batch_process_duration is the duration of the batch process in seconds
# start with indexing all the peak occurences
# generate timeseries from start to end time
start_time = batch_start_time
end_time = start_time + batch_process_duration
timestamps = np.arange(start_time, end_time, dt)
# Generate peak times and durations
peak_times, peak_durations = generate_peak_info(c, dt)
# Generate peak times and durations
peak_indices = index_peak_times(timestamps, peak_times, peak_durations)