python - Interpolate a hysteresis loop -


i have working code interpolate hysteresis loop - want interpolation of various branches loop has, described hysteresis loop starting top right, going down via top left, lower left, lower right, ... 2 times in picture.

i want interpolate (here) 4 branches , have working code that, seems not quite nice me - first branch 1 top right, on top left, lower left. second branch 1 returning top right via lower right. third same first, fourth second, fifth first , third ... , on ...

one branch consists of many lines, want see mean value, code deliveres:

idx = 0 while running:     thiselem = x[idx]     idx = (idx + 1) % len(x)     nextelem = x[idx]     if thiselem < nextelem:         first_run_down = x[0:idx]         running = false f = interpolate.interp1d(first_run_down, y[0:idx]) xnew = np.linspace(np.max(first_run_down), np.min(first_run_down), num=int_points) xnews.append(xnew) fs.append(f(xnew)) plt.plot(xnew, f(xnew), 'b-', alpha=.2) print 'first run down till', idx, 'line.'  running = true idx_old = idx+1 idx = idx+1 while running:     thiselem = x[idx]     idx = (idx + 1) % len(x)     nextelem = x[idx]     if thiselem > nextelem:         first_run_up = x[idx_old:idx]         running = false g = interpolate.interp1d(first_run_up, y[idx_old:idx]) xnew_2 = np.linspace(np.max(first_run_up), np.min(first_run_up), num=int_points) xnews_2.append(xnew_2) gs.append(g(xnew_2)) plt.plot(xnew_2, g(xnew_2), 'b.', alpha=.2) 

where first_run_down first branch, first_run_up second ...

what irritates me, fact have add code, when have more 2 loops, , kind of stuck finding solution.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -