예제 #1
0
 def config(self,cnf=None,**kw):
     if cnf is None and len(kw)==0:
         dict={}
         for key in self.__optionAliases.keys():
             dict[key] = [key,self.__optionAliases[key]]
         for key in self.__options.keys():
             dict[key] = OptionHandler.config(self,key)
         if self.__baseClass is None:
             return dict
         else:
             return AUTOutil.cnfmerge((dict,self.__baseClass.config(self)))
     elif type(cnf) == types.StringType:
         cnf = self.__applyOptionAliases(cnf)
         if self.__options.has_key(cnf):
             return (cnf,cnf,cnf,
                     self.__optionDefaults[cnf],
                     self.__options[cnf])
         else:
             if self.__baseClass is None:
                 raise AUTORuntimeError("Option %s not found"%cnf)
             else:
                 return self.__baseClass.config(self,cnf)
     else:
         dict = AUTOutil.cnfmerge((cnf,kw))
         self.__parseOptions(dict)
         if not(self.__baseClass is None):
             self.__baseClass.config(self,dict)
예제 #2
0
 def _addCommands(self,moduleList):
     for module in [AUTOCommands]:
         # Now we copy the commands from the module
         for key in module.__dict__.keys():
             # Check to see if it is a descendent of AUTOCommands.command
             if AUTOutil.findBaseClass(module.__dict__[key],AUTOCommands.command):
                 exec _functionTemplate%(key,module.__name__,key,key,key)
예제 #3
0
 def config(self,cnf=None,**kw):
     if type(cnf) == types.StringType or (cnf is None and len(kw) == 0):
         return self._configNoDraw(cnf)
     else:
         self._configNoDraw(AUTOutil.cnfmerge((cnf,kw)))
         self.clear()
         self.draw()
예제 #4
0
def _testFilename(inputname, outputname):
    import AUTOclui, AUTOutil, runAUTO
    old_path = os.getcwd()
    log = open("log", "w")

    os.environ["LANG"] = "C"
    console = AUTOInteractiveConsole(AUTOclui.exportFunctions(log=log))
    console.execfile(inputname)
    console.close()
    log.close()
    os.chdir(old_path)
    cmd = [
        "diff", "-b", "--ignore-matching-lines='.*ab\.o.*'",
        "--ignore-matching-lines='.*cir\.o.*'",
        "--ignore-matching-lines='.*wav\.o.*'",
        "--ignore-matching-lines='   [0-9][0-9 ]  .*'",
        "--ignore-matching-lines='Finished running:.*'",
        "--ignore-matching-lines='.*Location of special point.*'",
        "--ignore-matching-lines='[uU]sing .*'",
        "--ignore-matching-lines='.*Total Time.*'", "log", outputname
    ]
    status, output = AUTOutil.getstatusoutput(cmd)
    if status != 0:
        raise AUTOExceptions.AUTORegressionError(
            "Error: log files differ:\n%s" % output)
    os.system("rm -f log")
예제 #5
0
파일: runDemo.py 프로젝트: ttxtea/auto-07p
def test():
    import os
    import sys
    import AUTOutil

    log = open("log", "w")
    err = open("err", "w")
    stdout = sys.stdout

    class teelog(object):
        def write(self, text):
            log.write(text)
            stdout.write(text)

        def flush(self):
            log.flush()
            stdout.flush()

    runDemo("ab",
            log=teelog(),
            err=err,
            makefile="",
            demos_dir=os.path.join(os.environ["AUTO_DIR"], "python"),
            clean="yes")
    log.close()
    err.close()

    diffopts = [
        "diff", "-b", "--ignore-matching-lines='.*Total Time.*'",
        "--ignore-matching-lines='.*ab\.o.*'",
        "--ignore-matching-lines='   [0-9]  .*'"
    ]
    status, output = AUTOutil.getstatusoutput(diffopts +
                                              ["log", "test_data/runDemo.log"])
    if status != 0:
        raise AUTOExceptions.AUTORegressionError("Log files differ")

    status, output = AUTOutil.getstatusoutput(diffopts +
                                              ["err", "test_data/runDemo.err"])
    if status != 0:
        raise AUTOExceptions.AUTORegressionError("Error files differ")

    os.remove("log")
    os.remove("err")
