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
¶
baseline_hour_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
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 |
|
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, settings=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
is_electricity_data = is_electricity_data
instance-attribute
¶
tz = None
instance-attribute
¶
warnings = []
instance-attribute
¶
disqualification = []
instance-attribute
¶
pv_start = None
instance-attribute
¶
settings = HourlyDataSettings()
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, settings=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
is_electricity_data = is_electricity_data
instance-attribute
¶
tz = None
instance-attribute
¶
warnings = []
instance-attribute
¶
disqualification = []
instance-attribute
¶
pv_start = None
instance-attribute
¶
settings = HourlyDataSettings()
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.