def process_incoming_data(self, chdata, tsdata, sync_offset, marker_number,
                              dsyncs = np.array([1,2], dtype = np.uintc)):
        """
        Filter routine for the raw data that comes in during a measurement.
        Note that this is quite identical to the function hht4.filter_raw_data 
        However, we don't need to take care of filter_overflows anymore. Also, because
        I create the sync numbers artificially, there are no decreasing sync numbers in the
        beginning of the measurements. To check for this problem, we can check if there
        is a negative time jump in the time stamp data. 
        """

        if self.check_for_decreasing_timestamps(tsdata):
            error_out = False
            pass
        else:
            error_out = True

        data, sync_offset = self.decode_data(chdata, tsdata, sync_offset)
        while len(data) > 0:
            #Now we can just use the HydraHarp TTTR module.
            data = hht4.filter_timewindow(data, self.apd1_chan, self.minbinch1, self.maxbinch1)
            data = hht4.filter_timewindow(data, self.apd2_chan, self.minbinch2, self.maxbinch2)
            data = hhopt.filter_counts_on_marker(data, mchan = marker_number,
                        delta_syncs = dsyncs.astype(np.uintc))

            break

        return data, error_out, sync_offset
Пример #2
0
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
Пример #3
0
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
Пример #4
0
    def process_incoming_data(self,
                              chdata,
                              tsdata,
                              sync_offset,
                              marker_number,
                              dsyncs=np.array([1, 2], dtype=np.uintc)):
        """
        Filter routine for the raw data that comes in during a measurement.
        Note that this is quite identical to the function hht4.filter_raw_data 
        However, we don't need to take care of filter_overflows anymore. Also, because
        I create the sync numbers artificially, there are no decreasing sync numbers in the
        beginning of the measurements. To check for this problem, we can check if there
        is a negative time jump in the time stamp data. 
        """

        if self.check_for_decreasing_timestamps(tsdata):
            error_out = False
            pass
        else:
            error_out = True

        data, sync_offset = self.decode_data(chdata, tsdata, sync_offset)
        while len(data) > 0:
            #Now we can just use the HydraHarp TTTR module.
            data = hht4.filter_timewindow(data, self.apd1_chan, self.minbinch1,
                                          self.maxbinch1)
            data = hht4.filter_timewindow(data, self.apd2_chan, self.minbinch2,
                                          self.maxbinch2)
            data = hhopt.filter_counts_on_marker(data,
                                                 mchan=marker_number,
                                                 delta_syncs=dsyncs.astype(
                                                     np.uintc))

            break

        return data, error_out, sync_offset
Пример #5
0
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
Пример #6
0
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