예제 #1
0
파일: 3dgraph.py 프로젝트: eddienko/SamPy
    def drawrows(self,list=None):
	'drawrows(self,list=None) - draw all or list of rows in 3D coordinates'
	self.clearcanvas()
	self.createAxis()
	da = self.data
	dv = self.vmax-self.vmin
	if dv != 0.0:
		data = divide(subtract(da,self.vmin),dv/self.maxY)
	else:
		data = da
	rows= len(data)
	steps= len(data[0])
	lasthv = self.maxY*self.yfac
	
	if list == None: list = range(rows)
	for row in list:
	  if row < rows and row >=0 :
#            rootx  = self.xorg - row*self.hoff/self.rows
#            rooty  = self.yorg + row*self.voff/self.rows
#	     rowdata1 = data[rows-1-row]
            rootx  = self.xorg - (rows-1-row)*self.hoff/self.rows
            rooty  = self.yorg + (rows-1-row)*self.voff/self.rows
	    rowdata1 = data[row]
	    for cidx in range(steps-1):
		datum = [rowdata1[cidx],rowdata1[cidx+1]]
		lside = multiply(datum,self.yfac)
		self.canvas.create_line( rootx,rooty-lside[0],
			rootx+self.xincr,rooty-lside[1],
			capstyle=ROUND,
			width=self.linewidth,fill='darkblue')
		rootx = rootx + self.xincr

	    self.root.update()
def mvariance(data):
    """
    Take the variance of an array of arbitrary dimension. Works for
    slices and other arrays where ar.flat is undefined.
    """
    from Numeric import multiply
    tmp = data - mmean(data)
    return mmean(multiply(tmp, tmp))
예제 #3
0
	def GridCoordinatesFromCoordinates(self,scaledcoor):
		"""
		Returns a list containing the grid coordinates, i.e. the 
		indices of the array that correspond to the specified
		scaled coordinates, 'scaledcoor'. Note, that since the scaled 
		coordinates in general do not coincide with a grid point 
		the returned grid coordinates will be of type float.
		"""
		from Numeric import multiply
		return list(multiply(scaledcoor,self.GetSpatialShape()))
예제 #4
0
파일: 3dgraph.py 프로젝트: eddienko/SamPy
    def drawsurf1(self,steplist=None):
	'drawsurf1(self,steplist=None) - draw spectrum surface cell by stepwise'
	self.clearcanvas()
	self.createAxis()
	# use color table if ctable is set
	if self.ctable:
	    p = reshape(self.CT[self.ct],(256,3))
	    spec=[]
	    for i in range(256):
		pp = p[i]
		st = '#%02x%02x%02x' % (int(pp[0]),int(pp[1]),int(pp[2]))
		spec.append(st)	
	    self.ctc = spec
	da = self.data
	dv = self.vmax-self.vmin
	if dv != 0.:
		data = divide(subtract(da,self.vmin),dv/self.maxY)
		da1 = divide(subtract(da,self.vmin),dv/255)
	else:
		data = da
		da1 = divide(da,self.vmin/255)

	rows= len(data)
	steps= len(data[0])
	lasthv = self.maxY*self.yfac
        xadj   = float(self.xincr)/4.0
	if xadj < 2: xadj=2	
	if steplist == None:
		steplist = range(steps-1)
#	for cidx in range(steps-1):
	for cidx in steplist:
	    for row in range(rows-1):
                rootx  = self.xorg + cidx*self.xincr - row*self.hoff/self.rows
                rooty  = self.yorg + row*self.voff/self.rows
		datum = [data[rows-1-row][cidx+1],data[rows-1-row][cidx],data[rows-1-row-1][cidx],data[rows-1-row-1][cidx+1]]
	        lside = multiply(datum,self.yfac)
		if self.ctable:
		     if not(self.average):
			ind = int(da1[rows-1-row,cidx])
		     else:
			ind = int((da1[rows-1-row,cidx]+da1[rows-1-row-1,cidx]+ da1[rows-1-row,cidx+1]+da1[rows-1-row-1,cidx+1])/4)
		     color = self.ctc[ind]
		else:
		     color = self.spectrum[cidx]
		self.canvas.create_polygon(
			rootx+self.xincr,rooty-lside[0],
			rootx,rooty-lside[1],
			rootx-self.hroff,rooty-lside[2]+self.vroff,
			rootx+self.xincr-self.hroff,rooty-lside[3]+self.vroff,
                        fill=color, outline=color,
                        width=xadj)

	    self.root.update()
예제 #5
0
파일: 3dgraph.py 프로젝트: RainW7/SamPy
    def drawstepSline(self, list=None):
        'drawstepSline(self,list=None) - draw selected step slices in spectrum color'
        self.clearcanvas()
        self.createAxis()
        da = self.data
        dv = self.vmax - self.vmin
        if dv != 0.0:
            data = divide(subtract(da, self.vmin), dv / self.maxY)
        else:
            data = da
        rows = len(data)
        steps = len(data[0])
        lasthv = self.maxY * self.yfac

        if list == None: list = range(steps)
        else:
            ll = []
            for i in range(len(list)):
                if list[i] < steps:
                    ll.append(list[i])
            list = ll
        np = len(list)
        for row in range(rows - 1):
            rootx = self.xorg - row * self.hoff / self.rows
            rooty = self.yorg + row * self.voff / self.rows
            rowdata1 = data[rows - 1 - row]
            rowdata2 = data[rows - 1 - row - 1]
            for i in range(np):
                cidx = list[i]
                if cidx >= 0 and cidx < steps:
                    datum = [rowdata2[cidx], rowdata1[cidx]]
                    lside = multiply(datum, self.yfac)
                    color = self.spectrum[cidx]
                    self.canvas.create_polygon(rootx - self.hroff,
                                               rooty - lside[0] + self.vroff,
                                               rootx,
                                               rooty - lside[1],
                                               rootx,
                                               rooty,
                                               rootx - self.hroff,
                                               rooty + self.vroff,
                                               outline=color,
                                               width=self.linewidth,
                                               fill=color)
                    if np < steps:
                        if i < (np - 1):
                            rootx = rootx + self.xincr * (list[i + 1] - cidx)
                    else:
                        rootx = rootx + self.xincr

            self.root.update()
예제 #6
0
파일: 3dgraph.py 프로젝트: RainW7/SamPy
    def drawsteps(self, list=None):
        'drawsteps(self,list=None) - draw all or selected step list in 3D coordinates'
        self.clearcanvas()
        self.createAxis()
        da = self.data
        dv = self.vmax - self.vmin
        if dv != 0.0:
            data = divide(subtract(da, self.vmin), dv / self.maxY)
        else:
            data = da
        rows = len(data)
        steps = len(data[0])
        lasthv = self.maxY * self.yfac

        if list == None: list = range(steps)
        else:
            ll = []
            for i in range(len(list)):
                if list[i] < steps:
                    ll.append(list[i])
            list = ll
        np = len(list)
        for row in range(rows - 1):
            rootx = self.xorg - row * self.hoff / self.rows
            rooty = self.yorg + row * self.voff / self.rows
            rowdata1 = data[rows - 1 - row]
            rowdata2 = data[rows - 1 - row - 1]
            for i in range(np):
                cidx = list[i]
                if cidx >= 0 and cidx < steps:
                    datum = [rowdata1[cidx], rowdata2[cidx]]
                    lside = multiply(datum, self.yfac)
                    self.canvas.create_line(
                        rootx,
                        rooty - lside[0],
                        rootx - self.hroff,
                        rooty - lside[1] + self.vroff,
                        #			capstyle=ROUND,
                        width=self.linewidth,
                        fill='darkblue')
                    if np < steps:
                        if i < (np - 1):
                            rootx = rootx + self.xincr * (list[i + 1] - cidx)
                    else:
                        rootx = rootx + self.xincr

            self.root.update()
