Ejemplo n.º 1
0
	def setElements(self, els):
		'''Set the list self.elements, and the link e.container'''
		self.elements=els
		for e in self.elements:
			e.container=self
		if not os.environ.get("MIEN_NO_VERIFY_XML"):
			ns=[e.name() for e in self.elements]
			bnc=[notinname.search(n) for n in ns]
			if any(bnc):
				self.report('warning: fixing illegal names')
				ind=nonzero1d(bnc)
				for i in ind:
					on=ns[i]
					nn=notinname.sub('_', on)
					ns[i]=nn
					self.elements[i].attributes['Name']=nn
					self.elements[i].update_refs()				
			us=set(ns)
			if len(us)==len(ns):
				return
			self.report('warning: non unique names')
			sibs=[]
			for i, n in enumerate(ns[:]):
				if n in sibs:
					nn=uniqueName(n, sibs)
					self.elements[i].attributes['Name']=nn
					self.elements[i].update_refs()
					sibs.append(nn)
				else:	
					sibs.append(n)
Ejemplo n.º 2
0
def writeDensityFile(of, a,  **kwargs):
	thresh=kwargs.get('thresh', .000001)
	norm=kwargs.get('norm', None)
	of.write("%.6g  #Max Density\n" % a.max())
	of.write("0  #Directional tuning (meaningless)\n")
	if norm:
		a=a*norm*(1.0/a.max())
	if thresh:
		nz=nonzero1d(a>thresh*a.max())
		#print nz[0].min(), nz[0].max()
		#print nz[1].min(), nz[1].max()
		#print nz[2].min(), nz[2].max()
		xr=range(nz[0].min(), nz[0].max())
		yr=range(nz[1].min(), nz[1].max())
		zr=range(nz[2].min(), nz[2].max())
	else:
		size=a.shape
		xr=range(size[0])
		yr=range(size[1])
		zr=range(size[2])
	for x in xr:
		for y in yr:
			for z in zr:
				v=a[x,y,z]
				of.write("%i %i %i %.6g 0 0\n" % (x,y,z,v))
	of.close()			
Ejemplo n.º 3
0
Archivo: gui.py Proyecto: gic888/MIEN
	def getCondition(self):
		'''Return a 1D array of integers representing the unit IDs for which all specified conditions are met'''
		if not (self.ast or self.data):
			return None
		if not self.condition:
			return arange(self.nunits)
		inds=ones(self.nunits)
		for k in self.condition.keys():
			colid=self.parnames.index(k)
			if self.data:
				col=data.getData()[:,colid]
			else:	
				col=self.ast.getColumn(colid)
			mi, ma = self.condition[k]
			newinds=logical_and(col>=mi, col<=ma)
			inds=logical_and(inds, newinds)
		return nonzero1d(inds)