definitions
read_definitions(definitions_dir, flows, techs)
Reads YAML files from definitions directory, extracts tags, inserts tags into definitions, replaces tokens in definitions, and returns the updated definitions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
definitions_dir |
Path
|
Path leading to the definitions |
required |
flows |
dict
|
Dictionary containng the different flow types. Each key represents a flow type, the corresponding value is a dictionary containing key value pairs of attributes like denisty, energycontent and their values. |
required |
techs |
dict
|
Dictionary containing information about different technologies. Each key in the dictionary represents a unique technology ID, and the corresponding value is a dictionary containing various specifications for that technology, like 'description', 'class', 'primary output' etc. |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing the definitions after processing and replacing tags and tokens |
Source code in python/posted/definitions.py
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 |
|
replace_tags(definitions, tag, items)
Replaces specified tags in dictionary keys and values with corresponding items from another dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
definitions |
dict
|
Dictionary containing the definitions, where the tags should be replaced by the items |
required |
tag |
str
|
String to identify where replacements should be made in the definitions. Specifies
the placeholder that needs to be replaced with actual values from the |
required |
items |
dict[str, dict]
|
Dictionary containing the items from whith to replace the definitions |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing the definitions with replacements based on the provided tag and items. |
Source code in python/posted/definitions.py
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 |
|
unit_token_func(unit_component, flows)
Takes a unit component type and a dictionary of flows, and returns a lambda function that extracts the default unit based on the specified component type from the flow dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit_component |
Literal['full', 'raw', 'variant']
|
Specifies the type of unit token to be returned. |
required |
flows |
dict
|
Dictionary containg the flows |
required |
Returns:
Type | Description |
---|---|
lambda function
|
lambda function that takes a dictionary |
Source code in python/posted/definitions.py
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 |
|