예제 #6
0
    def __init__(self, parent=None, cnf={}, **kw):

        optionDefaults = {}
        # The kind of diagram (single solution vs. bifur diagram)
        optionDefaults["type"] = ("bifurcation", self.__optionCallback)
        # The X column
        optionDefaults["bifurcation_x"] = ([0], self.__optionCallback)
        optionDefaults["solution_x"] = (["t"], self.__optionCallback)
        # The Y column
        optionDefaults["bifurcation_y"] = ([1], self.__optionCallback)
        optionDefaults["solution_y"] = ([0], self.__optionCallback)
        # Sets of labels that the user is likely to want to use
        optionDefaults["label_defaults"] = (None, self.__optionCallback)
        # Sets of columns that the user is likely to want to use
        optionDefaults["bifurcation_column_defaults"] = (None, self.__optionCallback)
        optionDefaults["solution_column_defaults"] = (None, self.__optionCallback)
        # The index of the solution we wish to draw
        optionDefaults["index"] = ([0], self.__optionCallback)
        # The label of the solution we wish to draw
        optionDefaults["label"] = ([0], self.__optionCallback)

        # Already parsed data structures
        optionDefaults["bifurcation_diagram"] = (parseB.parseB(), self.__optionCallback)
        optionDefaults["solution"] = (parseS.parseS(), self.__optionCallback)
        optionDefaults["bifurcation_diagram_filename"] = ("", self.__optionCallback)
        optionDefaults["solution_filename"] = ("", self.__optionCallback)
        optionDefaults["runner"] = (None, self.__optionCallback)
        optionDefaults["mark_t"] = (None, self.__optionCallback)

        optionDefaults["bifurcation_symbol"] = ("B", self.__optionCallback)
        optionDefaults["limit_point_symbol"] = ("L", self.__optionCallback)
        optionDefaults["hopf_symbol"] = ("H", self.__optionCallback)
        optionDefaults["period_doubling_symbol"] = ("D", self.__optionCallback)
        optionDefaults["torus_symbol"] = ("T", self.__optionCallback)
        optionDefaults["user_point_symbol"] = ("U", self.__optionCallback)
        optionDefaults["error_symbol"] = ("X", self.__optionCallback)
        optionDefaults["use_labels"] = (1, self.__optionCallback)

        parser = ConfigParser.ConfigParser()
        parser.add_section("AUTO_plotter")
        if os.path.exists(os.path.expandvars("$AUTO_DIR/.autorc")):
            parser.read(os.path.expandvars("$AUTO_DIR/.autorc"))
        if os.path.exists(os.path.expandvars("$HOME/.autorc")):
            parser.read(os.path.expandvars("$HOME/.autorc"))
        if os.path.exists("./.autorc"):
            parser.read("./.autorc")

        for option in parser.options("AUTO_plotter"):
            optionDefaults[option] = (eval(parser.get("AUTO_plotter", option)), self.__optionCallback)

        self.__needsPlot = None
        apply(grapher.GUIGrapher.__init__, (self, parent))

        dict = AUTOutil.cnfmerge((cnf, kw))
        self.addOptions(optionDefaults)
        plotter.config(self, dict)
    def __init__(self, outputRecorder=None, errorRecorder=None):

        # Initialize the global AUTO runner
        runner = runAUTO.runAUTO()
        if outputRecorder is not None:
            stdout = sys.stdout

            class WriteLog(object):
                def write(self, s):
                    outputRecorder.write(s)
                    stdout.write(s)

                def flush(self):
                    outputRecorder.flush()
                    stdout.flush()

            runner.config(log=WriteLog())
        if errorRecorder is not None:
            stderr = sys.stderr

            class WriteErr(object):
                def write(self, s):
                    errorRecorder.write(s)
                    stderr.write(s)

                def flush(self):
                    errorRecorder.flush()
                    stderr.flush()

            runner.config(err=WriteErr())
        self._runner = runner

        # Read in the aliases.
        self._aliases = None

        parser = AUTOutil.getAUTORC()
        if parser.has_section("AUTO_command_aliases"):
            self._aliases = {}
            for option in parser.options("AUTO_command_aliases"):
                cmd = parser.get("AUTO_command_aliases", option)
                if cmd not in self._aliases:
                    self._aliases[cmd] = []
                self._aliases[cmd].append(option)

        self._addCommands([AUTOCommands])

        # Now I resolve the aliases
        for key, aliases in list(self._aliases.items()):
            for alias in aliases:
                f = self._copyfunction(getattr(AUTOCommands, key).fun, alias)
                setattr(self, alias, f)
                doc = getattr(AUTOCommands, key).__doc__
                doc = self._adjustdoc(doc, alias, key)
                f.__doc__ = doc
예제 #8
0
 def config(self, cnf=None, **kw):
     if type(cnf) == types.StringType or (cnf is None and len(kw) == 0):
         return self._configNoDraw(cnf)
     else:
         self._configNoDraw(AUTOutil.cnfmerge((cnf, kw)))
     if self.__needsPlot:
         self._plotNoDraw()
         self.__needsPlot = None
     self.clear()
     self.computeXRange()
     self.computeYRange()
     self.draw()
     self.update()
예제 #9
0
    def __init__(self,parent=None,cnf={},**kw):
        kw=AUTOutil.cnfmerge((cnf,kw))
        apply(InteractiveGrapher.__init__,(self,parent),kw)
        self.bind("<ButtonPress-3>",self.popupMenuWrapper)
        self.menu=Tkinter.Menu()
        self.menu.add_radiobutton(label="print value",command=self.printValueBindings)
#        self.menu.add_radiobutton(label="print tag",command=self.printTagBindings)
#        self.menu.add_radiobutton(label="label point",command=self.labelPointBindings)
        self.menu.add_radiobutton(label="zoom",command=self.zoomBindings)
        self.menu.invoke('zoom')
        self.menu.add_command(label="Unzoom",command=self.unzoom)
        self.menu.add_command(label="Postscript",command=self.generatePostscript)
        self.menu.add_command(label="Configure...",command=self.__interactiveConfigureDialog)
        self.bind("<Configure>",self.drawWrapper)
예제 #10
0
 def expert(self,keys):
     baseList = []
     for key in keys:
         # Check to see if it is a descendent of AUTOCommands.command
         if AUTOutil.findBaseClass(AUTOCommands.__dict__[key],AUTOCommands.command):
             bases = AUTOCommands.__dict__[key].__bases__
             for base in bases:
                 if not(base in baseList):
                     baseList.append(base)
     
     for base in baseList:
         if base.__name__[:7] == "command" and len(base.__name__) > 7: 
             self.addmenu(base.__name__[7:],'Commands which inherit from %s'%base.__name__)
         else:
             self.addmenu(base.__name__,'Commands which inherit from %s'%base.__name__)
     self.addExpertCommands([AUTOCommands])
예제 #11
0
파일: parseB.py 프로젝트: bzhurov/auto
 def getLabel(self,label):
     """Given a label, return the correct solution"""
     if label is None:
         return self
     if isinstance(label, int):
         for k in self.labels.getIndices():
             v = self._gettypelabel(k)[1]
             if v.get("LAB",0) == label:
                 return self.getIndex(k)
         raise KeyError("Label %s not found"%label)
     if isinstance(label, str) and len(label) > 2 and label[-1].isdigit():
         j = 2
         if not label[2].isdigit():
             j = 3
         number = int(label[j:])
         i = 0
         for k,v in self.labels.sortByIndex():
             if label[:j] in v:
                 i  = i + 1
                 if i == number:
                     return self.getIndex(k)
         raise KeyError("Label %s not found"%label)
     if not AUTOutil.isiterable(label):
         label = [label]
     labels = {}
     counts = [0]*len(label)
     for k,val in self.labels.sortByIndex():
         ty_name,v = self._gettypelabel(k)
         if "LAB" not in v:
             continue
         for i in range(len(label)):
             lab = label[i]
             j = 2
             if len(lab) > 2 and not lab[2].isdigit():
                 j = 3
             if (isinstance(lab, str) and len(lab) > j and
                 ty_name == lab[:j]):
                 counts[i] = counts[i] + 1
                 if counts[i] == int(lab[j:]):
                     labels[k] = val
         if v["LAB"] in label or ty_name in label:
             labels[k] = val
             continue
     new = self.__class__(self)
     new.labels = Points.PointInfo(labels)
     return new
