Exemplo n.º 1
0
    def setAttributes(self):
        """Set attributes of class for the configurations"""
        setattr(self, 'runTraining', util.str2bool(self.get('runTraining')))
        setattr(self, 'runInference', util.str2bool(self.get('runInference')))
        setattr(self, 'hep_data', self.get('hep_data'))
        setattr(self, 'treename', self.get('treename'))
        setattr(self, 'dnn_data', self.get('dnn_data'))
        setattr(self, 'output_path', self.get('output_path'))
        setattr(self, 'nHiddenLayers', int(self.get('nHiddenLayers')))
        setattr(self, 'nNodes', self.get('nNodes').split(','))
        setattr(self, 'epochs', int(self.get('epochs')))
        setattr(self, 'batch_size', int(self.get('batch_size')))
        setattr(self, 'loss', self.get('loss'))
        setattr(self, 'optimizer', self.get('optimizer'))
        setattr(self, 'metrics', self.get('metrics').split(','))
        setattr(self, 'kfold_splits', int(self.get('kfold_splits')))
        setattr(self, 'init', self.get('init'))
        setattr(self, 'output_dim', int(self.get('output_dim')))
        setattr(self, 'features', self.get('features').split(','))
        setattr(self, 'percentile', int(self.get('percentile')))
        setattr(self, 'activation', self.get('activation'))
        setattr(self, 'nEntries', int(self.get('nEntries')))
        setattr(self, 'verbose_level', self.get('verbose'))

        return
Exemplo n.º 2
0
	def update(self):
		self.lines=inp_load_file(self.file_name)
		if self.lines==False:
			error_dlg(self,_("File not found.")+" "+self.file_name)
			return

		for w in self.widget_list:
			values=inp_search_token_array(self.lines, w.token)
			w.edit_box.blockSignals(True)

			if w.widget=="gtkswitch":
				w.edit_box.set_value(str2bool(values[0]))
			elif w.widget=="leftright":
				w.edit_box.set_value(str2bool(values[0]))
			elif w.widget=="gpvdm_select":
				w.edit_box.setText(values[0])
			elif w.widget=="QLineEdit":
				w.edit_box.setText(values[0])
			elif w.widget=="QColorPicker":
				print()
			elif w.widget=="QComboBoxLang":
				print()
			elif w.widget=="QParasitic":
				w.edit_box.setValue(values[0])
			elif w.widget=="QChangeLog":
				w.edit_box.setText(values[0])
				
			w.edit_box.blockSignals(False)
Exemplo n.º 3
0
		def callback_dbus(self,data_in):
			if data_in.startswith("hex"):
				data_in=data_in[3:]
				data=codecs.decode(data_in, 'hex')
				data=data.decode('ascii')

				if data.startswith("lock"):
					if len(self.jobs)==0:
						print(_("I did not think I was running any jobs"))
						self.stop()
					else:
						if self.finished_jobs.count(data)==0:
							job=int(data[4:])
							self.base_job_finished(job)

							self.finished_jobs.append(data)
							make_work_book=inp_get_token_value(os.path.join(get_sim_path(),"dump.inp"),"#dump_workbook")
							if make_work_book!=None:
								if str2bool(make_work_book)==True:
									if gen_workbook(self.jobs[job].path,os.path.join(self.jobs[job].path,"data.xlsx"))==False:
										self.excel_workbook_gen_error=self.excel_workbook_gen_error or True

							self.progress_window.set_fraction(float(self.jobs_run)/float(len(self.jobs)))

							if (self.jobs_run==len(self.jobs)):
								self.stop()

				elif (data=="pulse"):
					if len(self.jobs)==1:
						splitup=data.split(":")
						if len(splitup)>1:
							text=data.split(":")[1]
							self.progress_window.set_text(text)
						#self.progress_window.progress.set_pulse_step(0.01)
						self.progress_window.pulse()
				elif (data.startswith("enable_pulse")):
					splitup=data.split(":")
					if len(splitup)>1:
						value=str2bool(data.split(":")[1])
						self.progress_window.enable_pulse(value)
				elif (data.startswith("percent")):
					if len(self.jobs)==1:
						splitup=data.split(":")
						if len(splitup)>1:
							frac=float(data.split(":")[1])
							self.progress_window.set_fraction(frac)
				elif (data.startswith("text")):
					if len(self.jobs)==1:
						splitup=data.split(":")
						if len(splitup)>1:
							self.progress_window.set_text(data.split(":")[1])
				elif (data.startswith("fit_run")):
					elapsed_time = time.time() - self.gui_update_time
					if elapsed_time>5:

						self.gui_update_time=time.time()
					
						if self.fit_update!=None:
							self.fit_update()
Exemplo n.º 4
0
def plot_load_oplot_file(plot_token, file_name):
    lines = inp_load_file(file_name)
    if lines != False:
        plot_token.logy = str2bool(inp_search_token_value(lines, "#logy"))
        plot_token.logx = str2bool(inp_search_token_value(lines, "#logx"))
        plot_token.logz = str2bool(inp_search_token_value(lines, "#logz"))
        plot_token.grid = str2bool(inp_search_token_value(lines, "#grid"))
        plot_token.invert_y = str2bool(
            inp_search_token_value(lines, "#invert_y"))
        plot_token.normalize = str2bool(
            inp_search_token_value(lines, "#normalize"))
        plot_token.norm_to_peak_of_all_data = str2bool(
            inp_search_token_value(lines, "#norm_to_peak_of_all_data"))
        plot_token.subtract_first_point = str2bool(
            inp_search_token_value(lines, "#subtract_first_point"))
        plot_token.add_min = str2bool(inp_search_token_value(
            lines, "#add_min"))
        plot_token.file0 = inp_search_token_value(lines, "#file0")
        plot_token.file1 = inp_search_token_value(lines, "#file1")
        plot_token.file2 = inp_search_token_value(lines, "#file2")
        plot_token.tag0 = inp_search_token_value(lines, "#tag0")
        plot_token.tag1 = inp_search_token_value(lines, "#tag1")
        plot_token.tag2 = inp_search_token_value(lines, "#tag2")
        plot_token.legend_pos = inp_search_token_value(lines, "#legend_pos")
        plot_token.key_units = inp_search_token_value(lines, "#key_units")
        plot_token.label_data = str2bool(
            inp_search_token_value(lines, "#label_data"))
        plot_token.type = inp_search_token_value(lines, "#type")
        plot_token.x_label = inp_search_token_value(lines, "#x_label")
        plot_token.y_label = inp_search_token_value(lines, "#y_label")
        plot_token.z_label = inp_search_token_value(lines, "#z_label")
        plot_token.data_label = inp_search_token_value(lines, "#data_label")
        plot_token.x_units = inp_search_token_value(lines, "#x_units")
        plot_token.y_units = inp_search_token_value(lines, "#y_units")
        plot_token.y_units = inp_search_token_value(lines, "#z_units")
        plot_token.data_units = inp_search_token_value(lines, "#data_units")
        plot_token.x_mul = float(inp_search_token_value(lines, "#x_mul"))
        plot_token.y_mul = float(inp_search_token_value(lines, "#y_mul"))
        plot_token.z_mul = float(inp_search_token_value(lines, "#z_mul"))
        plot_token.data_mul = float(inp_search_token_value(lines, "#data_mul"))
        plot_token.key_units = inp_search_token_value(lines, "#key_units")
        plot_token.x_start = float(inp_search_token_value(lines, "#x_start"))
        plot_token.x_stop = float(inp_search_token_value(lines, "#x_stop"))
        plot_token.x_points = float(inp_search_token_value(lines, "#x_points"))
        plot_token.y_start = float(inp_search_token_value(lines, "#y_start"))
        plot_token.y_stop = float(inp_search_token_value(lines, "#y_stop"))
        plot_token.y_points = float(inp_search_token_value(lines, "#y_points"))
        plot_token.time = float(inp_search_token_value(lines, "#time"))
        plot_token.Vexternal = float(
            inp_search_token_value(lines, "#Vexternal"))

        return True
    return False
