示例#1
0
	def read_data_file(self,data,index):
		if dat_file_read(data,self.input_files[index])==True:
			self.sub_zero_frame(data,index)
			my_min=0.0;

			for y in range(0,data.y_len):
				data.y_scale[y]=data.y_scale[y]*self.plot_token.x_mul

			for x in range(0,data.x_len):
				data.x_scale[x]=data.x_scale[x]*self.plot_token.x_mul
				
			for x in range(0,data.x_len):
				for y in range(0,data.y_len):
					for z in range(0,data.z_len):
						#print("mull=",self.plot_token.y_mul)
						data.data[z][x][y]=data.data[z][x][y]*self.plot_token.y_mul

						#if self.plot_token.invert_y==True:
						#	data.data[z][x][y]=-data.data[z][x][y]

			if self.plot_token.subtract_first_point==True:
				val=data.data[0][0][0]
				for x in range(0,data.x_len):
					for y in range(0,data.y_len):
						for z in range(0,data.z_len):
							data.data[z][x][y]=data.data[z][x][y]-val


			if self.plot_token.add_min==True:
				my_max,my_min=dat_file_max_min(data)

				for x in range(0,data.x_len):
					for y in range(0,data.y_len):
						for z in range(0,data.z_len):
							data.data[z][x][y]=data.data[z][x][y]-my_min

			if self.plot_token.normalize==True:
				my_max,my_min=dat_file_max_min(data)
				for x in range(0,data.x_len):
					for y in range(0,data.y_len):
						for z in range(0,data.z_len):
							if data.data[z][x][y]!=0:
								data.data[z][x][y]=data.data[z][x][y]/my_max
							else:
								data.data[z][x][y]=0.0


			if index<len(self.plot_id):
				plot_number=self.plot_id[index]
			else:
				plot_number=index
			#print("YMIN=",self.plot_token.ymin)
			if self.plot_token.ymax!=-1:
				self.ax[plot_number].set_ylim((self.plot_token.ymin,self.plot_token.ymax))
			return True
		else:
			return False
示例#2
0
		def recalculate(self):
			self.colors=[]
			lines=[]

			if dat_file_read(self.graph_data,self.graph_path)==True:
				#print(self.graph_path)
				self.graph_z_max,self.graph_z_min=dat_file_max_min(self.graph_data)
				#print(self.graph_z_max,self.graph_z_min)
			val=inp_get_token_value("light.inp", "#Psun")
			self.suns=float(val)
			l=epitaxy_get_layers()-1
			for i in range(0,epitaxy_get_layers()):

				path=os.path.join(get_materials_path(),epitaxy_get_mat_file(l-i),"mat.inp")


				if inp_load_file(lines,path)==True:
					red=float(inp_search_token_value(lines, "#Red"))
					green=float(inp_search_token_value(lines, "#Green"))
					blue=float(inp_search_token_value(lines, "#Blue"))
				else:

					red=0.0
					green=0.0
					blue=0.0
				self.colors.append(color(red,green,blue))
			self.colors.reverse()
			self.update()
	def cal_min_max(self):

		self.z_max=-1e40
		self.z_min=1e40

		for i in range(0,len(self.dirs)):
			fname=os.path.join(self.dirs[i],self.files_combo.currentText())
			x=[]
			y=[]
			z=[]

			my_data=dat_file()
			if dat_file_read(my_data,fname) == True:
				#print(z)
				temp_max,temp_min=dat_file_max_min(my_data)

				if temp_max>self.z_max:
					self.z_max=temp_max

				if temp_min<self.z_min:
					self.z_min=temp_min