예제 #12
0
 def addExpertCommands(self,moduleList):
     for module in moduleList:
         keys = module.__dict__.keys()
         keys.sort()
         for key in keys:
             # Check to see if it is a descendent of AUTOCommands.command
             if AUTOutil.findBaseClass(module.__dict__[key],AUTOCommands.command):
                 if module.__dict__[key].__bases__[0] == AUTOCommands.command:
                     self.addmenuitem('command',
                                      'command',
                                      key,label=key,
                                      command=lambda obj=self,name=key,command=module.__dict__[key]:obj._getArgs(name,command))
                 else:
                     self.addmenuitem(module.__dict__[key].__bases__[0].__name__[7:],
                                      'command',
                                      key,label=key,
                                      command=lambda obj=self,name=key,command=module.__dict__[key]:obj._getArgs(name,command))
예제 #13
0
    def __init__(self,parent=None,cnf={},**kw):
        self.data = []

        #Get the data from the arguements and then erase the
        #ones which are not used by canvas
        optionDefaults={}
        optionDefaults["minx"] = (0,None)
        optionDefaults["maxx"] = (0,None)
        optionDefaults["miny"] = (0,None)
        optionDefaults["maxy"] = (0,None)
        optionDefaults["left_margin"] = (80,None)
        optionDefaults["right_margin"] = (40,None)
        optionDefaults["top_margin"] = (40,None)
        optionDefaults["bottom_margin"] = (40,None)
        optionDefaults["decorations"] = (1,None)
        optionDefaults["xlabel"] = ("",None)
        optionDefaults["ylabel"] = ("",None)
        optionDefaults["xticks"] = (5,None)
        optionDefaults["yticks"] = (5,None)
        optionDefaults["grid"] = ("yes",None)
        optionDefaults["tick_label_template"] = ("%.2e",None)
        optionDefaults["tick_length"] = (0.2,None)
        optionDefaults["odd_tick_length"] = (0.4,None)
        optionDefaults["even_tick_length"] = (0.2,None)
        # background is handled by the Canvas widget
        optionDefaults["foreground"] = ("black",None)
        optionDefaults["color_list"] = ("black red green blue",None)
        optionDefaults["symbol_font"] = ("-misc-fixed-*-*-*-*-*-*-*-*-*-*-*-*",None)
        optionDefaults["symbol_color"] = ("red",None)
        optionDefaults["smart_label"] = (0,None)
        optionDefaults["line_width"] = (2,None)
        optionDefaults["realwidth"] = (1,None)
        optionDefaults["realheight"] = (1,None)

        optionAliases = {}
        optionAliases["fg"] = "foreground"
        # __parseOptions uses functions from the Canvas
        # widget, so we need to initialize it first
        apply(Tkinter.Canvas.__init__,(self,parent))
        optionHandler.OptionHandler.__init__(self,Tkinter.Canvas)

        dict = AUTOutil.cnfmerge((cnf,kw))
        self.addOptions(optionDefaults)
        self.addAliases(optionAliases)
        BasicGrapher.config(self,dict)
예제 #14
0
 def __compactindexed(self, value):
     """compact THL/THU/UZR lists"""
     d = []
     v0s = []
     for v0, v1 in value:
         if v0 in v0s:
             if not AUTOutil.isiterable(v1):
                 v1 = [v1]
             # add to list when parameter was already encountered
             try:
                 d[v0s.index(v0)][1].extend(v1)
             except AttributeError:
                 d[v0s.index(v0)][1] = [d[v0s.index(v0)][1]]
                 d[v0s.index(v0)][1].extend(v1)
         else:
             v0s.append(v0)
             d.append([v0, v1])
     return d
예제 #15
0
    def __oldstr(self):
        olist = [self.__newstr([
                ["e", "s", "dat", "sv"],
                ["unames", "parnames"],
                ["U", "PAR"],
                ["NPAR", "IBR", "LAB"],
                ["STOP"],
                ["SP"],
                ["NUNSTAB", "NSTAB", "IEQUIB", "ITWIST", "ISTART"],
                ["IREV", "IFIXED", "IPSI"]])]
            
        for j, line_comment in enumerate(self.line_comments):
            if j==1:
                s = " ".join([str(len(self["ICP"]))]+list(map(str,self["ICP"])))
            elif j==7:
                s = str(len(self["THL"]))
            elif j==8:
                s = str(len(self["THU"]))
            elif j==9:
                uzrlist = []
                for k, v in self["UZR"] or []:
                    if not AUTOutil.isiterable(v):
                        v = [v]
                    for vv in v:
                        uzrlist.append([k, vv])
                s = str(len(uzrlist))
            else:
                s = " ".join([str(self[d]) for d in line_comment.split(",")])
            olist.append(s+" "*(max(24-len(s),1))+line_comment+"\n")
            if j==7:
                for k, v in self["THL"] or []:
                    olist.append("%s %s\n" % (k, v))
            elif j==8:
                for k, v in self["THU"] or []:
                    olist.append("%s %s\n" % (k, v))
            elif j==9:
                for k, v in uzrlist:
                    olist.append("%s %s\n" % (k, v))

        return "".join(olist)
