27#include <lal/SFTfileIO.h>
28#include <lal/LALStdio.h>
29#include <lal/LogPrintf.h>
30#include <lal/UserInput.h>
31#include <lal/LALPulsarVCSInfo.h>
35int main(
int argc,
char **argv )
38 lalUserVarHelpDescription =
"Provide SFTs to this program for computing coherence between two channels, saved as ASCII data file for use by Fscan";
43 SFTCatalog *catalog_a = NULL, *catalog_b = NULL;
44 SFTVector *sft_vect_a = NULL, *sft_vect_b = NULL;
50 CHAR outbase[256], outfile0[512];
52 CHAR *SFTpattA = NULL, *SFTpattB = NULL, *outputDir = NULL, *outputBname = NULL, *
header = NULL;
53 INT4 startGPS = 0, endGPS = 0;
62 " - '<SFT file>;<SFT file>;...', where <SFT file> may contain wildcards\n - 'list:<file containing list of SFT files>'" ) ==
XLAL_SUCCESS,
XLAL_EFUNC );
64 " - '<SFT file>;<SFT file>;...', where <SFT file> may contain wildcards\n - 'list:<file containing list of SFT files>'" ) ==
XLAL_SUCCESS,
XLAL_EFUNC );
81 printf(
"Starting spec_coherence...\n" );
89 constraints.maxStartTime = &endTime;
92 printf(
"Calling XLALSFTdataFind with SFTpattA=%s\n", SFTpattA );
94 printf(
"Calling XLALSFTdataFind with SFTpattB=%s\n", SFTpattB );
98 if ( errnumA != 0 || errnumB != 0 ) {
99 if ( errnumA != 0 && allow_skipping ) {
101 if ( catalog_a != NULL ) {
104 if ( catalog_b != NULL ) {
109 }
else if ( errnumA != 0 ) {
112 if ( errnumB != 0 && allow_skipping ) {
114 if ( catalog_a != NULL ) {
117 if ( catalog_b != NULL ) {
122 }
else if ( errnumB != 0 ) {
128 XLAL_CHECK_MAIN( catalog_b->length > 0,
XLAL_EFAILED,
"No SFTs found for Ch B, please examine start time, end time, frequency range, etc." );
131 LogPrintf(
LOG_NORMAL,
"Channel B %s has length of %u SFT files\n", SFTpattB, catalog_b->length );
134 snprintf( outbase,
sizeof( outbase ),
"%s/%s", outputDir, outputBname );
139 snprintf( outfile0,
sizeof( outfile0 ),
"%s.txt", outbase );
141 COHOUT = fopen( outfile0,
"w" );
143 XLAL_CHECK_MAIN( COHOUT != NULL,
XLAL_EIO,
"Failed to open '%s' for writing: %s", outfile0, strerror( fopenerr ) );
152 printf(
"Looping over SFTs to compute coherence\n" );
155 fprintf( stderr,
"Extracting SFT %d...\n",
j );
160 if ( errnumB != 0 ) {
167 XLAL_CHECK_MAIN( sft_vect_b->data[0].deltaF * timebaseline == 1.0,
XLAL_EINVAL,
"Time baseline of SFTs and the request do not match" );
183 coh->
data[
i] = sft_vect_a->
data[0].
data->
data[
i] * conj( sft_vect_b->data[0].data->data[
i] );
185 psd_b->data[
i] = sft_vect_b->data[0].data->data[
i] * conj( sft_vect_b->data[0].data->data[
i] );
189 coh->
data[
i] += sft_vect_a->
data[0].
data->
data[
i] * conj( sft_vect_b->data[0].data->data[
i] );
191 psd_b->data[
i] += sft_vect_b->data[0].data->data[
i] * conj( sft_vect_b->data[0].data->data[
i] );
197 sft_vect_a = sft_vect_b = NULL;
208 fprintf( COHOUT,
"%16.8f %g\n",
f, COH );
211 fprintf( stderr,
"Destroying Variables\n" );
219 fprintf( stderr,
"Closing Files\n" );
223 fprintf( stderr,
"Done Destroying Variables\n" );
224 fprintf( stderr,
"end of spec_coherence\n" );
225 fprintf( stderr,
"Spec_coherence_done!\n" );
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
SFTVector * extract_one_sft(const SFTCatalog *full_catalog, const LIGOTimeGPS starttime, const REAL8 f_min, const REAL8 f_max)
#define XLAL_INIT_DECL(var,...)
char char * XLALStringDuplicate(const char *s)
void LogPrintf(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
void XLALDestroySFTVector(SFTVector *vect)
XLAL interface to destroy an SFTVector.
void XLALDestroySFTCatalog(SFTCatalog *catalog)
Free an 'SFT-catalogue'.
SFTCatalog * XLALSFTdataFind(const CHAR *file_pattern, const SFTConstraints *constraints)
Find the list of SFTs matching the file_pattern and satisfying the given constraints,...
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
COMPLEX16Vector * XLALCreateCOMPLEX16Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
void XLALDestroyCOMPLEX16Vector(COMPLEX16Vector *vector)
#define XLAL_CHECK_MAIN(assertion,...)
#define XLAL_ERROR_MAIN(...)
#define XLAL_TRY(statement, errnum)
int main(int argc, char **argv)
A vector of COMPLEX8FrequencySeries.
COMPLEX8FrequencySeries * data
Pointer to the data array.
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.