empire.core package#

Submodules#

empire.core.config module#

class empire.core.config.EmpireConfiguration(use_temporary_directory, temporary_directory, forecast_horizon_year, number_of_scenarios, length_of_regular_season, discount_rate, wacc, optimization_solver, use_scenario_generation, use_fixed_sample, load_change_module, filter_make, filter_use, n_cluster, moment_matching, n_tree_compare, use_emission_cap, compute_operational_duals, print_in_iamc_format, write_in_lp_format, serialize_instance, north_sea, regular_seasons=['winter', 'spring', 'summer', 'fall'], n_peak_seasons=2, len_peak_season=24, leap_years_investment=5, time_format='%d/%m/%Y %H:%M', **kwargs)#

Bases: object

Parameters:
  • use_temporary_directory (bool) –

  • temporary_directory (str | Path) –

  • forecast_horizon_year (int) –

  • number_of_scenarios (int) –

  • length_of_regular_season (int) –

  • discount_rate (float) –

  • wacc (float) –

  • optimization_solver (str) –

  • use_scenario_generation (bool) –

  • use_fixed_sample (bool) –

  • load_change_module (bool) –

  • filter_make (bool) –

  • filter_use (bool) –

  • n_cluster (int) –

  • moment_matching (bool) –

  • n_tree_compare (int) –

  • use_emission_cap (bool) –

  • compute_operational_duals (bool) –

  • print_in_iamc_format (bool) –

  • write_in_lp_format (bool) –

  • serialize_instance (bool) –

  • north_sea (bool) –

  • regular_seasons (list[str]) –

  • n_peak_seasons (int) –

  • len_peak_season (int) –

  • leap_years_investment (int) –

  • time_format (str) –

classmethod from_dict(config)#

Constructs EmpireConfiguration object from a dictionary.

If constructor arguments are missing and they don’t have default values, they are added with None value to handle earlier versions of the configuration.

Parameters:

config (Dict) – Dictionary with configurations.

Returns:

An instance of EmpireConfiguration.

Return type:

EmpireConfiguration

to_dict()#

Used for serialization.

Returns:

dictionary

Return type:

dict

validate()#

Validates the configuration. Raises an error if the configuration is invalid.

