Exemplo n.º 1
0
    def obtainRefined(self, server, iphase):
        """Upload refined phase from PdfFit server instance.

        server -- instance of PdfFit server
        iphase -- index of this phase in server
        """
        server.setphase(iphase)
        if self.refined is None:
            self.refined = PDFStructure(self.name)
        self.refined.readStr(server.save_struct_string(iphase), 'pdffit')
        return
Exemplo n.º 2
0
 def test_copy(self):
     """check FitStructure.copy()
     """
     stru2 = self.stru.copy()
     self.assertEqual('noname', stru2.name)
     stru3 = Structure()
     self.assertRaises(ControlTypeError, stru2.copy, stru3)
     self.stru.refined = PDFStructure('refined-name')
     stru4 = self.stru.copy()
     self.assertIsNot(self.stru.refined, stru4.refined)
     self.assertEqual('refined-name', stru4.refined.name)
     return
Exemplo n.º 3
0
    def load(self, z, subpath):
        """Load structure from a zipped project file.

        z       -- zipped project file
        subpath -- path to its own storage within project file
        """
        #subpath = projname/fitname/structure/myname/
        from diffpy.pdfgui.control.pdfguicontrol import CtrlUnpickler
        subs = subpath.split('/')
        rootDict = z.fileTree[subs[0]][subs[1]][subs[2]][subs[3]]
        self.initial.readStr(z.read(subpath + 'initial'), 'pdffit')
        # refined
        if rootDict.has_key('refined'):
            self.refined = PDFStructure(self.name)
            self.refined.readStr(z.read(subpath + 'refined'), 'pdffit')
        # constraints
        if rootDict.has_key('constraints'):
            self.constraints = CtrlUnpickler.loads(
                z.read(subpath + 'constraints'))
            translate = {
                'gamma': 'delta1',
                'delta': 'delta2',
                'srat': 'sratio'
            }
            for old, new in translate.items():
                if old in self.constraints:
                    self.constraints[new] = self.constraints.pop(old)
        # selected_pairs
        if rootDict.has_key("selected_pairs"):
            self.selected_pairs = z.read(subpath + 'selected_pairs')
        # sgoffset
        if rootDict.has_key("sgoffset"):
            sgoffsetstr = z.read(subpath + 'sgoffset')
            sgoffset = [float(w) for w in sgoffsetstr.split()]
            self.initial.pdffit['sgoffset'] = sgoffset
        # custom_spacegroup
        if rootDict.has_key("custom_spacegroup"):
            bytes = z.read(subpath + 'custom_spacegroup')
            self.custom_spacegroup = CtrlUnpickler.loads(bytes)
        return
Exemplo n.º 4
0
 def setUp(self):
     self.stru = PDFStructure('noname')
     return