Esempio n. 1
0
    def parse_timers(self):
        """
        Parse the TIMER section reported in the ABINIT output files.

        Returns:
            `AbinitTimerParser` object
        """
        filenames = filter(os.path.exists, [task.output_file.path for task in self])
                                                                           
        parser = AbinitTimerParser()
        parser.parse(filenames)
                                                                           
        return parser
Esempio n. 2
0
    def __init__(self, parent, filepath, **kwargs):
        """
        Args:
            parent:
                parent window
            filepath:
                Abinit output file.
        """
        filepath = os.path.abspath(filepath)
        if "title" not in kwargs:
            kwargs["title"] = "Abinit Timer: %s" % os.path.basename(filepath)

        super(AbinitTimerFrame, self).__init__(parent, **kwargs)

        try:
            self.timer = AbinitTimerParser()
            self.timer.parse(filepath)

        except Exception as exc:
            raise awx.Error(str(exc))

        self.BuildUi()
Esempio n. 3
0
    def __init__(self, parent, filepath, **kwargs):
        """
        Args:
            parent:
                parent window
            filepath:
                Abinit output file.
        """
        filepath = os.path.abspath(filepath)
        if "title" not in kwargs:
            kwargs["title"] = "Abinit Timer: %s" % os.path.basename(filepath)

        super(AbinitTimerFrame, self).__init__(parent, **kwargs)

        try:
            self.timer = AbinitTimerParser()
            self.timer.parse(filepath)

        except Exception as exc:
            raise awx.Error(str(exc))

        self.BuildUi()
Esempio n. 4
0
 def timer_data(self):
     """Timer data."""
     return AbinitTimerParser().parse(self.filepath)
Esempio n. 5
0
class AbinitTimerFrame(awx.Frame):
    """
    Frame to control to plot the timing data of a *single* ABINIT run.
    """
    def __init__(self, parent, filepath, **kwargs):
        """
        Args:
            parent:
                parent window
            filepath:
                Abinit output file.
        """
        filepath = os.path.abspath(filepath)
        if "title" not in kwargs:
            kwargs["title"] = "Abinit Timer: %s" % os.path.basename(filepath)

        super(AbinitTimerFrame, self).__init__(parent, **kwargs)

        try:
            self.timer = AbinitTimerParser()
            self.timer.parse(filepath)

        except Exception as exc:
            raise awx.Error(str(exc))

        self.BuildUi()

    def BuildUi(self):

        # Set callbacks (bound methods of AbiTimerData).
        self.plot_types = OrderedDict([
            ("pie", self.timer.show_pie),
            ("stacked_hist", self.timer.show_stacked_hist),
            #("raw_data", self.OnRawData),
        ])

        keys = AbinitTimerSection.NUMERIC_FIELDS

        main_sizer = wx.BoxSizer(wx.VERTICAL)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        plot_label = wx.StaticText(self, -1, "plot type:", wx.DefaultPosition,
                                   wx.DefaultSize, 0)
        plot_label.Wrap(-1)
        hsizer.Add(plot_label, 0,
                   wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM | wx.LEFT, 5)

        self.plot_cbox = wx.ComboBox(self, -1, "pie", wx.DefaultPosition,
                                     wx.DefaultSize, self.plot_types.keys(), 0)
        hsizer.Add(self.plot_cbox, 0, wx.ALL, 5)

        key_label = wx.StaticText(self, -1, "key:", wx.DefaultPosition,
                                  wx.DefaultSize, 0)
        key_label.Wrap(-1)
        hsizer.Add(key_label, 0,
                   wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM | wx.LEFT, 5)

        self.key_cbox = wx.ComboBox(self, -1, "wall_time", wx.DefaultPosition,
                                    wx.DefaultSize, keys, 0)
        hsizer.Add(self.key_cbox, 0, wx.ALL, 5)

        main_sizer.Add(hsizer, 0, wx.ALIGN_CENTER_HORIZONTAL, 5)

        plot_button = wx.Button(self, -1, "Plot", wx.DefaultPosition,
                                wx.DefaultSize, 0)
        plot_button.Bind(wx.EVT_BUTTON, self.OnClick)
        main_sizer.Add(plot_button, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5)

        self.SetSizerAndFit(main_sizer)

    def OnClick(self, event):
        callback = self.plot_types[self.plot_cbox.GetValue()]
        kwargs = dict(key=str(self.key_cbox.GetValue()))
        callback(**kwargs)
