Esempio n. 1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "path",
        nargs="?",
        type=Path,
        default="propagate.h5/output",
        help="path to the output file",
    )
    add_argparse_2d_args(parser)
    add_argparse_save_arg(parser)
    args = parser.parse_args()

    figure, ax = plt.subplots(1, 1)

    time, _, energy, _ = read_output(args.path)
    plot_energy(ax, time, energy)

    system = units.get_default_unit_system()
    ax.set_xlabel(system.get_time_unit().format_label("t"))
    ax.set_ylabel(system.get_length_unit().format_label("x"))

    apply_2d_args(ax, figure, args)

    handle_saving(figure, args)
    plt.show()
Esempio n. 2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("path", nargs=2, help="path to the natpop file")
    parser.add_argument("-n", "--node", type=int, default=1, help="node")
    parser.add_argument("-d",
                        "--dof",
                        type=int,
                        default=1,
                        help="degree of freedom")
    add_argparse_2d_args(parser)
    args = parser.parse_args()

    figure, ax = plt.subplots(1, 1)

    time1, natpop1 = read_natpop(args.path[0], node=args.node, dof=args.dof)
    time2, natpop2 = read_natpop(args.path[1], node=args.node, dof=args.dof)

    if time1.shape != time2.shape:
        raise ValueError("number of time points differs")

    if not numpy.allclose(time1, time2):
        raise ValueError("time points differ")

    entropy1 = compute_entropy(natpop1)
    entropy2 = compute_entropy(natpop2)

    plot_entropy_diff(ax, time1, entropy1, entropy2)

    system = units.get_default_unit_system()
    ax.set_xlabel(system.get_time_unit().format_label("t"))

    apply_2d_args(ax, figure, args)

    plt.show()
Esempio n. 3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("path", nargs=2, help="path to the output file")
    add_argparse_2d_args(parser)
    args = parser.parse_args()

    figure, ax = plt.subplots(1, 1)

    time1, _, energy1, _ = read_output(args.path[0])
    time2, _, energy2, _ = read_output(args.path[1])

    if time1.shape != time2.shape:
        raise ValueError("different number of time points")

    if not numpy.allclose(time1, time2):
        raise ValueError("different time points")

    plot_energy_diff(ax, time1, energy1, energy2)

    system = units.get_default_unit_system()
    ax.set_xlabel(system.get_time_unit().format_label("t"))
    ax.set_ylabel(system.get_energy_unit().format_label(r"\Delta E"))

    apply_2d_args(ax, figure, args)

    plt.show()
Esempio n. 4
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "path",
        nargs="?",
        type=Path,
        default=Path("propagate.h5/natpop"),
        help="path to the natpop file",
    )
    parser.add_argument("-n", "--node", type=int, default=1, help="node")
    parser.add_argument("-d",
                        "--dof",
                        type=int,
                        default=1,
                        help="degree of freedom")
    add_argparse_2d_args(parser)
    add_argparse_save_arg(parser)
    args = parser.parse_args()

    figure, ax = plt.subplots(1, 1)

    time, natpop = read_natpop(args.path, node=args.node, dof=args.dof)
    plot_natpop(ax, time, natpop)

    try:
        ax.set_xlabel(
            units.get_default_unit_system().get_time_unit().format_label("t"))
    except units.MissingUnitError:
        ax.set_xlabel("$t$")

    apply_2d_args(ax, figure, args)
    handle_saving(figure, args)

    if not args.output:
        plt.show()
Esempio n. 5
0
def render_frame(i, times, dmat2, X1, X2, num_digits, dpi):
    unit_system = units.get_default_unit_system()
    fig, ax = plt.subplots()
    ax.set_title("$t=" + str(times[i]) + "$")
    ax.set_xlabel(unit_system.get_length_unit().format_label("x_1"))
    ax.set_ylabel(unit_system.get_length_unit().format_label("x_2"))
    ax.pcolormesh(X1, X2, dmat2[i])
    fig.savefig(("{:0" + str(num_digits) + "d}.png").format(i), dpi=dpi)
    plot.close_figure(fig)
    LOGGER.info("rendered image %d", i)
