예제 #1
0
파일: cif2spg.py 프로젝트: gmrigna/abipy
def main():
    def str_examples():
        examples = """
    Usage example:\n
        cif2spg.py silicon.cif     => Open CIF file and visualize info on the spacegroup.
        cif2spg.py -g silicon.cif  => Same as above but use the GUI. 
    """
        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('cif_file', nargs=1, help="CIF File")

    parser.add_argument('-g', '--gui', action="store_true", help="Enable GUI")

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

    cif_file = options.cif_file[0]
    structure = abilab.Structure.from_file(cif_file)
    #print(structure.to_abivars())

    finder = SymmetryFinder(structure, symprec=1e-5, angle_tolerance=5)

    data = finder.get_symmetry_dataset()
    from pprint import pprint

    if not options.gui:
        pprint(data)

    else:
        from StringIO import StringIO
        import wx
        from abipy.gui.editor import SimpleTextViewer

        stream = StringIO()
        pprint(data, stream=stream)
        stream.seek(0)
        text = "".join(stream)
        app = wx.App()
        frame = SimpleTextViewer(None, text=text)
        frame.Show()
        app.MainLoop()

    return 0
예제 #2
0
파일: structure.py 프로젝트: zbwang/abipy
 def OnShow(self, event):
     s = self._convert()
     SimpleTextViewer(self, text=s, title=self.structure.formula).Show()
예제 #3
0
파일: flowviewer.py 프로젝트: gmrigna/abipy
def task_show_deps(parent, task):
    """Show the dependencies of the task."""
    text = task.str_deps()
    SimpleTextViewer(parent, text).Show()
예제 #4
0
파일: flowviewer.py 프로젝트: gmrigna/abipy
def show_history(parent, task):
    """Show the history of the task."""
    text = "\n".join(task.history)
    SimpleTextViewer(parent, text).Show()
예제 #5
0
 def OnShowInput(self, event):
     """Show the fftprof input in an external window."""
     fft_input = self.MakeInput()
     SimpleTextViewer(self, fft_input).Show()