def plot_parameters(data, index=0, view=[None, None], path='.'): r"""Plot the data parameters :math:`(q,p,Q,P,S)` over time. For each new `index` we start a new figure. This allows plotting several time evolutions to the same figure """ print("Plotting the parameters of data block '{}'".format(index)) time, qhist, phist, Qhist, Phist, Shist = data # View if view[0] is None: view[0] = nanmin(time) if view[1] is None: view[1] = nanmax(time) # Plot the time evolution of the parameters q, p, Q, P and S fig = figure(figsize=(12, 12)) ax = fig.add_subplot(4, 2, 1) for item in qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$q$") ax = fig.add_subplot(4, 2, 2) for item in phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$p$") ax = fig.add_subplot(4, 2, 3) for item in Qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Re Q$") ax = fig.add_subplot(4, 2, 4) for item in Phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Re P$") ax = fig.add_subplot(4, 2, 5) for item in Qhist: ax.plot(time, imag(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Im Q$") ax = fig.add_subplot(4, 2, 6) for item in Phist: ax.plot(time, imag(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Im P$") ax = fig.add_subplot(4, 2, 7) for item in Shist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig( os.path.join( path, "wavepacket_parameters_block".format(index, GD.output_format))) close(fig) # Plot the time evolution of the parameters P, Q, S, p and q # This time plot abs/angle instead of real/imag fig = figure(figsize=(12, 12)) ax = fig.add_subplot(4, 2, 1) for item in qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$q$") ax = fig.add_subplot(4, 2, 2) for item in phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$p$") ax = fig.add_subplot(4, 2, 3) for item in Qhist: ax.plot(time, abs(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$|Q|$") ax = fig.add_subplot(4, 2, 4) for item in Phist: ax.plot(time, abs(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$|P|$") ax = fig.add_subplot(4, 2, 5) for item in Qhist: ax.plot(time, ComplexMath.cont_angle(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\arg Q$") ax = fig.add_subplot(4, 2, 6) for item in Phist: ax.plot(time, ComplexMath.cont_angle(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\arg P$") ax = fig.add_subplot(4, 2, 7) for item in Shist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig( os.path.join( path, "wavepacket_parameters_abs_ang_block{}{}".format( index, GD.output_format))) close(fig) vals = ~isnan(time) # Plot the complex trajectory of the parameters P fig = figure() ax = fig.gca() for item in Phist: ax.plot(real(item[vals]), imag(item[vals]), "-o") ax.grid(True) ax.set_aspect("equal") ax.set_xlabel(r"$\Re P(t)$") ax.set_ylabel(r"$\Im P(t)$") ax.set_title(r"Trajectory of $P$") fig.savefig( os.path.join( path, "wavepacket_parameters_trajectoryP_block{}{}".format( index, GD.output_format))) close(fig) # Plot the complex trajectory of the parameters Q fig = figure() ax = fig.gca() for item in Qhist: ax.plot(real(item[vals]), imag(item[vals]), "-o") ax.grid(True) ax.set_aspect("equal") ax.set_xlabel(r"$\Re Q(t)$") ax.set_ylabel(r"$\Im Q(t)$") ax.set_title(r"Trajectory of $Q$") fig.savefig( os.path.join( path, "wavepacket_parameters_trajectoryQ_block{}{}".format( index, GD.output_format))) close(fig) fig = figure() ax = fig.gca() for P, Q in zip(Phist, Qhist): ax.plot(time, abs(P.T * Q - Q.T * P), label=r'$P^{T} Q - Q^{T} P = 0$') ax.plot(time, abs(conjugate(P.T) * Q - conjugate(Q.T) * P + 2.0j), label=r'$P^{H} Q - Q^{H} P + 2\imath I = 0$') ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_xlabel(r"$t$") ax.legend(loc='upper left') fig.suptitle("Wavepacket PQ relation check") fig.savefig( os.path.join( path, "wavepacket_PQrelation_block{}{}".format(index, GD.output_format))) close(fig)
def plot_parameters(data, index=0): r"""Plot the data parameters :math:`(q,p,Q,P,S)` over time. For each new `index` we start a new figure. This allows plotting several time evolutions to the same figure """ print("Plotting the parameters of data block '" + str(index) + "'") timegrid, qhist, phist, Qhist, Phist, Shist = data # Plot the time evolution of the parameters q, p, Q, P and S fig = figure(figsize=(12, 12)) ax = fig.add_subplot(4, 2, 1) for item in qhist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\|q\|_2$") ax = fig.add_subplot(4, 2, 2) for item in phist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\|p\|_2$") ax = fig.add_subplot(4, 2, 3) for item in Qhist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\Re \det Q$") ax = fig.add_subplot(4, 2, 4) for item in Phist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\Re \det P$") ax = fig.add_subplot(4, 2, 5) for item in Qhist: ax.plot(timegrid, imag(item)) ax.grid(True) ax.set_title(r"$\Im \det Q$") ax = fig.add_subplot(4, 2, 6) for item in Phist: ax.plot(timegrid, imag(item)) ax.grid(True) ax.set_title(r"$\Im \det P$") ax = fig.add_subplot(4, 2, 7) for item in Shist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig("wavepacket_parameters_block" + str(index) + GD.output_format) close(fig) # Plot the time evolution of the parameters P, Q, S, p and q # This time plot abs/angle instead of real/imag fig = figure(figsize=(12, 12)) ax = fig.add_subplot(4, 2, 1) for item in qhist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\|q\|_2$") ax = fig.add_subplot(4, 2, 2) for item in phist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\|p\|_2$") ax = fig.add_subplot(4, 2, 3) for item in Qhist: ax.plot(timegrid, abs(item)) ax.grid(True) ax.set_title(r"$|\det Q|$") ax = fig.add_subplot(4, 2, 4) for item in Phist: ax.plot(timegrid, abs(item)) ax.grid(True) ax.set_title(r"$|\det P|$") ax = fig.add_subplot(4, 2, 5) for item in Qhist: ax.plot(timegrid, ComplexMath.cont_angle(item)) ax.grid(True) ax.set_title(r"$\arg \det Q$") ax = fig.add_subplot(4, 2, 6) for item in Phist: ax.plot(timegrid, ComplexMath.cont_angle(item)) ax.grid(True) ax.set_title(r"$\arg \det P$") ax = fig.add_subplot(4, 2, 7) for item in Shist: ax.plot(timegrid, item, label=r"$S$") ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig("wavepacket_parameters_abs_ang_block" + str(index) + GD.output_format) close(fig) # Plot the complex trajectory of the parameters P fig = figure() ax = fig.gca() for item in Phist: ax.plot(real(item), imag(item), "-o") ax.set_xlabel(r"$\Re \det P$") ax.set_ylabel(r"$\Im \det P$") ax.grid(True) ax.set_aspect("equal") ax.set_title(r"Trajectory of $\det P$") fig.savefig("wavepacket_parameters_trajectoryP_block" + str(index) + GD.output_format) close(fig) # Plot the complex trajectory of the parameters Q fig = figure() ax = fig.gca() for item in Qhist: ax.plot(real(item), imag(item), "-o") ax.set_xlabel(r"$\Re \det Q$") ax.set_ylabel(r"$\Im \det Q$") ax.grid(True) ax.set_aspect("equal") ax.set_title(r"Trajectory of $\det Q$") fig.savefig("wavepacket_parameters_trajectoryQ_block" + str(index) + GD.output_format) close(fig)
def plot_parameters(data, index=0, view=[None, None], path='.'): r"""Plot the data parameters :math:`(q,p,Q,P,S)` over time. For each new `index` we start a new figure. This allows plotting several time evolutions to the same figure """ print("Plotting the parameters of data block '{}'".format(index)) time, qhist, phist, Qhist, Phist, Shist = data # View if view[0] is None: view[0] = nanmin(time) if view[1] is None: view[1] = nanmax(time) # Plot the time evolution of the parameters q, p, Q, P and S fig = figure(figsize=(12, 12)) ax = fig.add_subplot(4, 2, 1) for item in qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\|q\|_2$") ax = fig.add_subplot(4, 2, 2) for item in phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\|p\|_2$") ax = fig.add_subplot(4, 2, 3) for item in Qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Re \det Q$") ax = fig.add_subplot(4, 2, 4) for item in Phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Re \det P$") ax = fig.add_subplot(4, 2, 5) for item in Qhist: ax.plot(time, imag(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Im \det Q$") ax = fig.add_subplot(4, 2, 6) for item in Phist: ax.plot(time, imag(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Im \det P$") ax = fig.add_subplot(4, 2, 7) for item in Shist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig( os.path.join( path, "wavepacket_parameters_block" + str(index) + GD.output_format)) close(fig) # Plot the time evolution of the parameters P, Q, S, p and q # This time plot abs/angle instead of real/imag fig = figure(figsize=(12, 12)) ax = fig.add_subplot(4, 2, 1) for item in qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\|q\|_2$") ax = fig.add_subplot(4, 2, 2) for item in phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\|p\|_2$") ax = fig.add_subplot(4, 2, 3) for item in Qhist: ax.plot(time, abs(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$|\det Q|$") ax = fig.add_subplot(4, 2, 4) for item in Phist: ax.plot(time, abs(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$|\det P|$") ax = fig.add_subplot(4, 2, 5) for item in Qhist: ax.plot(time, ComplexMath.cont_angle(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\arg \det Q$") ax = fig.add_subplot(4, 2, 6) for item in Phist: ax.plot(time, ComplexMath.cont_angle(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\arg \det P$") ax = fig.add_subplot(4, 2, 7) for item in Shist: ax.plot(time, real(item), label=r"$S$") ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig( os.path.join( path, "wavepacket_parameters_abs_ang_block" + str(index) + GD.output_format)) close(fig) vals = ~isnan(time) # Plot the complex trajectory of the parameters P fig = figure() ax = fig.gca() for item in Phist: ax.plot(real(item[vals]), imag(item[vals]), "-o") ax.set_xlabel(r"$\Re \det P(t)$") ax.set_ylabel(r"$\Im \det P(t)$") ax.grid(True) ax.set_aspect("equal") ax.set_title(r"Trajectory of $\det P$") fig.savefig( os.path.join( path, "wavepacket_parameters_trajectoryP_block" + str(index) + GD.output_format)) close(fig) # Plot the complex trajectory of the parameters Q fig = figure() ax = fig.gca() for item in Qhist: ax.plot(real(item[vals]), imag(item[vals]), "-o") ax.set_xlabel(r"$\Re \det Q(t)$") ax.set_ylabel(r"$\Im \det Q(t)$") ax.grid(True) ax.set_aspect("equal") ax.set_title(r"Trajectory of $\det Q$") fig.savefig( os.path.join( path, "wavepacket_parameters_trajectoryQ_block" + str(index) + GD.output_format)) close(fig)
def plot_parameters(data, index=0, view=[None, None], path='.'): r"""Plot the data parameters :math:`(q,p,Q,P,S)` over time. For each new `index` we start a new figure. This allows plotting several time evolutions to the same figure """ print("Plotting the parameters of data block '{}'".format(index)) time, qhist, phist, Qhist, Phist, Shist = data # View if view[0] is None: view[0] = nanmin(time) if view[1] is None: view[1] = nanmax(time) # Plot the time evolution of the parameters q, p, Q, P and S fig = figure(figsize=(12, 12)) ax = fig.add_subplot(4, 2, 1) for item in qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$q$") ax = fig.add_subplot(4, 2, 2) for item in phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$p$") ax = fig.add_subplot(4, 2, 3) for item in Qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Re Q$") ax = fig.add_subplot(4, 2, 4) for item in Phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Re P$") ax = fig.add_subplot(4, 2, 5) for item in Qhist: ax.plot(time, imag(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Im Q$") ax = fig.add_subplot(4, 2, 6) for item in Phist: ax.plot(time, imag(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Im P$") ax = fig.add_subplot(4, 2, 7) for item in Shist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig(os.path.join(path, "wavepacket_parameters_block".format(index, GD.output_format))) close(fig) # Plot the time evolution of the parameters P, Q, S, p and q # This time plot abs/angle instead of real/imag fig = figure(figsize=(12, 12)) ax = fig.add_subplot(4, 2, 1) for item in qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$q$") ax = fig.add_subplot(4, 2, 2) for item in phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$p$") ax = fig.add_subplot(4, 2, 3) for item in Qhist: ax.plot(time, abs(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$|Q|$") ax = fig.add_subplot(4, 2, 4) for item in Phist: ax.plot(time, abs(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$|P|$") ax = fig.add_subplot(4, 2, 5) for item in Qhist: ax.plot(time, ComplexMath.cont_angle(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\arg Q$") ax = fig.add_subplot(4, 2, 6) for item in Phist: ax.plot(time, ComplexMath.cont_angle(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\arg P$") ax = fig.add_subplot(4, 2, 7) for item in Shist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig(os.path.join(path, "wavepacket_parameters_abs_ang_block{}{}".format(index, GD.output_format))) close(fig) vals = ~isnan(time) # Plot the complex trajectory of the parameters P fig = figure() ax = fig.gca() for item in Phist: ax.plot(real(item[vals]), imag(item[vals]), "-o") ax.grid(True) ax.set_aspect("equal") ax.set_xlabel(r"$\Re P(t)$") ax.set_ylabel(r"$\Im P(t)$") ax.set_title(r"Trajectory of $P$") fig.savefig(os.path.join(path, "wavepacket_parameters_trajectoryP_block{}{}".format(index, GD.output_format))) close(fig) # Plot the complex trajectory of the parameters Q fig = figure() ax = fig.gca() for item in Qhist: ax.plot(real(item[vals]), imag(item[vals]), "-o") ax.grid(True) ax.set_aspect("equal") ax.set_xlabel(r"$\Re Q(t)$") ax.set_ylabel(r"$\Im Q(t)$") ax.set_title(r"Trajectory of $Q$") fig.savefig(os.path.join(path, "wavepacket_parameters_trajectoryQ_block{}{}".format(index, GD.output_format))) close(fig) fig = figure() ax = fig.gca() for P, Q in zip(Phist, Qhist): ax.plot(time, abs(P.T * Q - Q.T * P), label=r'$P^{T} Q - Q^{T} P = 0$') ax.plot(time, abs(conjugate(P.T) * Q - conjugate(Q.T) * P + 2.0j), label=r'$P^{H} Q - Q^{H} P + 2\imath I = 0$') ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_xlabel(r"$t$") ax.legend(loc='upper left') fig.suptitle("Wavepacket PQ relation check") fig.savefig(os.path.join(path, "wavepacket_PQrelation_block{}{}".format(index, GD.output_format))) close(fig)
def plot_parameters(data, index=0, view=[None, None], path='.'): r"""Plot the data parameters :math:`(q,p,Q,P,S)` over time. For each new `index` we start a new figure. This allows plotting several time evolutions to the same figure """ print("Plotting the parameters of data block '{}'".format(index)) time, qhist, phist, Qhist, Phist, Shist = data # View if view[0] is None: view[0] = nanmin(time) if view[1] is None: view[1] = nanmax(time) # Plot the time evolution of the parameters q, p, Q, P and S fig = figure(figsize=(12, 12)) ax = fig.add_subplot(4, 2, 1) for item in qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\|q\|_2$") ax = fig.add_subplot(4, 2, 2) for item in phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\|p\|_2$") ax = fig.add_subplot(4, 2, 3) for item in Qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Re \det Q$") ax = fig.add_subplot(4, 2, 4) for item in Phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Re \det P$") ax = fig.add_subplot(4, 2, 5) for item in Qhist: ax.plot(time, imag(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Im \det Q$") ax = fig.add_subplot(4, 2, 6) for item in Phist: ax.plot(time, imag(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\Im \det P$") ax = fig.add_subplot(4, 2, 7) for item in Shist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig(os.path.join(path, "wavepacket_parameters_block"+str(index)+GD.output_format)) close(fig) # Plot the time evolution of the parameters P, Q, S, p and q # This time plot abs/angle instead of real/imag fig = figure(figsize=(12, 12)) ax = fig.add_subplot(4, 2, 1) for item in qhist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\|q\|_2$") ax = fig.add_subplot(4, 2, 2) for item in phist: ax.plot(time, real(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\|p\|_2$") ax = fig.add_subplot(4, 2, 3) for item in Qhist: ax.plot(time, abs(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$|\det Q|$") ax = fig.add_subplot(4, 2, 4) for item in Phist: ax.plot(time, abs(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$|\det P|$") ax = fig.add_subplot(4, 2, 5) for item in Qhist: ax.plot(time, ComplexMath.cont_angle(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\arg \det Q$") ax = fig.add_subplot(4, 2, 6) for item in Phist: ax.plot(time, ComplexMath.cont_angle(item)) ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$\arg \det P$") ax = fig.add_subplot(4, 2, 7) for item in Shist: ax.plot(time, real(item), label=r"$S$") ax.set_xlim(view[0], view[1]) ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig(os.path.join(path, "wavepacket_parameters_abs_ang_block"+str(index)+GD.output_format)) close(fig) vals = ~isnan(time) # Plot the complex trajectory of the parameters P fig = figure() ax = fig.gca() for item in Phist: ax.plot(real(item[vals]), imag(item[vals]), "-o") ax.set_xlabel(r"$\Re \det P(t)$") ax.set_ylabel(r"$\Im \det P(t)$") ax.grid(True) ax.set_aspect("equal") ax.set_title(r"Trajectory of $\det P$") fig.savefig(os.path.join(path, "wavepacket_parameters_trajectoryP_block"+str(index)+GD.output_format)) close(fig) # Plot the complex trajectory of the parameters Q fig = figure() ax = fig.gca() for item in Qhist: ax.plot(real(item[vals]), imag(item[vals]), "-o") ax.set_xlabel(r"$\Re \det Q(t)$") ax.set_ylabel(r"$\Im \det Q(t)$") ax.grid(True) ax.set_aspect("equal") ax.set_title(r"Trajectory of $\det Q$") fig.savefig(os.path.join(path, "wavepacket_parameters_trajectoryQ_block"+str(index)+GD.output_format)) close(fig)
def plot_parameters(data, index=0): r"""Plot the data parameters :math:`(q,p,Q,P,S)` over time. For each new `index` we start a new figure. This allows plotting several time evolutions to the same figure """ print("Plotting the parameters of data block '"+str(index)+"'") timegrid, qhist, phist, Qhist, Phist, Shist = data # Plot the time evolution of the parameters q, p, Q, P and S fig = figure(figsize=(12,12)) ax = fig.add_subplot(4,2,1) for item in qhist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\|q\|_2$") ax = fig.add_subplot(4,2,2) for item in phist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\|p\|_2$") ax = fig.add_subplot(4,2,3) for item in Qhist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\Re \det Q$") ax = fig.add_subplot(4,2,4) for item in Qhist: ax.plot(timegrid, imag(item)) ax.grid(True) ax.set_title(r"$\Im \det Q$") ax = fig.add_subplot(4,2,5) for item in Phist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\Re \det P$") ax = fig.add_subplot(4,2,6) for item in Phist: ax.plot(timegrid, imag(item)) ax.grid(True) ax.set_title(r"$\Im \det P$") ax = fig.add_subplot(4,2,7) for item in Shist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig("wavepacket_parameters_block"+str(index)+GD.output_format) close(fig) # Plot the time evolution of the parameters P, Q, S, p and q # This time plot abs/angle instead of real/imag fig = figure(figsize=(12,12)) ax = fig.add_subplot(4,2,1) for item in qhist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\|q\|_2$") ax = fig.add_subplot(4,2,2) for item in phist: ax.plot(timegrid, real(item)) ax.grid(True) ax.set_title(r"$\|p\|_2$") ax = fig.add_subplot(4,2,3) for item in Qhist: ax.plot(timegrid, abs(item)) ax.grid(True) ax.set_title(r"$|\det Q|$") ax = fig.add_subplot(4,2,4) for item in Qhist: ax.plot(timegrid, ComplexMath.cont_angle(item)) ax.grid(True) ax.set_title(r"$\arg \det Q$") ax = fig.add_subplot(4,2,5) for item in Phist: ax.plot(timegrid, abs(item)) ax.grid(True) ax.set_title(r"$|\det P|$") ax = fig.add_subplot(4,2,6) for item in Phist: ax.plot(timegrid, ComplexMath.cont_angle(item)) ax.grid(True) ax.set_title(r"$\arg \det P$") ax = fig.add_subplot(4,2,7) for item in Shist: ax.plot(timegrid, item, label=r"$S$") ax.grid(True) ax.set_title(r"$S$") fig.suptitle("Wavepacket parameters") fig.savefig("wavepacket_parameters_abs_ang_block"+str(index)+GD.output_format) close(fig) # Plot the complex trajectory of the parameters P fig = figure() ax = fig.gca() for item in Phist: ax.plot(real(item), imag(item), "-o") ax.set_xlabel(r"$\Re \det P$") ax.set_ylabel(r"$\Im \det P$") ax.grid(True) ax.set_title(r"Trajectory of $\det P$") fig.savefig("wavepacket_parameters_trajectoryP_block"+str(index)+GD.output_format) close(fig) # Plot the complex trajectory of the parameters Q fig = figure() ax = fig.gca() for item in Qhist: ax.plot(real(item), imag(item), "-o") ax.set_xlabel(r"$\Re \det Q$") ax.set_ylabel(r"$\Im \det Q$") ax.grid(True) ax.set_title(r"Trajectory of $\det Q$") fig.savefig("wavepacket_parameters_trajectoryQ_block"+str(index)+GD.output_format) close(fig)