00001 /* 00002 * Copyright (C) 2005 Reinhard Prix 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 /** 00021 * \author Reinhard Prix 00022 * \date 2005 00023 * \file 00024 * \ingroup pulsar 00025 * \brief Header-file defining the API for the F-statistic functions. 00026 * 00027 * This code is (partly) a descendant of an earlier implementation found in 00028 * LALDemod.[ch] by Jolien Creighton, Maria Alessandra Papa, Reinhard Prix, Steve Berukoff, Xavier Siemens, Bruce Allen 00029 * ComputSky.[ch] by Jolien Creighton, Reinhard Prix, Steve Berukoff 00030 * LALComputeAM.[ch] by Jolien Creighton, Maria Alessandra Papa, Reinhard Prix, Steve Berukoff, Xavier Siemens 00031 * 00032 * $Id: ComputeFstat.h,v 1.46 2008/10/01 21:29:47 reinhard Exp $ 00033 * 00034 */ 00035 00036 #ifndef _COMPUTEFSTAT_H /* Double-include protection. */ 00037 #define _COMPUTEFSTAT_H 00038 00039 /* C++ protection. */ 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 #include <lal/LALRCSID.h> 00045 NRCSID( COMPUTEFSTATH, "$Id: ComputeFstat.h,v 1.46 2008/10/01 21:29:47 reinhard Exp $" ); 00046 00047 /*---------- exported INCLUDES ----------*/ 00048 #include <lal/LALComputeAM.h> 00049 #include <lal/PulsarDataTypes.h> 00050 #include <lal/DetectorStates.h> 00051 00052 /*---------- exported DEFINES ----------*/ 00053 00054 /*----- Error-codes -----*/ 00055 #define COMPUTEFSTATC_ENULL 1 00056 #define COMPUTEFSTATC_ENONULL 2 00057 #define COMPUTEFSTATC_EINPUT 3 00058 #define COMPUTEFSTATC_EMEM 4 00059 #define COMPUTEFSTATC_EXLAL 5 00060 #define COMPUTEFSTATC_EIEEE 6 00061 00062 #define COMPUTEFSTATC_MSGENULL "Arguments contained an unexpected null pointer" 00063 #define COMPUTEFSTATC_MSGENONULL "Output pointer is non-NULL" 00064 #define COMPUTEFSTATC_MSGEINPUT "Invalid input" 00065 #define COMPUTEFSTATC_MSGEMEM "Out of memory. Bad." 00066 #define COMPUTEFSTATC_MSGEXLAL "XLAL function call failed" 00067 #define COMPUTEFSTATC_MSGEIEEE "Floating point failure" 00068 00069 /*---------- exported types ----------*/ 00070 00071 /** Simple container for two REAL8-vectors, namely the SSB-timings DeltaT_alpha and Tdot_alpha, 00072 * with one entry per SFT-timestamp. These are required input for XLALNewDemod(). 00073 * We also store the SSB reference-time tau0. 00074 */ 00075 typedef struct { 00076 LIGOTimeGPS refTime; 00077 REAL8Vector *DeltaT; /**< Time-difference of SFT-alpha - tau0 in SSB-frame */ 00078 REAL8Vector *Tdot; /**< dT/dt : time-derivative of SSB-time wrt local time for SFT-alpha */ 00079 } SSBtimes; 00080 00081 /** Multi-IFO container for SSB timings */ 00082 typedef struct { 00083 UINT4 length; /**< number of IFOs */ 00084 SSBtimes **data; /**< array of SSBtimes (pointers) */ 00085 } MultiSSBtimes; 00086 00087 00088 /** Struct holding the "antenna-pattern" matrix \f$\mathcal{M}_{\mu\nu} \equiv \left( \mathbf{h}_\mu|\mathbf{h}_\nu\right)\f$, 00089 * in terms of the multi-detector scalar product. This matrix can be shown to be expressible as 00090 * \f{equation} 00091 * \mathcal{M}_{\mu\nu} = \mathcal{S}^{-1}\,T_\mathrm{SFT}\,\left( \begin{array}{c c} A_d & C_d \\ C_d & B_d \\\end{array}\right)\,, 00092 * \f} 00093 * where (here) \f$\mathcal{S} \equiv \frac{1}{N_\mathrm{SFT}}\sum_{X,\alpha} S_{X\alpha}\f$ characterizes the multi-detector noise-floor, and 00094 * \f{equation} 00095 * A_d \equiv \sum_{X,\alpha} \widehat{a}^X_\alpha \widehat{a}^X_\alpha\,,\quad 00096 * B_d \equiv \sum_{X,\alpha} \widehat{b}^X_\alpha \widehat{b}^X_\alpha \,,\quad 00097 * C_d \equiv \sum_{X,\alpha} \widehat{a}^X_\alpha \widehat{b}^X_\alpha \,, 00098 * \f} 00099 * and the noise-weighted atenna-functions \f$\widehat{a}^X_\alpha = \sqrt{w^X_\alpha}\,a^X_\alpha\f$, 00100 * \f$\widehat{b}^X_\alpha = \sqrt{w^X_\alpha}\,b^X_\alpha\f$, and noise-weights 00101 * \f$w^X_\alpha \equiv {S^{-1}_{X\alpha}/{\mathcal{S}^{-1}}\f$. 00102 * 00103 * \note One reason for storing the un-normalized \a Ad, \a Bd, \a Cd and the normalization-factor \a Sinv_Tsft separately 00104 * is that the former are of order unity, while \a Sinv_Tsft is very large, and it has numerical advantages for parameter-estimation 00105 * to use that fact. 00106 */ 00107 typedef struct { 00108 REAL8 Ad; /**< \f$A_d \equiv \sum_{X,\alpha} \widehat{a}^X_\alpha \widehat{a}^X_\alpha\f$ */ 00109 REAL8 Bd; /**< \f$B_d \equiv \sum_{X,\alpha} \widehat{b}^X_\alpha \widehat{b}^X_\alpha\f$ */ 00110 REAL8 Cd; /**< \f$C_d \equiv \sum_{X,\alpha} \widehat{a}^X_\alpha \widehat{b}^X_\alpha\f$ */ 00111 REAL8 Dd; /**< determinant \f$D_d \equiv A_d B_d - C_d^2 \f$ */ 00112 REAL8 Sinv_Tsft; /**< normalization-factor \f$\mathcal{S}^{-1}\,T_\mathrm{SFT}\f$ */ 00113 } AntennaPatternMatrix; 00114 00115 00116 /** Multi-IFO container for antenna-pattern coefficients a^X(t), b^X(t) and atenna-pattern matrix M_mu_nu */ 00117 typedef struct { 00118 UINT4 length; /**< number of IFOs */ 00119 AMCoeffs **data; /**< noise-weighted am-coeffs \f$\widehat{a}_{X\alpha}\f$, and \f$\widehat{b}_{X\alpha}\f$ */ 00120 AntennaPatternMatrix Mmunu; /**< antenna-pattern matrix \f$\mathcal{M}_{\mu\nu}\f$ */ 00121 } MultiAMCoeffs; 00122 00123 /** Struct holding the "antenna-pattern" matrix \f$\mathcal{M}_{\mu\nu} \equiv \left( \mathbf{h}_\mu|\mathbf{h}_\nu\right)\f$, 00124 * in terms of the multi-detector scalar product. This matrix can be shown to be expressible, in the case of complex AM co\"{e}fficients, as 00125 * \f{equation} 00126 * \mathcal{M}_{\mu\nu} = \mathcal{S}^{-1}\,T_\mathrm{SFT}\,\left( \begin{array}{c c c c} A_d & C_d & 0 & -E_d \\ C_d & B_d & E_d & 0 \\ 0 & E_d & A_d & C_d \\ -E_d & 0 & C_d & B_d \\ \end{array}\right)\,, 00127 * \f} 00128 * where (here) \f$\mathcal{S} \equiv \frac{1}{N_\mathrm{SFT}}\sum_{X,\alpha} S_{X\alpha}\f$ characterizes the multi-detector noise-floor, and 00129 * \f{equation} 00130 * A_d \equiv \sum_{X,\alpha} \mathrm{Re} \widehat{a}^X_\alpha{}^* \widehat{a}^X_\alpha\,,\quad 00131 * B_d \equiv \sum_{X,\alpha} \mathrm{Re} \widehat{b}^X_\alpha{}^* \widehat{b}^X_\alpha \,,\quad 00132 * C_d \equiv \sum_{X,\alpha} \mathrm{Re} \widehat{a}^X_\alpha{}^* \widehat{b}^X_\alpha \,, 00133 * E_d \equiv \sum_{X,\alpha} \mathrm{Im} \widehat{a}^X_\alpha{}^* \widehat{b}^X_\alpha \,, 00134 * \f} 00135 * and the noise-weighted atenna-functions \f$\widehat{a}^X_\alpha = \sqrt{w^X_\alpha}\,a^X_\alpha\f$, 00136 * \f$\widehat{b}^X_\alpha = \sqrt{w^X_\alpha}\,b^X_\alpha\f$, and noise-weights 00137 * \f$w^X_\alpha \equiv {S^{-1}_{X\alpha}/{\mathcal{S}^{-1}}\f$. 00138 * 00139 * \note One reason for storing the un-normalized \a Ad, \a Bd, \a Cd, \a Ed and the normalization-factor \a Sinv_Tsft separately 00140 * is that the former are of order unity, while \a Sinv_Tsft is very large, and it has numerical advantages for parameter-estimation 00141 * to use that fact. 00142 */ 00143 typedef struct { 00144 REAL8 Ad; /**< \f$A_d \equiv \mathrm{Re} \sum_{X,\alpha} \widehat{a}^X_\alpha{}^* \widehat{a}^X_\alpha\f$ */ 00145 REAL8 Bd; /**< \f$B_d \equiv \mathrm{Re} \sum_{X,\alpha} \widehat{b}^X_\alpha{}^* \widehat{b}^X_\alpha\f$ */ 00146 REAL8 Cd; /**< \f$C_d \equiv \mathrm{Re} \sum_{X,\alpha} \widehat{a}^X_\alpha{}^* \widehat{b}^X_\alpha\f$ */ 00147 REAL8 Ed; /**< \f$E_d \equiv \mathrm{Im} \sum_{X,\alpha} \widehat{a}^X_\alpha{}^* \widehat{b}^X_\alpha\f$ */ 00148 REAL8 Dd; /**< determinant \f$D_d \equiv A_d B_d - C_d^2 -E_d^2 \f$ */ 00149 REAL8 Sinv_Tsft; /**< normalization-factor \f$\mathcal{S}^{-1}\,T_\mathrm{SFT}\f$ */ 00150 } CmplxAntennaPatternMatrix; 00151 00152 /** Multi-IFO container for antenna-pattern coefficients a^X(t), b^X(t) and atenna-pattern matrix M_mu_nu */ 00153 typedef struct { 00154 UINT4 length; /**< number of IFOs */ 00155 CmplxAMCoeffs **data; /**< noise-weighted am-coeffs \f$\widehat{a}_{X\alpha}\f$, and \f$\widehat{b}_{X\alpha}\f$ */ 00156 CmplxAntennaPatternMatrix Mmunu; /**< antenna-pattern matrix \f$\mathcal{M}_{\mu\nu}\f$ */ 00157 } MultiCmplxAMCoeffs; 00158 00159 /** Type containing F-statistic proper plus the two complex amplitudes Fa and Fb (for ML-estimators) */ 00160 typedef struct { 00161 REAL8 F; /**< F-statistic value */ 00162 COMPLEX16 Fa; /**< complex amplitude Fa */ 00163 COMPLEX16 Fb; /**< complex amplitude Fb */ 00164 } Fcomponents; 00165 00166 /** The precision in calculating the barycentric transformation */ 00167 typedef enum { 00168 SSBPREC_NEWTONIAN, /**< simple Newtonian: \f$\tau = t + \vec{r}\cdot\vec{n}/c\f$ */ 00169 SSBPREC_RELATIVISTIC, /**< detailed relativistic: \f$\tau=\tau(t; \vec{n}, \vec{r})\f$ */ 00170 SSBPREC_LAST /**< end marker */ 00171 } SSBprecision; 00172 00173 00174 /** Extra parameters controlling the actual computation of F */ 00175 typedef struct { 00176 UINT4 Dterms; /**< how many terms to keep in the Dirichlet kernel (~16 is usually fine) */ 00177 REAL8 upsampling; /**< frequency-upsampling applied to SFTs ==> dFreq != 1/Tsft ... */ 00178 SSBprecision SSBprec; /**< whether to use full relativist SSB-timing, or just simple Newtonian */ 00179 BOOLEAN useRAA; /**< whether to use the frequency- and sky-position-dependent rigid adiabatic response tensor and not just the long-wavelength approximation */ 00180 BOOLEAN bufferedRAA; /**< approximate RAA by assuming constant response over (small) frequency band */ 00181 } ComputeFParams; 00182 00183 /** Struct holding buffered ComputeFStat()-internal quantities to avoid unnecessarily 00184 * recomputing things that depend ONLY on the skyposition and detector-state series (but not on the spins). 00185 * For the first call of ComputeFStat() the pointer-entries should all be NULL. 00186 */ 00187 typedef struct { 00188 const MultiDetectorStateSeries *multiDetStates;/**< buffer for each detStates (store pointer) and skypos */ 00189 REAL8 Alpha, Delta; /**< skyposition of candidate */ 00190 MultiSSBtimes *multiSSB; 00191 MultiSSBtimes *multiBinary; 00192 MultiAMCoeffs *multiAMcoef; 00193 MultiCmplxAMCoeffs *multiCmplxAMcoef; 00194 } ComputeFBuffer; 00195 00196 00197 /*---------- exported Global variables ----------*/ 00198 /* empty init-structs for the types defined in here */ 00199 extern const SSBtimes empty_SSBtimes; 00200 extern const MultiSSBtimes empty_MultiSSBtimes; 00201 extern const AntennaPatternMatrix empty_AntennaPatternMatrix; 00202 extern const MultiAMCoeffs empty_MultiAMCoeffs; 00203 extern const Fcomponents empty_Fcomponents; 00204 extern const ComputeFParams empty_ComputeFParams; 00205 extern const ComputeFBuffer empty_ComputeFBuffer; 00206 00207 /*---------- exported prototypes [API] ----------*/ 00208 int 00209 XLALComputeFaFb ( Fcomponents *FaFb, 00210 const SFTVector *sfts, 00211 const PulsarSpins fkdot, 00212 const SSBtimes *tSSB, 00213 const AMCoeffs *amcoe, 00214 const ComputeFParams *params); 00215 00216 int 00217 XLALComputeFaFbXavie ( Fcomponents *FaFb, 00218 const SFTVector *sfts, 00219 const PulsarSpins fkdot, 00220 const SSBtimes *tSSB, 00221 const AMCoeffs *amcoe, 00222 const ComputeFParams *params); 00223 int 00224 XLALComputeFaFbCmplx ( Fcomponents *FaFb, 00225 const SFTVector *sfts, 00226 const PulsarSpins fkdot, 00227 const SSBtimes *tSSB, 00228 const CmplxAMCoeffs *amcoe, 00229 const ComputeFParams *params); 00230 00231 void 00232 LALGetBinarytimes (LALStatus *, 00233 SSBtimes *tBinary, 00234 const SSBtimes *tSSB, 00235 const DetectorStateSeries *DetectorStates, 00236 const BinaryOrbitParams *binaryparams, 00237 LIGOTimeGPS refTime); 00238 00239 void 00240 LALGetMultiBinarytimes (LALStatus *status, 00241 MultiSSBtimes **multiBinary, 00242 const MultiSSBtimes *multiSSB, 00243 const MultiDetectorStateSeries *multiDetStates, 00244 const BinaryOrbitParams *binaryparams, 00245 LIGOTimeGPS refTime); 00246 00247 void 00248 LALGetSSBtimes (LALStatus *, 00249 SSBtimes *tSSB, 00250 const DetectorStateSeries *DetectorStates, 00251 SkyPosition pos, 00252 LIGOTimeGPS refTime, 00253 SSBprecision precision); 00254 00255 void 00256 LALGetAMCoeffs(LALStatus *, 00257 AMCoeffs *coeffs, 00258 const DetectorStateSeries *DetectorStates, 00259 SkyPosition skypos); 00260 00261 void 00262 LALNewGetAMCoeffs(LALStatus *, 00263 AMCoeffs *coeffs, 00264 const DetectorStateSeries *DetectorStates, 00265 SkyPosition skypos); 00266 00267 00268 int 00269 XLALComputeAntennaPatternCoeffs ( REAL8 *ai, 00270 REAL8 *bi, 00271 const SkyPosition *skypos, 00272 const LIGOTimeGPS *tGPS, 00273 const LALDetector *site, 00274 const EphemerisData *edat 00275 ); 00276 00277 void 00278 LALGetMultiSSBtimes (LALStatus *, 00279 MultiSSBtimes **multiSSB, 00280 const MultiDetectorStateSeries *multiDetStates, 00281 SkyPosition pos, 00282 LIGOTimeGPS refTime, 00283 SSBprecision precision ); 00284 00285 void 00286 LALGetMultiAMCoeffs (LALStatus *, 00287 MultiAMCoeffs **multiAMcoef, 00288 const MultiDetectorStateSeries *multiDetStates, 00289 SkyPosition pos ); 00290 00291 00292 void ComputeFStat ( LALStatus *, Fcomponents *Fstat, 00293 const PulsarDopplerParams *doppler, 00294 const MultiSFTVector *multiSFTs, 00295 const MultiNoiseWeights *multiWeights, 00296 const MultiDetectorStateSeries *multiDetStates, 00297 const ComputeFParams *params, 00298 ComputeFBuffer *cfBuffer ); 00299 00300 void ComputeFStatFreqBand ( LALStatus *status, 00301 REAL8FrequencySeries *FstatVector, 00302 const PulsarDopplerParams *doppler, 00303 const MultiSFTVector *multiSFTs, 00304 const MultiNoiseWeights *multiWeights, 00305 const MultiDetectorStateSeries *multiDetStates, 00306 const ComputeFParams *params); 00307 00308 int 00309 XLALWeighMultiAMCoeffs ( MultiAMCoeffs *multiAMcoef, const MultiNoiseWeights *multiWeights ); 00310 00311 void 00312 LALEstimatePulsarAmplitudeParams (LALStatus * status, 00313 PulsarCandidate *pulsarParams, 00314 const Fcomponents *Fstat, 00315 const LIGOTimeGPS *FstatRefTime, 00316 const CmplxAntennaPatternMatrix *Mmunu 00317 ); 00318 00319 /* destructors */ 00320 void XLALDestroyMultiSSBtimes ( MultiSSBtimes *multiSSB ); 00321 void XLALDestroyMultiAMCoeffs ( MultiAMCoeffs *multiAMcoef ); 00322 void XLALDestroyAMCoeffs ( AMCoeffs *amcoef ); 00323 00324 void XLALEmptyComputeFBuffer ( ComputeFBuffer *cfb ); 00325 00326 00327 /* helpers */ 00328 int sin_cos_LUT (REAL4 *sinx, REAL4 *cosx, REAL8 x); 00329 int sin_cos_2PI_LUT (REAL4 *sin2pix, REAL4 *cos2pix, REAL8 x); 00330 00331 00332 #ifdef __cplusplus 00333 } 00334 #endif 00335 /* C++ protection. */ 00336 00337 #endif /* Double-include protection. */
1.5.2