Exemplo n.º 5
0
    def change_active_layer_thickness(self, obj):
        thickness = obj.get_data("refresh")
        count = 0
        for item in self.model:
            if str2bool(item[COLUMN_DEVICE]) == True:
                count = count + 1

        if count == 1:
            for item in self.model:
                if str2bool(item[COLUMN_DEVICE]) == True:
                    item[COLUMN_THICKNES] = str(thickness)
                    self.save_model()
                    self.refresh(False)
                    return
Exemplo n.º 6
0
def create(request):
	success = True
	result = {}
	error = ''
	status_code = 200

	# handle multi and inline parameters in request
	multi = util.str2bool(request.args.get('multi'))
	inline = util.str2bool(request.args.get('inline'))

	print multi

	# handle multiple documents
	if multi is True:
		raise NotImplementedError()

		if type(request.json) is not list:
			# check to see if it is a single document (i.e., dict)
			#if multi is True:
			#	if len(request.json) > 1:
			#		for doc in request.json:
			#			print doc['title']
			pass

	if 'application/json' in request.headers['content-type']:
		# create the package object
		try:
			result['id'] = crud_helpers.create_package(request.json)
		except HelperException as e:
			success = False
			error = e.error
			status_code = e.status_code
	else:
		success = False
		error = "The content-type was not of the expected type.  The content-type found was " + request.headers["content-type"] + ", whereas the content-type expected was application/json."
		status_code = 400

	# handle inline parameter in request
	if inline is True:
		# parse out resource
		pass
		# TODO

	if success is True:
		response = createJsonResponse(result, status_code)
	else:
		result['error'] = error
		response = createJsonResponse(result, status_code)
	
	return response
Exemplo n.º 7
0
	def change_active_layer_thickness(self,obj):
		thickness=obj.get_data("refresh")
		count=0
		for item in self.model:
			if str2bool(item[COLUMN_DEVICE])==True:
				count=count+1

		if count==1:
			for item in self.model:
				if str2bool(item[COLUMN_DEVICE])==True:
					item[COLUMN_THICKNES]=str(thickness)
					self.save_model()
					self.refresh(False)
					return
Exemplo n.º 8
0
    def insert_row(self, i, enabled, src_file, src_token, src_path, dest_file,
                   dest_token, dest_path):
        self.tab.blockSignals(True)
        self.tab.insertRow(i)

        item = gtkswitch()
        item.set_value(str2bool(enabled))
        item.changed.connect(self.tab_changed)
        self.tab.setCellWidget(i, 0, item)

        item = QTableWidgetItem(src_file)
        self.tab.setItem(i, 1, item)

        item = QTableWidgetItem(src_token)
        self.tab.setItem(i, 2, item)

        self.item = gpvdm_select()
        self.item.setText(src_path)
        self.item.button.clicked.connect(self.callback_show_list_src)
        self.tab.setCellWidget(i, 3, self.item)

        item = QTableWidgetItem(dest_file)
        self.tab.setItem(i, 4, item)

        item = QTableWidgetItem(dest_token)
        self.tab.setItem(i, 5, item)

        self.item = gpvdm_select()
        self.item.setText(dest_path)
        self.item.button.clicked.connect(self.callback_show_list_dest)
        self.tab.setCellWidget(i, 6, self.item)

        self.tab.blockSignals(False)
Exemplo n.º 9
0
    def insert_row(self, i, enabled, f, t, p, v, section):
        self.tab.blockSignals(True)

        self.item = gtkswitch()
        self.item.set_value(str2bool(enabled))
        self.item.changed.connect(self.tab_changed)
        self.tab.setCellWidget(i, 0, self.item)

        item = QTableWidgetItem(f)
        self.tab.setItem(i, 1, item)

        item = QTableWidgetItem(t)
        self.tab.setItem(i, 2, item)

        self.item = gpvdm_select()
        self.item.setText(p)
        self.item.button.clicked.connect(self.callback_show_list)

        self.tab.setCellWidget(i, 3, self.item)

        item = QTableWidgetItem(v)
        self.tab.setItem(i, 4, item)

        item = QTableWidgetItem(section)
        self.tab.setItem(i, 5, item)

        self.tab.blockSignals(False)
Exemplo n.º 10
0
def tree_load_config(sim_dir):
	global copy_materials

	copy_materials=inp_get_token_value(os.path.join(sim_dir,"scan_config.inp"),"#copy_materials")
	if copy_materials==None:
		copy_materials="False"
	copy_materials=str2bool(copy_materials)
Exemplo n.º 11
0
	def update(self):
		lines=inp_load_file(os.path.join(get_sim_path(),"fit"+str(self.index)+".inp"))
		if lines!=False:
			enabled=str2bool(inp_search_token_value(lines, "#enabled"))
			if enabled==True:
				self.tmesh_real.update()
				self.tmesh.update()
Exemplo n.º 12
0
def tree_load_config(sim_dir):
	global copy_materials

	copy_materials=inp_get_token_value(os.path.join(sim_dir,"scan_config.inp"),"#copy_materials")
	if copy_materials==None:
		copy_materials="False"
	copy_materials=str2bool(copy_materials)
Exemplo n.º 13
0
def mesh_load(vector):
	file_name="mesh_"+vector+".inp"

	if vector=="x":
		mesh_clear_xlist()
	elif vector=="y":
		mesh_clear_ylist()
	elif vector=="z":
		mesh_clear_zlist()

	my_list=[]
	pos=0
	lines=inp_load_file(file_name)

	if lines!=False:
		if lines[pos]!="#remesh_enable":			#Check we are not trying to open an old version
			return False

		pos=pos+1	#first comment
		remesh=str2bool(lines[pos])
		pos=pos+1	#remesh

		if vector=="x":
			global xlist
			xlist.remesh=remesh
		elif vector=="y":
			global ylist
			ylist.remesh=remesh
		elif vector=="z":
			global zlist
			zlist.remesh=remesh

		pos=pos+1	#first comment
		mesh_layers=int(lines[pos])
		for i in range(0, mesh_layers):
			#thick
			pos=pos+1			#token
			token=lines[pos]
			pos=pos+1
			thick=lines[pos]	#length

			pos=pos+1			#token
			token=lines[pos]
			pos=pos+1
			points=lines[pos] 	#points
			
			pos=pos+1			#token
			token=lines[pos]
			pos=pos+1
			mul=lines[pos] 		#mul

			pos=pos+1			#token
			token=lines[pos]
			pos=pos+1
			left_right=lines[pos] 		#left_right

			mesh_add(vector,thick,points,mul,left_right)

	return True
Exemplo n.º 14
0
	def draw(self):
		emission=False
		lines=[]
		for i in range(0,epitaxy_get_layers()):
			if epitaxy_get_pl_file(i)!="none":
				if inp_load_file(lines,epitaxy_get_pl_file(i)+".inp")==True:
					if str2bool(lines[1])==True:
						emission=True				

		tot=0
		for i in range(0,epitaxy_get_layers()):
			tot=tot+epitaxy_get_width(i)

		pos=0.0
		l=epitaxy_get_layers()-1
		lines=[]

		for i in range(0,epitaxy_get_layers()):
			thick=200.0*epitaxy_get_width(l-i)/tot
			pos=pos+thick
			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:
				print "Could not load",path
				red=0.0
				green=0.0
				blue=0.0

			self.draw_box(200,450.0-pos,thick*0.9,red,green,blue,l-i)
		step=50.0

		lines=[]
		if inp_load_file(lines,os.path.join(os.getcwd(),"light.inp"))==True:
			self.sun=float(inp_search_token_value(lines, "#Psun"))

		if self.sun<=0.01:
			step=200
		elif self.sun<=0.1:
			step=100
		elif self.sun<=1.0:
			step=50
		elif self.sun<=10.0:
			step=10
		else:
			step=5.0
		if self.sun!=0:
			for x in range(0,200,step):
				self.draw_photon(270+x,50)

		if emission==True:
			for x in range(0,200,50):
				self.draw_photon_up(240+x,180)

		self.draw_mode(200,250,200)
Exemplo n.º 15
0
	def __init__(self):
		QWidget.__init__(self)
		self.complex_display=False

		self.hbox=QVBoxLayout()
		self.gl_cmp=gl_cmp(os.path.join(os.getcwd(),"snapshots"))
		
		toolbar=QToolBar()
		toolbar.setIconSize(QSize(42, 42))

		self.tb_rotate = QAction(QIcon(os.path.join(get_image_file_path(),"rotate.png")), _("Rotate"), self)
		self.tb_rotate.triggered.connect(self.tb_rotate_click)
		toolbar.addAction(self.tb_rotate)
		self.tb_rotate.setEnabled(True)
		
		self.tb_contact = QAction(QIcon(os.path.join(get_image_file_path(),"contact.png")), _("Contacts"), self)
		self.tb_contact.triggered.connect(self.callback_contacts)
		toolbar.addAction(self.tb_contact)

		self.tb_mesh = QAction(QIcon(os.path.join(get_image_file_path(),"mesh.png")), _("Edit the electrical mesh"), self)
		self.tb_mesh.triggered.connect(self.callback_edit_mesh)
		toolbar.addAction(self.tb_mesh)


		self.tb_config = QAction(QIcon(os.path.join(get_image_file_path(),"cog.png")), _("Configuration"), self)
		self.tb_config.triggered.connect(self.callback_configure)
		toolbar.addAction(self.tb_config)
		
		self.hbox.addWidget(toolbar)
		
		enable_3d=inp_get_token_value(os.path.join(os.getcwd(),"config.inp") , "#gui_config_3d_enabled")
		if enable_3d==None:
			enable_3d="True"
		enable_3d=str2bool(enable_3d)
		
		if enable_3d==True:
			self.display=glWidget(self)
			self.hbox.addWidget(self.display)
			self.display.setMinimumSize(800, 600)

			self.timer=QTimer()
			self.timer.setSingleShot(True)
			self.timer.timeout.connect(self.timer_update)
			self.timer.start(2000)
		else:
			self.add_fallback()
			
		self.setLayout(self.hbox)

		self.electrical_mesh=tab_electrical_mesh()
		self.electrical_mesh.changed.connect(self.recalculate)

		self.contacts_window=contacts_window()
		self.contacts_window.changed.connect(self.recalculate)

		self.gl_cmp.slider.changed.connect(self.recalculate)
Exemplo n.º 16
0
def get_distance(tfp_a, tfp_b, main_config = dict()):
    """ get the cosine distance between the two trace files counts """

    verbose = False
    if "verbose" in main_config:
        verbose = util.str2bool(main_config["verbose"])

    vector_a = get_command_counts(tfp_a, verbose)
    vector_b = get_command_counts(tfp_b, verbose)

    return util.cosin_dist(vector_a, vector_b)
Exemplo n.º 17
0
def inp_find_active_file(file_path):
    """if you are looking for /path/to/file/cluster0.inp it will expect /path/to/file/cluster"""
    path = os.path.dirname(file_path)
    root = os.path.basename(file_path)
    files = zip_lsdir(os.path.join(path, "sim.gpvdm"))
    for f in files:
        if inp_issequential_file(f, root) == True:
            ret = str2bool(
                inp_get_token_value(os.path.join(path, f), "#tab_enabled"))
            if ret == True:
                return f
    return False
def get_distance(tfp_a, tfp_b, main_config=dict()):
    verbose = False
    if "verbose" in main_config:
        verbose = util.str2bool(main_config["verbose"])

    output_a = get_output(tfp_a, verbose)
    output_b = get_output(tfp_b, verbose)

    if (output_a == output_b):
        return 0.0

    return 1.0
Exemplo n.º 19
0
 def init(self, sim_dir):
     self.terminate_on_finish = False
     self.mylock = False
     self.cpus = multiprocessing.cpu_count()
     self.jobs = []
     self.status = []
     self.jobs_running = 0
     self.jobs_run = 0
     self.sim_dir = sim_dir
     self.cluster = str2bool(inp_get_token_value("server.inp", "#cluster"))
     self.server_ip = inp_get_token_value("server.inp", "#server_ip")
     self.finished_jobs = []
Exemplo n.º 20
0
    def init(self):
        total = 0
        self.pos = 0
        lines = inp_load_file(lines, "mesh_y.inp")
        if lines != False:
            total = inp_sum_items(lines, "#mesh_layer_points0")

        lines = inp_load_file(lines, "dump.inp")
        if lines != False:
            self.pos = str2bool(
                inp_search_token_value(lines, "#dump_energy_slice_pos"))

        label = gtk.Label("Energy slice dump")
        label.show()
        self.pack_start(label, True, True, 0)

        check = gtk.CheckButton("Enable")
        self.pack_start(check, True, True, 0)

        print("total=", total)
        adj = gtk.Adjustment(self.pos, 0, total, 1.0, 1.0, 1.0)
        adj.connect("value_changed", self.scroll)
        self.vscale = gtk.HScale(adj)
        self.vscale.set_size_request(150, 30)
        self.pack_start(self.vscale, True, True, 0)
        self.vscale.show()

        self.enable = False
        lines = inp_load_file(lines, "dump.inp")
        if lines != False:
            self.enable = str2bool(
                inp_search_token_value(lines, "#dump_energy_slice_switch"))

        check.set_active(self.enable)
        self.vscale.set_sensitive(self.enable)

        check.unset_flags(gtk.CAN_FOCUS)
        check.connect("clicked", self.check_clicked)
Exemplo n.º 21
0
def get_distance(tfp_a, tfp_b, main_config=dict()):
    """ If the timeout status of program A does not equal the timeout status of program B, then these programs are distance 1 apart. Otherwise they are distance 0. """

    verbose = False
    if "verbose" in main_config:
        verbose = util.str2bool(main_config["verbose"])

    timeoutStatus_a = get_timeout_status(tfp_a, verbose)
    timeoutStatus_b = get_timeout_status(tfp_b, verbose)

    if (timeoutStatus_a == timeoutStatus_b):
        return 0.0

    return 1.0
Exemplo n.º 22
0
	def update_contact_db(self):
		for i in range(0,self.tab.rowCount()):
			try:
				float(tab_get_value(self.tab,i, 3))
				float(tab_get_value(self.tab,i, 4))
				float(tab_get_value(self.tab,i, 5))
				float(tab_get_value(self.tab,i, 6))
			except:
				return False

		contacts_clear()
		for i in range(0,self.tab.rowCount()):
			contacts_append(tab_get_value(self.tab,i, 0),tab_get_value(self.tab,i, 1),str2bool(tab_get_value(self.tab,i, 2)),float(tab_get_value(self.tab,i, 3)),float(tab_get_value(self.tab,i, 4)),float(tab_get_value(self.tab,i, 5)),float(tab_get_value(self.tab,i, 6)))
		return True
def get_distance(tfp_a, tfp_b, main_config=dict()):
    """ If the exit status of program A does not equal the exception type of program B, then these programs are distance 1 apart. Otherwise they are distance 0. """

    verbose = False
    if "verbose" in main_config:
        verbose = util.str2bool(main_config["verbose"])

    exception_a = get_exceptionType(tfp_a, verbose)
    exception_b = get_exceptionType(tfp_b, verbose)

    if (exception_a == exception_b):
        return 0.0

    return 1.0
Exemplo n.º 24
0
def main(FLAGS):
    util.VAL_IMAGE_FLAGS = FLAGS

    imagenet_inference_labels = get_imagenet_inference_labels()
    imagenet_training_labels = get_imagenet_training_labels()
    assert (
        sorted(imagenet_training_labels) == sorted(imagenet_inference_labels))
    validation_nums = get_validation_labels(FLAGS)
    x_test = get_validation_images(FLAGS)
    validation_labels = imagenet_inference_labels[validation_nums]

    if FLAGS.batch_size < 10:
        print('validation_labels', validation_labels)

    (batch_size, width, height, channels) = x_test.shape
    print('batch_size', batch_size)
    print('width', width)
    print('height', height)
    print('channels', channels)

    x_test_flat = x_test.flatten(order='C')
    hostname = 'localhost'
    port = 34000

    if 'NGRAPH_COMPLEX_PACK' in os.environ:
        complex_packing = str2bool(os.environ['NGRAPH_COMPLEX_PACK'])
    else:
        complex_packing = False

    client = pyhe_client.HESealClient(FLAGS.hostname, port, batch_size,
                                      x_test_flat, complex_packing)

    while not client.is_done():
        time.sleep(1)
    results = client.get_results()

    imagenet_labels = get_imagenet_labels()
    results = np.array(results)

    if (FLAGS.batch_size == 1):
        top5 = results.argsort()[-5:]
    else:
        results = np.reshape(results, (FLAGS.batch_size, 1001))
        top5 = np.flip(results.argsort()[:, -5:], axis=1)

    preds = imagenet_labels[top5]
    print('validation_labels', validation_labels)
    print('top5', preds)

    util.accuracy(preds, validation_labels)
Exemplo n.º 25
0
    def insert_row(self, pos, thick, points, mul, left_right):

        item = QTableWidgetItem(str(thick))
        self.tab.setItem(pos, 0, item)

        item = QTableWidgetItem(str(points))
        self.tab.setItem(pos, 1, item)

        item = QTableWidgetItem(str(mul))
        self.tab.setItem(pos, 2, item)

        self.item = leftright()
        self.item.set_value(str2bool(left_right))
        self.item.changed.connect(self.tab_changed)
        self.tab.setCellWidget(pos, 3, self.item)
Exemplo n.º 26
0
	def init(self):
		total=0
		self.pos=0
		lines=[]
		if inp_load_file(lines,"mesh.inp")==True:
			total=inp_sum_items(lines, "#mesh_layer_points0")

		if inp_load_file(lines,"dump.inp")==True:
			self.pos=str2bool(inp_search_token_value(lines, "#dump_energy_slice_pos"))


		label=gtk.Label("Energy slice dump")
		label.show()
		self.pack_start(label, True, True, 0)

		check = gtk.CheckButton("Enable")
		self.pack_start(check, True, True, 0)

		print "total=",total
		adj=gtk.Adjustment(self.pos, 0, total, 1.0, 1.0, 1.0)
		adj.connect("value_changed", self.scroll)
		self.vscale = gtk.HScale(adj)
		self.vscale.set_size_request(150, 30)
		self.pack_start(self.vscale, True, True, 0)
		self.vscale.show()


		self.enable=False
		if inp_load_file(lines,"dump.inp")==True:
			self.enable=str2bool(inp_search_token_value(lines, "#dump_energy_slice_switch"))

		check.set_active(self.enable)
		self.vscale.set_sensitive(self.enable)

		check.unset_flags(gtk.CAN_FOCUS)
		check.connect("clicked", self.check_clicked)
Exemplo n.º 27
0
	def cal_state(self):
		val=False
		for token in self.tokens:
			v=inp_get_token_value(os.path.join(get_sim_path(),"dump.inp"), token )
			if v==None:
				return None
			val = val + int(str2bool(v))

		if val==len(self.tokens):
			return dump_slow
		
		if val==0:
			return dump_fast

		return dump_custom
Exemplo n.º 28
0
def QIcon_load(name, size=-1):
    global use_theme
    if use_theme == None:
        use_theme = inp_get_token_value(
            os.path.join(os.getcwd(), "config.inp"), "#gui_use_icon_theme")
        if use_theme == None:
            use_theme = False
        else:
            use_theme = str2bool(use_theme)

    if running_on_linux() == True and use_theme == True:
        image = QIcon()
        if image.hasThemeIcon(name) == True:
            return image.fromTheme(name)

    return QIcon(get_icon_path(name, size=size))
Exemplo n.º 29
0
def plot_load_oplot_file(plot_token, file_name):
    lines = []
    if inp_load_file(lines, file_name) == True:
        plot_token.logy = str2bool(inp_search_token_value(lines, "#logy"))
        plot_token.logx = str2bool(inp_search_token_value(lines, "#logx"))
        plot_token.grid = str2bool(inp_search_token_value(lines, "#grid"))
        plot_token.invert_y = str2bool(inp_search_token_value(lines, "#invert_y"))
        plot_token.normalize = str2bool(inp_search_token_value(lines, "#normalize"))
        plot_token.norm_to_peak_of_all_data = str2bool(inp_search_token_value(lines, "#norm_to_peak_of_all_data"))
        plot_token.subtract_first_point = str2bool(inp_search_token_value(lines, "#subtract_first_point"))
        plot_token.add_min = str2bool(inp_search_token_value(lines, "#add_min"))
        plot_token.file0 = inp_search_token_value(lines, "#file0")
        plot_token.file1 = inp_search_token_value(lines, "#file1")
        plot_token.file2 = inp_search_token_value(lines, "#file2")
        plot_token.tag0 = inp_search_token_value(lines, "#tag0")
        plot_token.tag1 = inp_search_token_value(lines, "#tag1")
        plot_token.tag2 = inp_search_token_value(lines, "#tag2")
        plot_token.legend_pos = inp_search_token_value(lines, "#legend_pos")
        plot_token.key_units = inp_search_token_value(lines, "#key_units")
        plot_token.label_data = str2bool(inp_search_token_value(lines, "#label_data"))
        plot_token.type = inp_search_token_value(lines, "#type")
        plot_token.x_label = inp_search_token_value(lines, "#x_label")
        plot_token.y_label = inp_search_token_value(lines, "#y_label")
        plot_token.x_units = inp_search_token_value(lines, "#x_units")
        plot_token.y_units = inp_search_token_value(lines, "#y_units")
        plot_token.x_mul = float(inp_search_token_value(lines, "#x_mul"))
        plot_token.y_mul = float(inp_search_token_value(lines, "#y_mul"))
        plot_token.key_units = inp_search_token_value(lines, "#key_units")
        plot_token.x_start = float(inp_search_token_value(lines, "#x_start"))
        plot_token.x_stop = float(inp_search_token_value(lines, "#x_stop"))
        plot_token.x_points = float(inp_search_token_value(lines, "#x_points"))
        plot_token.y_start = float(inp_search_token_value(lines, "#y_start"))
        plot_token.y_stop = float(inp_search_token_value(lines, "#y_stop"))
        plot_token.y_points = float(inp_search_token_value(lines, "#y_points"))
        plot_token.time = float(inp_search_token_value(lines, "#time"))
        plot_token.Vexternal = float(inp_search_token_value(lines, "#Vexternal"))

        return True
    return False
Exemplo n.º 30
0
    def set_assumption(self, key, value):
        if value is None or value == '':
            return

        if key.startswith("include_"):
            if isinstance(value, int):
                self.__setattr__(key, value != 0)
            else:
                try:
                    self.__setattr__(key, str2bool(value))
                except AttributeError:
                    self.__setattr__(key, value)
        else:
            try:
                self.__setattr__(key, float(value))
            except (ValueError, TypeError):
                self.__setattr__(key, value)
Exemplo n.º 31
0
def contacts_load():
	global store
	store=[]
	lines=[]
	pos=0
	if inp_load_file(lines,os.path.join(os.getcwd(),"contacts.inp"))==True:
		pos=pos+1	#first comment
		layers=int(lines[pos])

		for i in range(0, layers):
			#start
			pos=pos+1					#token
			token=lines[pos]

			pos=pos+1
			start=lines[pos]			#read value

			#width
			pos=pos+1					#token
			token=lines[pos]

			pos=pos+1
			width=lines[pos]			#read value

			#depth
			pos=pos+1					#token
			token=lines[pos]

			pos=pos+1
			depth=lines[pos]			#read value

			#voltage
			pos=pos+1					#token
			token=lines[pos]

			pos=pos+1
			voltage=lines[pos]			#read value

			#active
			pos=pos+1					#token
			token=lines[pos]
			
			pos=pos+1
			active=lines[pos]			#read value
			
			contacts_append(float(start),float(depth),float(voltage),float(width),str2bool(active))
Exemplo n.º 32
0
def tree_load_program(program_list, sim_dir):
    file_name = os.path.join(sim_dir, "opvdm_gui_config.inp")

    if os.path.isfile(file_name) == True:
        f = open(file_name)
        config = f.readlines()
        f.close()

        for ii in range(0, len(config)):
            config[ii] = config[ii].rstrip()

        pos = 0
        mylen = int(config[0])
        pos = pos + 1

        for i in range(0, mylen):
            program_list.append([config[pos], config[pos + 1], config[pos + 2], str2bool(config[pos + 3])])
            pos = pos + 4
Exemplo n.º 33
0
def getDistance(javaFileA, javaFileB, mainConfig):
    verbose = False
    if (util.str2bool(mainConfig['verbose'])):
        verbose = True

    lineCountA = fileLineCount(javaFileA, verbose)
    lineCountB = fileLineCount(javaFileB, verbose)
    distance = abs(lineCountA - lineCountB)

    if (distance < 0 and verbose):
        print("There was a problem calculating line distance between " +
              str(javaFileA) + " and " + str(javaFileB) +
              ". Negative one was outputted as a distance.")

    if (verbose):
        print("Distance: " + str(distance))

    return distance
Exemplo n.º 34
0
    def load_tabs(self):

        file_list = zip_lsdir(os.path.join(get_sim_path(), "sim.gpvdm"))
        files = []
        for i in range(0, len(file_list)):
            if file_list[i].startswith("fit") and file_list[i].endswith(
                    ".inp"):
                num = file_list[i][3:-4]
                if num.isdigit() == True:
                    files.append(file_list[i])

        for i in range(0, len(files)):
            value = strextract_interger(files[i])
            if value != -1:
                token = inp_get_token_value(
                    os.path.join(get_sim_path(), files[i]), "#fit_hidden")
                if str2bool(token) == False:
                    self.add_page(value)

        self.fit_progress = fit_progress()
        self.notebook.addTab(self.fit_progress, "Fit progress")
Exemplo n.º 35
0
def tab_set_value(tab, y, x, value):
    if type(tab.cellWidget(y, x)) == QComboBox:
        tab.cellWidget(y, x).blockSignals(True)
        tab.cellWidget(y, x).setCurrentIndex(
            tab.cellWidget(y, x).findText(value))
        tab.cellWidget(y, x).blockSignals(False)
    elif type(tab.cellWidget(y, x)) == QComboBoxLang:
        tab.cellWidget(y, x).blockSignals(True)
        tab.cellWidget(y, x).setValue_using_english(value)
        tab.cellWidget(y, x).blockSignals(False)
    elif type(tab.cellWidget(y, x)) == gpvdm_select:
        tab.cellWidget(y, x).blockSignals(True)
        tab.cellWidget(y, x).setText(value)
        tab.cellWidget(y, x).blockSignals(False)
    elif type(tab.cellWidget(y, x)) == gtkswitch:
        tab.cellWidget(y, x).blockSignals(True)
        tab.cellWidget(y, x).set_value(str2bool(value))
        tab.cellWidget(y, x).blockSignals(False)
    else:
        item = QTableWidgetItem(str(value))
        tab.setItem(y, x, item)
Exemplo n.º 36
0
def cp_devices(dest,src):
	src=os.path.join(src,"device_lib")
	dest=os.path.join(dest,"device_lib")

	if not os.path.exists(dest):
		os.makedirs(dest)

	for dirpath, dirnames, files in os.walk(src):
		for name in files:
			if name.endswith(".gpvdm")==True:
				src_file=os.path.join(dirpath, name)
				dst_file=os.path.join(dest,subtract_paths(src,src_file))
				dst_dir=os.path.dirname(dst_file)

				private=inp_get_token_value(os.path.join(os.path.dirname(src_file),"info.inp"), "#private",archive=os.path.basename(src_file))

				if private!=None:
					if str2bool(private)==False:
						if os.path.isdir(dst_dir)==False:
							os.makedirs(dst_dir)
						shutil.copyfile(src_file,dst_file)
Exemplo n.º 37
0
def main():
    spinner = yaspin(Spinners.shark,
                     text="Searching the market sea for data...")
    spinner.start()
    if args.nasdaq:
        csv_file = args.nasdaq[0]
    else:
        spinner.stop()
        print("You need to pass --nasdaq <PATH TO DOWNLOADED NASDAQ CSV>")
        sys.exit(2)
    if args.output_folder:
        if isinstance(args.output_folder, list):
            output_folder = args.output_folder[0]
        else:
            output_folder = args.output_folder
    time.sleep(2)
    findance = FinDance(csv_file=csv_file, output_folder_path=output_folder)
    if not str2bool(args.handle_all_symbols):
        ## Only handle one symbol
        if args.symbol:
            symbol = args.symbol[0]
            spinner.text = f"Collecting data locally for symbol {symbol}..."
            findance.store_symbol_ticker_data(symbol)
            spinner.text = f"Writing data to {output_folder}..."
            findance.write_symbol_ticker_data(symbol)
        else:
            spinner.stop()
            print(
                "You must pass either --symbol <NASDAQ SYMBOL> or --handle-all-symbols"
            )
            sys.exit(2)
    else:
        spinner.text = f"Collecting data locally for all symbols in {csv_file}..."
        findance.store_all_symbols_ticker_data()
        spinner.text = f"Writing data to {output_folder} for all symbols in {csv_file}..."
        findance.write_all_symbol_ticker_data()
    spinner.stop()
Exemplo n.º 38
0
    def from_file(self):
        param_list = []
        true_false_list = []
        lines = inp_load_file("dump_file.inp")

        if lines != False:
            pos = 0
            while (1):
                token = lines[pos]
                pos = pos + 1

                if token == "#ver":
                    break

                file_name = lines[pos]
                pos = pos + 1

                true_false = lines[pos]
                pos = pos + 1

                true_false_list.append(str2bool(true_false))
                param_list.append(file_name)

        return param_list, true_false_list
