Skip to content

Commit

Permalink
Implement facade specific parameter mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
henhuy committed Oct 6, 2023
1 parent fa112e3 commit 80c6932
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions data_adapter_oemof/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,25 @@ def map_key(self, key):
if self.process_name in self.mapping and key in self.mapping[self.process_name]:
return self.mapping[self.process_name][key]

# 2. Check facade-specific mappings second
# 2. Check adapter-specific mappings second
if (
self.adapter.__name__ in self.mapping
and key in self.mapping[self.adapter.__name__]
):
return self.mapping[self.adapter.__name__][key]

# 3. Check default mappings third
# 3. Check facade-specific mappings third
if (
self.adapter.facade.__name__ in self.mapping
and key in self.mapping[self.adapter.facade.__name__]
):
return self.mapping[self.adapter.facade.__name__][key]

# 4. Check default mappings fourth
if key in self.mapping.get("DEFAULT", []):
return self.mapping["DEFAULT"][key]

# 4. Use key if no mapping available
# 5. Use key if no mapping available
logger.warning(f"Key not found. Did not map '{key}'")
return key

Expand Down
2 changes: 2 additions & 0 deletions data_adapter_oemof/mappings/PARAMETER_MAP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ DEFAULT:
marginal_cost: variable_costs
fixed_cost: fixed_costs
capacity_cost: capital_costs
Conversion:
marginal_cost: fuel_costs

0 comments on commit 80c6932

Please sign in to comment.