ScheduleModel

class OBLib.ScheduleModel.ScheduleModel[source]

Bases: OBLib.DeterministicModel.DeterministicModel

The ScheduleModel class.

This is a deterministic model which makes predictions based on a series of fixed ‘daily profiles’.

This is similar to the approach taken to specify schedules in many building simulation tools.

Code Example

>>> from OBLib import ScheduleModel
>>> model=ScheduleModel()
>>> model.inputs.set_timestamps(start=(2021,1,1),
>>>                             freq='H',
>>>                             periods=24*7)
>>> model.inputs.all_days=[21]
>>> result=model.run()
property inputs

The model inputs. Access this object to change the model inputs.

Read-only property.

Return type

ScheduleInputs

run()[source]

Runs the model.

Returns

The model outputs.

Return type

ScheduleOutputs

class OBLib.ScheduleModel.ScheduleInputs[source]

Bases: OBLib.DeterministicModel.DeterministicInputs

Inputs to the ScheduleModel class.

The inputs are formed of a series of ‘day profiles’.

A day profile is a list of numbers which represents the schedule for a day: For example:

  • [21] represents a constant value of 21 throughout the day.

  • [5,12,5] represents a value of 5 for the first 8 hours, followed by a value of 21 for the next 8 hours, with a final value of 8 for the remaining 8 hours.

  • [5]*8 + [12]*8 + [5]*8 represents the same profile as [5,12,5]

Day profile lists can be set to the following attributes. These attributes are applied in the order below when creating the final predicted values.

  • all_days: This day profile is applied to all days.

  • weekdays: This day profile is applied to weekdays (Monday to Friday) only.

  • weekends: This day profile is applied to weekends (Saturday and Sunday) only.

property all_days

A day schedule to be applied to all days.

Default value is [np.nan].

Read/write property.

Return type

tuple or list

set_timestamps(start=None, end=None, *args, **kwargs)

Convenience method to set the timestamps property.

Parameters
  • start (tuple) – The start timestamp (optional)

  • end (tuple) – The end timestamp (optional)

The remaining input arguments here are passed to the pandas.date_range method. See the pandas documentation for details.

Typcial inputs might be:

  • start=(2021,1,1,0,0) (i.e. 1st January 2021)

  • freq=’H’ (for hourly intervals)

  • periods=24 (to generate 1 day of hourly intervals)

Return type

pandas.DatetimeIndex

property timestamps

The input timestamps. Model predictions will be made for each timestamp.

Read / write property.

Return type

pandas.DatetimeIndex

property weekdays

A day schedule to be applied to weekdays (Monday to Friday).

Read/write property.

Return type

tuple or list

property weekends

A day schedule to be applied to weekends (Saturday and Sunday).

Read/write property.

Return type

tuple or list

class OBLib.ScheduleModel.ScheduleOutputs[source]

Bases: OBLib.DeterministicModel.DeterministicOutputs

Outputs of the ScheduleModel class.

property data

The model predictions.

Read-only property.

Returns

A dictionary of the model results. Key-value pairs are: keys -> the name of the quantity or variable; values -> a list of the model predictions (this list aligns with the output timestamps).

Return type

dict

property df

A Pandas dataframe of the timestamps and data.

Read-only property.

Returns

A dataframe with: index -> timestamps; columns -> ‘data’ keys; values -> data values.

Return type

pandas.DataFrame

property timestamps

The outputs timestamps.

Read-only property.

Return type

pandas.DatetimeIndex