LtmApiModule
class pyltm.LtmApiModuleProperties¶
| Property | Description | Required |
|---|---|---|
model |
Methods¶
attributes¶
static attributes() -> jsonbuild_area_graph¶
build_area_graph(self: pyltm.LtmApiModule) -> strbuild_connection_tree¶
build_connection_tree(self: pyltm.LtmApiModule) -> strconnect¶
connect(*args, **kwargs)Overloaded function.
connect(self: pyltm.LtmApiModule, from_ref: pyltm.PyLtmReference, to_ref: pyltm.PyLtmReference) -> pyltm.PyLtmConnectionConnects 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.PyLtmConnectionDoc
dump_model¶
dump_model(self: pyltm.LtmApiModule, dump_path: str, model_filename: str = 'model.json', timeseries_filename: str = 'timeseries.h5') -> NoneDumps the model to a JSON file and timeseries to h5-file.
Parameters:
dump_path (str) – relative path to dump folder
model_filename (str, optional) – name of json file. Default value is model.json.
timeseries_filename (str, optional) – name of h5-file with timeseries. default value is timeseries.h5.
Return type: None
execute_model¶
execute_model(self: pyltm.LtmApiModule, path: str = '') -> jsonExecutes 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.
export_results¶
export_results(self: pyltm.LtmApiModule) -> Noneimport_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) -> boolImports 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:
datadir (str) – Path to a classic runtime directory
import_market_step (bool) – Import or skip market steps
import_loads (bool) – Import or skip loads
recalculate_average_yearly_inflow (bool) – Recalculate average yearly inflow from DETD MIDDELÅRSPERIOD to historical period
import_detailed_hydro (bool) – Import or skip detailed hydro
import_wind (bool) – Import or skip wind (may be time consuming if large timeseries are used)
Returns: Success or failure of the import
Return type: success (bool)
load¶
load(*args, **kwargs)Overloaded function.
load(self: pyltm.LtmApiModule, model: json = {}) -> strload(self: pyltm.LtmApiModule, filename: str = '') -> strload_from_ltm_dir¶
load_from_ltm_dir(self: pyltm.LtmApiModule, path: str = '') -> NoneImport 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() -> jsonrun¶
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) -> NoneSets 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:
fn (callback) –
A Python function with signature: def usercallback(program_info: dict, userdata: any):
… return True
userdata (any) – User provided userdata
set_post_execute_callback¶
set_post_execute_callback(self: pyltm.LtmApiModule, fn: Callable[[pyltm.ProgramResult, object], bool], userdata: object = None) -> NoneSets a user callback that will be called after a program has been executed.
Parameters:
fn (callback) –
A Python function with signature: def post_execute_callback(program_result: ProgramResult, userdata: any)
… return True
userdata (any) – User provided data
set_post_model_execute_callback¶
set_post_model_execute_callback(self: pyltm.LtmApiModule, fn: Callable[[list[pyltm.ProgramResult], object], bool], userdata: object = None) -> NoneSets a user callback that will be called after the model has executed all programs.
Parameters:
fn (callback) –
A Python function with signature: def post_model_execute_callback(program_result: list[ProgramResult], userdata: any)
… return True
userdata (any) – User provided data
set_pre_execute_callback¶
set_pre_execute_callback(self: pyltm.LtmApiModule, fn: Callable[[pyltm.ProgramInfo, object], bool], userdata: object = None) -> NoneSets a user callback that will be called before calling next program in the list.
Parameters:
fn (callback) –
A Python function with signature: def pre_execute_callback(program_infos: ProgramInfo, userdata: any)
… return True
userdata (any) – User provided data
set_pre_model_execute_callback¶
set_pre_model_execute_callback(self: pyltm.LtmApiModule, fn: Callable[[list[pyltm.ProgramInfo], object], bool], userdata: object = None) -> NoneSets a user callback that will be called before the model executes any programs.
Parameters:
fn (callback) –
A Python function with signature: def pre_model_execute_callback(program_infos: list[ProgramInfo], userdata: any)
… return True
userdata (any) – User provided data
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) -> boolWrite the in-memory model to disk
write_model(self: pyltm.LtmApiModule, model: json = {}) -> boolWrites the model directly to disk from a JSON/Python Dictionary.
Args: model (dict): A dictionary representation of a LtmApi model