From 3f68a9b5a907ad8ecd3e106ea73ceb54396bff74 Mon Sep 17 00:00:00 2001 From: MaGering Date: Wed, 2 Aug 2023 11:15:37 +0200 Subject: [PATCH 1/6] Fix name of profile in field efficiency --- src/oemof/tabular/datapackage/building.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oemof/tabular/datapackage/building.py b/src/oemof/tabular/datapackage/building.py index 1302fe99..a36f84cd 100644 --- a/src/oemof/tabular/datapackage/building.py +++ b/src/oemof/tabular/datapackage/building.py @@ -140,7 +140,7 @@ def infer_metadata( r.descriptor["schema"]["foreignKeys"].append( { "fields": key, - "reference": {"resource": key + "_profile"}, + "reference": {"resource": r.name + "_" + key + "_profile"}, } ) From 8cf3f248c03a9226e17e83b69f7272596e8a093a Mon Sep 17 00:00:00 2001 From: MaGering Date: Wed, 2 Aug 2023 11:17:01 +0200 Subject: [PATCH 2/6] Add 'component' to marginal cost profile sequence name according to new sequence naming convention --- ...ginal_cost_profile.csv => component_marginal_cost_profile.csv} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/oemof/tabular/examples/datapackages/foreignkeys/data/sequences/{marginal_cost_profile.csv => component_marginal_cost_profile.csv} (100%) diff --git a/src/oemof/tabular/examples/datapackages/foreignkeys/data/sequences/marginal_cost_profile.csv b/src/oemof/tabular/examples/datapackages/foreignkeys/data/sequences/component_marginal_cost_profile.csv similarity index 100% rename from src/oemof/tabular/examples/datapackages/foreignkeys/data/sequences/marginal_cost_profile.csv rename to src/oemof/tabular/examples/datapackages/foreignkeys/data/sequences/component_marginal_cost_profile.csv From a32dde522d1443c0879ef8370804625bacae307b Mon Sep 17 00:00:00 2001 From: MaGering Date: Wed, 2 Aug 2023 11:17:42 +0200 Subject: [PATCH 3/6] Update foreign keys example json with changes due to new sequence naming convention --- .../datapackages/foreignkeys/datapackage.json | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/oemof/tabular/examples/datapackages/foreignkeys/datapackage.json b/src/oemof/tabular/examples/datapackages/foreignkeys/datapackage.json index 4ccb1e77..314aa5b7 100644 --- a/src/oemof/tabular/examples/datapackages/foreignkeys/datapackage.json +++ b/src/oemof/tabular/examples/datapackages/foreignkeys/datapackage.json @@ -115,7 +115,7 @@ { "fields": "marginal_cost", "reference": { - "resource": "marginal_cost_profile" + "resource": "component_marginal_cost_profile" } }, { @@ -128,9 +128,9 @@ } }, { - "path": "data/sequences/component_profile.csv", + "path": "data/sequences/component_marginal_cost_profile.csv", "profile": "tabular-data-resource", - "name": "component_profile", + "name": "component_marginal_cost_profile", "format": "csv", "mediatype": "text/csv", "encoding": "utf-8", @@ -142,12 +142,7 @@ "format": "default" }, { - "name": "electricity-load-profile", - "type": "number", - "format": "default" - }, - { - "name": "dispatchable-profile", + "name": "marginal-cost-coal", "type": "integer", "format": "default" } @@ -158,9 +153,9 @@ } }, { - "path": "data/sequences/marginal_cost_profile.csv", + "path": "data/sequences/component_profile.csv", "profile": "tabular-data-resource", - "name": "marginal_cost_profile", + "name": "component_profile", "format": "csv", "mediatype": "text/csv", "encoding": "utf-8", @@ -172,7 +167,12 @@ "format": "default" }, { - "name": "marginal-cost-coal", + "name": "electricity-load-profile", + "type": "number", + "format": "default" + }, + { + "name": "dispatchable-profile", "type": "integer", "format": "default" } @@ -183,4 +183,4 @@ } } ] -} \ No newline at end of file +} From 55617e55eefa28ebbe3b525ecf50f7add05ca314 Mon Sep 17 00:00:00 2001 From: MaGering Date: Wed, 2 Aug 2023 11:23:16 +0200 Subject: [PATCH 4/6] Apply black --- src/oemof/tabular/datapackage/building.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/oemof/tabular/datapackage/building.py b/src/oemof/tabular/datapackage/building.py index a36f84cd..e9b2915e 100644 --- a/src/oemof/tabular/datapackage/building.py +++ b/src/oemof/tabular/datapackage/building.py @@ -140,7 +140,9 @@ def infer_metadata( r.descriptor["schema"]["foreignKeys"].append( { "fields": key, - "reference": {"resource": r.name + "_" + key + "_profile"}, + "reference": { + "resource": r.name + "_" + key + "_profile" + }, } ) From 3ee00ade1490db1e96f17ddf73fabf4d3016e504 Mon Sep 17 00:00:00 2001 From: MaGering Date: Wed, 2 Aug 2023 11:33:35 +0200 Subject: [PATCH 5/6] Fix E721 in src/oemof/tabular/tools/postprocessing.py:24:12 --- src/oemof/tabular/tools/postprocessing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/oemof/tabular/tools/postprocessing.py b/src/oemof/tabular/tools/postprocessing.py index 8d65bcc4..b2d11e46 100644 --- a/src/oemof/tabular/tools/postprocessing.py +++ b/src/oemof/tabular/tools/postprocessing.py @@ -21,7 +21,7 @@ def component_results(es, results, select="sequences"): setattr(es, "typemap", facades.TYPEMAP) for k, v in es.typemap.items(): - if type(k) == str: + if isinstance(k, str): if select == "sequences": _seq_by_type = [ views.node(results, n, multiindex=True).get("sequences") From bf4ab1177c96e7762613edb971fe619c66783b64 Mon Sep 17 00:00:00 2001 From: MaGering Date: Wed, 2 Aug 2023 12:06:14 +0200 Subject: [PATCH 6/6] Update docs with naming convention --- docs/usage.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/usage.rst b/docs/usage.rst index 234f47b8..9204f822 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -357,6 +357,22 @@ field names in the generators-profile resource. non-valid resources.** +If resources are passed with a key other than "profile" (e.g. marginal_cost or +efficiency), the foreign keys must also be updated with this key. In this case, +the name of the resource is composed of the components name and the key: + +.. code-block:: json + + "foreignKeys": [ + { + "fields": "marginal_cost", + "reference": { + "resource": "generator_marginal_cost_profile" + } + } + ] + + Scripting ========================= Currently the only way to construct a model and compute it is by using the