Commit 62cf1fc6 authored by Reinhard Prix's avatar Reinhard Prix

Simplify types carrying multi-IFO detector and noise-floor info

   - split MultiDetectorInfo type into MultiLALDetector and MultiNoiseFloor types
     (current usage indicates that it's better to separate these data structures)
   - use fixed-size MultiXXX arrays to simplify memory handling
   - adapted all affected lalsuite codes
   - adjusted octapps to this API change in issue refs #1090
   - refs #1084
Original: 44644a4ff70e5c89ffa6deb94eb33a144546bd5b
parent 35181c58
......@@ -561,20 +561,8 @@ XLALInitCode ( ConfigVariables *cfg, const UserInput_t *uvar )
}
UINT4 numDetectors = uvar->IFOs->length;
MultiLALDetector *multiDet;
if ( (multiDet = XLALCreateMultiLALDetector ( numDetectors )) == NULL ) {
XLALPrintError ("%s: XLALCreateMultiLALDetector(1) failed with errno=%d\n", __func__, xlalErrno );
XLAL_ERROR ( XLAL_EFUNC );
}
LALDetector *site = NULL;
for ( UINT4 X=0; X < numDetectors; X++ ) {
if ( (site = XLALGetSiteInfo ( uvar->IFOs->data[X] )) == NULL ) {
XLALPrintError ("%s: Failed to get site-info for detector '%s'\n", __func__, uvar->IFOs->data[X] );
XLAL_ERROR ( XLAL_EFUNC );
}
multiDet->data[X] = (*site); /* copy! */
XLALFree ( site );
}
MultiLALDetector multiDet;
XLAL_CHECK ( XLALParseMultiLALDetector ( &multiDet, uvar->IFOs ) == XLAL_SUCCESS, XLAL_EFUNC );
/* init timestamps vector covering observation time */
UINT4 numSteps = (UINT4) ceil ( uvar->dataDuration / uvar->TAtom );
......@@ -598,7 +586,7 @@ XLALInitCode ( ConfigVariables *cfg, const UserInput_t *uvar )
}
/* get detector states */
if ( (cfg->multiDetStates = XLALGetMultiDetectorStates ( multiTS, multiDet, edat, 0.5 * uvar->TAtom )) == NULL ) {
if ( (cfg->multiDetStates = XLALGetMultiDetectorStates ( multiTS, &multiDet, edat, 0.5 * uvar->TAtom )) == NULL ) {
XLALPrintError ( "%s: XLALGetMultiDetectorStates() failed.\n", __func__ );
XLAL_ERROR ( XLAL_EFUNC );
}
......@@ -653,7 +641,6 @@ XLALInitCode ( ConfigVariables *cfg, const UserInput_t *uvar )
} /* if ( uvar->computeLV && uvar->LVlX ) */
/* get rid of all temporary memory allocated for this step */
XLALDestroyMultiLALDetector ( multiDet );
XLALDestroyEphemerisData ( edat );
XLALDestroyMultiTimestamps ( multiTS );
multiTS = NULL;
......
......@@ -697,12 +697,9 @@ XLALInitCode ( ConfigVariables *cfg, const UserInput_t *uvar )
XLALPrintError ("%s: Failed to get site-info for detector '%s'\n", __func__, uvar->IFO );
XLAL_ERROR ( XLAL_EFUNC );
}
MultiLALDetector *multiDet;
if ( (multiDet = XLALCreateMultiLALDetector ( 1 )) == NULL ) { /* currently only implemented for single-IFO case */
XLALPrintError ("%s: XLALCreateMultiLALDetector(1) failed with errno=%d\n", __func__, xlalErrno );
XLAL_ERROR ( XLAL_EFUNC );
}
multiDet->data[0] = (*site); /* copy! */
MultiLALDetector multiDet;
multiDet.length = 1;
multiDet.sites[0] = (*site); /* copy! */
XLALFree ( site );
/* init timestamps vector covering observation time */
......@@ -728,13 +725,12 @@ XLALInitCode ( ConfigVariables *cfg, const UserInput_t *uvar )
}
/* get detector states */
if ( (cfg->multiDetStates = XLALGetMultiDetectorStates ( multiTS, multiDet, edat, 0.5 * uvar->TAtom )) == NULL ) {
if ( (cfg->multiDetStates = XLALGetMultiDetectorStates ( multiTS, &multiDet, edat, 0.5 * uvar->TAtom )) == NULL ) {
XLALPrintError ( "%s: XLALGetMultiDetectorStates() failed.\n", __func__ );
XLAL_ERROR ( XLAL_EFUNC );
}
/* get rid of all temporary memory allocated for this step */
XLALDestroyMultiLALDetector ( multiDet );
XLALDestroyEphemerisData ( edat );
XLALDestroyMultiTimestamps ( multiTS );
multiTS = NULL;
......
......@@ -76,9 +76,10 @@
/** configuration-variables derived from user-variables */
typedef struct
{
EphemerisData *edat; /**< ephemeris-data */
MultiLIGOTimeGPSVector *multiTimestamps;/**< a vector of timestamps to generate time-series/SFTs for */
MultiDetectorInfo detInfo; //!< detectors and noise-floors (for Gaussian noise) to generate data for
EphemerisData *edat; /**< ephemeris-data */
MultiLIGOTimeGPSVector *multiTimestamps; /**< a vector of timestamps to generate time-series/SFTs for */
MultiLALDetector multiIFO; //!< detectors to generate data for
MultiNoiseFloor multiNoiseFloor; //!< ... and corresponding noise-floors to generate Gaussian white noise for
SFTCatalog *noiseCatalog; /**< catalog of noise-SFTs */
MultiSFTCatalogView *multiNoiseCatalogView; /**< multi-IFO 'view' of noise-SFT catalogs */
......@@ -186,7 +187,8 @@ main(int argc, char *argv[])
CWMFDataParams DataParams = empty_CWMFDataParams;
DataParams.fMin = uvar.fmin;
DataParams.Band = uvar.Band;
DataParams.detInfo = GV.detInfo;
DataParams.multiIFO = GV.multiIFO;
DataParams.multiNoiseFloor = GV.multiNoiseFloor;
DataParams.multiTimestamps = (*GV.multiTimestamps);
DataParams.randSeed = uvar.randSeed;
DataParams.SFTWindowType = uvar.SFTWindowType;
......@@ -365,7 +367,7 @@ XLALInitMakefakedata ( ConfigVars_t *cfg, UserVariables_t *uvar )
XLAL_CHECK ( ! ( have_IFOs && have_noiseSFTs ), XLAL_EINVAL, "Allow only *one* of --IFOs or --noiseSFTs to determine detectors\n");
if ( have_IFOs ) {
XLAL_CHECK ( XLALParseMultiDetectorInfo ( &(cfg->detInfo), uvar->IFOs, uvar->sqrtSX ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( XLALParseMultiLALDetector ( &(cfg->multiIFO), uvar->IFOs ) == XLAL_SUCCESS, XLAL_EFUNC );
}
// TIMESTAMPS: either from --timestampsFiles, --startTime+duration, or --noiseSFTs
......@@ -406,7 +408,7 @@ XLALInitMakefakedata ( ConfigVars_t *cfg, UserVariables_t *uvar )
// extract multi-timestamps from the multi-SFT-catalog view
XLAL_CHECK ( (cfg->multiTimestamps = XLALTimestampsFromMultiSFTCatalogView ( cfg->multiNoiseCatalogView )) != NULL, XLAL_EFUNC );
// extract IFOs from multi-SFT catalog
XLAL_CHECK ( XLALMultiDetectorInfoFromMultiSFTCatalogView ( &(cfg->detInfo), cfg->multiNoiseCatalogView ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( XLALMultiLALDetectorFromMultiSFTCatalogView ( &(cfg->multiIFO), cfg->multiNoiseCatalogView ) == XLAL_SUCCESS, XLAL_EFUNC );
} // endif have_noiseSFTs
else if ( have_timestampsFiles )
......@@ -425,12 +427,20 @@ XLALInitMakefakedata ( ConfigVars_t *cfg, UserVariables_t *uvar )
{
LIGOTimeGPS tStart;
XLALGPSSetREAL8 ( &tStart, uvar->startTime );
XLAL_CHECK ( ( cfg->multiTimestamps = XLALMakeMultiTimestamps ( tStart, uvar->duration, uvar->Tsft, uvar->SFToverlap, cfg->detInfo.length )) != NULL, XLAL_EFUNC );
XLAL_CHECK ( ( cfg->multiTimestamps = XLALMakeMultiTimestamps ( tStart, uvar->duration, uvar->Tsft, uvar->SFToverlap, cfg->multiIFO.length )) != NULL, XLAL_EFUNC );
} // endif have_startTime
else {
XLAL_ERROR (XLAL_EFAILED, "Something went wrong with my internal logic ..\n");
}
// check if the user asked for Gaussian white noise to be produced (sqrtSn[X]!=0), otherwise leave noise-floors at 0
if ( uvar->sqrtSX != NULL ) {
XLAL_CHECK ( XLALParseMultiNoiseFloor ( &(cfg->multiNoiseFloor), uvar->sqrtSX ) == XLAL_SUCCESS, XLAL_EFUNC );
} else {
cfg->multiNoiseFloor.length = cfg->multiIFO.length;
// values remain at their default sqrtSn[X] = 0;
}
/* Init ephemerides */
XLAL_CHECK ( (cfg->edat = XLALInitBarycenter ( uvar->ephemEarth, uvar->ephemSun )) != NULL, XLAL_EFUNC );
......
......@@ -317,19 +317,11 @@ XLALInitCode ( ConfigVariables *cfg, const UserVariables_t *uvar, const char *ap
cfg->averageABCD = uvar->averageABCD;
/* convert detector names into site-info */
MultiLALDetector *multiDet;
XLAL_CHECK ( (multiDet = XLALCreateMultiLALDetector ( numDetectors )) != NULL, XLAL_EFUNC, "XLALCreateMultiLALDetector(1) failed." );
LALDetector *site = NULL;
for ( UINT4 X=0; X < numDetectors; X++ ) {
XLAL_CHECK ( (site = XLALGetSiteInfo ( uvar->IFOs->data[X] )) != NULL, XLAL_EFUNC, "Failed to get site-info for detector '%s'.", uvar->IFOs->data[X] );
multiDet->data[X] = (*site); /* copy! */
XLALFree ( site );
}
MultiLALDetector multiDet;
XLAL_CHECK ( XLALParseMultiLALDetector ( &multiDet, uvar->IFOs ) == XLAL_SUCCESS, XLAL_EFUNC );
/* get detector states */
XLAL_CHECK ( (cfg->multiDetStates = XLALGetMultiDetectorStates ( cfg->multiTimestamps, multiDet, cfg->edat, 0.5 * uvar->Tsft )) != NULL, XLAL_EFUNC, "XLALGetDetectorStates() failed." );
XLALDestroyMultiLALDetector ( multiDet );
XLAL_CHECK ( (cfg->multiDetStates = XLALGetMultiDetectorStates ( cfg->multiTimestamps, &multiDet, cfg->edat, 0.5 * uvar->Tsft )) != NULL, XLAL_EFUNC, "XLALGetDetectorStates() failed." );
cfg->multiWeights = NULL; // FIXME: noise weights not supported (yet)
......
......@@ -251,9 +251,10 @@ int main(int argc, char *argv[])
CWMFDataParams DataParams;
DataParams.fMin = round(inputParams->fmin*inputParams->Tcoh - inputParams->dfmax*inputParams->Tcoh - 0.5*(inputParams->blksize-1) - (REAL8)(inputParams->maxbinshift) - 6.0)/inputParams->Tcoh;
DataParams.Band = round(inputParams->fspan*inputParams->Tcoh + 2.0*inputParams->dfmax*inputParams->Tcoh + (inputParams->blksize-1) + (REAL8)(2.0*inputParams->maxbinshift) + 12.0)/inputParams->Tcoh;
DataParams.detInfo.length = 1;
DataParams.detInfo.sites[0] = *(inputParams->det);
DataParams.detInfo.sqrtSn[0] = 0.0;
DataParams.multiIFO.length = 1;
DataParams.multiIFO.sites[0] = *(inputParams->det);
DataParams.multiNoiseFloor.length = 1;
DataParams.multiNoiseFloor.sqrtSn[0] = args_info.avesqrtSh_arg;
DataParams.multiTimestamps = *multiTimestamps;
DataParams.randSeed = args_info.injRandSeed_arg;
DataParams.SFTWindowType = "Hann";
......@@ -272,7 +273,7 @@ int main(int argc, char *argv[])
//If not signal only, create sfts that include noise or extract a band from real data
if (!inputParams->signalOnly) {
if (args_info.gaussNoiseWithSFTgaps_given || args_info.timestampsFile_given || args_info.segmentFile_given || !(args_info.sftDir_given || args_info.sftFile_given)) {
DataParams.detInfo.sqrtSn[0] = args_info.avesqrtSh_arg;
DataParams.multiNoiseFloor.sqrtSn[0] = args_info.avesqrtSh_arg;
XLAL_CHECK( XLALCWMakeFakeMultiData(&sftvector, NULL, NULL, &DataParams, edat) == XLAL_SUCCESS, XLAL_EFUNC );
} else {
SFTConstraints constraints = empty_constraints;
......@@ -296,7 +297,7 @@ int main(int argc, char *argv[])
//If printing the data outputs, then do that here
if ((args_info.printSignalData_given || args_info.printMarginalizedSignalData_given) && args_info.injectionSources_given) {
DataParams.detInfo.sqrtSn[0] = 0.0;
DataParams.multiNoiseFloor.sqrtSn[0] = 0.0;
PulsarParamsVector *oneSignal = NULL;
XLAL_CHECK( (oneSignal = XLALCreatePulsarParamsVector(1)) != NULL, XLAL_EFUNC );
......
......@@ -35,6 +35,7 @@
#include <lal/SFTutils.h>
#include <lal/LogPrintf.h>
#include <lal/DopplerScan.h>
#include <lal/DetectorStates.h>
#include <lal/ExtrapolatePulsarSpins.h>
#include <lal/LALInitBarycenter.h>
#include <lal/NormalizeSFTRngMed.h>
......@@ -106,7 +107,7 @@ int main(int argc, char *argv[]){
MultiPSDVector *multiPSDs = NULL;
MultiNoiseWeights *multiWeights = NULL;
MultiLIGOTimeGPSVector *multiTimes = NULL;
MultiLALDetector *multiDetectors = NULL;
MultiLALDetector multiDetectors;
MultiDetectorStateSeries *multiStates = NULL;
MultiAMCoeffs *multiCoeffs = NULL;
SFTIndexList *sftIndices = NULL;
......@@ -259,13 +260,13 @@ int main(int argc, char *argv[]){
}
/* read the detector information from the SFTs */
if ((multiDetectors = XLALExtractMultiLALDetectorFromSFTs ( inputSFTs )) == NULL){
LogPrintf ( LOG_CRITICAL, "%s: XLALExtractMultiLALDetectorFromSFTs() failed with errno=%d\n", __func__, xlalErrno );
if ( XLALMultiLALDetectorFromMultiSFTs ( &multiDetectors, inputSFTs ) != XLAL_SUCCESS){
LogPrintf ( LOG_CRITICAL, "%s: XLALMultiLALDetectorFromMultiSFTs() failed with errno=%d\n", __func__, xlalErrno );
XLAL_ERROR( XLAL_EFUNC );
}
/* Find the detector state for each SFT */
if ((multiStates = XLALGetMultiDetectorStates ( multiTimes, multiDetectors, config.edat, 0.0 )) == NULL){
if ((multiStates = XLALGetMultiDetectorStates ( multiTimes, &multiDetectors, config.edat, 0.0 )) == NULL){
LogPrintf ( LOG_CRITICAL, "%s: XLALGetMultiDetectorStates() failed with errno=%d\n", __func__, xlalErrno );
XLAL_ERROR( XLAL_EFUNC );
}
......@@ -459,7 +460,6 @@ int main(int argc, char *argv[]){
XLALDestroySFTIndexList( sftIndices );
XLALDestroyMultiAMCoeffs ( multiCoeffs );
XLALDestroyMultiDetectorStateSeries ( multiStates );
XLALDestroyMultiLALDetector( multiDetectors );
XLALDestroyMultiTimestamps ( multiTimes );
XLALDestroyMultiNoiseWeights ( multiWeights );
XLALDestroyMultiPSDVector ( multiPSDs );
......
......@@ -121,7 +121,8 @@ typedef struct
EphemerisData *edat; /**< ephemeris data (from XLALInitBarycenter()) */
LALSegList segmentList; /**< segment list contains start- and end-times of all segments */
PulsarParams signalParams; /**< GW signal parameters: Amplitudes + doppler */
MultiDetectorInfo detInfo; /**< (multi-)detector info */
MultiLALDetector multiIFO; /**< (multi-)detector info */
MultiNoiseFloor multiNoiseFloor; /**< ... and corresponding noise-floors to be used as weights */
DopplerCoordinateSystem coordSys; /**< array of enums describing Doppler-coordinates to compute metric in */
ResultHistory_t *history; /**< history trail leading up to and including this application */
} ConfigVariables;
......@@ -262,7 +263,8 @@ main(int argc, char *argv[])
metricParams.segmentList = config.segmentList;
metricParams.coordSys = config.coordSys;
metricParams.metricType = uvar.metricType;
metricParams.detInfo = config.detInfo;
metricParams.multiIFO = config.multiIFO;
metricParams.multiNoiseFloor = config.multiNoiseFloor;
metricParams.signalParams = config.signalParams;
metricParams.projectCoord = uvar.projection - 1; /* user-input counts from 1, but interally we count 0=1st coord. (-1==no projection) */
metricParams.approxPhase = uvar.approxPhase;
......@@ -472,7 +474,14 @@ XLALInitCode ( ConfigVariables *cfg, const UserVariables_t *uvar, const char *ap
}
/* ----- initialize IFOs and (Multi-)DetectorStateSeries ----- */
XLAL_CHECK ( XLALParseMultiDetectorInfo ( &cfg->detInfo, uvar->IFOs, uvar->sqrtSX ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( XLALParseMultiLALDetector ( &cfg->multiIFO, uvar->IFOs ) == XLAL_SUCCESS, XLAL_EFUNC );
UINT4 numDet = cfg->multiIFO.length;
XLAL_CHECK ( numDet >= 1, XLAL_EINVAL );
if ( uvar->IFOs ) {
XLAL_CHECK ( XLALParseMultiNoiseFloor ( &cfg->multiNoiseFloor, uvar->IFOs ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( numDet == cfg->multiNoiseFloor.length, XLAL_EINVAL );
}
/* ---------- translate coordinate system into internal representation ---------- */
if ( XLALDopplerCoordinateNames2System ( &cfg->coordSys, uvar->coords ) ) {
......@@ -607,17 +616,17 @@ XLALOutputDopplerMetric ( FILE *fp, const DopplerMetric *metric, const ResultHis
fprintf ( fp, "Tspan = %.1f;\n", Tspan );
fprintf ( fp, "Nseg = %d;\n", Nseg );
fprintf ( fp, "detectors = {");
for ( i=0; i < meta->detInfo.length; i ++ )
for ( i=0; i < meta->multiIFO.length; i ++ )
{
if ( i > 0 ) fprintf ( fp, ", ");
fprintf ( fp, "\"%s\"", meta->detInfo.sites[i].frDetector.name );
fprintf ( fp, "\"%s\"", meta->multiIFO.sites[i].frDetector.name );
}
fprintf ( fp, "};\n");
fprintf ( fp, "detectorWeights = [");
for ( i=0; i < meta->detInfo.length; i ++ )
for ( i=0; i < meta->multiNoiseFloor.length; i ++ )
{
if ( i > 0 ) fprintf ( fp, ", ");
fprintf ( fp, "%f", meta->detInfo.detWeights[i] );
fprintf ( fp, "%f", meta->multiNoiseFloor.sqrtSn[i] );
}
fprintf ( fp, "];\n");
......
......@@ -80,9 +80,10 @@ XLALCWMakeFakeMultiData ( MultiSFTVector **multiSFTs, ///< [out] pointer to op
const MultiLIGOTimeGPSVector *multiTimestamps = &(dataParams->multiTimestamps);
// check multi-detector input
XLAL_CHECK ( dataParams->detInfo.length >= 1, XLAL_EINVAL );
UINT4 numDet = dataParams->detInfo.length;
XLAL_CHECK ( dataParams->multiIFO.length >= 1, XLAL_EINVAL );
UINT4 numDet = dataParams->multiIFO.length;
XLAL_CHECK ( multiTimestamps->length == numDet, XLAL_EINVAL, "Inconsistent number of IFOs: detInfo says '%d', multiTimestamps says '%d'\n", numDet, multiTimestamps->length );
XLAL_CHECK ( dataParams->multiNoiseFloor.length == numDet, XLAL_EINVAL );
// check Tsft, consistent over detectors
REAL8 Tsft = multiTimestamps->data[0]->deltaT;
......@@ -111,9 +112,10 @@ XLALCWMakeFakeMultiData ( MultiSFTVector **multiSFTs, ///< [out] pointer to op
{
/* detector params */
CWMFDataParams dataParamsX = (*dataParams); // struct-copy for general settings
dataParamsX.detInfo.length = 1;
dataParamsX.detInfo.sites[0] = dataParams->detInfo.sites[X];
dataParamsX.detInfo.sqrtSn[0] = dataParams->detInfo.sqrtSn[X];
dataParamsX.multiIFO.length = 1;
dataParamsX.multiIFO.sites[0] = dataParams->multiIFO.sites[X];
dataParamsX.multiNoiseFloor.length = 1;
dataParamsX.multiNoiseFloor.sqrtSn[0] = dataParams->multiNoiseFloor.sqrtSn[X];
MultiLIGOTimeGPSVector mTimestamps = empty_MultiLIGOTimeGPSVector;
mTimestamps.length = 1;
mTimestamps.data = &(multiTimestamps->data[X]); // such that pointer mTimestamps.data[0] = multiTimestamps->data[X]
......@@ -164,7 +166,8 @@ XLALCWMakeFakeData ( SFTVector **SFTvect,
XLAL_CHECK ( dataParams != NULL, XLAL_EINVAL );
XLAL_CHECK ( edat != NULL, XLAL_EINVAL );
XLAL_CHECK ( dataParams->detInfo.length ==1, XLAL_EINVAL );
XLAL_CHECK ( dataParams->multiIFO.length == 1, XLAL_EINVAL );
XLAL_CHECK ( dataParams->multiNoiseFloor.length == 1, XLAL_EINVAL );
XLAL_CHECK ( dataParams->multiTimestamps.length == 1, XLAL_EINVAL );
XLAL_CHECK ( dataParams->multiTimestamps.data[0] != NULL, XLAL_EINVAL );
......@@ -174,7 +177,7 @@ XLALCWMakeFakeData ( SFTVector **SFTvect,
REAL8 fSamp = 2.0 * fBand;
const LIGOTimeGPSVector *timestamps = dataParams->multiTimestamps.data[0];
const LALDetector *site = &dataParams->detInfo.sites[0];
const LALDetector *site = &dataParams->multiIFO.sites[0];
REAL8 Tsft = timestamps->deltaT;
// if SFT output requested: need *effective* fMin and Band consistent with SFT bins
......@@ -276,10 +279,10 @@ XLALCWMakeFakeData ( SFTVector **SFTvect,
XLAL_CHECK ( (Tseries_sum = XLALAddREAL4TimeSeries ( Tseries_sum, Tseries_i )) != NULL, XLAL_EFUNC );
XLALDestroyREAL4TimeSeries ( Tseries_i );
}
} // for iInj = 1 ... (numPulsars-1)
} // for iInj < numSources
// add Gaussian noise if requested
REAL8 sqrtSn = dataParams->detInfo.sqrtSn[0];
/* add Gaussian noise if requested */
REAL8 sqrtSn = dataParams->multiNoiseFloor.sqrtSn[0];
if ( sqrtSn > 0)
{
REAL8 noiseSigma = sqrtSn * sqrt ( fBand );
......
......@@ -72,7 +72,8 @@ typedef struct tagCWMFDataParams
{
REAL8 fMin; //!< smallest frequency guaranteed to be generated [returned fMin can be smaller]
REAL8 Band; //!< smallest frequency band guaranteed to be generated [returned Band can be larger]
MultiDetectorInfo detInfo; //!< detectors and noise-floors (for Gaussian noise) to generate data for
MultiLALDetector multiIFO; //!< detectors to generate data for
MultiNoiseFloor multiNoiseFloor; //!< ... and corresponding noise-floors to generate Gaussian white noise for
MultiLIGOTimeGPSVector multiTimestamps; //!< timestamps to generate SFTs for
const char *SFTWindowType; //!< window to apply to the SFT timeseries
REAL8 SFTWindowBeta; //!< 'beta' parameter required for *some* windows [otherwise must be 0]
......
......@@ -39,7 +39,6 @@
/*---------- internal types ----------*/
/*---------- empty initializers ---------- */
const MultiDetectorInfo empty_MultiDetectorInfo;
/*---------- Global variables ----------*/
......@@ -48,7 +47,6 @@ int XLALFillDetectorTensor (DetectorState *detState, const LALDetector *detector
/*==================== FUNCTION DEFINITIONS ====================*/
/**
* \deprecated Use XLALGetDetectorStates() instead
*/
......@@ -332,15 +330,15 @@ LALGetMultiDetectorStates( LALStatus *status, /**< pointer to LALStatus struc
* instead of a multi-SFT vector. We therefore need to extract this info from the
* multi-SFT vector first
*/
MultiLALDetector *multiIFO;
if ( ( multiIFO = XLALExtractMultiLALDetectorFromSFTs ( multiSFTs )) == NULL ) {
XLALPrintError ("%s: XLALExtractMultiLALDetectorFromSFTs() failed with code %d\n", __func__, xlalErrno );
MultiLALDetector multiIFO;
if ( XLALMultiLALDetectorFromMultiSFTs ( &multiIFO, multiSFTs ) != XLAL_SUCCESS ) {
XLALPrintError ("%s: XLALMultiLALDetectorFromMultiSFTs() failed with code %d\n", __func__, xlalErrno );
ABORT ( status, DETECTORSTATES_EXLAL, DETECTORSTATES_MSGEXLAL );
}
MultiLIGOTimeGPSVector *multiTS;
if ( ( multiTS = XLALExtractMultiTimestampsFromSFTs ( multiSFTs )) == NULL ) {
XLALPrintError ("%s: XLALExtractMultiTimestampsFromSFTs() failed with code %d\n", __func__, xlalErrno );
XLALDestroyMultiLALDetector ( multiIFO );
ABORT ( status, DETECTORSTATES_EXLAL, DETECTORSTATES_MSGEXLAL );
}
......@@ -349,16 +347,14 @@ LALGetMultiDetectorStates( LALStatus *status, /**< pointer to LALStatus struc
/* the API of this LAL interface specifies a hardcoded shift by Tsft/2 of all timestamps */
REAL8 Tsft = 1.0 / multiSFTs->data[0]->data[0].deltaF;
REAL8 tOffset = 0.5 * Tsft;
if ( ( ret = XLALGetMultiDetectorStates( multiTS, multiIFO, edat, tOffset )) == NULL ) {
if ( ( ret = XLALGetMultiDetectorStates( multiTS, &multiIFO, edat, tOffset )) == NULL ) {
XLALPrintError ("%s: XLALGetMultiDetectorStates() failed with code %d\n", __func__, xlalErrno );
XLALDestroyMultiLALDetector ( multiIFO );
XLALDestroyMultiTimestamps ( multiTS );
ABORT ( status, DETECTORSTATES_EXLAL, DETECTORSTATES_MSGEXLAL );
}
/* free temporary mem */
XLALDestroyMultiTimestamps ( multiTS );
XLALDestroyMultiLALDetector ( multiIFO );
(*mdetStates) = ret;
......@@ -527,93 +523,6 @@ void LALGetMultiDetectorVelTimePos(LALStatus *status,
/* normal exit */
RETURN (status);
}
/**
* Simple creator function for MultiLALDetector with numDetectors entries
*/
MultiLALDetector *
XLALCreateMultiLALDetector ( UINT4 numDetectors )
{
MultiLALDetector *ret;
if ( (ret = XLALMalloc ( sizeof(*ret) )) == NULL ) {
XLALPrintError ("%s: XLALMalloc(%d) failed.\n", __func__, sizeof(*ret) );
XLAL_ERROR_NULL ( XLAL_ENOMEM );
}
ret->length = numDetectors;
if ( (ret->data = XLALCalloc ( numDetectors, sizeof(*ret->data) )) == NULL ) {
XLALPrintError ("%s: XLALCalloc(%d, %d) failed.\n", __func__, numDetectors, sizeof(*ret->data) );
XLALFree ( ret );
XLAL_ERROR_NULL ( XLAL_ENOMEM );
}
return ret;
} /* XLALCreateMultiLALDetector() */
/**
* Corresponding destructor function for MultiLALDetector.
* As usual this allows NULL input.
*/
void
XLALDestroyMultiLALDetector ( MultiLALDetector *multiIFO )
{
if ( !multiIFO )
return;
if ( multiIFO->data )
XLALFree ( multiIFO->data );
XLALFree ( multiIFO );
return;
} /* XLALDestroyMultiLALDetector() */
/**
* Given a multi-SFT vector, return a MultiLALDetector vector holding the multi-IFO detector infos
*/
MultiLALDetector *
XLALExtractMultiLALDetectorFromSFTs ( const MultiSFTVector *multiSFTs )
{
/* check input consistency */
if ( !multiSFTs ) {
XLALPrintError ("%s: invalid NULL input 'multiSFTs'\n", __func__ );
XLAL_ERROR_NULL ( XLAL_EINVAL );
}
UINT4 numDetectors = multiSFTs->length;
/* create output vector */
MultiLALDetector *multiIFO;
if ( ( multiIFO = XLALCreateMultiLALDetector ( numDetectors ) ) == NULL ) {
XLALPrintError ("%s: XLALCreateMultiLALDetector(%d) failed.\n", __func__, numDetectors );
XLAL_ERROR_NULL ( XLAL_EFUNC );
}
/* step through multi-IFO vector and extract detector-info */
UINT4 X;
for ( X=0; X < numDetectors; X ++ )
{
LALDetector *det = NULL;
/* get LALDetector struct for this detector */
if ( (det = XLALGetSiteInfo ( multiSFTs->data[X]->data[0].name )) == NULL ) {
XLALPrintError ("%s: call to XLALGetSiteInfo(%s) has failed with code %s.\n", __func__, multiSFTs->data[X]->data[0].name, xlalErrno );
XLALDestroyMultiLALDetector ( multiIFO );
XLAL_ERROR_NULL ( XLAL_EFUNC );
}
multiIFO->data[X] = (*det);
XLALFree ( det );
} /* for X < numDetectors */
/* return result */
return multiIFO;
} /* XLALExtractMultiLALDetectorFromSFTs() */
/** Create a DetectorStateSeries with length entries */
DetectorStateSeries*
......@@ -761,7 +670,7 @@ XLALGetDetectorStates ( const LIGOTimeGPSVector *timestamps, /**< array of GPS t
*/
MultiDetectorStateSeries *
XLALGetMultiDetectorStates( const MultiLIGOTimeGPSVector *multiTS, /**< [in] multi-IFO timestamps */
const MultiLALDetector *multiIFO, /**< [in] multi-IFO array holding detector info */
const MultiLALDetector *multiIFO, /**< [in] multi-IFO array holding detector info */
const EphemerisData *edat, /**< [in] ephemeris data */
REAL8 tOffset /**< [in] shift all timestamps by this amount */
)
......@@ -801,7 +710,7 @@ XLALGetMultiDetectorStates( const MultiLIGOTimeGPSVector *multiTS, /**< [in] mul
for ( X=0; X < numDetectors; X ++ )
{
LIGOTimeGPSVector *tsX = multiTS->data[X];
LALDetector *detX = &multiIFO->data[X];
const LALDetector *detX = &(multiIFO->sites[X]);
if ( !tsX || !detX ) {
XLALPrintError ("%s: invalid NULL data-vector tsX[%d] = %p, detX[%d] = %p\n", __func__, X, tsX, X, detX );
......@@ -838,42 +747,62 @@ XLALGetMultiDetectorStates( const MultiLIGOTimeGPSVector *multiTS, /**< [in] mul
} /* XLALGetMultiDetectorStates() */
/**
* Parse string-vectors (typically input by user) of N detector noise-floors \f$\sqrt{S_X}\f$
* for detectors \f$X=1\ldots N\f$, where here we assume equal number of SFTs per detector
* such that \f$S^{-1} = \frac{1}{N}\sum_{X=0}^{N-1} S_X^{-1}\f$.
*
* returns MultiNoiseFloor struct 'multiNoiseFloor'.
*/
int
XLALParseMultiNoiseFloor ( MultiNoiseFloor *multiNoiseFloor, /**< [out] parsed multi-IFO noise floor info */
const LALStringVector *sqrtSX /**< [in] string-list of \f$\sqrt{S_X}\f$ for detectors \f$X\f$ */
)
{
XLAL_CHECK ( multiNoiseFloor != NULL, XLAL_EINVAL );
XLAL_CHECK ( sqrtSX != NULL, XLAL_EINVAL );
UINT4 numDet = sqrtSX->length;
XLAL_CHECK ( (numDet > 0) && (numDet <= PULSAR_MAX_DETECTORS), XLAL_EINVAL );
/* initialize empty return struct */
multiNoiseFloor->length = numDet;
/* parse input strings and fill multiNoiseFloor */
REAL8 calSInvNdet = 0;
for ( UINT4 X = 0; X < numDet; X ++ )
{
const char *sqrtSnStr = sqrtSX->data[X];
REAL8 sqrtSn;
XLAL_CHECK ( sscanf ( sqrtSnStr , "%lf", &sqrtSn ) == 1, XLAL_EINVAL, "Failed to parse '%s' into REAL8\n", sqrtSnStr );
XLAL_CHECK ( sqrtSn >= 0, XLAL_EDOM );
multiNoiseFloor->sqrtSn[X] = sqrtSn;
calSInvNdet += 1 / SQUARE ( sqrtSn );
} /* for X < numDet */
multiNoiseFloor->sqrtSnTotal = sqrt ( numDet / calSInvNdet ); // SnTotal = harmonicMean{S_X} assuming equal number of SFT per detector
return XLAL_SUCCESS;
} /* XLALParseMultiNoiseFloor() */
/**
* Parse string-vectors (typically input by user) of N detector-names
* and N noise-power \f$\sqrt{S_X}\f$ for detectors \f$X=1\ldots N\f$,
* returns a MultiDetectorInfo struct with normalized detector "weights".
*
* NOTE: you can pass sqrtSX == NULL, corresponding to zero-noise, equal-sensitivity detectors,
* ie. this is interpreted as \f$S_X=0\f$, and all noise-weights will be equal: \f$w_X=1\f$
*
* NOTE2: the derived noise-weights 'detWeights' are defined according to the conventions in
* CFSv2_Notes.pdf [LIGO-T0900149-v3] at https://dcc.ligo.org/cgi-bin/DocDB/ShowDocument?docid=1665, namely
* \f$w_X \equiv \frac{S_X^{-1}}{\mathcal{S}^{-1}}\f$, where
* the normalization constant \f$\mathcal{S}\f$ is defined as the harmonic mean
* \f$\mathcal{S}^{-1} \equiv \frac{1}{N}\sum_{X=1}^{N} S_X^{-1}\f$,
* such that \f$\sum_{X=1}^N w_X = N\f$.
* for detectors \f$X=1\ldots N\f$, returns a MultiLALDetector struct
*
*/
int
XLALParseMultiDetectorInfo ( MultiDetectorInfo *detInfo, /**< [out] parsed detector-info struct */
const LALStringVector *detNames, /**< [in] list of detector names */
const LALStringVector *sqrtSX /**< [in] string-list of \f$\sqrt{S_X}\f$ for detectors \f$X\f$ (can be NULL) */
)
XLALParseMultiLALDetector ( MultiLALDetector *detInfo, /**< [out] parsed detector-info struct */