Skip to content

Commit

Permalink
Merge branch 'refs/heads/devel'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.idea/workspace.xml
  • Loading branch information
SanPen committed Oct 2, 2024
2 parents 49c49e1 + 2af93e8 commit d733acf
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/GridCal/Gui/Diagrams/MapWidget/grid_map_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,10 +1278,10 @@ def plot_substation(self, i: int, api_object: Substation):
if results is not None:
if isinstance(results, PowerFlowTimeSeriesResults):
table = results.mdl(result_type=ResultTypes.BusVoltageModule)
table.plot_device(ax=ax_2, device_idx=i)
table.plot_device(ax=ax_2, device_idx=i, title="Power flow")
elif isinstance(results, OptimalPowerFlowTimeSeriesResults):
table = results.mdl(result_type=ResultTypes.BusVoltageModule)
table.plot_device(ax=ax_2, device_idx=i)
table.plot_device(ax=ax_2, device_idx=i, title="Optimal power flow")

# Injections
# filter injections by bus
Expand Down
4 changes: 2 additions & 2 deletions src/GridCal/Gui/Diagrams/SchematicWidget/schematic_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -3737,10 +3737,10 @@ def plot_bus(self, i: int, api_object: Bus):
if results is not None:
if isinstance(results, PowerFlowTimeSeriesResults):
table = results.mdl(result_type=ResultTypes.BusVoltageModule)
table.plot_device(ax=ax_2, device_idx=i)
table.plot_device(ax=ax_2, device_idx=i, title="Power flow")
elif isinstance(results, OptimalPowerFlowTimeSeriesResults):
table = results.mdl(result_type=ResultTypes.BusVoltageModule)
table.plot_device(ax=ax_2, device_idx=i)
table.plot_device(ax=ax_2, device_idx=i, title="Optimal power flow")

# Injections
# filter injections by bus
Expand Down
19 changes: 10 additions & 9 deletions src/GridCal/Gui/Diagrams/base_diagram_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from typing import List, Dict, Union, Tuple, Callable, TYPE_CHECKING
import numpy as np
import cv2
from docutils.nodes import title
from matplotlib import pyplot as plt