Esempio n. 6
0
class AbinitTimerFrame(awx.Frame):
    """
    Frame to control to plot the timing data of a *single* ABINIT run.
    """
    def __init__(self, parent, filepath, **kwargs):
        """
        Args:
            parent:
                parent window
            filepath:
                Abinit output file.
        """
        filepath = os.path.abspath(filepath)
        if "title" not in kwargs:
            kwargs["title"] = "Abinit Timer: %s" % os.path.basename(filepath)

        super(AbinitTimerFrame, self).__init__(parent, **kwargs)

        try:
            self.timer = AbinitTimerParser()
            self.timer.parse(filepath)

        except Exception as exc:
            raise awx.Error(str(exc))

        self.BuildUi()

    def BuildUi(self):

        # Set callbacks (bound methods of AbiTimerData).
        self.plot_types = OrderedDict([
            ("pie", self.timer.show_pie),
            ("stacked_hist", self.timer.show_stacked_hist),
            #("raw_data", self.OnRawData),
        ])

        keys = AbinitTimerSection.NUMERIC_FIELDS

        main_sizer = wx.BoxSizer(wx.VERTICAL)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        plot_label = wx.StaticText(self, -1, "plot type:", wx.DefaultPosition, wx.DefaultSize, 0)
        plot_label.Wrap(-1)
        hsizer.Add(plot_label, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM | wx.LEFT, 5)

        self.plot_cbox = wx.ComboBox(self, -1, "pie", wx.DefaultPosition, wx.DefaultSize, self.plot_types.keys(),
                                     0)
        hsizer.Add(self.plot_cbox, 0, wx.ALL, 5)

        key_label = wx.StaticText(self, -1, "key:", wx.DefaultPosition, wx.DefaultSize, 0)
        key_label.Wrap(-1)
        hsizer.Add(key_label, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM | wx.LEFT, 5)

        self.key_cbox = wx.ComboBox(self, -1, "wall_time", wx.DefaultPosition, wx.DefaultSize, keys, 0)
        hsizer.Add(self.key_cbox, 0, wx.ALL, 5)

        main_sizer.Add(hsizer, 0, wx.ALIGN_CENTER_HORIZONTAL, 5)

        plot_button = wx.Button(self, -1, "Plot", wx.DefaultPosition, wx.DefaultSize, 0)
        plot_button.Bind(wx.EVT_BUTTON, self.OnClick)
        main_sizer.Add(plot_button, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5)

        self.SetSizerAndFit(main_sizer)

    def OnClick(self, event):
        callback = self.plot_types[self.plot_cbox.GetValue()]
        kwargs = dict(
            key=str(self.key_cbox.GetValue())
        )
        callback(**kwargs)
Esempio n. 7
0
def main():
    def str_examples():
        examples = """
    Usage example:\n
        abiinsp.py OUTFILE status  ==> Report the list of Warning, Commments, Errors
        abiinsp.py OUTFILE plot    ==> Plot results of the GS Scf cycle, Phonon Scf cycle...
        abiinsp.py OUTFILE timer   ==> Visualize timing data with matplotlib.
    """
        return examples

    def show_examples_and_exit(err_msg=None, error_code=1):
        """Display the usage of the script."""
        sys.stderr.write(str_examples())
        if err_msg: sys.stderr.write("Fatal Error\n" + err_msg + "\n")
        sys.exit(error_code)

    parser = argparse.ArgumentParser(
        epilog=str_examples(),
        formatter_class=argparse.RawDescriptionHelpFormatter)

    parser.add_argument('filepath',
                        nargs="?",
                        help="File to inspect (output file or log file)")

    # Create the parsers for the sub-commands
    subparsers = parser.add_subparsers(dest='command',
                                       help='sub-command help',
                                       description="Valid subcommands")

    # Subparser for status command.
    p_status = subparsers.add_parser(
        'status',
        help="Check the status of the run (errors, warning, completion)")

    #p_status.add_argument('format', nargs="?", default="cif", type=str, help="Format of the output file (ciff, POSCAR, json).")

    # Subparser for plot command.
    p_plot = subparsers.add_parser('plot', help="Plot data")
    #p_plot.add_argument('visualizer', nargs="?", default="xcrysden", type=str, help="Visualizer.")

    subparsers.add_parser('timer', help="Show timing data.")

    subparsers.add_parser('pseudo', help="Show info on pseudopotential file.")

    # Parse command line.
    try:
        options = parser.parse_args()
    except:
        show_examples_and_exit(error_code=1)

    if options.command == "status":
        # Parse the Abinit Events in filepath.
        parser = EventsParser()
        report = parser.parse(options.filepath)
        print(report)

    elif options.command == "plot":
        # TODO: At present only GS runs are supported by plottable_from_outfile
        obj = plottable_from_outfile(options.filepath)

        if obj is not None:
            obj.plot()
        else:
            raise ValueError(
                "Don't know how to extract plottable data from %s" %
                options.filepath)

    elif options.command == "timer":
        parser = AbinitTimerParser()

        parser.parse(options.filepath)
        #parser.show_pie(key="wall_time", minfract=0.05)
        #parser.show_efficiency),
        #parser.show_stacked_hist),

    elif options.command == "pseudo":
        from pymatgen.io.abinitio.pseudos import PseudoParser
        pseudo = PseudoParser().parse(options.filepath)
        print(pseudo)

    else:
        raise ValueError("Unsupported command %s" % options.command)

    return 0