Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-da3b9d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
makefakedata_v5.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2013, 2015 Reinhard Prix
3* Copyright (C) 2008, 2010, 2022 Karl Wette
4* Copyright (C) 2008 Chris Messenger
5* Copyright (C) 2007 Badri Krishnan, Reinhard Prix
6*
7* This program is free software; you can redistribute it and/or modify
8* it under the terms of the GNU General Public License as published by
9* the Free Software Foundation; either version 2 of the License, or
10* (at your option) any later version.
11*
12* This program is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15* GNU General Public License for more details.
16*
17* You should have received a copy of the GNU General Public License
18* along with with program; see the file COPYING. If not, write to the
19* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20* MA 02110-1301 USA
21*/
22
23/**
24 * \file
25 * \ingroup lalpulsar_bin_Tools
26 * \author R. Prix, M.A. Papa, X. Siemens, B. Allen, C. Messenger
27 */
28
29/*-----------------------------------------------------------------------
30 *
31 * File Name: makefakedata_v5.c
32 *
33 * Authors: R. Prix, M.A. Papa, X. Siemens, B. Allen, C. Messenger
34 *
35 * This code is a descendant of an earlier implementation 'makefakedata_v4.c',
36 * which itself descended from 'makefakedata_v2.c'
37 * by Badri Krishnan, Bruce Allen, Maria Alessandra Papa, Reinhard Prix, Xavier Siemens, Yousuke Itoh
38 *
39 *-----------------------------------------------------------------------
40 */
41
42/* ---------- includes ---------- */
43#include "config.h"
44
45#include <sys/stat.h>
46
47#include <lal/AVFactories.h>
48#include <lal/SeqFactories.h>
49#include <lal/FrequencySeries.h>
50#include <lal/LALInitBarycenter.h>
51#include <lal/Random.h>
52#include <gsl/gsl_math.h>
53
54#include <lal/UserInput.h>
55#include <lal/SFTfileIO.h>
56#include <lal/GeneratePulsarSignal.h>
57#include <lal/SimulatePulsarSignal.h>
58#include <lal/TimeSeries.h>
59#include <lal/BinaryPulsarTiming.h>
60#include <lal/Window.h>
61#include <lal/LALString.h>
62#include <lal/LALCache.h>
63#include <lal/Units.h>
64#include <lal/TransientCW_utils.h>
65#include <lal/CWMakeFakeData.h>
66#include <lal/LALPulsarVCSInfo.h>
67
68#ifdef HAVE_LIBLALFRAME
69#include <lal/LALFrameIO.h>
70#include <lal/LALFrStream.h>
71#endif
72
73/***************************************************/
74
75/*----------------------------------------------------------------------*/
76
77
78/** configuration-variables derived from user-variables */
79typedef struct {
80 EphemerisData *edat; /**< ephemeris-data */
81 MultiLIGOTimeGPSVector *multiTimestamps; /**< a vector of timestamps to generate time-series/SFTs for */
82 MultiLALDetector multiIFO; //!< detectors to generate data for
83 MultiNoiseFloor multiNoiseFloor; //!< ... and corresponding noise-floors to generate Gaussian white noise for
84
85 SFTCatalog *noiseCatalog; /**< catalog of noise-SFTs */
86 MultiSFTCatalogView *multiNoiseCatalogView; /**< multi-IFO 'view' of noise-SFT catalogs */
87 MultiREAL8TimeSeries *inputMultiTS; /**< 'input' time-series to add other stuff to, and output as frames or SFTs */
88 REAL8 fminOut; /**< Lowest frequency in output SFT (= heterodyning frequency) */
89 REAL8 BandOut; /**< bandwidth of output SFT in Hz (= 1/2 sampling frequency) */
90
91 const CHAR *window_type; /**< name of window function */
92 REAL8 window_param; /**< parameter of window function */
93
94 transientWindow_t transientWindow; /**< properties of transient-signal window */
95 CHAR *VCSInfoString; /**< Git version string */
96 CHAR *outFrameDir; /**< output frame directory */
98
99// ----- User variables
100typedef struct {
101 /* SFT output */
102 CHAR *outSFTdir; /**< Output directory for SFTs */
103 CHAR *outLabel; /**< 'misc' entry in SFT-filenames, and description entry of output frame filenames */
104 UINT4 outPubObsRun; /**< if >0, names SFTs using the public filename convention with this observing run number */
105 UINT4 outPubRevision; /**< if outPubObsRun>0, names SFTs using the public filename convention with this revision number */
106 BOOLEAN outSingleSFT; /**< use to output a single concatenated SFT */
107
108 CHAR *TDDfile; /**< Filename for ASCII output time-series */
109 CHAR *logfile; /**< name of logfile */
110
111 /* specify start + duration */
112 LALStringVector *timestampsFiles; /**< Names of numDet timestamps files */
113 LIGOTimeGPS startTime; /**< Start-time of requested signal in detector-frame (GPS seconds) */
114 INT4 duration; /**< Duration of requested signal in seconds */
115
116 /* time-series sampling + heterodyning frequencies */
117 REAL8 fmin; /**< Lowest frequency in output SFT (= heterodyning frequency) */
118 REAL8 Band; /**< bandwidth of output SFT in Hz (= 1/2 sampling frequency) */
119 REAL8 sourceDeltaT; /**< source-frame sampling period. '0' implies defaults set in XLALGeneratePulsarSignal() */
120
121 /* SFT params */
122 REAL8 Tsft; /**< SFT time baseline Tsft */
123 REAL8 SFToverlap; /**< overlap SFTs by this many seconds */
124
125 LALStringVector *IFOs; /**< list of detector-names "H1,H2,L1,.." or single detector*/
126
127 /* noise to add [OPTIONAL] */
128 LALStringVector *sqrtSX; /**< Add Gaussian noise: list of respective detectors' noise-floors sqrt{Sn}" */
129
130 CHAR *noiseSFTs; /**< Glob-like pattern specifying noise-SFTs to be added to signal */
131
132 /* Frame input and output */
133 CHAR *outFrameDir; /**< directory for writing output timeseries in frame files */
134 LALStringVector *inFrames; /**< frame glob-patterns or cache files of time-series data to be added to output (one per IFO) */
135 LALStringVector *inFrChannels;/**< list of frame channels to read time-series data from (one per IFO) */
136 LALStringVector *outFrChannels;/**< list of output frame channel names to write (one per IFO) */
137
138 /* Window function [OPTIONAL] */
139 CHAR *SFTWindowType; /**< Windowing function to apply to the SFT time series */
140 REAL8 SFTWindowParam; /**< parameter required for certain window-types */
141
142 CHAR *ephemEarth; /**< Earth ephemeris file to use */
143 CHAR *ephemSun; /**< Sun ephemeris file to use */
144
145 /* pulsar parameters */
146 LALStringVector *injectionSources; ///< Source parameters to inject: comma-separated list of file-patterns and/or direct config-strings ('{...}')
147
148 INT4 randSeed; /**< allow user to specify random-number seed for reproducible noise-realizations */
149
151
152
153// ---------- exportable API types ----------
154
155// ----- global variables ----------
156
157int XLALWriteREAL4TimeSeries2fp( FILE *fp, const REAL4TimeSeries *TS );
158
159// ---------- local prototypes ----------
160int XLALInitUserVars( UserVariables_t *uvar, int argc, char *argv[] );
162
163int XLALWriteMFDlog( const char *logfile, const ConfigVars_t *cfg );
164int XLALFreeMem( ConfigVars_t *cfg );
165
166BOOLEAN is_directory( const CHAR *fname );
167
168/*----------------------------------------------------------------------
169 * main function
170 *----------------------------------------------------------------------*/
171int
172main( int argc, char *argv[] )
173{
174 size_t len;
177
178 /* ------------------------------
179 * read user-input and set up shop
180 *------------------------------*/
181 XLAL_CHECK( XLALInitUserVars( &uvar, argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC );
182
184
185 MultiSFTVector *mSFTs = NULL;
186 MultiREAL8TimeSeries *mTseries = NULL;
187
189 if ( uvar.injectionSources ) {
190 XLAL_CHECK( ( injectionSources = XLALPulsarParamsFromUserInput( uvar.injectionSources, NULL ) ) != NULL, XLAL_EFUNC );
191 }
192
193 CWMFDataParams XLAL_INIT_DECL( DataParams );
194 DataParams.multiIFO = GV.multiIFO;
195 DataParams.multiNoiseFloor = GV.multiNoiseFloor;
196 DataParams.multiTimestamps = GV.multiTimestamps;
197 DataParams.randSeed = uvar.randSeed;
198 DataParams.SFTWindowType = GV.window_type;
199 DataParams.SFTWindowParam = GV.window_param;
200 DataParams.sourceDeltaT = uvar.sourceDeltaT;
201 DataParams.inputMultiTS = GV.inputMultiTS;
202 DataParams.fMin = GV.fminOut;
203 DataParams.Band = GV.BandOut;
204
205 XLAL_CHECK( XLALCWMakeFakeMultiData( &mSFTs, &mTseries, injectionSources, &DataParams, GV.edat ) == XLAL_SUCCESS, XLAL_EFUNC );
206
208 injectionSources = NULL;
209
210 // if noiseSFTs specified, load them and add them to the resulting SFT-vector
211 if ( GV.multiNoiseCatalogView ) {
212 SFTtype *sft0 = &( mSFTs->data[0]->data[0] );
213 /* load effective frequency-band from noise-SFTs */
214 UINT4 numBins = sft0->data->length;
215 REAL8 dFreq = sft0->deltaF;
216 REAL8 fMin = sft0->f0;
217 REAL8 fMax = fMin + numBins * dFreq;
218 MultiSFTVector *mNoiseSFTs;
219 XLAL_CHECK( ( mNoiseSFTs = XLALLoadMultiSFTsFromView( GV.multiNoiseCatalogView, fMin, fMax ) ) != NULL, XLAL_EFUNC );
220 XLAL_CHECK( XLALMultiSFTVectorAdd( mSFTs, mNoiseSFTs ) == XLAL_SUCCESS, XLAL_EFUNC );
221 XLALDestroyMultiSFTVector( mNoiseSFTs );
222 }
223
224 // determine output channel names for frames and public SFT filenames
225#ifdef HAVE_LIBLALFRAME
226 if ( XLALUserVarWasSet( &uvar.outFrChannels ) ) {
227 XLAL_CHECK( uvar.outFrChannels->length == mTseries->length, XLAL_EINVAL, "--outFrChannels: number of channel names (%d) must agree with number of IFOs (%d)\n",
228 uvar.outFrChannels->length, mTseries->length );
229 }
230#endif
231 LALStringVector *outChannelNames = XLALCreateEmptyStringVector( mTseries->length );
232 XLAL_CHECK( outChannelNames != NULL, XLAL_EFUNC );
233 for ( UINT4 X = 0; X < mTseries->length; X ++ ) {
234 REAL8TimeSeries *Tseries = mTseries->data[X];
235 char buffer[LALNameLength];
236
237 size_t written = 0;
238 if ( 0 ) { // needed so that the 'else if' blocks can be removed if HAVE_LIBLALFRAME is not defined
239#ifdef HAVE_LIBLALFRAME
240 } else if ( XLALUserVarWasSet( &uvar.outFrChannels ) ) { // if output frame channel names given, use those
241 written = snprintf( buffer, sizeof( buffer ), "%s", uvar.outFrChannels->data[X] );
242 if ( buffer[2] == ':' ) { // check we got correct IFO association
243 XLAL_CHECK( ( buffer[0] == Tseries->name[0] ) && ( buffer[1] == Tseries->name[1] ), XLAL_EINVAL,
244 "Possible IFO mismatch: outFrChannel[%d] = '%s', IFO = '%c%c': be careful about --outFrChannel ordering\n", X, buffer, Tseries->name[0], Tseries->name[1] );
245 } // if buffer[2]==':'
246 } else if ( XLALUserVarWasSet( &uvar.inFrChannels ) ) { // otherwise: if input frame channel names given, use them for output, append "-<outLabel>"
247 written = snprintf( buffer, sizeof( buffer ), "%s-%s", uvar.inFrChannels->data[X], uvar.outLabel );
248#endif
249 } else { // otherwise: fall back to <IFO>:<outLabel> channel name
250 written = snprintf( buffer, sizeof( buffer ), "%c%c:%s", Tseries->name[0], Tseries->name[1], uvar.outLabel );
251 }
252 XLAL_CHECK( written < LALNameLength, XLAL_ESIZE, "Output frame name exceeded max length (%d): '%s'\n", LALNameLength, buffer );
253
254 outChannelNames->data[X] = XLALStringDuplicate( buffer );
255 }
256
257 if ( uvar.outSFTdir ) {
258 XLAL_CHECK( is_directory( uvar.outSFTdir ), XLAL_EINVAL );
259
260 /* generate comment string */
261 CHAR *logstr;
263 char *comment = XLALCalloc( 1, len = strlen( logstr ) + strlen( GV.VCSInfoString ) + 512 );
264 XLAL_CHECK( comment != NULL, XLAL_ENOMEM, "XLALCalloc(1,%zu) failed.\n", len );
265 sprintf( comment, "Generated by:\n%s\n%s\n", logstr, GV.VCSInfoString );
266
267 /* default window is rectangular */
268 const char *window_type = ( GV.window_type != NULL ) ? GV.window_type : "rectangular";
269 const REAL8 window_param = ( GV.window_type != NULL ) ? GV.window_param : 0;
270
271 for ( UINT4 X = 0; X < mSFTs->length; X ++ ) {
272 SFTVector *sfts = mSFTs->data[X];
273
274 /* set up SFT filename */
276 XLAL_CHECK( XLALFillSFTFilenameSpecStrings( &spec, uvar.outSFTdir, NULL, NULL, window_type, NULL, NULL, NULL ) == XLAL_SUCCESS, XLAL_EFUNC );
277 spec.window_param = window_param;
278
279 if ( uvar.outPubObsRun > 0 ) { // public SFT filename
280
281 /* get channel name and check for consistency */
282 const char *channelName = outChannelNames->data[X];
283 const SFTtype *sft0 = &sfts->data[0];
284 XLAL_CHECK( ( channelName[0] == sft0->name[0] ) && ( channelName[1] == sft0->name[1] ), XLAL_EINVAL,
285 "Possible IFO mismatch: output channel[%d] = '%s', IFO = '%c%c': be careful about output channel ordering\n", X, channelName, sft0->name[0], sft0->name[1] );
286
287 /* set public observing run, revision, channel name */
288 XLAL_CHECK( XLALFillSFTFilenameSpecStrings( &spec, NULL, NULL, NULL, NULL, NULL, "SIM", channelName ) == XLAL_SUCCESS, XLAL_EFUNC );
289 spec.pubObsRun = uvar.outPubObsRun;
290 spec.pubRevision = uvar.outPubRevision;
291
292 } else { // private SFT filename; see private description from --outLabel
293 XLAL_CHECK( XLALFillSFTFilenameSpecStrings( &spec, NULL, NULL, NULL, NULL, uvar.outLabel, NULL, NULL ) == XLAL_SUCCESS, XLAL_EFUNC );
294 }
295
296 /* either write whole SFT-vector to single concatenated file */
297 XLAL_CHECK( XLALWriteSFTVector2StandardFile( sfts, &spec, comment, uvar.outSingleSFT ) == XLAL_SUCCESS, XLAL_EFUNC );
298 } // for X < numIFOs
299
300 XLALFree( logstr );
301 XLALFree( comment );
302
303 } /* if outSFTdir */
304
305
306 /* output ASCII time-series if requested */
307 if ( uvar.TDDfile ) {
308 CHAR *fname = XLALCalloc( 1, len = strlen( uvar.TDDfile ) + 10 );
309 XLAL_CHECK( fname != NULL, XLAL_ENOMEM, "XLALCalloc(1,%zu) failed\n", len );
310
311 for ( UINT4 X = 0; X < mTseries->length; X ++ ) {
312 const REAL8TimeSeries *TS = mTseries->data[X];
313 sprintf( fname, "%c%c-%s", TS->name[0], TS->name[1], uvar.TDDfile );
315
316 } // for X < numDet
317
318 XLALFree( fname );
319 } /* if outputting ASCII time-series */
320
321 /* output time-series to frames if requested */
322#ifdef HAVE_LIBLALFRAME
323 if ( GV.outFrameDir != NULL ) {
324 XLAL_CHECK( is_directory( uvar.outFrameDir ), XLAL_EINVAL );
326 len = strlen( GV.outFrameDir ) + strlen( uvar.outLabel ) + 100;
327 char *fname;
328
330
331 for ( UINT4 X = 0; X < mTseries->length; X ++ ) {
332 REAL8TimeSeries *Tseries = mTseries->data[X];
333
334 /* use standard frame output filename format */
335 char IFO[2] = { Tseries->name[0], Tseries->name[1] };
336 LIGOTimeGPS startTimeGPS = Tseries->epoch;
337 REAL8 duration = Tseries->data->length * Tseries->deltaT;
338 XLAL_CHECK( ( fname = LALCalloc( 1, len ) ) != NULL, XLAL_ENOMEM );
339 size_t written = snprintf( fname, len, "%s/%c-%c%c_%s-%d-%d.gwf",
340 GV.outFrameDir, IFO[0], IFO[0], IFO[1], uvar.outLabel, startTimeGPS.gpsSeconds, ( int )duration );
341 XLAL_CHECK( written < len, XLAL_ESIZE, "Frame-filename exceeds expected maximal length (%zu): '%s'\n", len, fname );
342
343 /* define the output frame */
344 LALFrameH *outFrame;
345 XLAL_CHECK( ( outFrame = XLALFrameNew( &startTimeGPS, duration, uvar.outLabel, 1, 0, 0 ) ) != NULL, XLAL_EFUNC );
346
347 /* add timeseries to the frame - make sure to change the timeseries name since this is used as the channel name */
348 strcpy( Tseries->name, outChannelNames->data[X] );
350
351 /* Here's where we add extra information into the frame - first we add the command line args used to generate it */
352 XLALFrameAddFrHistory( outFrame, __FILE__, hist );
353
354 /* then we add the version string */
355 XLALFrameAddFrHistory( outFrame, __FILE__, GV.VCSInfoString );
356
357 /* output the frame to file - compression level 1 (higher values make no difference) */
358 XLAL_CHECK( XLALFrameWrite( outFrame, fname ) == XLAL_SUCCESS, XLAL_EFUNC );
359
360 /* free the frame, frame file name and history memory */
361 XLALFrameFree( outFrame );
362 XLALFree( fname );
363
364 } // for X < numDetectors
365
366 XLALFree( hist );
367
368 } /* if GV.outFrameDir: outputting time-series to frames */
369#endif // HAVE_LIBLALFRAME
370
371 /* ---------- free memory ---------- */
374
375 XLALDestroyStringVector( outChannelNames );
376
377 XLALFreeMem( &GV ); /* free the config-struct */
378
380
381 return 0;
382} /* main */
383
384/**
385 * Handle user-input and set up shop accordingly, and do all
386 * consistency-checks on user-input.
387 */
388int
390{
391 XLAL_CHECK( cfg != NULL, XLAL_EINVAL, "Invalid NULL input 'cfg'\n" );
392 XLAL_CHECK( uvar != NULL, XLAL_EINVAL, "Invalid NULL input 'uvar'\n" );
393
395 XLAL_CHECK( cfg->VCSInfoString != NULL, XLAL_EFUNC, "XLALVCSInfoString failed.\n" );
396
397 /* if requested, log all user-input and code-versions */
398 if ( uvar->logfile ) {
399 XLAL_CHECK( XLALWriteMFDlog( uvar->logfile, cfg ) == XLAL_SUCCESS, XLAL_EFUNC, "XLALWriteMFDlog() failed with xlalErrno = %d\n", xlalErrno );
400 }
401
402 /* Init ephemerides */
403 XLAL_CHECK( ( cfg->edat = XLALInitBarycenter( uvar->ephemEarth, uvar->ephemSun ) ) != NULL, XLAL_EFUNC );
404
405 // ---------- check user-input consistency ----------
406
407 // ----- check if frames + frame channels given
408 BOOLEAN have_frames = ( uvar->inFrames != NULL );
409 BOOLEAN have_channels = ( uvar->inFrChannels != NULL );
410 XLAL_CHECK( !( have_frames || have_channels ) || ( have_frames && have_channels ), XLAL_EINVAL, "Need both --inFrames and --inFrChannels, or NONE\n" );
411
412 // ----- IFOs : only from one of {--IFOs, --noiseSFTs, --inFrChannels}: mutually exclusive
413 BOOLEAN have_IFOs = ( uvar->IFOs != NULL );
414 BOOLEAN have_noiseSFTs = ( uvar->noiseSFTs != NULL );
415 XLAL_CHECK( have_frames || have_IFOs || have_noiseSFTs, XLAL_EINVAL, "Need one of --IFOs, --noiseSFTs or --inFrChannels to determine detectors\n" );
416
417 if ( have_frames ) {
418 XLAL_CHECK( !have_IFOs && !have_noiseSFTs, XLAL_EINVAL, "If --inFrames given, cannot handle --IFOs or --noiseSFTs input\n" );
420 } else { // !have_frames
421 XLAL_CHECK( !( have_IFOs && have_noiseSFTs ), XLAL_EINVAL, "Cannot handle both --IFOs and --noiseSFTs input\n" );
422 }
423 if ( have_IFOs ) {
425 }
426
427 // ----- TIMESTAMPS: either from --timestampsFiles, --startTime+duration, or --noiseSFTs
428 BOOLEAN have_startTime = XLALUserVarWasSet( &uvar->startTime );
429 BOOLEAN have_duration = XLALUserVarWasSet( &uvar->duration );
430 BOOLEAN have_timestampsFiles = ( uvar->timestampsFiles != NULL );
431 // need BOTH startTime+duration or none
432 XLAL_CHECK( ( have_duration && have_startTime ) || !( have_duration || have_startTime ), XLAL_EINVAL, "Need BOTH {--startTime,--duration} or NONE\n" );
433 // at least one of {startTime,timestamps,noiseSFTs,inFrames} required
434 XLAL_CHECK( have_timestampsFiles || have_startTime || have_noiseSFTs || have_frames, XLAL_EINVAL, "Need at least one of {--timestampsFiles, --startTime+duration, --noiseSFTs, --inFrames}\n" );
435 // don't allow timestamps + {startTime+duration OR noiseSFTs}
436 XLAL_CHECK( !have_timestampsFiles || !( have_startTime || have_noiseSFTs ), XLAL_EINVAL, "--timestampsFiles incompatible with {--noiseSFTs or --startTime+duration}\n" );
437 // note, however, that we DO allow --noiseSFTs and --startTime+duration, which will act as a constraint
438 // on the noise-SFTs to load in
439
440 // don't allow --SFToverlap with either --noiseSFTs OR --timestampsFiles
441 XLAL_CHECK( uvar->SFToverlap >= 0, XLAL_EDOM );
442 BOOLEAN haveOverlap = ( uvar->SFToverlap > 0 );
443 XLAL_CHECK( !haveOverlap || !( have_noiseSFTs || have_timestampsFiles ), XLAL_EINVAL, "--SFToverlap incompatible with {--noiseSFTs or --timestampsFiles}\n" );
444
445
446 // frequency-band either taken here from user-input, or later from noiseSFTs (no defaults)
447 UINT4 nSetfminBand = UVAR_SET2( fmin, Band );
448 XLAL_CHECK( ( nSetfminBand == 2 ) || ( ( nSetfminBand == 0 ) && have_noiseSFTs ), XLAL_EINVAL, "Need either 'noiseSFTs' or BOTH of 'fmin' and 'Band'!\n" );
449 if ( nSetfminBand == 2 ) {
450 /* check for negative fmin and Band, which would break the fMin_eff, fBand_eff calculation below */
451 XLAL_CHECK( uvar->fmin >= 0, XLAL_EDOM, "Invalid negative frequency fmin=%f!\n\n", uvar->fmin );
452 XLAL_CHECK( uvar->Band > 0, XLAL_EDOM, "Invalid non-positive frequency band Band=%f!\n\n", uvar->Band );
453 cfg->fminOut = uvar->fmin;
454 cfg->BandOut = uvar->Band;
455 }
456
457 // now handle the 3 mutually-exclusive cases: have_noiseSFTs || have_timestampsFiles || have_startTime (only)
458 if ( have_noiseSFTs ) {
459 SFTConstraints XLAL_INIT_DECL( constraints );
460 if ( have_startTime && have_duration ) { // use optional (startTime+duration) as constraints,
461 LIGOTimeGPS minStartTime, maxStartTime;
462 minStartTime = uvar->startTime;
463 maxStartTime = uvar->startTime;
464 XLALGPSAdd( &maxStartTime, uvar->duration );
465 constraints.minStartTime = &minStartTime;
466 constraints.maxStartTime = &maxStartTime;
467 char bufGPS1[32], bufGPS2[32];
468 XLALPrintWarning( "Only noise-SFTs between GPS [%s, %s] will be used!\n", XLALGPSToStr( bufGPS1, &minStartTime ), XLALGPSToStr( bufGPS2, &maxStartTime ) );
469 } /* if start+duration given */
470 XLAL_CHECK( ( cfg->noiseCatalog = XLALSFTdataFind( uvar->noiseSFTs, &constraints ) ) != NULL, XLAL_EFUNC );
471 XLAL_CHECK( cfg->noiseCatalog->length > 0, XLAL_EINVAL, "No noise-SFTs matching (start+duration, timestamps) were found!\n" );
473
474 // extract multi-timestamps from the multi-SFT-catalog view
476 // extract IFOs from multi-SFT catalog
478
479 // if not given by user: extract frequency start + band from noise SFT catalog
480 if ( !UVAR_ANYSET2( fmin, Band ) ) {
481 const SFTDescriptor *desc = &( cfg->multiNoiseCatalogView->data[0].data[0] );
482 REAL8 noise_fmin = desc->header.f0;
483 REAL8 noise_dFreq = desc->header.deltaF;
484 UINT4 noise_numBins = desc->numBins;
485 REAL8 noise_band = noise_numBins * noise_dFreq;
486 cfg->fminOut = noise_fmin;
487 cfg->BandOut = noise_band;
488 }
489
490 } // endif have_noiseSFTs
491 else if ( have_timestampsFiles ) {
493
494 XLAL_CHECK( ( cfg->multiTimestamps->length > 0 ) && ( cfg->multiTimestamps->data != NULL ), XLAL_EINVAL, "Got empty timestamps-list from XLALReadMultiTimestampsFiles()\n" );
495
496 for ( UINT4 X = 0; X < cfg->multiTimestamps->length; X ++ ) {
497 XLAL_CHECK( ( cfg->multiTimestamps->data[X]->length > 0 ) && ( cfg->multiTimestamps->data[X]->data != NULL ), XLAL_EINVAL, "Got empty timestamps-list for detector %s", cfg->multiIFO.sites[X].frDetector.prefix );
498 cfg->multiTimestamps->data[X]->deltaT = uvar->Tsft; // Tsft information not given by timestamps-file
499 }
500 } // endif have_timestampsFiles
501 else if ( have_startTime && have_duration ) {
502 XLAL_CHECK( ( cfg->multiTimestamps = XLALMakeMultiTimestamps( uvar->startTime, uvar->duration, uvar->Tsft, uvar->SFToverlap, cfg->multiIFO.length ) ) != NULL, XLAL_EFUNC );
503 } // endif have_startTime
504
505 // check if the user asked for Gaussian white noise to be produced (sqrtSn[X]!=0), otherwise leave noise-floors at 0
506 if ( uvar->sqrtSX != NULL ) {
508 } else {
510 // values remain at their default sqrtSn[X] = 0;
511 }
512
513 // determine SFT window to use
514 {
515 const BOOLEAN have_window = XLALUserVarWasSet( &uvar->SFTWindowType );
516 const BOOLEAN have_param = XLALUserVarWasSet( &uvar->SFTWindowParam );
517 const CHAR *window_type_from_uvar = uvar->SFTWindowType;
518 const REAL8 window_param_from_uvar = have_param ? uvar->SFTWindowParam : 0;
519 if ( have_window ) {
520 XLAL_CHECK( XLALCheckNamedWindow( window_type_from_uvar, have_param ) == XLAL_SUCCESS, XLAL_EFUNC );
521 }
522 if ( have_noiseSFTs ) {
523 const CHAR *window_type_from_noiseSFTs = cfg->noiseCatalog->data[0].window_type;
524 const REAL8 window_param_from_noiseSFTs = cfg->noiseCatalog->data[0].window_param;
525 const BOOLEAN have_window_type_from_noiseSFTs = ( XLALStringCaseCompare( window_type_from_noiseSFTs, "unknown" ) != 0 );
526 /* need window info from noise SFTs or user input - if we have both, check for consistency */
527 if ( have_window_type_from_noiseSFTs && have_window ) {
528 XLAL_CHECK( XLALCompareSFTWindows( window_type_from_noiseSFTs, window_param_from_noiseSFTs, window_type_from_uvar, window_param_from_uvar ) == XLAL_SUCCESS, XLAL_EFUNC, "Inconsistent SFT window between --noiseSFTs and user input: [%s,%f] vs [%s,%f].", window_type_from_noiseSFTs, window_param_from_noiseSFTs, window_type_from_uvar, window_param_from_uvar );
529 cfg->window_type = window_type_from_noiseSFTs;
530 cfg->window_param = window_param_from_noiseSFTs;
531 } else if ( have_window_type_from_noiseSFTs ) {
532 cfg->window_type = window_type_from_noiseSFTs;
533 cfg->window_param = window_param_from_noiseSFTs;
534 } else if ( have_window ) {
535 cfg->window_type = window_type_from_uvar;
536 cfg->window_param = window_param_from_uvar;
537 } else {
538 XLAL_ERROR( XLAL_EINVAL, "When --noiseSFTs is given and have unknown window, --SFTWindowType is required.\n" );
539 }
540 } else if ( have_window ) {
541 cfg->window_type = window_type_from_uvar;
542 cfg->window_param = window_param_from_uvar;
543 }
544 }
545
546#ifdef HAVE_LIBLALFRAME
547 // if user requested time-series data from frames to be added: try to read the frames now
548 if ( have_frames ) {
550 XLAL_CHECK( uvar->inFrames->length == numDetectors, XLAL_EINVAL, "Need equal number of channel names (%d) as frame specifications (%d)\n", uvar->inFrChannels->length, numDetectors );
551
552 XLAL_CHECK( ( cfg->inputMultiTS = XLALCalloc( 1, sizeof( *cfg->inputMultiTS ) ) ) != NULL, XLAL_ENOMEM );
554 XLAL_CHECK( ( cfg->inputMultiTS->data = XLALCalloc( numDetectors, sizeof( cfg->inputMultiTS->data[0] ) ) ) != NULL, XLAL_ENOMEM );
555 if ( cfg->multiTimestamps == NULL ) {
556 XLAL_CHECK( ( cfg->multiTimestamps = XLALCalloc( 1, sizeof( *cfg->multiTimestamps ) ) ) != NULL, XLAL_ENOMEM );
557 XLAL_CHECK( ( cfg->multiTimestamps->data = XLALCalloc( numDetectors, sizeof( cfg->multiTimestamps->data[0] ) ) ) != NULL, XLAL_ENOMEM );
559 }
560 for ( UINT4 X = 0; X < numDetectors; X ++ ) {
562 XLAL_CHECK( ( cache = XLALCacheImport( uvar->inFrames->data[X] ) ) != NULL, XLAL_EFUNC, "Failed to import cache file '%s'\n", uvar->inFrames->data[X] );
563 // ----- open frame stream ----------
564 LALFrStream *stream;
565 XLAL_CHECK( ( stream = XLALFrStreamCacheOpen( cache ) ) != NULL, XLAL_EFUNC, "Failed to open stream from cache file '%s'\n", uvar->inFrames->data[X] );
567
568 // ----- determine time span of frame data from the stream ----------
569 // determine time spanned by the frames in this cache
570 LIGOTimeGPS frames_startGPS, frames_endGPS;
571 XLAL_CHECK( XLALFrStreamSeekO( stream, 0, SEEK_SET ) == 0, XLAL_EFUNC, "Failed to move to start of input frame-stream\n" );
572 XLAL_CHECK( XLALFrStreamTell( &frames_startGPS, stream ) == XLAL_SUCCESS, XLAL_EFUNC );
573 XLAL_CHECK( XLALFrStreamSeekO( stream, 0, SEEK_END ) == 0, XLAL_EFUNC, "Failed to move to end of input frame-stream\n" );
574 XLAL_CHECK( XLALFrStreamTell( &frames_endGPS, stream ) == XLAL_SUCCESS, XLAL_EFUNC );
575 REAL8 frames_start = XLALGPSGetREAL8( &frames_startGPS );
576 REAL8 frames_end = XLALGPSGetREAL8( &frames_endGPS );
577 REAL8 frames_span = frames_end - frames_start;
578
579 LIGOTimeGPS ts_startGPS;
580 REAL8 ts_duration;
581 // check that it's consistent with timestamps, if given, otherwise create timestamps from this
582 if ( cfg->multiTimestamps->data[X] != NULL ) { // FIXME: implicitly assumes timestamps are sorted, which is not guaranteed by timestamps-reading from file
583 const LIGOTimeGPSVector *timestampsX = cfg->multiTimestamps->data[X];
584 REAL8 tStart = XLALGPSGetREAL8( &timestampsX->data[0] );
585 REAL8 tEnd = XLALGPSGetREAL8( &timestampsX->data[timestampsX->length - 1] ) + timestampsX->deltaT;
586 XLAL_CHECK( tStart >= frames_start && tEnd <= frames_end, XLAL_EINVAL, "Detector X=%d: Requested timestamps-range [%.0f, %.0f]s outside of cache range [%.0f,%.0f]s\n",
587 X, tStart, tEnd, frames_start, frames_end );
588 XLALGPSSetREAL8( &ts_startGPS, tStart );
589 ts_duration = ( tEnd - tStart );
590 } // if have_timestamps
591 else {
592 ts_startGPS = frames_startGPS;
593 ts_duration = frames_span;
594 XLAL_CHECK( ( cfg->multiTimestamps->data[X] = XLALMakeTimestamps( ts_startGPS, ts_duration, uvar->Tsft, uvar->SFToverlap ) ) != NULL, XLAL_EFUNC );
595 // in this case we can't allow timestamps extending beyond the end of the frame timeseries, so we drop the last timestamp if necessary
596 LIGOTimeGPSVector *timestampsX = cfg->multiTimestamps->data[X];
597 REAL8 tEnd;
598 while ( ( tEnd = XLALGPSGetREAL8( &timestampsX->data[timestampsX->length - 1] ) + timestampsX->deltaT ) > frames_end ) {
599 timestampsX->length --;
600 }
601 } // if have no timestamps
602
603 const char *channel = uvar->inFrChannels->data[X];
604 size_t limit = 0; // unlimited read
606 XLAL_CHECK( ( ts = XLALFrStreamInputREAL8TimeSeries( stream, channel, &ts_startGPS, ts_duration, limit ) ) != NULL,
607 XLAL_EFUNC, "Frame reading failed for stream created for '%s': ts_start = {%d,%d}, duration=%.0f\n",
608 uvar->inFrames->data[X], ts_startGPS.gpsSeconds, ts_startGPS.gpsNanoSeconds, ts_duration );
609
610 if ( XLALUnitCompare( &( ts->sampleUnits ), &lalStrainUnit ) != 0 ) {
611 if ( XLALUnitCompare( &( ts->sampleUnits ), &lalADCCountUnit ) == 0 ) {
612 XLALPrintWarning( "Note: Input timeseries has dimensions 'ADC count' [count] instead of strain.\n" );
613 } else {
614 char unitName[64];
615 XLAL_CHECK( XLALUnitAsString( unitName, sizeof( unitName ), &( ts->sampleUnits ) ) != NULL, XLAL_EUNIT,
616 "Failed to express time-series units as a string\n" );
617 XLAL_CHECK( XLALUnitIsDimensionless( &( ts->sampleUnits ) ), XLAL_EUNIT,
618 "Timeseries input data has invalid units '%s': must be either strain or dimensionless!", unitName );
619 XLALPrintWarning( "Note: Input timeseries is dimensionless instead of strain units.\n" );
620 }
621 ts->sampleUnits = lalStrainUnit; // needed to make XLALCWMakeFakeData() work
622 }
623
624 cfg->inputMultiTS->data[X] = ts;
625
626 XLAL_CHECK( XLALFrStreamClose( stream ) == XLAL_SUCCESS, XLAL_EFUNC, "Stream closing failed for cache file '%s'\n", uvar->inFrames->data[X] );
627 } // for X < numDetectors
628 } // if inFrames
629
630 if ( uvar->outFrameDir ) {
631 cfg->outFrameDir = uvar->outFrameDir;
632 }
633#endif
634
635 return XLAL_SUCCESS;
636
637} /* XLALInitMakefakedata() */
638
639
640/**
641 * Register all "user-variables", and initialized them from command-line and config-files
642 */
643int
644XLALInitUserVars( UserVariables_t *uvar, int argc, char *argv[] )
645{
646
647 XLAL_CHECK( uvar != NULL, XLAL_EINVAL, "Invalid NULL input 'uvar'\n" );
648 XLAL_CHECK( argv != NULL, XLAL_EINVAL, "Invalid NULL input 'argv'\n" );
649
650 // ---------- set a few defaults ----------
651 uvar->ephemEarth = XLALStringDuplicate( "earth00-40-DE405.dat.gz" );
652 uvar->ephemSun = XLALStringDuplicate( "sun00-40-DE405.dat.gz" );
653
654 uvar->Tsft = 1800;
655 uvar->outSingleSFT = 1; /* write our a single SFT file by default */
656
657#define MISC_DEFAULT "mfdv5"
659
660 // ---------- register all our user-variable ----------
661 /* output options */
662 XLALRegisterUvarMember( outSingleSFT, BOOLEAN, 's', OPTIONAL, "Write a single concatenated SFT file instead of individual files" );
663 XLALRegisterUvarMember( outSFTdir, STRING, 'n', OPTIONAL, "Output SFTs: directory for output SFTs" );
664 XLALRegisterUvarMember( outLabel, STRING, 0, OPTIONAL, "'misc' entry in SFT-filenames or 'description' entry of frame filenames" );
665 XLALRegisterUvarMember( outPubObsRun, UINT4, 'O', OPTIONAL, "if >0, names SFTs using the public filename convention with this observing run number" );
666 XLALRegisterUvarMember( outPubRevision, UINT4, 'R', OPTIONAL, "if " UVAR_STR( outPubObsRun ) ">0, names SFTs using the public filename convention with this revision number" );
667 XLALRegisterUvarMember( TDDfile, STRING, 't', OPTIONAL, "Filename to output time-series into" );
668
669 XLALRegisterUvarMember( logfile, STRING, 'l', OPTIONAL, "Filename for log-output" );
670
671 /* detectors and respective noise-floors */
672 XLALRegisterUvarMember( IFOs, STRINGVector, 'I', OPTIONAL, "CSV list of detectors, eg. \"H1,H2,L1,G1, ...\" " );
673 XLALRegisterUvarMember( sqrtSX, STRINGVector, 0, OPTIONAL, "Add Gaussian Noise: CSV list of detectors' noise-floors sqrt{Sn}" );
674
675 XLALRegisterUvarMember( ephemEarth, STRING, 0, OPTIONAL, "Earth ephemeris file to use" );
676 XLALRegisterUvarMember( ephemSun, STRING, 0, OPTIONAL, "Sun ephemeris file to use" );
677
678 /* start + duration of timeseries */
679 XLALRegisterUvarMember( startTime, EPOCH, 'G', OPTIONAL, "Start-time of requested signal in detector-frame (format 'xx.yy[GPS|MJD]')" );
680 XLALRegisterUvarMember( duration, INT4, 0, OPTIONAL, "Duration of requested signal in seconds" );
681 XLALRegisterUvarMember( timestampsFiles, STRINGVector, 0, OPTIONAL, "ALTERNATIVE: File to read timestamps from (file-format: lines with <seconds> <nanoseconds>)" );
682
683 /* sampling and heterodyning frequencies */
684 XLALRegisterUvarMember( fmin, REAL8, 0, NODEFAULT, "Lowest frequency (Hz) of output SFT, and heterodyning frequency of time series written to frames; REQUIRED unless --noiseSFTs given.\n\nNote that, since the output time series written to frames are heterodyned at this frequency, signals at frequency 'f' will be shifted to frequency 'f - fmin'." );
685 XLALRegisterUvarMember( Band, REAL8, 0, NODEFAULT, "Bandwidth (Hz) of output SFT, and of time series written to frames (i.e. half the time series sampling frequency); REQUIRED unless --noiseSFTs given." );
686
687 /* SFT properties */
688 XLALRegisterUvarMember( Tsft, REAL8, 0, OPTIONAL, "Time baseline of one SFT in seconds" );
689 XLALRegisterUvarMember( SFToverlap, REAL8, 0, OPTIONAL, "Overlap between successive SFTs in seconds (conflicts with --noiseSFTs or --timestampsFiles)" );
690 XLALRegisterUvarMember( SFTWindowType, STRING, 0, OPTIONAL, "Window function to apply to the SFTs ('rectangular', 'hann', 'tukey', etc.); when --noiseSFTs is given, required ONLY if noise SFTs have unknown window" );
691 XLALRegisterUvarMember( SFTWindowParam, REAL8, 0, OPTIONAL, "Window parameter required for a few window-types (eg. 'tukey')" );
692
693 /* pulsar params */
694 XLALRegisterUvarMember( injectionSources, STRINGVector, 0, OPTIONAL, "%s", InjectionSourcesHelpString );
695 XLALRegisterUvarMember( sourceDeltaT, REAL8, 0, OPTIONAL, "Source-frame sampling period. '0' implies implies defaults set in XLALGeneratePulsarSignal()." );
696
697 /* noise */
698 XLALRegisterUvarMember( noiseSFTs, STRING, 'D', OPTIONAL, "Noise-SFTs to be added to signal. Possibilities are:\n"
699 " - '<SFT file>;<SFT file>;...', where <SFT file> may contain wildcards\n - 'list:<file containing list of SFT files>'\n"
700 "(Used also to set IFOs and timestamps, and frequency range unless separately specified.)" );
701 XLALRegisterUvarMember( randSeed, INT4, 0, OPTIONAL, "Specify random-number seed for reproducible noise (0 means use /dev/urandom for seeding)." );
702
703 /* frame input/output options */
704#ifdef HAVE_LIBLALFRAME
705 XLALRegisterUvarMember( outFrameDir, STRING, 'F', OPTIONAL, "Output Frames: directory for output timeseries frame files" );
706 XLALRegisterUvarMember( inFrames, STRINGVector, 'C', OPTIONAL, "CSV list (one per IFO) of input frame cache files" );
707 XLALRegisterUvarMember( inFrChannels, STRINGVector, 'N', OPTIONAL, "CSV list (one per IFO) of frame channels to read timeseries from" );
708 XLALRegisterUvarMember( outFrChannels, STRINGVector, 0, NODEFAULT, "CSV list (one per IFO) of output frame channel names [default: <inFrChannels>-<outLabel> or <IFO>:<outLabel>]" );
709#else
710 XLALRegisterUvarMember( outFrameDir, STRING, 'F', DEPRECATED, "Need to compile with lalframe support for this option to work" );
711 XLALRegisterUvarMember( inFrames, STRINGVector, 'C', DEPRECATED, "Need to compile with lalframe support for this option to work" );
712 XLALRegisterUvarMember( inFrChannels, STRINGVector, 'N', DEPRECATED, "Need to compile with lalframe support for this option to work" );
713 XLALRegisterUvarMember( outFrChannels, STRINGVector, 0, DEPRECATED, "Need to compile with lalframe support for this option to work" );
714#endif
715
716 // ----- 'expert-user/developer' options ----- (only shown in help at lalDebugLevel >= warning)
717
718 /* read cmdline & cfgfile */
719 BOOLEAN should_exit = 0;
721 if ( should_exit ) {
722 exit( 1 );
723 }
724
725 return XLAL_SUCCESS;
726
727} /* XLALInitUserVars() */
728
729
730/**
731 * This routine frees up all the memory.
732 */
733int
735{
736 XLAL_CHECK( cfg != NULL, XLAL_EINVAL );
737
738 /* Free config-Variables and userInput stuff */
740
741 /* free timestamps if any */
743
744 XLALFree( cfg->VCSInfoString );
745
746 // free noise-SFT catalog
749
750 // free noise time-series data
752
753 /* Clean up earth/sun Ephemeris tables */
755
756 return XLAL_SUCCESS;
757
758} /* XLALFreeMem() */
759
760/**
761 * Log the all relevant parameters of this run into a log-file.
762 * The name of the log-file used is uvar_logfile
763 * <em>NOTE:</em> Currently this function only logs the user-input and code-versions.
764 */
765int
766XLALWriteMFDlog( const char *logfile, const ConfigVars_t *cfg )
767{
768 XLAL_CHECK( logfile != NULL, XLAL_EINVAL, "Invalid NULL input 'logfile'\n" );
769 XLAL_CHECK( cfg != NULL, XLAL_EINVAL, "Invalid NULL input 'cfg'\n" );
770
771 FILE *fplog = fopen( logfile, "wb" );
772 XLAL_CHECK( fplog != NULL, XLAL_EIO, "Failed to fopen log-file '%s' for writing ('wb').\n", logfile );
773
774 /* write out a log describing the complete user-input (in cfg-file format) */
776 XLAL_CHECK( logstr != NULL, XLAL_EFUNC, "XLALUserVarGetLog(UVAR_LOGFMT_CFGFILE) failed.\n" );
777
778 fprintf( fplog, "## LOG-FILE of Makefakedata run\n\n" );
779 fprintf( fplog, "# User-input: [formatted as config-file]\n" );
780 fprintf( fplog, "# ----------------------------------------------------------------------\n\n" );
781 fprintf( fplog, "%s", logstr );
782 XLALFree( logstr );
783
784 /* write out a log describing the complete user-input (in commandline format) */
786 XLAL_CHECK( logstr != NULL, XLAL_EFUNC, "XLALUserVarGetLog(UVAR_LOGFMT_CMDLINE) failed.\n" );
787
788 fprintf( fplog, "\n\n# User-input: [formatted as commandline]\n" );
789 fprintf( fplog, "# ----------------------------------------------------------------------\n\n" );
790 fprintf( fplog, "%s", logstr );
791 XLALFree( logstr );
792
793 /* append an VCS-version string of the code used */
794 fprintf( fplog, "\n\n# VCS-versions of executable:\n" );
795 fprintf( fplog, "# ----------------------------------------------------------------------\n" );
796 fprintf( fplog, "\n%s\n", cfg->VCSInfoString );
797 fclose( fplog );
798
799 return XLAL_SUCCESS;
800
801} /* XLALWriteMFDLog() */
802
803/* determine if the given filepath is an existing directory or not */
805is_directory( const CHAR *fname )
806{
807 struct stat stat_buf;
808
809 if ( stat( fname, &stat_buf ) ) {
810 return 0;
811 }
812
813 if ( ! S_ISDIR( stat_buf.st_mode ) ) {
814 return 0;
815 } else {
816 return 1;
817 }
818
819} /* is_directory() */
820
821/**
822 * Write a REAL4TimeSeries in a 2-column ASCII format (lines of "GPS_i data_i")
823 * into an open file 'fp'
824 */
825int
827{
828 XLAL_CHECK( fp != NULL, XLAL_EINVAL );
829 XLAL_CHECK( TS != NULL, XLAL_EINVAL );
830 XLAL_CHECK( ( TS->data != NULL ) && ( TS->data->length > 0 ) && ( TS->data->data != NULL ), XLAL_EINVAL );
831
832 REAL8 t0 = XLALGPSGetREAL8( &( TS->epoch ) );
833 XLAL_CHECK( xlalErrno == 0, XLAL_EFAULT, "XLALGPSGetREAL8(%d,%d) failed\n", TS->epoch.gpsSeconds, TS->epoch.gpsNanoSeconds );
834
835 for ( UINT4 i = 0; i < TS->data->length; i++ ) {
836 REAL8 ti = t0 + i * TS->deltaT;
837 XLAL_CHECK( fprintf( fp, "%16.9f %e\n", ti, TS->data->data[i] ) > 0, XLAL_EIO );
838 }
839
840 return XLAL_SUCCESS;
841
842} /* XLALWriteREAL4TimeSeries2fp() */
#define IFO
void LALCheckMemoryLeaks(void)
#define LALCalloc(m, n)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
#define tEnd
ConfigVariables GV
global container for various derived configuration settings
Definition: PredictFstat.c:70
#define STRING(a)
const char * window_type
Definition: SFTnaming.c:44
const char * comment
Definition: SearchTiming.c:94
#define fprintf
PulsarParamsVector * XLALPulsarParamsFromUserInput(const LALStringVector *UserInput, const LIGOTimeGPS *refTimeDef)
Function to determine the PulsarParamsVector input from a user-input defining CW sources.
const char *const InjectionSourcesHelpString
void XLALDestroyPulsarParamsVector(PulsarParamsVector *ppvect)
Destructor for PulsarParamsVector type.
int XLALCWMakeFakeMultiData(MultiSFTVector **multiSFTs, MultiREAL8TimeSeries **multiTseries, const PulsarParamsVector *injectionSources, const CWMFDataParams *dataParams, const EphemerisData *edat)
Generate fake 'CW' data, returned either as SFTVector or REAL4Timeseries or both, for given CW-signal...
char * XLALGPSToStr(char *s, const LIGOTimeGPS *t)
int XLALParseMultiLALDetector(MultiLALDetector *detInfo, const LALStringVector *detNames)
Parse string-vectors (typically input by user) of N detector-names for detectors ,...
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 ,...
void XLALDestroyMultiREAL8TimeSeries(MultiREAL8TimeSeries *multiTS)
Destroy a MultiREAL8TimeSeries, NULL-robust.
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 XLALDestroyCache(LALCache *cache)
LALCache * XLALCacheImport(const char *fname)
unsigned char BOOLEAN
double REAL8
#define XLAL_INIT_DECL(var,...)
char CHAR
uint32_t UINT4
int32_t INT4
LALNameLength
int XLALFrStreamSeekO(LALFrStream *stream, double dt, int whence)
int XLALFrStreamTell(LIGOTimeGPS *epoch, LALFrStream *stream)
int XLALFrStreamClose(LALFrStream *stream)
LALFrStream * XLALFrStreamCacheOpen(LALCache *cache)
REAL8TimeSeries * XLALFrStreamInputREAL8TimeSeries(LALFrStream *stream, const char *chname, const LIGOTimeGPS *start, double duration, size_t lengthlimit)
LALFrameUFrameH LALFrameH
int XLALFrameAddFrHistory(LALFrameH *frame, const char *name, const char *comment)
int XLALFrameWrite(LALFrameH *frame, const char *fname)
LALFrameH * XLALFrameNew(const LIGOTimeGPS *epoch, double duration, const char *project, int run, int frnum, INT8 detectorFlags)
void XLALFrameFree(LALFrameH *frame)
int XLALFrameAddREAL8TimeSeriesProcData(LALFrameH *frame, const REAL8TimeSeries *series)
void * XLALCalloc(size_t m, size_t n)
void XLALFree(void *p)
char char * XLALStringDuplicate(const char *s)
int XLALStringCaseCompare(const char *s1, const char *s2)
char * XLALVCSInfoString(const LALVCSInfoList vcs_list, const int verbose, const char *prefix)
int XLALdumpREAL8TimeSeries(const char *fname, const REAL8TimeSeries *series)
void XLALDestroySFTCatalog(SFTCatalog *catalog)
Free an 'SFT-catalogue'.
Definition: SFTcatalog.c:329
LIGOTimeGPSVector * XLALMakeTimestamps(LIGOTimeGPS tStart, REAL8 Tspan, REAL8 Tsft, REAL8 Toverlap)
Given a start-time, Tspan, Tsft and Toverlap, returns a list of timestamps covering this time-stretch...
void XLALDestroyMultiSFTCatalogView(MultiSFTCatalogView *multiView)
Destroys a MultiSFTCatalogView, without freeing the original catalog that the 'view' was referring to...
Definition: SFTcatalog.c:496
void XLALDestroyMultiSFTVector(MultiSFTVector *multvect)
Destroy a multi SFT-vector.
Definition: SFTtypes.c:424
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.
Definition: SFTcatalog.c:380
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...
Definition: SFTfileIO.c:449
int XLALCompareSFTWindows(const CHAR *type1, const REAL8 param1, const CHAR *type2, const REAL8 param2)
Check whether two SFT windows, each defined by a type name and parameter value, match.
Definition: SFTnaming.c:667
SFTCatalog * XLALSFTdataFind(const CHAR *file_pattern, const SFTConstraints *constraints)
Find the list of SFTs matching the file_pattern and satisfying the given constraints,...
Definition: SFTcatalog.c:71
int XLALCheckValidDescriptionField(const char *desc)
Check whether given string qualifies as a valid 'description' field of a FRAME filename (per ) or SFT...
Definition: SFTnaming.c:639
int XLALMultiSFTVectorAdd(MultiSFTVector *a, const MultiSFTVector *b)
Adds SFT-data from MultiSFTvector 'b' to elements of MultiSFTVector 'a'.
Definition: SFTtypes.c:842
int XLALWriteSFTVector2StandardFile(const SFTVector *sftVect, SFTFilenameSpec *SFTfnspec, const CHAR *SFTcomment, const BOOLEAN merged)
Write the given SFTVector to SFT file(s) with a standard () filename(s).
Definition: SFTfileIO.c:755
void XLALDestroyMultiTimestamps(MultiLIGOTimeGPSVector *multiTS)
Destroy a MultiLIGOTimeGPSVector timestamps vector.
int XLALFillSFTFilenameSpecStrings(SFTFilenameSpec *spec, const CHAR *path, const CHAR *extn, const CHAR *detector, const CHAR *window_type, const CHAR *privMisc, const CHAR *pubObsKind, const CHAR *pubChannel)
Convenience function for filling out the string fields in a SFTFilenameSpec.
Definition: SFTnaming.c:257
MultiLIGOTimeGPSVector * XLALReadMultiTimestampsFiles(const LALStringVector *fnames)
backwards compatible wrapper to XLALReadMultiTimestampsFilesConstrained() without GPS-time constraint...
void XLALDestroyStringVector(LALStringVector *vect)
LALStringVector * XLALCreateEmptyStringVector(UINT4 length)
int XLALUnitIsDimensionless(const LALUnit *unit)
int XLALUnitCompare(const LALUnit *unit1, const LALUnit *unit2)
const LALUnit lalStrainUnit
char * XLALUnitAsString(char *string, UINT4 length, const LALUnit *input)
const LALUnit lalADCCountUnit
int XLALUserVarReadAllInput(BOOLEAN *should_exit, int argc, char *argv[], const LALVCSInfoList vcs_list)
#define UVAR_ANYSET2(n1, n2)
void XLALDestroyUserVars(void)
#define XLALRegisterUvarMember(name, type, option, category,...)
#define UVAR_STR(n)
void CHAR * XLALUserVarGetLog(UserVarLogFormat format)
int XLALUserVarWasSet(const void *cvar)
#define UVAR_SET2(n1, n2)
UVAR_LOGFMT_CMDLINE
UVAR_LOGFMT_CFGFILE
int XLALCheckNamedWindow(const char *windowName, const BOOLEAN haveBeta)
#define xlalErrno
#define XLAL_ERROR(...)
#define XLAL_CHECK(assertion,...)
int int XLALPrintWarning(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
XLAL_EUNIT
XLAL_ENOMEM
XLAL_SUCCESS
XLAL_EFAULT
XLAL_EFUNC
XLAL_EDOM
XLAL_ESIZE
XLAL_EIO
XLAL_EINVAL
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
int main(int argc, char *argv[])
BOOLEAN is_directory(const CHAR *fname)
int XLALWriteREAL4TimeSeries2fp(FILE *fp, const REAL4TimeSeries *TS)
Write a REAL4TimeSeries in a 2-column ASCII format (lines of "GPS_i data_i") into an open file 'fp'.
int XLALInitUserVars(UserVariables_t *uvar, int argc, char *argv[])
Register all "user-variables", and initialized them from command-line and config-files.
int XLALInitMakefakedata(ConfigVars_t *cfg, UserVariables_t *uvar)
Handle user-input and set up shop accordingly, and do all consistency-checks on user-input.
int XLALWriteMFDlog(const char *logfile, const ConfigVars_t *cfg)
Log the all relevant parameters of this run into a log-file.
int XLALFreeMem(ConfigVars_t *cfg)
This routine frees up all the memory.
#define MISC_DEFAULT
desc
ts
size_t numDetectors
double t0
CHAR name[LALNameLength]
COMPLEX8Sequence * data
A vector of COMPLEX8FrequencySeries.
COMPLEX8FrequencySeries * data
Pointer to the data array.
Struct controlling all the aspects of the fake data (time-series + SFTs) to be produced by XLALCWMake...
MultiLALDetector multiIFO
detectors to generate data for (if provided by user and not via noise files)
CHAR * VCSInfoString
Git version string.
MultiNoiseFloor multiNoiseFloor
... and corresponding noise-floors to be used as weights
MultiLIGOTimeGPSVector * multiTimestamps
a vector of timestamps (only set if provided from dedicated time stamp files)
EphemerisData * edat
ephemeris data
configuration-variables derived from user-variables
REAL8 fminOut
Lowest frequency in output SFT (= heterodyning frequency)
REAL8 window_param
parameter of window function
REAL8 BandOut
bandwidth of output SFT in Hz (= 1/2 sampling frequency)
CHAR * VCSInfoString
Git version string.
CHAR * window_type
name of window function
MultiNoiseFloor multiNoiseFloor
... and corresponding noise-floors to generate Gaussian white noise for
CHAR * outFrameDir
output frame directory
MultiREAL8TimeSeries * inputMultiTS
'input' time-series to add other stuff to, and output as frames or SFTs
MultiLIGOTimeGPSVector * multiTimestamps
a vector of timestamps to generate time-series/SFTs for
MultiSFTCatalogView * multiNoiseCatalogView
multi-IFO 'view' of noise-SFT catalogs
SFTCatalog * noiseCatalog
catalog of noise-SFTs
MultiLALDetector multiIFO
detectors to generate data for
const CHAR * window_type
name of window function
EphemerisData * edat
ephemeris-data
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
LALFrDetector frDetector
CHAR prefix[3]
INT4 gpsNanoSeconds
A vector of 'timestamps' of type LIGOTimeGPS.
Definition: SFTfileIO.h:188
REAL8 deltaT
'length' of each timestamp (e.g.
Definition: SFTfileIO.h:194
LIGOTimeGPS * data
array of timestamps
Definition: SFTfileIO.h:193
UINT4 length
number of timestamps
Definition: SFTfileIO.h:192
array of detectors definitions 'LALDetector'
UINT4 length
number of detectors
LALDetector sites[PULSAR_MAX_DETECTORS]
array of site information
A collection of (multi-IFO) LIGOTimeGPSVector time-stamps vectors.
Definition: SFTfileIO.h:198
UINT4 length
number of timestamps vectors or ifos
Definition: SFTfileIO.h:202
LIGOTimeGPSVector ** data
timestamps vector for each ifo
Definition: SFTfileIO.h:203
array of detector-specific 'noise floors' (ie PSD values), assumed constant over the frequency-band o...
UINT4 length
number of detectors
A collection of (multi-IFO) REAL8 time-series.
REAL8TimeSeries ** data
Pointer to the data array.
UINT4 length
Number of elements in array.
A multi-SFT-catalogue "view": a multi-IFO vector of SFT-catalogs.
Definition: SFTfileIO.h:255
SFTCatalog * data
array of SFT-catalog pointers
Definition: SFTfileIO.h:260
A collection of SFT vectors – one for each IFO in a multi-IFO search.
Definition: SFTfileIO.h:179
UINT4 length
number of ifos
Definition: SFTfileIO.h:183
SFTVector ** data
sftvector for each ifo
Definition: SFTfileIO.h:184
Straightforward vector type of N PulsarParams structs.
REAL4Sequence * data
LIGOTimeGPS epoch
REAL4 * data
REAL8Sequence * data
LIGOTimeGPS epoch
CHAR name[LALNameLength]
An "SFT-catalogue": a vector of SFTdescriptors, as returned by XLALSFTdataFind()
Definition: SFTfileIO.h:238
SFTDescriptor * data
array of data-entries describing matched SFTs
Definition: SFTfileIO.h:243
UINT4 length
number of SFTs in catalog
Definition: SFTfileIO.h:242
'Constraints' for SFT-matching: which detector, within which time-stretch and which timestamps exactl...
Definition: SFTfileIO.h:212
A 'descriptor' of an SFT: basically containing the header-info plus an opaque description of where ex...
Definition: SFTfileIO.h:226
const char * window_type
window function applied to SFT
Definition: SFTfileIO.h:229
REAL8 window_param
parameter of window function, if required
Definition: SFTfileIO.h:230
Structure specifying an SFT file name, following the convention in .
Definition: SFTfileIO.h:266
user input variables
Definition: compareFstats.c:51
LALStringVector * outFrChannels
list of output frame channel names to write (one per IFO)
INT4 duration
Duration of requested signal in seconds.
CHAR * ephemSun
Sun ephemeris file to use.
REAL8 SFTWindowParam
parameter required for certain window-types
CHAR * ephemEarth
Earth ephemeris file to use.
CHAR * outFrameDir
directory for writing output timeseries in frame files
CHAR * outSFTdir
Output directory for SFTs.
REAL8 fmin
Lowest frequency in output SFT (= heterodyning frequency)
REAL8 Band
bandwidth of output SFT in Hz (= 1/2 sampling frequency)
UINT4 outPubObsRun
if >0, names SFTs using the public filename convention with this observing run number
LALStringVector * injectionSources
Source parameters to inject: comma-separated list of file-patterns and/or direct config-strings ('{....
CHAR * SFTWindowType
Windowing function to apply to the SFT time series.
LALStringVector * inFrChannels
list of frame channels to read time-series data from (one per IFO)
LIGOTimeGPS startTime
Start-time of requested signal in detector-frame (GPS seconds)
REAL8 SFToverlap
overlap SFTs by this many seconds
CHAR * logfile
name of logfile
UINT4 outPubRevision
if outPubObsRun>0, names SFTs using the public filename convention with this revision number
LALStringVector * timestampsFiles
Names of numDet timestamps files.
REAL8 Tsft
SFT time baseline Tsft.
LALStringVector * IFOs
list of detector-names "H1,H2,L1,.." or single detector
LALStringVector * sqrtSX
Add Gaussian noise: list of respective detectors' noise-floors sqrt{Sn}".
LALStringVector * inFrames
frame glob-patterns or cache files of time-series data to be added to output (one per IFO)
BOOLEAN outSingleSFT
use to output a single concatenated SFT
CHAR * noiseSFTs
Glob-like pattern specifying noise-SFTs to be added to signal.
CHAR * outLabel
'misc' entry in SFT-filenames, and description entry of output frame filenames
Struct defining one transient window instance.