26#include <gsl/gsl_math.h>
28#include <lal/ComputeFstat.h>
29#include <lal/LALgetopt.h>
30#include <lal/LALBarycenter.h>
31#include <lal/LALInitBarycenter.h>
32#include <lal/AVFactories.h>
33#include <lal/SinCosLUT.h>
57#define LALCOMPUTEAMH_ENULL 7
58#define LALCOMPUTEAMH_EINPUT 8
59#define LALCOMPUTEAMH_ENONULL 9
60#define LALCOMPUTEAMH_EMEM 10
62#define LALCOMPUTEAMH_MSGENULL "Arguments contained an unexpected null pointer"
63#define LALCOMPUTEAMH_MSGEINPUT "Invalid input"
64#define LALCOMPUTEAMH_MSGENONULL "Output pointer is non-NULL"
65#define LALCOMPUTEAMH_MSGEMEM "Out of memory. Bad."
68int main(
int argc,
char *argv[] )
73 const CHAR *sites[2] = {
"H1",
"V1"};
81 char earthEphem[] = TEST_PKG_DATA_DIR
"earth00-40-DE405.dat.gz";
82 char sunEphem[] = TEST_PKG_DATA_DIR
"sun00-40-DE405.dat.gz";
88 while ( ( opt =
LALgetopt( argc, argv,
"n:qv:" ) ) != -1 ) {
114 multiDet.
length = numIFOs;
115 for ( X = 0; X < numIFOs; X ++ ) {
121 multiDet.
sites[X] = ( *site );
134 for ( X = 0; X < numIFOs; X ++ ) {
142 for (
i = 0;
i < numSteps;
i ++ ) {
144 multiTS->data[X]->data[
i].gpsSeconds = ti;
145 multiTS->data[X]->data[
i].gpsNanoSeconds = 0;
160 while ( numChecks-- ) {
174 if (
status.statusCode ) {
208 printf(
"OK. All tests passed successfully\n\n" );
225 if ( !multiAM1 || !multiAM2 || tolerance <= 0 ) {
237 REAL8 maxerr_ab = 0, avgerr_ab = 0;
239 for ( X = 0; X <
numDet; X ++ ) {
251 for (
i = 0;
i < numSteps;
i ++ ) {
255 if ( err_a > maxerr_ab ) {
258 if ( err_b > maxerr_ab ) {
262 avgerr_ab += err_a + err_b;
269 avgerr_ab /= ( 2.0 * numTerms );
275 REAL8 maxxerr_Ad = 0, maxxerr_Bd = 0, maxxerr_Cd = 0, maxxerr_Dd = 0;
278 err = fabs( Mmunu1->
Ad - Mmunu2->
Ad );
279 if (
err > maxxerr_Ad ) {
282 err = fabs( Mmunu1->
Bd - Mmunu2->
Bd );
283 if (
err > maxxerr_Bd ) {
286 err = fabs( Mmunu1->
Cd - Mmunu2->
Cd );
287 if (
err > maxxerr_Cd ) {
290 err = fabs( Mmunu1->
Dd - Mmunu2->
Dd );
291 if (
err > maxxerr_Dd ) {
309 REAL8 tolerance_Mmunu = tolerance * sqrt( 1.0 * numTerms );
310 XLALPrintError(
"%s: tolerances tol(a,b,c)=%g, tol(Mmunu) = %g\n",
__func__, tolerance, tolerance_Mmunu );
312 if ( maxxerr_Ad > tolerance_Mmunu ) {
313 XLALPrintError(
"%s: maximal difference in Ad is %g, which exceeds the tolerance %g\n",
__func__, maxxerr_Ad, tolerance_Mmunu );
319 if ( maxxerr_Bd > tolerance_Mmunu ) {
320 XLALPrintError(
"%s: maximal difference in Bd is %g, which exceeds the tolerance %g\n",
__func__, maxxerr_Bd, tolerance_Mmunu );
326 if ( maxxerr_Cd > tolerance_Mmunu ) {
327 XLALPrintError(
"%s: maximal difference in Cd is %g, which exceeds the tolerance %g\n",
__func__, maxxerr_Cd, tolerance_Mmunu );
340 if ( maxerr_ab > tolerance ) {
341 XLALPrintError(
"%s: maximal difference in {a, b} coefficients is %g, which exceeds the tolerance %g\n",
__func__, maxerr_ab, tolerance );
347 if ( avgerr_ab > tolerance ) {
348 XLALPrintError(
"%s: average difference in {a, b} coefficients is %g, which exceeds the tolerance %g\n",
__func__, avgerr_ab, tolerance );
387 if ( ( ret =
LALCalloc( 1,
sizeof( *ret ) ) ) == NULL ) {
401 amcoeX = ret->
data[X];
409 if (
status->statusPtr->statusCode ) {
410 LALPrintError(
"\nCall to old_LALNewGetAMCoeffs() has failed ... \n\n" );
421 ABORT(
status, -1,
"old_LALGetMultiAMCoeffs() failed" );
424 ( *multiAMcoef ) = ret;
459 REAL4 sin1delta, cos1delta;
460 REAL4 sin1alpha, cos1alpha;
463 REAL4 eta1, eta2, eta3;
472 numSteps = DetectorStates->
length;
500 eta1 = -sin1delta * cos1alpha;
501 eta2 = -sin1delta * sin1alpha;
509 for (
i = 0;
i < numSteps;
i++ ) {
514 ai =
d->d11 * ( xi1 * xi1 - eta1 * eta1 )
515 + 2 *
d->d12 * ( xi1 *
xi2 - eta1 * eta2 )
516 - 2 *
d->d13 * eta1 * eta3
517 +
d->d22 * (
xi2 *
xi2 - eta2 * eta2 )
518 - 2 *
d->d23 * eta2 * eta3
519 -
d->d33 * eta3 * eta3;
521 bi =
d->d11 * 2 * xi1 * eta1
522 + 2 *
d->d12 * ( xi1 * eta2 +
xi2 * eta1 )
523 + 2 *
d->d13 * xi1 * eta3
524 +
d->d22 * 2 *
xi2 * eta2
525 + 2 *
d->d23 *
xi2 * eta3;
539 coeffs->
A += ai * ai;
540 coeffs->
B += bi * bi;
541 coeffs->
C += ai * bi;
546 norm = 2.0f / numSteps;
551 coeffs->
D = coeffs->
A * coeffs->
B - coeffs->
C * coeffs->
C;
#define __func__
log an I/O error, i.e.
void LALCheckMemoryLeaks(void)
static double double delta
#define ABORT(statusptr, code, mesg)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
int LALgetopt(int argc, char *const *argv, const char *optstring)
int main(int argc, char *argv[])
#define LALCOMPUTEAMH_EINPUT
#define LALCOMPUTEAMH_MSGENONULL
#define LALCOMPUTEAMH_EMEM
#define LALCOMPUTEAMH_MSGEMEM
#define LALCOMPUTEAMH_ENULL
#define LALCOMPUTEAMH_ENONULL
#define LALCOMPUTEAMH_MSGENULL
static void old_LALNewGetAMCoeffs(LALStatus *, AMCoeffs *coeffs, const DetectorStateSeries *DetectorStates, SkyPosition skypos)
#define LALCOMPUTEAMH_MSGEINPUT
static void old_LALGetMultiAMCoeffs(LALStatus *, MultiAMCoeffs **multiAMcoef, const MultiDetectorStateSeries *multiDetStates, SkyPosition pos)
static int XLALCompareMultiAMCoeffs(MultiAMCoeffs *multiAM1, MultiAMCoeffs *multiAM2, REAL8 tolerance)
void XLALDestroyMultiDetectorStateSeries(MultiDetectorStateSeries *mdetStates)
Helper function to get rid of a multi-IFO DetectorStateSeries Note, this is "NULL-robust" in the sens...
MultiDetectorStateSeries * XLALGetMultiDetectorStates(const MultiLIGOTimeGPSVector *multiTS, const MultiLALDetector *multiIFO, const EphemerisData *edat, REAL8 tOffset)
Get the detector-time series for the given MultiLIGOTimeGPSVector.
EphemerisData * XLALInitBarycenter(const CHAR *earthEphemerisFile, const CHAR *sunEphemerisFile)
XLAL interface to reading ephemeris files 'earth' and 'sun', and return ephemeris-data in old backwar...
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
void XLALDestroyMultiAMCoeffs(MultiAMCoeffs *multiAMcoef)
Destroy a MultiAMCoeffs structure.
int XLALWeightMultiAMCoeffs(MultiAMCoeffs *multiAMcoef, const MultiNoiseWeights *multiWeights)
Replace AM-coeffs by weighted AM-coeffs, i.e.
MultiAMCoeffs * XLALComputeMultiAMCoeffs(const MultiDetectorStateSeries *multiDetStates, const MultiNoiseWeights *multiWeights, SkyPosition skypos)
Multi-IFO version of XLALComputeAMCoeffs().
#define XLAL_INIT_DECL(var,...)
int LALPrintError(const char *fmt,...)
void * XLALCalloc(size_t m, size_t n)
const LALDetector * XLALGetSiteInfo(const CHAR *name)
Find the site geometry-information 'LALDetector' for given a detector name (or prefix).
LIGOTimeGPSVector * XLALCreateTimestampVector(UINT4 len)
Allocate a LIGOTimeGPSVector.
void XLALDestroyMultiTimestamps(MultiLIGOTimeGPSVector *multiTS)
Destroy a MultiLIGOTimeGPSVector timestamps vector.
int XLALSinCosLUT(REAL4 *sinx, REAL4 *cosx, REAL8 x)
Calculate sin(x) and cos(x) to roughly 1e-7 precision using a lookup-table and Taylor-expansion.
#define SKYCOORDINATESH_ESYS
COORDINATESYSTEM_EQUATORIAL
REAL4Vector * XLALCreateREAL4Vector(UINT4 length)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
This structure contains the per-SFT (weighted) antenna-pattern functions , with the SFT-index,...
REAL4 B
summed antenna-pattern matrix coefficient:
REAL4Vector * b
(weighted) per-SFT antenna-pattern function
REAL4 A
summed antenna-pattern matrix coefficient:
REAL4 C
summed antenna-pattern matrix coefficient:
REAL4Vector * a
(weighted) per-SFT antenna-pattern function
Struct holding the "antenna-pattern" matrix , in terms of the multi-detector scalar product.
REAL8 Sinv_Tsft
normalization-factor (using single-sided PSD!)
REAL4 Dd
determinant factor , such that
SymmTensor3 detT
Detector-tensor components in SSB-fixed, Cartesian coordinates.
Timeseries of DetectorState's, representing the detector-info at different timestamps.
DetectorState * data
array of DetectorState entries
UINT4 length
total number of entries
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
Multi-IFO container for antenna-pattern coefficients and atenna-pattern matrix .
UINT4 length
number of IFOs
AMCoeffs ** data
noise-weighted AM-coeffs , and
AntennaPatternMatrix Mmunu
antenna-pattern matrix
Multi-IFO time-series of DetectorStates.
UINT4 length
number of detectors
DetectorStateSeries ** data
vector of pointers to DetectorStateSeries
array of detectors definitions 'LALDetector'
UINT4 length
number of detectors
LALDetector sites[PULSAR_MAX_DETECTORS]
array of site information
A collection of (multi-IFO) LIGOTimeGPSVector time-stamps vectors.
One noise-weight (number) per SFT (therefore indexed over IFOs and SFTs.
A symmetric 3x3 tensor (such as detector-tensors), storing only the upper triangle.