Esempio n. 1
0
def main():
    if len(sys.argv) < 2:
        print >> sys.stderr, "scriptfile not specified."
        sys.exit(2)
    elif not os.path.isfile(sys.argv[1]):
        print >> sys.stderr, "Cannot read %r" % sys.argv[1]
        sys.exit(2)
    scriptfile = sys.argv[1]
    scriptbase = os.path.basename(scriptfile)
    del sys.argv[1]
    box = PdfFitSandbox()
    try:
        box.loadscript(scriptfile)
    except:
        exc_type, exc_value, exc_tb = sys.exc_info()
        import traceback
        for filename, lineno, fnc, line in traceback.extract_tb(exc_tb):
            if os.path.basename(filename) != scriptbase:
                continue
            print >> sys.stderr, "%s:%i:%s" % (scriptfile, lineno, line)
        print >> sys.stderr, exc_value
        sys.exit(1)
    # make sure reading from stderr will not hang, see
    # http://www.python.org/doc/current/lib/popen2-flow-control.html
    os.close(sys.stderr.fileno())
    # all is ready, dump it
    sys.stdout.write( safeCPickleDumps(box.allfits()) )
    return
Esempio n. 2
0
    def save(self, z, subpath):
        """Save data to a zipped project file.

        z       -- zipped project file
        subpath -- path to its own storage within project file
        """
        from diffpy.pdfgui.utils import safeCPickleDumps
        # write raw data
        z.writestr(subpath + 'obs', self.writeObsStr())
        content = {}
        for item in FitDataSet.persistentItems:
            content[item] = getattr(self, item, None)
        bytes = safeCPickleDumps(content)
        z.writestr(subpath+'calc', bytes)

        # make a picklable dictionary of constraints
        if self.constraints:
            bytes = safeCPickleDumps(self.constraints)
            z.writestr(subpath + 'constraints', bytes)
        return
Esempio n. 3
0
    def save(self, z, subpath):
        """Save data to a zipped project file.

        z       -- zipped project file
        subpath -- path to its own storage within project file
        """
        from diffpy.pdfgui.utils import safeCPickleDumps
        # write raw data
        z.writestr(subpath + 'obs', self.writeObsStr())
        content = {}
        for item in FitDataSet.persistentItems:
            content[item] = getattr(self, item, None)
        bytes = safeCPickleDumps(content)
        z.writestr(subpath + 'calc', bytes)

        # make a picklable dictionary of constraints
        if self.constraints:
            bytes = safeCPickleDumps(self.constraints)
            z.writestr(subpath + 'constraints', bytes)
        return
Esempio n. 4
0
    def save(self, z, subpath):
        """Save structure to a zipped project file.

        z       -- zipped project file
        subpath -- path to its own storage within project file
        """
        from diffpy.pdfgui.utils import safeCPickleDumps
        z.writestr(subpath+'initial', self.initial.writeStr('pdffit'))
        if self.refined:
            z.writestr(subpath+'refined', self.refined.writeStr('pdffit'))
        if self.constraints:
            bytes = safeCPickleDumps(self.constraints)
            z.writestr(subpath+'constraints', bytes)
        z.writestr(subpath+'selected_pairs', self.selected_pairs)
        # sgoffset
        sgoffset = self.initial.pdffit.get('sgoffset', [0.0, 0.0, 0.0])
        sgoffsetstr = "%g %g %g" % tuple(sgoffset)
        z.writestr(subpath+'sgoffset', sgoffsetstr)
        if self.custom_spacegroup:
            bytes = safeCPickleDumps(self.custom_spacegroup)
            z.writestr(subpath+'custom_spacegroup', bytes)
        return
Esempio n. 5
0
    def save(self, z, subpath):
        """Save structure to a zipped project file.

        z       -- zipped project file
        subpath -- path to its own storage within project file
        """
        from diffpy.pdfgui.utils import safeCPickleDumps
        z.writestr(subpath+'initial', self.initial.writeStr('pdffit'))
        if self.refined:
            z.writestr(subpath+'refined', self.refined.writeStr('pdffit'))
        if self.constraints:
            bytes = safeCPickleDumps(self.constraints)
            z.writestr(subpath+'constraints', bytes)
        z.writestr(subpath+'selected_pairs', self.selected_pairs)
        # sgoffset
        sgoffset = self.initial.pdffit.get('sgoffset', [0.0, 0.0, 0.0])
        sgoffsetstr = "%g %g %g" % tuple(sgoffset)
        z.writestr(subpath+'sgoffset', sgoffsetstr)
        if self.custom_spacegroup:
            bytes = safeCPickleDumps(self.custom_spacegroup)
            z.writestr(subpath+'custom_spacegroup', bytes)
        return
Esempio n. 6
0
    def save(self, z, subpath):
        """save data from a zipped project file

        z       -- zipped project file
        subpath -- path to its own storage within project file
        """
        from diffpy.pdfgui.utils import safeCPickleDumps
        config = {
            'rmin' : self.rmin,
            'rstep' : self.rstep,
            'rmax' : self.rmax,
            'rlen' : self.rlen,
            'rcalc' : self.rcalc,
            'Gcalc' : self.Gcalc,
            'stype' : self.stype,
            'qmax' : self.qmax,
            'qdamp' : self.qdamp,
            'qbroad' : self.qbroad,
            'dscale' : self.dscale,
        }
        z.writestr(subpath + 'config', safeCPickleDumps(config))
        return
Esempio n. 7
0
    def save(self, z, subpath):
        """save data from a zipped project file

        z       -- zipped project file
        subpath -- path to its own storage within project file
        """
        from diffpy.pdfgui.utils import safeCPickleDumps
        config = {
            'rmin': self.rmin,
            'rstep': self.rstep,
            'rmax': self.rmax,
            'rlen': self.rlen,
            'rcalc': self.rcalc,
            'Gcalc': self.Gcalc,
            'stype': self.stype,
            'qmax': self.qmax,
            'qdamp': self.qdamp,
            'qbroad': self.qbroad,
            'dscale': self.dscale,
        }
        z.writestr(subpath + 'config', safeCPickleDumps(config))
        return
Esempio n. 8
0
    def save(self, z, subpath):
        """save data from a zipped project file

        z       -- zipped project file
        subpath -- path to its own storage within project file
        """
        from diffpy.pdfgui.utils import safeCPickleDumps

        config = {
            "rmin": self.rmin,
            "rstep": self.rstep,
            "rmax": self.rmax,
            "rlen": self.rlen,
            "rcalc": self.rcalc,
            "Gcalc": self.Gcalc,
            "stype": self.stype,
            "qmax": self.qmax,
            "qdamp": self.qdamp,
            "qbroad": self.qbroad,
            "dscale": self.dscale,
        }
        z.writestr(subpath + "config", safeCPickleDumps(config))
        return