예제 #16
0
 def addSimpleCommands(self,moduleList):
     self.defaultEntry = Pmw.EntryField(self,
                                        labelpos = 'w',
                                        label_text = 'Default name:',
                                        validate = None,
                                        command = self.__setDefault)
     self.defaultEntry.grid(row=0,columnspan=2)
     for module in moduleList:
         keys = module.__dict__.keys()
         keys.sort()
         i = 0
         for key in keys:
             # Check to see if it is a descendent of AUTOCommands.command
             if AUTOutil.findBaseClass(module.__dict__[key],AUTOCommands.command):
                 try:
                     if module.__dict__[key].type==AUTOCommands.SIMPLE:
                         button = Tkinter.Button(self,text=module.__dict__[key].shortName,
                                                 command=lambda obj=self,name=key,command=module.__dict__[key]:obj._getArgs(name,command))
                         button.grid(row=i/2 + 1,column=i%2)
                         i = i + 1
                 except AttributeError:
                     pass
예제 #17
0
 def __init__(self,parent=None,cnf={},**kw):
     kw=AUTOutil.cnfmerge((cnf,kw))
     apply(LabeledGrapher.__init__,(self,parent),kw)    
예제 #18
0
파일: parseB.py 프로젝트: bzhurov/auto
 def readFilename(self,filename):
     inputfile = AUTOutil.openFilename(filename,"r")
     self.read(inputfile)
     inputfile.close()
예제 #19
0
    def __init__(self, filename):
        if isinstance(filename, str):
            inputfile = AUTOutil.openFilename(filename, "rb")
        else:
            inputfile = filename
        self.inputfile = inputfile
        self.name = inputfile.name
        self.solutions = []

        # We now go through the file and read the solutions.
        prev = None
        # for fort.8 we need to read everything into memory; otherwise load the
        # data on demand from disk when we really need it
        # on Windows always load everything because deleting open files is
        # impossible there
        inmemory = (os.path.basename(inputfile.name) == 'fort.8'
                    or sys.platform in ['cygwin', 'win32'])
        while len(inputfile.read(1)) > 0:
            line = inputfile.readline()
            if not line: raise PrematureEndofData
            try:
                header = list(map(int, line.split()))
            except ValueError:
                raise PrematureEndofData
            if len(header) < 10:
                raise PrematureEndofData
            if len(header) == 10:
                # This is the case for AUTO94 and before
                header = header + [NPAR]
            numLinesPerEntry = header[8]
            start_of_data = inputfile.tell()
            if prev is not None and all(
                [header[i] == prevheader[i] for i in [4, 6, 7, 8, 11]]):
                # guess the end from the previous solution
                end += inputfile.tell() - prev
                # See if the guess for the solution end is correct
                inputfile.seek(end)
                data = inputfile.readline().split()
                # This is where we detect the end of the file
                if len(data) == 0:
                    data = inputfile.read(1)
                if len(data) != 0:
                    try:
                        # Check length of line...
                        if len(data) != 12 and len(data) != 16:
                            raise IncorrectHeaderLength
                        # and the fact they are all integers
                        map(int, data)
                        # and the fact that NCOL*NTST+1=NTPL
                        if int(data[9]) * int(data[10]) + 1 != int(data[6]):
                            end = None
                        # If it passes all these tests we say it is a header line
                        # and we can read quickly
                    except:
                        # otherwise the guessed end is not valid
                        end = None
            else:
                end = None
            data = None
            if end is None:
                # We skip the correct number of lines in the entry to
                # determine its end.
                inputfile.seek(start_of_data)
                if inmemory:
                    data = "".encode("ascii").join([
                        inputfile.readline() for i in range(numLinesPerEntry)
                    ])
                else:
                    for i in range(numLinesPerEntry):
                        inputfile.readline()
                end = inputfile.tell()
            elif inmemory:
                inputfile.seek(start_of_data)
                data = inputfile.read(end - start_of_data)
            else:
                inputfile.seek(end)
            if data is None:
                data = (start_of_data, end)
            self.solutions.append({'header': header, 'data': data})
            prev = start_of_data
            prevheader = header
예제 #20
0
 def getLabel(self, label):
     if label is None:
         return self
     if isinstance(label, int):
         for d in self:
             if d["Label"] == label:
                 return d
         raise KeyError("Label %s not found" % label)
     if isinstance(label, str) and len(label) > 2 and label[-1].isdigit():
         j = 2
         if not label[2].isdigit():
             j = 3
         number = int(label[j:])
         i = 0
         for d in self:
             if d["Type name"] == label[:j]:
                 i = i + 1
                 if i == number:
                     return d
         raise KeyError("Label %s not found" % label)
     if isinstance(label, types.FunctionType):
         # accept a user-defined boolean function
         f = label
         cnt = getattr(f, "func_code", getattr(f, "__code__",
                                               None)).co_argcount
         if cnt == 1:
             # function takes just one parameter
             s = [s for s in self if f(s)]
         elif cnt == 2:
             # function takes two parameters: compare all solutions
             # with each other
             indices = set([])
             for i1, s1 in enumerate(self):
                 if i1 in indices:
                     continue
                 for i2 in range(i1 + 1, len(self)):
                     if i2 not in indices and f(s1, self[i2]):
                         indices.add(i2)
             s = [self[i] for i in sorted(indices)]
         else:
             raise AUTOExceptions.AUTORuntimeError(
                 "Invalid number of arguments for %s." % f.__name__)
         return self.__class__(s)
     if not AUTOutil.isiterable(label):
         label = [label]
     data = []
     counts = [0] * len(label)
     for d in self:
         ap = None
         if d["Label"] in label or d["Type name"] in label:
             ap = d
         for i in range(len(label)):
             lab = label[i]
             j = 2
             if len(lab) > 2 and not lab[2].isdigit():
                 j = 3
             if (isinstance(lab, str) and len(lab) > j
                     and d["Type name"] == lab[:j]):
                 counts[i] = counts[i] + 1
                 if counts[i] == int(lab[j:]):
                     ap = d
         if ap is not None:
             data.append(ap)
     return self.__class__(data)
