graphs in memory

hi

i am trying to use mathplot in a script that has to produce and store about 3000 graps a time, the problem i have is that something inside mathplot keeps stroring in the memmory, (eigther the graph or the file to write to i guess…) so once it reached 1.5GB of ram it crashes

i hope you can help me find a way to flush this memory usage

already tryed the .clf and .close options

regards Bas

hi

i am trying to use mathplot in a script that has to produce and store
about 3000 graps a time, the problem i have is that something inside
mathplot keeps stroring in the memmory, (eigther the graph or the file
to write to i guess...) so once it reached 1.5GB of ram it crashes

i hope you can help me find a way to flush this memory usage

already tryed the .clf and .close options

regards Bas

In order to help you, we'll need to see a complete, minimal script
that shows the problem you're having. Memory issues usually depend on
the specifics of how you're doing something,

Ryan

···

On Mon, Oct 12, 2009 at 8:09 AM, bas pigmans <mrnatrium@...287...> wrote:

hi

i am trying to use mathplot in a script that has to produce and store about
3000 graps a time, the problem i have is that something inside mathplot
keeps stroring in the memmory, (eigther the graph or the file to write to i
guess...) so once it reached 1.5GB of ram it crashes

i hope you can help me find a way to flush this memory usage

already tryed the .clf and .close options

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

i got that problem solved but i now have a new memory problem, the
error i get is
invalid command name " *randomnumber*callit"
    while executing
" *randomnumber*callit"
    ("after" script)
searched the internet and found that there is some variable stuck
somewhere, here is the def cousing the error, is designed to read some
files (getting them from the lists self.files and self.workspaces)
make a plot and save the plot

def save2dmulti(self):
        try:
            os.mkdir(self.save+"/graph")
        except:
            pass
        for x in range(0,1):
            #fig = pyplot.figure()
            for file in self.files:
                ax = pyplot.subplot(111)#fig.add_subplot(111)
                pyplot.hold(True)
                for workspace in self.workspaces:
                    f = open(workspace+"/alignment.iuf","r")
                    idlist = pickle.load(f)
                    f.close()
                    self.__newdict = {}
                    for item in idlist:
                        self.__newdict[idlist[item]] = item
                    for x in range(0,1):
                        try:
                            f =
open(workspace+"/letters/letter_"+self.__newdict[file]+".txt", "r")
                        except:
                            print "gene "+file+" not found in
"+workspace+" skipping this workspace"
                            break
                        vals = pickle.load(f)
                        f.close()
                        base =
                        basecount =
                        for val in vals:
                            if val[0] == "A":
                                base.append("A")
                                basecount.append(val[1])
                            elif val[0] == "C":
                                base.append("C")
                                basecount.append(val[2])
                            elif val[0] == "T":
                                base.append("T")
                                basecount.append(val[3])
                            elif val[0] == "G":
                                base.append("G")
                                basecount.append(val[4])
                        N = len(base)
                        ind = numpy.arange(N)
                        width = 0.5

                        ax.plot(ind, basecount,'o-', label = workspace)
                        ax.set_xticks(ind)
                ax.set_title(file)
                pyplot.legend()
                #print "one"
                for workspacer in self.workspaces:
                    #print "pretry"
                    try:
                        #print "opening file"
                        f = open(workspacer+"/alignment.iuf","r")
                        idlist = pickle.load(f)
                        f.close()
                        #print "making dict"
                        self.__newdict = {}
                        for item in idlist:
                            self.__newdict[idlist[item]] = item
                        f =
open(workspacer+"/validated/"+self.__newdict[file]+".fa","r")
                        text = f.read()
                        text = text.split("\n")
                        #print text, text[0], text[1]
                        f.close()
                        f = open(self.save+"/temp.fa","w")
                        #print "check OK"+workspacer
                        t = text[0]+"\n"+text[1]+"\n"
                        f.write(t)
                        f.close()
                        output = ""
                        cline = "centroid_fold "+self.save+"/temp.fa"
                        test = subprocess.Popen(str(cline),stdout =
subprocess.PIPE,stderr = open(os.devnull))
                        output = test.communicate()[0]
                        #print output
                        output = output.split(">")
                        out = output[1]
                        out = out.split("\r\n")
                        #print out
                        xax =
                        counter =0
                        for x in range(0,len(base)):

xax.append(str(vals[counter][0])+"\n"+out[2][counter])
                            counter = counter +1

                        ax.set_xticks(ind)
                        ax.set_xticklabels(xax)

                        sav = file
                        sav =
sav.replace(":","_").replace("\\","_").replace("-","_").replace(">","")
                        #pyplot.show()
                        pyplot.savefig(self.save+"/graph/"+sav+".png")
                        os.remove(self.save+"/temp.fa")
                        pyplot.clf()

                        break
                    except:
                        #print workspacer +" failed"
                        #print "ERROR"
                        pass

the code itself works and does what it needs to do, side effect is
that when i later make and show a graph all the graphs made by this
code are also shown and i get the error

2009/10/14 Ryan May <rmay31@...287...>:

···

On Mon, Oct 12, 2009 at 8:09 AM, bas pigmans <mrnatrium@...287...> wrote:

hi

i am trying to use mathplot in a script that has to produce and store about
3000 graps a time, the problem i have is that something inside mathplot
keeps stroring in the memmory, (eigther the graph or the file to write to i
guess...) so once it reached 1.5GB of ram it crashes

i hope you can help me find a way to flush this memory usage

already tryed the .clf and .close options

In order to help you, we'll need to see a complete, minimal script
that shows the problem you're having. Memory issues usually depend on
the specifics of how you're doing something,

Ryan

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma