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
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 |
|
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.