예제 #21
0
    def __init__(self,parent=None,cnf={},**kw):
        optionDefaults={}
        optionDefaults["problem"] = ("auto_plotter3d",self.__optionCallback)
        # The kind of diagram (single solution vs. bifur diagram)
        optionDefaults["type"]     = ("bifurcation",self.__optionCallback)  
        # The X column
        optionDefaults["bifurcation_x"]     = ([0],self.__optionCallback)
        optionDefaults["solution_x"]        = (["t"],self.__optionCallback)
        # The Y column
        optionDefaults["bifurcation_y"]     = ([1],self.__optionCallback)
        optionDefaults["solution_y"]        = ([0],self.__optionCallback)
        # The Z column
        optionDefaults["bifurcation_z"]     = ([1],self.__optionCallback)
        optionDefaults["solution_z"]        = ([0],self.__optionCallback)
        # The Color column
        optionDefaults["bifurcation_color"] = ([1],self.__optionCallback)
        optionDefaults["solution_color"]    = ([0],self.__optionCallback)
        # Sets of labels that the user is likely to want to use
        optionDefaults["label_defaults"]   = (None,self.__optionCallback)
        # Sets of columns that the user is likely to want to use
        optionDefaults["bifurcation_column_defaults"]   = (None,self.__optionCallback)
        optionDefaults["solution_column_defaults"]   = (None,self.__optionCallback)
        # The index of the solution we wish to draw
        optionDefaults["index"]    = ([0],self.__optionCallback)
        # The label of the solution we wish to draw
        optionDefaults["label"]    = ([0],self.__optionCallback)

        # Already parsed data structures
        optionDefaults["bifurcation_diagram"]          = (parseB.parseB(),self.__optionCallback)
        optionDefaults["solution"]          = (parseS.parseS(),self.__optionCallback)
        optionDefaults["bifurcation_diagram_filename"] = ("",self.__optionCallback)
        optionDefaults["solution_filename"] = ("",self.__optionCallback)
        optionDefaults["runner"]         = (None,self.__optionCallback)
        optionDefaults["mark_t"]         = (None, self.__optionCallback)
        optionDefaults["mark_t_radius"]  = (0.01, self.__optionCallback)
        optionDefaults["mark_t_color"]   = ((1.0,1.0,1.0), self.__optionCallback)


        # Options for the GUI
        optionDefaults["bifurcation_x_scale"]       = (1.0,None)
        optionDefaults["bifurcation_y_scale"]       = (1.0,None)
        optionDefaults["bifurcation_z_scale"]       = (1.0,None)
        optionDefaults["bifurcation_x_trans"]       = (0.0,None)
        optionDefaults["bifurcation_y_trans"]       = (0.0,None)
        optionDefaults["bifurcation_z_trans"]       = (0.0,None)
        optionDefaults["solution_x_scale"]       = (1.0,None)
        optionDefaults["solution_y_scale"]       = (1.0,None)
        optionDefaults["solution_z_scale"]       = (1.0,None)
        optionDefaults["solution_x_trans"]       = (0.0,None)
        optionDefaults["solution_y_trans"]       = (0.0,None)
        optionDefaults["solution_z_trans"]       = (0.0,None)

        optionDefaults["line_width"]        = (1.0,None)
        optionDefaults["cylinder"]     = (0,None)
        optionDefaults["geom_comp"]    = (7,None)
        optionDefaults["light_comp"]   = (7,None)
        optionDefaults["write_points_on"] = (0,None)

        optionDefaults["grid_on"]       = (0,None)
        optionDefaults["grid_lines"]    = (6,None)
        optionDefaults["grid_1_start"]  = (-1.0,None)
        optionDefaults["grid_2_start"]  = (-1.0,None)
        optionDefaults["grid_1_end"]    = (1.0,None)
        optionDefaults["grid_2_end"]    = (1.0,None)
        optionDefaults["grid_width"]    = (1.0,None)
        optionDefaults["grid_R"]        = (1.0,None)
        optionDefaults["grid_G"]        = (1.0,None)
        optionDefaults["grid_B"]        = (1.0,None)
        optionDefaults["grid_cylinder"] = (0,None)
        optionDefaults["grid_direction"]= (["x","y","z"],None)

        optionDefaults["cube_on"]    = (1,None)
        optionDefaults["cube_R"]     = (1.0,None)
        optionDefaults["cube_G"]     = (1.0,None)
        optionDefaults["cube_B"]     = (1.0,None)
        

        optionDefaults["auto_center"]= (1,None)
        optionDefaults["auto_scale"]= (1,None)

        parser = ConfigParser.ConfigParser()
        parser.add_section("AUTO_plotter3D")
        if(os.path.exists(os.path.expandvars("$AUTO_DIR/.autorc"))):
            parser.read(os.path.expandvars("$AUTO_DIR/.autorc"))
        if(os.path.exists(os.path.expandvars("$HOME/.autorc"))):
            parser.read(os.path.expandvars("$HOME/.autorc"))
        if(os.path.exists("./.autorc")):
            parser.read("./.autorc")

        for option in parser.options("AUTO_plotter3D"):
            optionDefaults[option] = (eval(parser.get("AUTO_plotter3D",option)),self.__optionCallback)


        Tkinter.Frame.__init__(self,parent)
        optionHandler.OptionHandler.__init__(self)

        self.user_data = {}

        dict = AUTOutil.cnfmerge((cnf,kw))
        self.addOptions(optionDefaults)
        plotter3D.config(self,dict)
