Example #1
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)
Example #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
Example #3
0
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()

"""
The comparHys function can be used to guage how similar two hystereses are.
By default the function returns the average distance between each point on the
two curves. While the number alone may not be the most meaningful, it's 
magnitude will determine how similar different each cycle is. 

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


"""
We can plot the difference over each cycle, and view which cycles are the most
similar/different.

"""
fig, ax = plt.subplots()
plt.plot(Diffs)
ax.set_xlabel('Cycle (#)')
ax.set_ylabel('Avg. difference between Curves (unitless)')
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)