Esempio n. 6
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "path",
        nargs="?",
        type=Path,
        default=Path("propagate.h5/gpop"),
        help="path to the gpop file",
    )
    parser.add_argument("-d",
                        "--dof",
                        type=int,
                        default=1,
                        help="degree of freedom")
    parser.add_argument(
        "--momentum",
        action="store_true",
        help="whether to transform to momentum space",
    )
    parser.add_argument("--logz", action="store_true")
    parser.add_argument("--zmin", type=float)
    parser.add_argument("--zmax", type=float)
    parser.add_argument("--colorbar", action="store_true")
    add_argparse_2d_args(parser)
    add_argparse_save_arg(parser)
    args = parser.parse_args()

    figure, ax = plt.subplots(1, 1)

    data = read_gpop(args.path, dof=args.dof)
    if args.momentum:
        data = transform_to_momentum_space(data)
    mesh = plot_gpop(ax, *data, args.zmin, args.zmax, args.logz)
    if args.colorbar:
        figure.colorbar(mesh, ax=ax).solids.set_rasterized(True)

    unitsys = units.get_default_unit_system()
    try:
        ax.set_xlabel(unitsys.get_time_unit().format_label("t"))
    except units.MissingUnitError:
        ax.set_xlabel("$t$")

    try:
        ax.set_ylabel(unitsys.get_length_unit().format_label("x"))
    except units.MissingUnitError:
        ax.set_ylabel("$x$")

    apply_2d_args(ax, figure, args)

    handle_saving(figure, args)

    if not args.output:
        plt.show()
Esempio n. 7
0
    def init_plot(self):
        self.label.setText(f"Time: {self.time[0]:6.2f}")

        if self.line:
            self.line.remove()
            self.line = None

        unit_system = units.get_default_unit_system()
        self.axes.set_xlabel(unit_system.get_length_unit().format_label("x_1"))
        self.axes.set_ylabel(unit_system.get_time_unit().format_label("t"))

        (self.line,) = self.axes.plot(self.grid, self.density[0])

        if self.plot_args:
            plot.apply_2d_args(self.axes, self.plot.figure, self.plot_args)

        self.plot.canvas.draw()
Esempio n. 8
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "path",
        nargs="+",
        default=["natpop"],
        help="path to the natpop file",
    )
    parser.add_argument("-n", "--node", type=int, default=1, help="node")
    parser.add_argument("-d",
                        "--dof",
                        type=int,
                        default=1,
                        help="degree of freedom")
    parser.add_argument(
        "--normalize",
        action="store_true",
        help="whether to normalize the entropy",
    )
    add_argparse_2d_args(parser)
    add_argparse_save_arg(parser)
    args = parser.parse_args()

    labels = labels_from_paths(args.path)
    figure, ax = plt.subplots(1, 1)

    for path, label in zip(args.path, labels):
        time, natpop = read_natpop(path, node=args.node, dof=args.dof)
        try:
            entropy = compute_entropy(natpop, args.normalize)
        except ZeroDivisionError:
            entropy = compute_entropy(natpop)
            args.normalize = False
        plot_entropy(ax, time, entropy, label=label, normalize=args.normalize)

    system = units.get_default_unit_system()
    ax.set_xlabel(system.get_time_unit().format_label("t"))

    apply_2d_args(ax, figure, args)
    if len(args.path) > 1:
        ax.legend()

    handle_saving(figure, args)
    if not args.output:
        plt.show()
Esempio n. 9
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "path_natpop",
        nargs="?",
        default="natpop",
        help="path to the natpop file",
    )
    parser.add_argument(
        "path_evals",
        nargs="?",
        default="eval_dmat_dof1",
        help="path to the file containing the dmat eigenvalues",
    )
    parser.add_argument("-n", "--node", type=int, default=1, help="node")
    parser.add_argument("-d",
                        "--dof",
                        type=int,
                        default=1,
                        help="degree of freedom")
    add_argparse_2d_args(parser)
    args = parser.parse_args()

    figure, ax = plt.subplots(1, 1)

    time, natpop = read_natpop(args.path_natpop, node=args.node, dof=args.dof)
    time2, evals = read_dmat_evals(args.path_evals)

    if not numpy.allclose(time, time2):
        raise RuntimeError("time points do not match")

    for natpop, value in zip(natpop.T, evals.T):
        plt.plot(time, natpop - value)

    system = units.get_default_unit_system()
    ax.set_xlabel(system.get_time_unit().format_label("t"))

    apply_2d_args(ax, figure, args)

    plt.show()
Esempio n. 10
0
def plot_energy(
    index: int,
    path: Path,
    parameters: Parameters,
    file_path: Path,
    extension: str = ".pdf",
    modfunc: Callable[[Figure, Axes, Parameters], None] = None,
):
    total_path = path / file_path
    try:
        fig, ax = plot.create_subplots(1, 1)
        time, _, energy, _ = inout.read_output(total_path)
        plot.plot_energy(ax, time, energy)
        system = units.get_default_unit_system()
        ax.set_xlabel(system.get_time_unit().format_label("t"))
        ax.set_ylabel(system.get_energy_unit().format_label("E"))
        if modfunc:
            modfunc(fig, ax, parameters)
        plot.save(fig, str(index) + extension)
        plot.close_figure(fig)
    except FileNotFoundError:
        LOGGER.warning("file does not exist: %s", total_path)
