fixed evil tab/spaces
This commit is contained in:
		| @@ -5,9 +5,14 @@ import autophase | |||||||
| class DamarisFFT: | class DamarisFFT: | ||||||
|     def clip(self, start=None, stop=None): |     def clip(self, start=None, stop=None): | ||||||
|         """ |         """ | ||||||
|         Method for clipping data, only the timesignal between start and stop |         :param float start: beginning of clipping | ||||||
|  |         :param float stop: end of clipping | ||||||
|  |  | ||||||
|  |         Method for clipping data, returns only the timesignal | ||||||
|  |         between start and stop | ||||||
|         is returned. |         is returned. | ||||||
|         start and stop can be either time or frequency. The unit is automatically determined |         start and stop can be either time or frequency. | ||||||
|  |         The unit is automatically determined | ||||||
|         """ |         """ | ||||||
|         # check if start/stop order is properly |         # check if start/stop order is properly | ||||||
|         if start > stop: |         if start > stop: | ||||||
| @@ -15,12 +20,12 @@ class DamarisFFT: | |||||||
|             # TODO swap values? |             # TODO swap values? | ||||||
|             raise |             raise | ||||||
|         # if one uses clip as a "placeholder" |         # if one uses clip as a "placeholder" | ||||||
|         if start==None and stop==None: |         if start == None and stop == None: | ||||||
|             return self |             return self | ||||||
|  |  | ||||||
|         if start==None: |         if start == None: | ||||||
|             start = 0 |             start = 0 | ||||||
|         if stop==None: |         if stop == None: | ||||||
|             stop = -1 |             stop = -1 | ||||||
|         # check if data is fft which changes the start/stop units |         # check if data is fft which changes the start/stop units | ||||||
|         # TODO should get nicer(failsafe), i.e. flags in the object? |         # TODO should get nicer(failsafe), i.e. flags in the object? | ||||||
| @@ -50,6 +55,8 @@ class DamarisFFT: | |||||||
|         Correct the baseline of your data by subtracting the mean of the  |         Correct the baseline of your data by subtracting the mean of the  | ||||||
|         last_part fraction of your data. |         last_part fraction of your data. | ||||||
|  |  | ||||||
|  |         :param float last_part: last section of your timesignal used to calculate baseline | ||||||
|  |  | ||||||
|         last_part defaults to 0.1, i.e. last 10% of your data |         last_part defaults to 0.1, i.e. last 10% of your data | ||||||
|         """ |         """ | ||||||
|         # TODO baselinecorrection for spectra after: |         # TODO baselinecorrection for spectra after: | ||||||
| @@ -80,7 +87,14 @@ class DamarisFFT: | |||||||
|         """ |         """ | ||||||
|     def exp_window(self, line_broadening=10): |     def exp_window(self, line_broadening=10): | ||||||
|         """ |         """ | ||||||
|         exponential window |         Exponential window function | ||||||
|  |  | ||||||
|  |         :param float line_broadening: Applies apodization to time signal | ||||||
|  |  | ||||||
|  |         .. math:: | ||||||
|  |  | ||||||
|  |             \\exp\\left(-\\pi\\cdot \\textsf{line_broadening} \\cdot t\\right) | ||||||
|  |  | ||||||
|         """ |         """ | ||||||
|         apod = numpy.exp(-self.x*numpy.pi*line_broadening) |         apod = numpy.exp(-self.x*numpy.pi*line_broadening) | ||||||
|         for i in range(2): |         for i in range(2): | ||||||
|   | |||||||
| @@ -567,7 +567,7 @@ class DamarisGUI: | |||||||
|                 extensions_dict["res"]="unnamed" |                 extensions_dict["res"]="unnamed" | ||||||
|             else: |             else: | ||||||
|                 extensions_dict["res"]=os.path.splitext(os.path.basename(self.sw.res_script_filename))[0] |                 extensions_dict["res"]=os.path.splitext(os.path.basename(self.sw.res_script_filename))[0] | ||||||
| 	    # create new dump file name |             # create new dump file name | ||||||
|             try: |             try: | ||||||
|                 self.dump_filename=actual_config.get("data_pool_name")%extensions_dict |                 self.dump_filename=actual_config.get("data_pool_name")%extensions_dict | ||||||
|             except ValueError,e: |             except ValueError,e: | ||||||
| @@ -580,7 +580,7 @@ class DamarisGUI: | |||||||
|                 print "The dump filename is a directory, using filename 'DAMARIS_data_pool.h5'" |                 print "The dump filename is a directory, using filename 'DAMARIS_data_pool.h5'" | ||||||
|                 self.dump_filename+=os.sep+"DAMARIS_data_pool.h5" |                 self.dump_filename+=os.sep+"DAMARIS_data_pool.h5" | ||||||
|  |  | ||||||
| 	    # compression |             # compression | ||||||
|             self.dump_complib=actual_config.get("data_pool_complib",None) |             self.dump_complib=actual_config.get("data_pool_complib",None) | ||||||
|             if self.dump_complib=="None": |             if self.dump_complib=="None": | ||||||
|                 self.dump_complib=None |                 self.dump_complib=None | ||||||
| @@ -589,7 +589,7 @@ class DamarisGUI: | |||||||
|             else: |             else: | ||||||
|                 self.dump_complevel=0 |                 self.dump_complevel=0 | ||||||
|  |  | ||||||
| 	    # time interval |             # time interval | ||||||
|             self.dump_timeinterval=60*60*10 |             self.dump_timeinterval=60*60*10 | ||||||
|             try: |             try: | ||||||
|                 self.dump_timeinterval=int(60*float(actual_config["data_pool_write_interval"])) |                 self.dump_timeinterval=int(60*float(actual_config["data_pool_write_interval"])) | ||||||
| @@ -621,29 +621,29 @@ class DamarisGUI: | |||||||
|                 # init is finnished now |                 # init is finnished now | ||||||
|                  |                  | ||||||
|         # now it's time to create the hdf file |         # now it's time to create the hdf file | ||||||
| 	dump_file=None |         dump_file=None | ||||||
|         if not os.path.isfile(self.dump_filename): |         if not os.path.isfile(self.dump_filename): | ||||||
|             if not init: |             if not init: | ||||||
|                 print "dump file \"%s\" vanished unexpectedly, creating new one"%self.dump_filename |                 print "dump file \"%s\" vanished unexpectedly, creating new one"%self.dump_filename | ||||||
|             # have a look to the path and create necessary directories |             # have a look to the path and create necessary directories | ||||||
| 	    dir_stack=[] |             dir_stack=[] | ||||||
| 	    dir_trunk=os.path.dirname(os.path.abspath(self.dump_filename)) |             dir_trunk=os.path.dirname(os.path.abspath(self.dump_filename)) | ||||||
| 	    while dir_trunk!="" and not os.path.isdir(dir_trunk): |             while dir_trunk!="" and not os.path.isdir(dir_trunk): | ||||||
| 		dir_stack.append(os.path.basename(dir_trunk)) |                 dir_stack.append(os.path.basename(dir_trunk)) | ||||||
| 		dir_trunk=os.path.dirname(dir_trunk) |                 dir_trunk=os.path.dirname(dir_trunk) | ||||||
| 		try: |                 try: | ||||||
| 			while len(dir_stack): |                     while len(dir_stack): | ||||||
| 				dir_trunk=os.path.join(dir_trunk, dir_stack.pop()) |                         dir_trunk=os.path.join(dir_trunk, dir_stack.pop()) | ||||||
| 				if os.path.isdir(dir_trunk): continue |                         if os.path.isdir(dir_trunk): continue | ||||||
| 				os.mkdir(dir_trunk) |                         os.mkdir(dir_trunk) | ||||||
| 		except OSError, e: |                 except OSError, e: | ||||||
| 			print e |                     print e | ||||||
| 			print "coud not create dump directory '%s', so hdf5 dumps disabled"%dir_trunk |                     print "coud not create dump directory '%s', so hdf5 dumps disabled"%dir_trunk | ||||||
| 			self.dump_filename="" |                     self.dump_filename="" | ||||||
| 			self.dump_timeinterval=0 |                     self.dump_timeinterval=0 | ||||||
| 			return True |                     return True | ||||||
|  |  | ||||||
| 	    # create new dump file |             # create new dump file | ||||||
|             dump_file=tables.openFile(self.dump_filename,mode="w",title="DAMARIS experiment data") |             dump_file=tables.openFile(self.dump_filename,mode="w",title="DAMARIS experiment data") | ||||||
|             # write scripts and other useful information |             # write scripts and other useful information | ||||||
|             scriptgroup=dump_file.createGroup("/","scripts","Used Scripts") |             scriptgroup=dump_file.createGroup("/","scripts","Used Scripts") | ||||||
| @@ -674,7 +674,7 @@ class DamarisGUI: | |||||||
|                                                 title="log messages", |                                                 title="log messages", | ||||||
|                                                 filters=tables.Filters(complevel=9, complib='zlib')) |                                                 filters=tables.Filters(complevel=9, complib='zlib')) | ||||||
|          |          | ||||||
| 	if dump_file is None and os.path.isfile(self.dump_filename) and tables.isPyTablesFile(self.dump_filename): |         if dump_file is None and os.path.isfile(self.dump_filename) and tables.isPyTablesFile(self.dump_filename): | ||||||
|             # take some data from dump file and repack |             # take some data from dump file and repack | ||||||
|             os.rename(self.dump_filename, self.dump_filename+".bak") |             os.rename(self.dump_filename, self.dump_filename+".bak") | ||||||
|             old_dump_file=tables.openFile(self.dump_filename+".bak", mode="r+") |             old_dump_file=tables.openFile(self.dump_filename+".bak", mode="r+") | ||||||
| @@ -687,12 +687,12 @@ class DamarisGUI: | |||||||
|             # prepare for update |             # prepare for update | ||||||
|             dump_file=tables.openFile(self.dump_filename, mode="r+") |             dump_file=tables.openFile(self.dump_filename, mode="r+") | ||||||
|          |          | ||||||
| 	if dump_file is None: |         if dump_file is None: | ||||||
| 		# exit! |             # exit! | ||||||
| 		print "coud not create dump directory '%s', so hdf5 dumps disabled"%dir_trunk |             print "coud not create dump directory '%s', so hdf5 dumps disabled"%dir_trunk | ||||||
| 		self.dump_filename="" |             self.dump_filename="" | ||||||
| 		self.dump_timeinterval=0 |             self.dump_timeinterval=0 | ||||||
| 		return True |             return True | ||||||
|  |  | ||||||
|         # no undo please! |         # no undo please! | ||||||
|         if dump_file.isUndoEnabled(): |         if dump_file.isUndoEnabled(): | ||||||
| @@ -1207,32 +1207,32 @@ class ScriptWidgets: | |||||||
|         cursor_mark=textbuffer.get_insert() |         cursor_mark=textbuffer.get_insert() | ||||||
|         cursor_iter=textbuffer.get_iter_at_mark(cursor_mark) |         cursor_iter=textbuffer.get_iter_at_mark(cursor_mark) | ||||||
|         if textbuffer is self.experiment_script_textbuffer: |         if textbuffer is self.experiment_script_textbuffer: | ||||||
| 	    line_indicator=self.experiment_script_line_indicator |             line_indicator=self.experiment_script_line_indicator | ||||||
| 	    column_indicator=self.experiment_script_column_indicator |             column_indicator=self.experiment_script_column_indicator | ||||||
|         if textbuffer is self.data_handling_textbuffer: |         if textbuffer is self.data_handling_textbuffer: | ||||||
| 	    line_indicator=self.data_handling_line_indicator |             line_indicator=self.data_handling_line_indicator | ||||||
| 	    column_indicator=self.data_handling_column_indicator |             column_indicator=self.data_handling_column_indicator | ||||||
|  |  | ||||||
| 	# do only necessary updates! |         # do only necessary updates! | ||||||
| 	li_range_new=textbuffer.get_end_iter().get_line()+1 |         li_range_new=textbuffer.get_end_iter().get_line()+1 | ||||||
| 	if line_indicator.get_range()[1]!=li_range_new: |         if line_indicator.get_range()[1]!=li_range_new: | ||||||
| 	        line_indicator.set_range(1, li_range_new) |                 line_indicator.set_range(1, li_range_new) | ||||||
| 	ci_range_new=cursor_iter.get_chars_in_line()+1 |         ci_range_new=cursor_iter.get_chars_in_line()+1 | ||||||
| 	if column_indicator.get_range()[1]!=ci_range_new: |         if column_indicator.get_range()[1]!=ci_range_new: | ||||||
| 	        column_indicator.set_range(1, ci_range_new) |                 column_indicator.set_range(1, ci_range_new) | ||||||
| 	cursor_line=cursor_iter.get_line()+1 |         cursor_line=cursor_iter.get_line()+1 | ||||||
| 	cursor_lineoffset=cursor_iter.get_line_offset()+1 |         cursor_lineoffset=cursor_iter.get_line_offset()+1 | ||||||
| 	if line_indicator.get_value()!=cursor_line: |         if line_indicator.get_value()!=cursor_line: | ||||||
| 	        line_indicator.set_value(cursor_line) |                 line_indicator.set_value(cursor_line) | ||||||
| 	if column_indicator.get_value()!=cursor_lineoffset: |         if column_indicator.get_value()!=cursor_lineoffset: | ||||||
| 	        column_indicator.set_value(cursor_lineoffset) |                 column_indicator.set_value(cursor_lineoffset) | ||||||
|         return False |         return False | ||||||
|  |  | ||||||
|     def textviews_keypress(self, widget, event, data = None): |     def textviews_keypress(self, widget, event, data = None): | ||||||
|         """ |         """ | ||||||
|         helpful tab and return key functions |         helpful tab and return key functions | ||||||
|         """ |         """ | ||||||
| 	#print "keypress", event.state, event.keyval |         #print "keypress", event.state, event.keyval | ||||||
|         if event.state>k.gdk.CONTROL_MASK!=0: |         if event.state>k.gdk.CONTROL_MASK!=0: | ||||||
|             if event.keyval==gtk.gdk.keyval_from_name("c"): |             if event.keyval==gtk.gdk.keyval_from_name("c"): | ||||||
|                 if self.main_notebook.get_current_page() == 0: |                 if self.main_notebook.get_current_page() == 0: | ||||||
| @@ -1344,7 +1344,7 @@ class ScriptWidgets: | |||||||
|             return 1 |             return 1 | ||||||
|  |  | ||||||
|         #self.textviews_moved(widget) |         #self.textviews_moved(widget) | ||||||
| 	return 0 |         return 0 | ||||||
|  |  | ||||||
|     def load_file_as_unicode(self, script_filename): |     def load_file_as_unicode(self, script_filename): | ||||||
|         script_file = file(script_filename, "rU") |         script_file = file(script_filename, "rU") | ||||||
| @@ -1734,10 +1734,10 @@ pygobject version %(pygobject)s | |||||||
|         self.xml_gui.signal_connect("on_printer_setup_button_clicked", self.printer_setup_handler) |         self.xml_gui.signal_connect("on_printer_setup_button_clicked", self.printer_setup_handler) | ||||||
|         for self.system_default_filename in self.system_default_filenames: |         for self.system_default_filename in self.system_default_filenames: | ||||||
|             if self.system_default_filename: |             if self.system_default_filename: | ||||||
| 	        if os.access(self.system_default_filename, os.R_OK): |                 if os.access(self.system_default_filename, os.R_OK): | ||||||
|                     self.load_config(self.system_default_filename) |                     self.load_config(self.system_default_filename) | ||||||
| 	        else: |                 else: | ||||||
| 		    print "can not read system defaults from %s, ask your instrument responsible if required"%self.system_default_filename |                     print "can not read system defaults from %s, ask your instrument responsible if required"%self.system_default_filename | ||||||
|  |  | ||||||
|         self.config_from_system = self.get() |         self.config_from_system = self.get() | ||||||
|         self.load_config() |         self.load_config() | ||||||
| @@ -2064,7 +2064,7 @@ class MonitorWidgets: | |||||||
|     def source_list_reset(self): |     def source_list_reset(self): | ||||||
|         self.display_source_treestore.clear() |         self.display_source_treestore.clear() | ||||||
|         self.source_list_add(u'None') |         self.source_list_add(u'None') | ||||||
| 	none_iter=self.source_list_find([u'None']) |         none_iter=self.source_list_find([u'None']) | ||||||
|         if none_iter is not None: self.display_source_combobox.set_active_iter(none_iter) |         if none_iter is not None: self.display_source_combobox.set_active_iter(none_iter) | ||||||
|  |  | ||||||
|     def source_list_find_one(self, model, iter, what): |     def source_list_find_one(self, model, iter, what): | ||||||
| @@ -2286,8 +2286,8 @@ class MonitorWidgets: | |||||||
|                 self.displayed_data[0]==event.subject): |                 self.displayed_data[0]==event.subject): | ||||||
|                 self.displayed_data=[None,None] |                 self.displayed_data=[None,None] | ||||||
|                 none_iter=self.source_list_find([u'None']) |                 none_iter=self.source_list_find([u'None']) | ||||||
| 	        if none_iter is not None: self.display_source_combobox.set_active_iter(none_iter) |                 if none_iter is not None: self.display_source_combobox.set_active_iter(none_iter) | ||||||
| 		# not necessary, because event will be submitted |                 # not necessary, because event will be submitted | ||||||
|                 #self.clear_display() |                 #self.clear_display() | ||||||
|             self.source_list_remove(event.subject) |             self.source_list_remove(event.subject) | ||||||
|             gtk.gdk.threads_leave() |             gtk.gdk.threads_leave() | ||||||
| @@ -2334,7 +2334,7 @@ class MonitorWidgets: | |||||||
|             self.clear_display() |             self.clear_display() | ||||||
|         elif self.data_pool is None or new_data_name not in self.data_pool: |         elif self.data_pool is None or new_data_name not in self.data_pool: | ||||||
|             none_iter=self.source_list_find([u'None']) |             none_iter=self.source_list_find([u'None']) | ||||||
| 	    if none_iter is not None: self.display_source_combobox.set_active_iter(none_iter) |             if none_iter is not None: self.display_source_combobox.set_active_iter(none_iter) | ||||||
|             self.display_source_path_label.set_label(u"") |             self.display_source_path_label.set_label(u"") | ||||||
|         else: |         else: | ||||||
|             new_data_struct=self.data_pool[new_data_name] |             new_data_struct=self.data_pool[new_data_name] | ||||||
| @@ -2538,7 +2538,7 @@ class MonitorWidgets: | |||||||
|             # Autoscaling activated? |             # Autoscaling activated? | ||||||
|             elif self.display_autoscaling_checkbutton.get_active(): |             elif self.display_autoscaling_checkbutton.get_active(): | ||||||
|  |  | ||||||
| 		xlim_min, xlim_max=self.matplot_axes.get_xlim() |                 xlim_min, xlim_max=self.matplot_axes.get_xlim() | ||||||
|                 if xlim_min!= xmin or xlim_max!=xmax : |                 if xlim_min!= xmin or xlim_max!=xmax : | ||||||
|                     self.matplot_axes.set_xlim(xmin, xmax) |                     self.matplot_axes.set_xlim(xmin, xmax) | ||||||
|  |  | ||||||
| @@ -2620,26 +2620,25 @@ class MonitorWidgets: | |||||||
|                 self.matplot_axes.set_ylabel("") |                 self.matplot_axes.set_ylabel("") | ||||||
|  |  | ||||||
|             # Any  variables to be set? |             # Any  variables to be set? | ||||||
| #            if False: | #           if False: | ||||||
| #				if isinstance(in_result, Accumulation): | #			    if isinstance(in_result, Accumulation): | ||||||
| #					descriptions = in_result.common_descriptions | #			    	descriptions = in_result.common_descriptions | ||||||
| #				elif isinstance(in_result, ADC_Result): | #			    elif isinstance(in_result, ADC_Result): | ||||||
| #					descriptions = in_result.description | #			    	descriptions = in_result.description | ||||||
| 		#	    else: pass | #        	       else: pass | ||||||
| 		#	    actual_config = self.config.get() | #        	       actual_config = self.config.get() | ||||||
| #				if (descriptions is not None) : #--markusro | #			    if (descriptions is not None) : #--markusro | ||||||
| 			#		print actual_config['pretty_descriptions'] | #               	print actual_config['pretty_descriptions'] | ||||||
| 			#		pass | #               		pass | ||||||
| #					description_string = "" | #			    	description_string = "" | ||||||
| #					for key in descriptions.keys(): | #			    	for key in descriptions.keys(): | ||||||
| #						description_string += "%s = %s\n" % (key,descriptions[key]) | #			    		description_string += "%s = %s\n" % (key,descriptions[key]) | ||||||
| #						self.matplot_axes.text(0.7,0.95, description_string[:-1], | #			    		self.matplot_axes.text(0.7,0.95, description_string[:-1], | ||||||
| #												size=8, | #			    								size=8, | ||||||
| #												transform=self.matplot_axes.transAxes, | #			    								transform=self.matplot_axes.transAxes, | ||||||
| #												va='top', | #			    								va='top', | ||||||
| #												backgroundcolor='white') | #			    								backgroundcolor='white') | ||||||
| # | # | ||||||
|  |  | ||||||
|             # Draw it! |             # Draw it! | ||||||
|             self.matplot_canvas.draw_idle() |             self.matplot_canvas.draw_idle() | ||||||
|             del in_result |             del in_result | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user