コード例 #1
0
ファイル: gpvdm_open.py プロジェクト: roderickmackenzie/gpvdm
	def on_selection_changed(self,item):
		if type(item)!=None:
			file_name=item.text()
			print(file_name)
			full_path=os.path.join(self.dir, file_name)
			if (file_name.endswith(".dat")==True):
				state=plot_state()
				get_plot_file_info(state,full_path)
				summary="<big><b>"+file_name+"</b></big><br>"+_("<br>title: ")+state.title+_("<br>x axis: ")+state.x_label+" ("+latex_to_html(state.x_units)+_(")<br>y axis: ")+state.y_label+" ("+latex_to_html(state.y_units)+_(")<br><br><big><b>Double click to open</b></big>")
				help_window().help_set_help(["dat_file.png",summary])

			if file_name.endswith("equilibrium"):
				state=plot_state()
				get_plot_file_info(state,full_path)
				summary="<big><b>equilibrium</b></big><br>"+_("<br>This contains the simulation output at 0V in the dark.")
				help_window().help_set_help(["dir_file.png",summary])
コード例 #2
0
ファイル: scan_tab.py プロジェクト: roderickmackenzie/gpvdm
	def callback_gen_plot_command(self):
		dialog=gpvdm_open(self.sim_dir)
		ret=dialog.window.exec_()

		if ret==QDialog.Accepted:
			full_file_name=dialog.get_filename()
			#dialog.destroy()
			#print cur_dir=os.getcwd()
			#print full_file_name
			file_name=os.path.basename(full_file_name)

			plot_data=plot_state()
			plot_data.path=self.sim_dir
			plot_data.example_file0=full_file_name
			plot_data.example_file1=full_file_name

			plot_now=False
			if check_info_file(file_name)==True:
				plot_data.file0=file_name
				plot_xy_window=plot_dlg_class(plot_data)
				plot_xy_window.run()
				plot_now=plot_xy_window.ret
			else:
				plot_data.file0=file_name
				plot_data.tag0=""
				plot_data.file1=""
				plot_data.tag1=""
				plot_now=True

			if plot_now==True:
				self.plot_results(plot_data)
コード例 #3
0
ファイル: scan_tab.py プロジェクト: roderickmackenzie/opvdm
	def callback_gen_plot_command(self, widget, data=None):
		#dialog = gtk.FileChooserDialog("File to plot",
        #       None,
        #       gtk.FILE_CHOOSER_ACTION_OPEN,
        #       (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
        #        gtk.STOCK_OPEN, gtk.RESPONSE_OK))
		#dialog.set_default_response(gtk.RESPONSE_OK)
		#dialog.set_current_folder(self.sim_dir)
		#filter = gtk.FileFilter()
		#filter.set_name("Data files")
		#filter.add_pattern("*.dat")
		#dialog.add_filter(filter)

		#filter = gtk.FileFilter()
		#filter.set_name("Input files")
		#filter.add_pattern("*.inp")
		#dialog.add_filter(filter)

		#dialog.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)


		#response = dialog.run()
		dialog=opvdm_open()
		dialog.init(self.sim_dir)
		response=dialog.run()

		if response == True:
			full_file_name=dialog.get_filename()
			dialog.destroy()
			#print cur_dir=os.getcwd()
			#print full_file_name
			file_name=os.path.basename(full_file_name)

			plot_data=plot_state()
			plot_data.path=self.sim_dir
			plot_data.example_file0=full_file_name
			plot_data.example_file1=full_file_name

			plot_now=False
			if check_info_file(file_name)==True:
				plot_data.file0=file_name
				plot_xy_window=plot_dlg_class(gtk.WINDOW_TOPLEVEL)
				plot_xy_window.my_init(plot_data)
				plot_now=plot_xy_window.my_run(plot_data)
			else:
				plot_data.file0=file_name
				plot_data.tag0=""
				plot_data.file1=""
				plot_data.tag1=""
				plot_now=True

			if plot_now==True:
				self.plot_results(plot_data)

				self.plotted_graphs.refresh()

		else:
			print _("Closed, no files selected")
			dialog.destroy()
コード例 #4
0
	def append(self,file_name):
		plot_token=plot_state()
		if plot_load_info(plot_token,file_name)==True:
			menu_item = gtk.MenuItem(os.path.basename(file_name).split(".")[0])
			self.menu.append(menu_item)
			self.list.append(plot_token)
			menu_item.connect("activate", self.callback,self.list[len(self.list)-1])
			menu_item.show()
コード例 #5
0
ファイル: opvdm_open.py プロジェクト: roderickmackenzie/opvdm
	def on_selection_changed(self, widget):
		selected=self.icon_view.get_selected_items()
		if len(selected)!=0:
			icon_pos=selected[0][0]
			icon_name=self.store[icon_pos][0]
			icon_type=self.store[icon_pos][COL_IS_DIRECTORY]
			full_path=os.path.join(self.dir,icon_name)
			if icon_type=="dat":
				state=plot_state()
				get_plot_file_info(state,full_path)
				summary="<big><b>"+self.store[icon_pos][0]+"</b></big>\n"+_("\ntitle: ")+state.title+_("\nx axis: ")+state.x_label+" ("+latex_to_pygtk_subscript(state.x_units)+_(")\ny axis: ")+state.y_label+" ("+latex_to_pygtk_subscript(state.y_units)+_(")\n\n<big><b>Double click to open</b></big>")
				my_help_class.help_set_help(["dat_file.png",summary])

			if icon_name.endswith("equilibrium"):
				state=plot_state()
				get_plot_file_info(state,full_path)
				summary="<big><b>equilibrium</b></big>\n"+_("\nThis contains the simulation output at 0V in the dark.")
				my_help_class.help_set_help(["dir_file.png",summary])
コード例 #6
0
ファイル: scan_tab.py プロジェクト: roderickmackenzie/gpvdm
	def callback_reopen_xy_window(self, widget, data=None):
		if len(self.plotted_graphs)>0:
			pos=len(self.plotted_graphs)-1
			plot_data=plot_state()
			plot_data.file0=self.plotted_graphs[pos].file0
			plot_xy_window=plot_dlg_class(plot_data)
			plot_xy_window.run()
			plot_now=plot_xy_window.ret

			if plot_now==True:
				self.plot_results(plot_data)
				self.plotted_graphs.refresh()
コード例 #7
0
ファイル: make_man.py プロジェクト: roderickmackenzie/gpvdm
def make_man():
	file_paths = []  # List which will store all of the full filepaths.
	out=""
	files=glob.glob("*.dat")
	section_one=[]
	section_two=[]
	text_list=[]
	for filename in files:

		if filename.endswith(".dat")==True:

			temp=plot_state()
			ret=plot_load_info(temp,filename)
			if ret==True:

				section_one.append(temp.section_one)
				section_two.append(temp.section_two)
				out=""
				filename=filename.replace("_","\\_")
				out=out+"\\textbf{"+filename+"}:"+ temp.title+"\\newline\n"
				out=out+"x-axis:"+temp.x_label+"($"+temp.x_units+"$)\\newline\n"
				out=out+"y-axis:"+temp.y_label+"($"+temp.y_units+"$)\\newline\n"
				out=out+"\\newline\n"
				text_list.append(out)


				file_paths.append(filename)

	section_one, section_two, text_list = zip(*sorted(zip(section_one, section_two,text_list),key = operator.itemgetter(1, 2)))



	text_file = open("./man_src/files.tex", "w")
	last_section_one=""
	last_section_two=""
	for i in range(0,len(text_list)):
		if section_one[i]!="":
			if last_section_one!=section_one[i]:
				last_section_one=section_one[i]
				text_file.write("\subsubsection{"+section_one[i]+"}\n")

			if last_section_two!=section_two[i]:
				last_section_two=section_two[i]
				text_file.write("\paragraph{"+section_two[i]+"}\n")

			text_file.write(text_list[i])
	text_file.close()
コード例 #8
0
ファイル: workbook.py プロジェクト: roderickmackenzie/gpvdm
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")
コード例 #9
0
	def load_data(self,input_files,config_file):

		self.input_files=input_files
		self.config_file=config_file

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

		loaded=False
		self.plot_token=plot_state()

		#Try and get the data from the config file
		if plot_load_info(self.plot_token,input_files[0])==False:
			return
		#print("fred>>>>>>>>>>",self.plot_token.x_len)
		if plot_load_info(self.plot_token,config_file)==True:
			print("I have updated the plot info",self.plot_token.type)


		#print("the config file is",config_file)
		#print(input_files,loaded)

		if len(self.plot_id)==0:
			for i in range(0,len(input_files)):
				self.plot_id.append(0)

		self.plot_token.path=os.path.dirname(config_file)
		if self.plot_token.tag0=="":
			self.plot_token.file0=os.path.basename(input_files[0])

		plot_save_oplot_file(config_file,self.plot_token)

		self.output_file=os.path.splitext(config_file)[0]+".png"

		#ret=plot_populate_plot_token(plot_token,self.input_files[0])
		#if ret==True:
		#print "Rod",input_files
		title=self.plot_token.title
		self.setWindowTitle(title+" - www.gpvdm.com")

		#print("Loaded OK",self.config_file)

		test_file=self.input_files[0]
		for i in range(0,len(self.input_files)):
			if os.path.isfile(self.input_files[i]):
				test_file=self.input_files[i]
