24 #include <lal/LALStdio.h>
25 #include <lal/SFTfileIO.h>
26 #include <lal/Units.h>
40 #define GPS2REAL8(gps) (1.0 * (gps).gpsSeconds + 1.e-9 * (gps).gpsNanoSeconds )
54 for ( sft = 0; sft < sft_vect->
length; sft++ ) {
59 XLALPrintError(
"CompareSFTVectors(): SFT#%u epochs differ (%f/%f)!\n",
63 if ( strncmp( sft1.
name, sft2.
name,
sizeof( sft1.
name ) ) ) {
64 XLALPrintError(
"CompareSFTVectors(): SFT#%u names differ!\n", sft );
67 if ( sft1.
f0 != sft2.
f0 ) {
68 XLALPrintError(
"CompareSFTVectors(): f0 of SFT#%u differ (%f/%f)!\n",
69 sft, sft1.
f0, sft2.
f0 );
73 XLALPrintError(
"CompareSFTVectors(): deltaF of SFT#%u differ (%f/%f)!\n",
78 CHAR buf1[256], buf2[256];
85 XLALPrintError(
"CompareSFTVectors(): Units of SFT#%u differ (%s/%s)!\n",
90 XLALPrintError(
"CompareSFTVectors(): lengths of SFT#%u differ!\n", sft );
93 for ( bin = 0; bin < sft1.
data->
length; bin++ ) {
96 XLALPrintError(
"CompareSFTVectors(): bins %u of SFT#%u differ!\n", sft, bin );
157 XLALPrintError(
"\nLALCheckSFTs(): SFT-test1 has correct checksum but LALCheckSFTs claimed it hasn't.\n\n" );
164 XLALPrintError(
"\nLALCheckSFTs() failed to catch invalid CRC checksum in SFT-bad6 \n\n" );
199 TEST_DATA_DIR
"SFT-test1;"
200 TEST_DATA_DIR
"SFT-test2;"
201 TEST_DATA_DIR
"SFT-test3;"
202 TEST_DATA_DIR
"SFT-test5;"
203 TEST_DATA_DIR
"SFT-test6;"
204 TEST_DATA_DIR
"SFT-test7", NULL ) ) != NULL,
XLAL_EFUNC );
215 XLALPrintError(
"%s: XLALLoadMultiSFTs (cat, -1, -1) failed with xlalErrno = %d\n", fn, xlalErrno );
221 if ( ( sft_vect->
length != 4 )
222 || ( multsft_vect->
length != 2 )
224 XLALPrintError(
"\nFailed to read in multi-SFT from 2 IFOs 'SFT-test*'!\n\n" );
232 for ( X = 0; X < numIFOs; X ++ ) {
233 if ( CompareSFTVectors( multsft_vect->
data[X], multsft_vect2->
data[X] ) ) {
234 XLALPrintError(
"%s: comparing (X)XLALLoadMultiSFTs(): sft-vectors differ for X=%d\n", fn, X );
243 spec.window_param = 0.5;
246 strcpy( spec.privMisc,
"test" );
252 const CHAR *currSingleSFT = NULL;
254 FILE *fpConcat = NULL, *fpSingle = NULL;
255 int concat = 0, single = 0;
258 strcpy( spec.privMisc,
"testconcat" );
260 LALPrintError(
"\n XLALWriteSFTVector2StandardFile failed to write multi-SFT vector to file!\n\n" );
264 const UINT4 numSingleSFTs = 3;
265 const CHAR *singleSFTs[] = {
266 "H-1_H1_60SFT_test-000012345-61.sft",
267 "H-1_H1_60SFT_test-000012465-61.sft",
268 "H-1_H1_60SFT_test-000012585-61.sft"
270 printf(
"*** Comparing single and concatenated SFTs ***\n" );
272 const CHAR *concatSFT =
"H-3_H1_60SFT_testconcat-000012345-302.sft";
273 if ( ( fpConcat = fopen( concatSFT,
"rb" ) ) == NULL ) {
274 LALPrintError(
"\n Cound not open SFT '%s'!\n\n", concatSFT );
278 while ( !feof( fpConcat ) ) {
280 concat = fgetc( fpConcat );
281 if ( ferror( fpConcat ) ) {
288 if ( fpSingle == NULL ) {
290 if (
i == numSingleSFTs ) {
294 if ( ( fpSingle = fopen( singleSFTs[
i],
"rb" ) ) == NULL ) {
295 LALPrintError(
"\n Cound not open SFT '%s'!\n\n", singleSFTs[
i] );
298 currSingleSFT = singleSFTs[
i];
301 single = fgetc( fpSingle );
302 if ( ferror( fpSingle ) ) {
307 if ( feof( fpSingle ) ) {
318 if ( concat != single ) {
319 LALPrintError(
"\n Comparison failed between '%s'(last char = %i) and '%s'(last char = %i)!!\n\n",
320 concatSFT, concat, currSingleSFT, single );
325 printf(
"*** Comparing was successful!!! ***\n" );
337 multsft_vect2 = NULL;
345 if ( catalog->
length != 2 ) {
346 if ( lalDebugLevel ) {
347 XLALPrintError(
"\nFailed to find 'outputsft_r*.sft' in catalog\n\n" );
353 XLAL_EFAILED,
"catalog window type '%s' should be '%s'",
356 XLAL_EFAILED,
"catalog window parameter %g should be %g",
361 if ( sft_vect->
length != 2 ) {
362 if ( lalDebugLevel ) {
363 XLALPrintError(
"\nFailed to read back in 'outputsft_r*.sft'\n\n" );
370 XLALPrintError(
"\nXLALLoadSFTs() call failed (where it should have succeeded)!\n\n" );
375 if ( CompareSFTVectors( sft_vect, sft_vect2 ) ) {
387 #define TS_FNAME "testTimestamps.dat"
388 #define TS_FNAME_NEW "testTimestampsNew.dat"
401 char buf1[256], buf2[256];
402 for (
UINT4 i = 0;
i < numTS;
i ++ ) {
404 "Timestamps-lists differ in entry %" LAL_UINT4_FORMAT
": %s != %s\n",
i + 1,
XLALGPSToStr( buf1, &ts2->
data[
i] ),
XLALGPSToStr( buf2, &ts3->data[
i] ) );
415 XLALPrintError(
"\n\n--------------------------------------------------------------------------------\n" );
416 XLALPrintError(
"\n OK. All tests passed correctly ! (error-messages above are OK!)\n" );
417 XLALPrintError(
"\n--------------------------------------------------------------------------------\n" );
#define __func__
log an I/O error, i.e.
#define GPS2REAL8(gps)
convert GPS-time to REAL8
void LALCheckMemoryLeaks(void)
int main(int argc, char **argv)
char * XLALGPSToStr(char *s, const LIGOTimeGPS *t)
#define XLAL_INIT_DECL(var,...)
int LALPrintError(const char *fmt,...)
void XLALDestroySFTVector(SFTVector *vect)
XLAL interface to destroy an SFTVector.
void XLALDestroySFTCatalog(SFTCatalog *catalog)
Free an 'SFT-catalogue'.
MultiSFTVector * XLALLoadMultiSFTs(const SFTCatalog *inputCatalog, REAL8 fMin, REAL8 fMax)
Function to load a catalog of SFTs from possibly different detectors.
void XLALDestroyMultiSFTVector(MultiSFTVector *multvect)
Destroy a multi SFT-vector.
int XLALCheckCRCSFTCatalog(BOOLEAN *crc_check, SFTCatalog *catalog)
This function reads in the SFTs in the catalog and validates their CRC64 checksums.
SFTVector * XLALLoadSFTs(const SFTCatalog *catalog, REAL8 fMin, REAL8 fMax)
Load the given frequency-band [fMin, fMax) (half-open) from the SFT-files listed in the SFT-'catalogu...
SFTCatalog * XLALSFTdataFind(const CHAR *file_pattern, const SFTConstraints *constraints)
Find the list of SFTs matching the file_pattern and satisfying the given constraints,...
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).
LIGOTimeGPSVector * XLALReadTimestampsFile(const CHAR *fname)
backwards compatible wrapper to XLALReadTimestampsFileConstrained() without GPS-time constraints
int XLALWriteSFT2NamedFile(const SFTtype *sft, const CHAR *SFTfilename, const CHAR *SFTwindowtype, const REAL8 SFTwindowparam, const CHAR *SFTcomment)
Write the given SFTtype to a SFT file with the supplied filename.
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.
void XLALDestroyTimestampVector(LIGOTimeGPSVector *vect)
De-allocate a LIGOTimeGPSVector.
int XLALUnitCompare(const LALUnit *unit1, const LALUnit *unit2)
char * XLALUnitAsString(char *string, UINT4 length, const LALUnit *input)
#define XLAL_CHECK_MAIN(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
REAL8 XLALGPSDiff(const LIGOTimeGPS *t1, const LIGOTimeGPS *t0)
A vector of COMPLEX8FrequencySeries.
COMPLEX8FrequencySeries * data
Pointer to the data array.
UINT4 length
Number of elements in array.
A vector of 'timestamps' of type LIGOTimeGPS.
REAL8 deltaT
'length' of each timestamp (e.g.
LIGOTimeGPS * data
array of timestamps
UINT4 length
number of timestamps
A collection of SFT vectors – one for each IFO in a multi-IFO search.
UINT4 length
number of ifos
SFTVector ** data
sftvector for each ifo
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...
const char * window_type
window function applied to SFT
REAL8 window_param
parameter of window function, if required
Structure specifying an SFT file name, following the convention in .