custom_curves
custom_curves
Custom curve data models for scenario inputs.
Classes
CustomCurveError
Bases: Exception
Base custom curve error
CustomCurve
Bases: Base
Wrapper around a single custom curve. Curves are getting saved to the filesystem, as bulk processing of scenarios could end up with several 100 MBs of curves, which we don't want to keep in memory.
Source code in src/pyetm/models/base.py
Functions
retrieve
Process curve from client, save to file, set file_path
Source code in src/pyetm/models/custom_curves.py
contents
Open file from path and return contents
Source code in src/pyetm/models/custom_curves.py
remove
Remove file and clear path
Source code in src/pyetm/models/custom_curves.py
from_json
classmethod
Initialize a CustomCurve from JSON data
Source code in src/pyetm/models/custom_curves.py
CustomCurves
Bases: Base
Wrapper around a collection of custom curves.
Source code in src/pyetm/models/base.py
Functions
is_attached
attached_keys
from_json
classmethod
Initialize CustomCurves collection from JSON data
Source code in src/pyetm/models/custom_curves.py
validate_for_upload
Validate all curves for upload
Source code in src/pyetm/models/custom_curves.py
is_valid_update
Validate curve updates without applying them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
updates
|
dict[str, Series]
|
Dictionary mapping curve keys to pandas Series with 8760 values |
required |
Returns:
| Type | Description |
|---|---|
dict[str, WarningCollector]
|
Dictionary mapping curve keys to WarningCollector objects for errors |
Source code in src/pyetm/models/custom_curves.py
update
Update custom curve data with validation and warning display.
Invalid curves are rejected (not updated) to maintain data integrity. Warnings are automatically displayed for invalid curves and non-existent keys. Warnings from previous updates are cleared to show only current operation issues.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
updates
|
dict[str, Series]
|
Dictionary mapping curve keys to pandas Series with 8760 values |
required |
Source code in src/pyetm/models/custom_curves.py
remove_curve
Remove a specific custom curve's cache file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
curve_name
|
str
|
Name of the curve to remove |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if successfully removed, False otherwise |
Source code in src/pyetm/models/custom_curves.py
clear_cache
Clear all custom curve cache files.
Returns:
| Type | Description |
|---|---|
int
|
Number of files successfully removed |