Code Reference
framdata
database_names
DatabaseNames
Container for names and locations of files and folders in the NVE database.
DatabaseNames
Bases: Base
Define names of files and folders in the NVE database and map files to folders.
Source code in framdata/database_names/DatabaseNames.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
get_file_name(source: Path, db_folder: str, file_id: str) -> str | None
classmethod
Get the name of a file, with extension, from a file ID and a path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path
|
Root path of the database. |
required |
db_folder
|
str
|
Database folder to look for the file in. |
required |
file_id
|
str
|
ID of file, i.e the name of the file without extension. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If multiple files with the same ID but different extensions are found. |
Returns:
Type | Description |
---|---|
str | None
|
str | None: File ID and extension combined. If file is not found, return None. |
Source code in framdata/database_names/DatabaseNames.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
get_relative_folder_path(file_id: str) -> Path
classmethod
Get the relative database folder path for a given file_id.
The relative path consists of database folder and file name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_id
|
str
|
Identifier for the file to retrieve. |
required |
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
The database folder name. |
Source code in framdata/database_names/DatabaseNames.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
DemandNames
Contains classes defining the demand table and validations.
DemandMetadataSchema
Bases: _AttributeMetadataSchema
Pandera DataFrameModel schema for metadata in the Demand.Consumers file.
Source code in framdata/database_names/DemandNames.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
check_unit_is_str_for_attributes(df: pd.DataFrame) -> Series[bool]
classmethod
Check that the 'unit' value is a string for the row where 'attribute' is 'Capacity'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
Dataframe
|
DataFrame used to check value for "unit". |
required |
Returns:
Type | Description |
---|---|
Series[bool]
|
Series[bool]: Series of boolean values detonating if each element has passed the check. |
Source code in framdata/database_names/DemandNames.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
DemandNames
Bases: _BaseComponentsNames
Container class for describing the demand attribute table's names, structure, and convertion to Demand Component.
Source code in framdata/database_names/DemandNames.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> dict[str, Demand]
staticmethod
Create a Demand component from a table row in the Demand.Consumers file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one Demand object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
list[str]
|
Set of columns which defines memberships in meta groups for aggregation. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]]
|
NOT USED |
None
|
Returns:
Type | Description |
---|---|
dict[str, Demand]
|
dict[str, Demand]: A dictionary with the consumer_id as key and the demand component as value. |
Source code in framdata/database_names/DemandNames.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
get_attribute_data_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for attribute data in the Demand.Consumers file.
Returns:
Name | Type | Description |
---|---|---|
DemandSchema |
DataFrameModel
|
Pandera DataFrameModel schema for Demand attribute data. |
Source code in framdata/database_names/DemandNames.py
131 132 133 134 135 136 137 138 139 140 |
|
get_metadata_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for metadata in the Demand.Consumers file.
Returns:
Name | Type | Description |
---|---|---|
DemandMetadataSchema |
DataFrameModel
|
Pandera DataFrameModel schema for Demand metadata. |
Source code in framdata/database_names/DemandNames.py
142 143 144 145 146 147 148 149 150 151 |
|
DemandSchema
Bases: DataFrameModel
Pandera DataFrameModel schema for attribute data in the Demand.Consumers file.
Source code in framdata/database_names/DemandNames.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
Config
Schema-wide configuration for the DemandSchema class.
Source code in framdata/database_names/DemandNames.py
296 297 298 299 |
|
check_elastic_demand(df: DataFrame) -> Series[bool]
classmethod
Check that all elastic demand values are present if one or more is.
Source code in framdata/database_names/DemandNames.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
dtype_str_int_float(series: Series[Any]) -> Series[bool]
classmethod
Check if values in the series are of datatype: str, int or float.
Source code in framdata/database_names/DemandNames.py
233 234 235 236 237 |
|
dtype_str_int_float_none(series: Series[Any]) -> Series[bool]
classmethod
Check if values in the series are of datatype: str, int, float or None.
Source code in framdata/database_names/DemandNames.py
239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
numeric_values_are_between_or_equal_to_0_and_1(series: Series[Any]) -> Series[bool]
classmethod
Check if numeric values in the series are between zero and one or equal to zero and one.
Source code in framdata/database_names/DemandNames.py
271 272 273 274 275 |
|
numeric_values_greater_than_or_equal_to_0(series: Series[Any]) -> Series[bool]
classmethod
Check if numeric values in the series are greater than or equal to zero.
Source code in framdata/database_names/DemandNames.py
259 260 261 262 263 264 265 266 267 268 269 |
|
numeric_values_less_than_or_equal_to_0(series: Series[Any]) -> Series[bool]
classmethod
Check if numeric values in the series are less than or equal to zero.
Source code in framdata/database_names/DemandNames.py
253 254 255 256 257 |
|
H5Names
Define names and fields used in H5 files.
H5Names
Container class for names used in H5 files.
Source code in framdata/database_names/H5Names.py
4 5 6 7 8 9 10 |
|
HydroBypassNames
Contain the BypassNames class and related Pandera schemas for handling hydropower bypass data.
Includes attribute and metadata schemas.
HydroBypassMetadataSchema
Bases: _AttributeMetadataSchema
Pandera DataFrameModel schema for metadata in the Hydropower.Bypass file.
Source code in framdata/database_names/HydroBypassNames.py
145 146 147 148 |
|
HydroBypassNames
Bases: _BaseComponentsNames
Define naming conventions and attribute object creation for HydroBypass object, which is an attribute of the HydroModule.
Provides methods for creating generator components, retrieving Pandera schemas for attribute and metadata tables, and formatting validation errors specific to generator schemas.
Source code in framdata/database_names/HydroBypassNames.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> dict[str, HydroBypass]
staticmethod
Create a HydroBypass object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one HydroModule object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
set[str]
|
Set of columns used to tag object with memberships. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]]
|
NOT USED, currently only used in HydroModulesNames. |
None
|
Returns:
Type | Description |
---|---|
dict[str, HydroBypass]
|
dict[str, HydroBypass]: A dictionary with the bypass ID as key and the module unit as value. |
Source code in framdata/database_names/HydroBypassNames.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
get_attribute_data_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for attribute data in the Hydropower.Bypass file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Bypass attribute data. |
Source code in framdata/database_names/HydroBypassNames.py
85 86 87 88 89 90 91 92 93 94 |
|
get_metadata_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for the metadata table in the Hydropower.Bypass file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Bypass metadata. |
Source code in framdata/database_names/HydroBypassNames.py
96 97 98 99 100 101 102 103 104 105 |
|
HydroBypassSchema
Bases: DataFrameModel
Pandera DataFrameModel schema for attribute data in the Hydropower.Bypass file.
Source code in framdata/database_names/HydroBypassNames.py
139 140 141 142 |
|
HydroGeneratorNames
Define the GeneratorNames class and related Pandera schemas for hydropower generator data.
Provides: - GeneratorNames: class for handling generator component names and schema validation. - GeneratorSchema: Pandera schema for generator attribute data. - GeneratorMetadataSchema: Pandera schema for generator metadata.
GeneratorMetadataSchema
Bases: _AttributeMetadataSchema
Pandera DataFrameModel schema for metadata in the Hydropower.Generators file.
Source code in framdata/database_names/HydroGeneratorNames.py
158 159 160 161 |
|
GeneratorSchema
Bases: DataFrameModel
Pandera DataFrameModel schema for attribute data in the Hydropower.Generators file.
Source code in framdata/database_names/HydroGeneratorNames.py
152 153 154 155 |
|
HydroGeneratorNames
Bases: _BaseComponentsNames
Handles generator component names and schema validation for hydropower generator data.
Provides methods for creating generator components, retrieving Pandera schemas for attribute and metadata tables, and formatting validation errors specific to generator schemas.
Source code in framdata/database_names/HydroGeneratorNames.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> dict[str, tuple[HydroGenerator, dict[str, Meta]]]
staticmethod
Create a hydro generator attribute object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one HydroModule object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
set[str]
|
Set of columns used to tag object with memberships. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]]
|
NOT USED, currently only used in HydroModulesNames. |
None
|
Returns:
Type | Description |
---|---|
dict[str, tuple[HydroGenerator, dict[str, Meta]]]
|
dict[str, dict[str, Meta]]: A dictionary with the generator ID as key and the attribute object and metadata as value. |
Source code in framdata/database_names/HydroGeneratorNames.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
get_attribute_data_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for attribute data in the Hydropower.Generators file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Generator attribute data. |
Source code in framdata/database_names/HydroGeneratorNames.py
98 99 100 101 102 103 104 105 106 107 |
|
get_metadata_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for the metadata table in the Hydropower.Generators file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Generator metadata. |
Source code in framdata/database_names/HydroGeneratorNames.py
109 110 111 112 113 114 115 116 117 118 |
|
HydroInflowNames
Define the InflowNames class and related Pandera schemas for handling hydropower inflow data.
Includes attribute and metadata schemas.
HydroInflowNames
Bases: _BaseComponentsNames
Convert hydropower inflow data to attribute objects for HydroModules. Handle attribute and metadata schema validation.
Source code in framdata/database_names/HydroInflowNames.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> dict[str, AvgFlowVolume]
staticmethod
Create a hydro inflow component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one HydroModule object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
set[str]
|
Set of columns used to tag object with memberships. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]]
|
NOT USED, currently only used in HydroModulesNames. |
None
|
Returns:
Type | Description |
---|---|
dict[str, AvgFlowVolume]
|
dict[str, Component]: A dictionary with the inflow ID as key and the module unit as value. |
Source code in framdata/database_names/HydroInflowNames.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
get_attribute_data_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for attribute data in the Hydropower.Inflow file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Inflow attribute data. |
Source code in framdata/database_names/HydroInflowNames.py
78 79 80 81 82 83 84 85 86 87 |
|
get_metadata_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for the metadata table in the Hydropower.Inflow file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Inflow metadata. |
Source code in framdata/database_names/HydroInflowNames.py
89 90 91 92 93 94 95 96 97 98 |
|
InflowMetadataSchema
Bases: _AttributeMetadataSchema
Pandera DataFrameModel schema for metadata in the Hydropower.Inflow file.
Source code in framdata/database_names/HydroInflowNames.py
138 139 140 141 |
|
InflowSchema
Bases: DataFrameModel
Pandera DataFrameModel schema for attribute data in the Hydropower.Inflow file.
Source code in framdata/database_names/HydroInflowNames.py
132 133 134 135 |
|
HydroModulesNames
Defines schema, names, and component creation logic for hydropower modules.
This module provides: - HydroModulesNames: class for column names and component creation for hydropower modules. - HydroModuleSchema: Pandera schema for attribute data. - HydroModuleMetadataSchema: Pandera schema for metadata.
HydroModuleMetadataSchema
Bases: _AttributeMetadataSchema
Pandera DataFrameModel schema for metadata in the Hydropower.Modules file.
Source code in framdata/database_names/HydroModulesNames.py
239 240 241 242 |
|
HydroModuleSchema
Bases: DataFrameModel
Pandera DataFrameModel schema for attribute data in the Hydropower.Modules file.
Source code in framdata/database_names/HydroModulesNames.py
233 234 235 236 |
|
HydroModulesNames
Bases: _BaseComponentsNames
Provides column names, schema accessors, and component creation logic for hydropower modules.
This class defines constants for column names, methods for creating HydroModule components from data rows, and accessors for Pandera schemas used for validation of attribute and metadata tables.
Source code in framdata/database_names/HydroModulesNames.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> dict[str, Component]
staticmethod
Create a hydro module component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one HydroModule object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
set[str]
|
Set of columns used to tag object with memberships. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]]
|
Dictionary of attributes to link to the HydroModule. |
None
|
Returns:
Type | Description |
---|---|
dict[str, Component]
|
dict[str, Component]: A dictionary with the module_id as key and the module unit as value. |
Source code in framdata/database_names/HydroModulesNames.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
get_attribute_data_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for attribute data in the Hydropower.Modules file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the HydroModule attribute data. |
Source code in framdata/database_names/HydroModulesNames.py
179 180 181 182 183 184 185 186 187 188 |
|
get_metadata_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for the metadata table in the Hydropower.Modules file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the HydroModule metadata. |
Source code in framdata/database_names/HydroModulesNames.py
190 191 192 193 194 195 196 197 198 199 |
|
HydroPumpNames
Define the PumpNames class and related Pandera schemas for handling hydropower pump data.
Includes attribute and metadata validation for the Hydropower.Pumps file.
HydroPumpNames
Bases: _BaseComponentsNames
Handle naming conventions, schema definitions, and component creation for hydropower pump data.
Source code in framdata/database_names/HydroPumpNames.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> dict[str, HydroPump]
staticmethod
Create a HydroPump object from a row in the Hydropower.Pumps table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one HydroModule object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
set[str]
|
Set of columns used to tag object with memberships. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]]
|
NOT USED, currently only used in HydroModulesNames. |
None
|
Returns:
Type | Description |
---|---|
dict[str, HydroPump]
|
dict[str, HydroPump]: A dictionary with the pump ID as key and the module unit as value. |
Source code in framdata/database_names/HydroPumpNames.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
get_attribute_data_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for attribute data in the Hydropower.Pumps file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Pump attribute data. |
Source code in framdata/database_names/HydroPumpNames.py
113 114 115 116 117 118 119 120 121 122 |
|
get_metadata_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for the metadata table in the Hydropower.Pumps file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Pump metadata. |
Source code in framdata/database_names/HydroPumpNames.py
124 125 126 127 128 129 130 131 132 133 |
|
PumpMetadataSchema
Bases: _AttributeMetadataSchema
Pandera DataFrameModel schema for metadata in the Hydropower.Pumps file.
Source code in framdata/database_names/HydroPumpNames.py
173 174 175 176 |
|
PumpSchema
Bases: DataFrameModel
Pandera DataFrameModel schema for attribute data in the Hydropower.Pumps file.
Source code in framdata/database_names/HydroPumpNames.py
167 168 169 170 |
|
HydroReservoirNames
Module for handling reservoir names and schemas in hydropower data.
This module defines the ReservoirNames class for managing reservoir attributes, and provides Pandera schemas for validating reservoir attribute and metadata tables.
HydroReservoirMetadataSchema
Bases: _AttributeMetadataSchema
Pandera DataFrameModel schema for metadata in the Hydropower.Reservoirs file.
Source code in framdata/database_names/HydroReservoirNames.py
168 169 170 171 |
|
HydroReservoirNames
Bases: _BaseComponentsNames
Class for managing reservoir attribute names and providing methods for schema validation and component creation.
This class defines column names for reservoir attributes, methods for creating HydroReservoir components, and functions to retrieve Pandera schemas for validating reservoir attribute and metadata tables.
Source code in framdata/database_names/HydroReservoirNames.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> dict[str, HydroReservoir]
staticmethod
Create a HydroReservoir object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one HydroModule object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
set[str]
|
Set of columns used to tag object with memberships. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]]
|
NOT USED, currently only used in HydroModulesNames. |
None
|
Returns:
Type | Description |
---|---|
dict[str, HydroReservoir]
|
dict[str, HydroReservoir]: A dictionary with the inflow ID as key and the module unit as value. |
Source code in framdata/database_names/HydroReservoirNames.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
get_attribute_data_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for attribute data in the Hydropower.Reservoirs file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Reservoir attribute data. |
Source code in framdata/database_names/HydroReservoirNames.py
108 109 110 111 112 113 114 115 116 117 |
|
get_metadata_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for the metadata table in the Hydropower.Reservoirs file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Reservoir metadata. |
Source code in framdata/database_names/HydroReservoirNames.py
119 120 121 122 123 124 125 126 127 128 |
|
HydroReservoirSchema
Bases: DataFrameModel
Pandera DataFrameModel schema for attribute data in the Hydropower.Reservoirs file.
Source code in framdata/database_names/HydroReservoirNames.py
162 163 164 165 |
|
ThermalNames
Classes defining Thermal tables.
ThermalMetadataSchema
Bases: _AttributeMetadataSchema
Pandera DataFrameModel schema for metadata in the Thermal.Generators file.
Source code in framdata/database_names/ThermalNames.py
228 229 230 231 |
|
ThermalNames
Bases: _BaseComponentsNames
Container class for describing the Thermal attribute table's names and structure.
Source code in framdata/database_names/ThermalNames.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> dict[str, Thermal]
staticmethod
Create a thermal unit component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one Thermal object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
set[str]
|
Set of columns used to tag object with memberships. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]]
|
NOT USED |
None
|
Returns:
Type | Description |
---|---|
dict[str, Thermal]
|
dict[str, Thermal]: A dictionary with the thermal_id as key and the thermal unit as value. |
Source code in framdata/database_names/ThermalNames.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
get_attribute_data_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for attribute data in the Thermal.Generators file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for Thermal attribute data. |
Source code in framdata/database_names/ThermalNames.py
168 169 170 171 172 173 174 175 176 177 |
|
get_metadata_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for the metadata table in the Thermal.Generators file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Thermal metadata. |
Source code in framdata/database_names/ThermalNames.py
179 180 181 182 183 184 185 186 187 188 |
|
ThermalSchema
Bases: DataFrameModel
Pandera DataFrameModel schema for attribute data in the Thermal.Generators file.
Source code in framdata/database_names/ThermalNames.py
222 223 224 225 |
|
TimeVectorMetadataNames
Contains names of fields in time vector metadata.
TimeVectorMetadataNames
Denote available fields in time vector metadata, and provide functionality for time vector metadata processing.
The processing is concerned with casting the metadata fields to correct types and decoding the fields and/or values if they are stored as bytes.
Source code in framdata/database_names/TimeVectorMetadataNames.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
cast_meta(raw_meta: dict[str | bytes, str | bytes | int | bool | None]) -> tuple[dict[str, str, bool | int | str | datetime | timedelta | tzinfo | None], set[str]]
staticmethod
Decode possible binary keys and values and cast values of metadata dict to their defined types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raw_meta
|
dict[str | bytes, str | bytes | int | bool | None]
|
Dictionary to decode and cast. |
required |
Returns:
Type | Description |
---|---|
tuple[dict[str, str, bool | int | str | datetime | timedelta | tzinfo | None], set[str]]
|
tuple[dict[str, Any], set[str]]: Decoded and cast dictionary, set of missing keys. |
Source code in framdata/database_names/TimeVectorMetadataNames.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
cast_value(value: str | bytes | None, cast_function: Callable | type) -> object | None
staticmethod
Cast a string value into new type, but always return None if value is None or "None".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str | None
|
A string value or None. |
required |
cast_function
|
Union[Callable, type]
|
Function or type with which to cast the value into. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If anything goes wrong in the cast_function. |
Returns:
Type | Description |
---|---|
object | None
|
object|None: Value as new type or None. |
Source code in framdata/database_names/TimeVectorMetadataNames.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
TransmissionNames
Defines the TransmissionNames class and related Pandera schemas.
These describe validate Transmission attributes and metadata tables in the energy model database.
TransmissionMetadataSchema
Bases: _AttributeMetadataSchema
Pandera DataFrameModel schema for metadata in the Transmission.Grid file.
Source code in framdata/database_names/TransmissionNames.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
|
check_unit_is_str_for_attributes(df: pd.DataFrame) -> Series[bool]
classmethod
Check that the 'unit' value is a string for the rows where 'attribute' is 'Capacity' and 'Loss'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
Dataframe
|
DataFrame used to check value for "unit". |
required |
Returns:
Type | Description |
---|---|
Series[bool]
|
Series[bool]: Series of boolean values detonating if each element has passed the check. |
Source code in framdata/database_names/TransmissionNames.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
|
TransmissionNames
Bases: _BaseComponentsNames
Container class for describing the Transmission attribute table's names and structure.
Source code in framdata/database_names/TransmissionNames.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> dict[str, Transmission]
staticmethod
Create a transmission unit component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one Transmission object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
set[str]
|
Set of columns used to tag object with memberships. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]] | None
|
NOT USED |
None
|
Returns:
Type | Description |
---|---|
dict[str, Transmission]
|
dict[str, Transmission]: A dictionary with the transmission_id as key and the transmission unit as value. |
Source code in framdata/database_names/TransmissionNames.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
get_attribute_data_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for attribute data in the Transmission.Grid file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for Transmission attribute data. |
Source code in framdata/database_names/TransmissionNames.py
133 134 135 136 137 138 139 140 141 142 |
|
get_metadata_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for the metadata table in the Transmission.Grid file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Transmission metadata. |
Source code in framdata/database_names/TransmissionNames.py
144 145 146 147 148 149 150 151 152 153 |
|
TransmissionSchema
Bases: DataFrameModel
Pandera DataFrameModel schema for attribute data in the Transmission.Grid file.
Source code in framdata/database_names/TransmissionNames.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
Config
Schema-wide configuration for the DemandSchema class.
Source code in framdata/database_names/TransmissionNames.py
264 265 266 267 |
|
check_internal_line_error(dataframe: pd.DataFrame) -> Series[bool]
classmethod
Raise warning if origin node is the same as destination node, in which case we have an internal line.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataframe
|
DataFrame
|
DataFrame to check. |
required |
Returns:
Type | Description |
---|---|
Series[bool]
|
Series[bool]: Series of boolean values denoting if each element has passed the check. |
Source code in framdata/database_names/TransmissionNames.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
dtype_str_int_float(series: Series[Any]) -> Series[bool]
classmethod
Check if values in the series are of datatype: str, int or float.
Source code in framdata/database_names/TransmissionNames.py
218 219 220 221 222 |
|
dtype_str_int_float_none(series: Series[Any]) -> Series[bool]
classmethod
Check if values in the series are of datatype: str, int, float or None.
Source code in framdata/database_names/TransmissionNames.py
224 225 226 227 228 229 230 231 232 233 234 235 |
|
numeric_values_are_between_or_equal_to_0_and_1(series: Series[Any]) -> Series[bool]
classmethod
Check if numeric values in the series are between zero and one or equal to zero and one.
Source code in framdata/database_names/TransmissionNames.py
243 244 245 246 247 |
|
numeric_values_greater_than_or_equal_to_0(series: Series[Any]) -> Series[bool]
classmethod
Check if numeric values in the series are greater than or equal to zero.
Source code in framdata/database_names/TransmissionNames.py
237 238 239 240 241 |
|
WindSolarNames
Classes defining Wind and Solar tables and how to create Components from them.
SolarNames
Bases: WindSolarNames
Class representing the names and structure of Solar tables, and method for creating Solar Component objects.
Source code in framdata/database_names/WindSolarNames.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> dict[str, Solar]
staticmethod
Create a Solar Component from a row in the Solar.Generators table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one solar object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
set[str]
|
Set of columns used to tag object with memberships. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]] | None
|
NOT USED |
None
|
Returns:
Type | Description |
---|---|
dict[str, Solar]
|
dict[str, Solar]: A dictionary with the id as key and the solar unit as value. |
Source code in framdata/database_names/WindSolarNames.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
WindNames
Bases: WindSolarNames
Class representing the names and structure of Wind tables, and method for creating Wind Component objects.
Source code in framdata/database_names/WindSolarNames.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> dict[str, Wind]
staticmethod
Create a Wind Component from a row in the Wind.Generators table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one Wind object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
set[str]
|
Set of columns used to tag object with memberships. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]] | None
|
NOT USED |
None
|
Returns:
Type | Description |
---|---|
dict[str, Wind]
|
dict[str, Wind]: A dictionary with the wind_id as key and the wind unit as value. |
Source code in framdata/database_names/WindSolarNames.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
WindSolarMetadataSchema
Bases: _AttributeMetadataSchema
Standard Pandera DataFrameModel schema for metadata in the Wind and Solar files.
Source code in framdata/database_names/WindSolarNames.py
98 99 100 101 |
|
WindSolarNames
Bases: _BaseComponentsNames
Class representing the names and structure of Wind and Solar tables.
Source code in framdata/database_names/WindSolarNames.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
get_attribute_data_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for attribute data in a Wind and Solar file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for Wind and Solar attribute data. |
Source code in framdata/database_names/WindSolarNames.py
38 39 40 41 42 43 44 45 46 47 |
|
get_metadata_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for the metadata table in a Wind and Solar file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Thermal metadata. |
Source code in framdata/database_names/WindSolarNames.py
49 50 51 52 53 54 55 56 57 58 |
|
WindSolarSchema
Bases: DataFrameModel
Standard Pandera DataFrameModel schema for attribute data in the Wind and Solar files.
Source code in framdata/database_names/WindSolarNames.py
92 93 94 95 |
|
YamlNames
Define names and fields used in yaml files.
YamlNames
Contain names in yaml files.
Source code in framdata/database_names/YamlNames.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
nodes_names
Define class for handling tables with Nodes.
EmissionNodesNames
Bases: NodesNames
Class representing the names and structure of emission nodes tables.
Source code in framdata/database_names/nodes_names.py
155 156 157 158 159 160 |
|
FuelNodesNames
Bases: NodesNames
Class representing the names and structure of fuel nodes tables.
Source code in framdata/database_names/nodes_names.py
146 147 148 149 150 151 152 |
|
NodesMetadataSchema
Bases: _AttributeMetadataSchema
Standard Pandera DataFrameModel schema for metadata in the Nodes files.
Source code in framdata/database_names/nodes_names.py
134 135 136 137 |
|
NodesNames
Bases: _BaseComponentsNames
Class representing the names and structure of nodes tables, and the convertion of the table to Node objects.
Source code in framdata/database_names/nodes_names.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
create_component(row: NDArray, indices: dict[str, int], meta_columns: set[str], meta_data: pd.DataFrame, attribute_objects: dict[str, tuple[object, dict[str, Meta]]] | None = None) -> tuple[dict[str, Node], list[str]]
staticmethod
Create a node object from direct parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row
|
NDArray
|
Array containing the values of one table row, represeting one Node object. |
required |
indices
|
list[str, int]
|
Mapping of table's Column names to the array's indices. |
required |
meta_columns
|
list[str]
|
Set of columns which defines memberships in meta groups for aggregation. |
required |
meta_data
|
DataFrame
|
Dictionary containing at least unit of every column. |
required |
attribute_objects
|
dict[str, tuple[object, dict[str, Meta]]]
|
NOT USED |
None
|
Returns:
Type | Description |
---|---|
tuple[dict[str, Node], list[str]]
|
dict[str, Node]: Dictionary of node id and the Node object. |
Source code in framdata/database_names/nodes_names.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
get_attribute_data_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for attribute data in a Nodes file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for Nodes attribute data. |
Source code in framdata/database_names/nodes_names.py
74 75 76 77 78 79 80 81 82 83 |
|
get_metadata_schema() -> pa.DataFrameModel
staticmethod
Get the Pandera DataFrameModel schema for the metadata table in a Nodes file.
Returns:
Type | Description |
---|---|
DataFrameModel
|
pa.DataFrameModel: Pandera DataFrameModel schema for the Thermal metadata. |
Source code in framdata/database_names/nodes_names.py
85 86 87 88 89 90 91 92 93 94 |
|
NodesSchema
Bases: DataFrameModel
Standard Pandera DataFrameModel schema for attribute data in the Nodes files.
Source code in framdata/database_names/nodes_names.py
128 129 130 131 |
|
PowerNodesNames
Bases: NodesNames
Class representing the names and structure of power nodes tables.
Source code in framdata/database_names/nodes_names.py
140 141 142 143 |
|
validation_functions
Module containing registered custom check functions used by Pandera schema classes.
check_unit_is_str_for_attributes(df: pd.DataFrame, attribute_names: list[str]) -> Series[bool]
Check if 'Unit' column values are strings for the rows where the 'Attribute' column matches specific attributes.
This function checks whether the values in the 'Unit' column are strings for rows where the 'Attribute' column matches any of the specified attribute names. Rows that do not match the specified attributes are considered valid by default. This function is commonly used by subclasses of 'AttributeMetadataSchema' to validate that a unit is given for certain attributes in the metadata belonging to a Component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
The DataFrame containing the columns to validate. |
required |
attribute_names
|
list[str]
|
A list with the names of the attributes to check in the 'Attribute' column. |
required |
Returns:
Type | Description |
---|---|
Series[bool]
|
Series[bool]: A boolean Series indicating whether each row passes the validation. Rows where the 'Attribute' |
Series[bool]
|
column does not match the specified attribute are automatically marked as valid. |
Example
Given the following DataFrame:
attribute | unit |
---|---|
Volume | MWh |
Temperature | None |
Capacity | None |
And attribute_names = ["Volume", "Capacity"]
, the method will validate that the 'Unit' column contains strings
for rows where 'attribute' is "Volume" and "Capacity". The resulting Series will be:
validation_result |
---|
True |
True |
False |
Source code in framdata/database_names/validation_functions.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
dtype_str_int_float(series: Series[Any]) -> Series[bool]
Check if the series contains only str, int or float values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
series
|
Series[Any]
|
Series to check. |
required |
Returns:
Type | Description |
---|---|
Series[bool]
|
Series[bool]: Series of boolean values detonating if each element has passed the check. |
Source code in framdata/database_names/validation_functions.py
40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
dtype_str_int_float_none(series: Series[Any]) -> Series[bool]
Check if the series contains only str, int, float or None values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
series
|
Series[Any]
|
Series to check. |
required |
Returns:
Type | Description |
---|---|
Series[bool]
|
Series[bool]: Series of boolean values detonating if each element has passed the check. |
Source code in framdata/database_names/validation_functions.py
55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
numeric_values_are_between_or_equal_to(series: Series[Any], min_value: int | float, max_value: int | float) -> Series[bool]
Check if values are between or equal to a min and max value if they are of type int or float.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
series
|
Series[Any]
|
Series to check. |
required |
min_value
|
int | float
|
Value that the elements in the series should be greater than or equal. |
required |
max_value
|
int | float
|
Value that the elements in the series should be less than or equal. |
required |
Returns:
Type | Description |
---|---|
Series[bool]
|
Series[bool]: Series of boolean values detonating if each element has passed the check. |
Source code in framdata/database_names/validation_functions.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
numeric_values_greater_than_or_equal_to(series: Series[Any], min_value: int | float) -> Series[bool]
Check if values are greater than or equal to min_value if they are of type int or float.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
series
|
Series[Any]
|
Series to check. |
required |
min_value
|
int | float
|
Value that the elements in the series should be greater than or equal. |
required |
Returns:
Type | Description |
---|---|
Series[bool]
|
Series[bool]: Series of boolean values detonating if each element has passed the check. |
Source code in framdata/database_names/validation_functions.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
numeric_values_less_than_or_equal_to(series: Series[Any], max_value: int | float) -> Series[bool]
Check if values are less than or equal to max_value if they are of type int or float.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
series
|
Series[Any]
|
Series to check. |
required |
max_value
|
int | float
|
Value that the elements in the series should be greater than or equal. |
required |
Returns:
Type | Description |
---|---|
Series[bool]
|
Series[bool]: Series of boolean values detonating if each element has passed the check. |
Source code in framdata/database_names/validation_functions.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
file_editors
NVEFileEditor
Contain class with common functionality for editing files.
NVEFileEditor
Bases: Base
Parent class with common functionality for classes concerned with editing FRAM files.
Source code in framdata/file_editors/NVEFileEditor.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
__init__(source: Path | str | None = None) -> None
Set path to parquet file if supplied, load/initialize table and metadata as pd.DataFrame and dictionary respectively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str | None
|
Path to parquet file with timevectors. Defaults to None. |
None
|
Source code in framdata/file_editors/NVEFileEditor.py
11 12 13 14 15 16 17 18 19 20 21 22 |
|
get_source() -> Path
Get the source file path of the editor.
Source code in framdata/file_editors/NVEFileEditor.py
24 25 26 |
|
set_source(source: Path) -> None
Set the source file path of the editor.
Source code in framdata/file_editors/NVEFileEditor.py
28 29 30 31 |
|
NVEH5TimeVectorEditor
Contains class for editing time vectors in H5 files.
NVEH5TimeVectorEditor
Bases: NVEFileEditor
Class with functionality concerned with editing time vectors and their metadata in H5 files.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
__init__(source: Path | str | None = None) -> None
Set path to parquet file if supplied, load/initialize table and metadata as pd.DataFrame and dictionary respectively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str | None
|
Path to parquet file with timevectors. Defaults to None. |
None
|
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
get_common_index() -> NDArray | None
Return a copy of a given index as a pandas series from the table.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
82 83 84 |
|
get_common_metadata() -> None | dict
Get a copy of the metadata of the parquet file.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
54 55 56 |
|
get_index(vector_id: str) -> NDArray
Return a copy of a given index as a pandas series from the table.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
69 70 71 72 73 74 75 |
|
get_metadata(vector_id: str) -> None | dict
Get a copy of the metadata of the parquet file.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
40 41 42 43 44 45 46 |
|
get_vector(vector_id: str) -> NDArray
Return a copy of a given vector as a pandas series from the table.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
92 93 94 95 96 97 98 |
|
get_vector_ids() -> list[str]
Get the IDs of all vectors.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
100 101 102 |
|
set_common_index(values: NDArray) -> None
Set a whole index in the time index table.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
77 78 79 80 |
|
set_common_metadata(value: dict[str, METADATA_TYPES]) -> None
Set a field (new or overwrite) in the metadata.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
58 59 60 61 |
|
set_index(vector_id: str, index: NDArray) -> None
Set a whole index in the time index table.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
63 64 65 66 67 |
|
set_metadata(vector_id: str, value: dict[str, METADATA_TYPES]) -> None
Set a field (new or overwrite) in the metadata.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
48 49 50 51 52 |
|
set_vector(vector_id: str, values: NDArray) -> None
Set a whole vector in the time vector table.
Source code in framdata/file_editors/NVEH5TimeVectorEditor.py
86 87 88 89 90 |
|
NVEParquetTimeVectorEditor
Contains class for editing time vectors in parquet files.
NVEParquetTimeVectorEditor
Bases: NVEFileEditor
Class for managing time vectors and their metadata stored in parquet files.
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
__init__(source: Path | str | None = None) -> None
Set path to parquet file if supplied, load/initialize table and metadata as pd.DataFrame and dictionary respectively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str | None
|
Path to parquet file with timevectors. Defaults to None. |
None
|
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
17 18 19 20 21 22 23 24 25 26 27 |
|
get_dataframe() -> pd.DataFrame
Return a copy of all of the vector table as a pandas dataframe.
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
74 75 76 |
|
get_index_column() -> pd.Series
Get the datetime column of the dataframe.
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
95 96 97 98 99 100 |
|
get_metadata()
Get a copy of the metadata of the parquet file.
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
47 48 49 |
|
get_vector(vector_id: str) -> pd.Series
Return a copy of a given vector as a pandas series from the table.
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
66 67 68 69 70 71 72 |
|
get_vector_ids() -> list[str]
Get the IDs of all vectors.
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
83 84 85 |
|
save_to_parquet(path: Path | str) -> None
Save the edited dataframe and metadata to parquet file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to save tha file to. Must be defined to force user to explicitly overwrite the original file if they want. |
required |
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
set_dataframe(dataframe: pd.DataFrame) -> None
Set the dataframe of the editor.
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
78 79 80 81 |
|
set_index_column(index: pd.Series) -> None
Set the index column.
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
87 88 89 90 91 92 93 |
|
set_metadata(key: str, value: bool | int | str | datetime | timedelta | tzinfo | None) -> None
Set a field (new or overwrite) in the metadata.
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
51 52 53 54 55 |
|
set_vector(vector_id: str, values: pd.Series) -> None
Set a whole vector in the time vector table.
Source code in framdata/file_editors/NVEParquetTimeVectorEditor.py
57 58 59 60 61 62 63 64 |
|
loaders
NVEExcelTimeVectorLoader
Bases: NVETimeVectorLoader
Class for loading time vector data from NVE excel file sources.
Meant for short time vectors (e.g. yearly volumes or installed capacities) which are desireable to view and edit easily through Excel. Supports the followinf formats: - 'Horizontal': One column containing IDs, the other column names represents the index. Vector values as rows - 'Vertical': One column as index (DateTime), the oher columns names are vector IDs. Vectors as column values.
Source code in framdata/loaders/time_vector_loaders.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
__init__(source: Path | str, require_whole_years: bool, relative_loc: Path | str | None = None, validate: bool = True) -> None
Intitialize loader instance and connect it to an Excel file containing time vector data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str
|
Absolute Path to database or excel file. |
required |
require_whole_years
|
bool
|
Flag for validating that the time vectors in the source contain data for complete years. |
required |
relative_loc
|
Path | str | None
|
Path to excel file relative to source. Defaults to None. |
None
|
validate
|
bool
|
Flag to turn on validation of timevectors. NB! Loads all data into memory at once. Defaults to True. |
True
|
Source code in framdata/loaders/time_vector_loaders.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
clear_cache() -> None
Clear cached data.
Source code in framdata/loaders/time_vector_loaders.py
255 256 257 258 259 |
|
get_index(vector_id: str) -> ListTimeIndex
Get the TimeIndex describing the time dimension of the vectors in the file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used since all vectors in the NVE excel files have the same index. |
required |
Returns:
Name | Type | Description |
---|---|---|
TimeIndex |
ListTimeIndex
|
TimeIndex object describing the excel file's index. |
Source code in framdata/loaders/time_vector_loaders.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
get_metadata(vector_id: str) -> dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
Read Excel file metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If an expected metadata key is missing. |
Returns:
Type | Description |
---|---|
dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
|
dict[str, bool|int|str|datetime|timedelta|tzinfo|None]: Metadata dictionary. |
Source code in framdata/loaders/time_vector_loaders.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
get_unit(vector_id: str) -> str
Get the unit of the given time vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
ID of a time vector. Not used since all time vectors in the NVE excel files have the same unit. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Unit of the time vector. |
Source code in framdata/loaders/time_vector_loaders.py
62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
get_values(vector_id: str) -> NDArray
Get numpy array with all the values of a given vector in the Loader's excel file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Unique id of the vector in the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Numpy array with values. |
Source code in framdata/loaders/time_vector_loaders.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
NVEH5TimeVectorLoader
Bases: NVETimeVectorLoader
Class for loading time vector data from NVE HDF5 file sources.
Meant for large time vectors (e.g. hourly data over multiple years). Supports differing lengths and metadata of vectors stored in the file.
Specialized to the following format
- index (h5py.Group, optional): Used to define indexes for vectors if index is supposed to only apply to that vector.
- common_index (h5py.Dataset): Contains one numpy array for all vectors. This is a fallback index for vectors which have not defined their own index in the index group. Also used on purpose if many or all vectors have the same index.
- metadata (h5py.Group): Used connect a specific set of metadata to a particular vector.
- common_metadata (h5py.Group): Contains one set of metadata fields for all vectors. Used in a similar way as common_index.
- vectors (h5py.Group): Contains numpy arrays containing the vector values connected to a unique ID. The same ID is used to connect the vector to an index or metadata.
Source code in framdata/loaders/time_vector_loaders.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
|
__init__(source: Path | str, require_whole_years: bool, relative_loc: Path | str | None = None, validate: bool = True) -> None
Intitialize loader instance and connect it to a H5 file containing time vector data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str
|
Absolute Path to database or HDF5 file. |
required |
require_whole_years
|
bool
|
Flag for validating that the time vectors in the source contain data for complete years. |
required |
relative_loc
|
Path | str | None
|
Path to HDF5 file relative to source. Defaults to None. |
None
|
validate
|
bool
|
Whether to validate vectors after loading. NB! Loads all data into memory at once. Defaults to True. |
True
|
Source code in framdata/loaders/time_vector_loaders.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
|
clear_cache() -> None
Clear cached data.
Source code in framdata/loaders/time_vector_loaders.py
440 441 442 443 444 |
|
get_index(vector_id: str) -> TimeIndex
Get the TimeIndex describing the time dimension of the vectors in the file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used since all vectors in the NVE parquet files have the same index. |
required |
Returns:
Name | Type | Description |
---|---|---|
TimeIndex |
TimeIndex
|
TimeIndex object describing the parquet file's index. |
Source code in framdata/loaders/time_vector_loaders.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
|
get_metadata(vector_id: str) -> dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
Retrieve and decodes custom metadata from parquet file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If any of the expected metadata keys is not found in file. |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
|
Dictionary with decoded metadata. |
Source code in framdata/loaders/time_vector_loaders.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
get_values(vector_id: str) -> NDArray
Get numpy array with all the values of a given vector in the Loader's HDF5 file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Unique id of the vector in the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Numpy array with values. |
Source code in framdata/loaders/time_vector_loaders.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
NVEParquetTimeVectorLoader
Bases: NVETimeVectorLoader
Class for loading time vector data from NVE parquet file sources.
Meant for large time vectors. All vectors in the file must have the same lenghts and metadata. Supports format: - 'Vertical' with one index collumn (DateTime) and the others containing vector values.
Source code in framdata/loaders/time_vector_loaders.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 |
|
__init__(source: Path | str, require_whole_years: bool, relative_loc: Path | str | None = None, validate: bool = True) -> None
Intitialize loader instance and connect it to an Parquet file containing time vector data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str
|
Absolute Path to database or parquet file. |
required |
require_whole_years
|
bool
|
Flag for validating that the time vectors in the source contain data for complete years. |
required |
relative_loc
|
Path | str | None
|
Path to parquet file relative to source. Defaults to None. |
None
|
validate
|
bool
|
Flag to turn on validation of timevectors. NB! Loads all data into memory at once. Defaults to True. |
True
|
Source code in framdata/loaders/time_vector_loaders.py
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
|
clear_cache() -> None
Clear cached data.
Source code in framdata/loaders/time_vector_loaders.py
726 727 728 729 730 |
|
get_index(vector_id: str) -> TimeIndex
Get the TimeIndex describing the time dimension of the vectors in the file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used since all vectors in the NVE parquet files have the same index. |
required |
Returns:
Name | Type | Description |
---|---|---|
TimeIndex |
TimeIndex
|
TimeIndex object describing the parquet file's index. |
Source code in framdata/loaders/time_vector_loaders.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 |
|
get_metadata(vector_id: str) -> dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
Retrieve and decodes custom metadata from parquet file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If any of the expected metadata keys is not found in file. |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
|
Dictionary with decoded metadata. |
Source code in framdata/loaders/time_vector_loaders.py
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 |
|
get_values(vector_id: str) -> NDArray
Get numpy array with all the values of a given vector in the Loader's parquet file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Unique id of the vector in the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Numpy array with values. |
Source code in framdata/loaders/time_vector_loaders.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
|
NVEYamlTimeVectoroader
Bases: NVETimeVectorLoader
Class for loading time vector data from NVE YAML file sources.
Meant for very sparse time vector data, where the vectors have varying lengths and indexes. Currently all vectors must have the same metadata within each file. Supported format: - Metadata: field containing dictionary with metadata for all vectors. - Other fields are vector IDs with lists for x and y axes.
Source code in framdata/loaders/time_vector_loaders.py
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
|
__init__(source: Path | str, require_whole_years: bool, relative_loc: Path | str | None = None, validate: bool = True) -> None
Intitialize loader instance and connect it to an Yaml file containing time vector data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str
|
Absolute Path to database or excel file. |
required |
require_whole_years
|
bool
|
Flag for validating that the time vectors in the source contain data for complete years. |
required |
relative_loc
|
Path | str | None
|
Path to excel file relative to source. Defaults to None. |
None
|
validate
|
bool
|
Flag to turn on validation of timevectors. NB! Loads all data into memory at once. Defaults to True. |
True
|
Source code in framdata/loaders/time_vector_loaders.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
|
clear_cache() -> None
Clear cached data.
Source code in framdata/loaders/time_vector_loaders.py
589 590 591 592 593 594 595 596 597 |
|
get_index(vector_id: str) -> TimeIndex
Get index of vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Unique id of the curve in the Loader source. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
TimeIndex
|
Numpy array with index of vector. |
Source code in framdata/loaders/time_vector_loaders.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
|
get_metadata(vector_id: str) -> dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
Read YAML file metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If an expected metadata key is missing. |
Returns:
Type | Description |
---|---|
dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
|
dict[str, bool|int|str|datetime|timedelta|tzinfo|None]: Metadata dictionary. |
Source code in framdata/loaders/time_vector_loaders.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
|
get_values(vector_id: str) -> NDArray
Get values of vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Unique id of the curve in the Loader source. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Numpy array with values of vector. |
Source code in framdata/loaders/time_vector_loaders.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
|
NVETimeVectorLoader
Loader for NVE time vector data.
This module provides the NVETimeVectorLoader class, which extends FileLoader and TimeVectorLoader to handle metadata and validation for time vector data from NVE parquet files.
NVETimeVectorLoader
Bases: FileLoader
, TimeVectorLoader
Common interface for metadata in NVE TimeVectorLoaders.
Source code in framdata/loaders/NVETimeVectorLoader.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
__init__(source: Path | str, require_whole_years: bool, relative_loc: Path | str | None = None) -> None
Initialize NVETimeVectorLoader with source and optional relative location.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str
|
Path or string to the source file. |
required |
require_whole_years
|
bool
|
Flag for validating that the time vectors in the source contain data for complete years. |
required |
relative_loc
|
Path | str | None
|
Relative location, defaults to None. |
None
|
Source code in framdata/loaders/NVETimeVectorLoader.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
get_reference_period(vector_id: str) -> ReferencePeriod | None
Get Reference perod from metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If only one of start year or number of years are set in metadata. |
Returns:
Type | Description |
---|---|
ReferencePeriod | None
|
ReferencePeriod | None |
Source code in framdata/loaders/NVETimeVectorLoader.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
get_unit(vector_id: str) -> str
Get the unit of the given time vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
ID of a time vector. Not used since all time vectors in the NVE parquet files have the same unit. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Unit of the time vector. |
Source code in framdata/loaders/NVETimeVectorLoader.py
67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
is_max_level(vector_id: str) -> bool | None
Check if the time vector is classified as a max level vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
ID of the time vector. |
required |
Returns:
Type | Description |
---|---|
bool | None
|
bool | None: True if max level, False otherwise, or None if not specified. |
Source code in framdata/loaders/NVETimeVectorLoader.py
41 42 43 44 45 46 47 48 49 50 51 52 |
|
is_zero_one_profile(vector_id: str) -> bool | None
Check if the time vector is classified as a zero-one profile vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
ID of the time vector. |
required |
Returns:
Type | Description |
---|---|
bool | None
|
bool | None: True if zero-one profile, False otherwise, or None if not specified. |
Source code in framdata/loaders/NVETimeVectorLoader.py
54 55 56 57 58 59 60 61 62 63 64 65 |
|
validate_vectors() -> None
Validate data in all vectors contained in the Loader.
Conditions validated
- If vector contains negative values. (- If vector is a zero one profile and contains values outside the unit interval.) * not in use currently
Raises:
Type | Description |
---|---|
ValueError
|
When conditions are violated. |
Source code in framdata/loaders/NVETimeVectorLoader.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
curve_loaders
Contains class for loading Curve data from NVE yaml files.
NVEYamlCurveLoader
Bases: FileLoader
, CurveLoader
Handle reading of Curve data from a yaml File of NVE specific format.
Source code in framdata/loaders/curve_loaders.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
__init__(source: Path | str, relative_loc: Path | str | None = None) -> None
Handle reading of curves from a single yaml file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str
|
Absolute Path to database or yaml file path. |
required |
relative_loc
|
Optional[Union[Path, str]]
|
Path to yaml file relative to source. Defaults to None. |
None
|
Source code in framdata/loaders/curve_loaders.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
clear_cache() -> None
Clear cached data.
Source code in framdata/loaders/curve_loaders.py
132 133 134 135 136 137 138 139 |
|
get_metadata(content_id: str) -> dict
Retrieve metadata for the specified content ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content_id
|
str
|
Unique identifier for the content. |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
Metadata associated with the content. |
Source code in framdata/loaders/curve_loaders.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
get_x_axis(curve_id: str) -> NDArray
Get values of x axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
curve_id
|
str
|
Unique id of the curve in the Loader source. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Numpy array with values of x axis. |
Source code in framdata/loaders/curve_loaders.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
get_x_unit(curve_id: str) -> str
Get the unit of the x axis for the specified curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
curve_id
|
str
|
Unique id of the curve in the Loader source. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Unit of the x axis. |
Source code in framdata/loaders/curve_loaders.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
get_y_axis(curve_id: str) -> NDArray
Get values of y axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
curve_id
|
str
|
Unique id of the curve in the Loader source. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Numpy array with values of y axis. |
Source code in framdata/loaders/curve_loaders.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
get_y_unit(curve_id: str) -> str
Get the unit of the y axis for the specified curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
curve_id
|
str
|
Unique id of the curve in the Loader source. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Unit of the y axis. |
Source code in framdata/loaders/curve_loaders.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
time_vector_loaders
Contain classes for reading time vector data from various file types with formats specific to NVE.
This module provides
- NVEExcelTimeVectorLoader: Handle time vectors in excel files.
- NVEH5TimeVectorLoader: Handle time vectors in HDF5 files.
- NVEYamlTimeVectorLoader: Handle time vectors in Yaml files.
- NVEParquetTieVectorLoader: Handle time vectors in Parquet files.
NVEExcelTimeVectorLoader
Bases: NVETimeVectorLoader
Class for loading time vector data from NVE excel file sources.
Meant for short time vectors (e.g. yearly volumes or installed capacities) which are desireable to view and edit easily through Excel. Supports the followinf formats: - 'Horizontal': One column containing IDs, the other column names represents the index. Vector values as rows - 'Vertical': One column as index (DateTime), the oher columns names are vector IDs. Vectors as column values.
Source code in framdata/loaders/time_vector_loaders.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
__init__(source: Path | str, require_whole_years: bool, relative_loc: Path | str | None = None, validate: bool = True) -> None
Intitialize loader instance and connect it to an Excel file containing time vector data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str
|
Absolute Path to database or excel file. |
required |
require_whole_years
|
bool
|
Flag for validating that the time vectors in the source contain data for complete years. |
required |
relative_loc
|
Path | str | None
|
Path to excel file relative to source. Defaults to None. |
None
|
validate
|
bool
|
Flag to turn on validation of timevectors. NB! Loads all data into memory at once. Defaults to True. |
True
|
Source code in framdata/loaders/time_vector_loaders.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
clear_cache() -> None
Clear cached data.
Source code in framdata/loaders/time_vector_loaders.py
255 256 257 258 259 |
|
get_index(vector_id: str) -> ListTimeIndex
Get the TimeIndex describing the time dimension of the vectors in the file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used since all vectors in the NVE excel files have the same index. |
required |
Returns:
Name | Type | Description |
---|---|---|
TimeIndex |
ListTimeIndex
|
TimeIndex object describing the excel file's index. |
Source code in framdata/loaders/time_vector_loaders.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
get_metadata(vector_id: str) -> dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
Read Excel file metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If an expected metadata key is missing. |
Returns:
Type | Description |
---|---|
dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
|
dict[str, bool|int|str|datetime|timedelta|tzinfo|None]: Metadata dictionary. |
Source code in framdata/loaders/time_vector_loaders.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
get_unit(vector_id: str) -> str
Get the unit of the given time vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
ID of a time vector. Not used since all time vectors in the NVE excel files have the same unit. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Unit of the time vector. |
Source code in framdata/loaders/time_vector_loaders.py
62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
get_values(vector_id: str) -> NDArray
Get numpy array with all the values of a given vector in the Loader's excel file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Unique id of the vector in the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Numpy array with values. |
Source code in framdata/loaders/time_vector_loaders.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
NVEH5TimeVectorLoader
Bases: NVETimeVectorLoader
Class for loading time vector data from NVE HDF5 file sources.
Meant for large time vectors (e.g. hourly data over multiple years). Supports differing lengths and metadata of vectors stored in the file.
Specialized to the following format
- index (h5py.Group, optional): Used to define indexes for vectors if index is supposed to only apply to that vector.
- common_index (h5py.Dataset): Contains one numpy array for all vectors. This is a fallback index for vectors which have not defined their own index in the index group. Also used on purpose if many or all vectors have the same index.
- metadata (h5py.Group): Used connect a specific set of metadata to a particular vector.
- common_metadata (h5py.Group): Contains one set of metadata fields for all vectors. Used in a similar way as common_index.
- vectors (h5py.Group): Contains numpy arrays containing the vector values connected to a unique ID. The same ID is used to connect the vector to an index or metadata.
Source code in framdata/loaders/time_vector_loaders.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
|
__init__(source: Path | str, require_whole_years: bool, relative_loc: Path | str | None = None, validate: bool = True) -> None
Intitialize loader instance and connect it to a H5 file containing time vector data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str
|
Absolute Path to database or HDF5 file. |
required |
require_whole_years
|
bool
|
Flag for validating that the time vectors in the source contain data for complete years. |
required |
relative_loc
|
Path | str | None
|
Path to HDF5 file relative to source. Defaults to None. |
None
|
validate
|
bool
|
Whether to validate vectors after loading. NB! Loads all data into memory at once. Defaults to True. |
True
|
Source code in framdata/loaders/time_vector_loaders.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
|
clear_cache() -> None
Clear cached data.
Source code in framdata/loaders/time_vector_loaders.py
440 441 442 443 444 |
|
get_index(vector_id: str) -> TimeIndex
Get the TimeIndex describing the time dimension of the vectors in the file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used since all vectors in the NVE parquet files have the same index. |
required |
Returns:
Name | Type | Description |
---|---|---|
TimeIndex |
TimeIndex
|
TimeIndex object describing the parquet file's index. |
Source code in framdata/loaders/time_vector_loaders.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
|
get_metadata(vector_id: str) -> dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
Retrieve and decodes custom metadata from parquet file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If any of the expected metadata keys is not found in file. |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
|
Dictionary with decoded metadata. |
Source code in framdata/loaders/time_vector_loaders.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
get_values(vector_id: str) -> NDArray
Get numpy array with all the values of a given vector in the Loader's HDF5 file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Unique id of the vector in the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Numpy array with values. |
Source code in framdata/loaders/time_vector_loaders.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
|
NVEParquetTimeVectorLoader
Bases: NVETimeVectorLoader
Class for loading time vector data from NVE parquet file sources.
Meant for large time vectors. All vectors in the file must have the same lenghts and metadata. Supports format: - 'Vertical' with one index collumn (DateTime) and the others containing vector values.
Source code in framdata/loaders/time_vector_loaders.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 |
|
__init__(source: Path | str, require_whole_years: bool, relative_loc: Path | str | None = None, validate: bool = True) -> None
Intitialize loader instance and connect it to an Parquet file containing time vector data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str
|
Absolute Path to database or parquet file. |
required |
require_whole_years
|
bool
|
Flag for validating that the time vectors in the source contain data for complete years. |
required |
relative_loc
|
Path | str | None
|
Path to parquet file relative to source. Defaults to None. |
None
|
validate
|
bool
|
Flag to turn on validation of timevectors. NB! Loads all data into memory at once. Defaults to True. |
True
|
Source code in framdata/loaders/time_vector_loaders.py
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
|
clear_cache() -> None
Clear cached data.
Source code in framdata/loaders/time_vector_loaders.py
726 727 728 729 730 |
|
get_index(vector_id: str) -> TimeIndex
Get the TimeIndex describing the time dimension of the vectors in the file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used since all vectors in the NVE parquet files have the same index. |
required |
Returns:
Name | Type | Description |
---|---|---|
TimeIndex |
TimeIndex
|
TimeIndex object describing the parquet file's index. |
Source code in framdata/loaders/time_vector_loaders.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 |
|
get_metadata(vector_id: str) -> dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
Retrieve and decodes custom metadata from parquet file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If any of the expected metadata keys is not found in file. |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
|
Dictionary with decoded metadata. |
Source code in framdata/loaders/time_vector_loaders.py
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 |
|
get_values(vector_id: str) -> NDArray
Get numpy array with all the values of a given vector in the Loader's parquet file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Unique id of the vector in the file. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Numpy array with values. |
Source code in framdata/loaders/time_vector_loaders.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
|
NVEYamlTimeVectoroader
Bases: NVETimeVectorLoader
Class for loading time vector data from NVE YAML file sources.
Meant for very sparse time vector data, where the vectors have varying lengths and indexes. Currently all vectors must have the same metadata within each file. Supported format: - Metadata: field containing dictionary with metadata for all vectors. - Other fields are vector IDs with lists for x and y axes.
Source code in framdata/loaders/time_vector_loaders.py
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
|
__init__(source: Path | str, require_whole_years: bool, relative_loc: Path | str | None = None, validate: bool = True) -> None
Intitialize loader instance and connect it to an Yaml file containing time vector data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
Path | str
|
Absolute Path to database or excel file. |
required |
require_whole_years
|
bool
|
Flag for validating that the time vectors in the source contain data for complete years. |
required |
relative_loc
|
Path | str | None
|
Path to excel file relative to source. Defaults to None. |
None
|
validate
|
bool
|
Flag to turn on validation of timevectors. NB! Loads all data into memory at once. Defaults to True. |
True
|
Source code in framdata/loaders/time_vector_loaders.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
|
clear_cache() -> None
Clear cached data.
Source code in framdata/loaders/time_vector_loaders.py
589 590 591 592 593 594 595 596 597 |
|
get_index(vector_id: str) -> TimeIndex
Get index of vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Unique id of the curve in the Loader source. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
TimeIndex
|
Numpy array with index of vector. |
Source code in framdata/loaders/time_vector_loaders.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 |
|
get_metadata(vector_id: str) -> dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
Read YAML file metadata.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Not used. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If an expected metadata key is missing. |
Returns:
Type | Description |
---|---|
dict[str, bool | int | str | datetime | timedelta | tzinfo | None]
|
dict[str, bool|int|str|datetime|timedelta|tzinfo|None]: Metadata dictionary. |
Source code in framdata/loaders/time_vector_loaders.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 |
|
get_values(vector_id: str) -> NDArray
Get values of vector.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vector_id
|
str
|
Unique id of the curve in the Loader source. |
required |
Returns:
Name | Type | Description |
---|---|---|
NDArray |
NDArray
|
Numpy array with values of vector. |
Source code in framdata/loaders/time_vector_loaders.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 |
|