Ejemplo n.º 1
0
    def __init__(self, parent, filepath, **kwargs):
        super(AbinitEventsPanel, self).__init__(parent, -1, **kwargs)

        self.filepath = os.path.abspath(filepath)

        parser = EventsParser()
        self.events = events = parser.parse(self.filepath)

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        vbox = wx.BoxSizer(wx.VERTICAL)
        panel1 = awx.Panel(self, -1)
        panel2 = awx.Panel(self, -1)

        self.tree = tree = wx.TreeCtrl(panel1, 1, wx.DefaultPosition, (-1, -1),
                                       wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS)

        root = self.tree.AddRoot('Events')

        err_tree = tree.AppendItem(root, "%d Errors" % events.num_errors)
        warn_tree = tree.AppendItem(root, "%d Warnings" % events.num_warnings)
        com_tree = tree.AppendItem(root, "%d Comments" % events.num_comments)

        for e in self.events.errors:
            tree.AppendItem(err_tree,
                            "line: " + str(e.lineno),
                            data=wx.TreeItemData(e.message))

        for w in self.events.warnings:
            tree.AppendItem(warn_tree,
                            "line: " + str(w.lineno),
                            data=wx.TreeItemData(w.message))

        for c in self.events.comments:
            tree.AppendItem(com_tree,
                            "line: " + str(c.lineno),
                            data=wx.TreeItemData(c.message))

        tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id=1)

        self.display = wx.StaticText(panel2,
                                     -1,
                                     '', (10, 10),
                                     style=wx.ALIGN_LEFT)

        vbox.Add(self.tree, 1, wx.EXPAND)
        main_sizer.Add(panel1, 1, wx.EXPAND)
        main_sizer.Add(panel2, 1, wx.EXPAND)
        panel1.SetSizerAndFit(vbox)

        self.SetSizerAndFit(main_sizer)
        self.Centre()
Ejemplo n.º 2
0
    def read_mainlog_ewc(self):
        """
       Read errors, warnings and comments from the main output and the log file.
                                                                                        
       :return: Two namedtuple instances: main, log. 
                The lists of strings with the corresponding messages are
                available in main.errors, main.warnings, main.comments, log.errors etc.
       """
        from pymatgen.io.abinit.events import EventsParser
        parser = EventsParser()
        main_events = parser.parse(self.last_output())
        log_events = parser.parse(self.log_name)

        return main_events, log_events
Ejemplo n.º 3
0
    def read_mainlog_ewc(self):
       """
       Read errors, warnings and comments from the main output and the log file.
                                                                                        
       :return: Two namedtuple instances: main, log. 
                The lists of strings with the corresponding messages are
                available in main.errors, main.warnings, main.comments, log.errors etc.
       """
       from pymatgen.io.abinit.events import EventsParser
       parser = EventsParser()
       main_events = parser.parse(self.last_output())
       log_events = parser.parse(self.log_name)

       return main_events, log_events
Ejemplo n.º 4
0
 def events(self):
     """
     List of ABINIT events reported in the file.
     """
     # Parse the file the first time the property is accessed or when mtime is changed.
     stat = os.stat(self.filepath)
     if stat.st_mtime != self._last_mtime or not hasattr(self, "_events"):
         self._events = EventsParser().parse(self.filepath)
     return self._events
Ejemplo n.º 5
0
    def __init__(self, parent, filepath, **kwargs):
        super(AbinitEventsPanel, self).__init__(parent, -1, **kwargs)

        self.filepath = os.path.abspath(filepath)

        parser = EventsParser()
        self.events = events = parser.parse(self.filepath)

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        vbox = wx.BoxSizer(wx.VERTICAL)
        panel1 = awx.Panel(self, -1)
        panel2 = awx.Panel(self, -1)

        self.tree = tree = wx.TreeCtrl(panel1, 1, wx.DefaultPosition, (-1, -1), wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS)

        root = self.tree.AddRoot('Events')

        err_tree = tree.AppendItem(root, "%d Errors" % events.num_errors)
        warn_tree = tree.AppendItem(root, "%d Warnings" % events.num_warnings)
        com_tree = tree.AppendItem(root, "%d Comments" % events.num_comments)

        for e in self.events.errors:
            tree.AppendItem(err_tree, "line: " + str(e.lineno), data=wx.TreeItemData(e.message))

        for w in self.events.warnings:
            tree.AppendItem(warn_tree, "line: " + str(w.lineno), data=wx.TreeItemData(w.message))

        for c in self.events.comments:
            tree.AppendItem(com_tree, "line: " + str(c.lineno), data=wx.TreeItemData(c.message))

        tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, id=1)

        self.display = wx.StaticText(panel2, -1, '', (10, 10), style=wx.ALIGN_LEFT)

        vbox.Add(self.tree, 1, wx.EXPAND)
        main_sizer.Add(panel1, 1, wx.EXPAND)
        main_sizer.Add(panel2, 1, wx.EXPAND)
        panel1.SetSizerAndFit(vbox)

        self.SetSizerAndFit(main_sizer)
        self.Centre()
Ejemplo n.º 6
0
def main():

    def str_examples():
        examples = """\
Usage example:
    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('-V', '--version', action='version', version="%(prog)s version " + abilab.__version__)
    parser.add_argument('--loglevel', default="ERROR", type=str,
                        help="set the loglevel. Possible values: CRITICAL, ERROR (default), WARNING, INFO, DEBUG")
    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.")

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

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

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

    # loglevel is bound to the string value obtained from the command line argument.
    # Convert to upper case to allow the user to specify --loglevel=DEBUG or --loglevel=debug
    import logging
    numeric_level = getattr(logging, options.loglevel.upper(), None)
    if not isinstance(numeric_level, int):
        raise ValueError('Invalid log level: %s' % options.loglevel)
    logging.basicConfig(level=numeric_level)

    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 = abilab.AbinitTimerParser()
        parser.parse(options.filepath)

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

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

    return 0
Ejemplo 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 Exception: 
        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.plot_pie(key="wall_time", minfract=0.05)
        #parser.plot_efficiency),
        #parser.plot_stacked_hist),

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

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

    return 0