Example #1
0
    def draw_graph(self):
        self.fig.clf()
        self.fig.subplots_adjust(bottom=0.2)
        self.fig.subplots_adjust(left=0.1)
        self.ax1 = self.fig.add_subplot(111)
        self.ax1.ticklabel_format(useOffset=False)

        self.ax1.set_ylabel(self.ylabel)
        if self.x != None:
            x_nm = [x * 1e9 for x in self.x]
            frequency, = self.ax1.plot(x_nm,
                                       self.y,
                                       'ro-',
                                       linewidth=3,
                                       alpha=1.0)

        if os.path.isfile(os.path.join(self.path, self.exp_file)) == True:

            dat_file_read(self.data, os.path.join(self.path, self.exp_file))
            title = get_ref_text(os.path.join(self.path, self.exp_file),
                                 html=False)

            if title != None:
                self.fig.suptitle(title)

            x_nm = [x * 1e9 for x in self.data.y_scale]
            frequency, = self.ax1.plot(x_nm,
                                       self.data.data[0][0],
                                       'bo-',
                                       linewidth=3,
                                       alpha=1.0)

        self.ax1.set_xlabel(_("Wavelength") + " (nm)")
Example #2
0
    def draw_mode(self, qp, start_x, start_y):
        t = []
        s = []
        z = []
        x = start_x
        y = start_y
        pen = QPen()
        pen.setWidth(3)
        pen.setColor(QColor(0, 0, 0))

        qp.setPen(pen)
        data = dat_file()
        if dat_file_read(
                data,
                os.path.join(get_sim_path(), "light_dump",
                             "light_1d_photons_tot_norm.dat")) == True:
            for i in range(1, data.y_len):

                x0 = (start_x - data.data[0][0][i - 1] * 40 - 10)
                y0 = (start_y + (200 * (i - 1) / data.y_len))
                x1 = (start_x - data.data[0][0][i] * 40 - 10)
                y1 = (start_y + (200 * i / data.y_len))
                if math.isnan(x0) == False and math.isnan(y0) == False:
                    x0 = (int)(x0)
                    y0 = (int)(y0)
                    x1 = (int)(x1)
                    y1 = (int)(y1)
                    qp.drawLine(x0, y0, x1, y1)
Example #3
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()
Example #4
0
def draw_mode(z_size, depth):

    glLineWidth(5)
    set_color(1.0, 1.0, 1.0, "mode")
    glBegin(GL_LINES)
    t = []
    s = []
    z = []
    start = 0.0
    data = dat_file()

    path = os.path.join(get_sim_path(), "light_dump",
                        "light_1d_photons_tot_norm.dat")
    if dat_file_read(data, path) == True:
        array_len = data.y_len
        s = data.data[0][0]
        s.reverse()
        #print(path)
        #print(data.data)
        for i in range(1, array_len):
            glVertex3f(0.0, start + (z_size * (i - 1) / array_len),
                       depth + s[i - 1] * 0.5)
            glVertex3f(0.0, start + (z_size * i / array_len),
                       depth + s[i] * 0.5)

    glEnd()
Example #5
0
	def sub_zero_frame(self,data,i):
		if self.zero_frame_enable==True:
			data_zero=dat_file()
			if dat_file_read(data_zero,self.zero_frame_list[i])==True:
				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]-data_zero.data[z][x][y]
Example #6
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
Example #7
0
    def draw_graph(self):
        self.fig.clf()
        self.fig.subplots_adjust(bottom=0.2)
        self.fig.subplots_adjust(left=0.1)
        self.ax1 = self.fig.add_subplot(111)
        self.ax1.ticklabel_format(useOffset=False)

        self.ax1.set_ylabel(self.ylabel)

        x_nm = [x * 1e9 for x in self.x]
        frequency, = self.ax1.plot(x_nm, self.y, "ro-", linewidth=3, alpha=1.0)

        if os.path.isfile(os.path.join(self.path, self.exp_file)) == True:
            data = dat_file()
            dat_file_read(data, os.path.join(self.path, self.exp_file))
            x_nm = [x * 1e9 for x in data.y_scale]
            frequency, = self.ax1.plot(x_nm, data.data[0][0], "bo-", linewidth=3, alpha=1.0)

        self.ax1.set_xlabel(_("Wavelength (nm)"))
Example #8
0
File: gl.py Project: mandulaj/gpvdm
		def load_data(self):
			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(os.path.join(get_sim_path(),"light.inp"), "#Psun")
			try:
				self.suns=float(val)
			except:
				self.suns=0.0
Example #9
0
def gen_workbook(input_file_or_dir,output_file):
	wb = Workbook()
	info_token=plot_state()
	if os.path.isfile(input_file_or_dir):
		files=[input_file_or_dir]
	if os.path.isdir(input_file_or_dir):
		files=glob.glob(os.path.join(input_file_or_dir,"*.dat"))
	else:
		return
	
	for my_file in files:
		print("about to save1",my_file)

		if plot_load_info(info_token,my_file)==True:
			x=[]
			y=[]
			z=[]
			data=dat_file()
			if dat_file_read(data,my_file)==True:
				print("read",my_file)
				ws = wb.create_sheet(title=title_truncate(os.path.basename(my_file)))
				ws.cell(column=1, row=1, value=info_token.title)
				ws.cell(column=1, row=2, value=info_token.x_label+" ("+info_token.x_units+") ")
				ws.cell(column=2, row=2, value=info_token.y_label+" ("+info_token.y_units+") ")
		
				for i in range(0,data.y_len):
					ws.cell(column=1, row=i+3, value=data.y_scale[i])
					ws.cell(column=2, row=i+3, value=data.data[0][0][i])

				c1 = ScatterChart()
				c1.title = info_token.title
				c1.style = 13
				c1.height=20
				c1.width=20
				c1.y_axis.title = info_token.y_label+" ("+info_token.y_units+") "
				c1.x_axis.title = info_token.x_label+" ("+info_token.x_units+") "

				xdata = Reference(ws, min_col=1, min_row=3, max_row=3+data.y_len)
				ydata = Reference(ws, min_col=2, min_row=3, max_row=3+data.y_len)

				series = Series(ydata,xdata,  title_from_data=True)
				c1.series.append(series)
				ws.add_chart(c1, "G4")

	print("about to save1")
	wb.save(filename = output_file)
	print("about to save0")
	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
Example #11
0
	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
Example #12
0
    def draw_mode(self, qp, start_x, start_y):
        t = []
        s = []
        z = []
        x = start_x
        y = start_y
        pen = QPen()
        pen.setWidth(3)
        pen.setColor(QColor(0, 0, 0))

        qp.setPen(pen)
        data = dat_file()
        if dat_file_read(data, os.path.join(os.getcwd(), "light_dump", "light_1d_photons_tot_norm.dat")) == True:
            for i in range(1, data.y_len):
                qp.drawLine(
                    start_x - data.data[0][0][i - 1] * 40 - 10,
                    start_y + (200 * (i - 1) / data.y_len),
                    start_x - data.data[0][0][i] * 40 - 10,
                    start_y + (200 * i / data.y_len),
                )
        else:
            print("no mode")
Example #13
0
def draw_mode(z_size,depth):

	glLineWidth(5)
	glColor3f(1.0, 1.0, 1.0)
	glBegin(GL_LINES)
	t=[]
	s=[]
	z=[]
	start=0.0
	data=dat_file()
			
	path=os.path.join(os.getcwd(),"light_dump","light_1d_photons_tot_norm.dat")
	if dat_file_read(data,path)==True:
		array_len=data.y_len
		s=data.data[0][0]
		s.reverse()
		#print(path)
		#print(data.data)
		for i in range(1,array_len):
			glVertex3f(0.0, start+(z_size*(i-1)/array_len), depth+s[i-1]*0.5)
			glVertex3f(0.0, start+(z_size*i/array_len), depth+s[i]*0.5)

	glEnd()
Example #14
0
    def load_data(self, input_files, config_file):
        self.lx = None
        self.ly = None
        self.input_files = input_files
        self.config_file = config_file

        if len(input_files) == 0:
            print(_("No files were given to load"))
            return

        if self.config_file == "":
            base = os.path.splitext(input_files[0])
            self.config_file = base[0] + ".oplot"

        self.data = []

        for i in range(0, len(self.input_files)):
            dat = dat_file()
            ret = dat_file_read(dat, self.input_files[i])
            self.data.append(dat)

        #Try and get the data from the config file
        self.norm_data()
Example #15
0
def gen_workbook(input_file_or_dir, output_file):
    if work_book_enabled == False:
        print("python3-openpyxl not found")
        return

    wb = Workbook()
    if os.path.isfile(input_file_or_dir):
        files = [input_file_or_dir]
    if os.path.isdir(input_file_or_dir):
        files = glob.glob(os.path.join(input_file_or_dir, "*.dat"))
    else:
        return

    ws = wb.active
    pos = 1
    for i in range(0, epitaxy_get_layers()):
        dos_layer = epitaxy_get_electrical_layer(i)
        if dos_layer.startswith("dos") == True:
            pos = workbook_from_inp(ws,
                                    pos,
                                    dos_layer + ".inp",
                                    title=epitaxy_get_name(i))

    for my_file in files:
        #print("about to save1",my_file)
        #print(my_file)
        data = dat_file()
        if dat_file_read(data, my_file, guess=False) == True:
            x = []
            y = []
            z = []
            if dat_file_read(data, my_file) == True:
                #print("read",my_file)
                ws = wb.create_sheet(
                    title=title_truncate(os.path.basename(my_file)))
                ws.cell(column=1, row=1, value=data.title)
                ws.cell(column=1,
                        row=2,
                        value=data.x_label + " (" + data.x_units + ") ")
                ws.cell(column=2,
                        row=2,
                        value=data.data_label + " (" + data.data_units + ") ")

                for i in range(0, data.y_len):
                    ws.cell(column=1, row=i + 3, value=data.y_scale[i])
                    ws.cell(column=2, row=i + 3, value=data.data[0][0][i])

                c1 = ScatterChart()
                c1.title = data.title
                c1.style = 13
                c1.height = 20
                c1.width = 20
                c1.y_axis.title = data.data_label + " (" + data.data_units + ") "
                c1.x_axis.title = data.x_label + " (" + data.x_units + ") "

                xdata = Reference(ws,
                                  min_col=1,
                                  min_row=3,
                                  max_row=3 + data.y_len)
                ydata = Reference(ws,
                                  min_col=2,
                                  min_row=3,
                                  max_row=3 + data.y_len)

                series = Series(ydata, xdata, title_from_data=True)
                c1.series.append(series)
                ws.add_chart(c1, "G4")
    #print("about to save1")
    try:
        wb.save(filename=output_file)
    except:
        return False

    return True
