Example #1
0
def pickVect():
	"pickVect() - pick (X,Y) pair vector out of ascii column data array to be fitted"
	if FIT['ncol'] <= 0: 
		message(FIT['root'],text='Error:  No data found !!!\n\nFirst Load Data Array in from an Ascii file\n\n')
		return
	cols = FIT['cols']
	xcol = FIT['xcol']
	ycol = FIT['ycol']
	ix = xcol.get()
	iy = ycol.get()
	if ix >= FIT['ncol']: ix= -1
	if iy >= FIT['ncol']: ix= FIT['ncol'] - 1
	if iy < ix: iy = ix+1
	if ix < 0: 
		x = range(1,len(cols[0])+1)
	else:
		x = cols[ix]
	y = cols[iy]
	data = []
	fo = open('xy.txt','w')
	for i in range(len(x)):
		data.append((x[i],y[i]))
		fo.write('%18.7f %18.7f \n' % (x[i],y[i]) )
	fo.close()	
	
	title='Least Square Fit: ix='+str(ix)+' ,iy='+str(iy)
	FIT['title'] = title
	xdisplayfile('xy.txt',title='xy.txt: '+title)
	fit(data,title=title)
Example #2
0
    def displayAscii(self):
	"displayAscii(self) - pick and disply the text file"
        import tkFileDialog
        fname = tkFileDialog.askopenfilename(initialdir=self.txtpath,
                initialfile='*.txt')
        if fname == (): return
	xdisplayfile(fname)
Example #3
0
def fittedData(f,x,y1,y2,ret,title=None):
	"""
	fittedData(f,x,y1,y2,ret,title=None) - pop up fitted displaywindow
	f - specify the fitting function struture dictionary used
	x - dependent vector
	y1 - raw y data vector
	y2 - fitted y value vector
	ret - LeastSquares fit returned values
	title - title string used by pop up window
	"""
	parms = ret[0]
	errs = ret[1]
	gdness = sqrt(errs/(len(x)-1))
	np = f['NumPar']
	fo = open('fit_out.txt','w')
	fo.write('# %s\n' % f['Exp'])
	fo.write('# %s\n' % str(f['Par']) )
	for i in range(np):
		fo.write('# %s =  %s\n' % (f['Par'][i],str(parms[i])) )
	fo.write('# Least Square Errors = %f\n# \n' % errs)
	fo.write('# Goodness of Fit = %f\n# \n' % gdness)
	fo.write('# %18s %18s %18s\n' % ('X','Y','Y_FIT'))
	for i in range(len(x)):
		fo.write('%4d  %18.7f %18.7f %18.7f\n' % (i,x[i],y1[i],y2[i]) )
	fo.close()	
	if title != None: title= 'fit_out.txt: ' + title
	else: title = 'fit_out.txt'
	xdisplayfile('fit_out.txt',title=title)
Example #4
0
    def displayFile(self):
	"displayFile(self) - display picked text file and update fields"
	from plotAscii import readArray
	if self.fname != '': xdisplayfile(self.fname)
	if self.NPT < 1:
	    data = readArray(self.fname)
	    self.data = data
	    self.columndata()
Example #5
0
    def pickmdaRpt(self):
	fname = tkFileDialog.askopenfilename(initialdir=self.mdapath,
		initialfile='*.mda')
	if fname ==(): return
	st='Generating ascii report for picked file : \n'
	self.txtWid.settext(st+fname)
	(self.mdapath, fn) = os.path.split(fname)
  	ofname = mdaAsciiReport(fname)
	(self.txtpath, fn) = os.path.split(ofname)
	xdisplayfile(ofname)
Example #6
0
    def pickmdaALL(self):
	fname = tkFileDialog.askopenfilename(initialdir=self.mdapath,
		initialfile='*.mda')
	if fname ==(): return
	(self.mdapath, fn) = os.path.split(fname)
	st='Generating all ascii reports for picked directory : \n'
	self.txtWid.settext(st+self.mdapath)
	ofname = mdaAscii_all(self.mdapath)
	(self.txtpath, fn) = os.path.split(ofname)
	xdisplayfile(ofname)
Example #7
0
    def pickmda2D1D(self):
	fname = tkFileDialog.askopenfilename(initialdir=self.mdapath,
		initialfile='*.mda')
	if fname ==(): return
	st='Generating 2D->1D ascii report for picked file : \n'
	self.txtWid.settext(st+fname)
	(self.mdapath, fn) = os.path.split(fname)
	d = readMDA(fname,2)
	dim = d[0]['rank']
	if dim < 2: return
  	ofname = mdaAscii_2D1D(d)
	(self.txtpath, fn) = os.path.split(ofname)
	xdisplayfile(ofname)
