flixopt.io
Classes
CalculationResultsPaths
dataclass
Container for all paths related to saving CalculationResults.
Functions
create_folders
Ensure the folder exists. Args: parents: Whether to create the parent folders if they do not exist.
Functions
replace_timeseries
Recursively replaces TimeSeries objects with their names prefixed by '::::'.
insert_dataarray
Recursively inserts TimeSeries objects into a dataset.
remove_none_and_empty
Recursively removes None and empty dicts and lists values from a dictionary or list.
document_linopy_model
Convert all model variables and constraints to a structured string representation. This can take multiple seconds for large models. The output can be saved to a yaml file with readable formating applied.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to save the document. Defaults to None. |
None
|
save_dataset_to_netcdf
Save a dataset to a netcdf file. Store the attrs as a json string in the 'attrs' attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ds
|
Dataset
|
Dataset to save. |
required |
path
|
Union[str, Path]
|
Path to save the dataset to. |
required |
compression
|
int
|
Compression level for the dataset (0-9). 0 means no compression. 5 is a good default. |
0
|
Raises:
Type | Description |
---|---|
ValueError
|
If the path has an invalid file extension. |
load_dataset_from_netcdf
Load a dataset from a netcdf file. Load the attrs from the 'attrs' attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Union[str, Path]
|
Path to load the dataset from. |
required |
Returns:
Name | Type | Description |
---|---|---|
Dataset |
Dataset
|
Loaded dataset. |