Example #16
0
	def draw_graph(self):

		self.layer_end=[]
		self.layer_name=[]
		self.optical_mode_file=os.path.join(get_sim_path(),"light_dump",self.data_file)

		self.my_figure.clf()
		ax1 = self.my_figure.add_subplot(111)
		ax2 = ax1.twinx()
		x_pos=0.0
		layer=0
		color =['r','g','b','y','o','r','g','b','y','o']
		start=0.0

		for i in range(0,epitaxy_get_layers()):
			if epitaxy_get_electrical_layer(i).startswith("dos")==False:
				start=start-epitaxy_get_width(i)
			else:
				break

		start=start*1e9

		x_pos=start
		for i in range(0,epitaxy_get_layers()):

#			label=epitaxy_get_mat_file(i)
			layer_ticknes=epitaxy_get_width(i)
			layer_material=epitaxy_get_mat_file(i)
			lumo=0.0
			h**o=0.0
			
			delta=float(layer_ticknes)*1e9
			#print(epitaxy_get_electrical_layer(i))
			lines=[]
			material_type=inp_get_token_value(os.path.join(get_materials_path(),layer_material,'mat.inp'), "#material_type")
			if epitaxy_get_electrical_layer(i).startswith("dos")==False:
				dos_file=os.path.join(get_materials_path(),layer_material,'dos.inp')
				if os.path.isfile(dos_file)==False:
					dos_file=os.path.join(get_default_material_path(),"dos.inp")

				lines=inp_load_file(dos_file)
				if lines!=False:
					lumo=-float(inp_search_token_value(lines, "#Xi"))
					Eg=float(inp_search_token_value(lines, "#Eg"))
			else:
				lines=inp_load_file(os.path.join(get_sim_path(),epitaxy_get_electrical_layer(i)+".inp"))
				if lines!=False:
					lumo=-float(inp_search_token_value(lines, "#Xi"))
					Eg=float(inp_search_token_value(lines, "#Eg"))
					#print("b")

			x = [x_pos,x_pos+delta,x_pos+delta,x_pos]

			#print("lumo=",lumo)
			lumo_delta=lumo-0.1

			h**o=lumo-Eg
			homo_delta=h**o-0.1

			draw_homo=True
			y_name_pos=lumo-Eg/2

			if Eg==0.0 or material_type=="metal":
				lumo_delta=-7.0
				draw_homo=False
				y_name_pos=lumo-1.0

			x_pos=x_pos+delta
			self.layer_end.append(x_pos)
			self.layer_name.append(layer_material)

			item=ax2.text(x_pos-delta/1.5, y_name_pos, epitaxy_get_name(i))
			item.set_fontsize(15)

			lumo_shape = [lumo,lumo,lumo_delta,lumo_delta]
			ax2.fill(x,lumo_shape, color[layer],alpha=0.4)
			item=ax2.text(x_pos-delta/1.5, lumo+0.1, "%.2f eV" % lumo)
			item.set_fontsize(15)

			if draw_homo==True:
				homo_shape = [h**o,h**o,homo_delta,homo_delta]
				ax2.fill(x,homo_shape, color[layer],alpha=0.4)
				item=ax2.text(x_pos-delta/1.5, lumo-Eg-0.4, "%.2f eV" % h**o)
				item.set_fontsize(15)

			layer=layer+1

		state=dat_file()
		if dat_file_read(state,self.optical_mode_file)==True:
			ax1.set_ylabel(state.data_label+" ("+state.data_units+")")
			ax1.set_xlabel(_("Position")+" (nm)")
			ax2.set_ylabel(_("Energy")+" (eV)")
			ax2.set_xlim([start, x_pos])
			#ax2.axis(max=)#autoscale(enable=True, axis='x', tight=None)

			for i in range(0,len(state.y_scale)):
				state.y_scale[i]=state.y_scale[i]*1e9
			
			ax1.plot(state.y_scale,state.data[0][0], 'black', linewidth=3 ,alpha=0.5)



		self.my_figure.tight_layout()