本文整理匯總了Python中WaveBlocksND.BlockFactory.get_axes方法的典型用法代碼示例。如果您正苦於以下問題:Python BlockFactory.get_axes方法的具體用法?Python BlockFactory.get_axes怎麽用?Python BlockFactory.get_axes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WaveBlocksND.BlockFactory
的用法示例。
在下文中一共展示了BlockFactory.get_axes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: plot_frames
# 需要導入模塊: from WaveBlocksND import BlockFactory [as 別名]
# 或者: from WaveBlocksND.BlockFactory import get_axes [as 別名]
def plot_frames(PP, iom, blockid=0, load=False, eigentransform=False, timerange=None, view=None, path='.'):
"""Plot the wave function for a series of timesteps.
:param iom: An :py:class:`IOManager` instance providing the simulation data.
"""
parameters = iom.load_parameters()
if not parameters["dimension"] == 2:
print("No wavefunction of two space dimensions, silent return!")
return
if PP is None:
PP = parameters
if load is True:
# TODO: Implement reshaping
raise NotImplementedError("Loading of 2D grids is not implemented")
else:
G = BlockFactory().create_grid(PP)
if eigentransform:
V = BlockFactory().create_potential(parameters)
BT = BasisTransformationWF(V)
BT.set_grid(G)
WF = WaveFunction(parameters)
WF.set_grid(G)
N = WF.get_number_components()
timegrid = iom.load_wavefunction_timegrid(blockid=blockid)
if timerange is not None:
if len(timerange) == 1:
I = (timegrid == timerange)
else:
I = ((timegrid >= timerange[0]) & (timegrid <= timerange[1]))
if any(I):
timegrid = timegrid[I]
else:
raise ValueError("No valid timestep remains!")
u, v = G.get_axes()
u = real(u.reshape(-1))
v = real(v.reshape(-1))
# View
if view is not None:
if view[0] is None:
view[0] = u.min()
if view[1] is None:
view[1] = u.max()
if view[2] is None:
view[2] = v.min()
if view[3] is None:
view[3] = v.max()
for step in timegrid:
print(" Plotting frame of timestep # {}".format(step))
# Load the data
wave = iom.load_wavefunction(blockid=blockid, timestep=step)
values = [wave[j, ...] for j in range(parameters["ncomponents"])]
WF.set_values(values)
# Transform the values to the eigenbasis
if eigentransform:
BT.transform_to_eigen(WF)
Psi = WF.get_values()
# Plot
fig = figure()
for level in range(N):
# Wavefunction data
z = Psi[level]
z = z.reshape(G.get_number_nodes())
fig.add_subplot(N, 1, level + 1)
plotcf2d(u, v, z, darken=0.3, limits=view)
fig.savefig(os.path.join(path, "wavefunction_contour_block_%s_level_%d_timestep_%07d.png" % (blockid, level, step)))
close(fig)