Esempio n. 11
0
def plot_natpop(
    index: int,
    path: Path,
    parameters: Parameters,
    file_path: Path,
    dof: int = 1,
    node: int = 1,
    extension: str = ".pdf",
):
    total_path = path / file_path
    try:
        fig, ax = plot.create_subplots(1, 1)
        plot.plot_natpop(ax, *inout.read_natpop(total_path, dof=dof, node=node))
        system = units.get_default_unit_system()
        ax.set_xlabel(system.get_time_unit().format_label("t"))
        ax.set_ylabel(r"$\lambda_i(t)$")
        for func in MODFUNCS:
            func(fig, ax, parameters)
        plot.save(fig, str(index) + extension)
        plot.close_figure(fig)
    except FileNotFoundError:
        LOGGER.warning("file does not exist: %s", total_path)
Esempio n. 12
0
def plot_expval(
    index: int,
    path: Path,
    parameters: Parameters,
    file_path: Path,
    extension: str = ".pdf",
    modfunc: Callable[[Figure, Axes, Parameters], None] = None,
):
    total_path = path / file_path
    try:
        fig, ax = plot.create_subplots(1, 1)
        plot.plot_expval(ax, *inout.expval.read_expval(total_path))
        ax.set_title(r"$\rho_1(x,t)$")
        system = units.get_default_unit_system()
        ax.set_xlabel(system.get_time_unit().format_label("t"))
        ax.set_xlabel(system.get_length_unit().format_label("x"))
        if modfunc:
            modfunc(fig, ax, parameters)
        plot.save(fig, str(index) + extension)
        plot.close_figure(fig)
    except FileNotFoundError:
        LOGGER.warning("file does not exist: %s", total_path)
Esempio n. 13
0
def plot_natpop(
    index: int,
    path: Path,
    parameters: Parameters,
    file_path: Path,
    dof: int = 1,
    node: int = 1,
    extension: str = ".pdf",
    modfunc: Callable[[Figure, Axes, Parameters], None] = None,
):
    total_path = path / file_path
    try:
        fig, ax = plot.create_subplots(1, 1)
        plot.plot_depletion(ax, *inout.read_natpop(total_path, dof=dof, node=node))
        system = units.get_default_unit_system()
        ax.set_xlabel(system.get_time_unit().format_label("t"))
        if modfunc:
            modfunc(fig, ax, parameters)
        plot.save(fig, str(index) + extension)
        plot.close_figure(fig)
    except FileNotFoundError:
        LOGGER.warning("file does not exist: %s", total_path)
Esempio n. 14
0
    def init_plot(self):
        self.label.setText(f"Time: {self.time[0]:6.2f}")

        if self.mesh:
            self.mesh.remove()
            self.mesh = None

        if self.plot_args:
            plot.apply_2d_args(self.axes, self.plot.figure, self.plot_args)

        unit_system = units.get_default_unit_system()
        self.axes.set_xlabel(unit_system.get_length_unit().format_label("x_1"))
        self.axes.set_ylabel(unit_system.get_length_unit().format_label("x_2"))

        X2, X1 = numpy.meshgrid(self.x2, self.x1)
        self.mesh = self.axes.pcolormesh(
            X1,
            X2,
            self.values[0],
            cmap="gnuplot",
            rasterized=True,
        )
        self.plot.canvas.draw()
Esempio n. 15
0
    def init_plot(self):
        if self.line_real:
            self.line_real.remove()
            self.line_real = None

        if self.line_imag:
            self.line_imag.remove()
            self.line_imag = None

        if self.line_abs:
            self.line_abs.remove()
            self.line_abs = None

        self.line_abs = self.axes.plot(
            self.grid,
            numpy.abs(self.evecs[self.index, self.time_index]),
        )[0]
        self.line_real = self.axes.plot(
            self.grid,
            numpy.real(self.evecs[self.index, self.time_index]),
        )[0]
        self.line_imag = self.axes.plot(
            self.grid,
            numpy.imag(self.evecs[self.index, self.time_index]),
        )[0]

        self.line_abs.set_visible(self.check_abs.isChecked())
        self.line_real.set_visible(self.check_real.isChecked())
        self.line_imag.set_visible(self.check_imag.isChecked())

        system = units.get_default_unit_system()
        self.axes.set_xlabel(system.get_length_unit().format_label("x"))
        self.axes.set_ylabel(r"$\varphi(x)$")
        plot.apply_2d_args(self.axes, self.plot.figure, self.plot_args)
        self.update_yrange()

        self.plot.canvas.draw()
Esempio n. 16
0
def main():
    print(str(units.get_default_unit_system()))