Exemplo n.º 39
0
def create(request, id):
	success = True
	result = {}
	error = ''
	status_code = 200

	if request is None:
		success = False
		error = "Bad request.  Somehow the request wasn't found."
		status_code = 400

	if id is None:
		success = False
		error = "Bad request.  Somehow the id wasn't found."
		status_code = 400

	# handle type, name, and multi parameters in request
	resource_type = request.args.get('type')
	resource_name = request.args.get('name')
	multi = util.str2bool(request.args.get('multi'))

	# handle multiple resources
	if multi is True:
		# TODO
		pass

	if resource_type == "url":
		# create a url type resource

		if 'application/json' in request.headers['content-type']:
			# create the content object

			json_data = ''

			try:
				json_data = request.json
			except Exception as e:
				success = False
				error = str(e)
				status_code = 400

			try:
				crud_helpers.create_url_resource(id, json_data, resource_name)
				
			except HelperException as e:
				success = False
				error = e.error
				status_code = e.status_code
		else:
			success = False
			error = "The content-type was not of the expected type.  The content-type found was " + request.headers["content-type"] + ", whereas the content-type expected was application/json."
			status_code = 400

	else:
		success = False
		error = "The resource type was not understood.  The specified value for resource type was " + str(resource_type) + "."
		status_code = 400		

	if success is True:
		response = createJsonResponse(result, status_code)
	else:
		result['error'] = error
		response = createJsonResponse(result, status_code)
	
	return response
Exemplo n.º 40
0
def contacts_load():
    global store
    store = []
    lines = []
    pos = 0
    lines = inp_load_file(os.path.join(get_sim_path(), "contacts.inp"))
    if lines != False:
        pos = pos + 1  #first comment
        layers = int(lines[pos])

        for i in range(0, layers):
            #name
            pos = pos + 1  #token
            token = lines[pos]

            pos = pos + 1
            name = lines[pos]  #read value

            #position
            pos = pos + 1  #token
            token = lines[pos]

            pos = pos + 1
            position = lines[pos]  #read value

            #active
            pos = pos + 1  #token
            token = lines[pos]

            pos = pos + 1
            active = lines[pos]  #read value

            #start
            pos = pos + 1  #token
            token = lines[pos]

            pos = pos + 1
            start = lines[pos]  #read value

            #width
            pos = pos + 1  #token
            token = lines[pos]

            pos = pos + 1
            width = lines[pos]  #read value

            #depth
            pos = pos + 1  #token
            token = lines[pos]

            pos = pos + 1
            depth = lines[pos]  #read value

            #voltage
            pos = pos + 1  #token
            token = lines[pos]

            pos = pos + 1
            voltage = lines[pos]  #read value

            contacts_append(name, position, str2bool(active), float(start),
                            float(width), float(depth), float(voltage))
Exemplo n.º 41
0
Arquivo: gl.py Projeto: mandulaj/gpvdm
		def render(self):
			#print("do draw")
			clear_color()
			glClearColor(self.view.bg_color[0], self.view.bg_color[1], self.view.bg_color[2], 0.5)
			gl_save_clear()


			dos_start=-1
			dos_stop=-1
			epi_y_len=epitaxy_get_y_len()
			
			if epi_y_len<=0:
				return

			self.x_mul=1e3
			self.y_mul=self.gl_device_height/epi_y_len
			self.z_mul=1e3


			x_len=mesh_get_xlen()

			max_gui_device_x=x_len*self.x_mul
			max_gui_device_y=1.0
			max_gui_device_z=mesh_get_zlen()*self.z_mul

			l=epitaxy_get_layers()-1

			xpoints=int(mesh_get_xpoints())
			ypoints=int(mesh_get_ypoints())
			zpoints=int(mesh_get_zpoints())

			if ypoints>10:
				ypoints=10
			
			if xpoints>10:
				xpoints=10
				
			if ypoints>10:
				ypoints=10

			self.emission=False
			self.ray_model=False
			
			lines=inp_load_file(os.path.join(get_sim_path(),"led.inp"))
			if lines!=False:
				self.ray_model=val=str2bool(inp_search_token_value(lines, "#led_on"))
				
			lines=[]

			for i in range(0,epitaxy_get_layers()):
				if epitaxy_get_pl_file(i)!="none":
					lines=inp_load_file(os.path.join(get_sim_path(),epitaxy_get_pl_file(i)+".inp"))
					if lines!=False:
						if str2bool(lines[1])==True:
							self.emission=True
					
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
			glLoadIdentity()

			glTranslatef(self.view.x_pos, self.view.y_pos, self.view.zoom) # Move Into The Screen
			
			glRotatef(self.view.xRot, 1.0, 0.0, 0.0)
			glRotatef(self.view.yRot, 0.0, 1.0, 0.0)
			glRotatef(self.view.zRot, 0.0, 0.0, 1.0)

			glColor3f( 1.0, 1.5, 0.0 )
			glPolygonMode(GL_FRONT, GL_FILL);

			threed_files=glob.glob("*.3d")
			if len(threed_files)>0:
				gl_save_load()
				gl_save_draw()
				draw_grid()
				return

			#glClearColor(0.92, 0.92, 0.92, 0.5) # Clear to black.

			lines=[]

			pos=0.0
				
			for i in range(0,epitaxy_get_layers()):

				thick=epitaxy_get_width(l-i)*self.y_mul
				obj=epitaxy_get_layer(l-i)
				red=obj.r
				green=obj.g
				blue=obj.b
				alpha=obj.alpha
				if i==l-self.selected_layer:
					box_lines(0.0,pos,0,max_gui_device_x,thick,max_gui_device_z)

				if epitaxy_get_electrical_layer(l-i).startswith("dos")==True and ypoints!=0 and xpoints!=0 and zpoints!=0:
					dy=thick/float(ypoints)
					dx=max_gui_device_x/float(xpoints)
					dz=max_gui_device_z/float(zpoints)
					xshrink=0.8
					zshrink=0.8
					
					if dos_start==-1:
						dos_start=pos
					
					dos_stop=pos+thick
			
					if xpoints==1:
						xshrink=1.0

					if zpoints==1:
						zshrink=1.0

					if xpoints==1 and zpoints==1:
						box(0.0,pos,0,max_gui_device_x,thick,max_gui_device_z,red,green,blue,alpha)
					else:
						for y in range(0,ypoints):
							for x in range(0,xpoints):
								for z in range(0,zpoints):
									box(dx*x,pos+y*(dy),z*dz,dx*xshrink,dy*0.8,dz*zshrink,red,green,blue,alpha)
					if self.tab_active_layers==True:
						tab(0.0,pos,max_gui_device_z,max_gui_device_x,thick,max_gui_device_z)
				
				elif epitaxy_get_electrical_layer(l-i).lower()=="contact" and (i==l or i==0):
					for c in contacts_get_array():
						if (c.position=="top" and i==l) or (c.position=="bottom" and i==0):
							if xpoints==1 and zpoints==1:
								xstart=0.0
								xwidth=max_gui_device_x
							else:
								xstart=max_gui_device_x*(c.start/x_len)
								xwidth=max_gui_device_x*(c.width/x_len)
								#print("contacts",xstart,xwidth,c.width,x_len)
								if (c.start+c.width)>x_len:
									xwidth=max_gui_device_x-xstart
								
							if c.depth>0.0:
								etch_depth=c.depth*self.y_mul
								if c.position=="top":
									box(xstart,pos-etch_depth-self.dy_layer_offset,0,xwidth,etch_depth,max_gui_device_z,0.0,0.0,1.0,1.0)
								else:
									box(xstart,pos+self.dy_layer_offset+thick,0,xwidth,etch_depth,max_gui_device_z,0.0,0.0,1.0,1.0)
									
							if c.active==True:
								box(xstart,pos,0,xwidth,thick,max_gui_device_z,0.0,1.0,0.0,alpha)
							else:
								box(xstart,pos,0,xwidth,thick,max_gui_device_z,red,green,blue,alpha)


				else:
					box(0.0,pos,0,max_gui_device_x,thick,max_gui_device_z,red,green,blue,alpha)
				

				if self.view.render_text==True:
					if epitaxy_get_electrical_layer(l-i).startswith("dos")==True:
						text=epitaxy_get_name(l-i)+" ("+_("active")+")"
					else:
						text=epitaxy_get_name(l-i)

					set_color(1.0,1.0,1.0,"text")

					font = QFont("Arial")
					font.setPointSize(18)
					if self.view.zoom>-20:
						self.renderText (max_gui_device_x+0.1,pos+thick/2,max_gui_device_z, text,font)

				pos=pos+thick+self.dy_layer_offset

			draw_mode(pos-self.dy_layer_offset,max_gui_device_z)
			draw_rays(self.ray_file,pos-self.dy_layer_offset,max_gui_device_x,self.y_mul,max_gui_device_z*1.05)
			#print(self.graph_path)

			if self.view.render_photons==True:
				#print(pos)
				self.draw_photons(max_gui_device_x,pos,max_gui_device_z)

			full_data_range=self.graph_z_max-self.graph_z_min
			graph(0.0,dos_start,max_gui_device_z+0.5,max_gui_device_x,dos_stop-dos_start,full_data_range,self.graph_data)

			if self.view.render_grid==True:
				draw_grid()

			if self.view.zoom<-60:
				draw_stars()
