Skip to content

Commit

Permalink
[NF] identify main loadcase depending on selected speed
Browse files Browse the repository at this point in the history
  • Loading branch information
helene-t committed Jun 30, 2022
1 parent c7a4dba commit 5c7455f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 34 deletions.
21 changes: 19 additions & 2 deletions SciDataTool/GUI/DDataPlotter/DDataPlotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from matplotlib.patches import Rectangle
from matplotlib.collections import PathCollection, QuadMesh
from matplotlib.text import Annotation
from numpy import array, allclose
from numpy import array, allclose, argmin, argmax, where, abs as np_abs
from SciDataTool.Functions.is_axes_in_order import is_axes_in_order
from SciDataTool.Functions.Plot import TEXT_BOX
from SciDataTool.Classes.Norm_ref import Norm_ref
Expand Down Expand Up @@ -374,7 +374,7 @@ def format_coord(x, y, z=None, sep=", ", ind=None):

# Add hidden annotations
if annotations != [] and not annotations[0]._visible and is_annot:
for annotation in annotations:
for ii, annotation in enumerate(annotations):
if annotation._x == x and annotation._y == y:
label += sep + annotation._text

Expand Down Expand Up @@ -423,6 +423,23 @@ def set_cursor(event):
and "Overall" not in legend
):
annot = annotations[self.ax.lines.index(plot_obj)]._text
if "main " in annot:
speed_index = argmin(
np_abs(self.data.get_axes("speed")[0].get_values() - X)
)
H = "H" + legend.split("H")[1].split(" ")[0]
order_index = [
True if H in string else False
for string in self.data.get_axes("order")[
0
].get_values()
].index(True)
loadcases = self.data.get_axes("loadcases")[0].get_values()
lc_index = argmax(
self.data.values[speed_index, order_index, :]
)
main_lc = loadcases[lc_index]
annot += main_lc
elif isinstance(plot_obj, PathCollection):
X = plot_obj.get_offsets().data[ind][0][0]
Y = plot_obj.get_offsets().data[ind][0][1]
Expand Down
35 changes: 3 additions & 32 deletions SciDataTool/Methods/DataND/plot_2D_Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,39 +789,10 @@ def plot_2D_Data(
if annotations is not None:
try:
annot = list()
axis_along = self.get_axes(annotations[0])[0]
axis_op = self.get_axes(annotations[1])[0]
operation = annotations[2]
arg_list_new = []
if self.unit == "W":
op = "=sum"
else:
op = "=rss"
for axis in self.get_axes():
if axis.name not in [axis_along.name, axis_op.name]:
arg_list_new.append(axis.name + op)
else:
arg_list_new.append(axis.name)
data2 = self.get_data_along(*arg_list_new, unit=unit)
arg_list_new = []
for arg in arg_list_along:
if axis_along.name in arg or axis_op.name in arg:
if "[" in arg:
arg_list_new.append(arg.split("[")[0])
else:
arg_list_new.append(
arg.replace("=sum", "").replace("=rss", "")
)
result = data2.get_magnitude_along(*arg_list_new)
for ii in range(len(result[annotations[0]])):
if operation == "max":
for ii in range(len(self.get_axes(annotations[0])[0].get_values())):
if annotations[2] == "max":
index = argmax(take(result[self.symbol], ii, axis=0))
annot.append(
"main "
+ annotations[1].rstrip("s")
+ ": "
+ axis_op.get_values()[index]
)
annot.append("main " + annotations[1].rstrip("s") + ": ")
# Keep only requested indices
annot = array(annot)[
axes_list[
Expand Down

0 comments on commit 5c7455f

Please sign in to comment.