_________________________ | ___________________________________________________________ |
name | base mapping |
_________________________ | ___________________________________________________________ |
oemof: | technologies |
regions: | concrete |
technologies: | regions |
technologies_and_types: | concrete |
technologies_reduced: | concrete |
Custom mappings are loaded and applied to oedatamodel results
_________________________ | ___________________________________________________________ |
name | description |
_________________________ | ___________________________________________________________ |
CustomFunctions: | From: https://github.com/jmespath/jmespath.site/issues/17#issuecomment-198111810 ---------------- Custom functions extend jmespath core functionality. They help to process json data and enable to apply a custom mapping on the json data (See apply_custom_mapping). Currently available custom functions are: - repeat - items - zip - to object - unique - exclude - group by group_by allows for the expref to be either a number of a string, so we have some special logic to handle this. We evaluate the first array element and verify that it's either a string of a number. We then create a key function that validates that type, which requires that remaining array elements resolve to the same type as the first element. - group by dict group_dict_by allows for the expref to be either a number of a string, so we have some special logic to handle this. We evaluate the first array element and verify that it's either a string of a number. We then create a key function that validates that type, which requires that remaining array elements resolve to the same type as the first element. |
_________________________ | ___________________________________________________________ |
name | description |
_________________________ | ___________________________________________________________ |
MappingNotFound: | Exception is thrown, if custom mapping is not found in folder "mappings". |
_________________________ | ___________________________________________________________ |
name | description |
_________________________ | ___________________________________________________________ |
apply_custom_mapping: | Custom mapping is (loaded and) applied to raw json/dict. Custom mapping can depend on pre-mappings (custom or default, last iteration must depend on default mapping, i.e. "normalized" or "concrete"). Depending mappings are recursively applied before current mapping is applied. Parameters ---------- raw_json: dict Result from OEP to perform custom mapping on. mapping: str Custom mapping (either name of predefined mapping or mapping json) which shall be applied Returns ------- dict Resulting json/dict after applying all custom/default mappings. |
---|---|
_________________________ | ___________________________________________________________ |
name | description |
_________________________ | ___________________________________________________________ |
iterate_mapping: | Recursive function to apply mappings down the mapping tree. Parameters ---------- raw_json: dict Scenario result or pre-mapped json. value: Union[dict, str] Either a dict (then next, deeper iteration is done) or a str (containing jmespath function to apply on given json). Returns ------- Union[dict, str, list] Either dict containing next iteration or result from jmespath function applied to given json. |
_________________________ | ___________________________________________________________ |
name | description |
_________________________ | ___________________________________________________________ |
load_custom_mapping: | Load custom mapping as json/dict from mappings folder. Parameters ---------- name: str Mapping name (searches for "{name}.json" in mappings folder. Raises ------ MappingNotFound If custom mapping cannot be found in mappings folder. Returns ------- dict Custom mapping json/dict. |