Commit 16fa6a84 authored by Karl Wette's avatar Karl Wette Committed by Reinhard Prix
Browse files

ComputeFstat: change XLALGetFstatMethodName(FstatMethodType) to...

ComputeFstat: change XLALGetFstatMethodName(FstatMethodType) to XLALGetFstatInputMethodName(const FstatInput*)
- Since F-statistic method might now be selected at runtime, cannot know for
  sure which method is in use until XLALCreateFstatInput() has been called
- Best therefore to query the FstatInput* for which method is being used
- Refs #2001
Original: f405ec2758fc7f932bd4af62cbe3c03db02b8a30
parent 76f4e1e5
......@@ -126,8 +126,6 @@ typedef struct
REAL8 tauTemplate; /**< total loop time per template, includes candidate-handling (transient stats, toplist etc) */
REAL8 tauF0; /**< Demod timing constant = time per template per SFT */
FstatMethodType FstatMethod; /**< Fstat-method used */
/* ----- transient-specific timings */
UINT4 tauMin; /**< shortest transient timescale [s] */
UINT4 tauMax; /**< longest transient timescale [s] */
......@@ -318,7 +316,7 @@ int compareFstatCandidates_BSGL ( const void *candA, const void *candB );
int WriteFstatLog ( const CHAR *log_fname, const CHAR *logstr );
CHAR *XLALGetLogString ( const ConfigVariables *cfg );
int write_TimingInfo ( const CHAR *timingFile, const timingInfo_t *ti );
int write_TimingInfo ( const CHAR *timingFile, const timingInfo_t *ti, const ConfigVariables *cfg );
gsl_vector_int *resize_histogram(gsl_vector_int *old_hist, size_t size);
......@@ -760,14 +758,12 @@ int main(int argc,char *argv[])
timing.NSFTs = GV.NSFTs;
timing.NFreq = (UINT4) ( 1 + floor ( GV.searchRegion.fkdotBand[0] / GV.dFreq ) );
timing.FstatMethod = GV.FstatMethod;
// compute averages:
timing.tauFstat /= num_templates;
timing.tauTemplate /= num_templates;
timing.tauF0 = timing.tauFstat / timing.NSFTs;
XLAL_CHECK_MAIN ( write_TimingInfo ( uvar.outputTiming, &timing ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK_MAIN ( write_TimingInfo ( uvar.outputTiming, &timing, &GV ) == XLAL_SUCCESS, XLAL_EFUNC );
} /* if timing output requested */
......@@ -1550,7 +1546,7 @@ XLALGetLogString ( const ConfigVariables *cfg )
XLAL_CHECK_NULL ( (logstr = XLALStringAppend ( logstr, "\n" )) != NULL, XLAL_EFUNC );
XLAL_CHECK_NULL ( (logstr = XLALStringAppend ( logstr, cfg->VCSInfoString )) != NULL, XLAL_EFUNC );
XLAL_CHECK_NULL ( snprintf ( buf, BUFLEN, "%%%% FstatMethod used: '%s'\n", XLALGetFstatMethodName ( cfg->FstatMethod ) ) < BUFLEN, XLAL_EBADLEN );
XLAL_CHECK_NULL ( snprintf ( buf, BUFLEN, "%%%% FstatMethod used: '%s'\n", XLALGetFstatInputMethodName ( cfg->Fstat_in ) ) < BUFLEN, XLAL_EBADLEN );
XLAL_CHECK_NULL ( (logstr = XLALStringAppend ( logstr, buf )) != NULL, XLAL_EFUNC );
XLAL_CHECK_NULL ( (logstr = XLALStringAppend ( logstr, "%% Started search: " )) != NULL, XLAL_EFUNC );
......@@ -2141,7 +2137,7 @@ XLALCenterIsLocalMax ( const scanlineWindow_t *scanWindow, const UINT4 rankingSt
*
*/
int
write_TimingInfo ( const CHAR *fname, const timingInfo_t *ti )
write_TimingInfo ( const CHAR *fname, const timingInfo_t *ti, const ConfigVariables *cfg )
{
XLAL_CHECK ( (fname != NULL) && (ti != NULL), XLAL_EINVAL );
......@@ -2159,7 +2155,7 @@ write_TimingInfo ( const CHAR *fname, const timingInfo_t *ti )
}
fprintf ( fp, "%8d %10d %10.1e %10.1e %10.1e %10s\n",
ti->NSFTs, ti->NFreq, ti->tauFstat, ti->tauTemplate, ti->tauF0, XLALGetFstatMethodName(ti->FstatMethod) );
ti->NSFTs, ti->NFreq, ti->tauFstat, ti->tauTemplate, ti->tauF0, XLALGetFstatInputMethodName(cfg->Fstat_in) );
fclose ( fp );
return XLAL_SUCCESS;
......
......@@ -207,7 +207,7 @@ int XLALExtrapolateToplistPulsarSpins ( toplist_t *list,
const LIGOTimeGPS usefulParamsRefTime,
const LIGOTimeGPS finegridRefTime);
static int write_TimingInfo ( const CHAR *fname, const timingInfo_t *ti );
static int write_TimingInfo ( const CHAR *fname, const timingInfo_t *ti, const FstatInputVector* Fstat_in_vec );
/* ---------- Global variables -------------------- */
LALStatus *global_status; /* a global pointer to MAIN()s head of the LALStatus structure */
......@@ -749,7 +749,6 @@ int MAIN( int argc, char *argv[]) {
XLALPrintError ("XLALParseFstatMethodString() failed.\n");
return( HIERARCHICALSEARCH_EBAD );
}
LogPrintf (LOG_NORMAL, "FstatMethod used: '%s'\n", XLALGetFstatMethodName( usefulParams.Fmethod ) );
usefulParams.useResamp = XLALFstatMethodClassIsResamp ( usefulParams.Fmethod );
usefulParams.mismatch1 = uvar_mismatch1;
......@@ -1703,7 +1702,7 @@ int MAIN( int argc, char *argv[]) {
timing.FstatMethod = usefulParams.Fmethod;
if ( uvar_outputTiming ) {
XLAL_CHECK ( write_TimingInfo ( uvar_outputTiming, &timing ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( write_TimingInfo ( uvar_outputTiming, &timing, Fstat_in_vec ) == XLAL_SUCCESS, XLAL_EFUNC );
}
} // if uvar_outputTiming
......@@ -2065,6 +2064,9 @@ void SetUpSFTs( LALStatus *status, /**< pointer to LALStatus structure */
if ( k == 0 ) {
in->sharedWorkspace = optionalArgs.sharedWorkspace = XLALGetSharedFstatWorkspace ( (*p_Fstat_in_vec)->data[0] );
}
if ( k == 0 ) {
LogPrintf (LOG_NORMAL, "FstatMethod used: '%s'\n", XLALGetFstatInputMethodName( (*p_Fstat_in_vec)->data[k] ) );
}
/* get SFT detectors and timestamps */
const MultiLALDetector *multiIFO = XLALGetFstatInputDetectors( (*p_Fstat_in_vec)->data[k] );
......@@ -2773,7 +2775,7 @@ int XLALExtrapolateToplistPulsarSpins ( toplist_t *list, /**< [out/
*
*/
static int
write_TimingInfo ( const CHAR *fname, const timingInfo_t *ti )
write_TimingInfo ( const CHAR *fname, const timingInfo_t *ti, const FstatInputVector* Fstat_in_vec )
{
/* input sanity */
if ( !fname || !ti ) {
......@@ -2795,7 +2797,7 @@ write_TimingInfo ( const CHAR *fname, const timingInfo_t *ti )
}
fprintf ( fp, "%8d %6d %10d %6d %10d %10d %10d %10.1e %10.1e %10.1e %15s\n",
ti->Nseg, ti->Ndet, ti->Tcoh, ti->Nsft, ti->NFreqCo, ti->Nco, ti->Nic, ti->c0ic, ti->c1co, ti->c0Demod, XLALGetFstatMethodName(ti->FstatMethod) );
ti->Nseg, ti->Ndet, ti->Tcoh, ti->Nsft, ti->NFreqCo, ti->Nco, ti->Nic, ti->c0ic, ti->c1co, ti->c0Demod, XLALGetFstatInputMethodName( Fstat_in_vec->data[0] ) );
fclose ( fp );
return XLAL_SUCCESS;
......
......@@ -57,6 +57,7 @@ typedef struct tagFstatInput_Resamp FstatInput_Resamp;
// Internal definition of input data structure
struct tagFstatInput {
FstatMethodType method; // Method to use for computing the F-statistic
FstatInput_Common common; // Common input data
FstatInput_Demod* demod; // Demodulation input data
FstatInput_Resamp* resamp; // Resampling input data
......@@ -300,6 +301,7 @@ XLALCreateFstatInput ( const SFTCatalog *SFTcatalog, ///< [in] Cata
FstatInput* input;
XLAL_CHECK_NULL ( (input = XLALCalloc ( 1, sizeof(*input) )) != NULL, XLAL_ENOMEM );
FstatInput_Common *common = &input->common; // handy shortcut
input->method = optArgs->FstatMethod;
// create method-specific input data
if ( XLALFstatMethodClassIsDemod ( optArgs->FstatMethod ) )
......@@ -470,6 +472,20 @@ XLALCreateFstatInput ( const SFTCatalog *SFTcatalog, ///< [in] Cata
} // XLALCreateFstatInput()
///
/// Returns the human-readable name of the \f$\mathcal{F}\f$-statistic method being used by a \c FstatInput structure.
///
const CHAR *
XLALGetFstatInputMethodName ( const FstatInput* input ///< [in] \c FstatInput structure.
)
{
// Check input
XLAL_CHECK_NULL ( input != NULL, XLAL_EINVAL );
return FstatMethodNames[input->method].name;
} // XLALGetFstatMethodName()
///
/// Returns the detector information stored in a \c FstatInput structure.
///
......@@ -851,16 +867,6 @@ XLALFstatMethodIsAvailable ( FstatMethodType i )
} // XLALFstatMethodIsAvailable()
///
/// Provide human-readable names for the different \f$\mathcal{F}\f$-statistic method variants in #FstatMethodType.
///
const CHAR *
XLALGetFstatMethodName ( FstatMethodType i )
{
XLAL_CHECK_NULL ( (i > FMETHOD_START) && (i < FMETHOD_END) && FstatMethodNames[i].name!=NULL, XLAL_EDOM, "Invalid FstatMethodType = %d\n", i );
return FstatMethodNames[i].name;
} // XLALGetFstatMethodName()
///
/// Return pointer to a static help string enumerating all (available) #FstatMethodType options.
/// Also indicates which is the (guessed) available 'best' method available.
......
......@@ -294,7 +294,6 @@ typedef struct tagFstatResults {
} FstatResults;
// ---------- API function prototypes ----------
const CHAR *XLALGetFstatMethodName ( FstatMethodType i);
int XLALFstatMethodIsAvailable ( FstatMethodType i );
const CHAR *XLALFstatMethodHelpString ( void );
int XLALParseFstatMethodString ( FstatMethodType *Fmethod, const char *s );
......@@ -310,6 +309,7 @@ FstatInput *
XLALCreateFstatInput ( const SFTCatalog *SFTcatalog, const REAL8 minCoverFreq, const REAL8 maxCoverFreq, const REAL8 dFreq,
const EphemerisData *ephemerides, const FstatOptionalArgs *optionalArgs );
const CHAR *XLALGetFstatInputMethodName ( const FstatInput* input );
const MultiLALDetector* XLALGetFstatInputDetectors ( const FstatInput* input );
const MultiLIGOTimeGPSVector* XLALGetFstatInputTimestamps ( const FstatInput* input );
const MultiNoiseWeights* XLALGetFstatInputNoiseWeights ( const FstatInput* input );
......
......@@ -258,7 +258,7 @@ main ( int argc, char *argv[] )
tauF1NoBuf += tauF1NoBuf_i;
fprintf (stderr, "%-15s: tauF1Buf = %.2g s, tauF1NoBuf = %.2g s, memSFTs = %.1f MB, memMaxCompute = %.1f MB\n",
XLALGetFstatMethodName ( FstatMethod ), tauF1Buf_i, tauF1NoBuf_i, memSFTs, memMaxCompute );
XLALGetFstatInputMethodName ( inputs->data[0] ), tauF1Buf_i, tauF1NoBuf_i, memSFTs, memMaxCompute );
XLALDestroyFstatInputVector ( inputs );
XLALDestroyFstatWorkspace ( sharedWorkspace );
......
......@@ -188,7 +188,7 @@ main ( int argc, char *argv[] )
{
FILE *fp;
char fname[1024]; XLAL_INIT_MEM ( fname );
snprintf ( fname, sizeof(fname)-1, "twoF%s-iSky%02d-if1dot%02d-iPeriod%02d.dat", XLALGetFstatMethodName(iMethod), iSky, if1dot, iPeriod );
snprintf ( fname, sizeof(fname)-1, "twoF%s-iSky%02d-if1dot%02d-iPeriod%02d.dat", XLALGetFstatInputMethodName(input[iMethod]), iSky, if1dot, iPeriod );
XLAL_CHECK ( (fp = fopen ( fname, "wb" )) != NULL, XLAL_EFUNC );
for ( UINT4 k = 0; k < results[iMethod]->numFreqBins; k ++ )
{
......@@ -211,10 +211,10 @@ main ( int argc, char *argv[] )
// compare to first result
if ( iMethod != firstMethod )
{
XLALPrintInfo ("Comparing results between method '%s' and '%s'\n", XLALGetFstatMethodName(firstMethod), XLALGetFstatMethodName(iMethod) );
XLALPrintInfo ("Comparing results between method '%s' and '%s'\n", XLALGetFstatInputMethodName(input[firstMethod]), XLALGetFstatInputMethodName(input[iMethod]) );
if ( compareFstatResults ( results[firstMethod], results[iMethod] ) != XLAL_SUCCESS )
{
XLALPrintError ("Comparison between method '%s' and '%s' failed\n", XLALGetFstatMethodName(firstMethod), XLALGetFstatMethodName(iMethod) );
XLALPrintError ("Comparison between method '%s' and '%s' failed\n", XLALGetFstatInputMethodName(input[firstMethod]), XLALGetFstatInputMethodName(input[iMethod]) );
XLAL_ERROR ( XLAL_EFUNC );
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment