Exemple #1
0
    def read(self, filename, format='pwinput'):
        """Load structure from a file, any original data become lost.
l
        filename -- file to be loaded
        format   -- structure formats
                    'pwinput' ( pw.x input, default), 'pwoutput' (pw.x output),
                    'bratoms', 'cif', 'discus', 'pdb', 'pdffit', 'rawxyz', 
                    'xcfg', 'xyz'

        Return instance of data Parser used to process file.  This
        can be inspected for information related to particular format.
        """
        from qecalc.qetask.qeparser.qestructureparser import parser_index
        if self._qeInput == None:
            from qecalc.qetask.qeparser.pwinput import PWInput
            self._qeInput = PWInput()
            self._qeInput.structure = self
            #self._qeInput.parse()

        if format in parser_index:
            module = __import__("qestructureparser.P_" + format, globals(), \
                                locals(), ['P_' + format], -1)
            parser = module.getParser(self._qeInput)
            new_structure = parser.parse(filename)
        else:
            diffpyStruct = Structure()
            parser = diffpyStruct.read(filename, format=format)
            new_structure = QEStructure(qeInput=self._qeInput)
            new_structure._setStructureFromDiffpyStructure(diffpyStruct, \
                                        massList = [], psList = [], ibrav = 0)

        new_structure.lattice._qeInput.update(forceUpdate=True)
        self.__Init(new_structure)
        return parser
Exemple #2
0
    def read(self, filename, format = 'pwinput'):
        """Load structure from a file, any original data become lost.
l
        filename -- file to be loaded
        format   -- structure formats
                    'pwinput' ( pw.x input, default), 'pwoutput' (pw.x output),
                    'bratoms', 'cif', 'discus', 'pdb', 'pdffit', 'rawxyz', 
                    'xcfg', 'xyz'

        Return instance of data Parser used to process file.  This
        can be inspected for information related to particular format.
        """        
        from  qecalc.qetask.qeparser.qestructureparser import parser_index      
        if self._qeInput == None:
            from qecalc.qetask.qeparser.pwinput import PWInput         
            self._qeInput = PWInput()
            #self._qeInput.parse()
        
        if format in parser_index:             
            module = __import__("qestructureparser.P_" + format, globals(), \
                                locals(), ['P_' + format], -1)
            parser = module.getParser(self._qeInput)
            new_structure = parser.parse(filename)
        else:            
            diffpyStruct = Structure()
            parser = diffpyStruct.read(filename, format = format)
            new_structure = QEStructure(qeInput = self._qeInput)
            new_structure._setStructureFromDiffpyStructure(diffpyStruct, \
                                        massList = [], psList = [], ibrav = 0)

        new_structure.lattice._qeInput.update( forceUpdate = True )
        self.__Init(new_structure)
        return parser
Exemple #3
0
    def read(self, filename, format='auto'):
        """Same as Structure.read, but update spcgr value in
        self.pdffit when parser can get spacegroup.

        Return instance of StructureParser used to load the data.
        See Structure.read() for more info.
        """
        p = Structure.read(self, filename, format)
        sg = getattr(p, 'spacegroup', None)
        if sg:  self.pdffit['spcgr'] = sg.short_name
        return p