Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
synthesizeLVStats.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 Reinhard Prix
3 * Copyright (C) 2011, 2014 David Keitel
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with with program; see the file COPYING. If not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301 USA
19 */
20
21/*********************************************************************************/
22/**
23 * \author R. Prix, D. Keitel
24 * \file
25 * \ingroup lalpulsar_bin_Fstatistic
26 * \brief
27 * Generate N samples of various statistics (F-stat, BSGL,...) drawn from their
28 * respective distributions, assuming Gaussian noise, and drawing signal params from
29 * their (given) priors
30 *
31 * This is based on synthesizeBstat and synthesizeTransientStats, and is mostly meant
32 * to be used for Monte-Carlos studies of ROC curves
33 *
34 */
35
36/*
37 *
38 * Some possible use-cases to consider
39 * - transient search BF-stat (synthesize atoms)
40 * - line-veto studies (generate line-realizations)
41 * - different B-stats from different prior models (to avoid integration)
42 *
43 */
44
45#include "config.h"
46
47#include <stdio.h>
48#include <stdbool.h>
49
50#include <gsl/gsl_rng.h>
51
52#include <lal/LALString.h>
53#include <lal/SkyCoordinates.h>
54#include <lal/AVFactories.h>
55#include <lal/LALInitBarycenter.h>
56#include <lal/UserInput.h>
57#include <lal/LogPrintf.h>
58#include <lal/ComputeFstat.h>
59#include <lal/TransientCW_utils.h>
60#include <lal/ProbabilityDensity.h>
61#include <lal/SynthesizeCWDraws.h>
62#include <lal/LineRobustStats.h>
63#include <lal/StringVector.h>
64#include <lal/LALPulsarVCSInfo.h>
65
66/*---------- DEFINES ----------*/
67#define SQ(x) ((x)*(x))
68#define SQUARE(x) ( (x) * (x) )
69#define CUBE(x) ((x)*(x)*(x))
70#define QUAD(x) ((x)*(x)*(x)*(x))
71#define TRUE (1==1)
72#define FALSE (1==0)
73
74/*----- Macros ----- */
75
76/* ---------- local types ---------- */
77/** Type containing multi- and single-detector \f$ \mathcal{F} \f$ -statistics and line-robust statistic */
78typedef struct tagBSGLComponents {
79 REAL4 TwoF; /**< multi-detector \f$ \mathcal{F} \f$ -statistic value */
80 REAL4 TwoFX[PULSAR_MAX_DETECTORS]; /**< fixed-size array of single-detector \f$ \mathcal{F} \f$ -statistic values */
81 UINT4 numDetectors; /**< number of detectors, numDetectors=0 should make all code ignore the TwoFX field. */
82 REAL4 log10BSGL; /**< line-robust statistic \f$ \log_{10}B_{\mathrm{SGL}} \f$ */
84
85
86/** User-variables: can be set from config-file or command-line */
87typedef struct {
88 /* amplitude parameters + ranges: 4 alternative ways to specify the h0-prior (set to < 0 to deactivate all but one!) */
89 REAL8 fixedh0Nat; /**< Alternative 1: if >=0 ==> fix the GW amplitude: h0/sqrt(Sn) */
90 REAL8 fixedSNR; /**< Alternative 2: if >=0 ==> fix the optimal SNR of the injected signals */
91 REAL8 fixedh0NatMax; /**< Alternative 3: if >=0 ==> draw GW amplitude h0 in [0, h0NatMax ]: <==> 'regularized' F-stat prior (obsolete) */
92 REAL8 fixedRhohMax; /**< Alternative 4: if >=0 ==> draw rhoh=h0*(detM)^(1/8) in [0, rhohMax]: <==> canonical F-stat prior */
93
94 REAL8 cosi; /**< cos(inclination angle). If not set: randomize within [-1,1] */
95 REAL8 psi; /**< polarization angle psi. If not set: randomize within [-pi/4,pi/4] */
96 REAL8 phi0; /**< initial GW phase phi_0. If not set: randomize within [0, 2pi] */
97 INT4 AmpPriorType; /**< enumeration of types of amplitude-priors: 0=physical, 1=canonical */
98
99 /* Doppler parameters */
100 REAL8 Alpha; /**< skyposition Alpha (RA) in radians */
101 REAL8 Delta; /**< skyposition Delta (Dec) in radians */
102
103 /* other parameters */
104 LALStringVector *IFOs; /**< list of detector-names "H1,H2,L1,.." or single detector*/
105 CHAR *lineIFO; /**< name of IFO into which line gets inserted */
106 INT4 dataStartGPS; /**< data start-time in GPS seconds */
107 INT4 dataDuration; /**< data-span to generate */
108 INT4 TAtom; /**< Fstat atoms time baseline */
109
110 BOOLEAN computeBSGL; /**< also compute line-robust statistic (BSGL) */
111 REAL8 Fstar0; /**< transition-scale parameter F*(0) for line-robust statistic */
112 LALStringVector *oLGX; /**< Line-to-gauss prior odds oLGX for line-robust statistic */
113
114 LALStringVector *sqrtSX; /**< per-detector noise PSD sqrt(SX) */
115
116 INT4 numDraws; /**< number of random 'draws' to simulate for F-stat and B-stat */
117
118 CHAR *outputStats; /**< output file to write numDraw resulting statistics into */
119 CHAR *outputAtoms; /**< output F-statistic atoms into a file with this basename */
120 CHAR *outputInjParams;/**< output injection parameters into this file */
121 BOOLEAN outputMmunuX; /**< Whether to write the per-IFO antenna pattern matrices into the parameter file */
122 BOOLEAN SignalOnly; /**< dont generate noise-draws: will result in non-random 'signal only' values of F and B */
123
124 BOOLEAN useFReg; /**< use 'regularized' Fstat (1/D)*e^F for marginalization, or 'standard' e^F */
125
126 CHAR *ephemEarth; /**< Earth ephemeris file to use */
127 CHAR *ephemSun; /**< Sun ephemeris file to use */
128
129 INT4 randSeed; /**< GSL random-number generator seed value to use */
131
132/**
133 * Configuration settings required for and defining a coherent pulsar search.
134 * These are 'pre-processed' settings, which have been derived from the user-input.
135 */
136typedef struct {
137 AmplitudePrior_t AmpPrior; /**< amplitude-parameter priors to draw signals from */
138
139 SkyPosition skypos; /**< (Alpha,Delta,system). Use Alpha < 0 to signal 'allsky' */
140 BOOLEAN SignalOnly; /**< dont generate noise-draws: will result in non-random 'signal only' values of F and B */
141
142 transientWindowRange_t transientSearchRange; /**< transient-window range for the search (flat priors) */
143 transientWindowRange_t transientInjectRange; /**< transient-window range for injections (flat priors) */
144
145 MultiDetectorStateSeries *multiDetStates; /**< multi-detector state series covering observation time */
146
147 gsl_rng *rng; /**< gsl random-number generator */
148 CHAR *logString; /**< logstring for file-output, containing cmdline-options + code VCS version info */
149
150 REAL4 *oLGX; /**< per-detector line prior odds */
151
152 MultiNoiseWeights *multiNoiseWeights; /**< per-detector noise weights SX^-1/S^-1, no per-SFT variation (can be NULL for unit weights) */
153
155
156/* ---------- local prototypes ---------- */
157int main( int argc, char *argv[] );
158
159int XLALInitUserVars( UserInput_t *uvar );
160int XLALInitCode( ConfigVariables *cfg, const UserInput_t *uvar );
161int XLALInitAmplitudePrior( AmplitudePrior_t *AmpPrior, const UserInput_t *uvar );
162int write_BSGL_candidate_to_fp( FILE *fp, const BSGLComponents *stats, const LALStringVector *IFOs, const InjParams_t *injParams, const BOOLEAN haveBSGL );
164
165/* exportable API */
166
167/*---------- Global variables ----------*/
168extern int vrbflg; /**< defined in lal/lib/std/LALError.c */
169
170/*----------------------------------------------------------------------*/
171/* Main Function starts here */
172/*----------------------------------------------------------------------*/
173/**
174 * MAIN function
175 * Generates samples of B-stat and F-stat according to their pdfs for given signal-params.
176 */
177int main( int argc, char *argv[] )
178{
181
182 vrbflg = 1; /* verbose error-messages */
183
184 /* turn off default GSL error handler */
185 gsl_set_error_handler_off();
186
187 /* ----- register and read all user-variables ----- */
188 if ( XLALInitUserVars( &uvar ) != XLAL_SUCCESS ) {
189 LogPrintf( LOG_CRITICAL, "%s: XLALInitUserVars() failed with errno=%d\n", __func__, xlalErrno );
190 return 1;
191 }
192
193 /* do ALL cmdline and cfgfile handling */
194 BOOLEAN should_exit = 0;
195 if ( XLALUserVarReadAllInput( &should_exit, argc, argv, lalPulsarVCSInfoList ) != XLAL_SUCCESS ) {
196 LogPrintf( LOG_CRITICAL, "%s: XLALUserVarReadAllInput() failed with errno=%d\n", __func__, xlalErrno );
197 return 1;
198 }
199 if ( should_exit ) {
200 return EXIT_FAILURE;
201 }
202
203 /* ---------- Initialize code-setup ---------- */
204 if ( XLALInitCode( &cfg, &uvar ) != XLAL_SUCCESS ) {
205 LogPrintf( LOG_CRITICAL, "%s: XLALInitCode() failed with error = %d\n", __func__, xlalErrno );
207 }
208
209 /* compare IFO name for line injection with IFO list, find the corresponding index, or throw an error if not found */
210 UINT4 numDetectors = cfg.multiDetStates->length;
211 INT4 lineX = -1;
212 if ( uvar.lineIFO ) {
213 for ( UINT4 X = 0; X < numDetectors; X++ ) {
214 if ( strcmp( uvar.lineIFO, uvar.IFOs->data[X] ) == 0 ) {
215 lineX = X;
216 }
217 }
218 if ( lineX == -1 ) {
219 XLALPrintError( "\nError in function %s, line %d : Could not match detector ID \"%s\" for line injection to any detector.\n\n", __func__, __LINE__, uvar.lineIFO );
221 }
222 }
223
224 /* ----- prepare stats output ----- */
225 FILE *fpStats = NULL;
226 if ( uvar.outputStats ) {
227 if ( ( fpStats = fopen( uvar.outputStats, "wb" ) ) == NULL ) {
228 LogPrintf( LOG_CRITICAL, "Error opening file '%s' for writing..\n\n", uvar.outputStats );
230 }
231 fprintf( fpStats, "%s", cfg.logString ); /* write search log comment */
232 if ( write_BSGL_candidate_to_fp( fpStats, NULL, uvar.IFOs, NULL, uvar.computeBSGL ) != XLAL_SUCCESS ) { /* write header-line comment */
234 }
235 } /* if outputStats */
236
237 /* ----- prepare injection params output ----- */
238 FILE *fpInjParams = NULL;
239 if ( uvar.outputInjParams ) {
240 if ( ( fpInjParams = fopen( uvar.outputInjParams, "wb" ) ) == NULL ) {
241 LogPrintf( LOG_CRITICAL, "Error opening file '%s' for writing..\n\n", uvar.outputInjParams );
243 }
244 fprintf( fpInjParams, "%s", cfg.logString ); /* write search log comment */
245 if ( write_InjParams_to_fp( fpInjParams, NULL, 0, uvar.outputMmunuX, numDetectors ) != XLAL_SUCCESS ) { /* write header-line comment */
247 }
248 } /* if outputInjParams */
249
250 multiAMBuffer_t XLAL_INIT_DECL( multiAMBuffer ); /* prepare AM-buffer */
251
252 /* ----- prepare BSGL computation */
253 BSGLSetup *BSGLsetup = NULL;
254 if ( uvar.computeBSGL ) {
255 BOOLEAN useLogCorrection = TRUE;
256 REAL4 *oLGX_p = NULL;
258 if ( uvar.oLGX != NULL ) {
259 XLAL_CHECK( uvar.oLGX->length == numDetectors, XLAL_EINVAL, "Invalid input: length(oLGX) = %d differs from number of detectors (%d)'\n", uvar.oLGX->length, numDetectors );
260 XLAL_CHECK( XLALParseLinePriors( &oLGX[0], uvar.oLGX ) == XLAL_SUCCESS, XLAL_EFUNC );
261 oLGX_p = &oLGX[0];
262 }
263 XLAL_CHECK( ( BSGLsetup = XLALCreateBSGLSetup( numDetectors, uvar.Fstar0, oLGX_p, useLogCorrection, 1 ) ) != NULL, XLAL_EFUNC ); // coherent F-stat: NSeg=1
264 } // if computeBSGL
265
266 /* ----- main MC loop over numDraws trials ---------- */
267 INT4 i;
268 for ( i = 0; i < uvar.numDraws; i ++ ) {
269 InjParams_t XLAL_INIT_DECL( injParamsDrawn );
270
271 /* ----- generate signal random draws from ranges and generate Fstat atoms */
272 MultiFstatAtomVector *multiAtoms;
273
274 multiAtoms = XLALSynthesizeTransientAtoms( &injParamsDrawn, cfg.skypos, cfg.AmpPrior, cfg.transientInjectRange, cfg.multiDetStates, cfg.SignalOnly, &multiAMBuffer, cfg.rng, lineX, cfg.multiNoiseWeights );
275 XLAL_CHECK( multiAtoms != NULL, XLAL_EFUNC );
276
277 /* ----- if requested, output signal injection parameters into file */
278 if ( fpInjParams && ( write_InjParams_to_fp( fpInjParams, &injParamsDrawn, uvar.dataStartGPS, uvar.outputMmunuX, numDetectors ) != XLAL_SUCCESS ) ) {
280 } /* if fpInjParams & failure*/
281
282 /* initialise BSGLComponents structure and allocate memory */
283 BSGLComponents XLAL_INIT_DECL( synthStats ); /* struct containing multi-detector Fstat, single-detector Fstats, line-robust stat */
284 synthStats.numDetectors = numDetectors;
285
286 /* compute F- and BSGListics from atoms */
287 UINT4 X;
288 for ( X = 0; X < numDetectors; X++ ) {
289 synthStats.TwoFX[X] = XLALComputeFstatFromAtoms( multiAtoms, X );
290 if ( xlalErrno != 0 ) {
291 XLALPrintError( "\nError in function %s, line %d : Failed call to XLALComputeFstatFromAtoms().\n\n", __func__, __LINE__ );
293 }
294 }
295
296 synthStats.TwoF = XLALComputeFstatFromAtoms( multiAtoms, -1 );
297 if ( xlalErrno != 0 ) {
298 XLALPrintError( "\nError in function %s, line %d : Failed call to XLALComputeFstatFromAtoms().\n\n", __func__, __LINE__ );
300 }
301
302 if ( uvar.computeBSGL ) {
303 synthStats.log10BSGL = XLALComputeBSGL( synthStats.TwoF, synthStats.TwoFX, BSGLsetup );
304 XLAL_CHECK( xlalErrno == 0, XLAL_EFUNC, "XLALComputeBSGL() failed with xlalErrno = %d\n", xlalErrno );
305 }
306
307 /* ----- if requested, output atoms-vector into file */
308 if ( uvar.outputAtoms ) {
309
310 LALFILE *fpAtoms;
311 char *fnameAtoms;
312 UINT4 len = strlen( uvar.outputAtoms ) + 20;
313 if ( ( fnameAtoms = XLALCalloc( 1, len ) ) == NULL ) {
314 XLALPrintError( "%s: failed to XLALCalloc ( 1, %d )\n", __func__, len );
316 }
317 sprintf( fnameAtoms, "%s_%04d_of_%04d.dat", uvar.outputAtoms, i + 1, uvar.numDraws );
318
319 if ( ( fpAtoms = XLALFileOpen( fnameAtoms, "wb" ) ) == NULL ) {
320 XLALPrintError( "%s: failed to open atoms-output file '%s' for writing.\n", __func__, fnameAtoms );
322 }
323 XLALFilePrintf( fpAtoms, "%s", cfg.logString ); /* output header info */
324
325 if ( write_MultiFstatAtoms_to_fp( fpAtoms, multiAtoms ) != XLAL_SUCCESS ) {
326 XLALPrintError( "%s: failed to write atoms to output file '%s'. xlalErrno = %d\n", __func__, fnameAtoms, xlalErrno );
328 }
329
330 XLALFree( fnameAtoms );
331 XLALFileClose( fpAtoms );
332 } /* if outputAtoms */
333
334
335 /* ----- if requested, output transient-cand statistics */
336 if ( fpStats && write_BSGL_candidate_to_fp( fpStats, &synthStats, uvar.IFOs, &injParamsDrawn, uvar.computeBSGL ) != XLAL_SUCCESS ) {
337 XLALPrintError( "%s: write_BSGL_candidate_to_fp() failed.\n", __func__ );
339 }
340
341 /* ----- free Memory */
343
344 } /* for i < numDraws */
345
346 /* ----- close files ----- */
347 if ( fpStats ) {
348 fclose( fpStats );
349 }
350 if ( fpInjParams ) {
351 fclose( fpInjParams );
352 }
353
354 /* ----- free memory ---------- */
355 XLALDestroyMultiDetectorStateSeries( cfg.multiDetStates );
356 XLALDestroyMultiNoiseWeights( cfg.multiNoiseWeights );
358 XLALDestroyMultiAMCoeffs( multiAMBuffer.multiAM );
359 /* ----- free amplitude prior pdfs ----- */
360 XLALDestroyPDF1D( cfg.AmpPrior.pdf_h0Nat );
361 XLALDestroyPDF1D( cfg.AmpPrior.pdf_cosi );
362 XLALDestroyPDF1D( cfg.AmpPrior.pdf_psi );
363 XLALDestroyPDF1D( cfg.AmpPrior.pdf_phi0 );
364
365 XLALFree( BSGLsetup );
366 BSGLsetup = NULL;
367
368 if ( cfg.logString ) {
369 XLALFree( cfg.logString );
370 }
371 gsl_rng_free( cfg.rng );
372
374
375 /* did we forget anything ? (doesn't cover gsl-memory!) */
377
378 return 0;
379
380} /* main() */
381
382/**
383 * Register all our "user-variables" that can be specified from cmd-line and/or config-file.
384 * Here we set defaults for some user-variables and register them with the UserInput module.
385 */
386int
388{
389 /* set a few defaults */
390 uvar->outputStats = NULL;
391
392 uvar->Alpha = -1; /* Alpha < 0 indicates "allsky" */
393 uvar->Delta = 0;
394
395 uvar->phi0 = 0;
396 uvar->psi = 0;
397
398 uvar->dataStartGPS = 814838413; /* 1 Nov 2005, ~ start of S5 */
399 uvar->dataDuration = ( INT4 ) round( LAL_YRSID_SI ) ; /* 1 year of data */
400
401 uvar->ephemEarth = XLALStringDuplicate( "earth00-40-DE405.dat.gz" );
402 uvar->ephemSun = XLALStringDuplicate( "sun00-40-DE405.dat.gz" );
403
404 uvar->numDraws = 1;
405 uvar->TAtom = 1800;
406
407 uvar->computeBSGL = 1;
408 uvar->Fstar0 = -LAL_REAL4_MAX; /* corresponding to OSL limit */
409 uvar->oLGX = NULL;
410
411 uvar->sqrtSX = NULL;
412 uvar->useFReg = 0;
413
414 uvar->fixedh0Nat = -1;
415 uvar->fixedSNR = -1;
416 uvar->fixedh0NatMax = -1;
417 uvar->fixedRhohMax = -1;
418
419 if ( ( uvar->IFOs = XLALCreateStringVector( "H1", NULL ) ) == NULL ) {
420 LogPrintf( LOG_CRITICAL, "Call to XLALCreateStringVector() failed with xlalErrno = %d\n", xlalErrno );
422 }
423 uvar->lineIFO = NULL;
424
425 /* ---------- transient window defaults ---------- */
426#define DEFAULT_TRANSIENT "rect"
427
428 /* register all our user-variables */
429 /* signal Doppler parameters */
430 XLALRegisterUvarMember( Alpha, REAL8, 'a', OPTIONAL, "Sky position alpha (equatorial coordinates) in radians [Default:allsky]" );
431 XLALRegisterUvarMember( Delta, REAL8, 'd', OPTIONAL, "Sky position delta (equatorial coordinates) in radians [Default:allsky]" );
432
433 /* signal amplitude parameters */
434 XLALRegisterUvarMember( fixedh0Nat, REAL8, 0, OPTIONAL, "Alternative 1: if >=0 fix the GW amplitude: h0/sqrt(Sn)" );
435 XLALRegisterUvarMember( fixedSNR, REAL8, 0, OPTIONAL, "Alternative 2: if >=0 fix the optimal SNR of the injected signals" );
436 XLALRegisterUvarMember( fixedh0NatMax, REAL8, 0, OPTIONAL, "Alternative 3: if >=0 draw GW amplitude h0 in [0, h0NatMax ] (FReg prior)" );
437 XLALRegisterUvarMember( fixedRhohMax, REAL8, 0, OPTIONAL, "Alternative 4: if >=0 draw rhoh=h0*(detM)^(1/8) in [0, rhohMax] (canonical F-stat prior)" );
438
439 XLALRegisterUvarMember( cosi, REAL8, 'i', OPTIONAL, "cos(inclination angle). If not set: randomize within [-1,1]." );
440 XLALRegisterUvarMember( psi, REAL8, 0, OPTIONAL, "polarization angle psi. If not set: randomize within [-pi/4,pi/4]." );
441 XLALRegisterUvarMember( phi0, REAL8, 0, OPTIONAL, "initial GW phase phi_0. If not set: randomize within [0, 2pi]" );
442
443 XLALRegisterUvarMember( AmpPriorType, INT4, 0, OPTIONAL, "Enumeration of types of amplitude-priors: 0=physical, 1=canonical" );
444
445 XLALRegisterUvarMember( IFOs, STRINGVector, 'I', OPTIONAL, "Comma-separated list of detectors, eg. \"H1,H2,L1,G1, ...\" " );
446 XLALRegisterUvarMember( lineIFO, STRING, 0, OPTIONAL, "Insert a line (signal in this one IFO, pure gaussian noise in others), e.g. \"H1\"" );
447 XLALRegisterUvarMember( dataStartGPS, INT4, 0, OPTIONAL, "data start-time in GPS seconds" );
448 XLALRegisterUvarMember( dataDuration, INT4, 0, OPTIONAL, "data-span to generate (in seconds)" );
449
450 /* misc params */
451 XLALRegisterUvarMember( computeBSGL, BOOLEAN, 0, OPTIONAL, "Compute line-robust statistic (BSGL)" );
452 XLALRegisterUvarMember( Fstar0, REAL8, 0, OPTIONAL, "BSGL: transition-scale parameter 'Fstar0'" );
453 XLALRegisterUvarMember( oLGX, STRINGVector, 0, OPTIONAL, "BSGL: prior per-detector line-vs-Gauss odds, length must be numDetectors. (Defaults to oLGX=1/Ndet)" );
454
455 XLALRegisterUvarMember( sqrtSX, STRINGVector, 0, OPTIONAL, "Per-detector noise PSD sqrt(SX). Only ratios relevant to compute noise weights. Defaults to 1,1,..." );
456
457 XLALRegisterUvarMember( numDraws, INT4, 'N', OPTIONAL, "Number of random 'draws' to simulate" );
458 XLALRegisterUvarMember( randSeed, INT4, 0, OPTIONAL, "GSL random-number generator seed value to use" );
459
460 XLALRegisterUvarMember( outputStats, STRING, 'o', OPTIONAL, "Output file containing 'numDraws' random draws of stats" );
461 XLALRegisterUvarMember( outputAtoms, STRING, 0, OPTIONAL, "Output F-statistic atoms into a file with this basename" );
462 XLALRegisterUvarMember( outputInjParams, STRING, 0, OPTIONAL, "Output injection parameters into this file" );
463 XLALRegisterUvarMember( outputMmunuX, BOOLEAN, 0, OPTIONAL, "Write the per-IFO antenna pattern matrices into the parameter file" );
464
465 XLALRegisterUvarMember( SignalOnly, BOOLEAN, 'S', OPTIONAL, "Signal only: generate pure signal without noise" );
466 XLALRegisterUvarMember( useFReg, BOOLEAN, 0, OPTIONAL, "use 'regularized' Fstat (1/D)*e^F (if TRUE) for marginalization, or 'standard' e^F (if FALSE)" );
467
468 XLALRegisterUvarMember( ephemEarth, STRING, 0, OPTIONAL, "Earth ephemeris file to use" );
469 XLALRegisterUvarMember( ephemSun, STRING, 0, OPTIONAL, "Sun ephemeris file to use" );
470
471 /* 'hidden' stuff */
472 XLALRegisterUvarMember( TAtom, INT4, 0, DEVELOPER, "Time baseline for Fstat-atoms (typically Tsft) in seconds." );
473
474 if ( xlalErrno ) {
475 XLALPrintError( "%s: something failed in initializing user variabels .. errno = %d.\n", __func__, xlalErrno );
477 }
478
479 return XLAL_SUCCESS;
480
481} /* XLALInitUserVars() */
482
483
484/** Initialize Fstat-code: handle user-input and set everything up. */
485int
487{
488 /* generate log-string for file-output, containing cmdline-options + code VCS version info */
489 char *vcs;
490 if ( ( vcs = XLALVCSInfoString( lalPulsarVCSInfoList, 0, "%% " ) ) == NULL ) { /* short VCS version string */
491 XLALPrintError( "%s: XLALVCSInfoString failed with errno=%d.\n", __func__, xlalErrno );
493 }
494 char *cmdline;
495 if ( ( cmdline = XLALUserVarGetLog( UVAR_LOGFMT_CMDLINE ) ) == NULL ) {
496 XLALPrintError( "%s: XLALUserVarGetLog ( UVAR_LOGFMT_CMDLINE ) failed with errno=%d.\n", __func__, xlalErrno );
498 }
499 const char fmt[] = "%%%% cmdline: %s\n%%%%\n%s%%%%\n";
500 UINT4 len = strlen( vcs ) + strlen( cmdline ) + strlen( fmt ) + 1;
501 if ( ( cfg->logString = XLALMalloc( len ) ) == NULL ) {
502 XLALPrintError( "%s: XLALMalloc ( %d ) failed.\n", __func__, len );
504 }
505 sprintf( cfg->logString, fmt, cmdline, vcs );
506 XLALFree( cmdline );
507 XLALFree( vcs );
508
509 /* trivial settings from user-input */
510 cfg->SignalOnly = uvar->SignalOnly;
511
512 /* ----- parse user-input on signal amplitude-paramters + ranges ----- */
513 /* skypos */
514 cfg->skypos.longitude = uvar->Alpha; /* Alpha < 0 indicates 'allsky' */
515 cfg->skypos.latitude = uvar->Delta;
517
518 /* ----- amplitude-params: create prior pdfs reflecting the user-input */
519 if ( XLALInitAmplitudePrior( &cfg->AmpPrior, uvar ) != XLAL_SUCCESS ) {
521 }
522
523 /* ----- initialize random-number generator ----- */
524 /* read out environment variables GSL_RNG_xxx
525 * GSL_RNG_SEED: use to set random seed: default = 0, override by using --randSeed on cmdline
526 * GSL_RNG_TYPE: type of random-number generator to use: default = 'mt19937'
527 */
528 gsl_rng_env_setup();
529 /* allow overriding the random-seed per command-line */
530 if ( XLALUserVarWasSet( &uvar->randSeed ) ) {
531 gsl_rng_default_seed = uvar->randSeed;
532 }
533 cfg->rng = gsl_rng_alloc( gsl_rng_default );
534
535 LogPrintf( LOG_DEBUG, "random-number generator type: %s\n", gsl_rng_name( cfg->rng ) );
536 LogPrintf( LOG_DEBUG, "seed = %lu\n", gsl_rng_default_seed );
537
538 /* init ephemeris-data */
539 EphemerisData *edat = XLALInitBarycenter( uvar->ephemEarth, uvar->ephemSun );
540 if ( !edat ) {
541 LogPrintf( LOG_CRITICAL, "%s: XLALInitBarycenter failed: could not load Earth ephemeris '%s' and Sun ephemeris '%s'\n", __func__, uvar->ephemEarth, uvar->ephemSun );
543 }
544
545 UINT4 numDetectors = uvar->IFOs->length;
546 MultiLALDetector multiDet;
547 XLAL_CHECK( XLALParseMultiLALDetector( &multiDet, uvar->IFOs ) == XLAL_SUCCESS, XLAL_EFUNC );
548
549 /* init timestamps vector covering observation time */
550 UINT4 numSteps = ( UINT4 ) ceil( uvar->dataDuration / uvar->TAtom );
553 XLALPrintError( "%s: XLALCreateMultiLIGOTimeGPSVector(%d) failed.\n", __func__, numDetectors );
554 }
555
556 for ( UINT4 X = 0; X < numDetectors; X++ ) {
557 if ( ( multiTS->data[X] = XLALCreateTimestampVector( numSteps ) ) == NULL ) {
558 XLALPrintError( "%s: XLALCreateTimestampVector(%d) failed.\n", __func__, numSteps );
559 }
560 multiTS->data[X]->deltaT = uvar->TAtom;
561 UINT4 i;
562 for ( i = 0; i < numSteps; i ++ ) {
563 UINT4 ti = uvar->dataStartGPS + i * uvar->TAtom;
564 multiTS->data[X]->data[i].gpsSeconds = ti;
565 multiTS->data[X]->data[i].gpsNanoSeconds = 0;
566 }
567 }
568
569 /* get detector states */
570 if ( ( cfg->multiDetStates = XLALGetMultiDetectorStates( multiTS, &multiDet, edat, 0.5 * uvar->TAtom ) ) == NULL ) {
571 XLALPrintError( "%s: XLALGetMultiDetectorStates() failed.\n", __func__ );
573 }
574
575 if ( uvar->sqrtSX ) { /* translate user-input PSD sqrt(SX) to noise-weights (this actually does not care whether they were normalized or not) */
576
577 /* parse input comma-separated list */
578 MultiNoiseFloor multiNoiseFloor;
579 XLAL_CHECK( XLALParseMultiNoiseFloor( &multiNoiseFloor, uvar->sqrtSX, numDetectors ) == XLAL_SUCCESS, XLAL_EFUNC );
580
581 /* translate to noise weights */
582 XLAL_CHECK( ( cfg->multiNoiseWeights = XLALComputeConstantMultiNoiseWeightsFromNoiseFloor( &multiNoiseFloor, multiTS, uvar->TAtom ) ) != NULL, XLAL_EFUNC );
583
584 } /* if ( uvar->sqrtSX ) */
585
586 /* get rid of all temporary memory allocated for this step */
589 multiTS = NULL;
590
591 /* ---------- initialize transient window ranges, for injection ... ---------- */
592 cfg->transientInjectRange.type = TRANSIENT_NONE; /* default: no transient signal window */
593 /* apply correct defaults if unset: t0=dataStart, t0Band=dataDuration-3*tauMax */
594// cfg->transientInjectRange.t0 = uvar->dataStartGPS + uvar->injectWindow_t0Days * DAY24;
595
597 return XLAL_SUCCESS;
598
599} /* XLALInitCode() */
600
601
602/** Initialize amplitude-prior pdfs from the user-input
603 */
604int
606{
607 const UINT4 AmpPriorBins = 100; // defines the binnning accuracy of our prior-pdfs
608
609 /* consistency check */
610 if ( !AmpPrior || !uvar ) {
611 XLALPrintError( "%s: invalid NULL input 'AmpPrior' or 'uvar'\n", __func__ );
613 }
614 if ( AmpPrior->pdf_h0Nat || AmpPrior->pdf_cosi || AmpPrior->pdf_psi || AmpPrior->pdf_phi0 ) {
615 XLALPrintError( "%s: AmplitudePriors must be set to NULL before calling this function!\n", __func__ );
617 }
618
619 /* first check that user only provided *one* method of determining the amplitude-prior range */
620 UINT4 numSets = 0;
621 if ( uvar->fixedh0Nat >= 0 ) {
622 numSets ++;
623 }
624 if ( uvar->fixedSNR >= 0 ) {
625 numSets ++;
626 }
627 if ( uvar->fixedh0NatMax >= 0 ) {
628 numSets ++ ;
629 }
630 if ( uvar->fixedRhohMax >= 0 ) {
631 numSets ++;
632 }
633 if ( numSets != 1 ) {
634 XLALPrintError( "%s: Specify (>=0) exactly *ONE* amplitude-prior range of {fixedh0Nat, fixedSNR, fixedh0NatMax, fixedRhohMax}\n", __func__ );
636 }
637
638 /* ===== first pass: deal with all user-supplied fixed values ==> singular priors! ===== */
639
640 /* ----- h0 ----- */
641 if ( uvar->fixedh0Nat >= 0 ) /* fix h0Nat */
642 if ( ( AmpPrior->pdf_h0Nat = XLALCreateSingularPDF1D( uvar->fixedh0Nat ) ) == NULL ) {
644 }
645
646 if ( uvar->fixedSNR >= 0 ) /* dummy-pdf, as signal will be computed with h0Nat=1 then rescaled to fixedSNR */
647 if ( ( AmpPrior->pdf_h0Nat = XLALCreateSingularPDF1D( 1.0 ) ) == NULL ) {
649 }
650
651 AmpPrior->fixedSNR = uvar->fixedSNR;
652 AmpPrior->fixRhohMax = ( uvar->fixedRhohMax >= 0 );
653
654 /* ----- cosi ----- */
655 if ( XLALUserVarWasSet( &uvar->cosi ) )
656 if ( ( AmpPrior->pdf_cosi = XLALCreateSingularPDF1D( uvar->cosi ) ) == NULL ) {
658 }
659 /* ----- psi ----- */
660 if ( XLALUserVarWasSet( &uvar->psi ) )
661 if ( ( AmpPrior->pdf_psi = XLALCreateSingularPDF1D( uvar->psi ) ) == NULL ) {
663 }
664 /* ----- phi0 ----- */
665 if ( XLALUserVarWasSet( &uvar->phi0 ) )
666 if ( ( AmpPrior->pdf_phi0 = XLALCreateSingularPDF1D( uvar->phi0 ) ) == NULL ) {
668 }
669
670
671 /* ===== second pass: deal with non-singular prior ranges, taking into account the type of priors to use */
672 REAL8 h0NatMax = 0;
673 if ( uvar->fixedh0NatMax >= 0 ) { /* draw h0Nat from [0, h0NatMax] */
674 h0NatMax = uvar->fixedh0NatMax;
675 }
676 if ( uvar->fixedRhohMax >= 0 ) { /* draw h0 from [0, rhohMax/(detM)^(1/8)] */
677 h0NatMax = uvar->fixedRhohMax; /* at first, will be rescaled by (detM)^(1/8) after the fact */
678 }
679
680 switch ( uvar->AmpPriorType ) {
682
683 /* ----- h0 ----- */ // uniform in [0, h0NatMax] : not that 'physical', but simple
684 if ( AmpPrior->pdf_h0Nat == NULL )
685 if ( ( AmpPrior->pdf_h0Nat = XLALCreateUniformPDF1D( 0, h0NatMax ) ) == NULL ) {
687 }
688 /* ----- cosi ----- */
689 if ( AmpPrior->pdf_cosi == NULL )
690 if ( ( AmpPrior->pdf_cosi = XLALCreateUniformPDF1D( -1.0, 1.0 ) ) == NULL ) {
692 }
693 /* ----- psi ----- */
694 if ( AmpPrior->pdf_psi == NULL )
695 if ( ( AmpPrior->pdf_psi = XLALCreateUniformPDF1D( -LAL_PI_4, LAL_PI_4 ) ) == NULL ) {
697 }
698 /* ----- phi0 ----- */
699 if ( AmpPrior->pdf_phi0 == NULL )
700 if ( ( AmpPrior->pdf_phi0 = XLALCreateUniformPDF1D( 0, LAL_TWOPI ) ) == NULL ) {
702 }
703
704 break;
705
707 /* ----- pdf(h0) ~ h0^3 ----- */
708 if ( AmpPrior->pdf_h0Nat == NULL ) {
709 UINT4 i;
710 pdf1D_t *pdf;
711 if ( ( pdf = XLALCreateDiscretePDF1D( 0, h0NatMax, AmpPriorBins ) ) == NULL ) {
713 }
714
715 for ( i = 0; i < pdf->probDens->length; i ++ ) {
716 REAL8 xMid = 0.5 * ( pdf->xTics->data[i] + pdf->xTics->data[i + 1] );
717 pdf->probDens->data[i] = CUBE( xMid ); // pdf(h0) ~ h0^3
718 }
719 AmpPrior->pdf_h0Nat = pdf;
720 }
721 /* ----- pdf(cosi) ~ ( 1 - cosi^2)^3 ----- */
722 if ( AmpPrior->pdf_cosi == NULL ) {
723 UINT4 i;
724 pdf1D_t *pdf;
725 if ( ( pdf = XLALCreateDiscretePDF1D( -1.0, 1.0, AmpPriorBins ) ) == NULL ) {
727 }
728
729 for ( i = 0; i < pdf->probDens->length; i ++ ) {
730 REAL8 xMid = 0.5 * ( pdf->xTics->data[i] + pdf->xTics->data[i + 1] );
731 REAL8 y = 1.0 - SQ( xMid );
732 pdf->probDens->data[i] = CUBE( y );
733 }
734 AmpPrior->pdf_cosi = pdf;
735 }
736 /* ----- psi ----- */
737 if ( AmpPrior->pdf_psi == NULL )
738 if ( ( AmpPrior->pdf_psi = XLALCreateUniformPDF1D( -LAL_PI_4, LAL_PI_4 ) ) == NULL ) {
740 }
741 /* ----- phi0 ----- */
742 if ( AmpPrior->pdf_phi0 == NULL )
743 if ( ( AmpPrior->pdf_phi0 = XLALCreateUniformPDF1D( 0, LAL_TWOPI ) ) == NULL ) {
745 }
746
747 break;
748
749 default:
750 XLALPrintError( "%s: something went wrong ... unknown priorType = %d\n", __func__, uvar->AmpPriorType );
752 break;
753
754 } // switch( uvar->AmpPriorType )
755
756 return XLAL_SUCCESS;
757
758} /* XLALInitAmplitudePrior() */
759
760
761/**
762 * Write one line for given BSGL candidate into output file.
763 *
764 * NOTE: input stats and injParams can be NULL pointers, then writes header comment instead
765 *
766 */
767int
768write_BSGL_candidate_to_fp( FILE *fp, const BSGLComponents *stats, const LALStringVector *IFOs, const InjParams_t *injParams, const BOOLEAN haveBSGL )
769{
770
771 XLAL_CHECK( fp, XLAL_EINVAL, "Invalid NULL filepointer input." );
772
773 /* if requested, write header-comment line */
774 if ( !stats && !injParams ) {
775
776 char stat_header_string[256] = "";
777 char buf0[256];
778 snprintf( stat_header_string, sizeof( stat_header_string ), "2F " );
779 for ( UINT4 X = 0; X < IFOs->length ; X ++ ) {
780 snprintf( buf0, sizeof( buf0 ), " 2F_%s", IFOs->data[X] );
781 UINT4 len1 = strlen( stat_header_string ) + strlen( buf0 ) + 1;
782 XLAL_CHECK( len1 <= sizeof( stat_header_string ), XLAL_EBADLEN, "Assembled output string too long! (%d > %zu)", len1, sizeof( stat_header_string ) );
783 strcat( stat_header_string, buf0 );
784 }
785 if ( haveBSGL ) {
786 snprintf( buf0, sizeof( buf0 ), " log10BSGL" );
787 strcat( stat_header_string, buf0 );
788 }
789 fprintf( fp, "%%%% freq alpha delta f1dot %s\n", stat_header_string );
790
791 return XLAL_SUCCESS; /* we're done here */
792
793 } /* if par == NULL */
794
795 /* sanity checks */
796 XLAL_CHECK( stats, XLAL_EFAULT, "Invalid stats pointer as input parameter!" );
797 XLAL_CHECK( injParams, XLAL_EFAULT, "Invalid injParams pointer as input parameter!" );
798
799 /* add output-field containing twoF and per-detector sumTwoFX */
800 char statString[256] = ""; /* defaults to empty */
801 char buf0[256];
802 snprintf( statString, sizeof( statString ), "%.6f", stats->TwoF );
803 for ( UINT4 X = 0; X < IFOs->length ; X ++ ) {
804 snprintf( buf0, sizeof( buf0 ), " %.6f", stats->TwoFX[X] );
805 UINT4 len1 = strlen( statString ) + strlen( buf0 ) + 1;
806 XLAL_CHECK( len1 <= sizeof( statString ), XLAL_EBADLEN, "Assembled output string too long! (%d > %zu)", len1, sizeof( statString ) );
807 strcat( statString, buf0 );
808 } /* for X < IFOs->length */
809 if ( haveBSGL ) {
810 snprintf( buf0, sizeof( buf0 ), " %.6f", stats->log10BSGL );
811 strcat( statString, buf0 );
812 }
813 fprintf( fp, "%.6f %.6f %.6f %.6f %s\n",
814 0.0, /* legacy field from synthesizeTransientStats: freq, not needed here */
815 injParams->skypos.longitude,
816 injParams->skypos.latitude,
817 0.0,
818 statString /* legacy field from synthesizeTransientStats: f1dot, not needed here */
819 );
820
821 return XLAL_SUCCESS;
822
823} /* write_BSGL_candidate_to_fp() */
824
825
826/**
827 *
828 */
830XLALComputeConstantMultiNoiseWeightsFromNoiseFloor( const MultiNoiseFloor *multiNoiseFloor, /**< [in] noise floor values sqrt(S) for all detectors */
831 const MultiLIGOTimeGPSVector *multiTS, /**< [in] timestamps vectors for all detectors, only needed for their lengths */
832 const UINT4 Tsft /**< [in] length of SFTs in secons, needed for normalization factor Sinv_Tsft */
833 )
834{
835
836 /* check input parameters */
837 XLAL_CHECK_NULL( multiNoiseFloor != NULL, XLAL_EINVAL );
839 UINT4 numDet = multiNoiseFloor->length;
840 XLAL_CHECK_NULL( numDet == multiTS->length, XLAL_EINVAL, "Inconsistent length between multiNoiseFloor (%d) and multiTimeStamps (%d) structs.\n", numDet, multiTS->length );
841
842 /* create multi noise weights for output */
843 MultiNoiseWeights *multiWeights = NULL;
844 XLAL_CHECK_NULL( ( multiWeights = XLALCalloc( 1, sizeof( *multiWeights ) ) ) != NULL, XLAL_ENOMEM, "Failed call to XLALCalloc ( 1, %zu )\n", sizeof( *multiWeights ) );
845 XLAL_CHECK_NULL( ( multiWeights->data = XLALCalloc( numDet, sizeof( *multiWeights->data ) ) ) != NULL, XLAL_ENOMEM, "Failed call to XLALCalloc ( %d, %zu )\n", numDet, sizeof( *multiWeights->data ) );
846 multiWeights->length = numDet;
847
848 REAL8 sqrtSnTotal = 0;
849 UINT4 numSFTsTotal = 0;
850 for ( UINT4 X = 0; X < numDet; X++ ) { /* first loop over detectors: compute total noise floor normalization */
851 sqrtSnTotal += multiTS->data[X]->length / SQ( multiNoiseFloor->sqrtSn[X] ); /* actually summing up 1/Sn, not sqrtSn yet */
852 numSFTsTotal += multiTS->data[X]->length;
853 }
854 sqrtSnTotal = sqrt( numSFTsTotal / sqrtSnTotal ); /* SnTotal = harmonicMean{S_X} assuming per-detector stationarity */
855
856 for ( UINT4 X = 0; X < numDet; X++ ) { /* second loop over detectors: compute the weights */
857
858 /* compute per-IFO weights */
859 REAL8 noise_weight_X = SQ( sqrtSnTotal / multiNoiseFloor->sqrtSn[X] ); /* w_Xalpha = S_Xalpha^-1/S^-1 = S / S_Xalpha */
860
861 /* create k^th weights vector */
862 if ( ( multiWeights->data[X] = XLALCreateREAL8Vector( multiTS->data[X]->length ) ) == NULL ) {
863 /* free weights vectors created previously in loop */
864 XLALDestroyMultiNoiseWeights( multiWeights );
865 XLAL_ERROR_NULL( XLAL_EFUNC, "Failed to allocate noiseweights for IFO X = %d\n", X );
866 } /* if XLALCreateREAL8Vector() failed */
867
868 /* loop over SFT timestamps and use same weights for all */
869 for ( UINT4 alpha = 0; alpha < multiTS->data[X]->length; alpha++ ) {
870 multiWeights->data[X]->data[alpha] = noise_weight_X;
871 }
872
873 } /* for X < numDet */
874
875 multiWeights->Sinv_Tsft = Tsft / SQ( sqrtSnTotal );
876
877 return multiWeights;
878
879} /* XLALComputeConstantMultiNoiseWeightsFromNoiseFloor() */
#define __func__
log an I/O error, i.e.
void LALCheckMemoryLeaks(void)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
#define STRING(a)
pdf1D_t * XLALCreateSingularPDF1D(REAL8 x0)
Creator function for a 'singular' 1D pdf, containing a single value with certainty,...
pdf1D_t * XLALCreateDiscretePDF1D(REAL8 xMin, REAL8 xMax, UINT4 numBins)
Creator function for a generic discrete 1D pdf over [xMin, xMax], discretized into numBins bins.
pdf1D_t * XLALCreateUniformPDF1D(REAL8 xMin, REAL8 xMax)
Creator function for a uniform 1D pdf over [xMin, xMax].
void XLALDestroyPDF1D(pdf1D_t *pdf)
Destructor function for 1-D pdf.
#define fprintf
REAL4 XLALComputeFstatFromAtoms(const MultiFstatAtomVector *multiFstatAtoms, const INT4 X)
Compute single-or multi-IFO Fstat '2F' from multi-IFO 'atoms'.
Definition: ComputeFstat.c:994
void XLALDestroyMultiFstatAtomVector(MultiFstatAtomVector *multiAtoms)
Free all memory associated with a MultiFstatAtomVector structure.
Definition: ComputeFstat.c:338
int XLALParseMultiLALDetector(MultiLALDetector *detInfo, const LALStringVector *detNames)
Parse string-vectors (typically input by user) of N detector-names for detectors ,...
void XLALDestroyMultiDetectorStateSeries(MultiDetectorStateSeries *mdetStates)
Helper function to get rid of a multi-IFO DetectorStateSeries Note, this is "NULL-robust" in the sens...
MultiDetectorStateSeries * XLALGetMultiDetectorStates(const MultiLIGOTimeGPSVector *multiTS, const MultiLALDetector *multiIFO, const EphemerisData *edat, REAL8 tOffset)
Get the detector-time series for the given MultiLIGOTimeGPSVector.
int XLALParseMultiNoiseFloor(MultiNoiseFloor *multiNoiseFloor, const LALStringVector *sqrtSX, UINT4 numDetectors)
Parse string-vectors (typically input by user) of N detector noise-floors for detectors ,...
int XLALFileClose(LALFILE *file)
LALFILE * XLALFileOpen(const char *path, const char *mode)
int XLALFilePrintf(LALFILE *file, const char *fmt,...)
EphemerisData * XLALInitBarycenter(const CHAR *earthEphemerisFile, const CHAR *sunEphemerisFile)
XLAL interface to reading ephemeris files 'earth' and 'sun', and return ephemeris-data in old backwar...
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
void XLALDestroyMultiAMCoeffs(MultiAMCoeffs *multiAMcoef)
Destroy a MultiAMCoeffs structure.
Definition: LALComputeAM.c:469
#define LAL_REAL4_MAX
#define LAL_YRSID_SI
#define LAL_TWOPI
#define LAL_PI_4
unsigned char BOOLEAN
double REAL8
#define XLAL_INIT_DECL(var,...)
char CHAR
uint32_t UINT4
int32_t INT4
float REAL4
void * XLALMalloc(size_t n)
void * XLALCalloc(size_t m, size_t n)
void XLALFree(void *p)
char char * XLALStringDuplicate(const char *s)
char * XLALVCSInfoString(const LALVCSInfoList vcs_list, const int verbose, const char *prefix)
BSGLSetup * XLALCreateBSGLSetup(const UINT4 numDetectors, const REAL4 Fstar0sc, const REAL4 oLGX[PULSAR_MAX_DETECTORS], const BOOLEAN useLogCorrection, const UINT4 numSegments)
REAL4 XLALComputeBSGL(const REAL4 twoF, const REAL4 twoFX[PULSAR_MAX_DETECTORS], const BSGLSetup *setup)
Single-bin wrapper of XLALVectorComputeBSGL(), provided for backwards compatibility.
int XLALParseLinePriors(REAL4 oLGX[PULSAR_MAX_DETECTORS], const LALStringVector *oLGX_string)
Parse string-vectors (typically input by user) of N per-detector line-to-Gaussian prior ratios to a ...
void LogPrintf(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
LOG_CRITICAL
LOG_DEBUG
void XLALDestroyMultiNoiseWeights(MultiNoiseWeights *weights)
Destroy a MultiNoiseWeights object.
Definition: PSDutils.c:172
#define PULSAR_MAX_DETECTORS
maximal number of detectors we can handle (for static arrays of detector quantities)
@ TRANSIENT_NONE
Note: in this case the window-parameters will be ignored, and treated as rect={data},...
LIGOTimeGPSVector * XLALCreateTimestampVector(UINT4 len)
Allocate a LIGOTimeGPSVector.
Definition: SFTtimestamps.c:47
void XLALDestroyMultiTimestamps(MultiLIGOTimeGPSVector *multiTS)
Destroy a MultiLIGOTimeGPSVector timestamps vector.
MultiLIGOTimeGPSVector * XLALCreateMultiLIGOTimeGPSVector(UINT4 numDetectors)
Simple creator function for MultiLIGOTimeGPSVector with numDetectors entries.
COORDINATESYSTEM_EQUATORIAL
LALStringVector * XLALCreateStringVector(const CHAR *str1,...)
int write_InjParams_to_fp(FILE *fp, const InjParams_t *par, const UINT4 dataStartGPS, const BOOLEAN outputMmunuX, const UINT4 numDetectors)
Write an injection-parameters structure to the given file-pointer, adding one line with the injection...
MultiFstatAtomVector * XLALSynthesizeTransientAtoms(InjParams_t *injParamsOut, SkyPosition skypos, AmplitudePrior_t AmpPrior, transientWindowRange_t transientInjectRange, const MultiDetectorStateSeries *multiDetStates, BOOLEAN SignalOnly, multiAMBuffer_t *multiAMBuffer, gsl_rng *rng, INT4 lineX, const MultiNoiseWeights *multiNoiseWeights)
Generates a multi-Fstat atoms vector for given parameters, drawing random parameters wherever require...
@ AMP_PRIOR_TYPE_CANONICAL
'canonical' priors: uniform in A^mu up to h_max
@ AMP_PRIOR_TYPE_PHYSICAL
'physical' priors: isotropic pdf{cosi,psi,phi0} AND flat pdf(h0)
void XLALDestroyExpLUT(void)
Destructor function for expLUT_t lookup table.
int write_MultiFstatAtoms_to_fp(LALFILE *fp, const MultiFstatAtomVector *multiAtoms)
Write multi-IFO F-stat atoms 'multiAtoms' into output stream 'fstat'.
int XLALUserVarReadAllInput(BOOLEAN *should_exit, int argc, char *argv[], const LALVCSInfoList vcs_list)
void XLALDestroyUserVars(void)
#define XLALRegisterUvarMember(name, type, option, category,...)
void CHAR * XLALUserVarGetLog(UserVarLogFormat format)
int XLALUserVarWasSet(const void *cvar)
UVAR_LOGFMT_CMDLINE
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
#define XLAL_ERROR_NULL(...)
#define xlalErrno
#define XLAL_ERROR(...)
#define XLAL_CHECK(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_CHECK_NULL(assertion,...)
XLAL_EBADLEN
XLAL_ENOMEM
XLAL_SUCCESS
XLAL_EFAULT
XLAL_EFUNC
XLAL_EIO
XLAL_EINVAL
XLAL_EFAILED
list y
double alpha
size_t numDetectors
Signal (amplitude) parameter ranges.
pdf1D_t * pdf_h0Nat
pdf for h0/sqrt{Sn}
REAL8 fixedSNR
alternative 1: adjust h0 to fix the optimal SNR of the signal
BOOLEAN fixRhohMax
alternative 2: draw h0 with fixed rhohMax = h0Max * (detM)^(1/8) <==> canonical Fstat prior
pdf1D_t * pdf_phi0
pdf(phi0)
pdf1D_t * pdf_cosi
pdf(cosi)
pdf1D_t * pdf_psi
pdf(psi)
Type containing multi- and single-detector -statistics and line-robust statistic.
UINT4 numDetectors
number of detectors, numDetectors=0 should make all code ignore the TwoFX field.
REAL4 TwoF
multi-detector -statistic value
REAL4 log10BSGL
line-robust statistic
Configuration settings required for and defining a coherent pulsar search.
REAL4 * oLGX
per-detector line prior odds
gsl_rng * rng
gsl random-number generator
AmplitudePrior_t AmpPrior
amplitude-parameter priors to draw signals from
SkyPosition skypos
(Alpha,Delta,system).
CHAR * logString
logstring for file-output, containing cmdline-options + code VCS version info
BOOLEAN SignalOnly
dont generate noise-draws: will result in non-random 'signal only' values of F and B
MultiDetectorStateSeries * multiDetStates
multi-detector state series covering observation time
transientWindowRange_t transientSearchRange
transient-window range for the search (flat priors)
MultiNoiseWeights * multiNoiseWeights
per-detector noise weights SX^-1/S^-1, no per-SFT variation (can be NULL for unit weights)
transientWindowRange_t transientInjectRange
transient-window range for injections (flat priors)
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
Hold all (generally) randomly drawn injection parameters: skypos, amplitude-params,...
SkyPosition skypos
Multi-IFO time-series of DetectorStates.
A multi-detector vector of FstatAtomVector.
Definition: ComputeFstat.h:187
array of detectors definitions 'LALDetector'
A collection of (multi-IFO) LIGOTimeGPSVector time-stamps vectors.
Definition: SFTfileIO.h:198
array of detector-specific 'noise floors' (ie PSD values), assumed constant over the frequency-band o...
REAL8 sqrtSn[PULSAR_MAX_DETECTORS]
per-IFO sqrt(PSD) values , where
UINT4 length
number of detectors
One noise-weight (number) per SFT (therefore indexed over IFOs and SFTs.
Definition: PSDutils.h:71
REAL8 Sinv_Tsft
normalization factor used: (using single-sided PSD!)
Definition: PSDutils.h:77
UINT4 length
number of detectors
Definition: PSDutils.h:75
REAL8Vector ** data
weights-vector for each detector
Definition: PSDutils.h:76
REAL8 * data
REAL8 longitude
REAL8 latitude
CoordinateSystem system
struct for buffering of AM-coeffs, if signal for same sky-position is injected
Struct defining a range of transient windows.
transientWindowType_t type
window-type: none, rectangular, exponential, ....
int main(int argc, char *argv[])
MAIN function Generates samples of B-stat and F-stat according to their pdfs for given signal-params.
int XLALInitCode(ConfigVariables *cfg, const UserInput_t *uvar)
Initialize Fstat-code: handle user-input and set everything up.
int XLALInitAmplitudePrior(AmplitudePrior_t *AmpPrior, const UserInput_t *uvar)
Initialize amplitude-prior pdfs from the user-input.
int vrbflg
defined in lal/lib/std/LALError.c
#define TRUE
#define CUBE(x)
int write_BSGL_candidate_to_fp(FILE *fp, const BSGLComponents *stats, const LALStringVector *IFOs, const InjParams_t *injParams, const BOOLEAN haveBSGL)
Write one line for given BSGL candidate into output file.
MultiNoiseWeights * XLALComputeConstantMultiNoiseWeightsFromNoiseFloor(const MultiNoiseFloor *multiNoiseFloor, const MultiLIGOTimeGPSVector *multiTS, const UINT4 Tsft)
#define SQ(x)
int XLALInitUserVars(UserInput_t *uvar)
Register all our "user-variables" that can be specified from cmd-line and/or config-file.