Beispiel #1
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
Beispiel #2
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
Beispiel #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
    def load(self, z, subpath):
        """Load data from a zipped project file.

        z       -- zipped project file
        subpath -- path to its own storage within project file
        """
        self.clear()
        subs = subpath.split('/')
        rootDict = z.fileTree[subs[0]][subs[1]][subs[2]][subs[3]]
        import cPickle
        # raw data
        self.readObsStr(z.read(subpath + 'obs'))

        # data from calculation
        content = cPickle.loads(z.read(subpath + 'calc'))
        for item in FitDataSet.persistentItems:
            # skip items which are not in the project file
            if item not in content: continue
            # update dictionaries so that old project files load fine
            if item == 'initial':
                self.initial.update(content[item])
            elif item == 'refined':
                self.refined.update(content[item])
            else:
                setattr(self, item, content[item])
        self._updateRcalcRange()

        # constraints
        if rootDict.has_key('constraints'):
            from diffpy.pdfgui.control.pdfguicontrol import CtrlUnpickler
            self.constraints = CtrlUnpickler.loads(
                z.read(subpath + 'constraints'))
            # handle renamed variable from old project files
            translate = {'qsig': 'qdamp', 'qalp': 'qbroad'}
            for old, new in translate.items():
                if old in self.constraints:
                    self.constraints[new] = self.constraints.pop(old)

        return
Beispiel #5
0
    def load(self, z, subpath):
        """Load data from a zipped project file.

        z       -- zipped project file
        subpath -- path to its own storage within project file
        """
        self.clear()
        subs = subpath.split('/')
        rootDict = z.fileTree[subs[0]][subs[1]][subs[2]][subs[3]]
        import cPickle
        # raw data
        self.readObsStr(z.read(subpath+'obs'))

        # data from calculation
        content = cPickle.loads(z.read(subpath+'calc'))
        for item in FitDataSet.persistentItems:
            # skip items which are not in the project file
            if item not in content: continue
            # update dictionaries so that old project files load fine
            if item == 'initial':
                self.initial.update(content[item])
            elif item == 'refined':
                self.refined.update(content[item])
            else:
                setattr(self, item, content[item])
        self._updateRcalcRange()

        # constraints
        if rootDict.has_key('constraints'):
            from diffpy.pdfgui.control.pdfguicontrol import CtrlUnpickler
            self.constraints = CtrlUnpickler.loads(z.read(subpath+'constraints'))
            # handle renamed variable from old project files
            translate = {'qsig' : 'qdamp',  'qalp' : 'qbroad'}
            for old, new in translate.items():
                if old in self.constraints:
                    self.constraints[new] = self.constraints.pop(old)

        return