예제 #22
0
    def __init__(self,parent=None,cnf={},**kw):
        optionDefaults={}
        optionDefaults["problem"] = ("auto_plotter3d",self.__optionCallback)
        # The kind of diagram (single solution vs. bifur diagram)
        optionDefaults["type"]     = ("bifurcation",self.__optionCallback)  
        # The X column
        optionDefaults["bifurcation_x"]     = ([0],self.__optionCallback)
        optionDefaults["solution_x"]        = (["t"],self.__optionCallback)
        # The Y column
        optionDefaults["bifurcation_y"]     = ([1],self.__optionCallback)
        optionDefaults["solution_y"]        = ([0],self.__optionCallback)
        # The Z column
        optionDefaults["bifurcation_z"]     = ([1],self.__optionCallback)
        optionDefaults["solution_z"]        = ([0],self.__optionCallback)
        # The Color column
        optionDefaults["bifurcation_color"] = ([1],self.__optionCallback)
        optionDefaults["solution_color"]    = ([0],self.__optionCallback)
        # Sets of labels that the user is likely to want to use
        optionDefaults["label_defaults"]   = (None,self.__optionCallback)
        # Sets of columns that the user is likely to want to use
        optionDefaults["bifurcation_column_defaults"]   = (None,self.__optionCallback)
        optionDefaults["solution_column_defaults"]   = (None,self.__optionCallback)
        # The index of the solution we wish to draw
        optionDefaults["index"]    = ([0],self.__optionCallback)
        # The label of the solution we wish to draw
        optionDefaults["label"]    = ([0],self.__optionCallback)

        # Already parsed data structures
        optionDefaults["bifurcation_diagram"]          = (parseB.parseB(),self.__optionCallback)
        optionDefaults["solution"]          = (parseS.parseS(),self.__optionCallback)
        optionDefaults["bifurcation_diagram_filename"] = ("",self.__optionCallback)
        optionDefaults["solution_filename"] = ("",self.__optionCallback)
        optionDefaults["runner"]         = (None,self.__optionCallback)
        optionDefaults["mark_t"]         = (None, self.__optionCallback)
        optionDefaults["mark_t_radius"]  = (0.01, self.__optionCallback)
        optionDefaults["mark_t_color"]   = ((1.0,1.0,1.0), self.__optionCallback)

        optionDefaults["special_point"]  = (None, self.__optionCallback)
        optionDefaults["special_point_radius"] = (0.005, self.__optionCallback)
        optionDefaults["special_point_colors"] = ([[0.0,0.0,1.0],  #Blue for branch point
                                                  [0.0,1.0,0.0],  #Green for fold
                                                  [1.0,1.0,0.0],  #Yellow for hopf
                                                  [0.0,1.0,1.0],  #Cyan for Period Doubling
                                                  [1.0,0.0,0.0],  #Red for Torus 
                                                  [0.5,0.5,0.5],  #Grey for user requested point
                                                  [0.1,0.1,0.1]], #Dark grey for error
                                                  self.__optionCallback)  

        # Options for the GUI
        optionDefaults["bifurcation_x_scale"]       = (1.0,None)
        optionDefaults["bifurcation_y_scale"]       = (1.0,None)
        optionDefaults["bifurcation_z_scale"]       = (1.0,None)
        optionDefaults["bifurcation_x_trans"]       = (0.0,None)
        optionDefaults["bifurcation_y_trans"]       = (0.0,None)
        optionDefaults["bifurcation_z_trans"]       = (0.0,None)
        optionDefaults["solution_x_scale"]       = (1.0,None)
        optionDefaults["solution_y_scale"]       = (1.0,None)
        optionDefaults["solution_z_scale"]       = (1.0,None)
        optionDefaults["solution_x_trans"]       = (0.0,None)
        optionDefaults["solution_y_trans"]       = (0.0,None)
        optionDefaults["solution_z_trans"]       = (0.0,None)

        optionDefaults["line_width"]        = (1.0,None)
        optionDefaults["cylinder"]     = (0,None)
        optionDefaults["geom_comp"]    = (7,None)
        optionDefaults["light_comp"]   = (7,None)
        optionDefaults["write_points_on"] = (0,None)

        optionDefaults["grid_on"]       = (0,None)
        optionDefaults["grid_lines"]    = (6,None)
        optionDefaults["grid_1_start"]  = (-1.0,None)
        optionDefaults["grid_2_start"]  = (-1.0,None)
        optionDefaults["grid_1_end"]    = (1.0,None)
        optionDefaults["grid_2_end"]    = (1.0,None)
        optionDefaults["grid_width"]    = (1.0,None)
        optionDefaults["grid_R"]        = (1.0,None)
        optionDefaults["grid_G"]        = (1.0,None)
        optionDefaults["grid_B"]        = (1.0,None)
        optionDefaults["grid_cylinder"] = (0,None)
        optionDefaults["grid_direction"]= (["x","y","z"],None)

        optionDefaults["cube_on"]    = (1,None)
        optionDefaults["cube_R"]     = (1.0,None)
        optionDefaults["cube_G"]     = (1.0,None)
        optionDefaults["cube_B"]     = (1.0,None)
        

        optionDefaults["auto_center"]= (1,None)
        optionDefaults["auto_scale"]= (1,None)

        parser = ConfigParser.ConfigParser()
        parser.add_section("AUTO_plotter3D")
        if(os.path.exists(os.path.expandvars("$AUTO_DIR/.autorc"))):
            parser.read(os.path.expandvars("$AUTO_DIR/.autorc"))
        if(os.path.exists(os.path.expandvars("$HOME/.autorc"))):
            parser.read(os.path.expandvars("$HOME/.autorc"))
        if(os.path.exists("./.autorc")):
            parser.read("./.autorc")

        for option in parser.options("AUTO_plotter3D"):
            optionDefaults[option] = (eval(parser.get("AUTO_plotter3D",option)),self.__optionCallback)

	geom.Geometry.__init__(self,parent)

        optionHandler.OptionHandler.__init__(self,geom.Geometry)

        self.user_data = {}

        dict = AUTOutil.cnfmerge((cnf,kw))
        self.addOptions(optionDefaults)
        self.set_problem(self.cget("problem"))
        plotter3D.config(self,dict)

	self.zoom_scale = 0.03
	self.default_zoom = -10.0
        self.bind('<Lock-ButtonPress-3>',self.zoom_mouse_down)
        self.bind('<Lock-Button3-Motion>',self.zoom_mouse_move)
	self.zoom(0.15)

        self.bind('<ButtonPress-3>',self.translate_mouse_down)
        self.bind('<Button3-Motion>',self.translate_mouse_move)
        self.bind('<Shift-ButtonPress-2>',self.zoom_mouse_down)
        self.bind('<Shift-Button2-Motion>',self.zoom_mouse_move)
        self.bind('<ButtonPress-2>',self.rotate_mouse_down)
        self.bind('<Button2-Motion>',self.rotate_mouse_move)
        self.bind('<ButtonRelease-2>',self.spin_mouse)

        self.tk_focusFollowsMouse()
        self.bind('<KeyPress-Up>',self.KeyEvent)
        self.bind('<KeyPress-Down>',self.KeyEvent)
        self.bind('<KeyPress-Left>',self.KeyEvent)
        self.bind('<KeyPress-Right>',self.KeyEvent)
        self.bind('<KeyPress-Next>',self.KeyEvent)
        self.bind('<KeyPress-Prior>',self.KeyEvent)

        self.bind('<Control-KeyPress-Up>',self.KeyEvent)
        self.bind('<Control-KeyPress-Down>',self.KeyEvent)
        self.bind('<Control-KeyPress-Left>',self.KeyEvent)
        self.bind('<Control-KeyPress-Right>',self.KeyEvent)
        self.bind('<Control-KeyPress-Next>',self.KeyEvent)
        self.bind('<Control-KeyPress-Prior>',self.KeyEvent)