コード例 #10
0
ファイル: band_graph.py プロジェクト: roderickmackenzie/opvdm
	def draw_graph(self):
		self.layer_end=[]
		self.layer_name=[]

		n=0
		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)=="none":
				start=start-epitaxy_get_width(i)
			else:
				break
		print "START=",start
		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)

			delta=float(layer_ticknes)*1e9
			if epitaxy_get_electrical_layer(i)=="none":
				mat_file=os.path.join(os.getcwd(),'materials',layer_material,'mat.inp')
				myfile = open(mat_file)
				self.mat_file_lines = myfile.readlines()
				myfile.close()
			
				for ii in range(0, len(self.mat_file_lines)):
					self.mat_file_lines[ii]=self.mat_file_lines[ii].rstrip()

				lumo=-float(self.mat_file_lines[1])
				Eg=float(self.mat_file_lines[3])
			else:
				lines=[]
				if inp_load_file(lines,epitaxy_get_electrical_layer(i)+".inp")==True:
					lumo=-float(inp_search_token_value(lines, "#Xi"))
					Eg=float(inp_search_token_value(lines, "#Eg"))

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

			lumo_delta=lumo-0.1
			h**o=lumo-Eg
			homo_delta=h**o-0.1
			if Eg==0.0:
				lumo_delta=-7.0
				h**o=0.0
			lumo_shape = [lumo,lumo,lumo_delta,lumo_delta]
			x_pos=x_pos+delta
			self.layer_end.append(x_pos)
			self.layer_name.append(layer_material)
			ax2.fill(x,lumo_shape, color[layer],alpha=0.4)
			ax2.text(x_pos-delta/1.5, lumo-0.4, epitaxy_get_name(i))

			if h**o!=0.0:
				homo_shape = [h**o,h**o,homo_delta,homo_delta]
				ax2.fill(x,homo_shape, color[layer],alpha=0.4)

			layer=layer+1

			n=n+1

		state=plot_state()
		get_plot_file_info(state,self.optical_mode_file)
		#summary="<big><b>"+self.store[path[0]][0]+"</b></big>\n"+"\ntitle: "+state.title+"\nx axis: "+state.x_label+" ("+latex_to_pygtk_subscript(state.x_units)+")\ny axis: "++" ("+latex_to_pygtk_subscript(state.y_units)+")\n\n<big><b>Double click to open</b></big>"

		print "ROD!!!!",state.y_label,self.optical_mode_file
		ax1.set_ylabel(state.y_label)
		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)
		loaded=False

		if os.path.isfile("light_dump.zip"):
			zf = zipfile.ZipFile("light_dump.zip", 'r')
			lines = zf.read(self.optical_mode_file).split("\n")
			zf.close()
			loaded=True
		elif os.path.isfile(self.optical_mode_file):
			print "I want to load",self.optical_mode_file
			f = open(self.optical_mode_file)
			lines = f.readlines()
			f.close()
			loaded=True
		
		if loaded==True:
			xx=[]
			yy=[]
			zz=[]
			lines_to_xyz(xx,yy,zz,lines)
			t = asarray(xx)
			s = asarray(yy)

			t=t*1e9
			ax1.plot(t,s, 'black', linewidth=3 ,alpha=0.5)

			

		self.my_figure.tight_layout()
