VeraGridEngine.IO.others packageο
Submodulesο
VeraGridEngine.IO.others.anarede moduleο
- class VeraGridEngine.IO.others.anarede.PWFParser[source]ο
Bases:
object- to_veragrid() MultiCircuit[source]ο
Convert Anarede grid to VeraGrid :return:
- class VeraGridEngine.IO.others.anarede.PwfBus[source]ο
Bases:
object- to_veragrid(vg_dict: Dict[str, PwfVoltageGroup]) Bus[source]ο
- Parameters:
vg_dict
- Returns:
- class VeraGridEngine.IO.others.anarede.PwfNetwork[source]ο
Bases:
object- add_device(device)[source]ο
Add a device to the appropriate list based on its class type. :param device: :return:
- to_veragrid() MultiCircuit[source]ο
- Returns:
- class VeraGridEngine.IO.others.anarede.PwfStaticCompensator[source]ο
Bases:
objectStaticCompensator
- to_veragrid(bus_dict: Dict[int, Bus]) tuple[int, ControllableShunt][source]ο
- Parameters:
bus_dict
- Returns:
- class VeraGridEngine.IO.others.anarede.PwfTransformer[source]ο
Bases:
object- to_veragrid(bus_dict: Dict[int, Bus]) Transformer2W[source]ο
- Parameters:
bus_dict
- Returns:
VeraGridEngine.IO.others.dpx_parser moduleο
- VeraGridEngine.IO.others.dpx_parser.load_dpx(file_name, contraction_factor=1000) tuple[MultiCircuit | Any, Logger | Any][source]ο
Read DPX file :param file_name: file name :param contraction_factor: contraction factor :return: MultiCircuit
- VeraGridEngine.IO.others.dpx_parser.read_dpx_data(file_name)[source]ο
Read the DPX file into a structured dictionary :param file_name: :return:
- VeraGridEngine.IO.others.dpx_parser.reformat(val)[source]ο
Pick string and give it format :param val: string value :return: int, float or string
- VeraGridEngine.IO.others.dpx_parser.repack(data_structures, logger=<VeraGridEngine.basic_structures.Logger object>, verbose=False)[source]ο
Pack the values as DataFrames with headers where available :param data_structures: Raw data structures :param logger: logger (inherited) :param verbose: print extra stuff :return:
VeraGridEngine.IO.others.helper_pow2pp moduleο
- VeraGridEngine.IO.others.helper_pow2pp.add_new_buses_to_pandapower_net(new_buses, pandapower_net, voltage_level: Series, assign_id_column_if_not_set=True)[source]ο
- VeraGridEngine.IO.others.helper_pow2pp.connect_elements_to_switches_bus_breaker(all_switches: DataFrame, elements_connected_to_switches: DataFrame, pandapower_net: pandapower.pandapowerNet)[source]ο
- VeraGridEngine.IO.others.helper_pow2pp.connect_elements_to_switches_node_breaker(all_switches: DataFrame, pandapower_net: pandapower.pandapowerNet)[source]ο
- VeraGridEngine.IO.others.helper_pow2pp.create_and_match_buses_for_switches(pandapower_net, powsybl_net) DataFrame[source]ο
Parametersο
pandapower_net powsybl_net
Returnsο
pandapower only allows two types of switches: bus-bus switches and bus-element switches. In the first case, a switch is connected to two pandapower-buses, in the second case, a switch is connected to a pandapower-bus and an element from another pandapower-net-table. Only lines 2w-transformers and 3w-transformers are allowed as elements for a bus-element-switch.
powsybl models switches differently: The connections between switches and elements are defined by nodes. Either switches share nodes with other switches or elements or they share a connection via another node.
There are three cases: 1. A switch shares a node with an element.
a. In this case, if the element is a transformer or a line, the element-index will be referenced in the column βelementβ of table switch and the element type in the column βetβ. b. If the element is not a transformer or a line, we need to create a new bus between the element and the switch. The index of this new bus will then be referenced in the column βelementβ and the entry in column βetβ will be βbβ.
2. Two switches share a node. In this case, we need to create a new bus between the switches. It will be referenced in either the βbusβ- or the βelementβ-column. 3. The nodes of two switches have an internal connection via another node. In this case, for each of these nodes not directly referenced by any switch, we create a new bus. The new bus will be referenced by the switches in either the βbusβ- or the βelementβ-column.
- VeraGridEngine.IO.others.helper_pow2pp.create_and_match_buses_for_switches_per_voltage_level_bus_breaker(all_switches: DataFrame, elements_connected_to_switches: DataFrame, pandapower_net: pandapower.pandapowerNet, powsybl_net: pypowsybl.network.Network, voltage_level: Series) tuple[DataFrame, DataFrame][source]ο
- VeraGridEngine.IO.others.helper_pow2pp.create_and_match_buses_for_switches_per_voltage_level_node_breaker(all_switches: DataFrame, pandapower_net: pandapower.pandapowerNet, powsybl_net: pypowsybl.network.Network, voltage_level: Series) DataFrame[source]ο
- VeraGridEngine.IO.others.helper_pow2pp.create_new_buses(nodes: Sequence, highest_bus_index: int) tuple[DataFrame, int][source]ο
- VeraGridEngine.IO.others.helper_pow2pp.drop_irrelevant_columns(element_table: DataFrame, element_type: str) DataFrame[source]ο
VeraGridEngine.IO.others.ipa_parser moduleο
- VeraGridEngine.IO.others.ipa_parser.load_iPA(file_name) MultiCircuit[source]ο
Read the nutsβ Indra file format :param file_name: json file name :return: MultiCircuit
VeraGridEngine.IO.others.pandapower_parser moduleο
- class VeraGridEngine.IO.others.pandapower_parser.Panda2VeraGrid(file_or_net: str | 'pandapowerNet', logger: Logger | None = None)[source]ο
Bases:
object- extract_tap_changers(row) TapChanger | None[source]ο
# Tap changer mapping (pandapower β GridCal) # # Ratio + tap_step_percent only: # dV = tap_step_percent / 100 # asymmetry_angle = 0Β° # # Ratio + tap_step_percent + tap_step_degree (cross regulator): # Ξ΄u = tap_step_percent / 100 # Ξ± = tap_step_degree (phase shift per tap, deg) # # Conversion (UCTE): # tan(Ξ±) = (Ξ΄u Β· sinΞ) / (1 + Ξ΄u Β· cosΞ) # β Ξ = Ξ± + arcsin(sin(Ξ±) / Ξ΄u) # # If Ξ΄u = 0 or |sin(Ξ±)| > Ξ΄u: # Fallback β treat as Ideal phase shifter: # dV = 0 # asymmetry_angle = Ξ± # # Symmetrical: # dV = tap_step_percent / 100 # asymmetry_angle = 90Β° # # Ideal: # dV = 0 # asymmetry_angle = tap_step_degree For βSymmetricalβ and βIdealβ, mapping stays as before.
- get_api_object_by_registry(panda_type: str, panda_code: int) Generator | Battery | Load | ExternalGrid | StaticGenerator | Shunt | ControllableShunt | CurrentInjection | Line | DcLine | Transformer2W | HvdcLine | VSC | UPFC | Winding | Switch | SeriesReactance | FluidNode | FluidPath | FluidP2x | FluidTurbine | FluidPump | Substation | Bus | BusBar | VoltageLevel | Country | Region | Community | Municipality | Area | Zone | Transformer3W | TransformerNW | OverheadLineType | Wire | TransformerType | EmissionGas | BranchGroup | LineLocations | LineLocation | ModellingAuthority | Facility | Fuel | Investment | InvestmentsGroup | Contingency | ContingencyGroup | RemedialAction | RemedialActionGroup | Technology | Owner | UndergroundLineType | SequenceLineType | RmsModelTemplate | EmtModelTemplate | FmuTemplate | RmsEvent | RmsEventsGroup | ShortCircuitEvent | IfMeasurement | ItMeasurement | QfMeasurement | PfMeasurement | QtMeasurement | PtMeasurement | QiMeasurement | PiMeasurement | VmMeasurement | VaMeasurement | PgMeasurement | QgMeasurement | None[source]ο
Get a previously registered veragrid object from a pandapower table-key :param panda_type: table name :param panda_code: index key :return: VeraGrid object
- get_multicircuit(convert_switches: bool = True) MultiCircuit[source]ο
Get a VeraGrid Multi-circuit from a PandaPower grid :return: MultiCircuit
- parse_buses(grid: MultiCircuit) Dict[str | int, Bus][source]ο
Add buses to the VeraGrid grid based on Pandapower data :param grid: MultiCircuit grid :return: PP row name or index to VeraGrid Bus object
- parse_external_grids(grid: MultiCircuit, bus_dictionary: Dict[str, Bus])[source]ο
Add external grid (slack bus) generators to the VeraGrid grid :param grid: MultiCircuit grid :param bus_dictionary: :return:
- parse_generators(grid: MultiCircuit, bus_dictionary: Dict[str, Bus])[source]ο
Add synchronous generators (row) to the VeraGrid grid :param grid: MultiCircuit grid :param bus_dictionary: :return:
- parse_impedances(grid: MultiCircuit, bus_dictionary: Dict[str, Bus])[source]ο
Add impedances to the VeraGrid grid :param grid: MultiCircuit grid :param bus_dictionary: :return:
- parse_lines(grid: MultiCircuit, bus_dictionary: Dict[str, Bus])[source]ο
Add lines (conductors) to the VeraGrid grid :param grid: MultiCircuit grid :param bus_dictionary:
- parse_loads(grid: MultiCircuit, bus_dictionary: Dict[str, Bus])[source]ο
Add loads to the VeraGrid grid based on Pandapower data :param grid: MultiCircuit grid :param bus_dictionary:
- parse_measurements(grid: MultiCircuit)[source]ο
- Parameters:
grid
- Returns:
- parse_shunts(grid: MultiCircuit, bus_dictionary: Dict[str, Bus])[source]ο
Add shunts to the VeraGrid grid based on Pandapower data :param grid: MultiCircuit grid :param bus_dictionary:
- parse_static_generators(grid: MultiCircuit, bus_dictionary: Dict[str, Bus])[source]ο
Add synchronous generators (row) to the VeraGrid grid :param grid: MultiCircuit grid :param bus_dictionary: :return:
- parse_storage(grid: MultiCircuit, bus_dictionary: Dict[str, Bus])[source]ο
Add storages to the VeraGrid grid :param grid: MultiCircuit grid :param bus_dictionary: :return:
- parse_switches(grid: MultiCircuit, bus_dictionary: Dict[str | int, Bus])[source]ο
See: https://pandapower.readthedocs.io/en/latest/elements/switch.html :param grid: MultiCircuit grid :param bus_dictionary: :return:
- parse_transformers(grid: MultiCircuit, bus_dictionary: Dict[str, Bus])[source]ο
Add transformers to the VeraGrid grid :param grid: MultiCircuit grid :param bus_dictionary:
- parse_transformers3W(grid: MultiCircuit, bus_dictionary: Dict[str, Bus])[source]ο
Add 3W transformers to the VeraGrid grid :param grid: MultiCircuit grid :param bus_dictionary:
- register(panda_type: str, panda_code: int, api_obj: Generator | Battery | Load | ExternalGrid | StaticGenerator | Shunt | ControllableShunt | CurrentInjection | Line | DcLine | Transformer2W | HvdcLine | VSC | UPFC | Winding | Switch | SeriesReactance | FluidNode | FluidPath | FluidP2x | FluidTurbine | FluidPump | Substation | Bus | BusBar | VoltageLevel | Country | Region | Community | Municipality | Area | Zone | Transformer3W | TransformerNW | OverheadLineType | Wire | TransformerType | EmissionGas | BranchGroup | LineLocations | LineLocation | ModellingAuthority | Facility | Fuel | Investment | InvestmentsGroup | Contingency | ContingencyGroup | RemedialAction | RemedialActionGroup | Technology | Owner | UndergroundLineType | SequenceLineType | RmsModelTemplate | EmtModelTemplate | FmuTemplate | RmsEvent | RmsEventsGroup | ShortCircuitEvent | IfMeasurement | ItMeasurement | QfMeasurement | PfMeasurement | QtMeasurement | PtMeasurement | QiMeasurement | PiMeasurement | VmMeasurement | VaMeasurement | PgMeasurement | QgMeasurement)[source]ο
Register a panda object and itβs associated VeraGrid object :param panda_type: table name :param panda_code: index key :param api_obj: VeraGrid object
- VeraGridEngine.IO.others.pandapower_parser.is_pandapower_file(file_path: str)[source]ο
Check if this is a pandapower file :param file_path: :return:
- VeraGridEngine.IO.others.pandapower_parser.is_pandapower_json(file_path)[source]ο
Check if a file is pandapower JSON :param file_path: :return:
VeraGridEngine.IO.others.plx_parser moduleο
- class VeraGridEngine.IO.others.plx_parser.PlexosBattery(name='', category='')[source]ο
Bases:
PlxGenerator
- class VeraGridEngine.IO.others.plx_parser.PlxBusMode(value)[source]ο
Bases:
Enum- NONE = 4ο
- PQ = 1ο
- PV = 2ο
- REF = 3ο
- STO_DISPATCH = 5ο
- class VeraGridEngine.IO.others.plx_parser.PlxGenerator(name='', category='', p_max=0, p_min=0, node=None)[source]ο
Bases:
PlxElement
- class VeraGridEngine.IO.others.plx_parser.PlxLine(name='', units=1, node_from=None, node_to=None, r=0.0, x=0.0, rate_max=0.0, rate_min=0.0)[source]ο
Bases:
PlxElement
- class VeraGridEngine.IO.others.plx_parser.PlxModel(fname, load_profiles=True, text_func=None, prog_func=None)[source]ο
Bases:
object- get_all_branches_dictionary()[source]ο
Returns a dictionary with all the Branches by the name :return: dictionary name -> object
- get_branch_ratings(n=None)[source]ο
Get DataFrame with the dynamic branch ratings :param n: number of time steps to extrapolate the profile :return: DataFrame
- get_buses_dictionary()[source]ο
Get dictionary relating the bus name to the latitude, longitude, voltage and name >>> bus_dict[name] >>> latitude, longitude, voltage, name :return: dictionary
- load_profile(path, zip_file_pointer=None)[source]ο
Attempt loading the profile :param path: relative or absolute path :param zip_file_pointer: pointer to open zip file is the file ins inside a zip file :return: DataFrame
- load_profile_if_necessary(key, path, zip_file_pointer=None)[source]ο
Load a profile is necessary :param key: object property type :param path: relative or absolute path where to find the file :param zip_file_pointer: pointer to open zip file is the file ins inside a zip file :return: Nothing
- load_project_file(fname)[source]ο
Load a PLEXOS project file :param fname: name of the plexos project file (*.zip, *.xml, *.xlsx)
- parse_data(objects, memberships, properties, zip_file_pointer=None)[source]ο
Pass the loaded DataFrames to model objects :param objects: Objects DataFrame :param memberships: Memberships DataFrame :param properties: Properties DataFrame :param zip_file_pointer: zip file pointer. If not None the data will be read from a zip file :return: Nothing
- static parse_excel(fname)[source]ο
Parse excel export of the plexos file :param fname: complete path to the file
- class VeraGridEngine.IO.others.plx_parser.PlxNode(name='', zone='', region='', voltage=0, latitude=0, longitude=0)[source]ο
Bases:
PlxElement
- class VeraGridEngine.IO.others.plx_parser.PlxRegion(name='')[source]ο
Bases:
PlxElement
- class VeraGridEngine.IO.others.plx_parser.PlxZone(name='')[source]ο
Bases:
PlxElement
- class VeraGridEngine.IO.others.plx_parser.XmlDictConfig(parent_element, text_to_remove='')[source]ο
Bases:
dictNote: need to add a root into if no exising Example usage: >>> tree = ElementTree.parse(βyour_file.xmlβ) >>> root = tree.getroot() >>> xmldict = XmlDictConfig(root) Or, if you want to use an XML string: >>> root = ElementTree.XML(xml_string) >>> xmldict = XmlDictConfig(root) And then use xmldict for what it isβ¦ a dict.
- VeraGridEngine.IO.others.plx_parser.get_st_generation_sent_out(plexos_results_folder)[source]ο
Get the generation auxiliary use from a PLEXOS results folder :param plexos_results_folder: PLEXOS results folder :return: pandas DataFrame with the generation dispatch
- VeraGridEngine.IO.others.plx_parser.get_st_node_load(plexos_results_folder, parse_dates=False)[source]ο
Get the node load use from a PLEXOS results folder :param plexos_results_folder: PLEXOS results folder :param parse_dates: Parse the dates? :return: pandas DataFrame with the node load
- VeraGridEngine.IO.others.plx_parser.plx_to_veragrid(mdl: PlxModel, plexos_results_folder, time_indices=None, text_func=None, prog_func=None)[source]ο
Reads plexos model with results and creates a VeraGrid model :param mdl: Plexos model instance :param plexos_results_folder: plexos results folder :param time_indices: time indices to sample :param text_func: :param prog_func: :return: MultiCircuit instance
VeraGridEngine.IO.others.pow2pp moduleο
- VeraGridEngine.IO.others.pow2pp.add_tap_parameters_for_3w_phase_tap_changer(powsybl_net: pypowsybl.network.Network, trafo_table: DataFrame) DataFrame[source]ο
Add phase tap changer parameters for 3-winding transformers
- VeraGridEngine.IO.others.pow2pp.add_tap_parameters_for_3w_ratio_tap_changer(powsybl_net: pypowsybl.network.Network, trafo_table: DataFrame) DataFrame[source]ο
Add ratio tap changer parameters for 3-winding transformers
- VeraGridEngine.IO.others.pow2pp.add_tap_parameters_for_phase_tap_changer(powsybl_net: pypowsybl.network.Network, trafo_table: DataFrame) DataFrame[source]ο
Comprehensive phase tap changer parameter calculation
- VeraGridEngine.IO.others.pow2pp.add_tap_parameters_for_ratio_tap_changer(powsybl_net: pypowsybl.network.Network, trafo_table: DataFrame) DataFrame[source]ο
Comprehensive ratio tap changer parameter calculation
- VeraGridEngine.IO.others.pow2pp.calculate_3w_impedance_parameters(trafo_table: DataFrame, conv: Literal['pairwise_min', 'global_max', 'common_ref'] = 'pairwise_min', ref_winding: str = 'hv', Sbase_common: float | None = None) None[source]ο
Convert star-leg impedances (r1,x1,r2,x2,r3,x3 in ohm) to vk_/vkr_ percent fields.
Parametersο
- trafo_tablepd.DataFrame
Must contain columns: r1,x1,r2,x2,r3,x3, vn_hv_kv, vn_mv_kv, vn_lv_kv, rated_s1/rated_s2/rated_s3 (MVA)
- conv{βpairwise_minβ,βglobal_maxβ,βcommon_refβ}
- Which S-base convention to use:
βpairwise_minβ: use S_base for each pair = min(sn_w1, sn_w2) (powsybl-style)
βglobal_maxβ: use S_base = max(sn_hv, sn_mv, sn_lv) for all pairs
βcommon_refβ: use a single Sbase_common and a single ref_winding for Vref
- ref_winding{βhvβ,βmvβ,βlvβ}
Used only when conv == βcommon_refβ.
- Sbase_commonfloat | None
If provided used as Sbase in βcommon_refβ; otherwise uses max rated winding.
- VeraGridEngine.IO.others.pow2pp.calculate_3w_iron_losses(trafo_table: DataFrame) None[source]ο
Calculate iron losses for 3-winding transformers
- VeraGridEngine.IO.others.pow2pp.calculate_detailed_tap_parameters(trafo_table: DataFrame, idx: int, steps: DataFrame, tap_type: str) None[source]ο
Map powsybl tap data to pandapower so that the current tap position is accurate. This is only good for the snapshot anaylsis. (tap_pos cannot be changed in
pandapower, the position should be changed in powsybl)
- VeraGridEngine.IO.others.pow2pp.calculate_iron_losses_and_open_loop_losses(trafo_table: DataFrame) None[source]ο
Calculate iron losses with proper defaults
- VeraGridEngine.IO.others.pow2pp.calculate_short_circuit_voltage(trafo_table: DataFrame) None[source]ο
Calculate short circuit voltage parameters for transformers with proper defaults
- VeraGridEngine.IO.others.pow2pp.convert_to_pandapower(network: pp.network.Network) pdp.pandapowerNet[source]ο
Convert pypowsybl network to pandapower network
- VeraGridEngine.IO.others.pow2pp.create_buses(pandapower_net: pdp.pandapowerNet, powsybl_net: pp.network.Network) None[source]ο
Create buses from pypowsybl network, handling UUID suffixes
- VeraGridEngine.IO.others.pow2pp.create_generators(pandapower_net: pdp.pandapowerNet, powsybl_net: pp.network.Network) None[source]ο
Create generators from pypowsybl network, excluding slack generators
- VeraGridEngine.IO.others.pow2pp.create_intermediate_bus(pandapower_net: pandapower.pandapowerNet, vl_id: str, powsybl_net) int[source]ο
Create an intermediate bus for element-element switches
- VeraGridEngine.IO.others.pow2pp.create_lines(pandapower_net: pdp.pandapowerNet, powsybl_net: pp.network.Network) None[source]ο
Create lines from pypowsybl network
- VeraGridEngine.IO.others.pow2pp.create_loads(pandapower_net: pdp.pandapowerNet, powsybl_net: pp.network.Network) None[source]ο
Create loads from pypowsybl network
- VeraGridEngine.IO.others.pow2pp.create_or_get_bus_for_node(pandapower_net: pandapower.pandapowerNet, node_id: int, nb_topology, powsybl_net) int[source]ο
Create or get a pandapower bus for a node
- VeraGridEngine.IO.others.pow2pp.find_bus_ids(element_table: DataFrame, pandapower_net: pandapower.pandapowerNet, target_column_name: str = 'bus', column_name_element_table: str = 'bus_id') DataFrame[source]ο
Simplified version that doesnβt rely on the identifier column
- VeraGridEngine.IO.others.pow2pp.get_bus_index(pandapower_net: pdp.pandapowerNet, bus_id: str) Any | None[source]ο
Get pandapower bus index from powsybl bus ID
- VeraGridEngine.IO.others.pow2pp.get_pandapower_bus_index(pandapower_net: pandapower.pandapowerNet, bus_id: str) Any | None[source]ο
Get pandapower bus index from powsybl bus ID
VeraGridEngine.IO.others.pypsa_parser moduleο
- class VeraGridEngine.IO.others.pypsa_parser.PyPSAParser[source]ο
Bases:
object- parse() MultiCircuit[source]ο
Parses the PyPSA network. :return: the VeraGrid circuit object.
- VeraGridEngine.IO.others.pypsa_parser.parse_pypsa_hdf5(file_path: str, logger: Logger) MultiCircuit[source]ο
Parses the HDF5 store file using the PyPSA library. :param file_path: the file path :param logger: a logger to produce warnings and/or errors. :return: the VeraGrid circuit object
- VeraGridEngine.IO.others.pypsa_parser.parse_pypsa_netcdf(file_path: str, logger: Logger) MultiCircuit[source]ο
Parses the netCDF file using the PyPSA library. :param file_path: the file path :param logger: a logger to produce warnings and/or errors. :return: the VeraGrid circuit object
- VeraGridEngine.IO.others.pypsa_parser.pypsa2veragrid(network: pypsa.Network, logger: Logger) MultiCircuit[source]ο
- Parameters:
network
logger
- Returns:
VeraGridEngine.IO.others.rte_parser moduleο
- VeraGridEngine.IO.others.rte_parser.find_class_name(child: Element)[source]ο
Try to find the CIM class name :param child: XML element :return: class name
- VeraGridEngine.IO.others.rte_parser.find_id(child: Element)[source]ο
Try to find the ID of an element :param child: XML element :return: RDFID
- VeraGridEngine.IO.others.rte_parser.parse_xml_text(text_lines: List[str]) Dict[source]ο
Fill the XML into the objects :param text_lines: list of text lines :return Dictionary representing the XML
- VeraGridEngine.IO.others.rte_parser.parse_xml_to_dict(xml_element: Element)[source]ο
Parse element into dictionary :param xml_element: XML element :return: Dictionary representing the XML
- VeraGridEngine.IO.others.rte_parser.read_cgmes_files(cim_files: List[str] | str, logger: DataLogger) Dict[str, List[str]][source]ο
Reads a list of .zip or xml into a dictionary of file name -> list of text lines :param cim_files: list of file names :param logger: DataLogger instance :return: dictionary of file name -> list of text lines