def data_from_file(filepath, do_filter_ofls=True, do_filter_crap=True, ch0_lastbin=700, ch1_lastbin=700, **kw): t0 = time.clock() d = np.load(filepath) raw = d['data'].astype(np.uint) d.close() print "Loading the data took %.2f seconds" % (time.clock() - t0) data = decode(raw) if do_filter_ofls: data = hhopt.filter_overflows(data.copy()) if ch0_lastbin != None: data = filter_timewindow(data, 0, 0, ch0_lastbin) if ch1_lastbin != None: data = filter_timewindow(data, 1, 0, ch1_lastbin) if do_filter_crap: data = hhopt.filter_decreasing_syncs(data) data = hhopt.filter_counts_on_marker(data, mchan=1, delta_syncs=np.array([1, 2], dtype=np.uintc)) return data
def data_from_file(filepath, do_filter_ofls=True, do_filter_crap=True, ch0_lastbin=700, ch1_lastbin=700, **kw): t0 = time.clock() d = np.load(filepath) raw = d['data'].astype(np.uint) d.close() print "Loading the data took %.2f seconds"%(time.clock()-t0) data = decode(raw) if do_filter_ofls: data = hhopt.filter_overflows(data.copy()) if ch0_lastbin != None: data = filter_timewindow(data, 0, 0, ch0_lastbin) if ch1_lastbin != None: data = filter_timewindow(data, 1, 0, ch1_lastbin) if do_filter_crap: data = hhopt.filter_decreasing_syncs(data) data = hhopt.filter_counts_on_marker(data, mchan = 1, delta_syncs = np.array([1,2], dtype = np.uintc)) return data
def filter_raw_antibunch_data(rawdata, ch0_lastbin, ch1_lastbin, filter_on_double_clicks = True): if len(rawdata) != 0: data = decode(rawdata) if len(data) != 0: data = hhopt.filter_overflows(data.copy()) #if len(data) != 0: # data = filter_timewindow(data, 0, 0, ch0_lastbin) #if len(data) != 0: # data = filter_timewindow(data, 1, 0, ch1_lastbin) if len(data) != 0: data = hhopt.filter_decreasing_syncs(data) if filter_on_double_clicks and len(data) != 0: data = hhopt.filter_double_clicks_per_sync(data) else: data = np.zeros((0,4), dtype = np.uintc) return data
def filter_raw_antibunch_data(rawdata, ch0_lastbin, ch1_lastbin, filter_on_double_clicks=True): if len(rawdata) != 0: data = decode(rawdata) if len(data) != 0: data = hhopt.filter_overflows(data.copy()) #if len(data) != 0: # data = filter_timewindow(data, 0, 0, ch0_lastbin) #if len(data) != 0: # data = filter_timewindow(data, 1, 0, ch1_lastbin) if len(data) != 0: data = hhopt.filter_decreasing_syncs(data) if filter_on_double_clicks and len(data) != 0: data = hhopt.filter_double_clicks_per_sync(data) else: data = np.zeros((0, 4), dtype=np.uintc) return data
def filter_raw_data(rawdata, sync_offset, do_filter_ofls=True, do_filter_crap=True, do_filter_counts_on_mrkr=True, ch0_lastbin=700, ch1_lastbin=700, marker_chan=1, dsyncs=np.array([1, 2], dtype=np.uintc)): """ Filters raw data, coming from the HydraHarp. The filters applied here are common for an LDE-type experiment, but can be switched on/off individually to meet the demands of the current experiment. A sync offset must be provided to keep track off the sync number. To switch the individual filters on and off use: do_filter_ofls = (True)/False do_filter_crap = (True)/False do_filter_counts_on_mrkr = (True)/False , additional options: marker_chan = (1) dsyncs = (np.array([1,2])) (check for clicks that are 1 or 2 syncs separated from a measurement marker) To switch on/off time filtering on both channels use the following ch0_lastbin = (700)/None ch1_lastbin = (700)/None """ if len(rawdata) != 0: data = decode(rawdata.astype(np.uintc)) sync_nr = data[-1, 0] + 1 print len(data) # print data # TODO: This loop seems weird to me. rewrite that. while len(data) != 0: #apply all the filtering here; we jump out of the while loop if there are no #events left to filter, or if the filter routine is complete. if do_filter_ofls: data = hhopt.filter_overflows(data.copy(), ofl_offset=sync_offset) if len(data) == 0: break if ch0_lastbin != None: data = filter_timewindow(data, 0, 0, ch0_lastbin) if len(data) == 0: break if ch1_lastbin != None: data = filter_timewindow(data, 1, 0, ch1_lastbin) if len(data) == 0: break if do_filter_crap: data = hhopt.filter_decreasing_syncs(data) if len(data) == 0: break if do_filter_counts_on_mrkr: data = hhopt.filter_counts_on_marker(data, mchan=np.int(marker_chan), delta_syncs=dsyncs.astype( np.uintc)) break else: data = np.empty((0, 4), dtype=np.uintc) sync_nr = sync_offset # print "No data to be filtered!" return data, sync_nr
def filter_raw_data(rawdata, sync_offset, do_filter_ofls = True, do_filter_crap = True, do_filter_counts_on_mrkr = True, ch0_lastbin = 700, ch1_lastbin = 700, marker_chan = 1, dsyncs = np.array([1,2], dtype = np.uintc)): """ Filters raw data, coming from the HydraHarp. The filters applied here are common for an LDE-type experiment, but can be switched on/off individually to meet the demands of the current experiment. A sync offset must be provided to keep track off the sync number. To switch the individual filters on and off use: do_filter_ofls = (True)/False do_filter_crap = (True)/False do_filter_counts_on_mrkr = (True)/False , additional options: marker_chan = (1) dsyncs = (np.array([1,2])) (check for clicks that are 1 or 2 syncs separated from a measurement marker) To switch on/off time filtering on both channels use the following ch0_lastbin = (700)/None ch1_lastbin = (700)/None """ if len(rawdata) != 0: data = decode(rawdata.astype(np.uintc)) sync_nr = data[-1,0]+1 print len(data) # print data # TODO: This loop seems weird to me. rewrite that. while len(data) != 0: #apply all the filtering here; we jump out of the while loop if there are no #events left to filter, or if the filter routine is complete. if do_filter_ofls: data = hhopt.filter_overflows(data.copy(), ofl_offset = sync_offset) if len(data) == 0: break if ch0_lastbin != None: data = filter_timewindow(data, 0, 0, ch0_lastbin) if len(data) == 0: break if ch1_lastbin != None: data = filter_timewindow(data, 1, 0, ch1_lastbin) if len(data) == 0: break if do_filter_crap: data = hhopt.filter_decreasing_syncs(data) if len(data) == 0: break if do_filter_counts_on_mrkr: data = hhopt.filter_counts_on_marker(data, mchan = np.int(marker_chan), delta_syncs = dsyncs.astype(np.uintc)) break else: data = np.empty((0,4), dtype = np.uintc) sync_nr = sync_offset # print "No data to be filtered!" return data, sync_nr