From 6df4bc1c888188f4de86d724346d512b32526cac Mon Sep 17 00:00:00 2001 From: Anurag Upadhyay <35711550+u-anurag@users.noreply.github.com> Date: Tue, 17 May 2022 14:38:43 -0700 Subject: [PATCH] Add helpers for fiber plot data --- vfo/internal_plotting_functions.py | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/vfo/internal_plotting_functions.py b/vfo/internal_plotting_functions.py index fe96d65..fe8199a 100644 --- a/vfo/internal_plotting_functions.py +++ b/vfo/internal_plotting_functions.py @@ -577,3 +577,62 @@ def _setStandardViewport(fig, ax, nodeCords, ndm, Disp = np.array([])): ax.set_zlabel('Z') return fig, ax + +# ============================================================================= +# Fiber Helpers +# ============================================================================= + +def _getAxisInfo(LocalAxis): + + if LocalAxis == 'z': + axisIndex = 1 + axisXlabel = "Local z value" + if LocalAxis == 'y': + axisIndex = 0 + axisXlabel = "Local y value" + + return axisIndex, axisXlabel + + +def _getResponseInfo(InputType): + if InputType == 'stress': + responseIndex = 3 + axisYlabel = "Fiber Stress" + if InputType == 'strain': + responseIndex = 4 + axisYlabel = "Fiber Strain" + + return responseIndex, axisYlabel + + + +def _getFiberBounds(fibrePositionSorted, fibreResponseSorted, Xbound, Ybound): + # Set up bounds based on data from + if Xbound == []: + xmin = 1.1*np.min(fibrePositionSorted) + xmax = 1.1*np.max(fibrePositionSorted) + else: + xmin = Xbound[0] + xmax = Xbound[1] + + if Ybound == []: + ymin = 1.1*np.min(fibreResponseSorted) + ymax = 1.1*np.max(fibreResponseSorted) + else: + ymin = Ybound[0] + ymax = Ybound[1] + + return xmin, xmax, ymin, ymax + + + +def _skipFiberData(fibrePositionSorted, fibreResponseSorted, fiberYPosition, skipStart, skipEnd): + # If end data is not being skipped, use the full vector length. + if skipEnd ==0: + skipEnd = len(fiberYPosition) + + # Remove unecessary data + xinputs = fibrePositionSorted[skipStart:skipEnd, :] + yinputs = fibreResponseSorted[skipStart:skipEnd, :] + + return xinputs, yinputs