コード例 #11
0
ファイル: cmp_class.py プロジェクト: roderickmackenzie/gpvdm
	def init(self):
		return False
		self.dumps=0
		self.plot_token=plot_state()

		vbox=gtk.VBox()

		self.multi_plot=False

		self.log_scale_y="auto"


		menu_items = (
		    ( "/_Options",         None,         None, 0, "<Branch>" ),
		    ( "/Options/_Subtract 0th frame",     None, self.callback_toggle_subtract, 0, "<ToggleItem>", "gtk-save" ),
		    ( "/_Axis/_Multiplot",     None, self.callback_multi_plot, 0, "<ToggleItem>", "gtk-save" ),
		    ( "/_Axis/_Set y axis to maximum",     None, self.callback_set_min_max, 0, "<ToggleItem>", "gtk-save" ),
		    )

		self.plot.item_factory.create_items(menu_items)

		primary_hbox.add(self.entry0)
		sim_vbox.add(primary_hbox)

		secondary_hbox=gtk.HBox()

		text=gtk.Label("Secondary dir")
		secondary_hbox.add(text)

		self.entry1 = gtk.combo_box_entry_new_text()
		self.entry1.show()

		for i in range(0,len(self.snapshot_list)):
			self.entry1.append_text(self.snapshot_list[i])

		secondary_hbox.add(self.entry1)
		sim_vbox.add(secondary_hbox)

		sim_vbox.show()
		#hbox.set_size_request(-1, 30)
		vbox.pack_start(sim_vbox, False, False, 0)

		hbox2=gtk.HBox()
		text=gtk.Label("Files to plot")
		hbox2.add(text)
		self.entry2 = gtk.Entry()
		self.entry2.set_text("pt_map nt_map")
		self.entry2.show()
		hbox2.add(self.entry2)
		hbox2.set_size_request(-1, 30)
		vbox.pack_start(hbox2, False, False, 0)

		hbox3=gtk.HBox()
		text=gtk.Label("Exprimental data")
		hbox3.add(text)
		self.entry3 = gtk.Entry()
		self.entry3.set_text("")
		self.entry3.show()
		hbox3.add(self.entry3)
		hbox3.set_size_request(-1, 30)
		vbox.pack_start(hbox3, False, False, 0)

		self.update_button = gtk.Button()
		self.update_button.set_label("Update")
		self.update_button.show()
		self.update_button.connect("clicked", self.callback_scale)
		vbox.add(self.update_button)

		self.config_load()
		self.count_dumps()



		if self.dumps==0:
			md = gtk.MessageDialog(None, 0, gtk.MESSAGE_QUESTION,  gtk.BUTTONS_YES_NO, "No slice data has been written to disk.  You need to re-run the simulation with the dump_slices set to 1.  Would you like to do this now?  Note: This generates lots of files and will slow down the simulation.")

			response = md.run()

			if response == gtk.RESPONSE_YES:
				inp_update_token_value("dump.inp", "#dump_1d_slices", "1",1)
				os.system(get_exe_command())

			md.destroy()

			self.count_dumps()

		self.entry0.connect("changed", self.callback_edit)
		self.entry1.connect("changed", self.callback_edit)
		self.entry2.connect("changed", self.callback_edit)
		self.entry3.connect("changed", self.callback_edit)



		vbox.show_all()
		self.add(vbox)

		self.update(0)
		if self.dumps!=0:
			self.plot.do_plot()
			print("CONVERT!!!!!!!!!!!",type(self.plot.plot_token.key_units))
		self.set_border_width(10)
		self.set_title("Compare")
		self.set_icon_from_file(os.path.join(get_image_file_path(),"image.jpg"))

		self.connect('key_press_event', self.on_key_press_event)

		self.show()