예제 #23
0
 def _configNoDraw(self, cnf=None, **kw):
     if type(cnf) == types.StringType or (cnf is None and len(kw) == 0):
         return grapher.GUIGrapher._configNoDraw(self, cnf)
     else:
         grapher.GUIGrapher._configNoDraw(self, AUTOutil.cnfmerge((cnf, kw)))
예제 #24
0
 def addOptions(self,dict,**kw):
     dict = AUTOutil.cnfmerge((dict,kw))
     for key in dict.keys():
         self.__optionDefaults[key] = dict[key][0]
         self.__options[key] = dict[key][0]
         self.__optionCallbacks[key] = dict[key][1]
예제 #25
0
 def addAliases(self,dict,**kw):
     dict = AUTOutil.cnfmerge((dict,kw))
     for key in dict.keys():
         self.__optionAliases[key] = dict[key]
예제 #26
0
 def __init__(self,parent=None,cnf={},**kw):
     WindowPlotter.__init__(self,plotterDataViewer3D.plotter3D,parent,AUTOutil.cnfmerge((cnf,kw)))
예제 #27
0
 def __init__(self,parent=None,cnf={},**kw):
     kw=AUTOutil.cnfmerge((cnf,kw))
     self.labels=[]
     apply(BasicGrapher.__init__,(self,parent),kw)
    def __init__(self,parent=None,**kw):

        optionDefaults = {}
        # The kind of diagram (single solution vs. bifur diagram)
        optionDefaults["type"]     = ("bifurcation",self.__optionCallback)  
        # The X column
        optionDefaults["bifurcation_x"] = ([0],self.__optionCallback)
        optionDefaults["solution_x"]    = ([-1],self.__optionCallback)
        # The Y column
        optionDefaults["bifurcation_y"] = ([1],self.__optionCallback)
        optionDefaults["solution_y"]    = ([0],self.__optionCallback)
        # The Z column
        optionDefaults["bifurcation_z"] = (None,self.__optionCallback)
        optionDefaults["solution_z"]    = (None,self.__optionCallback)
        # The coordinate names
        optionDefaults["bifurcation_coordnames"] = (None,self.__optionCallback)
        optionDefaults["solution_indepvarname"]  = (None,self.__optionCallback)
        optionDefaults["solution_coordnames"]    = (None,self.__optionCallback)
        optionDefaults["labelnames"]             = (None,self.__optionCallback)
        # Sets of labels that the user is likely to want to use
        optionDefaults["label_defaults"]   = (None,self.__optionCallback)
        # Sets of columns that the user is likely to want to use
        optionDefaults["bifurcation_column_defaults"]   = (None,self.__optionCallback)
        optionDefaults["solution_column_defaults"]   = (None,self.__optionCallback)
        # The index of the solution we wish to draw
        optionDefaults["index"]    = ([0],self.__optionCallback)
        # The label of the solution we wish to draw
        optionDefaults["label"]    = ([0],self.__optionCallback)

        # Already parsed data structures
        optionDefaults["bifurcation_diagram"]          = (parseB.parseB(),self.__optionCallback)
        optionDefaults["solution"]          = (parseS.parseS(),self.__optionCallback)
        optionDefaults["bifurcation_diagram_filename"] = ("",self.__optionCallback)
        optionDefaults["solution_filename"] = ("",self.__optionCallback)
        optionDefaults["runner"]         = (None,self.__optionCallback)
        optionDefaults["mark_t"]         = (None,self.__optionCallback)

        optionDefaults["letter_symbols"] = (True,self.__optionCallback)
        optionDefaults["bifurcation_symbol"]     = ("B",self.__optionCallback)
        optionDefaults["limit_point_symbol"]     = ("L",self.__optionCallback)
        optionDefaults["hopf_symbol"]            = ("H",self.__optionCallback)
        optionDefaults["zero_hopf_symbol"]       = ("ZH",self.__optionCallback)
        optionDefaults["bogdanov_takens_symbol"] = ("BT",self.__optionCallback)
        optionDefaults["cusp_symbol"]            = ("CP",self.__optionCallback)
        optionDefaults["generalized_hopf_symbol"]= ("GH",self.__optionCallback)
        optionDefaults["1_1_resonance_symbol"]   = ("R1",self.__optionCallback)
        optionDefaults["1_2_resonance_symbol"]   = ("R2",self.__optionCallback)
        optionDefaults["1_3_resonance_symbol"]   = ("R3",self.__optionCallback)
        optionDefaults["1_4_resonance_symbol"]   = ("R4",self.__optionCallback)
        optionDefaults["fold_flip_symbol"]       = ("LPD",self.__optionCallback)
        optionDefaults["fold_torus_symbol"]      = ("LTR",self.__optionCallback)
        optionDefaults["flip_torus_symbol"]      = ("PTR",self.__optionCallback)
        optionDefaults["torus_torus_symbol"]     = ("TTR",self.__optionCallback)
        optionDefaults["period_doubling_symbol"] = ("D",self.__optionCallback)
        optionDefaults["torus_symbol"]           = ("T",self.__optionCallback)
        optionDefaults["user_point_symbol"]      = ("U",self.__optionCallback)
        optionDefaults["error_symbol"]           = ("X",self.__optionCallback)

        optionDefaults["ps_colormode"]           = ("color",self.__optionCallback)
        optionDefaults["stability"]              = (False,self.__optionCallback)
        optionDefaults["coloring_method"]        = ("curve",self.__optionCallback)

        parser = AUTOutil.getAUTORC("AUTO_plotter")
        optionDefaultsRC = {}
        c = parseC.parseC()
        for option in parser.options("AUTO_plotter"):
            optionDefaultsRC[option] = self.parseoption(
                option,parser.get("AUTO_plotter",option),c)
        # Let these override the RC options, if specified.
        for key in ["hide","xlabel","ylabel","zlabel"]:
            if key in kw:
                optionDefaultsRC[key] = kw[key]

        self.__needsPlot = None
        grapher.GUIGrapher.__init__(self,parent,**optionDefaultsRC)

        self.addOptions(**optionDefaults)
        self.addRCOptions(**optionDefaultsRC)
        for options in [optionDefaultsRC, kw]:
            if "letter_symbols" in options:
                self.__optionCallback("letter_symbols",
                                      options["letter_symbols"], options)
                del options["letter_symbols"]
        plotter._configNoDraw(self,**optionDefaultsRC)
        plotter._configNoDraw(self,**kw)
        self._plotNoDraw()
        self.__needsPlot = None
        for coord in 'x', 'y', 'z':
            if "min"+coord not in kw or "max"+coord not in kw:
                self.computeRange(coord,kw.get("min"+coord),
                                  kw.get("max"+coord))
        grapher.GUIGrapher.plot(self)
