DataWorker

class pomato.data.DataWorker(data, file_path)

Data Worker Module reads data from disk.

This module’s purpose is to hide all the file system specific functions and allow for rather seemless data import. An instance of the DataManagement class acts as the carrier for the read data and is used as an attribute of DataWorker.

The based on file_path the module tries to import xlsx or matpower (.m or .mat) cases. Reading the excel file is done by going through the pre-defined data tables in data.data_attributes and attaching them to the DataManagement instance for processing and validation. Matpower cases are imported manually and

Parameters:
dataDataManagement

An instance of the DataManagement class with processed input data.

file_pathpathlib.Path

Filepath to input data.

Attributes:
dataDataManagement

An instance of the DataManagement class with processed input data.

Methods

read_xls(xls_filepath)

Read excel file at specified filepath.

read_csv_zipped(zip_filepath)

Read csv files zipped into archive at specified filepath.

read_csv_folder(folder)

Read csv files from specified folder.

stack_data(data, columns)

Stacks data that comes in a wide format.

process_matpower_case(casefile, m_type)

Process Matpower Case.

read_m_file(m_filepath)

Read .m file at specified filepath.

read_mat_file(mat_filepath)

Read mat file at specified filepath.

process_matpower_case(casefile, m_type)

Process Matpower Case.

Based on the read data, processing the matpower case data into somthing compatible with pomato. This is a fairly manual process, but it should work with most .mat/.m as the structure is the same (most of the time).

This methods populates the DataManagement instance with the corresponding data. Additionally it can add coordinates if a correspnonding file is provided.

Parameters:
casefilepathlib.Path

Filepath to input matpower .m casefile file.

m_typestr

Filetype, .mat or .m, set by parent method.

read_csv_folder(folder)

Read csv files from specified folder.

Parameters:
folderpathlib.Path

Path to folder containing input data .csv files.

read_csv_zipped(zip_filepath)

Read csv files zipped into archive at specified filepath.

Parameters:
zip_filepathpathlib.Path

Filepath to .zip file.

read_m_file(m_filepath)

Read .m file at specified filepath.

Reading a .m file with the providing the same return as method read_mat_file.

Returns the necessary data in DataFrames to be processes in process_matpower_case().

Parameters:
m_filepathpathlib.Path

Filepath to input matpower .m casefile file.

Returns:
caseinfostr

Matpower case information, i.e. case name.

busnamelist like

List of bus names. These are sometimes provided with the casedata, returns empty if not.

baseMVA

BaseMVA for the system.

bus_dfpd.DataFrame

DataFrame containing the bus/nodes data.

gen_dfpd.DataFrame

DataFrame containing the generator/plants data.

branch_df pd.DataFrame

DataFrame containing the branch/lines data.

gencost_dfpd.DataFrame

DataFrame containing the generation costs.

read_mat_file(mat_filepath)

Read mat file at specified filepath.

Reading a .mat file which is intended to be used with matlab as a way to exchange data, requires the package sio.loadmat.

Parameters:
mat_filepathpathlib.Path

Filepath to input matpower .mat casefile file.

Returns
——-
caseinfostr

Matpower case information, i.e. case name.

busnamelist like

List of bus names. These are sometimes provided with the casedata, returns empty if not.

baseMVA

BaseMVA for the system.

bus_dfpd.DataFrame

DataFrame containing the bus/nodes data.

gen_dfpd.DataFrame

DataFrame containing the generator/plants data.

branch_df pd.DataFrame

DataFrame containing the branch/lines data.

gencost_dfpd.DataFrame

DataFrame containing the generation costs.

read_xls(xls_filepath)

Read excel file at specified filepath.

Parameters:
xls_filepathpathlib.Path

Filepath to input excel file.

stack_data(data, columns)

Stacks data that comes in a wide format.

As xls files have a limit when it comes to table length, some data will be stored wide instead (e.g. demand or availability). To properly use this data in the model the data will be stacked based on the configuration in the options file (options[“data”][“stacked”]).