예제 #7
0
파일: 3dgraph.py 프로젝트: eddienko/SamPy
    def drawstepSline(self,list=None):
	'drawstepSline(self,list=None) - draw selected step slices in spectrum color'
	self.clearcanvas()
	self.createAxis()
	da = self.data
	dv = self.vmax-self.vmin
	if dv != 0.0:
		data = divide(subtract(da,self.vmin),dv/self.maxY)
	else:
		data = da
	rows= len(data)
	steps= len(data[0])
	lasthv = self.maxY*self.yfac
	
	if list == None: list=range(steps)
	else:
		ll = []
		for i in range(len(list)):
			if list[i] < steps:
				ll.append(list[i])	
		list = ll
    	np = len(list)
	for row in range(rows-1):
            rootx  = self.xorg - row*self.hoff/self.rows
            rooty  = self.yorg + row*self.voff/self.rows
	    rowdata1 = data[rows-1-row]
	    rowdata2 = data[rows-1-row-1]
	    for i in range(np):
	      cidx = list[i]
	      if cidx >=0 and cidx < steps:
		datum = [rowdata2[cidx],rowdata1[cidx]]
		lside = multiply(datum,self.yfac)
		color = self.spectrum[cidx]
		self.canvas.create_polygon(
			rootx-self.hroff,rooty-lside[0]+self.vroff,
			rootx,rooty-lside[1],
			rootx,rooty,
			rootx-self.hroff,rooty+self.vroff,
			outline=color,width=self.linewidth,
			fill=color)
		if np < steps:
		    if i < (np-1):
		        rootx = rootx + self.xincr*(list[i+1]-cidx)
		else:
		    rootx = rootx + self.xincr

	    self.root.update()
예제 #8
0
파일: 3dgraph.py 프로젝트: eddienko/SamPy
    def drawsteps(self,list=None):
	'drawsteps(self,list=None) - draw all or selected step list in 3D coordinates'
	self.clearcanvas()
	self.createAxis()
	da = self.data
	dv = self.vmax-self.vmin
	if dv != 0.0:
		data = divide(subtract(da,self.vmin),dv/self.maxY)
	else:
		data = da
	rows= len(data)
	steps= len(data[0])
	lasthv = self.maxY*self.yfac
	
	if list == None: list=range(steps)
	else:
		ll = []
		for i in range(len(list)):
			if list[i] < steps:
				ll.append(list[i])	
		list = ll
    	np = len(list)
	for row in range(rows-1):
            rootx  = self.xorg - row*self.hoff/self.rows
            rooty  = self.yorg + row*self.voff/self.rows
	    rowdata1 = data[rows-1-row]
	    rowdata2 = data[rows-1-row-1]
	    for i in range(np):
	      cidx = list[i]
	      if cidx >=0 and cidx < steps:
		datum = [rowdata1[cidx],rowdata2[cidx]]
		lside = multiply(datum,self.yfac)
		self.canvas.create_line(
			rootx,rooty-lside[0],
			rootx-self.hroff,rooty-lside[1]+self.vroff,
#			capstyle=ROUND,
			width=self.linewidth,fill='darkblue')
		if np < steps:
		    if i < (np-1):
		        rootx = rootx + self.xincr*(list[i+1]-cidx)
		else:
		    rootx = rootx + self.xincr

	    self.root.update()
예제 #9
0
파일: plot1d.py 프로젝트: eddienko/SamPy
    def errRun(self):
	"errRun(self) - plot error bar for selected curve"
	ic = string.atoi(self.errVar[0].get())
	if ic > 0 and ic < self.nc:
	   err = string.atof(self.errVar[1].get())
	   hz = self.errVar[2].get()
	   self.fig = self.fig+1
	   figure(self.fig,figsize=(5.5,4))
	   x = self.x
	   y = self.y
	   from Numeric import multiply
	   yerr = multiply(y[ic-1],err)
	   if hz:
		errorbar(y[ic-1],x,xerr=yerr)
	   else:
		errorbar(x,y[ic-1],yerr=yerr)
	   title('Curve # '+str(ic))
	   connect('button_press_event',self.closewin)
	   show()