Example #8
0
def pickFile():
	"pickFile() - use file selection dialog to load in Ascii data array"
        import tkFileDialog,os
	path = '.'
	if os.path.isfile('fit.config'):
		fi =open('fit.config')
		fname = fi.read()
		fi.close()
		(path,fn) = os.path.split(fname)
        fname = tkFileDialog.askopenfilename(initialdir=path,
                initialfile='*.txt')
        if fname ==(): exit() 
	FIT['fname'] = fname
	xdisplayfile(fname)
	arr = readArray(fname)
	cols = transposeA(arr)
	FIT['cols'] = cols
	FIT['ncol'] = len(cols)
	fo = open('fit.config','w')
	fo.write(fname)
	fo.close()
Example #9
0
    def statisticAll(self):
      "statisticAll(self) - calculate statistic for all curves"
      out = []
      for id in range(self.nc):
	y = self.y[id-1]
	ymin,ymax = min(y),max(y)
	y_hpeak = ymin + .5 *(ymax-ymin)
	x = self.x
	x_hpeak = []
	for i in range(self.NPT):
		if y[i] >= y_hpeak:
			i1 = i
			break
	for i in range(i1+1,self.NPT):
		if y[i] <= y_hpeak:
			i2 = i
			break
		if i == self.NPT-1: i2 = i
	x_hpeak = [x[i1],x[i2]]
	fwhm = abs(x_hpeak[1]-x_hpeak[0])
	for i in range(self.NPT):
		if y[i] == ymax: 
			jmax = i
			break
	xpeak = x[jmax]

	out.append([MLab.mean(y),MLab.std(y),ymin,ymax,xpeak,jmax,y_hpeak,x_hpeak,fwhm])
      fo = open('fwhm.txt','w')
      fo.write('File:  '+self.fname)
      for id in range(self.nc):
		list = out[id]
		fo.write('\n\nCurve #'+str(id+1))
		fo.write('\nMean: '+ str(list[0]))
		fo.write('\nStandard Deviation: '+ str(list[1]))
		fo.write('\nYmin, Ymax: '+ str(list[2]) + ', '+ str(list[3]))
		fo.write('\nYmax @ Xpos[i]: ' + str(list[4]) +'[i='+str(list[5])+']')
		fo.write('\nY-hpeak @ X-hpeak: ' + str(list[6]) +' @ '+str(list[7]))
		fo.write('\nFWHM: ' + str(list[8]))
      fo.close()
      xdisplayfile('fwhm.txt')
Example #10
0
    def viewAscii(self):
	fname = tkFileDialog.askopenfilename(initialdir=self.txtpath,
		initialfile='*txt*')
	if fname ==(): return
	xdisplayfile(fname)
Example #11
0
    def displayFile(self):
	"displayFile(self) - display picked text file"
	if self.fname != '': xdisplayfile(self.fname)
Example #12
0
 def help3dgraph(self):
     'help3dgraph(self) - display online help 3dgraph_help.txt '
     fname = os.environ['PYTHONSTARTUP'] + os.sep + '3dgraph_help.txt'
     xdisplayfile(fname)
Example #13
0
File: tv.py Project: eddienko/SamPy
 def displayFile(self):
     "displayFile(self) - display picked text file"
     from plotAscii import xdisplayfile
     if self.fname != '': xdisplayfile(self.fname)
Example #14
0
 def displayFile(self):
     'displayFile(self) - display content of Ascii file loaded in'
     if os.path.isfile(self.fname): xdisplayfile(self.fname)
     else:
         message(self.interior(),
                 text='Error: \n\n' + self.fname + '\nFile not found!')
Example #15
0
    def help3dgraph(self):
	'help3dgraph(self) - display online help 3dgraph_help.txt '
	fname = os.environ['PYTHONSTARTUP']+os.sep+'3dgraph_help.txt'
	xdisplayfile(fname)
Example #16
0
    def displayFile(self):
	'displayFile(self) - display content of Ascii file loaded in'
	if os.path.isfile(self.fname): xdisplayfile(self.fname)
	else: 
		message(self.interior(),text='Error: \n\n'+self.fname+'\nFile not found!')
Example #17
0
 def displayFile(self):
     "displayFile(self) - display picked text file"
     from plotAscii import xdisplayfile
     if self.fname != '': xdisplayfile(self.fname)