Example #1
0
    def plot_performance(self, log_file):

        if not os.path.isfile(log_file):
            print("File not found: " + str(log_file))
            return

        elapsed_time = []
        import re
        with open(log_file) as lfile:
            for line in lfile:
                line = re.findall(r'Timer: Elapsed seconds: [0-9.]+', line)
                if line:
                    line = line[0].split(':')[2]
                    elapsed_time.append(float(line))

        df = pd.DataFrame(elapsed_time)

        fig = plt.figure(figsize=(8, 5), dpi=100)
        ax = fig.gca()
        ax.grid(True)
        ax.set_xlabel('cycles')
        ax.set_ylabel('Cycle Elapsed time (secs)')
        df.plot(ax=ax, legend=False)
        if batch:
            fig.savefig(log_file + ".png", dpi=100)
        plt.show()
Example #2
0
    def plot_data(self, b):

        # Delete visbible figures
        for f in self.visible_fig:
            f.clear()
            plt.close(f)
            plt.gcf()
        dp.clear_output(wait=True)

        rolling = self.data.rolling(100).mean()
        for cb in self.checkboxes:
            if cb.value:
                h = cb.description
                fig = plt.figure()
                ax = fig.gca()
                y = h
                self.data.plot(x='Cycle', y=y, ax=ax, legend=False)
                rolling.plot(x=self.data['Cycle'], y=y, ax=ax, legend=0)
                last_val = self.data[h].tail(1).get_values()
                ax.set_title(str(h) + ' - ' + str(last_val))
                ax.grid(True)
                ax.set_xlabel('cycles')
                ax.set_ylabel(h)
                self.visible_fig.append(fig)
        plt.show()
Example #3
0
    def plot(self, report_file):
        fig = plt.figure(figsize=(8, 5), dpi=100)
        ax = fig.gca()
        ax.set_yscale("log")
        ax.grid(True)
        ax.set_xlabel('cycles')
        ax.set_ylabel('RMS residual')

        append_index = 0
        if not isinstance(report_file, list):
            report_file_list = [report_file]
            ax.set_title(report_file[:report_file.rindex('_report.csv')])
        else:
            report_file_list = report_file
            if len(report_file_list) > 1:
                append_index = 1

        for report_file in report_file_list:
            if not os.path.isfile(report_file):
                print("File not found: " + str(report_file))
                continue

            self.read_data(report_file)

            y = self.residual_list
            self.data.plot(x='Cycle', y=y, ax=ax, legend=False)
            append_index = append_index + 1

        box = ax.get_position()
        ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
        plt.legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
        if batch:
            fig.savefig(report_file + ".png", dpi=100)
        plt.show()
        self.visible_fig = []
Example #4
0
    def plot_data(self, b):

        # Delete visbible figures
        # for f in self.visible_fig:
        #    f.clear()
        #    plt.close(f)
        #    plt.gcf()
        # dp.clear_output(wait=True)
        self.rolling_avg = self.rolling.value
        self.out.clear_output()
        with self.out:
            rolling = self.data.rolling(self.rolling_avg).mean()
            for cb in self.checkboxes:
                if cb.value:
                    h = cb.description
                    fig = plt.figure()
                    ax = fig.gca()
                    y = h
                    self.data.plot(x="Cycle", y=y, ax=ax, legend=False)
                    rolling.plot(x="Cycle", y=y, ax=ax, legend=0)
                    last_val = self.data[h].tail(1).get_values()
                    # $\downarrow$ $\uparrow$ $\leftrightarrow$
                    rolling_grad = (rolling[h].tail(2).get_values()[0] -
                                    rolling[h].tail(2).get_values()[1])
                    trend = r"$\leftrightarrow$"
                    if rolling_grad > 0.0:
                        trend = r"$\downarrow$"
                    elif rolling_grad < 0.0:
                        trend = r"$\uparrow$"
                    ax.set_title(str(h) + " - " + str(last_val) + " " + trend)
                    ax.grid(True)
                    ax.set_xlabel("cycles")
                    ax.set_ylabel(h)
                    self.visible_fig.append(fig)
Example #5
0
    def plot(self, refile):
        fig = plt.figure(figsize=(8, 5), dpi=100)
        ax = fig.gca()

        self.report_file = refile

        def animate(i):
            ax.clear()
            ax.set_yscale("log")

            ax.set_xlabel("cycles")
            ax.set_ylabel("RMS residual")

            self.append_index = 0
            if not isinstance(self.report_file, list):
                report_file_list = [self.report_file]
                ax.set_title(
                    self.report_file[:self.report_file.rindex("_report.csv")])
            else:
                report_file_list = self.report_file
                if len(report_file_list) > 1:
                    self.append_index = 1

            for report_file in report_file_list:
                if not os.path.isfile(self.report_file):
                    print("File not found: " + str(self.report_file))
                    continue

                self.read_data(self.report_file)

                # y = self.residual_list
                x = "Cycle"
                if self.append_index > 0:
                    x = x + "_" + str(self.append_index)
                for y in self.residual_list:
                    self.data.plot(x=x, y=y, ax=ax, legend=False)
                self.append_index = self.append_index + 1

            # Turn on major and minor grid lines
            ax.grid(True, "both")
            box = ax.get_position()
            ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
            plt.legend(loc="center left", bbox_to_anchor=(1.0, 0.5))

        animate(0)
        # if not batch:
        #     ani = animation.FuncAnimation(fig, animate, interval=10000)

        if batch:
            fig.savefig(report_file + ".png", dpi=100)
        plt.show()
        self.visible_fig = []
Example #6
0
    def plot_multiple(self, report_file_list, variable_list, out_file):

        fig = plt.figure(figsize=(8, 5), dpi=100)

        handles_ = []
        for f in report_file_list:

            if not os.path.isfile(f):
                print("File not found: " + str(f))
                continue

            case_name = f[:-11]

            vars = []
            with open(f, 'r') as ff:
                vars = ff.readline().split()

            data = np.genfromtxt(f, skip_header=1)
            for v in range(0, len(vars) - 2):

                variable_name = vars[v + 2]
                if len(variable_list
                       ) != 0 and variable_name not in variable_list:
                    continue
                line, = plt.semilogy(data[:, 1],
                                     data[:, v + 2],
                                     label=case_name + ' ' + variable_name)
                handles_.append(line)

        plt.legend(handles=handles_)
        plt.xlabel('cycles')
        plt.ylabel('RMS residual')
        plt.show()
        if batch:
            fig.savefig(out_file + ".png", dpi=100)
        plt.show()
        self.visible_fig = []