28 #include <gsl/gsl_math.h>
30 #include <lal/Units.h>
31 #include <lal/FrequencySeries.h>
126 tmp = fMinIn / dFreq;
130 REAL8 fMaxIn = fMinIn + BandIn;
131 tmp = fMaxIn / dFreq;
135 UINT4 num_bins = (
UINT4 )( imax - imin + 1 );
138 ( *firstBin ) = imin;
139 ( *numBins ) = num_bins;
156 if ( ( sft =
XLALCalloc( 1,
sizeof( *sft ) ) ) == NULL ) {
212 ( *dest ) = ( *src );
237 if ( ( vect =
XLALCalloc( 1,
sizeof( *vect ) ) ) == NULL ) {
247 for ( iSFT = 0; iSFT <
numSFTs; iSFT ++ ) {
254 for (
j = 0;
j < iSFT;
j++ ) {
281 if ( ( vect =
XLALCalloc( 1,
sizeof( *vect ) ) ) == NULL ) {
343 memcpy( thisSFTOut, thisSFTIn,
sizeof( *thisSFTOut ) );
344 thisSFTOut->
data = tmp;
378 multSFTVec->
length = numifo;
382 for (
UINT4 k = 0;
k < numifo;
k++ ) {
407 multSFTVec->
length = numifo;
411 for (
UINT4 k = 0;
k < numifo;
k++ ) {
426 if ( multvect == NULL ) {
475 UINT4 firstBinSFT = round( fMinSFT /
df );
476 UINT4 lastBinSFT = firstBinSFT + ( numBinsSFT - 1 );
479 UINT4 firstBinExt, numBinsExt;
481 UINT4 lastBinExt = firstBinExt + ( numBinsExt - 1 );
484 "Requested frequency-bins [%f,%f]Hz = [%d, %d] not contained within SFT's [%f, %f]Hz = [%d,%d].\n",
485 fMin,
fMin +
Band, firstBinExt, lastBinExt, fMinSFT, fMinSFT + ( numBinsSFT - 1 ) *
df, firstBinSFT, lastBinSFT );
487 INT4 firstBinOffset = firstBinExt - firstBinSFT;
489 if ( ( *outSFT ) == NULL ) {
492 if ( ( *outSFT )->data == NULL ) {
495 if ( ( *outSFT )->data->length != numBinsExt ) {
497 ( *outSFT )->data->length = numBinsExt;
501 ( *( *outSFT ) ) = ( *inSFT );
502 ( *outSFT )->data =
ptr;
503 ( *outSFT )->f0 = firstBinExt *
df ;
506 memcpy( ( *outSFT )->data->data, inSFT->
data->
data + firstBinOffset, numBinsExt *
sizeof( ( *outSFT )->data->data[0] ) );
617 UINT4 firstBinSFT = round( fMinSFT /
df );
618 UINT4 lastBinSFT = firstBinSFT + ( numBinsSFT - 1 );
622 UINT4 numBinsExt = lastBinExt - firstBinExt + 1;
625 "Requested frequency-bins [%f,%f)Hz = [%d, %d] not contained within SFT's [%f, %f)Hz = [%d,%d].\n",
626 fMin,
fMin +
Band, firstBinExt, lastBinExt, fMinSFT, fMinSFT + ( numBinsSFT - 1 ) *
df, firstBinSFT, lastBinSFT );
628 INT4 firstBinOffset = firstBinExt - firstBinSFT;
630 if ( ( *outSFT ) == NULL ) {
633 if ( ( *outSFT )->data == NULL ) {
636 if ( ( *outSFT )->data->length != numBinsExt ) {
638 ( *outSFT )->data->length = numBinsExt;
642 ( *( *outSFT ) ) = ( *inSFT );
643 ( *outSFT )->data =
ptr;
644 ( *outSFT )->f0 = firstBinExt *
df ;
647 memcpy( ( *outSFT )->data->data, inSFT->
data->
data + firstBinOffset, numBinsExt *
sizeof( ( *outSFT )->data->data[0] ) );
725 memset( &( vect->
data[oldlen] ), 0,
sizeof( vect->
data[0] ) );
749 while ( ( j < IFOs->length ) && ( strncmp(
IFOs->data[
i],
multiSFTs->data[
j]->data[0].name, 2 ) != 0 ) ) {
850 UINT4 numIFOs =
a->length;
852 for (
UINT4 X = 0; X < numIFOs; X ++ ) {
897 int firstRelative = firstBinOut - firstBinIn;
975 if ( !multisfts || ( multisfts->
length == 0 ) ) {
979 for (
i = 0;
i < multisfts->
length;
i++ ) {
991 for (
i = 0;
i < multisfts->
length;
i++ ) {
1024 if ( !multisfts || ( multisfts->
length == 0 ) ) {
1028 for (
i = 0;
i < multisfts->
length;
i++ ) {
1036 firstSFT = ( multisfts->
data[0]->
data );
1044 for (
i = 0;
i < multisfts->
length;
i++ ) {
1088 UINT4 indexOfInputSFTVector = 0;
1089 UINT4 numberOfSFTsLoadedIntoOutputVector = 0;
1091 XLAL_CHECK_NULL( indexOfInputSFTVector < sfts->length,
XLAL_FAILURE,
"At least one timestamp is not in the range specified by the SFT vector" );
1093 for (
UINT4 jj = indexOfInputSFTVector; jj < sfts->
length; jj++ ) {
1095 indexOfInputSFTVector = jj + 1;
1097 numberOfSFTsLoadedIntoOutputVector++;
1146 REAL8 Tsft0 = 1.0 / dFreq;
1148 if ( fabs( ( Tsft0 - round( Tsft0 ) ) ) / Tsft0 < 10 *
LAL_REAL8_EPS ) {
1149 Tsft = round( Tsft0 );
1215 if ( name1[0] < name2[0] ) {
1217 }
else if ( name1[0] > name2[0] ) {
1219 }
else if ( name1[1] < name2[1] ) {
1221 }
else if ( name1[1] > name2[1] ) {
1240 }
else if ( desc1->
f0 < desc2->
f0 ) {
1242 }
else if ( desc1->
f0 > desc2->
f0 ) {
#define __func__
log an I/O error, i.e.
#define GPS2REAL8(gps)
convert GPS-time to REAL8
Internal SFT types and functions.
static const REAL8 fudge_up
static const REAL8 fudge_down
LIGOTimeGPSVector * timestamps
COMPLEX8FrequencySeries * XLALResizeCOMPLEX8FrequencySeries(COMPLEX8FrequencySeries *series, int first, size_t length)
void * XLALCalloc(size_t m, size_t n)
void * XLALRealloc(void *p, size_t n)
#define PULSAR_MAX_DETECTORS
maximal number of detectors we can handle (for static arrays of detector quantities)
int XLALSFTVectorResizeBand(SFTVector *SFTs, REAL8 f0, REAL8 Band)
Resize the frequency-band of a given SFT vector to [f0, f0+Band].
SFTtype * XLALCreateSFT(UINT4 numBins)
XLAL function to create one SFT-struct.
SFTVector * XLALDuplicateSFTVector(const SFTVector *sftsIn)
Create a complete copy of an SFT vector.
void XLALDestroySFTVector(SFTVector *vect)
XLAL interface to destroy an SFTVector.
int XLALSFTVectorAdd(SFTVector *a, const SFTVector *b)
Adds SFT-data from SFTvector 'b' to elements of SFTVector 'a'.
void XLALDestroyMultiSFTVector(MultiSFTVector *multvect)
Destroy a multi SFT-vector.
MultiSFTVector * XLALExtractStrictBandFromMultiSFTVector(const MultiSFTVector *inSFTs, REAL8 fMin, REAL8 Band)
Return a copy of a MultiSFT vector containing only the bins in [fMin, fMin+Band).
int XLALExtractBandFromSFT(SFTtype **outSFT, const SFTtype *inSFT, REAL8 fMin, REAL8 Band)
Return an SFTs containing only the bins in [fMin, fMin+Band].
MultiSFTVector * XLALExtractBandFromMultiSFTVector(const MultiSFTVector *inSFTs, REAL8 fMin, REAL8 Band)
Return a MultiSFT vector containing only the bins in [fMin, fMin+Band].
int XLALExtractStrictBandFromSFT(SFTtype **outSFT, const SFTtype *inSFT, REAL8 fMin, REAL8 Band)
Return a copy of an SFT containing only the bins in [fMin, fMin+Band).
REAL8 TSFTfromDFreq(REAL8 dFreq)
int XLALFindCoveringSFTBins(UINT4 *firstBin, UINT4 *numBins, REAL8 fMinIn, REAL8 BandIn, REAL8 Tsft)
Return the 'effective' frequency-band [fMinEff, fMaxEff] = [firstBin, lastBin] * 1/Tsft,...
int XLALMultiSFTVectorResizeBand(MultiSFTVector *multiSFTs, REAL8 f0, REAL8 Band)
Resize the frequency-band of a given multi-SFT vector to [f0, f0+Band].
MultiSFTVector * XLALCreateMultiSFTVector(UINT4 length, UINT4Vector *numsft)
Create a multi-IFO SFT vector with a given number of bins per SFT and number of SFTs per IFO (which w...
int XLALSFTResizeBand(SFTtype *SFT, REAL8 f0, REAL8 Band)
Resize the frequency-band of a given SFT to [f0, f0+Band].
int XLALAppendSFT2Vector(SFTVector *vect, const SFTtype *sft)
Append the given SFTtype to the SFT-vector (no SFT-specific checks are done!)
SFTVector * XLALCreateEmptySFTVector(UINT4 numSFTs)
XLAL function to create an SFTVector of numSFT SFTs (which are not allocated).
MultiSFTVector * XLALExtractMultiSFTVectorWithMultiTimestamps(const MultiSFTVector *multiSFTs, const MultiLIGOTimeGPSVector *multiTimestamps)
Extract a MultiSFTVector from another MultiSFTVector but only those timestamps matching.
int XLALSFTAdd(SFTtype *a, const SFTtype *b)
Adds SFT-data from SFT 'b' to SFT 'a'.
int XLALCopySFT(SFTtype *dest, const SFTtype *src)
Copy an entire SFT-type into another.
UINT4 XLALRoundFrequencyUpToSFTBin(const REAL8 freq, const REAL8 df)
Round a REAL8 frequency up to the nearest integer SFT bin number.
MultiSFTVector * XLALCreateEmptyMultiSFTVector(UINT4Vector *numsft)
Create an empty multi-IFO SFT vector with a given number of SFTs per IFO (which are not allocated).
int XLALLatestMultiSFTsample(LIGOTimeGPS *out, const MultiSFTVector *multisfts)
Find the time of the end of the latest SFT in a multi-SFT data structure.
UINT4 XLALRoundFrequencyDownToSFTBin(const REAL8 freq, const REAL8 df)
Round a REAL8 frequency down to the nearest integer SFT bin number.
void XLALDestroySFT(SFTtype *sft)
Destructor for one SFT.
int XLALReorderMultiSFTVector(MultiSFTVector *multiSFTs, const LALStringVector *IFOs)
Reorder the MultiSFTVector with specified list of IFOs.
int XLALMultiSFTVectorAdd(MultiSFTVector *a, const MultiSFTVector *b)
Adds SFT-data from MultiSFTvector 'b' to elements of MultiSFTVector 'a'.
int XLALCWGPSinRange(const LIGOTimeGPS gps, const LIGOTimeGPS *minGPS, const LIGOTimeGPS *maxGPS)
Defines the official CW convention for whether a GPS time is 'within' a given range,...
int compareSFTloc(const void *ptr1, const void *ptr2)
int compareDetNameCatalogs(const void *ptr1, const void *ptr2)
SFTVector * XLALCreateSFTVector(UINT4 numSFTs, UINT4 numBins)
XLAL function to create an SFTVector of numSFT SFTs with SFTlen frequency-bins (which will be allocat...
SFTVector * XLALExtractBandFromSFTVector(const SFTVector *inSFTs, REAL8 fMin, REAL8 Band)
Return a vector of SFTs containing only the bins in [fMin, fMin+Band].
SFTVector * XLALExtractStrictBandFromSFTVector(const SFTVector *inSFTs, REAL8 fMin, REAL8 Band)
Return a copy of a vector of SFTs containing only the bins in [fMin, fMin+Band).
int compareSFTdesc(const void *ptr1, const void *ptr2)
int XLALEarliestMultiSFTsample(LIGOTimeGPS *out, const MultiSFTVector *multisfts)
Finds the earliest timestamp in a multi-SFT data structure.
int compareSFTepoch(const void *ptr1, const void *ptr2)
SFTVector * XLALExtractSFTVectorWithTimestamps(const SFTVector *sfts, const LIGOTimeGPSVector *timestamps)
Extract an SFTVector from another SFTVector but only those timestamps matching.
int XLALUnitCompare(const LALUnit *unit1, const LALUnit *unit2)
COMPLEX8Vector * XLALCreateCOMPLEX8Vector(UINT4 length)
void XLALDestroyCOMPLEX8Vector(COMPLEX8Vector *vector)
#define XLAL_ERROR_NULL(...)
#define XLAL_CHECK(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_CHECK_NULL(assertion,...)
#define XLAL_PRINT_DEPRECATION_WARNING(replacement)
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
int XLALGPSCmp(const LIGOTimeGPS *t0, const LIGOTimeGPS *t1)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
REAL8 XLALGPSDiff(const LIGOTimeGPS *t1, const LIGOTimeGPS *t0)
INT8 XLALGPSToINT8NS(const LIGOTimeGPS *epoch)
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.
LIGOTimeGPS * data
array of timestamps
UINT4 length
number of timestamps
A collection of (multi-IFO) LIGOTimeGPSVector time-stamps vectors.
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
A 'descriptor' of an SFT: basically containing the header-info plus an opaque description of where ex...
SFTtype header
SFT-header info.
struct tagSFTLocator * locator
internal description of where to find this SFT [opaque!]