예제 #10
0
파일: 3dgraph.py 프로젝트: RainW7/SamPy
    def drawmesh(self):
        'drawmesh(self) - draw surface elements as mesh elements'
        self.clearcanvas()
        self.createAxis()
        da = self.data
        dv = self.vmax - self.vmin
        if dv != 0.:
            data = divide(subtract(da, self.vmin), dv / self.maxY)
        else:
            data = da
        rows = len(data)
        steps = len(data[0])
        lasthv = self.maxY * self.yfac

        for row in range(rows - 1):
            rootx = self.xorg - row * self.hoff / self.rows
            rooty = self.yorg + row * self.voff / self.rows
            rowdata1 = data[rows - 1 - row]
            rowdata2 = data[rows - 1 - row - 1]
            for cidx in range(steps - 1):
                datum = [
                    rowdata2[cidx], rowdata1[cidx], rowdata1[cidx + 1],
                    rowdata2[cidx + 1]
                ]
                lside = multiply(datum, self.yfac)
                self.canvas.create_line(rootx - self.hroff,
                                        rooty - lside[0] + self.vroff,
                                        rootx,
                                        rooty - lside[1],
                                        rootx + self.xincr,
                                        rooty - lside[2],
                                        rootx + self.xincr - self.hroff,
                                        rooty - lside[3] + self.vroff,
                                        fill='darkblue')
                if (row + 1) == (rows - 1):
                    self.canvas.create_line(rootx + self.xincr - self.hroff,
                                            rooty - lside[3] + self.vroff,
                                            rootx - self.hroff,
                                            rooty - lside[0] + self.vroff,
                                            fill='darkblue')
                rootx = rootx + self.xincr

            self.root.update()
예제 #11
0
파일: 3dgraph.py 프로젝트: eddienko/SamPy
    def drawmesh(self):
	'drawmesh(self) - draw surface elements as mesh elements'
	self.clearcanvas()
	self.createAxis()
	da = self.data
	dv = self.vmax-self.vmin
	if dv != 0.:
	    data = divide(subtract(da,self.vmin),dv/self.maxY)
	else:
	    data = da
	rows= len(data)
	steps= len(data[0])
	lasthv = self.maxY*self.yfac
	
	for row in range(rows-1):
            rootx  = self.xorg - row*self.hoff/self.rows
            rooty  = self.yorg + row*self.voff/self.rows
	    rowdata1 = data[rows-1-row]
	    rowdata2 = data[rows-1-row-1]
	    for cidx in range(steps-1):
		datum = [rowdata2[cidx],rowdata1[cidx],rowdata1[cidx+1],rowdata2[cidx+1]]
		lside = multiply(datum,self.yfac)
		self.canvas.create_line(
			rootx-self.hroff,rooty-lside[0]+self.vroff,
			rootx,rooty-lside[1],
			rootx+self.xincr,rooty-lside[2],
			rootx+self.xincr-self.hroff,rooty-lside[3]+self.vroff,
			fill='darkblue')
		if (row+1) == (rows-1):
			self.canvas.create_line(
			rootx+self.xincr-self.hroff,rooty-lside[3]+self.vroff,
			rootx-self.hroff,rooty-lside[0]+self.vroff,
			fill='darkblue')
		rootx = rootx + self.xincr

	    self.root.update()
예제 #12
0
파일: 3dgraph.py 프로젝트: RainW7/SamPy
    def drawrows(self, list=None):
        'drawrows(self,list=None) - draw all or list of rows in 3D coordinates'
        self.clearcanvas()
        self.createAxis()
        da = self.data
        dv = self.vmax - self.vmin
        if dv != 0.0:
            data = divide(subtract(da, self.vmin), dv / self.maxY)
        else:
            data = da
        rows = len(data)
        steps = len(data[0])
        lasthv = self.maxY * self.yfac

        if list == None: list = range(rows)
        for row in list:
            if row < rows and row >= 0:
                #            rootx  = self.xorg - row*self.hoff/self.rows
                #            rooty  = self.yorg + row*self.voff/self.rows
                #	     rowdata1 = data[rows-1-row]
                rootx = self.xorg - (rows - 1 - row) * self.hoff / self.rows
                rooty = self.yorg + (rows - 1 - row) * self.voff / self.rows
                rowdata1 = data[row]
                for cidx in range(steps - 1):
                    datum = [rowdata1[cidx], rowdata1[cidx + 1]]
                    lside = multiply(datum, self.yfac)
                    self.canvas.create_line(rootx,
                                            rooty - lside[0],
                                            rootx + self.xincr,
                                            rooty - lside[1],
                                            capstyle=ROUND,
                                            width=self.linewidth,
                                            fill='darkblue')
                    rootx = rootx + self.xincr

                self.root.update()
예제 #13
0
def f(t):
    s1 = sin(2 * pi * t)
    e1 = exp(-t)
    return absolute(multiply(s1, e1)) + .05
예제 #14
0
def f(t):
    s1 = sin(2*pi*t)
    e1 = exp(-t)
    return absolute(multiply(s1,e1))+.05
예제 #15
0
파일: 3dgraph.py 프로젝트: RainW7/SamPy
    def drawsurf1(self, steplist=None):
        'drawsurf1(self,steplist=None) - draw spectrum surface cell by stepwise'
        self.clearcanvas()
        self.createAxis()
        # use color table if ctable is set
        if self.ctable:
            p = reshape(self.CT[self.ct], (256, 3))
            spec = []
            for i in range(256):
                pp = p[i]
                st = '#%02x%02x%02x' % (int(pp[0]), int(pp[1]), int(pp[2]))
                spec.append(st)
            self.ctc = spec
        da = self.data
        dv = self.vmax - self.vmin
        if dv != 0.:
            data = divide(subtract(da, self.vmin), dv / self.maxY)
            da1 = divide(subtract(da, self.vmin), dv / 255)
        else:
            data = da
            da1 = divide(da, self.vmin / 255)

        rows = len(data)
        steps = len(data[0])
        lasthv = self.maxY * self.yfac
        xadj = float(self.xincr) / 4.0
        if xadj < 2: xadj = 2
        if steplist == None:
            steplist = range(steps - 1)
#	for cidx in range(steps-1):
        for cidx in steplist:
            for row in range(rows - 1):
                rootx = self.xorg + cidx * self.xincr - row * self.hoff / self.rows
                rooty = self.yorg + row * self.voff / self.rows
                datum = [
                    data[rows - 1 - row][cidx + 1], data[rows - 1 - row][cidx],
                    data[rows - 1 - row - 1][cidx],
                    data[rows - 1 - row - 1][cidx + 1]
                ]
                lside = multiply(datum, self.yfac)
                if self.ctable:
                    if not (self.average):
                        ind = int(da1[rows - 1 - row, cidx])
                    else:
                        ind = int((da1[rows - 1 - row, cidx] +
                                   da1[rows - 1 - row - 1, cidx] +
                                   da1[rows - 1 - row, cidx + 1] +
                                   da1[rows - 1 - row - 1, cidx + 1]) / 4)
                    color = self.ctc[ind]
                else:
                    color = self.spectrum[cidx]
                self.canvas.create_polygon(rootx + self.xincr,
                                           rooty - lside[0],
                                           rootx,
                                           rooty - lside[1],
                                           rootx - self.hroff,
                                           rooty - lside[2] + self.vroff,
                                           rootx + self.xincr - self.hroff,
                                           rooty - lside[3] + self.vroff,
                                           fill=color,
                                           outline=color,
                                           width=xadj)

            self.root.update()
예제 #16
0
from matplotlib.matlab import *
from RandomArray import normal
from Numeric import sin, exp, multiply, absolute, pi


def f(t):
    s1 = sin(2 * pi * t)
    e1 = exp(-t)
    return absolute(multiply(s1, e1)) + .05


t = arange(0.0, 5.0, 0.1)
s = f(t)
nse = multiply(normal(0.0, 0.3, t.shape), s)

plot(t, s + nse, 'b^')
vlines(t, 0, s, color='k')
xlabel('time (s)')
title('Comparison of model with data')
show()
예제 #17
0
from matplotlib.matlab import *
from RandomArray import normal
from Numeric import sin, exp, multiply, absolute, pi

def f(t):
    s1 = sin(2*pi*t)
    e1 = exp(-t)
    return absolute(multiply(s1,e1))+.05


t = arange(0.0, 5.0, 0.1)
s = f(t)
nse = multiply(normal(0.0, 0.3, t.shape), s)

plot(t, s+nse, 'b^')
vlines(t, 0, s, color='k')
xlabel('time (s)')
title('Comparison of model with data')
show()