Commit c30bde72 authored by Karl Wette's avatar Karl Wette
Browse files

Merge branch 'RP-PredictFstat-simplify-input-logic-and-cleanup-plus-modernize' into 'master'

lalapps_PredictFstat: simplify input logic, cleanup plus modernize some internals

See merge request lscsoft/lalsuite!77
parents 3b619fc1 19c2f16d
Pipeline #14013 failed with stages
in 181 minutes and 56 seconds
......@@ -82,7 +82,7 @@ fi
echo "done."
## ---------- predict F-stat value 'PFS'
cmdline="${pfs_code} --Alpha=$Alpha --Delta=$Delta --Freq=$Freq --h0=$h0 --cosi=$cosi --psi=$psi --phi0=$phi0 --IFO=$IFO --DataFiles='$SFTdir/*.sft' --PureSignal --assumeSqrtSX=1"
cmdline="${pfs_code} --Alpha=$Alpha --Delta=$Delta --Freq=$Freq --h0=$h0 --cosi=$cosi --psi=$psi --phi0=$phi0 --DataFiles='$SFTdir/*.sft' --PureSignal --assumeSqrtSX=1"
if [ "$DEBUG" ]; then echo $cmdline; fi
echo -n "Running $cmdline ... "
resPFS0=`$cmdline`
......
......@@ -33,7 +33,7 @@ Ftolerance=0.05
Tsft=1800;
startTime=711595934
duration=144000 ## 40 hours
endTime=$(echo $startTime $duration | awk '{printf "%.1f", $1 + $2}');
mfd_FreqBand=2.0;
Alpha=2.0
......@@ -105,7 +105,7 @@ else
fi
resSAF=`echo $tmp | awk '{printf "%g", 2.0 * $1}'`
pfs_CL_common=" --Alpha=$Alpha --Delta=$Delta --cosi=$cosi --h0=$h0 --psi=$psi --IFOs=$IFO"
pfs_CL_common=" --Alpha=$Alpha --Delta=$Delta --cosi=$cosi --h0=$h0 --psi=$psi"
## ---------- Run PredictFstat{NoiseWeights} ----------
outfile_pfs1="__tmp_PFS1.dat";
pfs_CL="${pfs_CL_common} --DataFiles=\"${SFTdir}/*.sft\" --Freq=$Freq --outputFstat=$outfile_pfs1"
......@@ -138,7 +138,7 @@ resPFS0=`echo $tmp | awk '{printf "%g", $1}'`
## ---------- Run PredictFstat{timestamps,assumeSqrtSX} ----------
outfile_pfs2="__tmp_PFS2.dat";
pfs_CL="${pfs_CL_common} --timestampsFiles=${timestamps} --Tsft=$Tsft --outputFstat=$outfile_pfs2 --assumeSqrtSX=${noiseSqrtSh}"
pfs_CL="${pfs_CL_common} --timestampsFiles=${timestamps} --Tsft=$Tsft --outputFstat=$outfile_pfs2 --assumeSqrtSX=${noiseSqrtSh} --IFOs=$IFO"
cmdline="$pfs_path $pfs_CL"
if [ "$DEBUG" ]; then echo $cmdline; fi
echo -n "Running ${pfs_code}{timestamps,assumeSqrtSX} ... "
......@@ -151,12 +151,12 @@ else
fi
resPFS2=`echo $tmp | awk '{printf "%g", $1}'`
## ---------- Run PredictFstat{startTime+duration,assumeSqrtSX} ----------
## ---------- Run PredictFstat{minStartTime+maxStartTime,assumeSqrtSX} ----------
outfile_pfs3="__tmp_PFS3.dat";
pfs_CL="${pfs_CL_common} --startTime=$startTime --duration=$duration --Tsft=$Tsft --outputFstat=$outfile_pfs3 --assumeSqrtSX=${noiseSqrtSh}"
pfs_CL="${pfs_CL_common} --minStartTime=$startTime --maxStartTime=$endTime --Tsft=$Tsft --outputFstat=$outfile_pfs3 --assumeSqrtSX=${noiseSqrtSh} --IFOs=$IFO"
cmdline="$pfs_path $pfs_CL"
if [ "$DEBUG" ]; then echo $cmdline; fi
echo -n "Running ${pfs_code}{startTime+duration,assumeSqrtSX} ... "
echo -n "Running ${pfs_code}{minStartTime+maxStartTime,assumeSqrtSX} ... "
if ! tmp=`eval $cmdline`; then
echo "FAILED:"
echo $cmdline
......@@ -172,7 +172,7 @@ echo "SemiAnalyticF: 2F_SA = $resSAF"
echo "PredictFstat{assumeSqrtSX}: 2F_PF0 = $resPFS0"
echo "PredictFstat{NoiseWeights}: 2F_PF1 = $resPFS1"
echo "PredictFstat{timestamps,assumeSqrtSX}: 2F_PF2 = $resPFS2"
echo "PredictFstat{startTime+duration,assumeSqrtSX}: 2F_PF2 = $resPFS3"
echo "PredictFstat{minStartTime+maxStartTime,assumeSqrtSX}: 2F_PF2 = $resPFS3"
echo
......@@ -214,7 +214,7 @@ if [ "$fail2" ]; then
else
echo " ==> OK."
fi
echo -n "Relative deviation 2F_PF{startTime+duration,assumeSqrtSX} wrt 2F_PF{assumeSqrtSX} = ${eps3}% (tolerance = ${tolerance0}%)"
echo -n "Relative deviation 2F_PF{minStartTime+maxStartTime,assumeSqrtSX} wrt 2F_PF{assumeSqrtSX} = ${eps3}% (tolerance = ${tolerance0}%)"
if [ "$fail3" ]; then
echo " ==> FAILED."
res=1;
......
......@@ -287,7 +287,7 @@ if ! eval $mfd_cmdline; then
exit 1
fi
pfs_cmdline="${pfs_code} --IFO=H1 --h0=1e-24 --cosi=0 --psi=0 --phi0=0 --Freq=60 --Alpha=$alpha --Delta=$delta --DataFiles=$sftfile_H1 --outputFstat=$outPFS --assumeSqrtSX=1.0 --printFstat=0"
pfs_cmdline="${pfs_code} --h0=1e-24 --cosi=0 --psi=0 --phi0=0 --Freq=60 --Alpha=$alpha --Delta=$delta --DataFiles=$sftfile_H1 --outputFstat=$outPFS --assumeSqrtSX=1.0 --printFstat=0"
echo $pfs_cmdline;
if ! eval $pfs_cmdline; then
echo "Error.. something failed when running '$pfs_code' ..."
......@@ -453,7 +453,7 @@ if ! eval $mfd_cmdline; then
exit 1
fi
pfs_cmdline="${pfs_code} --IFO=H1 --h0=1e-24 --cosi=0 --psi=0 --phi0=0 --Freq=60 --Alpha=$alpha --Delta=$delta --DataFiles=$sftfile_H1 --outputFstat=$outPFS --printFstat=0"
pfs_cmdline="${pfs_code} --h0=1e-24 --cosi=0 --psi=0 --phi0=0 --Freq=60 --Alpha=$alpha --Delta=$delta --DataFiles=$sftfile_H1 --outputFstat=$outPFS --printFstat=0"
echo $pfs_cmdline;
if ! eval $pfs_cmdline; then
echo "Error.. something failed when running '$pfs_code' ..."
......@@ -481,7 +481,7 @@ if ! eval $mfd_cmdline; then
exit 1
fi
pfs_cmdline="${pfs_code} --IFO=L1 --h0=1e-24 --cosi=0 --psi=0 --phi0=0 --Freq=60 --Alpha=$alpha --Delta=$delta --DataFiles=$sftfile_L1 --outputFstat=$outPFS --printFstat=0"
pfs_cmdline="${pfs_code} --h0=1e-24 --cosi=0 --psi=0 --phi0=0 --Freq=60 --Alpha=$alpha --Delta=$delta --DataFiles=$sftfile_L1 --outputFstat=$outPFS --printFstat=0"
echo $pfs_cmdline;
if ! eval $pfs_cmdline; then
echo "Error.. something failed when running '$pfs_code' ..."
......
......@@ -1058,15 +1058,21 @@ XLALLoadMultiSFTsFromView ( const MultiSFTCatalogView *multiCatalogView,/**< The
} // XLALLoadMultiSFTsFromView()
/// backwards compatible wrapper to XLALReadTimestampsFileConstrained() without GPS-time constraints
LIGOTimeGPSVector *
XLALReadTimestampsFile ( const CHAR *fname )
{
return XLALReadTimestampsFileConstrained ( fname, NULL, NULL );
}
/**
* Load timestamps file 'fname' into LIGOTimeGPSVector struct, allocated here.
*
* The timestamps file is of the format: <repeated lines of the form "seconds nano-seconds">
* allowing for '%#' as comments, which are ignored.
*
* The timestamps file must contain one GPS time per line, allowing for '%#' as comments, which are ignored.
* The constraints 'minGPS', 'maxGPS' are applied by returning only timestamps that fall within
* the range defined by XLALCWGPSinRange(gps, minGPS, maxGPS) == 0.
*/
LIGOTimeGPSVector *
XLALReadTimestampsFile ( const CHAR *fname )
XLALReadTimestampsFileConstrained ( const CHAR *fname, const LIGOTimeGPS *minGPS, const LIGOTimeGPS *maxGPS )
{
/** check input consistency */
XLAL_CHECK_NULL ( fname != NULL, XLAL_EINVAL );
......@@ -1076,6 +1082,7 @@ XLALReadTimestampsFile ( const CHAR *fname )
XLAL_CHECK_NULL ( XLALParseDataFile ( &flines, fname ) == XLAL_SUCCESS, XLAL_EFUNC );
UINT4 numTS = flines->lines->nTokens;
UINT4 numTSinRange = 0;
/* allocate and initialized segment list */
LIGOTimeGPSVector *timestamps = NULL;
......@@ -1112,16 +1119,23 @@ XLALReadTimestampsFile ( const CHAR *fname )
}
}
timestamps->data[iTS] = gps;
if ( XLALCWGPSinRange ( gps, minGPS, maxGPS) == 0 )
{
timestamps->data[numTSinRange ++] = gps;
}
} /* for iTS < numTS */
/* free parsed segment file contents */
XLALDestroyParsedDataFile ( flines );
// adjust size of timestamps vector to those found within range
timestamps->length = numTSinRange;
timestamps->data = XLALRealloc ( timestamps->data, numTSinRange * sizeof(timestamps->data[0]) );
return timestamps;
} /* XLALReadTimestampsFile() */
} /* XLALReadTimestampsFileConstrained() */
/**
......@@ -1185,16 +1199,23 @@ XLALCheckCRCSFTCatalog(
} /* XLALCheckCRCSFTCatalog() */
/// backwards compatible wrapper to XLALReadMultiTimestampsFilesConstrained() without GPS-time constraints
MultiLIGOTimeGPSVector *
XLALReadMultiTimestampsFiles ( const LALStringVector *fnames )
{
return XLALReadMultiTimestampsFilesConstrained ( fnames, NULL, NULL );
}
/**
* Load several timestamps files, return a MultiLIGOTimeGPSVector struct, allocated here.
*
* The timestamps files are of the format: <repeated lines of the form "seconds nano-seconds">
* allowing for '%#' as comments, which are ignored.
* The timestamps files must contain one GPS time per line, allowing for '%#' as comments, which are ignored.
* The constraints 'minGPS', 'maxGPS' are applied by returning only timestamps that fall within
* the range defined by XLALCWGPSinRange(gps, minGPS, maxGPS) == 0.
*
*/
MultiLIGOTimeGPSVector *
XLALReadMultiTimestampsFiles ( const LALStringVector *fnames )
XLALReadMultiTimestampsFilesConstrained ( const LALStringVector *fnames, const LIGOTimeGPS *minGPS, const LIGOTimeGPS *maxGPS )
{
XLAL_CHECK_NULL ( fnames != NULL, XLAL_EINVAL );
XLAL_CHECK_NULL ( fnames->data != NULL, XLAL_EINVAL );
......@@ -1211,12 +1232,12 @@ XLALReadMultiTimestampsFiles ( const LALStringVector *fnames )
for ( UINT4 X=0; X < numDet; X ++ )
{
XLAL_CHECK_NULL ( fnames->data[X] != NULL, XLAL_EINVAL );
XLAL_CHECK_NULL ( ( multiTS->data[X] = XLALReadTimestampsFile ( fnames->data[X] )) != NULL, XLAL_EFUNC );
XLAL_CHECK_NULL ( ( multiTS->data[X] = XLALReadTimestampsFileConstrained ( fnames->data[X], minGPS, maxGPS )) != NULL, XLAL_EFUNC );
} // for X < numDet
return multiTS;
} // XLALReadMultiTimestampsFiles()
} // XLALReadMultiTimestampsFilesConstrained()
/**
......
......@@ -297,7 +297,9 @@ int XLALWriteSFT2fp ( const SFTtype *sft, FILE *fp, const CHAR *SFTcomment );
int XLALWriteSFT2file ( const SFTtype *sft, const CHAR *fname, const CHAR *SFTcomment );
LIGOTimeGPSVector *XLALReadTimestampsFile ( const CHAR *fname );
LIGOTimeGPSVector *XLALReadTimestampsFileConstrained ( const CHAR *fname, const LIGOTimeGPS *minGPS, const LIGOTimeGPS *maxGPS );
MultiLIGOTimeGPSVector *XLALReadMultiTimestampsFiles ( const LALStringVector *fnames );
MultiLIGOTimeGPSVector *XLALReadMultiTimestampsFilesConstrained ( const LALStringVector *fnames, const LIGOTimeGPS *minGPS, const LIGOTimeGPS *maxGPS );
SFTVector* XLALLoadSFTs (const SFTCatalog *catalog, REAL8 fMin, REAL8 fMax);
......
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