diff --git a/scripts/checkPulseData.py b/scripts/checkPulseData.py index 7bd16a8..e0d9ad7 100644 --- a/scripts/checkPulseData.py +++ b/scripts/checkPulseData.py @@ -62,9 +62,6 @@ def prune(x): - #for element in x: - # if element is None: - # x.remove(element) return [element for element in x if element is not None] @@ -95,7 +92,18 @@ return self.substituted_str +class Table(dict): + def __init__(self, *keylist): + super(dict, self).__init__() + self.__keylist = keylist + for key in keylist: + self[key] = [] + + def append(self, *vals): + assert(len(vals) == len(self.__keylist)) + for i, v in enumerate(vals): + self[self.__keylist[i]].append(v) if __name__ == '__main__': @@ -141,7 +149,15 @@ 'N strips', 'V bias', 'MPVs']) - + # dic = {'Detector': [], + # 'Sector': [], + # 'Fill': [], + # 'N strips': [], + # 'V bias': [], + # 'MPVs': []} + + table = Table('Detector', 'Sector', 'Fill', 'N strips', 'V bias', 'MPVs') + # Loop on data for fill in fills: for sector in sectors: @@ -163,17 +179,20 @@ SEC=sector, CS=cstep)) pulse.append(None) - #pulse = build_pulse(pulse) - if monotonic(build_pulse(pulse)): + pulse = build_pulse(pulse) + if monotonic(pulse): # Append this occurrence to the data frame # Probably it would be faster to do as suggested here: # http://stackoverflow.com/a/17496530/3324012 - data_frame.loc[len(data_frame)] = [detector, - sector, - fill, - ns, - vmap[vstep], - pulse] + # data_frame.loc[len(data_frame)] = [detector, + # sector, + # fill, + # ns, + # vmap[vstep], + # pulse] + + table.append(detector, sector, fill, ns, vmap[vstep], pulse) + if VERBOSE: pulse = [round(v,2) for v in pulse] print(warning.format(NS=ns, @@ -182,4 +201,6 @@ V=vmap[vstep], PULSE=pulse)) - # datafile.Close() + datafile.Close() + # data_frame[data_frame['MPVs'].apply(monotonic)] + data_frame = pd.DataFrame.from_dict(table)