Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

LtmApiModule

class pyltm.LtmApiModule

Properties

PropertyDescriptionRequired
model

Methods

attributes

static attributes() -> json

build_area_graph

build_area_graph(self: pyltm.LtmApiModule) -> str

build_connection_tree

build_connection_tree(self: pyltm.LtmApiModule) -> str

connect

connect(*args, **kwargs)

Overloaded function.

connect(self: pyltm.LtmApiModule, from_ref: pyltm.PyLtmReference, to_ref: pyltm.PyLtmReference) -> pyltm.PyLtmConnection

Connects two model objects

Args: object1 (PyLtmReference): connection from object1 object2 (PyLtmReference): connection to object2

Returns: PyLtmConnection: connection object

connect(self: pyltm.LtmApiModule, from_obj: Union[pyltm.Area, pyltm.MarketStep, pyltm.DCLine, pyltm.Load, pyltm.Wind, pyltm.Solar, pyltm.BatteryModule, pyltm.UncontrollableGeneration, pyltm.UncontrollableGenerationSeries, pyltm.AggregatedHydroModule, pyltm.Bypass, pyltm.HydraulicCoupling, pyltm.Spill, pyltm.Reservoir, pyltm.Plant, pyltm.Pump, pyltm.MarketCalibrationArea, pyltm.Inflow, pyltm.MainPriceSeries, pyltm.SecondaryPriceSeries, pyltm.BiddingZone, pyltm.CriticalNetworkElement, pyltm.Line, pyltm.LineOutage, pyltm.Busbar, pyltm.TwoWindingTransformer, pyltm.MonitoredNetworkElement, pyltm.HvdcConnection, pyltm.RunConfig, pyltm.Watercourse], to_obj: Union[pyltm.Area, pyltm.MarketStep, pyltm.DCLine, pyltm.Load, pyltm.Wind, pyltm.Solar, pyltm.BatteryModule, pyltm.UncontrollableGeneration, pyltm.UncontrollableGenerationSeries, pyltm.AggregatedHydroModule, pyltm.Bypass, pyltm.HydraulicCoupling, pyltm.Spill, pyltm.Reservoir, pyltm.Plant, pyltm.Pump, pyltm.MarketCalibrationArea, pyltm.Inflow, pyltm.MainPriceSeries, pyltm.SecondaryPriceSeries, pyltm.BiddingZone, pyltm.CriticalNetworkElement, pyltm.Line, pyltm.LineOutage, pyltm.Busbar, pyltm.TwoWindingTransformer, pyltm.MonitoredNetworkElement, pyltm.HvdcConnection, pyltm.RunConfig, pyltm.Watercourse]) -> pyltm.PyLtmConnection

Doc

dump_model

dump_model(self: pyltm.LtmApiModule, dump_path: str, model_filename: str = 'model.json', timeseries_filename: str = 'timeseries.h5') -> None

Dumps the model to a JSON file and timeseries to h5-file.

Parameters:

Return type: None

execute_model

execute_model(self: pyltm.LtmApiModule, path: str = '') -> json

Executes a model and returns a JSON-like dictionary.

Parameters: path (str) – Path to the model. Defaults to an empty string.

Returns: A dictionary representing the JSON response.

Return type: dict[str, Any]

export_results

export_results(self: pyltm.LtmApiModule) -> None

import_directory

import_directory(self: pyltm.LtmApiModule, datadir: str, import_market_steps: bool = True, import_loads: bool = True, recalculate_average_yearly_inflow: bool = True, import_detailed_hydro: bool = True, import_wind: bool = True) -> bool

Imports an EMPS/EOPS directory into a LTM-API model Prerequisite for market description: The LTM-application konvtiltser.exe must be run on the dataset. It convert the *.enmd-files to the proper format and creates the file timeseries.h5 with the timeseries for the market description. Several importer options are available, passed as arguments.

Parameters:

Returns: Success or failure of the import

Return type: success (bool)

load

load(*args, **kwargs)

Overloaded function.

load(self: pyltm.LtmApiModule, model: json = {}) -> str
load(self: pyltm.LtmApiModule, filename: str = '') -> str

load_from_ltm_dir

load_from_ltm_dir(self: pyltm.LtmApiModule, path: str = '') -> None

Import a classic EMPS/EOPS runtime directory to be able to fetch results.

This creates a minimal LtmApiModel with areas, detailed hydro modules and dclines based on the classic runtime directory. Only used for getting results.

Parameters: datadir (str) – Path to a classic runtime directory

Returns: void

results

static results() -> json

run

run(self: pyltm.LtmApiModule) -> tuple[int, list[pyltm.ProgramResult]]

Runs the model.

Returns: A tuple with the last return code and all results for all executed programs.

Return type: tuple[int, list[ProgramResult]]

set_execute_callback

set_execute_callback(self: pyltm.LtmApiModule, arg0: Callable[[pyltm.ProgramResult, object], bool], arg1: object) -> None

Sets a user-callback that will be called after every program LTM core has executed

Note: set_execute_callback is deprecated and will be removed soon, use set_post_execute_callback.

Parameters:

set_post_execute_callback

set_post_execute_callback(self: pyltm.LtmApiModule, fn: Callable[[pyltm.ProgramResult, object], bool], userdata: object = None) -> None

Sets a user callback that will be called after a program has been executed.

Parameters:

set_post_model_execute_callback

set_post_model_execute_callback(self: pyltm.LtmApiModule, fn: Callable[[list[pyltm.ProgramResult], object], bool], userdata: object = None) -> None

Sets a user callback that will be called after the model has executed all programs.

Parameters:

set_pre_execute_callback

set_pre_execute_callback(self: pyltm.LtmApiModule, fn: Callable[[pyltm.ProgramInfo, object], bool], userdata: object = None) -> None

Sets a user callback that will be called before calling next program in the list.

Parameters:

set_pre_model_execute_callback

set_pre_model_execute_callback(self: pyltm.LtmApiModule, fn: Callable[[list[pyltm.ProgramInfo], object], bool], userdata: object = None) -> None

Sets a user callback that will be called before the model executes any programs.

Parameters:

validate_model

validate_model(self: pyltm.LtmApiModule) -> list[pyltm.Discrepancy]

validate_model_post_write

validate_model_post_write(self: pyltm.LtmApiModule) -> list[pyltm.Discrepancy]

write_model

write_model(*args, **kwargs)

Overloaded function.

write_model(self: pyltm.LtmApiModule) -> bool

Write the in-memory model to disk

write_model(self: pyltm.LtmApiModule, model: json = {}) -> bool

Writes the model directly to disk from a JSON/Python Dictionary.

Args: model (dict): A dictionary representation of a LtmApi model