def test_Circle_Subvector_Plot(monkeypatch):
    monkeypatch.setattr(plt, 'show', lambda: None)
    
    Circle = MakeCircle()
    Vector1 = Circle.cycles[0]
    Vector2 = hys.resample(Vector1, 30)
    Vector3 = hys.resample(Circle, 10)
    
    Vector1.plot()
    Vector2.plot()
    Vector3.plot(True)
    
    assert True == True
Beispiel #2
0
def test_compare(monkeypatch):

    ExpHys, AnalHys = getHys()
    AnalHys.recalculateCycles(peakProminence=0.0045)
    ExpHys.recalculateCycles(peakProminence=0.035 * 4.1 / 100 / 2)

    AnalHys = hys.resample(AnalHys, 10)
    ExpHys = hys.resample(ExpHys, 10)

    Diff, Diffs = hys.compareHys(AnalHys, ExpHys)

    test1 = abs(Diff - 6.79762) < 0.00001

    assert test1 == True
Beispiel #3
0
def test_comapre_basic():
    t = np.linspace(0, 4, 1000) * np.pi
    x = np.sin(t)
    y = np.cos(t) * t

    xy = np.column_stack([x, y])

    myHys = hys.Hysteresis(xy)
    myHys.plot(plotCycles=True)
    smallHys = hys.resample(myHys, 10)
    # samllHys.plot()

    out = hys.compareHys(smallHys, myHys)

    assert out[0] == 0


# t = np.linspace(0,4,1000)*np.pi
# x = np.sin(t)
# y = np.cos(t)*t

# xy = np.column_stack([x,y])

# myHys = hys.Hysteresis(xy)
# myHys.plot(plotCycles = True)
# smallHys = hys.reSample(myHys, 10)
# smallHys.xy[:,1] = smallHys.xy[:,1] / 4
# smallHys = hys.Hysteresis(smallHys.xy)

# smallHys.plot()
# # smallHys.xy[:,1] = smallHys.xy[:,1]/2

# out = hys.CompareHys(smallHys,myHys)
def test_DownSampled_Plotting(monkeypatch):
    """ Tests if the resampled hystresis can plot correctly """

    monkeypatch.setattr(plt, 'show', lambda: None)
    DamperHys = hys.Hysteresis(testHys2)

    downsampledHys = hys.resample(DamperHys, 20)
    downsampledHys.plot(plotCycles=True)
    plt.close()
    downsampledHys.plotCycles([2, 3])
    plt.close()
    downsampledHys.plotArea()
    plt.close()
    downsampledHys.plotSlope()
    plt.close()

    assert True == True
Beispiel #5
0
AnalHys.plotLoadProtocol(comparisonProtocol = ExpHys.loadProtocol)




"""
Now that each hysteresis has the same number of cycles, it's possible to
compare how "similar" each cycle is.

We will first shift each curve into a similar domain/range using the resample
functon. This will take each curve in the hystersis, and use linear 
interpolation to define 10 evenly spaced points along that curve.

"""
NsamplesPerCurve = 10
AnalHysDx = hys.resample(AnalHys, NsamplesPerCurve)
ExpHysDx = hys.resample(ExpHys, NsamplesPerCurve)

fig, ax = plt.subplots()
line1 = AnalHysDx.plot(True)
line2 = ExpHysDx.plot(True)
ax.lines[2].set_color('C3')
ax.lines[3].set_color('C2')
ax.set_xlabel('Drift (%)')
ax.set_ylabel('Force (kN)')
plt.minorticks_on()
ax.grid(which='major', color='grey', linewidth=0.5, alpha = 0.8)
ax.grid(b=True, which='minor', linewidth=0.5, alpha = 0.4)


plt.show()
Beispiel #6
0
# by recalculating the peaks with a prominence comand
AnalHys.recalculateCycles(peakProminence=0.005)
# AnalHys.plotLoadProtocol(comparisonProtocol = ExpHys.loadProtocol)

# Almost there! It looks like we are missing one of the Analysis points
# To get there, lets cut off the appropriate number of points
AnalHys = hys.Hysteresis(Wall_anal_xy[500:, :])
AnalHys.recalculateCycles(peakProminence=0.0045)
# AnalHys.plotLoadProtocol(comparisonProtocol = ExpHys.loadProtocol)

# =============================================================================
# resample
# =============================================================================

# Now we can resample and compare the curves!
AnalHysDx = hys.resample(AnalHys, 10)
ExpHysDx = hys.resample(ExpHys, 10)

fig, ax = plt.subplots()
AnalHysDx.plotLoadProtocol(comparisonProtocol=ExpHysDx.loadProtocol)

fig, ax = plt.subplots()
AnalHysDx.plot(True)
ExpHysDx.plot(True)

# fig, ax = plt.subplots()

Diff, Diffs = hys.compareHys(AnalHysDx, ExpHysDx)

# We can plot the difference over each cycle
fig, ax = plt.subplots()
Beispiel #7
0
basePoints = np.linspace(0, 1, 1000) * 2 * np.pi
testCirclex = np.cos(basePoints)
testCircley = np.sin(basePoints)
Circlexy = np.column_stack((testCirclex, testCircley))

Circle = hys.Hysteresis(Circlexy)

Circle.plot(plotCycles=True)
Circle.plotArea(plotCycles=True)
Circle.plotSlope(plotCycles=True, ylim=[-10, 10])
Circle.setPeaks()
fig, ax = Circle.plotCycles(plotCycles=True, plotPeaks=True)
# fig, ax = Circle.plotSubVector(0)

Vector1 = Circle.Cycles[0]
Vector2 = hys.resample(Vector1, 30)
Vector3 = hys.resample(Circle, 10)

Vector1.plot()
Vector2.plot()
Vector3.plot(True)

fig, ax = Circle.plot()
xy = Vector3.xy
plt.plot(xy[:, 0], xy[:, 1])
ax.set_xlabel('x')
ax.set_ylabel('y')
plt.minorticks_on()
ax.grid(which='major', color='grey', linewidth=0.5, alpha=0.8)
ax.grid(b=True, which='minor', linewidth=0.5, alpha=0.4)