Exemplo n.º 42
0
    def init(self, filename, tab_name):
        self.vbox = QVBoxLayout()
        self.file_name = filename
        self.tab_name = tab_name

        self.tab = QGridLayout()
        widget = QWidget()
        widget.setLayout(self.tab)
        self.vbox.addWidget(widget)

        scan_remove_file(filename)

        self.edit_list = []
        inp_load_file(self.lines, filename)

        n = 0
        pos = 0
        my_token_lib = tokens()
        height = 27
        widget_number = 0
        while pos < len(self.lines):
            token = self.lines[pos]
            if token == "#ver":
                break

            if token == "#end":
                break

            if token.startswith("#"):
                show = False
                units = "Units"

                pos = pos + 1
                value = self.lines[pos]

                result = my_token_lib.find(token)
                if result != False:
                    units = result.units
                    text_info = result.info
                    show = True

                    # self.set_size_request(600,-1)
                if show == True:
                    description = QLabel()
                    description.setText(latex_to_html(text_info))

                    if result.opt[0] == "switch":
                        edit_box = gtkswitch()
                        edit_box.set_value(str2bool(value))
                        edit_box.changed.connect(functools.partial(self.callback_edit, filename, token, edit_box))
                    elif result.opt[0] == "leftright":
                        edit_box = leftright()
                        edit_box.set_value(str2bool(value))
                        edit_box.changed.connect(functools.partial(self.callback_edit, filename, token, edit_box))
                    elif result.opt[0] == "text":
                        edit_box = QLineEdit()
                        if self.editable == False:
                            edit_box.setReadOnly(True)
                        edit_box.setText(value)
                        # edit_box.set_text(self.lines[pos]);
                        edit_box.textChanged.connect(functools.partial(self.callback_edit, filename, token, edit_box))
                        # edit_box.show()
                    else:
                        edit_box = QComboBox()
                        for i in range(0, len(result.opt)):
                            edit_box.addItem(result.opt[i])

                        all_items = [edit_box.itemText(i) for i in range(edit_box.count())]
                        for i in range(0, len(all_items)):
                            if all_items[i] == token:
                                edit_box.setCurrentIndex(i)

                        edit_box.currentIndexChanged.connect(
                            functools.partial(self.callback_edit, filename, token, edit_box)
                        )

                    edit_box.setFixedSize(300, 25)
                    unit = QLabel()
                    unit.setText(latex_to_html(units))

                    self.tab.addWidget(description, widget_number, 0)
                    self.tab.addWidget(edit_box, widget_number, 1)
                    self.tab.addWidget(unit, widget_number, 2)

                    scan_item_add(filename, token, text_info, 1)

                    widget_number = widget_number + 1
            pos = pos + 1

        spacer = QWidget()
        spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.vbox.addWidget(spacer)

        self.setLayout(self.vbox)
Exemplo n.º 43
0
	def init(self,filename,fullname):
		scan_remove_file(filename)
		self.widget_type=[]
		self.file_name=filename
		self.edit_list=[]
		self.line_number=[]
		inp_load_file(self.lines,filename)

		n=0
		pos=0
		my_token_lib=tokens()
		height=27
		for i in range(0, len(self.lines)/2):

			show=False
			units="Units"
			token=self.lines[pos]
			result=my_token_lib.find(token)
			if result!=False:
				units=result.units
				text_info=result.info
				show=True
			pos=pos+1
			self.set_size_request(600,-1)
			if show == True :
				hbox=gtk.HBox()
				hbox.show()
				label = gtk.Label()
				label.set_size_request(400,height)
				label.set_markup(latex_to_pygtk_subscript(text_info))
				label.set_use_markup(True)
				hbox.pack_start(label, False, False, padding=1)
				label.show()

				self.line_number.append(pos)

				if result.opt[0]=="text":
					edit_box=gtk.Entry(max=0)
					edit_box.set_text(self.lines[pos]);
					edit_box.connect("changed", self.callback_edit, token)
					edit_box.show()
					self.widget_type.append("edit")
				else:
					edit_box=gtk.combo_box_new_text()
					index=0
					true_false=False
					if len(result.opt)==2:
						if result.opt[0]==_("true") and result.opt[1]==_("false"):
							true_false=True

					for i in range(0,len(result.opt)):
						edit_box.append_text(result.opt[i])
						if true_false==False:
							if yes_no(self.lines[pos])==yes_no(result.opt[i]):
								index=i
						else:
							if str2bool(self.lines[pos])==True:
								index=0
							else:
								index=1

					edit_box.set_active(index);
					
					edit_box.connect("changed", self.callback_edit, token)
					edit_box.show()
					self.widget_type.append("combo")
				edit_box.set_size_request(300,height)
				self.edit_list.append(edit_box)
				hbox.pack_start(edit_box, False, False, padding=1)

				label = gtk.Label()
				label.set_markup(latex_to_pygtk_subscript(units))
				label.set_use_markup(True)
				label.set_size_request(200,height)
				label.show()
				hbox.pack_start(label, False, False, padding=1)
				label.show()
				self.pack_start(hbox, False, False, padding=1)
				#self.add()
				line=1
				scan_item_add(filename,token,text_info,line)
				
				n=n+1

			pos=pos+1