コード例 #12
0
ファイル: cmp_class.py プロジェクト: roderickmackenzie/opvdm
	def init(self):
		self.dumps=0
		self.plot_token=plot_state()
		self.win_list=windows()
		self.win_list.load()
		self.win_list.set_window(self,"cmp_class")

		self.snapshot_list=self.update_snapshots_dir()
		vbox=gtk.VBox()

		self.multi_plot=False

		self.log_scale_y="auto"

		self.plot=plot_widget()
		self.plot.init(self)

		accel_group = gtk.AccelGroup()
		item_factory = gtk.ItemFactory(gtk.MenuBar, "<main>", accel_group)

		menu_items = (
		    ( "/_Options",         None,         None, 0, "<Branch>" ),
		    ( "/Options/_Subtract 0th frame",     None, self.callback_toggle_subtract, 0, "<ToggleItem>", "gtk-save" ),
		    ( "/_Axis/_Multiplot",     None, self.callback_multi_plot, 0, "<ToggleItem>", "gtk-save" ),
		    ( "/_Axis/_Set y axis to maximum",     None, self.callback_set_min_max, 0, "<ToggleItem>", "gtk-save" ),
		    )

		self.plot.item_factory.create_items(menu_items)



		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"video.png"))
		self.video = gtk.ToolButton(image)
		self.plot.toolbar.add(self.video)
		self.video.show()
		self.video.connect("clicked", self.callback_save)

		image = gtk.Image()
   		image.set_from_file(os.path.join(get_image_file_path(),"scale.png"))
		self.scale = gtk.ToolButton(image)
		self.plot.toolbar.add(self.scale)

		sep = gtk.SeparatorToolItem()
		sep.set_draw(False)
		sep.set_expand(True)
		self.plot.toolbar.add(sep)
		sep.show()


		help = gtk.ToolButton(gtk.STOCK_HELP)
		self.plot.toolbar.add(help)
		help.connect("clicked", self.callback_help)
		help.show()

		close = gtk.ToolButton(gtk.STOCK_QUIT)
		close.connect("clicked", self.callback_close)
		self.plot.toolbar.add(close)
		close.show()

		self.connect("delete-event", self.callback_close) 

		self.plot.toolbar.show_all()


		self.canvas=self.plot.canvas 
		self.plot.show()
		vbox.add(self.plot)

		#adjust
		self.adj1 = gtk.Adjustment(0.0, 0.0, 100, 1, 1.0, 1.0)
		self.adj1.connect("value_changed", self.callback_scale)
		vscale = gtk.HScale(self.adj1)
		vscale.set_update_policy(gtk.UPDATE_CONTINUOUS)
		vscale.set_digits(1)
		vscale.set_value_pos(gtk.POS_TOP)
		vscale.set_draw_value(True)
		vscale.set_size_request(200, 40)
		vscale.set_digits(0)
		vbox.pack_start(vscale, False, False, 10)


		sim_vbox=gtk.VBox()
		primary_hbox=gtk.HBox()

		text=gtk.Label("Primary dir")
		primary_hbox.add(text)

		self.entry0 = gtk.combo_box_entry_new_text()
		self.entry0.show()


		for i in range(0,len(self.snapshot_list)):
			self.entry0.append_text(self.snapshot_list[i])

		primary_hbox.add(self.entry0)
		sim_vbox.add(primary_hbox)

		secondary_hbox=gtk.HBox()

		text=gtk.Label("Secondary dir")
		secondary_hbox.add(text)

		self.entry1 = gtk.combo_box_entry_new_text()
		self.entry1.show()

		for i in range(0,len(self.snapshot_list)):
			self.entry1.append_text(self.snapshot_list[i])

		secondary_hbox.add(self.entry1)
		sim_vbox.add(secondary_hbox)

		sim_vbox.show()
		#hbox.set_size_request(-1, 30)
		vbox.pack_start(sim_vbox, False, False, 0)

		hbox2=gtk.HBox()
		text=gtk.Label("Files to plot")
		hbox2.add(text)
		self.entry2 = gtk.Entry()
		self.entry2.set_text("pt_map nt_map")
		self.entry2.show()
		hbox2.add(self.entry2)
		hbox2.set_size_request(-1, 30)
		vbox.pack_start(hbox2, False, False, 0)

		hbox3=gtk.HBox()
		text=gtk.Label("Exprimental data")
		hbox3.add(text)
		self.entry3 = gtk.Entry()
		self.entry3.set_text("")
		self.entry3.show()
		hbox3.add(self.entry3)
		hbox3.set_size_request(-1, 30)
		vbox.pack_start(hbox3, False, False, 0)

		self.update_button = gtk.Button()
		self.update_button.set_label("Update")
		self.update_button.show()
		self.update_button.connect("clicked", self.callback_scale)
		vbox.add(self.update_button)

		self.config_load()
		self.count_dumps()
		if self.dumps==0:
			md = gtk.MessageDialog(None, 0, gtk.MESSAGE_QUESTION,  gtk.BUTTONS_YES_NO, "No slice data has been written to disk.  You need to re-run the simulation with the dump_slices set to 1.  Would you like to do this now?  Note: This generates lots of files and will slow down the simulation.")

			response = md.run()

			if response == gtk.RESPONSE_YES:
				inp_update_token_value("dump.inp", "#dump_1d_slices", "1",1)
				ret= os.system(get_exe_command())

			md.destroy()

			self.count_dumps()

		self.entry0.connect("changed", self.callback_edit)
		self.entry1.connect("changed", self.callback_edit)
		self.entry2.connect("changed", self.callback_edit)
		self.entry3.connect("changed", self.callback_edit)



		vbox.show_all()
		self.add(vbox)
		
		self.update(0)
		if self.dumps!=0:
			self.plot.do_plot()
			print "CONVERT!!!!!!!!!!!",type(self.plot.plot_token.key_units)
		self.set_border_width(10)
		self.set_title("Compare")
		self.set_icon_from_file(os.path.join(get_image_file_path(),"image.jpg"))

		self.connect('key_press_event', self.on_key_press_event)

		self.show()
