From c49a752ebd6f7a83d39472ccbb99a25d3f580b41 Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Tue, 5 Jul 2016 11:55:55 +0200 Subject: [PATCH] Temperture dialog works now, fixes T7 --- src/fileio/bds_file_reader.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fileio/bds_file_reader.py b/src/fileio/bds_file_reader.py index 392c607..4e2d8a9 100644 --- a/src/fileio/bds_file_reader.py +++ b/src/fileio/bds_file_reader.py @@ -1,28 +1,33 @@ import numpy as np import re from PyQt4.QtGui import QInputDialog +from PyQt4 import QtCore class FileReader: @staticmethod def read_datafile( path ): # TODO analyze file (LF,MF, HF) and act accordingly + print "Skipping first 4 lines!" data = np.loadtxt(path, skiprows=4) numpat = re.compile('\d+\.\d+') + print "successfully read %s"%path try: Temp = None - for line in open(path).readlines(): + for i,line in enumerate(open(path).readlines()): + print "Searching for temperature in %s (Line with 'Fixed or 'Temp', with float, i.e. 273.15K or 273.15)"%path if re.search("Fixed", line) or re.search("Temp", line): - print "Found line containing 'Fixed' or 'Temp':" + print "Found line containing 'Fixed' or 'Temp' (line %i):"%i print line Temp = float(re.search(numpat, line).group()) print "Temperature found in file:", Temp break + print "Search temperature in file name %s (float +'K')"%path search_temp_in_filename = re.search('\d+\.\d+K', path) if search_temp_in_filename: Temp = float(search_temp_in_filename.group()[:-1]) if Temp == None: raise ValueError except: - Temp = QInputDialog.getDouble( "No temperature found in data set", "Temperature/K:", value=0.00)[0] + Temp = QInputDialog.getDouble(None, "No temperature found in data set", "Temperature/K:", value=0.00)[0] # mask the data to values > 0 (loglog plot) mask = (data[:, 1] > 0) & (data[:, 2] > 0) # & (data[:,2]>1e-3) & (data[:,0] > 1e-2) _freq = data[mask, 0]