示例#4
0
	def do_plot(self):
		#print("PLOT TYPE=",self.plot_token.type)
		if self.plot_token!=None and len(self.plot_id)!=0:
			plot_number=0
			#print(">>>>>>>>>>>>",self.plot_token.x_len,self.plot_token.y_len,self.plot_token.z_len)
			self.fig.clf()
			self.fig.subplots_adjust(bottom=0.2)
			self.fig.subplots_adjust(bottom=0.2)
			self.fig.subplots_adjust(left=0.1)
			self.fig.subplots_adjust(hspace = .001)

			title=""
			if self.plot_title=="":
				title=self.plot_token.title
			else:
				title=self.plot_title

			if self.plot_token.time!=-1.0 and self.plot_token.Vexternal!=-1.0:
				mul,unit=time_with_units(self.plot_token.time)
				title=title+" V="+str(self.plot_token.Vexternal)+" time="+str(self.plot_token.time*mul)+" "+unit

			self.fig.suptitle(title)

			self.ax=[]
			number_of_plots=max(self.plot_id)+1
			if self.plot_token.type=="heat":
				number_of_plots=1




			for i in range(0,number_of_plots):
				self.ax.append(self.fig.add_subplot(number_of_plots,1,i+1, axisbg='white'))
				#Only place label on bottom plot
				if i==number_of_plots-1:
					#print(self.plot_token.x_label,self.plot_token.x_units)
					self.ax[i].set_xlabel(self.plot_token.x_label+" ("+str(self.plot_token.x_units)+")")

				else:
					self.ax[i].tick_params(axis='x', which='both', bottom='off', top='off',labelbottom='off') # labels along the bottom edge are off

				#Only place y label on center plot
				if self.plot_token.normalize==True or self.plot_token.norm_to_peak_of_all_data==True:
					y_text="Normalized "+self.plot_token.y_label
					y_units="au"
				else:
					y_text=self.plot_token.y_label
					y_units=self.plot_token.y_units
				if i==math.trunc(number_of_plots/2):
					self.ax[i].set_ylabel(y_text+" ("+y_units+")")

				if self.plot_token.logx==True:
					self.ax[i].set_xscale("log")

				if self.plot_token.logy==True:
					self.ax[i].set_yscale("log")


			lines=[]
			files=[]
			data=dat_file()
			my_max=1.0

			if self.plot_token.x_len==1 and self.plot_token.z_len==1:

				all_max=1.0
				if self.plot_token.norm_to_peak_of_all_data==True:
					my_max=-1e40
					for i in range(0, len(self.input_files)):
						if self.read_data_file(data,i)==True:
							local_max,my_min=dat_file_max_min(data)
							if local_max>my_max:
								my_max=local_max
					all_max=my_max

				for i in range(0, len(self.input_files)):
					if self.read_data_file(data,i)==True:
						if all_max!=1.0:
							for x in range(0,data.x_len):
								for y in range(0,data.y_len):
									for z in range(0,data.z_len):
										data.data[z][x][y]=data.data[z][x][y]/all_max

						Ec, = self.ax[plot_number].plot(data.y_scale,data.data[0][0], linewidth=3 ,alpha=1.0,color=self.color[i],marker=self.marker[i])

						#label data if required
						#if self.plot_token.label_data==True:
						#	for ii in range(0,len(t)):
						#		if z[ii]!="":
						#			fx_unit=fx_with_units(float(z[ii]))
						#			label_text=str(float(z[ii])*fx_unit[0])+" "+fx_unit[1]
						#			self.ax[plot_number].annotate(label_text,xy = (t[ii], s[ii]), xytext = (-20, 20),textcoords = 'offset points', ha = 'right', va = 'bottom',bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0'))

						#if number_of_plots>1:
						#	self.ax[plot_number].yaxis.set_major_formatter(ticker.FormatStrFormatter('%0.1e'))
						#	if min(s)!=max(s):
						#		print("TICKS=",(max(s)-min(s))/4.0)
						#		self.ax[plot_number].yaxis.set_ticks(arange(min(s), max(s), (max(s)-min(s))/4.0 ))

						#print("roderick",self.labels,i,self.labels[i])
						if self.labels[i]!="":
							#print "Rod=",self.labels[i]
							#print self.plot_token.key_units
							files.append("$"+numbers_to_latex(str(self.labels[i]))+" "+pygtk_to_latex_subscript(self.plot_token.key_units)+"$")

							lines.append(Ec)

				self.lx = None
				self.ly = None
				if self.plot_token.legend_pos=="No key":
					self.ax[plot_number].legend_ = None
				else:
					self.fig.legend(lines, files, self.plot_token.legend_pos)
			elif self.plot_token.x_len>1 and self.plot_token.y_len>1 and self.plot_token.z_len==1:		#3d plot
				data=dat_file()

				if self.read_data_file(data,0)==True:
					im=self.ax[0].pcolor(data.y_scale,data.x_scale,data.data[0])
					self.fig.colorbar(im)
					#self.ax[0].plot_surface(x, y, z, rstride=1, cstride=1, cmap=cm.coolwarm,linewidth=0, antialiased=False)
					#self.ax[0].invert_yaxis()
					#self.ax[0].xaxis.tick_top()
			elif self.plot_token.type=="heat":
				x=[]
				y=[]
				z=[]

				pos=float(self.plot_token.x_start)
				x_step=(float(self.plot_token.x_stop)-float(self.plot_token.x_start))/self.plot_token.x_points
				while(pos<float(self.plot_token.x_stop)):
					x.append(pos)
					pos=pos+x_step

				pos=float(self.plot_token.y_start)
				y_step=(float(self.plot_token.y_stop)-float(self.plot_token.y_start))/self.plot_token.y_points
				while(pos<float(self.plot_token.y_stop)):
					y.append(pos)
					pos=pos+y_step

				data = zeros((len(y),len(x)))

				for ii in range(0,len(self.input_files)):
					t=[]
					s=[]
					z=[]
					if self.read_data_file(t,s,z,ii)==True:
						#print(self.input_files[ii])
						for points in range(0,len(t)):
							found=0
							if t[points]>x[0]:
								for x_pos in range(0,len(x)):
									if x[x_pos]>t[points]:
										found=found+1
										break

							if s[points]>y[0]:
								for y_pos in range(0,len(y)):
									if y_pos!=0:
										if y[y_pos]>s[points]:
											found=found+1
											break
							if found==2:
								#print("adding data at",x_pos,y_pos)
								if data[y_pos][x_pos]<10.0:
									data[y_pos][x_pos]=data[y_pos][x_pos]+1
							else:
								print("not adding point",t[points],s[points])

				#print(x)
				#print(y)
				#print(data)
				x_grid, y_grid = mgrid[float(self.plot_token.y_start):float(self.plot_token.y_stop):complex(0, len(y)), float(self.plot_token.x_start):float(self.plot_token.x_stop):complex(0, len(x))]
				self.ax[0].pcolor(y_grid,x_grid,data)
				
			else:
				x=[]
				y=[]
				z=[]

				if read_data_2d(x,y,z,self.input_files[0])==True:
					#print(len(x),len(y),len(z),self.input_files[0])
					maxx=-1
					maxy=-1
					for i in range(0,len(z)):
						if x[i]>maxx:
							maxx=x[i]

						if y[i]>maxy:
							maxy=y[i]

					maxx=maxx+1
					maxy=maxy+1

					data = zeros((maxy,maxx))


					for i in range(0,len(z)):
						data[y[i]][x[i]]= random.random()+5
						self.ax[0].text(x[i], y[i]+float(maxy)/float(len(z))+0.1,'%.1e' %  z[i], fontsize=12)

					#fig, ax = plt.subplots()
					self.ax[0].pcolor(data,cmap=plt.cm.Blues)
					
					self.ax[0].invert_yaxis()
					self.ax[0].xaxis.tick_top()

			#self.fig.tight_layout(pad=0.0, w_pad=0.0, h_pad=0.0)
			self.fig.canvas.draw()