Exemplo n.º 44
0
    def drawWidget(self, qp):
        font = QFont("Sans", 11, QFont.Normal)
        qp.setFont(font)

        emission = False
        lines = []
        for i in range(0, epitaxy_get_layers()):
            if epitaxy_get_pl_file(i) != "none":
                if inp_load_file(lines, epitaxy_get_pl_file(i) + ".inp") == True:
                    if str2bool(lines[1]) == True:
                        emission = True

        tot = 0
        for i in range(0, epitaxy_get_layers()):
            tot = tot + epitaxy_get_width(i)

        pos = 0.0
        l = epitaxy_get_layers() - 1
        lines = []

        for i in range(0, epitaxy_get_layers()):
            thick = 200.0 * epitaxy_get_width(l - i) / tot
            pos = pos + thick
            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:
                print("Could not load", path)
                red = 0.0
                green = 0.0
                blue = 0.0

            self.draw_box(qp, 200, 450.0 - pos, thick * 0.9, red, green, blue, l - i)
        step = 50.0

        lines = []
        if inp_load_file(lines, os.path.join(os.getcwd(), "light.inp")) == True:
            self.sun = float(inp_search_token_value(lines, "#Psun"))

        if self.sun <= 0.01:
            step = 200
        elif self.sun <= 0.1:
            step = 100
        elif self.sun <= 1.0:
            step = 50
        elif self.sun <= 10.0:
            step = 10
        else:
            step = 5.0
        if self.sun != 0:
            for x in range(0, 200, step):
                self.draw_photon(qp, 210 + x, 100, False)

        if emission == True:
            for x in range(0, 200, 50):
                self.draw_photon(qp, 240 + x, 140, True)

        self.draw_mode(qp, 200, 250)
        qp.drawText(40, 540 + 40, "No OpenGL support, using 2D fallback mode")
Exemplo n.º 45
0
	def update_contact_db(self):
		for i in range(0,self.tab.rowCount()):
			try:
				float(tab_get_value(self.tab,i, 0))
				float(tab_get_value(self.tab,i, 2))
				float(tab_get_value(self.tab,i, 3))
				float(tab_get_value(self.tab,i, 1))
			except:
				return False

		contacts_clear()
		for i in range(0,self.tab.rowCount()):
			contacts_append(float(tab_get_value(self.tab,i, 0)),float(tab_get_value(self.tab,i, 2)),float(tab_get_value(self.tab,i, 3)),float(tab_get_value(self.tab,i, 1)),str2bool(tab_get_value(self.tab,i, 4)))	
		return True
Exemplo n.º 46
0
		def paintGL(self):
			if self.failed==False:
				dos_start=-1
				dos_stop=-1
				self.x_mul=1e3
				self.z_mul=1e3

				width=mesh_get_xlen()*self.x_mul
				depth=mesh_get_zlen()*self.z_mul

				l=epitaxy_get_layers()-1

				xpoints=int(mesh_get_xpoints())
				ypoints=int(mesh_get_ypoints())
				zpoints=int(mesh_get_zpoints())

				x_len=mesh_get_xlen()

				self.emission=False
				self.ray_model=False
				
				lines=[]
				if inp_load_file(lines,"led.inp")==True:
					self.ray_model=val=str2bool(inp_search_token_value(lines, "#led_on"))
					
				lines=[]

				for i in range(0,epitaxy_get_layers()):
					if epitaxy_get_pl_file(i)!="none":
						if inp_load_file(lines,epitaxy_get_pl_file(i)+".inp")==True:
							if str2bool(lines[1])==True:
								self.emission=True
						
				glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
				glLoadIdentity()

				glTranslatef(self.x_pos, self.y_pos, self.zoom) # Move Into The Screen
				
				glRotatef(self.xRot, 1.0, 0.0, 0.0)
				glRotatef(self.yRot, 0.0, 1.0, 0.0)
				glRotatef(self.zRot, 0.0, 0.0, 1.0)

				glColor3f( 1.0, 1.5, 0.0 )
				glPolygonMode(GL_FRONT, GL_FILL);


				#glClearColor(0.92, 0.92, 0.92, 0.5) # Clear to black.
				glClearColor(0.0, 0.0, 0.0, 0.5)
				lines=[]


				if self.suns!=0:
					if self.suns<=0.01:
						den=1.4
					elif self.suns<=0.1:
						den=0.8
					elif self.suns<=1.0:
						den=0.6
					elif self.suns<=10.0:
						den=0.3
					else:
						den=0.2
				
					x=np.arange(0, width , den)
					z=np.arange(0, depth , den)
					for i in range(0,len(x)):
						for ii in range(0,len(z)):
							draw_photon(x[i],z[ii],False)

				if self.emission==True and self.ray_model==False:
					den=0.6
					x=np.arange(0, width , den)
					y=np.arange(0, depth , den)
					for i in range(0,len(x)):
						for ii in range(0,len(y)):
								draw_photon(x[i]+0.1,y[ii]+0.1,True)


				tot=0

				for i in range(0,epitaxy_get_layers()):
					tot=tot+epitaxy_get_width(i)

				pos=0.0
				self.y_mul=0
				if tot>0:
					self.y_mul=1.5/tot
					
					for i in range(0,epitaxy_get_layers()):

						thick=epitaxy_get_width(l-i)*self.y_mul

						red=self.colors[l-i].r
						green=self.colors[l-i].g
						blue=self.colors[l-i].b

						if i==l-self.selected_layer:
							box_lines(0.0,pos,0,width,thick,depth)

						if epitaxy_get_electrical_layer(l-i).startswith("dos")==True:
							dy=thick/float(ypoints)
							dx=width/float(xpoints)
							dz=depth/float(zpoints)
							xshrink=0.8
							zshrink=0.8
							
							if dos_start==-1:
								dos_start=pos
							
							dos_stop=pos+thick
					
							if xpoints==1:
								xshrink=1.0

							if zpoints==1:
								zshrink=1.0

							if xpoints==1 and zpoints==1:
								box(0.0,pos,0,width,thick,depth,red,green,blue)
							else:
								for y in range(0,ypoints):
									for x in range(0,xpoints):
										for z in range(0,zpoints):
											box(dx*x,pos+y*(dy),z*dz,dx*xshrink,dy*0.8,dz*zshrink,red,green,blue)
							tab(0.0,pos,depth,width,thick,depth)
						
						elif epitaxy_get_electrical_layer(l-i).lower()=="contact" and i==l:
							if xpoints==1 and zpoints==1:
								box(0.0,pos,0,width,thick,depth,red,green,blue)
							else:
								for c in contacts_get_array():
									xstart=width*(c.start/x_len)
									xwidth=width*(c.width/x_len)
									#print("contacts",xstart,xwidth,c.width,x_len)
									if (c.start+c.width)>x_len:
										xwidth=width-xstart
									if c.active==True:
										box(xstart,pos,0,xwidth,thick,depth,0.0,1.0,0.0)
									else:
										box(xstart,pos,0,xwidth,thick,depth,red,green,blue)


						else:
							box(0.0,pos,0,width,thick,depth,red,green,blue)
						

						if epitaxy_get_electrical_layer(l-i).startswith("dos")==True:
							text=epitaxy_get_name(l-i)+" (active)"
						else:
							text=epitaxy_get_name(l-i)

						glColor3f(1.0,1.0,1.0)
						font = QFont("Arial")
						font.setPointSize(18)
						if self.zoom>-20:
							self.renderText (width+0.1,pos+thick/2,depth, text,font)

						pos=pos+thick+0.05


				
						glRotatef(self.tet_rotate, tet_x_rate, tet_y_rate, tet_z_rate)

				draw_mode(pos-0.05,depth)
				draw_rays(self.ray_fast,pos-0.05,width,self.y_mul,depth*1.05)
				#print(self.graph_path)

				full_data_range=self.graph_z_max-self.graph_z_min
				graph(0.0,dos_start,depth+0.5,width,dos_stop-dos_start,full_data_range,self.graph_data)
				draw_grid()
				if self.zoom<-60:
					draw_stars()