Skip to content

Commit

Permalink
Gauss-Newton solving visualization (eitcom#67)
Browse files Browse the repository at this point in the history
Add Gauss-Newton generator implementation and update the example to include both the generator and non-generator version of the gauss-newton.
  • Loading branch information
ChabaneAmaury committed Oct 3, 2022
1 parent 0ded736 commit 7ac3e32
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions examples/eit_static_jac.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,26 @@
ax.set_title("Conductivities Reconstructed")

# Calculate then show the results
ds = eit.gn(v1, lamb_decay=0.1, lamb_min=1e-5, maxiter=20, verbose=True)
im = ax.tripcolor(xx, yy, tri, np.real(ds), alpha=1.0, cmap="viridis")
fig.colorbar(im)
# ds = eit.gn(v1, lamb_decay=0.1, lamb_min=1e-5, maxiter=20, verbose=True)
# im = ax.tripcolor(xx, yy, tri, np.real(ds), alpha=1.0, cmap="viridis")
# fig.colorbar(im)

# Real time update version
# colorbar = None
# for ds in eit.gn(v1, lamb_decay=0.1, lamb_min=1e-5, maxiter=20, verbose=True, generator=True):
# im = ax.tripcolor(xx, yy, tri, np.real(ds), alpha=1.0, cmap="viridis")
# if colorbar is not None:
# colorbar.remove()
# colorbar = fig.colorbar(im)
# fig.canvas.draw()
# fig.canvas.flush_events()
colorbar = None
for ds in eit.gn(
v1, lamb_decay=0.1, lamb_min=1e-5, maxiter=20, verbose=True, generator=True
):
im = ax.tripcolor(xx, yy, tri, np.real(ds), alpha=1.0, cmap="viridis")
if (
colorbar is not None
): # Update the colorbar as the min and max values are changing
colorbar.remove()
colorbar = fig.colorbar(im)
fig.canvas.draw() # Update the canvas
fig.canvas.flush_events() # Flush the drawing queue

# fig.savefig('../doc/images/demo_static.png', dpi=96)
print("Reconstruction time:", datetime.datetime.now() - start_time)
plt.show(block=True)
plt.show(
block=True
) # Very important when using the generator version, otherwise the program exits automatically

0 comments on commit 7ac3e32

Please sign in to comment.