Hourly Model
opendsm.eemeter.models.hourly
¶
Copyright 2014-2025 OpenDSM contributors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
HourlyModel(settings=None)
¶
A class to fit a model to the input meter data.
Attributes:
Name | Type | Description |
---|---|---|
settings |
dict
|
A dictionary of settings. |
baseline_metrics |
dict
|
A dictionary of metrics based on input baseline data and model fit. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
settings |
dict | BaseHourlySettings | None
|
HourlySettings to use (generally left default). Will default to solar model if GHI is given to the fit step. |
None
|
Source code in opendsm/eemeter/models/hourly/model.py
settings = _settings.BaseHourlySettings()
instance-attribute
¶
is_fitted = False
instance-attribute
¶
baseline_metrics = None
instance-attribute
¶
warnings: list[EEMeterWarning] = []
instance-attribute
¶
disqualification: list[EEMeterWarning] = []
instance-attribute
¶
baseline_timezone = None
instance-attribute
¶
error = dict()
instance-attribute
¶
version = __version__
instance-attribute
¶
fit(baseline_data, ignore_disqualification=False)
¶
Fit the model using baseline data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
baseline_data |
HourlyBaselineData
|
HourlyBaselineData object. |
required |
ignore_disqualification |
bool
|
Whether to ignore disqualification errors / warnings. |
False
|
Returns:
Type | Description |
---|---|
HourlyModel
|
The fitted model. |
Raises:
Type | Description |
---|---|
TypeError
|
If baseline_data is not an HourlyBaselineData object. |
DataSufficiencyError
|
If the model can't be fit on disqualified baseline data. |
Source code in opendsm/eemeter/models/hourly/model.py
predict(reporting_data, ignore_disqualification=False)
¶
Predicts the energy consumption using the fitted model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reporting_data |
Union[HourlyBaselineData, HourlyReportingData]
|
The data used for prediction. |
required |
ignore_disqualification |
bool
|
Whether to ignore model disqualification. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
Dataframe with input data along with predicted energy consumption. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the model is not fitted. |
DisqualifiedModelError
|
If the model is disqualified and ignore_disqualification is False. |
TypeError
|
If the reporting data is not of type HourlyBaselineData or HourlyReportingData. |
Source code in opendsm/eemeter/models/hourly/model.py
to_dict()
¶
Returns a dictionary of model parameters.
Returns:
Type | Description |
---|---|
dict
|
Model parameters. |
Source code in opendsm/eemeter/models/hourly/model.py
to_json()
¶
Returns a JSON string of model parameters.
Returns:
Type | Description |
---|---|
str
|
Model parameters. |
from_dict(data)
classmethod
¶
Create a instance of the class from a dictionary (such as one produced from the to_dict method).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
dict
|
The dictionary containing the model data. |
required |
Returns:
Type | Description |
---|---|
HourlyModel
|
An instance of the class. |
Source code in opendsm/eemeter/models/hourly/model.py
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 |
|
from_json(str_data)
classmethod
¶
Create an instance of the class from a JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
str_data |
The JSON string representing the object. |
required |
Returns:
Type | Description |
---|---|
HourlyModel
|
An instance of the class. |
Source code in opendsm/eemeter/models/hourly/model.py
plot(df_eval)
¶
Plot a model fit with baseline or reporting data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df_eval |
HourlyBaselineData | HourlyReportingData
|
The baseline or reporting data object to plot. |
required |
Source code in opendsm/eemeter/models/hourly/model.py
HourlyBaselineData(df, is_electricity_data, pv_start=None, **kwargs)
¶
Data class to represent Hourly Baseline Data.
Only baseline data should go into the dataframe input, no blackout data should be input. Checks sufficiency for the data provided as input depending on OpenEEMeter specifications and populates disqualifications and warnings based on it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
A dataframe having a datetime index or a datetime column with the timezone also being set. It also requires 2 more columns - 'observed' for meter data, and 'temperature' for temperature data. Optionally, column 'ghi' can be included in order to fit on solar data. The temperature column should have values in Fahrenheit. Please convert your temperatures accordingly. |
required |
is_electricity_data |
bool
|
Flag to ascertain if this is electricity data or not. Electricity data values of 0 are set to NaN. |
required |
Attributes:
Name | Type | Description |
---|---|---|
df |
DataFrame
|
Immutable dataframe that contains the meter and temperature values for the baseline data period. |
disqualification |
list[EEMeterWarning]
|
A list of serious issues with the data that can degrade the quality of the model. If you want to go ahead with building the model while ignoring them, set the ignore_disqualification = True flag in the model. By default disqualifications are not ignored. |
warnings |
list[EEMeterWarning]
|
A list of issues with the data, but none that will severely reduce the quality of the model built. |
pv_start |
date
|
Solar install date. If left unset, assumed to be at beginning of data. |
Source code in opendsm/eemeter/models/hourly/data.py
warnings = []
instance-attribute
¶
disqualification = []
instance-attribute
¶
is_electricity_data = is_electricity_data
instance-attribute
¶
tz = None
instance-attribute
¶
pv_start = None
instance-attribute
¶
df
property
¶
Get the corrected input data stored in the class. The actual dataframe is immutable, this returns a copy.
log_warnings()
¶
Logs the warnings and disqualifications associated with the data.
HourlyReportingData(df, is_electricity_data, pv_start=None, **kwargs)
¶
Data class to represent Hourly Reporting Data.
Only reporting data should go into the dataframe input, no blackout data should be input. Checks sufficiency for the data provided as input depending on OpenEEMeter specifications and populates disqualifications and warnings based on it.
Meter data input is optional for the reporting class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
A dataframe having a datetime index or a datetime column with the timezone also being set. It also requires 2 more columns - 'observed' for meter data, and 'temperature' for temperature data. If GHI was provided during the baseline period, it should also be supplied for the reporting period with column name 'ghi'. The temperature column should have values in Fahrenheit. Please convert your temperatures accordingly. |
required |
is_electricity_data |
bool
|
Flag to ascertain if this is electricity data or not. Electricity data values of 0 are set to NaN. |
required |
Attributes:
Name | Type | Description |
---|---|---|
df |
DataFrame
|
Immutable dataframe that contains the meter and temperature values for the baseline data period. |
disqualification |
list[EEMeterWarning]
|
A list of serious issues with the data that can degrade the quality of the model. If you want to go ahead with building the model while ignoring them, set the ignore_disqualification = True flag in the model. By default disqualifications are not ignored. |
warnings |
list[EEMeterWarning]
|
A list of issues with the data, but none that will severely reduce the quality of the model built. |
pv_start |
date
|
Solar install date. If left unset, assumed to be at beginning of data. |
Source code in opendsm/eemeter/models/hourly/data.py
warnings = []
instance-attribute
¶
disqualification = []
instance-attribute
¶
is_electricity_data = is_electricity_data
instance-attribute
¶
tz = None
instance-attribute
¶
pv_start = None
instance-attribute
¶
df
property
¶
Get the corrected input data stored in the class. The actual dataframe is immutable, this returns a copy.
log_warnings()
¶
Logs the warnings and disqualifications associated with the data.