37#include <lal/LALString.h>
38#include <lal/AVFactories.h>
39#include <lal/LALInitBarycenter.h>
40#include <lal/UserInput.h>
41#include <lal/SFTfileIO.h>
42#include <lal/ExtrapolatePulsarSpins.h>
43#include <lal/NormalizeSFTRngMed.h>
44#include <lal/ComputeFstat.h>
45#include <lal/LALHough.h>
46#include <lal/LogPrintf.h>
47#include <lal/FstatisticTools.h>
48#include <lal/TransientCW_utils.h>
49#include <lal/LALPulsarVCSInfo.h>
54#define SQ(x) ((x)*(x))
103 CHAR *transientWindowType;
106 REAL8 transientTauDays;
113int main(
int argc,
char *argv[] );
128int main(
int argc,
char *argv[] )
159 const REAL8 twoF_expected = uvar.PureSignal ? (
rho2 ) : ( 4.0 +
rho2 );
160 const REAL8 twoF_sigma = uvar.PureSignal ? ( 0 ) : ( sqrt( 8.0 + 4.0 *
rho2 ) );
163 if ( uvar.printFstat ) {
164 fprintf( stdout,
"\n%.1f\n", twoF_expected );
168 if ( uvar.outputFstat ) {
169 FILE *fpFstat = NULL;
172 XLAL_CHECK_MAIN( ( fpFstat = fopen( uvar.outputFstat,
"wb" ) ) != NULL,
XLAL_ESYS,
"\nError opening file '%s' for writing..\n\n", uvar.outputFstat );
177 fprintf( fpFstat,
"%%%% cmdline: %s\n", logstr );
180 fprintf( fpFstat,
"%s\n", VCSInfoString );
185 fprintf( fpFstat,
"twoF_expected = %g;\n", twoF_expected );
186 fprintf( fpFstat,
"twoF_sigma = %g;\n", twoF_sigma );
230 uvar->outputFstat = NULL;
231 uvar->printFstat = 1;
237 uvar->PureSignal = 0;
239 uvar->assumeSqrtSX = NULL;
248 XLALRegisterUvarMember( outputFstat,
STRING, 0, NODEFAULT,
"Output-file (octave/matlab) for predicted F-stat value, variance and antenna-patterns" );
250 XLALRegisterUvarMember( PureSignal,
BOOLEAN,
'P', OPTIONAL,
"If true return 2F=SNR^2 ('pure signal without noise'). Otherwise return E[2F] = 4 + SNR^2." );
265 XLALRegisterUvarMember( DataFiles,
STRING,
'D', NODEFAULT,
"Per-detector SFTs (for detectors, timestamps and noise-estimate). Possibilities are:\n"
266 " - '<SFT file>;<SFT file>;...', where <SFT file> may contain wildcards\n - 'list:<file containing list of SFT files>'\n"
271 XLALRegisterUvarMember( assumeSqrtSX, STRINGVector, 0, OPTIONAL,
"Assume stationary per-detector noise-floor sqrt(S[X]) instead of estimating "
272 "(required if not given " UVAR_STR( DataFiles )
")." );
275 XLALRegisterUvarMember( timestampsFiles, STRINGVector, 0, NODEFAULT,
"CSV list of SFT timestamps files, one per detector (conflicts with " UVAR_STR( DataFiles )
")." );
276 XLALRegisterUvarMember( minStartTime, EPOCH, 0, OPTIONAL,
"SFT timestamps must be >= this GPS timestamp." );
277 XLALRegisterUvarMember( maxStartTime, EPOCH, 0, OPTIONAL,
"SFT timestamps must be < this GPS timestamp (only valid with " UVAR_STR( DataFiles )
")." );
283 XLALRegisterUvarMember( transientWindowType,
STRING, 0, OPTIONAL,
"Transient-signal window function to assume. ('none', 'rect', 'exp')." );
284 XLALRegisterUvarMember( transientStartTime, EPOCH, 0, NODEFAULT,
"GPS start-time 't0' of transient signal window." );
325 XLAL_CHECK( ( ( have_h0 && !have_cosi ) || ( !have_h0 && have_cosi ) ) == 0,
XLAL_EINVAL,
"Need both (h0, cosi) to specify signal!\n" );
326 XLAL_CHECK( ( ( have_Ap && !have_Ac ) || ( !have_Ap && have_Ac ) ) == 0,
XLAL_EINVAL,
"Need both (aPlus, aCross) to specify signal!\n" );
327 XLAL_CHECK( ( have_h0 && have_Ap ) == 0,
XLAL_EINVAL,
"Overdetermined: specify EITHER (h0,cosi) OR (aPlus,aCross)!\n" );
331 cfg->
pap.
aPlus = 0.5 * uvar->h0 * ( 1.0 +
SQ( uvar->cosi ) );
384 constraints.minStartTime = &uvar->minStartTime;
385 constraints.maxStartTime = &uvar->maxStartTime;
405 if ( !have_assumeSqrtSX ) {
406 UINT4 wings = uvar->RngMedWindow / 2 + 10;
407 REAL8 fMax = uvar->Freq + 1.0 * wings /
Tsft;
430 if ( have_timestamps ) {
432 if ( have_duration ) {
435 endTimeGPS = &tempGPS;
444 else if ( have_timeSpan == 2 ) {
464 if ( have_assumeSqrtSX ) {
469 XLAL_CHECK( assumeSqrtSX.sqrtSn[X] > 0,
XLAL_EDOM,
"all entries of assumeSqrtSX must be >0" );
481 REAL8 SXinv = 1.0 / (
SQ( assumeSqrtSX.sqrtSn[X] ) );
482 Sinv += numSFTsX * SXinv;
483 for (
UINT4 j = 0;
j < numSFTsX;
j ++ ) {
484 multiNoiseWeights->
data[X]->
data[
j] = SXinv;
492 for (
UINT4 j = 0;
j < numSFTsX;
j ++ ) {
493 multiNoiseWeights->
data[X]->
data[
j] /= Sinv;
509 if (
XLALUserVarWasSet( &uvar->transientWindowType ) && strcmp( uvar->transientWindowType,
"none" ) ) {
514 transientWindow.
type = twtype;
517 transientWindow.
t0 = uvar->transientStartTime.
gpsSeconds;
519 XLAL_ERROR(
XLAL_EINVAL,
"Required input " UVAR_STR( transientStartTime )
" missing for transient window type '%s'", uvar->transientWindowType );
523 transientWindow.
tau = uvar->transientTau;
525 XLAL_ERROR(
XLAL_EINVAL,
"Required input " UVAR_STR( transientStartTime )
" missing for transient window type '%s'", uvar->transientWindowType );
547 CHAR dateStr[512],
line[1024], summary[2048];
549 sprintf( summary,
"%%%% Date: %s", asctime( gmtime( &tp ) ) );
550 strcat( summary,
"%% Loaded SFTs: [ " );
552 sprintf(
line,
"%s:%d%s", multiIFO.sites[X].frDetector.name, mTS->
data[X]->
length, ( X <
numDetectors - 1 ) ?
", " :
" ]\n" );
553 strcat( summary,
line );
556 strcpy( dateStr, asctime( &utc ) );
557 dateStr[ strlen( dateStr ) - 1 ] = 0;
559 strcat( summary,
line );
560 sprintf(
line,
"%%%% Total amount of data: Tdata = %12.3f s (%.2f days)\n",
Tdata,
Tdata / 86400 );
561 strcat( summary,
line );
lal_errhandler_t lal_errhandler
int LAL_ERR_EXIT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
void LALCheckMemoryLeaks(void)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
int main(int argc, char *argv[])
MAIN function of PredictFstat code.
ConfigVariables GV
global container for various derived configuration settings
int initUserVars(UserInput_t *uvar)
Register all our "user-variables" that can be specified from cmd-line and/or config-file.
int InitPFS(ConfigVariables *cfg, UserInput_t *uvar)
Initialized Fstat-code: handle user-input and set everything up.
int vrbflg
defined in lal/lib/std/LALError.c
const FstatOptionalArgs FstatOptionalArgsDefaults
Global initializer for setting FstatOptionalArgs to default values.
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 XLALMultiLALDetectorFromMultiSFTCatalogView(MultiLALDetector *multiIFO, const MultiSFTCatalogView *multiView)
Extract multi detector-info from a given multi SFTCatalog view.
int XLALParseMultiNoiseFloor(MultiNoiseFloor *multiNoiseFloor, const LALStringVector *sqrtSX, UINT4 numDetectors)
Parse string-vectors (typically input by user) of N detector noise-floors for detectors ,...
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.
MultiAMCoeffs * XLALComputeMultiAMCoeffs(const MultiDetectorStateSeries *multiDetStates, const MultiNoiseWeights *multiWeights, SkyPosition skypos)
Multi-IFO version of XLALComputeAMCoeffs().
#define XLAL_INIT_DECL(var,...)
void * XLALCalloc(size_t m, size_t n)
char char * XLALStringDuplicate(const char *s)
char * XLALVCSInfoString(const LALVCSInfoList vcs_list, const int verbose, const char *prefix)
void void LogPrintfVerbatim(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
MultiPSDVector * XLALNormalizeMultiSFTVect(MultiSFTVector *multsft, UINT4 blockSize, const MultiNoiseFloor *assumeSqrtSX)
Function for normalizing a multi vector of SFTs in a multi IFO search and returns the running-median ...
void XLALDestroyMultiPSDVector(MultiPSDVector *multvect)
Destroy a multi PSD-vector.
MultiNoiseWeights * XLALComputeMultiNoiseWeights(const MultiPSDVector *rngmed, UINT4 blocksRngMed, UINT4 excludePercentile)
Computes weight factors arising from MultiSFTs with different noise floors.
void XLALDestroyMultiNoiseWeights(MultiNoiseWeights *weights)
Destroy a MultiNoiseWeights object.
void XLALDestroySFTCatalog(SFTCatalog *catalog)
Free an 'SFT-catalogue'.
void XLALDestroyMultiSFTCatalogView(MultiSFTCatalogView *multiView)
Destroys a MultiSFTCatalogView, without freeing the original catalog that the 'view' was referring to...
void XLALDestroyMultiSFTVector(MultiSFTVector *multvect)
Destroy a multi SFT-vector.
MultiLIGOTimeGPSVector * XLALReadMultiTimestampsFilesConstrained(const LALStringVector *fnames, const LIGOTimeGPS *minGPS, const LIGOTimeGPS *maxGPS)
Load several timestamps files, return a MultiLIGOTimeGPSVector struct, allocated here.
MultiLIGOTimeGPSVector * XLALMakeMultiTimestamps(LIGOTimeGPS tStart, REAL8 Tspan, REAL8 Tsft, REAL8 Toverlap, UINT4 numDet)
Same as XLALMakeTimestamps() just for several detectors, additionally specify the number of detectors...
MultiSFTCatalogView * XLALGetMultiSFTCatalogView(const SFTCatalog *catalog)
Return a MultiSFTCatalogView generated from an input SFTCatalog.
MultiLIGOTimeGPSVector * XLALTimestampsFromMultiSFTCatalogView(const MultiSFTCatalogView *multiView)
Given a multi-SFTCatalogView, return a MultiLIGOTimeGPSVector holding the SFT timestamps.
MultiSFTVector * XLALLoadMultiSFTsFromView(const MultiSFTCatalogView *multiCatalogView, REAL8 fMin, REAL8 fMax)
This function loads a MultiSFTVector from a given input MultiSFTCatalogView, otherwise the documentat...
SFTCatalog * XLALSFTdataFind(const CHAR *file_pattern, const SFTConstraints *constraints)
Find the list of SFTs matching the file_pattern and satisfying the given constraints,...
void XLALDestroyMultiTimestamps(MultiLIGOTimeGPSVector *multiTS)
Destroy a MultiLIGOTimeGPSVector timestamps vector.
void XLALNormalizeSkyPosition(double *restrict longitude, double *restrict latitude)
COORDINATESYSTEM_EQUATORIAL
int XLALParseTransientWindowName(const char *windowName)
Parse a transient window name string into the corresponding transientWindowType.
int XLALApplyTransientWindow2NoiseWeights(MultiNoiseWeights *multiNoiseWeights, const MultiLIGOTimeGPSVector *multiTS, transientWindow_t transientWindow)
apply transient window to give multi noise-weights, associated with given multi timestamps
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
struct tm * XLALGPSToUTC(struct tm *utc, INT4 gpssec)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_MAIN(assertion,...)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
int XLALGPSCmp(const LIGOTimeGPS *t0, const LIGOTimeGPS *t1)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
Struct holding the "antenna-pattern" matrix , in terms of the multi-detector scalar product.
Configuration settings required for and defining a coherent pulsar search.
UINT4 numSFTs
number of SFTs = Tobs/Tsft
PulsarAmplitudeParams pap
PulsarAmplitudeParameter {h0, cosi, psi, phi0}.
AntennaPatternMatrix Mmunu
antenna-pattern matrix and normalization
CHAR * dataSummary
descriptive string describing the data
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
UINT4 runningMedianWindow
If SFT noise weights are calculated from the SFTs, the running median window length to use.
REAL8 deltaT
'length' of each timestamp (e.g.
LIGOTimeGPS * data
array of timestamps
UINT4 length
number of timestamps
Multi-IFO container for antenna-pattern coefficients and atenna-pattern matrix .
AntennaPatternMatrix Mmunu
antenna-pattern matrix
Multi-IFO time-series of DetectorStates.
array of detectors definitions 'LALDetector'
A collection of (multi-IFO) LIGOTimeGPSVector time-stamps vectors.
UINT4 length
number of timestamps vectors or ifos
LIGOTimeGPSVector ** data
timestamps vector for each ifo
array of detector-specific 'noise floors' (ie PSD values), assumed constant over the frequency-band o...
One noise-weight (number) per SFT (therefore indexed over IFOs and SFTs.
REAL8 Sinv_Tsft
normalization factor used: (using single-sided PSD!)
UINT4 length
number of detectors
REAL8Vector ** data
weights-vector for each detector
A collection of PSD vectors – one for each IFO in a multi-IFO search.
A multi-SFT-catalogue "view": a multi-IFO vector of SFT-catalogs.
UINT4 length
number of detectors
A collection of SFT vectors – one for each IFO in a multi-IFO search.
Type containing the JKS 'amplitude parameters' {h0, cosi, phi0, psi}.
REAL8 aCross
Signal amplitude (cross)
REAL8 psi
polarization angle psi
REAL8 aPlus
Signal amplitude (plus)
REAL8 phi0
initial signal-phase (at some reference time)
An "SFT-catalogue": a vector of SFTdescriptors, as returned by XLALSFTdataFind()
SFTDescriptor * data
array of data-entries describing matched SFTs
UINT4 length
number of SFTs in catalog
'Constraints' for SFT-matching: which detector, within which time-stretch and which timestamps exactl...
SFTtype header
SFT-header info.
Struct defining one transient window instance.
UINT4 t0
GPS start-time 't0'.
UINT4 tau
transient timescale tau in seconds
transientWindowType_t type
window-type: none, rectangular, exponential, ....