class empire.core.config.EmpireRunConfiguration(run_name, dataset_path, tab_path, scenario_data_path, results_path, empire_path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/openempire/checkouts/stable/docs/source'))#

Bases: object

Parameters:
  • run_name (str) –

  • dataset_path (Path | str) –

  • tab_path (Path | str) –

  • scenario_data_path (Path | str) –

  • results_path (Path | str) –

  • empire_path (Path | str) –

classmethod from_dict(config)#

Constructs EmpireRunConfiguration object from a dictionary.

Parameters:

config (dict) – Dictionary with configurations.

Returns:

An instance of EmpireRunConfiguration.

Return type:

EmpireRunConfiguration

validate()#

Validates the configuration. Raises an error if the configuration is invalid.

empire.core.config.read_config_file(path)#
Parameters:

path (Path) –

Return type:

Dict

empire.core.empire module#

empire.core.empire.run_empire(name, tab_file_path, result_file_path, scenario_data_path, solver, temp_dir, FirstHoursOfRegSeason, FirstHoursOfPeakSeason, lengthRegSeason, lengthPeakSeason, Period, Operationalhour, Scenario, Season, HoursOfSeason, discountrate, WACC, LeapYearsInvestment, IAMC_PRINT, WRITE_LP, PICKLE_INSTANCE, EMISSION_CAP, USE_TEMP_DIR, LOADCHANGEMODULE, OPERATIONAL_DUALS)#
Parameters:
  • tab_file_path (Path) –

  • result_file_path (Path) –

empire.core.model_runner module#

empire.core.model_runner.run_empire_model(empire_config, run_config, data_managers, test_run)#
Parameters:
empire.core.model_runner.runner(data_managers)#
empire.core.model_runner.setup_run_paths(version, empire_config, run_path, empire_path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/openempire/checkouts/stable/docs/source'))#

Setup run paths for Empire.

Parameters:
  • version (str) – dataset version.

  • empire_config (EmpireConfiguration) – Empire configuration.

  • run_path (Path) – Path containing input and output to the empire run.

  • empire_path (Path) – Path to empire project, optional.

Returns:

Empire run configuration.

Return type:

EmpireRunConfiguration

empire.core.reader module#

empire.core.reader.generate_tab_files(file_path, tab_file_path)#

Read column value from excel sheet and save as .tab file “sheet.tab”

Parameters:
  • file_path – Path to the dataset.

  • tab_file_path – Path to save the .tab files.

empire.core.reader.read_file(excelfile, sheet, columns, tab_file_path, filename, skipheaders=0)#

Reads data from an Excel file and saves it as a .tab file.

Parameters:
  • excelfile (ExcelFile) – The Excel file object.

  • sheet (str) – The name of the sheet to read from.

  • columns (list) – List of columns to be read.

  • tab_file_path (Path) – Path to save the .tab file.

  • filename (str) – Base name for the .tab file.

  • skipheaders (int) – Number of header rows to skip. Defaults to 0.

Return type:

None

empire.core.reader.read_sets(excelfile, sheet, tab_file_path, filename)#

Reads sets data from an Excel file and saves each column as a separate .tab file.

Parameters:
  • excelfile (ExcelFile) – The Excel file object.

  • sheet (str) – The name of the sheet to read from.

  • tab_file_path (Path) – Path to save the .tab files.

  • filename (str) – Base name for the .tab files.

Return type:

None

empire.core.scenario_random module#

empire.core.scenario_random.check_scenarios_exist(scenario_data_path)#

Checks that the .tab files for the scenarios exist in scenario data folder.

Parameters:

scenario_data_path (Path) – Path to ScenarioData folder.

Returns:

True if exist, false if not.

Return type:

bool

empire.core.scenario_random.check_scenarios_exist_and_copy(run_config)#

Checks that the .tab files for the scenarios exist in scenario data folder and copys to the tab folder of the run.

Parameters:

run_config (EmpireRunConfiguration) – Empire run configuration

Raises:

ValueError – If files are missing in scenario data.

empire.core.scenario_random.gather_peak_sample(data, seasons, regularSeasonHours, peakSeasonHours, country_sample, overall_sample)#
empire.core.scenario_random.gather_regular_sample(data, season, seasons, regularSeasonHours, sample_hour)#
empire.core.scenario_random.generate_random_scenario(empire_config, dict_countries, scenario_data_path, tab_file_path)#

Method to generate random scenarios. Can also read existing samples if fix_sample is True.

Parameters:
  • run_config – Empire run configuration

  • empire_config (EmpireConfiguration) – Empire configuration

  • dict_countries (dict) – Dictionary mapping country names

  • scenario_data_path (Path) –

  • tab_file_path (Path) –

empire.core.scenario_random.make_datetime(data, time_format)#
empire.core.scenario_random.make_filter_result(data1, data2, regularSeasonHours, seasons, n_cluster, filepath)#
Parameters:

filepath (Path) –

empire.core.scenario_random.make_mean(data, regularSeasonHours, seasons)#
empire.core.scenario_random.make_ws(data, regularSeasonHours, seasons)#
empire.core.scenario_random.remove_time_index(data)#
empire.core.scenario_random.sample_generator(data, regularSeasonHours, scenario, season, seasons, period, generator, sample_hour)#
empire.core.scenario_random.sample_generator_peak(data, seasons, g, scenario, period, regularSeasonHours, peakSeasonHours, overall_sample, country_sample)#
empire.core.scenario_random.sample_hydro(data, regularSeasonHours, scenario, season, seasons, period, sample_hour)#
empire.core.scenario_random.sample_hydro_peak(data, seasons, scenario, period, regularSeasonHours, peakSeasonHours, overall_sample, country_sample)#
empire.core.scenario_random.sample_load(data, regularSeasonHours, scenario, season, seasons, period, sample_hour)#
empire.core.scenario_random.sample_load_peak(data, seasons, scenario, period, regularSeasonHours, peakSeasonHours, overall_sample, country_sample)#
empire.core.scenario_random.season_month(season)#
Parameters:

season (str) –

empire.core.scenario_random.year_season_filter(data, sample_year, season)#

Module contents#