Temperture dialog works now, fixes T7
This commit is contained in:
parent
2b254f2ee6
commit
c49a752ebd
@ -1,28 +1,33 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import re
|
import re
|
||||||
from PyQt4.QtGui import QInputDialog
|
from PyQt4.QtGui import QInputDialog
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
class FileReader:
|
class FileReader:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read_datafile( path ):
|
def read_datafile( path ):
|
||||||
# TODO analyze file (LF,MF, HF) and act accordingly
|
# TODO analyze file (LF,MF, HF) and act accordingly
|
||||||
|
print "Skipping first 4 lines!"
|
||||||
data = np.loadtxt(path, skiprows=4)
|
data = np.loadtxt(path, skiprows=4)
|
||||||
numpat = re.compile('\d+\.\d+')
|
numpat = re.compile('\d+\.\d+')
|
||||||
|
print "successfully read %s"%path
|
||||||
try:
|
try:
|
||||||
Temp = None
|
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):
|
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
|
print line
|
||||||
Temp = float(re.search(numpat, line).group())
|
Temp = float(re.search(numpat, line).group())
|
||||||
print "Temperature found in file:", Temp
|
print "Temperature found in file:", Temp
|
||||||
break
|
break
|
||||||
|
print "Search temperature in file name %s (float +'K')"%path
|
||||||
search_temp_in_filename = re.search('\d+\.\d+K', path)
|
search_temp_in_filename = re.search('\d+\.\d+K', path)
|
||||||
if search_temp_in_filename:
|
if search_temp_in_filename:
|
||||||
Temp = float(search_temp_in_filename.group()[:-1])
|
Temp = float(search_temp_in_filename.group()[:-1])
|
||||||
if Temp == None: raise ValueError
|
if Temp == None: raise ValueError
|
||||||
except:
|
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 the data to values > 0 (loglog plot)
|
||||||
mask = (data[:, 1] > 0) & (data[:, 2] > 0) # & (data[:,2]>1e-3) & (data[:,0] > 1e-2)
|
mask = (data[:, 1] > 0) & (data[:, 2] > 0) # & (data[:,2]>1e-3) & (data[:,0] > 1e-2)
|
||||||
_freq = data[mask, 0]
|
_freq = data[mask, 0]
|
||||||
|
Loading…
Reference in New Issue
Block a user