예제 #29
0
    def __init__(self,grapherClass,parent=None,cnf={},**kw):
        optiondefs = []
        self.defineoptions(AUTOutil.cnfmerge((cnf,kw)),optiondefs)
        Pmw.MegaToplevel.__init__(self, parent)

        interior = self.interior()
        self.helpBalloon = self.createcomponent('helpBalloon',
                                                (), None,
                                                Pmw.Balloon, interior)
                
        self.menuBar = self.createcomponent('menuBar',
                                            (), None,
                                            Pmw.MenuBar,interior,
                                            hotkeys="true",
                                            hull_relief = 'raised',
                                            hull_borderwidth = 1,
                                            balloon=self.helpBalloon)
        self.menuBar.addmenu("File","File operations")
        self.menuBar.addmenu("Options","View and set options")
        self.menuBar.addmenu("Help","View help on the plotting widget",side="right")
        self.menuBar.pack(fill=Tkinter.X)

        self.grapher = self.createcomponent('grapher',
                                            (), None,
                                            grapherClass,interior)

        self.menuBar.addmenuitem("File",
                                 "command",
                                 "Save the plot as postscript...",
                                 label = "Save Postscript...",
                                 command = self.grapher.generatePostscript
                                 )
        self.menuBar.addmenuitem("File",
                                 "command",
                                 "Destory the plot",
                                 label = "Quit",
                                 command = self.withdraw
                                 )
        self.menuBar.addmenuitem("Options",
                                 "command",
                                 label="Options...",
                                 command=self._setOptionWindow
                                 )


        topbox = Tkinter.Frame(interior,relief="raised",borderwidth=2)
        topbox.pack(side=Tkinter.BOTTOM)
        box = Tkinter.Frame(topbox)

        self.grapher.pack(expand=True,fill=Tkinter.BOTH)
        if self.grapher.cget("type") == "bifurcation":
            labelEntry = self.createcomponent('labelEntry',
                                              (), None,
                                              Pmw.OptionMenu,box,
                                              labelpos="w",
                                              label_text="Type",
                                              items=("'bifurcation'","'solution'"))
        else:
            labelEntry = self.createcomponent('labelEntry',
                                              (), None,
                                              Pmw.OptionMenu,box,
                                              labelpos="w",
                                              label_text="Type",
                                              items=("'solution'","'bifurcation'"))
            
        labelEntry.grid(row=0,column=0)
        labelEntry.configure(command = lambda value,obj=self:obj._modifyOption("type",value))

        #FIXME:  This being here is a bug.  It needs to be part of the configure stuff,
        #        otherwise you can't change solution files.
        labels = []
        if not(self.grapher.cget("label_defaults") is None):
            for x in self.grapher.cget("label_defaults"):
                labels.append(str(x))
        default_labels = self.grapher.cget("solution").getLabels()
        for i in range(len(default_labels)):
            labels.append("[%d]"%default_labels[i])
        all = "["
        for i in range(len(default_labels)):
            all = all + str(default_labels[i]) + ","
        all = all[:-1]+"]"
        labels.append(all)
        typeEntry = self.createcomponent('typeEntry',
                                         (), None,
                                         Pmw.ComboBox,box,
                                         labelpos="w",
                                         label_text="Label")
        
        typeEntry.grid(row=0,column=1)
        typeEntry.setentry(labels[0])
        typeEntry.setlist(labels)
        typeEntry.configure(selectioncommand = lambda entry,obj=self:obj._modifyOption("label",entry))
        box.grid(row=0)

        box = Tkinter.Frame(topbox)
        self._extraButtons(box)
        box.grid(row=1)
        
        # Let the appropriate things grow
        topbox.rowconfigure(1,weight=1)
        topbox.columnconfigure(0,weight=1)

        self.initialiseoptions(WindowPlotter)
예제 #30
0
 def _configNoDraw(self,cnf=None,**kw):
     if type(cnf) == types.StringType or (cnf is None and len(kw) == 0):
         return optionHandler.OptionHandler.config(self,cnf)
     else:
         optionHandler.OptionHandler.config(self,AUTOutil.cnfmerge((cnf,kw)))