mirror of
https://github.com/wassname/simpeg.git
synced 2026-07-02 13:41:17 +08:00
Animation added, need to figure out how to add the streamplot for current
This commit is contained in:
@@ -46,32 +46,29 @@ xx = mesh_sub.vectorCCx
|
||||
yy = mesh_sub.vectorCCy
|
||||
|
||||
#%% Solve
|
||||
txii = range(500,1500,200)
|
||||
jx_CC_sub = np.zeros((len(txii),mesh_sub.nCx,mesh_sub.nCy))
|
||||
jy_CC_sub = np.zeros((len(txii),mesh_sub.nCx,mesh_sub.nCy))
|
||||
txii = range(100,1900,20)
|
||||
#jx_CC_sub = np.zeros((len(txii),mesh_sub.nCx,mesh_sub.nCy))
|
||||
#jy_CC_sub = np.zeros((len(txii),mesh_sub.nCx,mesh_sub.nCy))
|
||||
|
||||
fig = plt.figure(figsize=(14,7))
|
||||
axs = plt.axes(ylim=(-800,0), xlim=(25,2000))
|
||||
im1 = axs.imshow([[],[]], alpha=0.75,extent = (xx[0],xx[-1],yy[-1],yy[0]),interpolation='nearest',vmin=-1e-2, vmax=1e-2)
|
||||
im2 = axs.imshow([[],[]],alpha=0.2,extent = (xx[0],xx[-1],yy[-1],yy[0]),interpolation='nearest',cmap='gray')
|
||||
#im3 = axs.streamplot(mesh_sub.vectorCCx, mesh_sub.vectorCCy, np.zeros((mesh_sub.nCy,mesh_sub.nCx)), np.zeros((mesh_sub.nCy,mesh_sub.nCx)),color='k')
|
||||
|
||||
|
||||
#==============================================================================
|
||||
# line1, = mesh_sub.plotImage([], ax = axs)
|
||||
# line2, = axs.streamplot([], [], [], [],color='k')
|
||||
#==============================================================================
|
||||
def init():
|
||||
im1.set_data([[],[]])
|
||||
im2.set_data([[],[]])
|
||||
return [im1]+[im2]
|
||||
|
||||
|
||||
|
||||
#==============================================================================
|
||||
# def init():
|
||||
# line1.set_data([])
|
||||
# line2.set_data([], [], [], [])
|
||||
# return line1, line2,
|
||||
#
|
||||
# def animate(ii):
|
||||
#==============================================================================
|
||||
def animate(ii):
|
||||
|
||||
|
||||
|
||||
for ii in range(len(txii)):
|
||||
#for ii in range(len(txii)):
|
||||
|
||||
|
||||
fig, axs = plt.subplots(1,1, figsize=(14,7))
|
||||
|
||||
tx = DC.SrcDipole([rx],txii[ii],txii[ii])
|
||||
|
||||
@@ -94,25 +91,24 @@ for ii in range(len(txii)):
|
||||
jy_CC = j_CC[mesh.nC:].reshape(mesh.nCy,mesh.nCx).T
|
||||
|
||||
#%% Grab only the core for presentation
|
||||
jx_CC_sub[ii,:,:] = jx_CC[padc:-padc,padc:]
|
||||
jy_CC_sub[ii,:,:] = jy_CC[padc:-padc,padc:]
|
||||
jx_CC_sub = jx_CC[padc:-padc,padc:]
|
||||
jy_CC_sub = jy_CC[padc:-padc,padc:]
|
||||
Q_sub = Q.reshape(mesh.nCy,mesh.nCx)
|
||||
Q_sub = Q_sub[padc:,padc:-padc]
|
||||
|
||||
J_rho = np.sqrt(jx_CC_sub[ii,:,:]**2 + jy_CC_sub[ii,:,:]**2)
|
||||
J_rho = np.sqrt(jx_CC_sub**2 + jy_CC_sub**2)
|
||||
lw = np.log10(J_rho/J_rho.min())
|
||||
|
||||
#==============================================================================
|
||||
# line1.set_data(model_sub)
|
||||
# line2.set_data(mesh_sub.vectorCCx, mesh_sub.vectorCCy, jx_CC_sub[2,:,:].T, jy_CC_sub[2,:,:].T)
|
||||
#==============================================================================
|
||||
axs.imshow(Q_sub,alpha=0.75,extent = (xx[0],xx[-1],yy[-1],yy[0]),interpolation='nearest',vmin=-1e-2, vmax=1e-2)
|
||||
axs.imshow(np.log10(model_sub.reshape(mesh_sub.nCy,mesh_sub.nCx)),alpha=0.2,extent = (xx[0],xx[-1],yy[-1],yy[0]),interpolation='nearest',cmap='gray')
|
||||
axs.streamplot(mesh_sub.vectorCCx, mesh_sub.vectorCCy, jx_CC_sub[ii,:,:].T, jy_CC_sub[ii,:,:].T,color='k',linewidth = lw.T)
|
||||
plt.ylim([-800,0])
|
||||
plt.xlim([25,2000])
|
||||
plt.show()
|
||||
#axs.imshow(Q_sub,alpha=0.75,extent = (xx[0],xx[-1],yy[-1],yy[0]),interpolation='nearest',vmin=-1e-2, vmax=1e-2)
|
||||
#axs.imshow(np.log10(model_sub.reshape(mesh_sub.nCy,mesh_sub.nCx)),alpha=0.2,extent = (xx[0],xx[-1],yy[-1],yy[0]),interpolation='nearest',cmap='gray')
|
||||
#im3 = axs.streamplot(mesh_sub.vectorCCx, mesh_sub.vectorCCy, jx_CC_sub.T, jy_CC_sub.T,color='k',linewidth = lw.T)
|
||||
|
||||
#plt.show()
|
||||
im1.set_array(Q_sub)
|
||||
im2.set_array(np.log10(model_sub.reshape(mesh_sub.nCy,mesh_sub.nCx)))
|
||||
#im2.set_array(mesh_sub.vectorCCx, mesh_sub.vectorCCy,jx_CC_sub.T,jy_CC_sub.T)
|
||||
|
||||
return [im1] + [im2]
|
||||
#%% Create widget
|
||||
|
||||
#def viewInv(msh,iteration):
|
||||
@@ -123,9 +119,7 @@ for ii in range(len(txii)):
|
||||
#%%
|
||||
#interact(viewInv,msh = mesh_sub, iteration = IntSlider(min=0, max=len(txii)-1 ,step=1, value=0))
|
||||
# set embed_frames=True to embed base64-encoded frames directly in the HTML
|
||||
#==============================================================================
|
||||
# anim = animation.FuncAnimation(fig, animate, init_func=init,
|
||||
# frames=100, interval=20, blit=True)
|
||||
#
|
||||
# anim.save('animation.html', writer=HTMLWriter(embed_frames=True))
|
||||
#==============================================================================
|
||||
anim = animation.FuncAnimation(fig, animate, init_func=init,
|
||||
frames=len(txii), interval=10)
|
||||
|
||||
anim.save('animation.html', writer=HTMLWriter(embed_frames=True))
|
||||
|
||||
+106
-24
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user