コード例 #13
0
def command_args(argc,argv):
	if argc>=2:
		if argv[1]=="--help":
			print "Usage: opvdm [option] src_file dest_file"
			print ""
			print "Options:"
			print "\t--version\tdisplays the current version"
			print "\t--help\t\tdisplays the help"
			print "\t--export\texport a simulation to a gz file"
			print "\t--import\timport a simulation from a .opvdm file"
			print "\t--patch\tpatch an .opvdm file with an older .opvdm file"
			print "\t\t\tusage --import abc.opvdm ./path/to/output/ "
			print "\t--clone\t\tgenerate a clean simulation in the current directory"
			print "\t--clean\t\tcleans the current simulation directory deleting .dat files and scan dirs"
			print "\t--dump-tab (output file)\t\tdumps simulation parameters as jpg"
			print "\t--import-scandirs\t\tOnly imports the scan directories"
			print "\t--clean-scandirs\t\tDeletes the content of all scan dirs"
			print "\t--scan-plot\t\truns an oplot file"
			print "\t\t\tusage --scan-plot /path/to/oplot/file.oplot "
			print "\t--run-scan\t\truns a scan"
			print "\t\t\tusage --run-scan /path/containing/base/files/ /path/to/scan/dir/ "

			print ""
			print "Additional information about opvdm is available at http://www.opvdm.com."
			print ""
			print "Report bugs to: [email protected]"
			sys.exit(0)
		if argv[1]=="--version":
			print ver()
			sys.exit(0)
		if argv[1]=="--import-scandirs":
			import_scan_dirs(os.getcwd(),argv[2])
			exit(0)
		if argv[1]=="--export":
			export_as(argv[2])
			sys.exit(0)
		if argv[1]=="--dump-tab":
			export_as(argv[2])
			sys.exit(0)
		if argv[1]=="--import":
			import_archive(argv[2],os.path.join(os.getcwd(),"sim.opvdm"),False)
			sys.exit(0)
		if argv[1]=="--patch":
			import_archive(argv[2],argv[3],True)
			sys.exit(0)
		if argv[1]=="--clone":
			opvdm_clone()
			sys.exit(0)
		if argv[1]=="--clone-src":
			opvdm_copy_src(argv[2])
			sys.exit(0)

		if argv[1]=="--file_info":
			data=plot_data()
			data.dump_file()
			sys.exit(0)
		if argv[1]=="--clean":
			clean_sim_dir()
			sys.exit(0)
		if argv[1]=="--clean-scandirs":
			clean_scan_dirs(os.getcwd())
			sys.exit(0)

		if argv[1]=="--server":
			obj=udp_server()
			obj.start()

		if argv[1]=="--client":
			client=udp_client()
			client.init()

		if argv[1]=="--make-man":
			make_man()
			sys.exit(0)

		if argv[1]=="--run-scan":
			scan_dir_path=argv[3]	#program file
			program_list=[]
			base_dir=argv[2]				#base dir
			exe_command   =  get_exe_command()
			scan_item_load(os.path.join(scan_dir_path,"scan_items.inp"))
			tree_load_program(program_list,scan_dir_path)

			watch_dir=os.path.join(os.getcwd(),scan_dir_path)
			#print program_list,pwd,scan_dir_path
			#sys.exit(0)
			#print pwd,scan_dir_path
			#print os.getcwd(),os.path.join(scan_dir_path)
			#tree_gen(program_list,os.getcwd(),os.path.join(os.getcwd(),"suns"))
			flat_list=[]
			tree_gen(flat_list,program_list,base_dir,scan_dir_path)
			commands=[]
			server_find_simulations_to_run(commands,scan_dir_path)
			myserver=server()
			myserver.init(watch_dir)
			myserver.clear_cache()
			for i in range(0, len(commands)):
				myserver.add_job(commands[i])
				print "Adding job"+commands[i]
			myserver.simple_run(exe_command)

			sys.exit(0)
		if argv[1]=="--scan-plot":
			plot_token=plot_state()
			oplot_file=argv[2]
			if plot_load_info(plot_token,oplot_file)==True:
				print "file0=",plot_token.file0,"<"
				plot_files, plot_labels, save_file = scan_gen_plot_data(plot_token,os.path.dirname(oplot_file))
				print "written data to",save_file
			else:
				print "Problem loading oplot file"
			sys.exit(0)
