oemof.tabular.datapackage package

Submodules

oemof.tabular.datapackage.aggregation module

Module used for aggregation sequences and elements.

oemof.tabular.datapackage.aggregation.temporal_clustering(datapackage, n, path='/tmp', how='daily')[source]

Creates a new datapackage by aggregating sequences inside the sequence folder of the specified datapackage by clustering n timesteps

Parameters:
  • datapackage (string) – String of meta data file datapackage.json
  • n (integer) – Number of clusters
  • path (string) – Path to directory where the aggregated datapackage is stored
  • how (string) – How to cluster ‘daily’ or ‘hourly’
oemof.tabular.datapackage.aggregation.temporal_skip(datapackage, n, path='/tmp', name=None, *args)[source]

Creates a new datapackage by aggregating sequences inside the sequence folder of the specified datapackage by skipping n timesteps

Parameters:
  • datapackage (string) – String of meta data file datapackage.json
  • n (integer) – Number of timesteps to skip
  • path (string) – Path to directory where the aggregated datapackage is stored
  • name (string) – Name of the new, aggregated datapackage. If not specified a name will be given

oemof.tabular.datapackage.building module

oemof.tabular.datapackage.building.download_data(url, directory='cache', unzip_file=None, **kwargs)[source]

Downloads data and stores it in specified directory

Parameters:
  • url (str) – Url of file to be downloaded.
  • directory (str) – Name of directory where to store the downloaded data. Default is ‘cache’-
  • unzip_file (str) – Regular or directory file name to be extracted from zip source.
  • kwargs – Additional keyword arguments.
oemof.tabular.datapackage.building.infer_metadata(package_name='default-name', keep_resources=False, foreign_keys=None, path=None)[source]

Add basic meta data for a datapackage

Parameters:
  • package_name (string) – Name of the data package
  • keep_resources (boolean) – Flag indicating of the resources meta data json-files should be kept after main datapackage.json is created. The resource meta data will be stored in the resources directory.
  • foreign_keys (dict) – Dictionary with foreign key specification. Keys for dictionary are: ‘bus’, ‘profile’, ‘from_to_bus’. Values are list with strings with the name of the resources
  • path (string) – Absolute path to root-folder of the datapackage
oemof.tabular.datapackage.building.infer_resources(directory='data/elements')[source]

Method looks at all files in directory and creates datapackage.Resource object that will be stored

Parameters:directory (string) – Path to directory from where resources are inferred
oemof.tabular.datapackage.building.initialize(config, directory='.')[source]

Initialize datapackage by reading config file and creating required directories (data/elements, data/sequences etc.) if directories are not specified in the config file, the default directory setup up will be used.

oemof.tabular.datapackage.building.input_filepath(file, directory='archive/')[source]
oemof.tabular.datapackage.building.package_from_resources(resource_path, output_path, clean=True)[source]

Collects resource descriptors and merges them in a datapackage.json

Parameters:
  • resource_path (string) – Path to directory with resources (in .json format)
  • output_path (string) – Root path of datapackage where the newly created datapckage.json is stored
  • clean (boolean) – If true, resources will be deleted
oemof.tabular.datapackage.building.read_build_config(file='build.toml')[source]

Read config build file in toml format

Parameters:file (string) – String with name of config file
oemof.tabular.datapackage.building.read_elements(filename, directory='data/elements')[source]

Reads element resources from the datapackage

Parameters:
  • filename (string) – Name of the elements to be read, for example load.csv
  • directory (string) – Directory where the file is located. Default: data/elements
Returns:

pd.DataFrame

oemof.tabular.datapackage.building.read_sequences(filename, directory='data/sequences')[source]

Reads sequence resources from the datapackage

Parameters:
  • filename (string) – Name of the sequences to be read, for example load_profile.csv
  • directory (string) – Directory from where the file should be read. Default: data/sequences
oemof.tabular.datapackage.building.timeindex(year, periods=8760, freq='H')[source]

Create pandas datetimeindex.

Parameters:
  • year (string) – Year of the index
  • periods (string) – Number of periods, default: 8760
  • freq (string) – Freq of the datetimeindex, default: ‘H’
oemof.tabular.datapackage.building.update_package_descriptor()[source]
oemof.tabular.datapackage.building.write_elements(filename, elements, directory='data/elements', replace=False, overwrite=False, create_dir=True)[source]

Writes elements to filesystem.

Parameters:
  • filename (string) – Name of the elements to be read, for example reservoir.csv
  • elements (pd.DataFrame) – Elements to be stored in data frame. Index: name
  • directory (string) – Directory where the file is stored. Default: data/elements
  • replace (boolean) – If set, existing data will be overwritten. Otherwise integrity of data (unique indices) will be checked
  • overwrite (boolean) – If set, existing elements will be overwritten
  • create_dir (boolean) – Create the directory if not exists
Returns:

path (string) – Returns the path where the file has been stored.

oemof.tabular.datapackage.building.write_sequences(filename, sequences, directory='data/sequences', replace=False, create_dir=True)[source]

Writes sequences to filesystem.

Parameters:
  • filename (string) – Name of the sequences to be read, for example load_profile.csv
  • sequences (pd.DataFrame) – Sequences to be stored in data frame. Index: datetimeindex with format %Y-%m-%dT%H:%M:%SZ
  • directory (string) – Directory where the file is stored. Default: data/elements
  • replace (boolean) – If set, existing data will be overwritten. Otherwise integrity of data (unique indices) will be checked
  • create_dir (boolean) – Create the directory if not exists
Returns:

path (string) – Returns the path where the file has been stored.

oemof.tabular.datapackage.processing module

oemof.tabular.datapackage.processing.clean(path=None, directories=['data', 'cache', 'resources'])[source]
Parameters:
  • path (str) – Path to root directory of the datapackage, if no path is passed the current directory is to be assumed the root.
  • directories (list (optional)) – List of directory names inside the root directory to clean (remove).
oemof.tabular.datapackage.processing.copy_datapackage(source, destination, subset=None)[source]
Parameters:
  • source (str) – datapackage.json
  • destination (str) – Destination of copied datapackage
  • name (optional) (str) – Name of datapackage
  • only_data (str) – Name of directory to only copy subset of datapackage (for example only the ‘data’ directory)
oemof.tabular.datapackage.processing.to_dict(value)[source]

Convert value from e.g. csv-reader to valid json / dict

oemof.tabular.datapackage.reading module

Tools to deserialize energy systems from datapackages.

WARNING

This is work in progress and still pretty volatile, so use it at your own risk. The datapackage format and conventions we use are still a bit in flux. This is also why we don’t have documentation or tests yet. Once things are stabilized a bit more, the way in which we extend the datapackage spec will be documented along with how to use the functions in this module.

oemof.tabular.datapackage.reading.deserialize_energy_system(cls, path, typemap={}, attributemap={})[source]
oemof.tabular.datapackage.reading.read_facade(facade, facades, create, typemap, data, objects, sequence_names, fks, resources)[source]

Parse the resource r as a facade.

oemof.tabular.datapackage.reading.sequences(r, timeindices=None)[source]

Parses the resource r as a sequence.