return string.join(a[start:(len(a)-back)], "/")
def GetData(filename, key=1):
+
+ if type(filename) != type(""):
+ if type(filename) == type([]):
+ return filename
+ else:
+ return [[0,0,0,0]]
+
+
+ if os.path.isdir(filename):
+ if os.path.exists(filename.strip("/")+"/average.dat"):
+ os.remove(filename.strip("/")+"/average.dat")
+ AverageAllData(filename)
+ return GetData(filename.strip("/")+"/average.dat")
+
input_file = open(filename, "r")
data = {}
for line in input_file:
def DoNothing(data):
return data
-def AverageAllDataSets(directory=".", function=DoNothing):
- dirs = {}
- for f in os.listdir(directory):
- if os.path.isdir(directory+"/"+str(f)) == True:
- data_set = []
- for datafile in os.listdir(directory+"/"+str(f)):
- if datafile.split(".")[1] == "dat":
- data_set.append(GetData(f))
-
- avg = Average(data_set)
- dirs.update({f : avg})
- return dirs
def GetDataSets(directory="."):
data_sets = []
if (len(data) <= 0):
return result
maxval = max(data, key = lambda e : e[u])[u]
+
+ if maxval == 0:
+ return result
for d in result:
d[u] = d[u] / maxval
out.write("\t")
out.write("\n")
-def AverageAllData(directory, save=None):
+def AverageAllData(directory, save=None, normalise=True):
data_sets = []
if save == None: save = directory+"/average.dat"
- for d in FindDataFiles(directory):
- data_sets.append(GetData(d))
+ for f in FindDataFiles(directory):
+ d = GetData(f)
+ if normalise:
+ d = MaxNormalise(d)
+ data_sets.append(d)
a = Average(data_sets)
SaveData(save, a)
if sys.argv[i] == "--raw":
plotFunc = ShowData
elif sys.argv[i] == "--tcs":
- plotFunc = ShowTCS
+ plotFunc = lambda e : ShowTCS(e, show_peak=False)
elif sys.argv[i] == "--output":
if i+1 >= len(sys.argv):
sys.stderr.write("Need argument for "+sys.argv[i]+" switch\n")