コード例 #14
0
def command_args(argc,argv):
	if argc>=2:
		if argv[1]=="--help":
			print(_("Usage: gpvdm [option] src_file dest_file"))
			print("")
			print(_("Options:"))
			print(_("\t--version\t\tdisplays the current version"))
			print(_("\t--help\t\t\tdisplays the help"))
			print(_("\t--export\t\texport a simulation to a gz file"))
			print(_("\t--import\t\timport a simulation from a .gpvdm file"))
			print(_("\t--patch\t\t\tpatch an .gpvdm file with an older .gpvdm file"))
			print(_("\t\t\t\tusage --import abc.gpvdm ./path/to/output/ "))
			print(_("\t--clone\t\t\tgenerate a clean simulation in the current directory"))
			print(_("\t--clean\t\t\tcleans the current simulation directory deleting .dat files but not  scan dirs"))
			print(_("\t--dump-tab\t\tdumps simulation parameters as jpg"))
			print(_("\t\t\t\tusage --dump-tab output_path "))
			print(_("\t--import-scandirs\tOnly imports the scan directories"))
			print(_("\t--clean-scandirs\tDeletes the content of all scan dirs"))
			print(_("\t--scan-plot\t\truns an oplot file"))
			print(_("\t\t\t\tusage --scan-plot /path/to/oplot/file.oplot "))
			print(_("\t--run-scan\t\truns a scan"))
			print(_("\t\t\t\tusage --run-scan /path/containing/base/files/ /path/to/scan/dir/ "))
			print(_("\t--sync-ver\t\truns a scan"))
			print(_("\t--edit-value\t\tedits a value in a .gpvdm archive"))
			print(_("\t\t\t\tusage --edit-value /path/to/sim.gpvdm #token_to_change new_value "))
			print(_("\t\t\t\tchanges the version of input file"))
			print(_("\t--replace\t\treplaces file in device lib"))
			if enable_cluster()==True:
				print(_("\t--server\t\tRun as server node for cluster"))
				print(_("\t--server\t\tRun as client node for cluster"))


			print("\t\t\t")
			print("")
			print(_("Additional information about gpvdm is available at http://www.gpvdm.com."))
			print("")
			print(_("Report bugs to: [email protected]"))
			sys.exit(0)

		if 	check_params(argv,"--version",0)==True:
			print(version())
			sys.exit(0)
		if 	check_params(argv,"--ver",0)==True:
			print(ver())
			sys.exit(0)
		if check_params(argv,"--import-scandirs",1)==True:
			import_scan_dirs(os.getcwd(),argv[2])
			exit(0)
		if check_params(argv,"--replace",1)==True:
			device_lib_replace(argv[2])
			exit(0)
		if check_params(argv,"--export",1)==True:
			export_as(argv[2])
			sys.exit(0)
		if check_params(argv,"--dump-tab",1)==True:
			export_as(argv[2])
			sys.exit(0)
		if check_params(argv,"--import",1)==True:
			import_archive(argv[2],os.path.join(os.getcwd(),"sim.gpvdm"),False)
			sys.exit(0)
		if check_params(argv,"--patch",2)==True:
			import_archive(argv[2],argv[3],True)
			sys.exit(0)
		if check_params(argv,"--clone",0)==True:
			gpvdm_clone(os.getcwd(),True)
			sys.exit(0)
		if check_params(argv,"--clone-src",1)==True:
			gpvdm_copy_src(argv[2])
			sys.exit(0)
		if check_params(argv,"--edit-value",3)==True:
			inp_update(argv[2], argv[3], argv[4])
			sys.exit(0)

		#if check_params(argv,"--file_info",0)==True:
		#	data=plot_data()
		#	data.dump_file()
		#	sys.exit(0)
		if check_params(argv,"--clean",0)==True:
			clean_sim_dir()
			sys.exit(0)
		if check_params(argv,"--clean-scandirs",0)==True:
			clean_scan_dirs(os.getcwd())
			sys.exit(0)

		if check_params(argv,"--make-man",1)==True:
			make_man()
			sys.exit(0)

		if check_params(argv,"--sync-ver",0)==True:
			ver_sync_ver()
			sys.exit(0)

		if check_params(argv,"--run-scan",2)==True:
			scan_dir_path=argv[3]	#program file
			program_list=[]
			base_dir=argv[2]				#base dir
			exe_command   =  get_exe_command()
			tree_load_program(program_list,scan_dir_path)

			watch_dir=os.path.join(os.getcwd(),scan_dir_path)
			#print(program_list,pwd,scan_dir_path)
			#sys.exit(0)
			#print(pwd,scan_dir_path)
			#print(os.getcwd(),os.path.join(scan_dir_path))
			#tree_gen(program_list,os.getcwd(),os.path.join(os.getcwd(),"suns"))
			flat_list=[]
			tree_gen(flat_list,program_list,base_dir,scan_dir_path)
			commands=[]
			server_find_simulations_to_run(commands,scan_dir_path)
			myserver=server()
			myserver.init(watch_dir)
			myserver.clear_cache()
			for i in range(0, len(commands)):
				myserver.add_job(commands[i],"")
				print("Adding job"+commands[i])
			myserver.simple_run(exe_command)

			sys.exit(0)

		if check_params(argv,"--scan-plot",1)==True:
			plot_token=plot_state()
			oplot_file=argv[2]
			if plot_load_info(plot_token,oplot_file)==True:
				print("file0=",plot_token.file0,"<")
				plot_files, plot_labels, save_file = scan_gen_plot_data(plot_token,os.path.dirname(oplot_file))
				print("written data to",save_file)
			else:
				print("Problem loading oplot file")
			sys.exit(0)