from PySide6.QtCore import Qt
Expand Down Expand Up @@ -325,47 +326,47 @@ def plot_branch(self, i: int, api_object: Union[Line, DcLine, Transformer2W, VSC
if isinstance(results, PowerFlowTimeSeriesResults):

Sf_table = results.mdl(result_type=ResultTypes.BranchActivePowerFrom)
Sf_table.plot_device(ax=ax_1, device_idx=i)
Sf_table.plot_device(ax=ax_1, device_idx=i, title="Power flow")

loading_table = results.mdl(result_type=ResultTypes.BranchLoading)
loading_table.convert_to_cdf()
loading_table.plot_device(ax=ax_2, device_idx=i)
loading_table.plot_device(ax=ax_2, device_idx=i, title="Power loading")
any_plot = True

elif isinstance(results, LinearAnalysisTimeSeriesResults):

Sf_table = results.mdl(result_type=ResultTypes.BranchActivePowerFrom)
Sf_table.plot_device(ax=ax_1, device_idx=i)
Sf_table.plot_device(ax=ax_1, device_idx=i, title="Linear flow")

loading_table = results.mdl(result_type=ResultTypes.BranchLoading)
loading_table.convert_to_cdf()
loading_table.plot_device(ax=ax_2, device_idx=i)
loading_table.plot_device(ax=ax_2, device_idx=i, title="Linear loading")
any_plot = True

elif isinstance(results, ContingencyAnalysisTimeSeriesResults):

Sf_table = results.mdl(result_type=ResultTypes.MaxContingencyFlows)
Sf_table.plot_device(ax=ax_1, device_idx=i)
Sf_table.plot_device(ax=ax_1, device_idx=i, title="Contingency flow")

loading_table = results.mdl(result_type=ResultTypes.MaxContingencyLoading)
loading_table.convert_to_cdf()
loading_table.plot_device(ax=ax_2, device_idx=i)
loading_table.plot_device(ax=ax_2, device_idx=i, title="Contingency loading")
any_plot = True

elif isinstance(results, OptimalPowerFlowTimeSeriesResults):

Sf_table = results.mdl(result_type=ResultTypes.BranchActivePowerFrom)
Sf_table.plot_device(ax=ax_1, device_idx=i)
Sf_table.plot_device(ax=ax_1, device_idx=i, title="Optimal power flow")

loading_table = results.mdl(result_type=ResultTypes.BranchLoading)
loading_table.convert_to_cdf()
loading_table.plot_device(ax=ax_2, device_idx=i)
loading_table.plot_device(ax=ax_2, device_idx=i, title="Optimal loading")
any_plot = True

elif isinstance(results, StochasticPowerFlowResults):
loading_table = results.mdl(result_type=ResultTypes.BranchLoadingAverage)
loading_table.convert_to_cdf()
loading_table.plot_device(ax=ax_2, device_idx=i)
loading_table.plot_device(ax=ax_2, device_idx=i, title="Stochastic loading")
any_plot = True

if any_plot:
Expand Down
2 changes: 1 addition & 1 deletion src/GridCal/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
_current_year_ = datetime.datetime.now().year

# do not forget to keep a three-number version!!!
__GridCal_VERSION__ = "5.1.46"
__GridCal_VERSION__ = "5.1.48"

url = 'https://github.com/SanPen/GridCal'

Expand Down
9 changes: 8 additions & 1 deletion src/GridCalEngine/Devices/Associations/association.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, device_type: DeviceType):
self._device_type = device_type

@property
def data(self):
def data(self) -> Dict[str, Association]:
"""
:return:
Expand Down Expand Up @@ -168,6 +168,13 @@ def to_dict(self) -> List[Dict[str, Union[str, float]]]:
"""
return [val.to_dict() for _, val in self._data.items()]

def to_list(self) -> List[ALL_DEV_TYPES]:
"""
Get a list of the associated api objects
:return:
"""
return [val.api_object for _, val in self._data.items()]

def parse(self,
data: List[Dict[str, Union[str, float]]],
elements_dict: Dict[str, ALL_DEV_TYPES],
Expand Down
11 changes: 10 additions & 1 deletion src/GridCalEngine/Devices/Parents/injection_parent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from __future__ import annotations
from typing import Union, TYPE_CHECKING
from typing import Union, List, TYPE_CHECKING
import numpy as np

from GridCalEngine.Devices.Parents.physical_device import PhysicalDevice
Expand All @@ -28,6 +28,7 @@

if TYPE_CHECKING:
from GridCalEngine.Devices import Technology
from GridCalEngine.Devices.types import ALL_DEV_TYPES


class InjectionParent(PhysicalDevice):
Expand Down Expand Up @@ -236,3 +237,11 @@ def associate_technology(self, tech: Technology, val=1.0):
:return:
"""
self.technologies.add_object(tech, val=val)

@property
def tech_list(self) -> List[ALL_DEV_TYPES]:
"""
Bus
:return: Bus
"""
return self.technologies.to_list()
6 changes: 4 additions & 2 deletions src/GridCalEngine/Simulations/results_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,18 @@ def plot(self, ax=None, selected_col_idx=None, selected_rows=None, stacked=False
except TypeError:
print('No numeric data to plot...')

def plot_device(self, ax=None, device_idx: int = 0, stacked=False):
def plot_device(self, ax=None, device_idx: int = 0, stacked=False, title: str = ""):
"""
Plot the data model
:param ax: Matplotlib axis
:param device_idx: list of selected column indices
:param stacked: Stack plot?
:param title: Title of the plot
"""
index, columns, data = self.get_data()

columns = [columns[device_idx]]
# columns = [columns[device_idx]]
columns = [self.title] if title == "" else [title]
data = data[:, device_idx]

if ax is None:
Expand Down
2 changes: 1 addition & 1 deletion src/GridCalEngine/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
_current_year_ = datetime.datetime.now().year

# do not forget to keep a three-number version!!!
__GridCalEngine_VERSION__ = "5.1.46"
__GridCalEngine_VERSION__ = "5.1.48"

url = 'https://github.com/SanPen/GridCal'

Expand Down
2 changes: 1 addition & 1 deletion src/GridCalServer/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
_current_year_ = datetime.datetime.now().year

# do not forget to keep a three-number version!!!
__GridCalServer_VERSION__ = "5.1.46"
__GridCalServer_VERSION__ = "5.1.48"

url = 'https://github.com/SanPen/GridCal'

Expand Down

0 comments on commit d733acf

Please sign in to comment.