src/statistics/time_threshold.c
photon_time_threshold_t *photon_time_threshold_alloc(size_t const queue_size) {
	photon_time_threshold_t *ptt = NULL;

	ptt = (photon_time_threshold_t *)malloc(sizeof(photon_time_threshold_t));

	if ( ptt == NULL ) {
		return(ptt);
	}

	ptt->photons = photon_stream_alloc(MODE_T3);
	ptt->numbers = number_to_channels_alloc(queue_size);

	if ( ptt->photons == NULL || ptt->numbers == NULL ) {
		photon_time_threshold_free(&ptt);
	}

	return(ptt);
}
/*
This code is designed to take an incoming stream of t3 photons, filter for
two-photon events, then divide those events into two groups based on whether
the first photon arrived before or after the specifed time.

This implements the following algorithm:
--------------------------------------------------------------------------------
held = None

for photon in filter(lambda p: p.channel in [1, 2], 
                     number_to_channels(photons)):
    if photon.channel == 1:
        held = photon
        if held.time < threshold:
            held.channel = 0
        else:
            held.channel = 2
    else:
        photon.channel = held.channel + 1
        yield(held)
        yield(photon)
 */
This code is designed to take an incoming stream of t3 photons, filter for
two-photon events, then divide those events into two groups based on whether
the first photon arrived before or after the specifed time.

This implements the following algorithm.

held = None


This code is designed to take an incoming stream of t3 photons filter for two - photon events then divide those events into two groups based on whether the first photon arrived before or after the specifed time . This implements the following algorithm . held = None
photon_time_threshold_t *photon_time_threshold_alloc(size_t const queue_size) {
	photon_time_threshold_t *ptt = NULL;
	ptt = (photon_time_threshold_t *)malloc(sizeof(photon_time_threshold_t));
	if ( ptt == NULL ) {
		return(ptt);
	}
	ptt->photons = photon_stream_alloc(MODE_T3);
	ptt->numbers = number_to_channels_alloc(queue_size);
	if ( ptt->photons == NULL || ptt->numbers == NULL ) {
		photon_time_threshold_free(&ptt);
	}
	return(ptt);
}
photon_time_threshold_t * photon_time_threshold_alloc ( size_t const queue_size ) { photon_time_threshold_t * ptt = NULL ; ptt = ( photon_time_threshold_t * ) malloc ( sizeof ( photon_time_threshold_t ) ) ; if ( ptt == NULL ) { return ( ptt ) ; } ptt -> photons = photon_stream_alloc ( MODE_T3 ) ; ptt -> numbers = number_to_channels_alloc ( queue_size ) ; if ( ptt -> photons == NULL || ptt -> numbers == NULL ) { photon_time_threshold_free ( & ptt ) ; } return ( ptt ) ; }
This code is designed to take an incoming stream of t3 photons, filter for
two-photon events, then divide those events into two groups based on whether
the first photon arrived before or after the specifed time.
This code is designed to take an incoming stream of t3 photons filter for two - photon events then divide those events into two groups based on whether the first photon arrived before or after the specifed time .