diff --git a/src/oemof/tabular/datapackage/building.py b/src/oemof/tabular/datapackage/building.py index 666d7814..1302fe99 100644 --- a/src/oemof/tabular/datapackage/building.py +++ b/src/oemof/tabular/datapackage/building.py @@ -212,6 +212,25 @@ def infer_metadata( ) p.add_resource(r.descriptor) + # create meta data resources periods + if not os.path.exists("data/periods"): + print( + "No periods path found in directory {}. Skipping...".format( + os.getcwd() + ) + ) + else: + for f in os.listdir("data/periods"): + r = Resource( + {"path": str(pathlib.PurePosixPath("data", "periods", f))} + ) + r.infer() + r.commit() + r.save( + pathlib.PurePosixPath("resources", f.replace(".csv", ".json")) + ) + p.add_resource(r.descriptor) + p.commit() p.save(metadata_filename) diff --git a/src/oemof/tabular/datapackage/reading.py b/src/oemof/tabular/datapackage/reading.py index d62f675e..02ff3c9b 100644 --- a/src/oemof/tabular/datapackage/reading.py +++ b/src/oemof/tabular/datapackage/reading.py @@ -437,17 +437,44 @@ def find(n, d): name="timeindex", ) timeindex = temporal.index + es = cls(timeindex=timeindex, temporal=temporal) # if no temporal provided as resource, take the first timeindex # from dict else: + # look for periods resource and if present, take as periods from it + if package.get_resource("periods"): + df_periods = pd.DataFrame.from_dict( + package.get_resource("periods").read(keyed=True) + ) + timeincrement = df_periods["increment"].values + timeindex = pd.DatetimeIndex(df_periods["timeindex"]) + periods = [ + pd.DatetimeIndex(df["timeindex"]) + for period, df in df_periods.groupby("periods") + ] + periods = [ + pd.DatetimeIndex( + i.values, freq=i.inferred_freq, name="timeindex" + ) + for i in periods + ] + + es = cls( + timeindex=timeindex, + timeincrement=timeincrement, + periods=periods, + infer_last_interval=False, + ) + # if lst is not empty - if lst: + elif lst: idx = pd.DatetimeIndex(lst[0]) timeindex = pd.DatetimeIndex( idx.values, freq=idx.inferred_freq, name="timeindex" ) temporal = None + es = cls(timeindex=timeindex, temporal=temporal) # if for any reason lst of datetimeindices is empty # (i.e. no sequences) have been provided, set datetime to one time # step of today (same as in the EnergySystem __init__ if no @@ -456,8 +483,7 @@ def find(n, d): timeindex = pd.date_range( start=pd.to_datetime("today"), periods=1, freq="H" ) - - es = cls(timeindex=timeindex, temporal=temporal) if lst else cls() + es = cls() es.add( *chain( diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/README.md b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/README.md new file mode 100644 index 00000000..be203d7c --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/README.md @@ -0,0 +1,5 @@ +# Dispatch example for oemof-tabular + +Run `scripts/infer.py` from the datapackage root directory to add the +meta data file `datapackage.json` after updating the resources of the +datapackage. diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/bus.csv b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/bus.csv new file mode 100644 index 00000000..56beebcf --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/bus.csv @@ -0,0 +1,5 @@ +name;type;balanced +bus0;bus;true +bus1;bus;true +heat-bus;bus;false +gas-bus;bus;false diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/dispatchable.csv b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/dispatchable.csv new file mode 100644 index 00000000..bac86320 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/dispatchable.csv @@ -0,0 +1,4 @@ +name;type;carrier;tech;capacity;bus;marginal_cost;profile;output_parameters +gas;dispatchable;gas;gt;100;bus1;40;1;{"full_load_time_max": 2000} +coal;dispatchable;coal;st;100;bus0;40;1;{} +lignite;dispatchable;lignite;st;50;bus0;20;1;{} diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/link.csv b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/link.csv new file mode 100644 index 00000000..0fb78032 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/link.csv @@ -0,0 +1,3 @@ +name;type;capacity;capacity_cost;loss;from_bus;to_bus +conn1;link;100;10;0.05;bus0;bus1 +conn2;link;10;0;0.05;heat-bus;gas-bus diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/load.csv b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/load.csv new file mode 100644 index 00000000..5a3b43d3 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/load.csv @@ -0,0 +1,3 @@ +name;amount;profile;type;bus +demand0;5000;electricity-load-profile;load;bus0 +demand1;1000;electricity-load-profile;load;bus1 diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/storage.csv b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/storage.csv new file mode 100644 index 00000000..d05c11eb --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/storage.csv @@ -0,0 +1,3 @@ +name,carrier,tech,storage_capacity,capacity,capacity_cost,storage_capacity_initial,type,bus +el-storage1,lithium,battery,100,10,10,0.5,storage,bus0 +el-storage2,lithium,battery,200,20,15,0.2,storage,bus0 diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/volatile.csv b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/volatile.csv new file mode 100644 index 00000000..8c5d3f1b --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/elements/volatile.csv @@ -0,0 +1,3 @@ +name;type;carrier;tech;capacity;capacity_cost;bus;marginal_cost;profile;output_parameters +wind;volatile;wind;onshore;50;;bus0;0;wind-profile;{} +pv;volatile;solar;pv;20;;bus1;0;pv-profile;{} diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/periods/periods.csv b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/periods/periods.csv new file mode 100644 index 00000000..7fad6495 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/periods/periods.csv @@ -0,0 +1,10 @@ +timeindex,periods, increment +2011-01-01T00:00:00Z,0,1 +2011-01-01T01:00:00Z,0,1 +2011-01-01T02:00:00Z,0,1 +2035-01-01T00:00:00Z,1,1 +2035-01-01T01:00:00Z,1,1 +2035-01-01T02:00:00Z,1,1 +2050-01-01T00:00:00Z,2,1 +2050-01-01T01:00:00Z,2,1 +2050-01-01T02:00:00Z,2,1 diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/sequences/load_profile.csv b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/sequences/load_profile.csv new file mode 100644 index 00000000..a6cb27d1 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/sequences/load_profile.csv @@ -0,0 +1,10 @@ +timeindex,electricity-load-profile +2011-01-01T00:00:00Z,0.000745659236 +2011-01-01T01:00:00Z,0.000709651546 +2011-01-01T02:00:00Z,0.00068564642 +2035-01-01T00:00:00Z,0.000745659236 +2035-01-01T01:00:00Z,0.000709651546 +2035-01-01T02:00:00Z,0.00068564642 +2050-01-01T00:00:00Z,0.000745659236 +2050-01-01T01:00:00Z,0.000709651546 +2050-01-01T02:00:00Z,0.00068564642 diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/sequences/volatile_profile.csv b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/sequences/volatile_profile.csv new file mode 100644 index 00000000..70035325 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/data/sequences/volatile_profile.csv @@ -0,0 +1,10 @@ +timeindex,wind-profile,pv-profile +2011-01-01T00:00:00Z,0.147532,0 +2011-01-01T01:00:00Z,0.184181,0 +2011-01-01T02:00:00Z,0.223937,0 +2035-01-01T00:00:00Z,0.147532,0 +2035-01-01T01:00:00Z,0.184181,0 +2035-01-01T02:00:00Z,0.223937,0 +2050-01-01T00:00:00Z,0.147532,0 +2050-01-01T01:00:00Z,0.184181,0 +2050-01-01T02:00:00Z,0.223937,0 diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/datapackage.json b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/datapackage.json new file mode 100644 index 00000000..da7070f6 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/datapackage.json @@ -0,0 +1,468 @@ +{ + "profile": "tabular-data-package", + "name": "oemof-tabular-dispatch-example", + "oemof_tabular_version": "0.0.4dev", + "resources": [ + { + "path": "data/elements/bus.csv", + "profile": "tabular-data-resource", + "name": "bus", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "balanced", + "type": "boolean", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [] + } + }, + { + "path": "data/elements/dispatchable.csv", + "profile": "tabular-data-resource", + "name": "dispatchable", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "carrier", + "type": "string", + "format": "default" + }, + { + "name": "tech", + "type": "string", + "format": "default" + }, + { + "name": "capacity", + "type": "integer", + "format": "default" + }, + { + "name": "bus", + "type": "string", + "format": "default" + }, + { + "name": "marginal_cost", + "type": "integer", + "format": "default" + }, + { + "name": "profile", + "type": "integer", + "format": "default" + }, + { + "name": "output_parameters", + "type": "object", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "resource": "bus", + "fields": "name" + } + } + ] + } + }, + { + "path": "data/elements/link.csv", + "profile": "tabular-data-resource", + "name": "link", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "capacity", + "type": "integer", + "format": "default" + }, + { + "name": "capacity_cost", + "type": "integer", + "format": "default" + }, + { + "name": "loss", + "type": "number", + "format": "default" + }, + { + "name": "from_bus", + "type": "string", + "format": "default" + }, + { + "name": "to_bus", + "type": "string", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [ + { + "fields": "from_bus", + "reference": { + "resource": "bus", + "fields": "name" + } + }, + { + "fields": "to_bus", + "reference": { + "resource": "bus", + "fields": "name" + } + } + ] + } + }, + { + "path": "data/elements/load.csv", + "profile": "tabular-data-resource", + "name": "load", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "amount", + "type": "integer", + "format": "default" + }, + { + "name": "profile", + "type": "string", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "bus", + "type": "string", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "resource": "bus", + "fields": "name" + } + }, + { + "fields": "profile", + "reference": { + "resource": "load_profile" + } + } + ] + } + }, + { + "path": "data/elements/storage.csv", + "profile": "tabular-data-resource", + "name": "storage", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "carrier", + "type": "string", + "format": "default" + }, + { + "name": "tech", + "type": "string", + "format": "default" + }, + { + "name": "storage_capacity", + "type": "integer", + "format": "default" + }, + { + "name": "capacity", + "type": "integer", + "format": "default" + }, + { + "name": "capacity_cost", + "type": "integer", + "format": "default" + }, + { + "name": "storage_capacity_initial", + "type": "number", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "bus", + "type": "string", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "resource": "bus", + "fields": "name" + } + } + ] + } + }, + { + "path": "data/elements/volatile.csv", + "profile": "tabular-data-resource", + "name": "volatile", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "carrier", + "type": "string", + "format": "default" + }, + { + "name": "tech", + "type": "string", + "format": "default" + }, + { + "name": "capacity", + "type": "integer", + "format": "default" + }, + { + "name": "capacity_cost", + "type": "string", + "format": "default" + }, + { + "name": "bus", + "type": "string", + "format": "default" + }, + { + "name": "marginal_cost", + "type": "integer", + "format": "default" + }, + { + "name": "profile", + "type": "string", + "format": "default" + }, + { + "name": "output_parameters", + "type": "object", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "resource": "bus", + "fields": "name" + } + }, + { + "fields": "profile", + "reference": { + "resource": "volatile_profile" + } + } + ] + } + }, + { + "path": "data/sequences/load_profile.csv", + "profile": "tabular-data-resource", + "name": "load_profile", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "timeindex", + "type": "datetime", + "format": "default" + }, + { + "name": "electricity-load-profile", + "type": "number", + "format": "default" + } + ], + "missingValues": [ + "" + ] + } + }, + { + "path": "data/sequences/volatile_profile.csv", + "profile": "tabular-data-resource", + "name": "volatile_profile", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "timeindex", + "type": "datetime", + "format": "default" + }, + { + "name": "wind-profile", + "type": "number", + "format": "default" + }, + { + "name": "pv-profile", + "type": "integer", + "format": "default" + } + ], + "missingValues": [ + "" + ] + } + }, + { + "path": "data/periods/periods.csv", + "profile": "tabular-data-resource", + "name": "periods", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "timeindex", + "type": "datetime", + "format": "default" + }, + { + "name": "periods", + "type": "integer", + "format": "default" + }, + { + "name": "increment", + "type": "integer", + "format": "default" + } + ], + "missingValues": [ + "" + ] + } + } + ] +} diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/scripts/datapackage.json b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/scripts/datapackage.json new file mode 100644 index 00000000..b4d7ea81 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/scripts/datapackage.json @@ -0,0 +1,5 @@ +{ + "profile": "tabular-data-package", + "name": "oemof-tabular-dispatch-example", + "oemof_tabular_version": "0.0.4dev" +} \ No newline at end of file diff --git a/src/oemof/tabular/examples/datapackages/dispatch_multi_period/scripts/infer.py b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/scripts/infer.py new file mode 100644 index 00000000..f14f7f67 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/dispatch_multi_period/scripts/infer.py @@ -0,0 +1,21 @@ +""" +Run this script from the root directory of the datapackage to update +or create meta data. +""" +from oemof.tabular.datapackage import building + +# This part is for testing only: It allows to pass +# the filename of inferred metadata other than the default. +if "kwargs" not in locals(): + kwargs = {} + +building.infer_metadata( + package_name="oemof-tabular-dispatch-example", + foreign_keys={ + "bus": ["volatile", "dispatchable", "storage", "load"], + "profile": ["load", "volatile"], + "from_to_bus": ["link"], + "chp": [], + }, + **kwargs, +) diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/README.md b/src/oemof/tabular/examples/datapackages/investment_multi_period/README.md new file mode 100644 index 00000000..0071c7c2 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/README.md @@ -0,0 +1,5 @@ +# Investment example for oemof-tabular + +Run `scripts/infer.py` from the datapackage root directory to add the +meta data file `datapackage.json` after updating the resources of the +datapackage. diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/bus.csv b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/bus.csv new file mode 100644 index 00000000..56beebcf --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/bus.csv @@ -0,0 +1,5 @@ +name;type;balanced +bus0;bus;true +bus1;bus;true +heat-bus;bus;false +gas-bus;bus;false diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/chp.csv b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/chp.csv new file mode 100644 index 00000000..69f09dd3 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/chp.csv @@ -0,0 +1,3 @@ +name;type;carrier;tech;capacity;marginal_cost;capacity_cost;electricity_bus;heat_bus;fuel_bus;electric_efficiency;thermal_efficiency;condensing_efficiency;lifetime;age +ext;extraction;gas;ext;;1;60;bus0;heat-bus;gas-bus;0.4;0.3;0.5;40;10 +bp;backpressure;gas;bp;;1;10;bus0;heat-bus;gas-bus;0.4;0.3;0;40;10 diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/conversion.csv b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/conversion.csv new file mode 100644 index 00000000..3ebba1a1 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/conversion.csv @@ -0,0 +1,2 @@ +name;type;carrier;tech;capacity;capacity_cost;marginal_cost;efficiency;from_bus;to_bus;lifetime;age +power2heat;conversion;electricity;heatpump;;20;2;0.99;bus1;heat-bus;20;0 diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/link.csv b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/link.csv new file mode 100644 index 00000000..e6f39bdf --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/link.csv @@ -0,0 +1,3 @@ +name;type;capacity;capacity_cost;loss;from_bus;to_bus +conn1;link;;10;0.05;bus0;bus1 +conn2;link;;10;0.05;heat-bus;gas-bus diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/load.csv b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/load.csv new file mode 100644 index 00000000..79db954e --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/load.csv @@ -0,0 +1,3 @@ +name;amount;profile;type;bus +demand0;500000;electricity-load-profile;load;bus0 +demand1;100000;electricity-load-profile;load;bus1 diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/source.csv b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/source.csv new file mode 100644 index 00000000..293ac04f --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/source.csv @@ -0,0 +1,6 @@ +name;type;carrier;tech;capacity;capacity_cost;bus;marginal_cost;profile;output_parameters;expandable;lifetime;age +gas-gt;dispatchable;gas;gt;0;100;bus1;40;;{"full_load_time_max": 2000};True;40;5 +coal-st;dispatchable;coal;st;0;100;bus0;40;;{};True;40;10 +lignite-st;dispatchable;lignite;st;0;50;bus0;20;;{};True;40;20 +wind;volatile;wind;onshore;0;50;bus0;0;wind-profile;{};True;20;5 +pv;volatile;solar;pv;0;20;bus1;0;pv-profile;{};True;20;5 diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/storage.csv b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/storage.csv new file mode 100644 index 00000000..bba9c313 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/elements/storage.csv @@ -0,0 +1,2 @@ +name;carrier;tech;storage_capacity;capacity;capacity_cost;invest_relation_output_capacity;invest_relation_input_output;expandable;type;bus;tech;lifetime;age +el-storage;lithium;battery;100;0;10;0.2;1;true;storage;bus0;battery;20;0 diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/data/periods/periods.csv b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/periods/periods.csv new file mode 100644 index 00000000..89e6bd93 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/periods/periods.csv @@ -0,0 +1,40 @@ +timeindex,periods, increment +2015-01-01T00:00:00Z,0,1 +2015-01-01T01:00:00Z,0,1 +2015-01-01T02:00:00Z,0,1 +2015-01-01T03:00:00Z,0,1 +2015-01-01T04:00:00Z,0,1 +2015-01-01T05:00:00Z,0,1 +2015-01-01T06:00:00Z,0,1 +2015-01-01T07:00:00Z,0,1 +2015-01-01T08:00:00Z,0,1 +2015-01-01T09:00:00Z,0,1 +2015-01-01T10:00:00Z,0,1 +2015-01-01T11:00:00Z,0,1 +2015-01-01T12:00:00Z,0,1 +2035-01-01T00:00:00Z,1,1 +2035-01-01T01:00:00Z,1,1 +2035-01-01T02:00:00Z,1,1 +2035-01-01T03:00:00Z,1,1 +2035-01-01T04:00:00Z,1,1 +2035-01-01T05:00:00Z,1,1 +2035-01-01T06:00:00Z,1,1 +2035-01-01T07:00:00Z,1,1 +2035-01-01T08:00:00Z,1,1 +2035-01-01T09:00:00Z,1,1 +2035-01-01T10:00:00Z,1,1 +2035-01-01T11:00:00Z,1,1 +2035-01-01T12:00:00Z,1,1 +2050-01-01T00:00:00Z,2,1 +2050-01-01T01:00:00Z,2,1 +2050-01-01T02:00:00Z,2,1 +2050-01-01T03:00:00Z,2,1 +2050-01-01T04:00:00Z,2,1 +2050-01-01T05:00:00Z,2,1 +2050-01-01T06:00:00Z,2,1 +2050-01-01T07:00:00Z,2,1 +2050-01-01T08:00:00Z,2,1 +2050-01-01T09:00:00Z,2,1 +2050-01-01T10:00:00Z,2,1 +2050-01-01T11:00:00Z,2,1 +2050-01-01T12:00:00Z,2,1 diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/data/sequences/load_profile.csv b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/sequences/load_profile.csv new file mode 100644 index 00000000..77c090d5 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/sequences/load_profile.csv @@ -0,0 +1,40 @@ +timeindex,electricity-load-profile +2015-01-01T00:00:00Z,7.45659235529747E-05 +2015-01-01T01:00:00Z,7.09651546087667E-05 +2015-01-01T02:00:00Z,6.85646419792947E-05 +2015-01-01T03:00:00Z,6.67642575071907E-05 +2015-01-01T04:00:00Z,0.000065714 +2015-01-01T05:00:00Z,6.22632963269306E-05 +2015-01-01T06:00:00Z,6.40636807990346E-05 +2015-01-01T07:00:00Z,6.48138409957447E-05 +2015-01-01T08:00:00Z,0.000065414 +2015-01-01T09:00:00Z,6.84146099399527E-05 +2015-01-01T10:00:00Z,7.20153788841607E-05 +2015-01-01T11:00:00Z,7.38157633562647E-05 +2015-01-01T12:00:00Z,7.26155070415287E-05 +2035-01-01T00:00:00Z,7.45659235529747E-05 +2035-01-01T01:00:00Z,7.09651546087667E-05 +2035-01-01T02:00:00Z,6.85646419792947E-05 +2035-01-01T03:00:00Z,6.67642575071907E-05 +2035-01-01T04:00:00Z,0.000065714 +2035-01-01T05:00:00Z,6.22632963269306E-05 +2035-01-01T06:00:00Z,6.40636807990346E-05 +2035-01-01T07:00:00Z,6.48138409957447E-05 +2035-01-01T08:00:00Z,0.000065414 +2035-01-01T09:00:00Z,6.84146099399527E-05 +2035-01-01T10:00:00Z,7.20153788841607E-05 +2035-01-01T11:00:00Z,7.38157633562647E-05 +2035-01-01T12:00:00Z,7.26155070415287E-05 +2050-01-01T00:00:00Z,7.45659235529747E-05 +2050-01-01T01:00:00Z,7.09651546087667E-05 +2050-01-01T02:00:00Z,6.85646419792947E-05 +2050-01-01T03:00:00Z,6.67642575071907E-05 +2050-01-01T04:00:00Z,0.000065714 +2050-01-01T05:00:00Z,6.22632963269306E-05 +2050-01-01T06:00:00Z,6.40636807990346E-05 +2050-01-01T07:00:00Z,6.48138409957447E-05 +2050-01-01T08:00:00Z,0.000065414 +2050-01-01T09:00:00Z,6.84146099399527E-05 +2050-01-01T10:00:00Z,7.20153788841607E-05 +2050-01-01T11:00:00Z,7.38157633562647E-05 +2050-01-01T12:00:00Z,7.26155070415287E-05 diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/data/sequences/source_profile.csv b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/sequences/source_profile.csv new file mode 100644 index 00000000..7310c766 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/data/sequences/source_profile.csv @@ -0,0 +1,40 @@ +timeindex,pv-profile,wind-profile +2015-01-01T00:00:00Z,0,0.147532 +2015-01-01T01:00:00Z,0,0.184181 +2015-01-01T02:00:00Z,0,0.223937 +2015-01-01T03:00:00Z,0,0.255732 +2015-01-01T04:00:00Z,0,0.26844 +2015-01-01T05:00:00Z,0,0.276708 +2015-01-01T06:00:00Z,0,0.26844 +2015-01-01T07:00:00Z,0,0.243378 +2015-01-01T08:00:00Z,0.005,0.203473 +2015-01-01T09:00:00Z,0.049,0.16961 +2015-01-01T10:00:00Z,0.119,0.148345 +2015-01-01T11:00:00Z,0.158,0.148345 +2015-01-01T12:00:00Z,0.152,0.157479 +2035-01-01T00:00:00Z,0,0.147532 +2035-01-01T01:00:00Z,0,0.184181 +2035-01-01T02:00:00Z,0,0.223937 +2035-01-01T03:00:00Z,0,0.255732 +2035-01-01T04:00:00Z,0,0.26844 +2035-01-01T05:00:00Z,0,0.276708 +2035-01-01T06:00:00Z,0,0.26844 +2035-01-01T07:00:00Z,0,0.243378 +2035-01-01T08:00:00Z,0.005,0.203473 +2035-01-01T09:00:00Z,0.049,0.16961 +2035-01-01T10:00:00Z,0.119,0.148345 +2035-01-01T11:00:00Z,0.158,0.148345 +2035-01-01T12:00:00Z,0.152,0.157479 +2050-01-01T00:00:00Z,0,0.147532 +2050-01-01T01:00:00Z,0,0.184181 +2050-01-01T02:00:00Z,0,0.223937 +2050-01-01T03:00:00Z,0,0.255732 +2050-01-01T04:00:00Z,0,0.26844 +2050-01-01T05:00:00Z,0,0.276708 +2050-01-01T06:00:00Z,0,0.26844 +2050-01-01T07:00:00Z,0,0.243378 +2050-01-01T08:00:00Z,0.005,0.203473 +2050-01-01T09:00:00Z,0.049,0.16961 +2050-01-01T10:00:00Z,0.119,0.148345 +2050-01-01T11:00:00Z,0.158,0.148345 +2050-01-01T12:00:00Z,0.152,0.157479 diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/datapackage.json b/src/oemof/tabular/examples/datapackages/investment_multi_period/datapackage.json new file mode 100644 index 00000000..e563ee25 --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/datapackage.json @@ -0,0 +1,644 @@ +{ + "profile": "tabular-data-package", + "name": "renpass-invest-example", + "oemof_tabular_version": "0.0.4dev", + "resources": [ + { + "path": "data/elements/bus.csv", + "profile": "tabular-data-resource", + "name": "bus", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "balanced", + "type": "boolean", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [] + } + }, + { + "path": "data/elements/chp.csv", + "profile": "tabular-data-resource", + "name": "chp", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "carrier", + "type": "string", + "format": "default" + }, + { + "name": "tech", + "type": "string", + "format": "default" + }, + { + "name": "capacity", + "type": "string", + "format": "default" + }, + { + "name": "marginal_cost", + "type": "integer", + "format": "default" + }, + { + "name": "capacity_cost", + "type": "integer", + "format": "default" + }, + { + "name": "electricity_bus", + "type": "string", + "format": "default" + }, + { + "name": "heat_bus", + "type": "string", + "format": "default" + }, + { + "name": "fuel_bus", + "type": "string", + "format": "default" + }, + { + "name": "electric_efficiency", + "type": "number", + "format": "default" + }, + { + "name": "thermal_efficiency", + "type": "number", + "format": "default" + }, + { + "name": "condensing_efficiency", + "type": "number", + "format": "default" + }, + { + "name": "lifetime", + "type": "integer", + "format": "default" + }, + { + "name": "age", + "type": "integer", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [ + { + "fields": "electricity_bus", + "reference": { + "resource": "bus", + "fields": "name" + } + }, + { + "fields": "fuel_bus", + "reference": { + "resource": "bus", + "fields": "name" + } + }, + { + "fields": "heat_bus", + "reference": { + "resource": "bus", + "fields": "name" + } + } + ] + } + }, + { + "path": "data/elements/conversion.csv", + "profile": "tabular-data-resource", + "name": "conversion", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "carrier", + "type": "string", + "format": "default" + }, + { + "name": "tech", + "type": "string", + "format": "default" + }, + { + "name": "capacity", + "type": "string", + "format": "default" + }, + { + "name": "capacity_cost", + "type": "integer", + "format": "default" + }, + { + "name": "marginal_cost", + "type": "integer", + "format": "default" + }, + { + "name": "efficiency", + "type": "number", + "format": "default" + }, + { + "name": "from_bus", + "type": "string", + "format": "default" + }, + { + "name": "to_bus", + "type": "string", + "format": "default" + }, + { + "name": "lifetime", + "type": "integer", + "format": "default" + }, + { + "name": "age", + "type": "integer", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [ + { + "fields": "from_bus", + "reference": { + "resource": "bus", + "fields": "name" + } + }, + { + "fields": "to_bus", + "reference": { + "resource": "bus", + "fields": "name" + } + } + ] + } + }, + { + "path": "data/elements/link.csv", + "profile": "tabular-data-resource", + "name": "link", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "capacity", + "type": "string", + "format": "default" + }, + { + "name": "capacity_cost", + "type": "integer", + "format": "default" + }, + { + "name": "loss", + "type": "number", + "format": "default" + }, + { + "name": "from_bus", + "type": "string", + "format": "default" + }, + { + "name": "to_bus", + "type": "string", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [ + { + "fields": "from_bus", + "reference": { + "resource": "bus", + "fields": "name" + } + }, + { + "fields": "to_bus", + "reference": { + "resource": "bus", + "fields": "name" + } + } + ] + } + }, + { + "path": "data/elements/load.csv", + "profile": "tabular-data-resource", + "name": "load", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "amount", + "type": "integer", + "format": "default" + }, + { + "name": "profile", + "type": "string", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "bus", + "type": "string", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "resource": "bus", + "fields": "name" + } + }, + { + "fields": "profile", + "reference": { + "resource": "load_profile" + } + } + ] + } + }, + { + "path": "data/elements/source.csv", + "profile": "tabular-data-resource", + "name": "source", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "carrier", + "type": "string", + "format": "default" + }, + { + "name": "tech", + "type": "string", + "format": "default" + }, + { + "name": "capacity", + "type": "integer", + "format": "default" + }, + { + "name": "capacity_cost", + "type": "integer", + "format": "default" + }, + { + "name": "bus", + "type": "string", + "format": "default" + }, + { + "name": "marginal_cost", + "type": "integer", + "format": "default" + }, + { + "name": "profile", + "type": "string", + "format": "default" + }, + { + "name": "output_parameters", + "type": "object", + "format": "default" + }, + { + "name": "expandable", + "type": "boolean", + "format": "default" + }, + { + "name": "lifetime", + "type": "integer", + "format": "default" + }, + { + "name": "age", + "type": "integer", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "resource": "bus", + "fields": "name" + } + }, + { + "fields": "profile", + "reference": { + "resource": "source_profile" + } + } + ] + } + }, + { + "path": "data/elements/storage.csv", + "profile": "tabular-data-resource", + "name": "storage", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "name", + "type": "string", + "format": "default" + }, + { + "name": "carrier", + "type": "string", + "format": "default" + }, + { + "name": "tech", + "type": "string", + "format": "default" + }, + { + "name": "storage_capacity", + "type": "integer", + "format": "default" + }, + { + "name": "capacity", + "type": "integer", + "format": "default" + }, + { + "name": "capacity_cost", + "type": "integer", + "format": "default" + }, + { + "name": "invest_relation_output_capacity", + "type": "number", + "format": "default" + }, + { + "name": "invest_relation_input_output", + "type": "integer", + "format": "default" + }, + { + "name": "expandable", + "type": "boolean", + "format": "default" + }, + { + "name": "type", + "type": "string", + "format": "default" + }, + { + "name": "bus", + "type": "string", + "format": "default" + }, + { + "name": "tech", + "type": "string", + "format": "default" + }, + { + "name": "lifetime", + "type": "integer", + "format": "default" + }, + { + "name": "age", + "type": "integer", + "format": "default" + } + ], + "missingValues": [ + "" + ], + "primaryKey": "name", + "foreignKeys": [ + { + "fields": "bus", + "reference": { + "resource": "bus", + "fields": "name" + } + } + ] + } + }, + { + "path": "data/sequences/load_profile.csv", + "profile": "tabular-data-resource", + "name": "load_profile", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "timeindex", + "type": "datetime", + "format": "default" + }, + { + "name": "electricity-load-profile", + "type": "number", + "format": "default" + } + ], + "missingValues": [ + "" + ] + } + }, + { + "path": "data/sequences/source_profile.csv", + "profile": "tabular-data-resource", + "name": "source_profile", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "timeindex", + "type": "datetime", + "format": "default" + }, + { + "name": "pv-profile", + "type": "number", + "format": "default" + }, + { + "name": "wind-profile", + "type": "number", + "format": "default" + } + ], + "missingValues": [ + "" + ] + } + }, + { + "path": "data/periods/periods.csv", + "profile": "tabular-data-resource", + "name": "periods", + "format": "csv", + "mediatype": "text/csv", + "encoding": "utf-8", + "schema": { + "fields": [ + { + "name": "timeindex", + "type": "datetime", + "format": "default" + }, + { + "name": "periods", + "type": "integer", + "format": "default" + }, + { + "name": "increment", + "type": "integer", + "format": "default" + } + ], + "missingValues": [ + "" + ] + } + } + ] +} diff --git a/src/oemof/tabular/examples/datapackages/investment_multi_period/scripts/infer.py b/src/oemof/tabular/examples/datapackages/investment_multi_period/scripts/infer.py new file mode 100644 index 00000000..0a275eda --- /dev/null +++ b/src/oemof/tabular/examples/datapackages/investment_multi_period/scripts/infer.py @@ -0,0 +1,25 @@ +from oemof.tabular.datapackage import building + +# This part is for testing only: It allows to pass +# the filename of inferred metadata other than the default. +if "kwargs" not in locals(): + kwargs = {} + +building.infer_metadata( + package_name="renpass-invest-example", + foreign_keys={ + "bus": [ + "volatile", + "dispatchable", + "storage", + "load", + "shortage", + "excess", + "source", + ], + "profile": ["load", "source"], + "chp": ["chp"], + "from_to_bus": ["link", "conversion"], + }, + **kwargs, +)