def plot_frames( iom, blockid=0 ): #, view=None, plotphase=True, plotcomponents=False, plotabssqr=False, imgsize=(12,9)): parameters = iom.load_parameters() if not parameters["dimension"] == 2: print("No wavefunction of two space dimensions, silent return!") return G = BlockFactory().create_grid(parameters) V = BlockFactory().create_potential(parameters) print(G.get_extensions()) WF = WaveFunction(parameters) WF.set_grid(G) BT = BasisTransformationWF(V) BT.set_grid(G) timegrid = iom.load_wavefunction_timegrid(blockid=blockid) u, v = G.get_nodes(split=True, flat=False) u = real(u) v = real(v) N = WF.get_number_components() for step in timegrid: print(" Plotting frame of timestep # " + str(step)) wave = iom.load_wavefunction(blockid=blockid, timestep=step) values = [wave[j, ...] for j in xrange(parameters["ncomponents"])] WF.set_values(values) # Transform the values to the eigenbasis # TODO: improve this: if parameters["algorithm"] == "fourier": BT.transform_to_eigen(WF) else: pass Psi = WF.get_values() fig = figure() for level in xrange(N): z = Psi[level] subplot(N, 1, level + 1) plotcm(z, darken=0.3) savefig("wavefunction_level_" + str(level) + "_timestep_" + (5 - len(str(step))) * "0" + str(step) + ".png") close(fig) print(" Plotting frames finished")
def plot_coefficients(parameters, data, blockid=0, imgsize=(10, 20), path='.'): """ :param parameters: A :py:class:`ParameterProvider` instance. :param timegrid: The timegrid that belongs to the coefficient values. :param coeffs: The coefficient values. :param imgsize: The size of the plot. For a large number of plotted coefficients, we might have to increase this value. """ print("Plotting the coefficients of data block '%s'" % blockid) # Check if we have enough coefficients to plot timegrid, coeffs = data # Plot for each of the N levels for jndex, coeff in enumerate(coeffs): # Scale the image to roughly fit the data shape v, u = coeff.shape imags = (imgsize[0], int(10 * v / float(u))) if imags[1] < 10000: imgsize = imags fig = figure(figsize=imgsize) ax = fig.gca() ax.matshow(abs(coeff)) ax.set_xlabel(r"$k$") ax.set_ylabel(r"$t$") ax.set_title(r"Coefficients $c_k^{%d}$" % jndex) fig.savefig(os.path.join(path, "wavepacket_coefficients_map_eigen_abs_block_"+str(blockid)+"_component_"+str(jndex)+GD.output_format)) close(fig) fig = figure(figsize=imgsize) ax = fig.gca() ax.matshow(angle(coeff)) ax.set_xlabel(r"$k$") ax.set_ylabel(r"$t$") ax.set_title(r"Coefficients $c_k^{%d}$" % jndex) fig.savefig(os.path.join(path, "wavepacket_coefficients_map_eigen_angle_block_"+str(blockid)+"_component_"+str(jndex)+GD.output_format)) close(fig) fig = figure(figsize=imgsize) ax = fig.gca() plotcm(coeff, angle(coeff), abs(coeff), darken=False, axes=ax) ax.set_xlabel(r"$k$") ax.set_ylabel(r"$t$") ax.set_title(r"Coefficients $c_k^{%d}$" % jndex) fig.savefig(os.path.join(path, "wavepacket_coefficients_map_eigen_cm_block_"+str(blockid)+"_component_"+str(jndex)+GD.output_format)) close(fig) fig = figure(figsize=imgsize) ax = fig.gca() plotcm(coeff, angle(coeff), abs(coeff), darken=True, axes=ax) ax.set_xlabel(r"$k$") ax.set_ylabel(r"$t$") ax.set_title(r"Coefficients $c_k^{%d}$" % jndex) fig.savefig(os.path.join(path, "wavepacket_coefficients_map_eigen_cm_darken_block_"+str(blockid)+"_component_"+str(jndex)+GD.output_format)) close(fig)
def plot_coefficients(parameters, data, index=0, imgsize=(10,20)): """ :param parameters: A :py:class:`ParameterProvider` instance. :param timegrid: The timegrid that belongs to the coefficient values. :param coeffs: The coefficient values. :param imgsize: The size of the plot. For a large number of plotted coefficients, we might have to increase this value. """ print("Plotting the coefficients of data block '"+str(index)+"'") # Check if we have enough coefficients to plot timegrid, coeffs = data # Plot for each of the N levels for jndex, coeff in enumerate(coeffs): # Scale the image to roughly fit the data shape v, u = coeff.shape imags = (imgsize[0], int(10*v / (1.0*u))) if imags[1] < 10000: imgsize = imags fig = figure(figsize=imgsize) ax = gca() ax.matshow(abs(coeff)) ax.set_xlabel("k") ax.set_ylabel("t") ax.set_title(r"Coefficients $c_k^"+str(jndex)+"$") fig.savefig("wavepacket_coefficients_map_abs_component"+str(jndex)+"_block"+str(index)+GD.output_format) close(fig) fig = figure(figsize=imgsize) ax = gca() ax.matshow(angle(coeff)) ax.set_xlabel("k") ax.set_ylabel("t") ax.set_title(r"Coefficients $c_k^"+str(jndex)+"$") fig.savefig("wavepacket_coefficients_map_angle_component"+str(jndex)+"_block"+str(index)+GD.output_format) close(fig) fig = figure(figsize=imgsize) ax = gca() plotcm(coeff, angle(coeff), abs(coeff), darken=False, axes=ax) ax.set_xlabel("k") ax.set_ylabel("t") ax.set_title(r"Coefficients $c_k^"+str(jndex)+"$") fig.savefig("wavepacket_coefficients_map_cm_component"+str(jndex)+"_block"+str(index)+GD.output_format) close(fig) fig = figure(figsize=imgsize) ax = gca() plotcm(coeff, angle(coeff), abs(coeff), darken=True, axes=ax) ax.set_xlabel("k") ax.set_ylabel("t") ax.set_title(r"Coefficients $c_k^"+str(jndex)+"$") fig.savefig("wavepacket_coefficients_map_cm_darken_component"+str(jndex)+"_block"+str(index)+GD.output_format) close(fig)
def plot_frames(iom, blockid=0):#, view=None, plotphase=True, plotcomponents=False, plotabssqr=False, imgsize=(12,9)): parameters = iom.load_parameters() if not parameters["dimension"] == 2: print("No wavefunction of two space dimensions, silent return!") return G = BlockFactory().create_grid(parameters) V = BlockFactory().create_potential(parameters) print(G.get_extensions()) WF = WaveFunction(parameters) WF.set_grid(G) BT = BasisTransformationWF(V) BT.set_grid(G) timegrid = iom.load_wavefunction_timegrid(blockid=blockid) u, v = G.get_nodes(split=True, flat=False) u = real(u) v = real(v) N = WF.get_number_components() for step in timegrid: print(" Plotting frame of timestep # " + str(step)) wave = iom.load_wavefunction(blockid=blockid, timestep=step) values = [ wave[j,...] for j in xrange(parameters["ncomponents"]) ] WF.set_values(values) # Transform the values to the eigenbasis # TODO: improve this: if parameters["algorithm"] == "fourier": BT.transform_to_eigen(WF) else: pass Psi = WF.get_values() fig = figure() for level in xrange(N): z = Psi[level] subplot(N,1,level+1) plotcm(z, darken=0.3) savefig("wavefunction_level_"+str(level)+"_timestep_"+(5-len(str(step)))*"0"+str(step)+".png") close(fig) print(" Plotting frames finished")
def plot_coefficients(parameters, data, blockid=0, imgsize=(10, 20), path='.'): """ :param parameters: A :py:class:`ParameterProvider` instance. :param imgsize: The size of the plot. For a large number of plotted coefficients, we might have to increase this value. """ print("Plotting the coefficients of data block '%s'" % blockid) # Check if we have enough coefficients to plot timegrid, coeffs = data # Plot for each of the N levels for jndex, coeff in enumerate(coeffs): # Scale the image to roughly fit the data shape v, u = coeff.shape imags = (imgsize[0], int(10 * v / float(u))) if imags[1] < 10000: imgsize = imags fig = figure(figsize=imgsize) ax = fig.gca() ax.matshow(abs(coeff)) ax.set_xlabel(r"$k$") ax.set_ylabel(r"$t$") ax.set_title(r"Coefficients $c_k^{%d}$" % jndex) fig.savefig( os.path.join( path, "wavepacket_coefficients_map_abs_block_" + str(blockid) + "_component_" + str(jndex) + GD.output_format)) close(fig) fig = figure(figsize=imgsize) ax = fig.gca() ax.matshow(angle(coeff)) ax.set_xlabel(r"$k$") ax.set_ylabel(r"$t$") ax.set_title(r"Coefficients $c_k^{%d}$" % jndex) fig.savefig( os.path.join( path, "wavepacket_coefficients_map_angle_block_" + str(blockid) + "_component_" + str(jndex) + GD.output_format)) close(fig) fig = figure(figsize=imgsize) ax = fig.gca() plotcm(coeff, angle(coeff), abs(coeff), darken=False, axes=ax) ax.set_xlabel(r"$k$") ax.set_ylabel(r"$t$") ax.set_title(r"Coefficients $c_k^{%d}$" % jndex) fig.savefig( os.path.join( path, "wavepacket_coefficients_map_cm_block_" + str(blockid) + "_component_" + str(jndex) + GD.output_format)) close(fig) fig = figure(figsize=imgsize) ax = fig.gca() plotcm(coeff, angle(coeff), abs(coeff), darken=True, axes=ax) ax.set_xlabel(r"$k$") ax.set_ylabel(r"$t$") ax.set_title(r"Coefficients $c_k^{%d}$" % jndex) fig.savefig( os.path.join( path, "wavepacket_coefficients_map_cm_darken_block_" + str(blockid) + "_component_" + str(jndex) + GD.output_format)) close(fig)
def plot_frames(PP, iom, blockid=0, load=False): r""" """ 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") #G = iom.load_grid(blockid=blockid) #G = grid.reshape((1, -1)) else: G = BlockFactory().create_grid(PP) V = BlockFactory().create_potential(parameters) WF = WaveFunction(parameters) WF.set_grid(G) BT = BasisTransformationWF(V) BT.set_grid(G) timegrid = iom.load_wavefunction_timegrid(blockid=blockid) u, v = G.get_nodes(split=True, flat=False) u = real(u) v = real(v) N = WF.get_number_components() for step in timegrid: print(" Plotting frame of timestep # " + str(step)) wave = iom.load_wavefunction(blockid=blockid, timestep=step) values = [ wave[j,...] for j in xrange(parameters["ncomponents"]) ] WF.set_values(values) # Transform the values to the eigenbasis # TODO: improve this: if parameters["algorithm"] == "fourier": BT.transform_to_eigen(WF) else: pass Psi = WF.get_values() fig = figure() for level in xrange(N): z = Psi[level] z = z.reshape(G.get_number_nodes()) subplot(N,1,level+1) plotcm(z, darken=0.3) savefig("wavefunction_level_"+str(level)+"_timestep_"+(5-len(str(step)))*"0"+str(step)+".png") close(fig) print(" Plotting frames finished")