Exporters#

class r2x.exporter.handler.BaseExporter(config, system, output_folder, ts_directory='Data')#

Class that defines the shared methods of parsers.

Note

This class is meant to be use for developing new parsers. Do not use it directly.

Parameters:
config#

Scenario configuration

system#

System class

output_foder#

output folder path

run()#

Sequentially run methods from the exporter

Return type:

BaseExporter

get_data(key='load')#

Return the parsed data for load.

read_file(fpath='load.csv')#

Read load data.

Parameters:
export_data_files(time_series_folder='Data')#

Save time series data files.

Parameters:
  • year (int)

  • time_series_folder (str)

Return type:

None

export_data_files(year, time_series_folder='Data')#

Export all time series objects attached to components.

This method assumes that self.config.weather_year and `self.output_folder exist.

Parameters:
  • time_series_folder (str) – Folder name to save time series data

  • year (int)

Return type:

None

read_file(fpath, filter_func=None, **kwargs)#

Read input model data from the file system.

Currently supported formats:
  • .csv

  • .h5

More to come!

Parameters:
  • fpath (Path, str) – Absolute location of the file in the system

  • filter_func (List) – Filter functions to apply

abstract run(*args, **kwargs)#

Run the exporter methods in sequence.

This methods needs to be implemented by any exporter and it’s content change based on the order the data is being exported.

Return type:

BaseExporter

Plexos#

class r2x.exporter.plexos.PlexosExporter(*args, plexos_scenario='default', database_manager=None, xml_fname=None, **kwargs)#

Plexos exporter class.

Parameters:
  • plexos_scenario (str)

  • xml_fname (str | None)

add_batteries()#

Add battery objects to the database.

add_component_category(component_type, class_enum, category_attribute='category', filter_func=None)#

Add all categories for a component type.

Parameters:
add_constraints()#

Add custom constraints.

Return type:

None

add_emissions()#

Add emission objects to the database.

Return type:

None

add_generators()#

Add generator objects to the database.

add_interfaces()#

Add transmission interfaces.

Return type:

None

add_lines()#

Add transmission lines that connect topology elements.

Return type:

None

add_reserves()#

Add system reserves to the database.

This method only appends the information for the type of reserves. Each generator that contributes to the reserve will add the membership for the type of reserve as a child membership.

Return type:

None

add_storage()#

Add storage objects to the database.

add_topology()#

Create network topology on Plexos.

Return type:

None

add_transformers()#

Add Transformer objects to the database.

Return type:

None

bulk_insert_objects(component_type, class_enum, collection_enum, category_attribute='category', name_prefix='', filter_func=None)#

Bulk insert objects to the database.

Parameters:
  • component_type (type[Component])

  • class_enum (ClassEnum)

  • collection_enum (CollectionEnum)

  • category_attribute (str)

  • name_prefix (str)

  • filter_func (Callable | None)

export_data_files(year, time_series_folder='Data')#

Export all time series objects attached to components.

This method assumes that self.config.weather_year and `self.output_folder exist.

Parameters:
  • time_series_folder (str) – Folder name to save time series data

  • year (int)

Return type:

None

insert_component_properties(component_type, /, *, parent_class, parent_object_name='System', collection, child_class=None, filter_func=None, scenario=None, records=None, exclude_fields=['ext', 'bus', 'services'])#

Bulk insert properties from selected component type.

Parameters:
  • component_type (type[Component])

  • parent_class (ClassEnum)

  • parent_object_name (str)

  • collection (CollectionEnum)

  • child_class (ClassEnum | None)

  • filter_func (Callable | None)

  • scenario (str | None)

  • records (list[dict] | None)

  • exclude_fields (list[str] | None)

Return type:

None

read_file(fpath, filter_func=None, **kwargs)#

Read input model data from the file system.

Currently supported formats:
  • .csv

  • .h5

More to come!

Parameters:
  • fpath (Path, str) – Absolute location of the file in the system

  • filter_func (List) – Filter functions to apply

run(*args, new_database=True, **kwargs)#

Run the exporter.

Parameters:

new_database (bool)

Return type:

PlexosExporter

Sienna#

class r2x.exporter.sienna.SiennaExporter(*args, **kwargs)#

Sienna exporter class.

This is the class that export the infrasys system to csv’s required to read in PowerSystems.jl. The class contains a method per file that needs to get created and some of the methods manipulate the data to be compliant wth PowerSystems.jl. The order is important for some steps, however, most of them could be run sequentially.

The method run is the responsible of running all the exporter.

Notes

All the methods defined an output_columns which defines the fields from the Component that we want to export.

All methods call export_component_to_csv or export_dict_to_csv that is defined on the BaseExporter class.

See also

BaseExporter.export_component_to_csv, BaseExporter.export_dict_to_csv

create_timeseries_pointers()#

Create timeseries_pointers.json file.

Parameters:

fname (str) – Name of the file to be created

Return type:

None

export_data()#

Export csv data to specified folder from output_data attribute.

Return type:

None

export_data_files(year, time_series_folder='Data')#

Export all time series objects attached to components.

This method assumes that self.config.weather_year and `self.output_folder exist.

Parameters:
  • time_series_folder (str) – Folder name to save time series data

  • year (int)

Return type:

None

process_branch_data(fname='branch.csv')#

Create branch.csv file.

Parameters:

fname (str) – Name of the file to be created

Return type:

None

process_bus_data(fname='bus.csv')#

Create bus.csv file.

Parameters:

fname (str) – Name of the file to be created

Return type:

None

process_dc_branch_data(fname='dc_branch.csv')#

Create dc_branch.csv file.

Parameters:

fname (str) – Name of the file to be created

Return type:

None

process_gen_data(fname='gen.csv')#

Create gen.csv file.

Parameters:

fname (str) – Name of the file to be created

process_load_data(fname='load.csv')#

Create load.csv file.

Parameters:

fname (str) – Name of the file to be created

Return type:

None

process_reserves_data(fname='reserves.csv')#

Create reserve.csv file.

Parameters:

fname (str) – Name of the file to be created

Return type:

None

process_storage_data(fname='storage.csv')#

Create storage.csv file.

Parameters:

fname (str) – Name of the file to be created

Return type:

None

read_file(fpath, filter_func=None, **kwargs)#

Read input model data from the file system.

Currently supported formats:
  • .csv

  • .h5

More to come!

Parameters:
  • fpath (Path, str) – Absolute location of the file in the system

  • filter_func (List) – Filter functions to apply

run(*args, path=None, **kwargs)#

Run sienna exporter workflow.

Notes

All methods call export_component_to_csv or export_dict_to_csv that is defined on the BaseExporter class.

If performance is a constraint, we could parallelize the methods.

Return type:

SiennaExporter