Example #1
0
    def callback_gen_plot_command(self):
        dialog = gpvdm_open(self.sim_dir, act_as_browser=False)
        ret = dialog.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 = dat_file()
            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)
Example #2
0
	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)
Example #3
0
	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()
Example #4
0
def scan_gen_plot_data(plot_token, base_path):
    ret = ""
    plot_files = []
    plot_labels = []
    save_file = ""

    file_name = plot_token.file0
    if file_name == "":
        print("You have given me no file name!!!")
        sys.exit(0)

    #search for the files
    return_file_list(plot_files, base_path, file_name)
    print("search_file=", plot_token.file0, file_name)
    print("plot_files0=", plot_files)
    #print("found_files=",plot_files)
    #print("found_files=",base_path)

    #now tidy up the list as we need to remove snapshots
    save_list = []
    if base_path.split(os.sep).count("snapshots") == 0:
        for i in range(len(plot_files)):
            if "snapshots" not in plot_files[i]:
                save_list.append(plot_files[i])
        plot_files = save_list

    print("plot_files=", plot_files)

    num_list = []

    #remove the file name in the base_dir
    test_file = os.path.join(base_path, file_name)
    if test_file in plot_files:
        plot_files.remove(test_file)

    #attempt to sort list in numeric order
    try:
        for i in range(0, len(plot_files)):
            dir_name = os.path.basename(os.path.dirname(plot_files[i]))
            if dir_name == "dynamic":
                dir_name = os.path.basename(
                    os.path.dirname(os.path.dirname(plot_files[i])))
            num_list.append(float(dir_name))

        num_list, plot_files = zip(*sorted(zip(num_list, plot_files)))
    except:
        print("There are stings in the list I can not order it")

    #if it is an info file then deal with it
    print(check_info_file(file_name), file_name, plot_token.file0,
          plot_token.file1, plot_token.tag0, plot_token.tag1)

    if (check_info_file(file_name) == True):
        #print "Rod",plot_files,self.sim_dir

        print(plot_files, "r", plot_labels, "r", save_file, "r", plot_files,
              "r", base_path, "r", plot_token)

        multi_plot = multiplot_from_tokens()
        plot_files, plot_labels, save_file = multi_plot.gen_plot(
            base_path, plot_token.file0, plot_token.tag0, plot_token.file1,
            plot_token.tag1)

    else:
        if len(plot_files) > 0:
            ret = plot_populate_plot_token(plot_token, plot_files[0])
            if ret == False:
                error_dlg(
                    self, "This file " + file_name +
                    " is not in the data base please file a bug report..")
                return

            #build plot labels
            for i in range(0, len(plot_files)):
                text = plot_files[i][len(base_path):len(plot_files[i]) - 1 -
                                     len(os.path.basename(plot_files[i]))]
                if text.endswith("dynamic"):
                    text = text[:-7]

                if text.endswith("optical_output"):
                    text = text[:-10]

                if text[0] == "/" or "\\":
                    text = text[1:]

                text = text.replace("\\", "/")

                plot_labels.append(str(text))

            save_file = os.path.join(
                base_path,
                os.path.splitext(os.path.basename(
                    plot_files[0]))[0]) + ".oplot"

    return plot_files, plot_labels, save_file
Example #5
0
def scan_gen_plot_data(plot_token,base_path):
	ret=""
	plot_files=[]
	plot_labels=[]
	save_file=""

	file_name=plot_token.file0
	if file_name=="":
		print("You have given me no file name!!!")
		sys.exit(0)

	#search for the files
	return_file_list(plot_files,base_path,file_name)
	print("search_file=",plot_token.file0)
	#print("found_files=",plot_files)
	#print("found_files=",base_path)
	
	#now tidy up the list as we need to remove snapshots
	save_list=[]
	if base_path.split(os.sep).count("snapshots")==0:
		for i in range(len(plot_files)):
			if "snapshots" not in plot_files[i]:
				save_list.append(plot_files[i])
		plot_files=save_list

	print("plot_files=",plot_files)
	
	num_list=[]

	#remove the file name in the base_dir
	test_file=os.path.join(base_path,file_name)
	if test_file in plot_files:
	    plot_files.remove(test_file)

	#attempt to sort list in numeric order
	try:
		for i in range(0, len(plot_files)):
			dir_name=os.path.basename(os.path.dirname(plot_files[i]))
			if dir_name=="dynamic":
				dir_name=os.path.basename(os.path.dirname(os.path.dirname(plot_files[i])))
			num_list.append(float(dir_name))

		num_list, plot_files = zip(*sorted(zip(num_list, plot_files)))
	except:
		print("There are stings in the list I can not order it")

	#if it is an info file then deal with it
	print(check_info_file(file_name),file_name,plot_token.file0,plot_token.file1,plot_token.tag0,plot_token.tag1)

	if (check_info_file(file_name)==True):
		#print "Rod",plot_files,self.sim_dir

		print(plot_files,"r",plot_labels,"r",save_file,"r",plot_files,"r",base_path,"r",plot_token)

		plot_files, plot_labels, save_file = gen_infofile_plot(plot_files,base_path,plot_token)

	else:
		ret=plot_populate_plot_token(plot_token,plot_files[0])
		if ret==False:
			message = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
			message.set_markup("This file "+file_name+" is not in the data base please file a bug report..")
			message.run()
			message.destroy()
			return

		#build plot labels
		for i in range(0,len(plot_files)):
			text=plot_files[i][len(base_path):len(plot_files[i])-1-len(os.path.basename(plot_files[i]))]
			if text.endswith("dynamic"):
				text=text[:-7]

			if text.endswith("light_dump"):
				text=text[:-10]

			if text[0]=="/" or "\\":
				text=text[1:]
				
			text=text.replace("\\","/")

			plot_labels.append(str(text))

		save_file=os.path.join(base_path,os.path.splitext(os.path.basename(plot_files[0]))[0])+".oplot"


	return plot_files, plot_labels, save_file