fixed evil tab/spaces
This commit is contained in:
parent
059c059de7
commit
aed38c1c89
@ -5,9 +5,14 @@ import autophase
|
||||
class DamarisFFT:
|
||||
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.
|
||||
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
|
||||
if start > stop:
|
||||
@ -15,12 +20,12 @@ class DamarisFFT:
|
||||
# TODO swap values?
|
||||
raise
|
||||
# if one uses clip as a "placeholder"
|
||||
if start==None and stop==None:
|
||||
if start == None and stop == None:
|
||||
return self
|
||||
|
||||
if start==None:
|
||||
if start == None:
|
||||
start = 0
|
||||
if stop==None:
|
||||
if stop == None:
|
||||
stop = -1
|
||||
# check if data is fft which changes the start/stop units
|
||||
# TODO should get nicer(failsafe), i.e. flags in the object?
|
||||
@ -50,12 +55,14 @@ class DamarisFFT:
|
||||
Correct the baseline of your data by subtracting the mean of the
|
||||
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
|
||||
"""
|
||||
# TODO baselinecorrection for spectra after:
|
||||
# Heuer, A; Haeberlen, U.: J. Mag. Res.(1989) 85, Is 1, 79-94
|
||||
# Heuer, A; Haeberlen, U.: J. Mag. Res.(1989) 85, Is 1, 79-94
|
||||
# Should I create an empty object?
|
||||
# I deided to do NOT a copy, but
|
||||
# I deided to do NOT a copy, but
|
||||
# rather modify the object
|
||||
n = int(self.x.size*last_part)
|
||||
for ch in xrange(len(self.y)):
|
||||
@ -80,7 +87,14 @@ class DamarisFFT:
|
||||
"""
|
||||
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)
|
||||
for i in range(2):
|
||||
|
@ -567,7 +567,7 @@ class DamarisGUI:
|
||||
extensions_dict["res"]="unnamed"
|
||||
else:
|
||||
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:
|
||||
self.dump_filename=actual_config.get("data_pool_name")%extensions_dict
|
||||
except ValueError,e:
|
||||
@ -580,7 +580,7 @@ class DamarisGUI:
|
||||
print "The dump filename is a directory, using filename '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)
|
||||
if self.dump_complib=="None":
|
||||
self.dump_complib=None
|
||||
@ -589,7 +589,7 @@ class DamarisGUI:
|
||||
else:
|
||||
self.dump_complevel=0
|
||||
|
||||
# time interval
|
||||
# time interval
|
||||
self.dump_timeinterval=60*60*10
|
||||
try:
|
||||
self.dump_timeinterval=int(60*float(actual_config["data_pool_write_interval"]))
|
||||
@ -621,29 +621,29 @@ class DamarisGUI:
|
||||
# init is finnished now
|
||||
|
||||
# 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 init:
|
||||
print "dump file \"%s\" vanished unexpectedly, creating new one"%self.dump_filename
|
||||
# have a look to the path and create necessary directories
|
||||
dir_stack=[]
|
||||
dir_trunk=os.path.dirname(os.path.abspath(self.dump_filename))
|
||||
while dir_trunk!="" and not os.path.isdir(dir_trunk):
|
||||
dir_stack.append(os.path.basename(dir_trunk))
|
||||
dir_trunk=os.path.dirname(dir_trunk)
|
||||
try:
|
||||
while len(dir_stack):
|
||||
dir_trunk=os.path.join(dir_trunk, dir_stack.pop())
|
||||
if os.path.isdir(dir_trunk): continue
|
||||
os.mkdir(dir_trunk)
|
||||
except OSError, e:
|
||||
print e
|
||||
print "coud not create dump directory '%s', so hdf5 dumps disabled"%dir_trunk
|
||||
self.dump_filename=""
|
||||
self.dump_timeinterval=0
|
||||
return True
|
||||
dir_stack=[]
|
||||
dir_trunk=os.path.dirname(os.path.abspath(self.dump_filename))
|
||||
while dir_trunk!="" and not os.path.isdir(dir_trunk):
|
||||
dir_stack.append(os.path.basename(dir_trunk))
|
||||
dir_trunk=os.path.dirname(dir_trunk)
|
||||
try:
|
||||
while len(dir_stack):
|
||||
dir_trunk=os.path.join(dir_trunk, dir_stack.pop())
|
||||
if os.path.isdir(dir_trunk): continue
|
||||
os.mkdir(dir_trunk)
|
||||
except OSError, e:
|
||||
print e
|
||||
print "coud not create dump directory '%s', so hdf5 dumps disabled"%dir_trunk
|
||||
self.dump_filename=""
|
||||
self.dump_timeinterval=0
|
||||
return True
|
||||
|
||||
# create new dump file
|
||||
# create new dump file
|
||||
dump_file=tables.openFile(self.dump_filename,mode="w",title="DAMARIS experiment data")
|
||||
# write scripts and other useful information
|
||||
scriptgroup=dump_file.createGroup("/","scripts","Used Scripts")
|
||||
@ -674,7 +674,7 @@ class DamarisGUI:
|
||||
title="log messages",
|
||||
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
|
||||
os.rename(self.dump_filename, self.dump_filename+".bak")
|
||||
old_dump_file=tables.openFile(self.dump_filename+".bak", mode="r+")
|
||||
@ -687,13 +687,13 @@ class DamarisGUI:
|
||||
# prepare for update
|
||||
dump_file=tables.openFile(self.dump_filename, mode="r+")
|
||||
|
||||
if dump_file is None:
|
||||
# exit!
|
||||
print "coud not create dump directory '%s', so hdf5 dumps disabled"%dir_trunk
|
||||
self.dump_filename=""
|
||||
self.dump_timeinterval=0
|
||||
return True
|
||||
|
||||
if dump_file is None:
|
||||
# exit!
|
||||
print "coud not create dump directory '%s', so hdf5 dumps disabled"%dir_trunk
|
||||
self.dump_filename=""
|
||||
self.dump_timeinterval=0
|
||||
return True
|
||||
|
||||
# no undo please!
|
||||
if dump_file.isUndoEnabled():
|
||||
dump_file.disableUndo()
|
||||
@ -1207,32 +1207,32 @@ class ScriptWidgets:
|
||||
cursor_mark=textbuffer.get_insert()
|
||||
cursor_iter=textbuffer.get_iter_at_mark(cursor_mark)
|
||||
if textbuffer is self.experiment_script_textbuffer:
|
||||
line_indicator=self.experiment_script_line_indicator
|
||||
column_indicator=self.experiment_script_column_indicator
|
||||
line_indicator=self.experiment_script_line_indicator
|
||||
column_indicator=self.experiment_script_column_indicator
|
||||
if textbuffer is self.data_handling_textbuffer:
|
||||
line_indicator=self.data_handling_line_indicator
|
||||
column_indicator=self.data_handling_column_indicator
|
||||
line_indicator=self.data_handling_line_indicator
|
||||
column_indicator=self.data_handling_column_indicator
|
||||
|
||||
# do only necessary updates!
|
||||
li_range_new=textbuffer.get_end_iter().get_line()+1
|
||||
if line_indicator.get_range()[1]!=li_range_new:
|
||||
line_indicator.set_range(1, li_range_new)
|
||||
ci_range_new=cursor_iter.get_chars_in_line()+1
|
||||
if column_indicator.get_range()[1]!=ci_range_new:
|
||||
column_indicator.set_range(1, ci_range_new)
|
||||
cursor_line=cursor_iter.get_line()+1
|
||||
cursor_lineoffset=cursor_iter.get_line_offset()+1
|
||||
if line_indicator.get_value()!=cursor_line:
|
||||
line_indicator.set_value(cursor_line)
|
||||
if column_indicator.get_value()!=cursor_lineoffset:
|
||||
column_indicator.set_value(cursor_lineoffset)
|
||||
# do only necessary updates!
|
||||
li_range_new=textbuffer.get_end_iter().get_line()+1
|
||||
if line_indicator.get_range()[1]!=li_range_new:
|
||||
line_indicator.set_range(1, li_range_new)
|
||||
ci_range_new=cursor_iter.get_chars_in_line()+1
|
||||
if column_indicator.get_range()[1]!=ci_range_new:
|
||||
column_indicator.set_range(1, ci_range_new)
|
||||
cursor_line=cursor_iter.get_line()+1
|
||||
cursor_lineoffset=cursor_iter.get_line_offset()+1
|
||||
if line_indicator.get_value()!=cursor_line:
|
||||
line_indicator.set_value(cursor_line)
|
||||
if column_indicator.get_value()!=cursor_lineoffset:
|
||||
column_indicator.set_value(cursor_lineoffset)
|
||||
return False
|
||||
|
||||
def textviews_keypress(self, widget, event, data = None):
|
||||
"""
|
||||
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.keyval==gtk.gdk.keyval_from_name("c"):
|
||||
if self.main_notebook.get_current_page() == 0:
|
||||
@ -1344,7 +1344,7 @@ class ScriptWidgets:
|
||||
return 1
|
||||
|
||||
#self.textviews_moved(widget)
|
||||
return 0
|
||||
return 0
|
||||
|
||||
def load_file_as_unicode(self, script_filename):
|
||||
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)
|
||||
for self.system_default_filename in self.system_default_filenames:
|
||||
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)
|
||||
else:
|
||||
print "can not read system defaults from %s, ask your instrument responsible if required"%self.system_default_filename
|
||||
else:
|
||||
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.load_config()
|
||||
@ -2064,7 +2064,7 @@ class MonitorWidgets:
|
||||
def source_list_reset(self):
|
||||
self.display_source_treestore.clear()
|
||||
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)
|
||||
|
||||
def source_list_find_one(self, model, iter, what):
|
||||
@ -2286,8 +2286,8 @@ class MonitorWidgets:
|
||||
self.displayed_data[0]==event.subject):
|
||||
self.displayed_data=[None,None]
|
||||
none_iter=self.source_list_find([u'None'])
|
||||
if none_iter is not None: self.display_source_combobox.set_active_iter(none_iter)
|
||||
# not necessary, because event will be submitted
|
||||
if none_iter is not None: self.display_source_combobox.set_active_iter(none_iter)
|
||||
# not necessary, because event will be submitted
|
||||
#self.clear_display()
|
||||
self.source_list_remove(event.subject)
|
||||
gtk.gdk.threads_leave()
|
||||
@ -2334,7 +2334,7 @@ class MonitorWidgets:
|
||||
self.clear_display()
|
||||
elif self.data_pool is None or new_data_name not in self.data_pool:
|
||||
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"")
|
||||
else:
|
||||
new_data_struct=self.data_pool[new_data_name]
|
||||
@ -2538,7 +2538,7 @@ class MonitorWidgets:
|
||||
# Autoscaling activated?
|
||||
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 :
|
||||
self.matplot_axes.set_xlim(xmin, xmax)
|
||||
|
||||
@ -2620,26 +2620,25 @@ class MonitorWidgets:
|
||||
self.matplot_axes.set_ylabel("")
|
||||
|
||||
# Any variables to be set?
|
||||
# if False:
|
||||
# if isinstance(in_result, Accumulation):
|
||||
# descriptions = in_result.common_descriptions
|
||||
# elif isinstance(in_result, ADC_Result):
|
||||
# descriptions = in_result.description
|
||||
# else: pass
|
||||
# actual_config = self.config.get()
|
||||
# if (descriptions is not None) : #--markusro
|
||||
# print actual_config['pretty_descriptions']
|
||||
# pass
|
||||
# description_string = ""
|
||||
# for key in descriptions.keys():
|
||||
# description_string += "%s = %s\n" % (key,descriptions[key])
|
||||
# self.matplot_axes.text(0.7,0.95, description_string[:-1],
|
||||
# size=8,
|
||||
# transform=self.matplot_axes.transAxes,
|
||||
# va='top',
|
||||
# backgroundcolor='white')
|
||||
# if False:
|
||||
# if isinstance(in_result, Accumulation):
|
||||
# descriptions = in_result.common_descriptions
|
||||
# elif isinstance(in_result, ADC_Result):
|
||||
# descriptions = in_result.description
|
||||
# else: pass
|
||||
# actual_config = self.config.get()
|
||||
# if (descriptions is not None) : #--markusro
|
||||
# print actual_config['pretty_descriptions']
|
||||
# pass
|
||||
# description_string = ""
|
||||
# for key in descriptions.keys():
|
||||
# description_string += "%s = %s\n" % (key,descriptions[key])
|
||||
# self.matplot_axes.text(0.7,0.95, description_string[:-1],
|
||||
# size=8,
|
||||
# transform=self.matplot_axes.transAxes,
|
||||
# va='top',
|
||||
# backgroundcolor='white')
|
||||
#
|
||||
|
||||
# Draw it!
|
||||
self.matplot_canvas.draw_idle()
|
||||
del in_result
|
||||
|
Loading…
Reference in New Issue
Block a user