From d54fe7c1f704a63824c5bfa0ece65245572e9b27 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 4 Mar 2015 21:21:30 -0500 Subject: Initial commit --- src/libcf/cf_fifo_dead_time.c | 164 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 src/libcf/cf_fifo_dead_time.c (limited to 'src/libcf/cf_fifo_dead_time.c') diff --git a/src/libcf/cf_fifo_dead_time.c b/src/libcf/cf_fifo_dead_time.c new file mode 100644 index 0000000..67ac065 --- /dev/null +++ b/src/libcf/cf_fifo_dead_time.c @@ -0,0 +1,164 @@ +/***************************************************************************** + * Johns Hopkins University + * Center For Astrophysical Sciences + * FUSE + ***************************************************************************** + * + * Synopsis: cf_fifo_dead_time(fitsfile *header, long nevents, + * float *ptime, long nseconds, float *ttime, float *aic_rate, + * float *ids_dtc) + * + * Description: Searches high-count-rate observations for data drop-outs + * due to FIFO overflows. If found, calculates time-dependent + * scale factor to correct for lost photon events. + * + * Arguments: fitsfile *header Pointer to FITS file containing the + * header of the intermediate data file + * long nevents Number of photon events in the file + * float *ptime Detection time for each photon + * long nseconds The number of timeline values + * float *ttime Tabulated times in the timeline + * float *aic_rate Active Image Counter array + * float *ids_dtc IDS dead-time correction array + * (modified) + * + * Calls: + * + * Return: 0 on success + * + * History of cf_screen_fifo_overflow: + * + * 02/10/04 1.1 wvd Begin work + * 02/17/05 1.2 wvd Place parentheses around assignment + * used as truth value. + * 11/09/05 1.3 wvd In the current scheme, the rate_lif + * and rate_sic arrays contain values + * from the housekeeping file and do + * not reflect data loss due to FIFO + * overflows. Now we calculate the + * count-rate array directly from the + * photon time array. + * 02/23/06 1.4 wvd Change length of data_rate array + * from nevents to nseconds. + * + * History: 12/29/06 1.1 wvd Derived from cf_screen_fifo_overflow. + * 01/15/07 1.2 wvd When count rate is zero, correct one + * second before to two seconds after. + * 02/08/07 1.3 wvd If TTPERIOD = 0, set it to 1. + * 04/07/07 1.4 wvd Clean up compiler warnings. + * + ****************************************************************************/ + +#include +#include "calfuse.h" + +int +compute_count_rate(long nevents, float *ptime, long nseconds, + float *ttime, long **data_rate) +{ + float delta_max = 1.0 + FRAME_TOLERANCE; + long j,k; + + *data_rate = (long *) cf_calloc(nseconds, sizeof(long)); + for (j=k=0; j 3200, look for data drop-outs. */ + if (mean_ids_rate > 3200 && nseconds > 4) { + compute_count_rate(nevents, ptime, nseconds, ttime, &data_rate); + flag_array = (int *) cf_calloc(nseconds, sizeof(int)); + + /* If count rate goes to zero, set flag_array. Where possible, + set flags from one second before to two seconds after. */ + for (k=0; k<1; k++) if (data_rate[k] == 0) + flag_array[k] = flag_array[k+1] = flag_array[k+2] = TRUE; + + for ( ; k