Inject.h

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Jolien Creighton, Teviet Creighton, John Whelan
00003 *
00004 *  This program is free software; you can redistribute it and/or modify
00005 *  it under the terms of the GNU General Public License as published by
00006 *  the Free Software Foundation; either version 2 of the License, or
00007 *  (at your option) any later version.
00008 *
00009 *  This program is distributed in the hope that it will be useful,
00010 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 *  GNU General Public License for more details.
00013 *
00014 *  You should have received a copy of the GNU General Public License
00015 *  along with with program; see the file COPYING. If not, write to the
00016 *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00017 *  MA  02111-1307  USA
00018 */
00019 
00020 /*************************************** <lalVerbatim file="InjectHV">
00021 Author: Creighton, T. D.
00022 $Id: Inject.h,v 1.9 2007/06/08 14:41:46 bema Exp $
00023 **************************************************** </lalVerbatim> */
00024 
00025 /********************************************************** <lalLaTeX>
00026 
00027 \section{Header \texttt{Inject.h}}
00028 \label{s:Inject.h}
00029 
00030 Provides routines to inject a signal into detector output.
00031 
00032 \subsection*{Synopsis}
00033 \begin{verbatim}
00034 #include <lal/Inject.h>
00035 \end{verbatim}
00036 
00037 This header provides simple routines to inject a signal, stored as a
00038 floating-point time series, into an integer time series that
00039 represents the ADC output of a detector channel.
00040 
00041 The basic concept at work here is that of \emph{dithering}.  That is,
00042 to add a real signal $x(t_k)$ to the integer output $n(t_k)$ of an
00043 ADC, we cannot simply compute $x+n$ at each time $t_k$ and round to
00044 the nearest integer.  To see this, consider injecting a sinusoid with
00045 an amplitude less than half the ADC resolution, $|x|<0.5$.  Then
00046 adding $x+n$ and rounding will always give back $n$, and the signal
00047 injection will have no effect on the output.
00048 
00049 Instead, what we would like to do is to add $x$ to the ADC
00050 \emph{input} before rounding occurs, and then round to an integer.
00051 That is, the ADC input was actually $n+d$, where $d\in[-0.5,0.5)$; we
00052 want to compute the rounded value of $n+d+x$, which may occasionally
00053 be different from $n$.  In principle, a Fourier transforms can detect
00054 a sinusoidal signal with an output much smaller than the ADC
00055 resolution: by integrating enough data, one can eventually detect a
00056 statistically significant phase correlation between the occasional
00057 increments and decrements in $n$.
00058 
00059 Of course given the output time series $n(t_k)$ we can only guess at
00060 the input series $n(t_k)+d(t_k)$ that produced it.  The simplest guess
00061 is to assume that each $d(t_k)$ is an independent random variable with
00062 a flat distribution over the range $[-0.5,0.5)$.  This is a reasonable
00063 guess to make if the root mean square variation between succesive
00064 output values $n$ is a few or more ADC counts; i.e. if the
00065 dimensionless power spectral density $\sqrt{fS(f)}$ has a value of a
00066 few or more around the sampling freqeuncy $f$.  This is almost always
00067 true of any detector designed to work at or near its noise limit: the
00068 input to the ADC will first be whitened so that $\sqrt{fS(f)}$ is
00069 nearly flat, and then amplified so that $\sqrt{fS(f)}$ is on the order
00070 of several (or more) ADC counts.
00071 
00072 In the routines covered by this header we will take it for granted
00073 that the above is a reasonable approximation, and will not check for
00074 it.  We will further assume that the signal to be injected has already
00075 been subjected to the same whitening and amplification, so that the
00076 units of $x(t_k)$ are normalized ADC counts (although it is still a
00077 real number, not an integer).
00078 
00079 The dithering routines should be used whenever one is injecting a
00080 signal into a time series representing raw digitized data.  In some
00081 data storage specifications, ADC output is not stored as an integer,
00082 but as a floating-point number representing an integer value.  Such
00083 data must be cast to integers before being passed to the digitizing
00084 routines.
00085 
00086 This header also provides even simpler routines for injecting a signal
00087 into floating-point data, without dithering.  These should only be
00088 used when the data is genuinely continuous in character.  This can
00089 include data derived by applying floating-point operations on ADC
00090 channels (e.g.\ digital filters, linear combinations of channels,
00091 etc.), but not data that simply represents ADC output in
00092 floating-point format.  The assumption here is that the numerical
00093 post-processing of the ADC data completely masks any statistical
00094 signiatures of the digitization.
00095 
00096 ******************************************************* </lalLaTeX> */
00097 
00098 #ifndef _INJECT_H
00099 #define _INJECT_H
00100 
00101 #include <lal/LALStdlib.h>
00102 #include <lal/Random.h>
00103 
00104 #ifdef  __cplusplus
00105 extern "C" {
00106 #pragma }
00107 #endif
00108 
00109 NRCSID( INJECTH, "$Id: Inject.h,v 1.9 2007/06/08 14:41:46 bema Exp $" );
00110 
00111 /********************************************************** <lalLaTeX>
00112 \subsection*{Error conditions}
00113 ****************************************** </lalLaTeX><lalErrTable> */
00114 #define INJECTH_ENUL  1
00115 #define INJECTH_EBAD  2
00116 #define INJECTH_EUNIT 3
00117 
00118 #define INJECTH_MSGENUL  "Unexpected null pointer in arguments"
00119 #define INJECTH_MSGEBAD  "A sampling interval is (effectively) zero"
00120 #define INJECTH_MSGEUNIT "Input or output is not in units of ADC counts"
00121 /******************************************** </lalErrTable><lalLaTeX>
00122 
00123 \subsection*{Types}
00124 ******************************************************* </lalLaTeX> */
00125 
00126 /* <lalLaTeX>
00127 \vfill{\footnotesize\input{InjectHV}}
00128 </lalLaTeX> */
00129 
00130 
00131 /* Function prototypes. */
00132 
00133 /* <lalLaTeX>
00134 \newpage\input{InjectVectorC}
00135 </lalLaTeX> */
00136 void
00137 LALSI2InjectVector( LALStatus    *,
00138                     INT2Vector   *output,
00139                     REAL4Vector  *signal,
00140                     RandomParams *params );
00141 
00142 void
00143 LALSSInjectVector( LALStatus    *,
00144                    REAL4Vector  *output,
00145                    REAL4Vector  *signal );
00146 
00147 /* <lalLaTeX>
00148 \newpage\input{InjectTimeSeriesC}
00149 </lalLaTeX> */
00150 void
00151 LALSI2InjectTimeSeries( LALStatus       *,
00152                         INT2TimeSeries  *output,
00153                         REAL4TimeSeries *signal,
00154                         RandomParams    *params );
00155 
00156 void
00157 LALSSInjectTimeSeries( LALStatus       *,
00158                        REAL4TimeSeries *output,
00159                        REAL4TimeSeries *signal );
00160 
00161 /* <lalLaTeX>
00162 \newpage\input{BasicInjectTestC}
00163 \newpage\input{InjectTestC}
00164 </lalLaTeX> */
00165 
00166 #ifdef  __cplusplus
00167 #pragma {
00168 }
00169 #endif
00170 
00171 #endif /* _INJECT_H */

Generated on Sun Sep 7 03:06:49 2008 for LAL by  doxygen 1.5.2