def pickMDA(self): 'pickMDA(self) - dialog to pick MDA file and load 1D array into memory' import tkFileDialog from readMDA import * fname = tkFileDialog.askopenfilename( initialdir=self.mdapath, filetypes=[("MDA File", '.mda'), ("All Files","*")]) if fname == (): return (self.mdapath, fn) = os.path.split(fname) self.mdafile = fn # fname self.W[0].setentry(fname) d = readMDA(fname,maxdim=1) try: if d[1].nd> 0: # print '1D data found' self.W[1].setentry(d[1].p[0].fieldName) x = d[1].p[0].data self.NPT = len(x) data = [] labels = [] for i in range(d[1].nd): data.append(array(d[1].d[i].data)) labels.append(d[1].d[i].name) self.pvs = labels self.initfields(x,data) self.xcord = x except IndexError: pass
def pickMDAFile(self): "pickMDAFile(self) - dialog to pick a MDA file" import tkFileDialog fname = tkFileDialog.askopenfilename( initialdir=self.mdapath, filetypes=[("MDA File", '.mda'), ("All Files","*")]) if fname == (): return (self.mdapath, fn) = os.path.split(fname) self.mdafile = fn # fname d = readMDA(fname) self.d = d try: if d[1].nd> 0: print '1D data found' except IndexError: pass try: if d[2].nd> 0: self.panimage() print '2D data found' except IndexError: pass try: if d[3].nd> 0: print '3D data found' except IndexError: pass
def read_raw(fname): d = readMDA(fname, verbose=0) x = d[1].p[0].data y = d[2].p[0].data fluo = np.array(d[2].d[6].data) diff = np.array(d[2].d[7].data) theta = d[2].d[52].data return fluo, diff, x, y, theta
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)
def mdaAsciiReport(fname): d = readMDA(fname,2) dim = d[0]['rank'] if dim == 1: if d[1].nd > 0: ofname = mdaAscii_1D(d) return ofname if dim > 1: if d[1].nd > 0: ofname = mdaAscii_1D(d) if d[2].nd > 0: ofname = mdaAscii_2D(d) return ofname
def mdaAscii_all(path): """ mdaAscii_all(path) - this routine automatically generates 1D/2D ascii reports for all the MDA files detected in the mda data directory specified by path """ fn = os.popen('ls '+path+os.sep+'*.mda').readlines() fname=[] for i in range(len(fn)): f = string.split(fn[i],'\n') fname.append(f[0]) fn = fname for i in range(len(fn)): if os.path.isfile(fn[i]): d = readMDA(fn[i],2) print "" print "=====>Source: ",fn[i],'( **'+str(d[0]['rank'])+'D Scan** )' if d[0]['rank'] == 1: f = mdaAscii_1D(d) if d[0]['rank'] >= 2: f = mdaAscii_2D(d) f = mdaAscii_1D(d) return f
'green': ((0.0, 1.0, 1.0), (0.11, 0.0, 0.0), (0.36, 1.0, 1.0), (0.62, 1.0, 1.0), (0.87, 0.0, 0.0), (1.0, 0.0, 0.0)), 'blue': ((0.0, 1.0, 1.0), (0.11, 1.0, 1.0), (0.36, 1.0, 1.0), (0.62, 0.0, 0.0), (0.87, 0.0, 0.0), (1.0, 0.0, 0.0))} my_cmap = matplotlib.colors.LinearSegmentedColormap('my_colormap',cdict,256) filename = '26idbSOFT_0423.mda' d = readMDA(filename) ccdn = array(d[2].d[19].data) fluo = array(d[2].d[6].data) figure() imshow(fluo) axis('tight') dims = shape(fluo) x = arange(0,dims[1],1) max_fluo = zeros((dims[0])) for ii in range(dims[0]): max_fluo[ii] = find(fluo[ii,:]==fluo[ii,:].max())[0] imgr = zeros((dims[0]))