コード例 #15
0
def soft_clustering(points,clusters):
    
    i = 0
    j = 0
    z = 0
    ac = 0
    ant = clusters
    fin = False

    initial_plot(clusters,points)

    start_time = time.time()

    while(not fin): 
        it_time = time.time()
        
        #Se recorren todo los puntos para calcular la distancia y clasificarlos
        for p in points:

            #Obtenemos los grados de pertenencia del punto <p> a los clusters
            gp = get_distances(p,ant)

            #Asignamos el punto <p> a todos los clusters con su repectiva pertenencia
            assign_point(p,gp,ant)

        # Se muestra el estado final del algoritmo
        if(z==1):
            plot_state(ant,points)

        #Se actualizan los radios y los centros
        res = calcularNuevosCluster(ant)
        i += 1

        # Mostramos en la consola los resultados de cada iteración
        print("Iteración",i,"===========================================================")
        if(z==0):
            ac = ac + (time.time() - it_time)
        print("Tiempo de iteración: ", (time.time() - it_time))
        print("Número de clusters: ",len(clusters))
        print("Centros y radios: ")
        for c in res:
            print(c.name,": ",c.center," [",c.radius,"]")
        print()

        #Si los cluster no han cambiado del paso anterior, se continua el algoritmo
        for n in range(len(res)):
            if((abs(res[n].center[0] - ant[n].center[0]) < 0.01) and 
                (abs(res[n].center[1] - ant[n].center[1]) < 0.01) and 
                (abs(res[n].radius - ant[n].radius) < 0.001)):
                j += 1

        ant = res

        # La condición de parada del alogritmo
        if(z == 1):
            fin = True

        if(j == len(res)):
            z = 1
        
        j = 0

    # Se imprime en la consola un mensaje de final de ejecución, 
    # con su tiempo total de ejecución
    if(fin):
        print("=======================================================================")
        print("FIN DEL ALGORITMO")
        print("TIEMPO DE EJECUCIÓN: ", ac)
        print("=======================================================================")
コード例 #16
0
	def load_data(self,input_files,config_file):

		self.input_files=input_files
		self.config_file=config_file

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

		loaded=False		
		self.plot_token=plot_state()

		#Try and get the data from the config file
		if plot_load_info(self.plot_token,config_file)==True:
			loaded=True
			print "I HAVE LOADED THE OPLOT FILE",self.plot_token.type

		#If that did not work get it from the data file
		if loaded==False:
			if plot_load_info(self.plot_token,input_files[0])==True:
				loaded=True

		print "the config file is",config_file
		print input_files,loaded
		if loaded==True:

			if len(self.plot_id)==0:
				for i in range(0,len(input_files)):
					self.plot_id.append(0)
		
			self.plot_token.path=os.path.dirname(config_file)
			if self.plot_token.tag0=="":
				self.plot_token.file0=os.path.basename(input_files[0])

			plot_save_oplot_file(config_file,self.plot_token)

			self.output_file=os.path.splitext(config_file)[0]+".png"

			#ret=plot_populate_plot_token(plot_token,self.input_files[0])
			#if ret==True:
			#print "Rod",input_files
			title=self.plot_token.title
			self.win.set_title(title+" - www.opvdm.com")
			lines=[]

			ret=plot_load_info(self.plot_token,input_files[0])
			myitem=self.item_factory.get_item("/Math/Subtract first point")
			myitem.set_active(self.plot_token.subtract_first_point)

			myitem=self.item_factory.get_item("/Math/Add min point")
			myitem.set_active(self.plot_token.add_min)

			myitem=self.item_factory.get_item("/Math/Invert y-axis")
			myitem.set_active(self.plot_token.invert_y)

			myitem=self.item_factory.get_item("/Math/Norm to 1.0 y")
			myitem.set_active(self.plot_token.normalize)

			myitem=self.item_factory.get_item("/Math/Norm to peak of all data")
			myitem.set_active(self.plot_token.norm_to_peak_of_all_data)

			print "Loaded OK",self.config_file

			test_file=self.input_files[0]
			for i in range(0,len(self.input_files)):
				if os.path.isfile(self.input_files[i]):
					test_file=self.input_files[i]

			print "test_file=",test_file
			print "Exit here"