LALPulsar  6.1.0.1-fe68b98
DetectorStates.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006, 2008 John T. Whelan
3  * Copyright (C) 2005, 2006 Reinhard Prix
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with with program; see the file COPYING. If not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18  * MA 02110-1301 USA
19  */
20 
21 /*---------- INCLUDES ----------*/
22 #define __USE_ISOC99 1
23 #include <math.h>
24 
25 #include <lal/SinCosLUT.h>
26 #include <lal/DetectorStates.h>
27 #include <lal/LISAspecifics.h>
28 #include <lal/UserInputParse.h>
29 
30 /*---------- local DEFINES ----------*/
31 #define TRUE (1==1)
32 #define FALSE (1==0)
33 
34 /*----- Macros ----- */
35 #define SQUARE(x) ((x) * (x))
36 
37 /*----- SWITCHES -----*/
38 
39 /*---------- internal types ----------*/
40 
41 /*---------- empty initializers ---------- */
42 
43 /*---------- Global variables ----------*/
44 
45 /*---------- internal prototypes ----------*/
46 int XLALFillDetectorTensor( DetectorState *detState, const LALDetector *detector ); /* no need to export this ... */
47 
48 /*==================== FUNCTION DEFINITIONS ====================*/
49 
50 /// \addtogroup DetectorStates_h
51 /// @{
52 
53 /**
54  * Function to compute the LWL detector-tensor for the given \a detector in
55  * SSB-fixed cartesian coordinates at time tgps.
56  * The coordinates used are: EQUATORIAL for Earth-based detectors, but ECLIPTIC for LISA.
57  * RETURN: 0 = OK, -1 = ERROR
58  */
59 int
60 XLALFillDetectorTensor( DetectorState *detState, /**< [out,in]: detector state: fill in detector-tensor */
61  const LALDetector *detector /**< [in]: which detector */
62  )
63 {
64 
65  if ( !detState || !detector ) {
67  return -1;
68  }
69 
70  const CHAR *prefix = detector->frDetector.prefix;
71 
72  /* we need to distinguish two cases: space-borne (i.e. LISA) and Earth-based detectors */
73  if ( XLALisLISAdetector( detector ) ) { /* LISA */
74  if ( XLALprecomputeLISAarms( detState ) != 0 ) {
75  XLALPrintError( "\nXLALprecomputeLISAarms() failed !\n\n" );
77  return -1;
78  }
79 
80  if ( XLALgetLISADetectorTensorLWL( &( detState->detT ), detState->detArms, prefix[1] ) != 0 ) {
81  XLALPrintError( "\nXLALgetLISADetectorTensorLWL() failed !\n\n" );
83  return -1;
84  }
85 
86  } /* if LISA */
87  else {
88  REAL4 sinG, cosG, sinGcosG, sinGsinG, cosGcosG;
89  SymmTensor3 *detT = &( detState->detT );
90 
91  XLAL_CHECK( XLALSinCosLUT( &sinG, &cosG, detState->earthState.gmstRad ) == XLAL_SUCCESS, XLAL_EFUNC );
92  sinGsinG = sinG * sinG;
93  sinGcosG = sinG * cosG;
94  cosGcosG = cosG * cosG;
95 
96  /*
97  printf("GMST = %fdeg; cosG = %f, sinG= %f\n",
98  LAL_180_PI * atan2(sinG,cosG), cosG, sinG);
99  */
100 
101  detT->d11 = detector->response[0][0] * cosGcosG
102  - 2 * detector->response[0][1] * sinGcosG
103  + detector->response[1][1] * sinGsinG;
104  detT->d22 = detector->response[0][0] * sinGsinG
105  + 2 * detector->response[0][1] * sinGcosG
106  + detector->response[1][1] * cosGcosG;
107  detT->d12 = ( detector->response[0][0] - detector->response[1][1] )
108  * sinGcosG
109  + detector->response[0][1] * ( cosGcosG - sinGsinG );
110  detT->d13 = detector->response[0][2] * cosG
111  - detector->response[1][2] * sinG;
112  detT->d23 = detector->response[0][2] * sinG
113  + detector->response[1][2] * cosG;
114  detT->d33 = detector->response[2][2];
115 
116  /*
117  printf("d = (%f %f %f\n",detT->d11,detT->d12,detT->d13);
118  printf(" %f %f %f\n",detT->d12,detT->d22,detT->d23);
119  printf(" %f %f %f)\n",detT->d13,detT->d23,detT->d33);
120 
121  printf("d*= (%f %f %f\n",detector->response[0][0],
122  detector->response[0][1],detector->response[0][2]);
123  printf(" %f %f %f\n",detector->response[1][0],
124  detector->response[1][1],detector->response[1][2]);
125  printf(" %f %f %f)\n",detector->response[2][0],
126  detector->response[2][1],detector->response[2][2]);
127  */
128 
129  } /* if Earth-based */
130 
131  return 0;
132 
133 } /* XLALFillDetectorTensor() */
134 
135 /**
136  * Compute the "squared-tensor" v x v for given vector v,
137  * the result is returned in a "detectorTensor" struct
138  */
139 int
141 {
142  if ( !vxv ) {
143  return -1;
144  }
145 
146  vxv->d11 = v[0] * v[0];
147  vxv->d12 = v[0] * v[1];
148  vxv->d13 = v[0] * v[2];
149 
150  vxv->d22 = v[1] * v[1];
151  vxv->d23 = v[1] * v[2];
152 
153  vxv->d33 = v[2] * v[2];
154 
155  return 0;
156 
157 } /* XLALTensorSquareVector3() */
158 
159 /**
160  * Compute the symmetrized tensor product T = v x w + w x v
161  */
162 int
164 {
165  if ( !vxw ) {
166  return -1;
167  }
168 
169  vxw->d11 = 2.0f * v[0] * w[0];
170  vxw->d12 = v[0] * w[1] + w[0] * v[1];
171  vxw->d13 = v[0] * w[2] + w[0] * v[2];
172 
173  vxw->d22 = 2.0f * v[1] * w[1];
174  vxw->d23 = v[1] * w[2] + w[1] * v[2];
175 
176  vxw->d33 = 2.0f * v[2] * w[2];
177 
178  return 0;
179 
180 } /* XLALSymmTensorProduct() */
181 
182 /**
183  * Convenience function for adding two SymmTensor3s: aT + bT
184  * NOTE: it *is* safe to have sum point to the same tensor-struct as either aT or bT.
185  */
186 int
188 {
189  if ( !sum || !aT || !bT ) {
190  return -1;
191  }
192 
193  sum->d11 = aT->d11 + bT->d11;
194  sum->d12 = aT->d12 + bT->d12;
195  sum->d13 = aT->d13 + bT->d13;
196 
197  sum->d22 = aT->d22 + bT->d22;
198  sum->d23 = aT->d23 + bT->d23;
199 
200  sum->d33 = aT->d33 + bT->d33;
201 
202  return 0;
203 
204 } /* XLALAddSymmTensor3s() */
205 
206 /**
207  * Convenience function for subtracting two SymmTensor3s: aT - bT
208  * NOTE: it *is* safe to have diff point to the same tensor-struct as either aT or bT.
209  */
210 int
212 {
213  if ( !diff || !aT || !bT ) {
214  return -1;
215  }
216 
217  diff->d11 = aT->d11 - bT->d11;
218  diff->d12 = aT->d12 - bT->d12;
219  diff->d13 = aT->d13 - bT->d13;
220 
221  diff->d22 = aT->d22 - bT->d22;
222  diff->d23 = aT->d23 - bT->d23;
223 
224  diff->d33 = aT->d33 - bT->d33;
225 
226  return 0;
227 
228 } /* XLALSubtractSymmTensor3s() */
229 
230 /**
231  * Convenience function for multiplying a SymmTensor3 by a scalar factor.
232  * NOTE: it *is* safe to have aT and mult point to the same tensor-struct
233  */
234 int
236 {
237  if ( !mult || !aT ) {
238  return -1;
239  }
240 
241  mult->d11 = factor * aT->d11;
242  mult->d12 = factor * aT->d12;
243  mult->d13 = factor * aT->d13;
244 
245  mult->d22 = factor * aT->d22;
246  mult->d23 = factor * aT->d23;
247 
248  mult->d33 = factor * aT->d33;
249 
250  return 0;
251 
252 } /* XLALScaleSymmTensor3() */
253 
254 /**
255  * Contract two symmetric tensors over both indices T1 : T2
256  */
257 REAL4
259 {
260  REAL4 ret;
261 
262  if ( !T1 || !T2 ) {
264  }
265 
266  ret = T1->d11 * T2->d11
267  + T1->d22 * T2->d22
268  + T1->d33 * T2->d33
269  + 2.0f * ( T1->d12 * T2->d12
270  + T1->d13 * T2->d13
271  + T1->d23 * T2->d23 );
272 
273  return ret;
274 
275 } /* XLALContractSymmTensor3s() */
276 
277 /** Get rid of a DetectorStateSeries */
278 void
280 {
281  if ( !detStates ) {
282  return;
283  }
284 
285  if ( detStates->data ) {
286  LALFree( detStates->data );
287  }
288  LALFree( detStates );
289 
290  return;
291 
292 } /* XLALDestroyDetectorStateSeries() */
293 
294 /**
295  * Helper function to get rid of a multi-IFO DetectorStateSeries
296  * Note, this is "NULL-robust" in the sense that it will not crash
297  * on NULL-entries anywhere in this struct, so it can be used
298  * for failure-cleanup even on incomplete structs.
299  */
300 void
302 {
303  UINT4 X, numDet;
304 
305  if ( !mdetStates ) {
306  return;
307  }
308 
309  numDet = mdetStates->length;
310  if ( mdetStates->data ) {
311  for ( X = 0; X < numDet ; X ++ ) {
312  XLALDestroyDetectorStateSeries( mdetStates->data[X] );
313  }
314 
315  LALFree( mdetStates->data );
316  }
317 
318  LALFree( mdetStates );
319 
320  return;
321 
322 } /* XLALDestroyMultiDetectorStateSeries() */
323 
324 /** Create a DetectorStateSeries with length entries */
326 XLALCreateDetectorStateSeries( UINT4 length ) /**< number of entries */
327 {
328  DetectorStateSeries *ret = NULL;
329 
330  if ( ( ret = LALCalloc( 1, sizeof( DetectorStateSeries ) ) ) == NULL ) {
331  XLALPrintError( "%s: failed to LALCalloc(1, %zu)\n", __func__, sizeof( DetectorStateSeries ) );
333  }
334 
335  if ( ( ret->data = LALCalloc( length, sizeof( DetectorState ) ) ) == NULL ) {
336  XLALFree( ret );
337  XLALPrintError( "%s: failed to LALCalloc(%d, %zu)\n", __func__, length, sizeof( DetectorState ) );
339  }
340 
341  ret->length = length;
342 
343  return ret;
344 
345 } /* XLALCreateDetectorStateSeries() */
346 
347 
348 /**
349  * Get the 'detector state' (ie detector-tensor, position, velocity, etc) for the given
350  * vector of timestamps, shifted by a common time-shift \a tOffset.
351  *
352  * This function just calls XLALBarycenterEarth() and XLALBarycenter() for the
353  * given vector of timestamps (shifted by tOffset) and returns the positions,
354  * velocities and LMSTs of the detector, stored in a DetectorStateSeries.
355  * There is also an entry containing the EarthState at each timestamp, which
356  * can be used as input for subsequent calls to XLALBarycenter().
357  *
358  * \a tOffset allows one to easily use the midpoints of SFT-timestamps, for example.
359  *
360  */
362 XLALGetDetectorStates( const LIGOTimeGPSVector *timestamps, /**< array of GPS timestamps t_i */
363  const LALDetector *detector, /**< detector info */
364  const EphemerisData *edat, /**< ephemeris file data */
365  REAL8 tOffset /**< compute detector states at timestamps SHIFTED by tOffset */
366  )
367 {
368  /* check input consistency */
369  if ( !timestamps || !detector || !edat ) {
370  XLALPrintError( "%s: invalid NULL input, timestamps=%p, detector=%p, edat=%p\n", __func__, timestamps, detector, edat );
372  }
373 
374  /* prepare return vector */
375  UINT4 numSteps = timestamps->length;
376  DetectorStateSeries *ret = NULL;
377  if ( ( ret = XLALCreateDetectorStateSeries( numSteps ) ) == NULL ) {
378  XLALPrintError( "%s: XLALCreateDetectorStateSeries(%d) failed.\n", __func__, numSteps );
380  }
381 
382  /* enter detector-info into the head of the state-vector */
383  ret->detector = ( *detector );
384 
385  /* set 'time-span' associated with each timestamp */
386  ret->deltaT = timestamps->deltaT;
387 
388  /* set SSB coordinate system used: EQUATORIAL for Earth-based, ECLIPTIC for LISA */
389  if ( XLALisLISAdetector( detector ) ) { /* LISA */
391  } else { /* Earth-based */
393  }
394 
395  /* now fill all the vector-entries corresponding to different timestamps */
396  UINT4 i;
397  for ( i = 0; i < numSteps; i++ ) {
398  BarycenterInput baryinput;
399  EmissionTime emit;
400  DetectorState *state = &( ret->data[i] );
401  EarthState *earth = &( state->earthState );
402  LIGOTimeGPS tgps;
403 
404  /* shift timestamp by tOffset */
405  tgps = timestamps->data[i];
406  XLALGPSAdd( &tgps, tOffset );
407 
408  /*----- first get earth-state */
409  if ( XLALBarycenterEarth( earth, &tgps, edat ) != XLAL_SUCCESS ) {
411  XLALPrintError( "%s: XLALBarycenterEarth() failed with xlalErrno=%d\n", __func__, xlalErrno );
413  }
414 
415  /*----- then get detector-specific info */
416  baryinput.tgps = tgps;
417  baryinput.site = ( *detector );
418  baryinput.site.location[0] /= LAL_C_SI;
419  baryinput.site.location[1] /= LAL_C_SI;
420  baryinput.site.location[2] /= LAL_C_SI;
421  baryinput.alpha = baryinput.delta = 0; /* irrelevant */
422  baryinput.dInv = 0;
423 
424  if ( XLALBarycenter( &emit, &baryinput, earth ) != XLAL_SUCCESS ) {
426  XLALPrintError( "%s: XLALBarycenterEarth() failed with xlalErrno=%d\n", __func__, xlalErrno );
428  }
429 
430  /*----- extract the output-data from this */
431  UINT4 j;
432  for ( j = 0; j < 3; j++ ) { /* copy detector's position and velocity */
433  state->rDetector[j] = emit.rDetector[j];
434  state->vDetector[j] = emit.vDetector[j];
435  } /* for j < 3 */
436 
437  /* local mean sidereal time = GMST + longitude */
438  state->LMST = earth->gmstRad + detector->frDetector.vertexLongitudeRadians;
439  state->LMST = fmod( state->LMST, LAL_TWOPI ); /* normalize */
440 
441  /* insert timestamp */
442  state->tGPS = tgps;
443 
444  /* compute the detector-tensor at this time-stamp in SSB-fixed Cartesian coordinates
445  * [EQUATORIAL for Earth-based, ECLIPTIC for LISA]
446  */
447  if ( XLALFillDetectorTensor( state, detector ) != 0 ) {
449  XLALPrintError( "%s: XLALFillDetectorTensor() failed ... errno = %d\n\n", __func__, xlalErrno );
451  }
452 
453  } /* for i < numSteps */
454 
455  /* return result */
456  return ret;
457 
458 } /* XLALGetDetectorStates() */
459 
460 
461 /**
462  * Get the detector-time series for the given MultiLIGOTimeGPSVector.
463  * NOTE: contrary to the deprecated XLALGetMultiDetectorStatesFromMultiSFTs() interface, this
464  * function computes detector-states at the given timestamps shifted by tOffset
465  *
466  */
468 XLALGetMultiDetectorStates( const MultiLIGOTimeGPSVector *multiTS, /**< [in] multi-IFO timestamps */
469  const MultiLALDetector *multiIFO, /**< [in] multi-IFO array holding detector info */
470  const EphemerisData *edat, /**< [in] ephemeris data */
471  REAL8 tOffset /**< [in] shift all timestamps by this amount */
472  )
473 {
474  /* check input consistency */
475  if ( !multiIFO || !multiTS || !edat ) {
476  XLALPrintError( "%s: invalid NULL input (multiIFO=%p, multiTS=%p or edat=%p)\n", __func__, multiIFO, multiTS, edat );
478  }
479 
481  numDetectors = multiIFO->length;
482  if ( numDetectors != multiTS->length ) {
483  XLALPrintError( "%s: inconsistent number of IFOs in 'multiIFO' (%d) and 'multiTS' (%d)\n", __func__, multiIFO->length, multiTS->length );
485  }
486 
487  /* prepare return-structure */
488  MultiDetectorStateSeries *ret = NULL;
489  if ( ( ret = LALCalloc( 1, sizeof( *ret ) ) ) == NULL ) {
490  XLALPrintError( "%s: LALCalloc ( 1, %zu ) failed\n", __func__, sizeof( *ret ) );
492  }
493  if ( ( ret->data = LALCalloc( numDetectors, sizeof( *( ret->data ) ) ) ) == NULL ) {
494  XLALFree( ret );
495  XLALPrintError( "%s: LALCalloc ( %d, %zu ) failed\n", __func__, numDetectors, sizeof( *( ret->data ) ) );
497  }
498  ret->length = numDetectors;
499 
500  REAL8 deltaT = multiTS->data[0]->deltaT;
501 
502  /* loop over detectors */
503  UINT4 X;
504  for ( X = 0; X < numDetectors; X ++ ) {
505  LIGOTimeGPSVector *tsX = multiTS->data[X];
506  const LALDetector *detX = &( multiIFO->sites[X] );
507 
508  if ( !tsX || !detX ) {
509  XLALPrintError( "%s: invalid NULL data-vector tsX[%d] = %p, detX[%d] = %p\n", __func__, X, tsX, X, detX );
511  }
512  if ( multiTS->data[X]->deltaT != deltaT ) {
513  XLALPrintError( "%s: inconsistent time-base multi-timeseries deltaT[%d]=%f != deltaT[0] = %f\n", __func__, X, multiTS->data[X]->deltaT, deltaT );
515  }
516 
517  /* fill in the detector-state series for this detector */
518  if ( ( ret->data[X] = XLALGetDetectorStates( tsX, detX, edat, tOffset ) ) == NULL ) {
519  XLALPrintError( "%s: XLALGetDetectorStates() failed.\n", __func__ );
521  }
522 
523  } /* for X < numDetectors */
524 
525  return ret;
526 
527 } /* XLALGetMultiDetectorStates() */
528 
529 /**
530  * Get the 'detector state' (ie detector-tensor, position, velocity, etc) for the given
531  * multi-vector of SFTs, shifted by a common time-shift \a tOffset.
532  *
533  * \a tOffset allows one to easily use the midpoints of SFT-timestamps, for example.
534  *
535  */
538  const MultiSFTVector *multiSFTs, /**< [in] multi-IFO SFTs */
539  const EphemerisData *edat, /**< [in] ephemeris data */
540  REAL8 tOffset /**< [in] shift all timestamps by this amount */
541 )
542 {
543 
544  // Check input
546  XLAL_CHECK_NULL( edat != NULL, XLAL_EFAULT );
547 
548  // XLALGetMultiDetectorStates() wants detector-array and timestamps-vectors directly,
549  // instead of a multi-SFT vector. We therefore need to extract this info from the
550  // multi-SFT vector first
551  MultiLALDetector multiIFO;
555 
556  // call XLALGetMultiDetectorStates()
557  MultiDetectorStateSeries *ret = NULL;
558  XLAL_CHECK_NULL( ( ret = XLALGetMultiDetectorStates( multiTS, &multiIFO, edat, tOffset ) ) != NULL, XLAL_EFUNC );
559 
560  // free temporary mem
562 
563  return ret;
564 
565 } /* XLALGetMultiDetectorStatesFromMultiSFTs() */
566 
567 /**
568  * Parse string-vectors (typically input by user) of N detector noise-floors \f$ \sqrt{S_X} \f$
569  * for detectors \f$ X=1\ldots N \f$ , where here we assume equal number of SFTs per detector
570  * such that \f$ S^{-1} = \frac{1}{N}\sum_{X=0}^{N-1} S_X^{-1} \f$ .
571  *
572  * \note input of length(sqrtSX)=1 < numDetectors is valid: use that single number for all detectors,
573  * otherwise we enforce length(sqrtSX) == numDetectors.
574  *
575  * returns result in MultiNoiseFloor struct 'multiNoiseFloor'.
576  */
577 int
578 XLALParseMultiNoiseFloor( MultiNoiseFloor *multiNoiseFloor, /**< [out] parsed multi-IFO noise floor info */
579  const LALStringVector *sqrtSX, /**< [in] string-list of \f$ \sqrt{S_X} \f$ for detectors \f$ X \f$ */
580  UINT4 numDetectors /**< [in] number of detectors. NOTE: length[sqrtSX] must be EITHER =numDetectors OR =1 */
581  )
582 {
583  XLAL_CHECK( multiNoiseFloor != NULL, XLAL_EINVAL );
584  XLAL_CHECK( sqrtSX != NULL, XLAL_EINVAL );
586  UINT4 numSqrtSX = sqrtSX->length;
587  XLAL_CHECK( ( numSqrtSX == numDetectors ) || ( numSqrtSX == 1 ), XLAL_EINVAL );
588 
589  /* initialize empty return struct */
590  multiNoiseFloor->length = numDetectors;
591 
592  /* parse input strings and fill multiNoiseFloor */
593  for ( UINT4 X = 0; X < numDetectors; X ++ ) {
594  UINT4 X0 = X % numSqrtSX; // always = 0 if (numSqrtSX == 1), otherwise = X if (numSqrtSX==numDetectors)
595  const char *sqrtSnStr = sqrtSX->data[X0];
596  REAL8 sqrtSn;
597  XLAL_CHECK( XLALParseStringValueAsREAL8( &sqrtSn, sqrtSnStr ) == XLAL_SUCCESS, XLAL_EFUNC );
598  XLAL_CHECK( sqrtSn >= 0, XLAL_EDOM );
599  multiNoiseFloor->sqrtSn[X] = sqrtSn;
600  } /* for X < numDetectors */
601 
602  return XLAL_SUCCESS;
603 
604 } /* XLALParseMultiNoiseFloor() */
605 
606 
607 /**
608  * Parse string-vectors (typically input by user) of N detector noise-floors \f$ \sqrt{S_X} \f$
609  * for detectors \f$ X=1\ldots N \f$ , where here we assume equal number of SFTs per detector
610  * such that \f$ S^{-1} = \frac{1}{N}\sum_{X=0}^{N-1} S_X^{-1} \f$ .
611  *
612  * The detectors corresponding to each noise-floor may be a subset of the input string-vectors,
613  * e.g. if parsing noise-floors for a segment where SFTs from some detectors are missing.
614  * The vector \p
615  */
616 int
617 XLALParseMultiNoiseFloorMapped( MultiNoiseFloor *multiNoiseFloor, /**< [out] parsed multi-IFO noise floor info */
618  const LALStringVector *multiNoiseFloorDetNames, /**< [in] detector names for entries in \p multiNoiseFloor */
619  const LALStringVector *sqrtSX, /**< [in] string-list of \f$ \sqrt{S_X} \f$ for detectors \f$ X \f$ */
620  const LALStringVector *sqrtSXDetNames /**< [in] detector names for entries in \p sqrtSX */
621  )
622 {
623  XLAL_CHECK( multiNoiseFloor != NULL, XLAL_EINVAL );
624  XLAL_CHECK( multiNoiseFloorDetNames != NULL, XLAL_EINVAL );
625  XLAL_CHECK( sqrtSX != NULL, XLAL_EINVAL );
626  XLAL_CHECK( sqrtSXDetNames != NULL, XLAL_EINVAL );
627  XLAL_CHECK( multiNoiseFloorDetNames->length <= sqrtSXDetNames->length, XLAL_EINVAL );
628  XLAL_CHECK( sqrtSX->length == sqrtSXDetNames->length, XLAL_EINVAL );
629 
630  /* parse input strings */
631  REAL8 sqrtSn[PULSAR_MAX_DETECTORS];
632  for ( UINT4 Y = 0; Y < sqrtSX->length; Y ++ ) {
634  XLAL_CHECK( sqrtSn[Y] >= 0, XLAL_EDOM );
635  }
636 
637  /* initialize empty return struct */
638  multiNoiseFloor->length = multiNoiseFloorDetNames->length;
639 
640  /* fill multiNoiseFloor with correctly mapped values */
641  for ( UINT4 X = 0; X < multiNoiseFloor->length; X ++ ) {
642  const INT4 Y = XLALFindStringInVector( multiNoiseFloorDetNames->data[X], sqrtSXDetNames );
643  if ( Y < 0 ) {
644  char *sqrtSXDet = XLALConcatStringVector( sqrtSXDetNames, "," );
645  XLAL_PRINT_ERROR( "Noise-floor detector '%s' not found in list of sqrtSX detectors '%s'", multiNoiseFloorDetNames->data[X], sqrtSXDet );
646  XLALFree( sqrtSXDet );
648  }
649  multiNoiseFloor->sqrtSn[X] = sqrtSn[Y];
650  }
651 
652  return XLAL_SUCCESS;
653 
654 } /* XLALParseMultiNoiseFloorMapped() */
655 
656 
657 /**
658  * Parse string-vectors (typically input by user) of N detector-names
659  * for detectors \f$ X=1\ldots N \f$ , returns a MultiLALDetector struct
660  *
661  */
662 int
663 XLALParseMultiLALDetector( MultiLALDetector *detInfo, /**< [out] parsed detector-info struct */
664  const LALStringVector *detNames /**< [in] list of detector names */
665  )
666 {
667  XLAL_CHECK( detInfo != NULL, XLAL_EINVAL );
668  XLAL_CHECK( detNames != NULL, XLAL_EINVAL );
669  UINT4 numDet = detNames->length;
671 
672  detInfo->length = numDet;
673 
674  /* parse input strings and fill detInfo */
675  for ( UINT4 X = 0; X < numDet; X ++ ) {
676  const LALDetector *ifo;
677  /* first parse detector name */
678  XLAL_CHECK( ( ifo = XLALGetSiteInfo( detNames->data[X] ) ) != NULL, XLAL_EINVAL, "Failed to parse detector-name '%s'\n", detNames->data[X] );
679  detInfo->sites[X] = ( *ifo ); // struct copy
680 
681  } /* for X < numDet */
682 
683  return XLAL_SUCCESS;
684 
685 } /* XLALParseMultiLALDetector() */
686 
687 
688 /**
689  * Extract multi detector-info from a given multi SFTCatalog view
690 */
691 int
692 XLALMultiLALDetectorFromMultiSFTCatalogView( MultiLALDetector *multiIFO, //!< [out] list of detectors found in catalog
693  const MultiSFTCatalogView *multiView //!< [in] multi-IFO view of SFT catalog
694  )
695 {
696  // check input consistency
697  XLAL_CHECK( multiIFO != NULL, XLAL_EINVAL );
698  XLAL_CHECK( multiView != NULL, XLAL_EINVAL );
699  UINT4 numIFOs = multiView->length;
700  XLAL_CHECK( ( numIFOs > 0 ) && ( numIFOs <= PULSAR_MAX_DETECTORS ), XLAL_EINVAL );
701 
702 
703 
704  multiIFO->length = numIFOs;
705  for ( UINT4 X = 0; X < numIFOs; X ++ ) {
706  const LALDetector *site;
707  XLAL_CHECK( ( site = XLALGetSiteInfo( multiView->data[X].data->header.name ) ) != NULL, XLAL_EFUNC );
708  multiIFO->sites[X] = ( *site ); // struct-copy
709  } /* for X < numIFOs */
710 
711  return XLAL_SUCCESS;
712 
713 } /* XLALMultiLALDetectorFromMultiSFTCatalogView() */
714 
715 
716 /**
717  * Extract multi detector-info from a given multi SFTCatalog view
718  */
719 int
720 XLALMultiLALDetectorFromMultiSFTs( MultiLALDetector *multiIFO, //!< [out] list of detectors found in catalog
721  const MultiSFTVector *multiSFTs //!< [in] multi-IFO SFT vector
722  )
723 {
724  // check input consistency
725  XLAL_CHECK( multiIFO != NULL, XLAL_EINVAL );
726  XLAL_CHECK( multiSFTs != NULL, XLAL_EINVAL );
727  XLAL_CHECK( multiSFTs->length > 0, XLAL_EINVAL );
728 
729  UINT4 numIFOs = multiSFTs->length;
730 
731  multiIFO->length = numIFOs;
732  for ( UINT4 X = 0; X < numIFOs; X ++ ) {
733  const LALDetector *site;
734  XLAL_CHECK( ( site = XLALGetSiteInfo( multiSFTs->data[X]->data[0].name ) ) != NULL, XLAL_EFUNC );
735  multiIFO->sites[X] = ( *site ); // struct-copy
736  } /* for X < numIFOs */
737 
738  return XLAL_SUCCESS;
739 
740 } /* XLALMultiLALDetectorFromMultiSFTVector() */
741 
742 /// @}
#define __func__
log an I/O error, i.e.
int j
#define LALCalloc(m, n)
#define LALFree(p)
int XLALprecomputeLISAarms(DetectorState *detState)
Precompute the arm-geometry for LISA, which is later used for assembling the RAA detector-tensor (whi...
BOOLEAN XLALisLISAdetector(const LALDetector *det)
Return true if 'det' is a LISA LALDetector struct.
Definition: LISAspecifics.c:65
int XLALgetLISADetectorTensorLWL(SymmTensor3 *detT, const Detector3Arms detArms, CHAR channelNum)
LIGOTimeGPSVector * timestamps
const double w
const double deltaT
int XLALParseMultiNoiseFloorMapped(MultiNoiseFloor *multiNoiseFloor, const LALStringVector *multiNoiseFloorDetNames, const LALStringVector *sqrtSX, const LALStringVector *sqrtSXDetNames)
Parse string-vectors (typically input by user) of N detector noise-floors for detectors ,...
int XLALTensorSquareVector3(SymmTensor3 *vxv, REAL4 v[3])
Compute the "squared-tensor" v x v for given vector v, the result is returned in a "detectorTensor" s...
int XLALAddSymmTensor3s(SymmTensor3 *sum, const SymmTensor3 *aT, const SymmTensor3 *bT)
Convenience function for adding two SymmTensor3s: aT + bT NOTE: it is safe to have sum point to the s...
DetectorStateSeries * XLALCreateDetectorStateSeries(UINT4 length)
Create a DetectorStateSeries with length entries.
int XLALParseMultiLALDetector(MultiLALDetector *detInfo, const LALStringVector *detNames)
Parse string-vectors (typically input by user) of N detector-names for detectors ,...
void XLALDestroyMultiDetectorStateSeries(MultiDetectorStateSeries *mdetStates)
Helper function to get rid of a multi-IFO DetectorStateSeries Note, this is "NULL-robust" in the sens...
int XLALMultiLALDetectorFromMultiSFTs(MultiLALDetector *multiIFO, const MultiSFTVector *multiSFTs)
Extract multi detector-info from a given multi SFTCatalog view.
int XLALFillDetectorTensor(DetectorState *detState, const LALDetector *detector)
Function to compute the LWL detector-tensor for the given detector in SSB-fixed cartesian coordinates...
MultiDetectorStateSeries * XLALGetMultiDetectorStates(const MultiLIGOTimeGPSVector *multiTS, const MultiLALDetector *multiIFO, const EphemerisData *edat, REAL8 tOffset)
Get the detector-time series for the given MultiLIGOTimeGPSVector.
void XLALDestroyDetectorStateSeries(DetectorStateSeries *detStates)
Get rid of a DetectorStateSeries.
int XLALSymmetricTensorProduct3(SymmTensor3 *vxw, REAL4 v[3], REAL4 w[3])
Compute the symmetrized tensor product T = v x w + w x v.
REAL4 XLALContractSymmTensor3s(const SymmTensor3 *T1, const SymmTensor3 *T2)
Contract two symmetric tensors over both indices T1 : T2.
MultiDetectorStateSeries * XLALGetMultiDetectorStatesFromMultiSFTs(const MultiSFTVector *multiSFTs, const EphemerisData *edat, REAL8 tOffset)
Get the 'detector state' (ie detector-tensor, position, velocity, etc) for the given multi-vector of ...
int XLALSubtractSymmTensor3s(SymmTensor3 *diff, const SymmTensor3 *aT, const SymmTensor3 *bT)
Convenience function for subtracting two SymmTensor3s: aT - bT NOTE: it is safe to have diff point to...
DetectorStateSeries * XLALGetDetectorStates(const LIGOTimeGPSVector *timestamps, const LALDetector *detector, const EphemerisData *edat, REAL8 tOffset)
Get the 'detector state' (ie detector-tensor, position, velocity, etc) for the given vector of timest...
int XLALMultiLALDetectorFromMultiSFTCatalogView(MultiLALDetector *multiIFO, const MultiSFTCatalogView *multiView)
Extract multi detector-info from a given multi SFTCatalog view.
int XLALScaleSymmTensor3(SymmTensor3 *mult, const SymmTensor3 *aT, REAL4 factor)
Convenience function for multiplying a SymmTensor3 by a scalar factor.
int XLALParseMultiNoiseFloor(MultiNoiseFloor *multiNoiseFloor, const LALStringVector *sqrtSX, UINT4 numDetectors)
Parse string-vectors (typically input by user) of N detector noise-floors for detectors ,...
int XLALBarycenterEarth(EarthState *earth, const LIGOTimeGPS *tGPS, const EphemerisData *edat)
Computes the position and orientation of the Earth, at some arrival time , specified LIGOTimeGPS inp...
Definition: LALBarycenter.c:78
int XLALBarycenter(EmissionTime *emit, const BarycenterInput *baryinput, const EarthState *earth)
Transforms from detector arrival time in GPS (as specified in the LIGOTimeGPS structure) to pulse em...
#define LAL_TWOPI
double REAL8
char CHAR
uint32_t UINT4
int32_t INT4
float REAL4
void XLALFree(void *p)
#define PULSAR_MAX_DETECTORS
maximal number of detectors we can handle (for static arrays of detector quantities)
const LALDetector * XLALGetSiteInfo(const CHAR *name)
Find the site geometry-information 'LALDetector' for given a detector name (or prefix).
Definition: SFTnaming.c:218
MultiLIGOTimeGPSVector * XLALExtractMultiTimestampsFromSFTs(const MultiSFTVector *multiSFTs)
Given a multi-SFT vector, return a MultiLIGOTimeGPSVector holding the SFT timestamps.
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.
Definition: SinCosLUT.c:83
COORDINATESYSTEM_ECLIPTIC
COORDINATESYSTEM_EQUATORIAL
INT4 XLALFindStringInVector(const char *needle, const LALStringVector *haystack)
char * XLALConcatStringVector(const LALStringVector *strings, const char *sep)
int XLALParseStringValueAsREAL8(REAL8 *valREAL8, const char *valString)
#define XLAL_ERROR_NULL(...)
#define xlalErrno
#define XLAL_ERROR(...)
#define XLAL_CHECK(assertion,...)
static _LAL_INLINE_ REAL4 XLALREAL4FailNaN(void)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_CHECK_NULL(assertion,...)
#define XLAL_PRINT_ERROR(...)
XLAL_ENOMEM
XLAL_SUCCESS
XLAL_EFAULT
XLAL_EFUNC
XLAL_EDOM
XLAL_EINVAL
XLAL_EFAILED
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
string prefix
size_t numDetectors
Basic input structure to LALBarycenter.c.
REAL8 alpha
Source right ascension in ICRS J2000 coords (radians).
REAL8 dInv
1/(distance to source), in 1/sec.
LIGOTimeGPS tgps
input GPS arrival time.
REAL8 delta
Source declination in ICRS J2000 coords (radians)
LALDetector site
detector site info.
CHAR name[LALNameLength]
State-info about position, velocity and LMST of a detector together with corresponding EarthState.
REAL8 vDetector[3]
Cart.
EarthState earthState
EarthState information.
Detector3Arms detArms
include up to three arms to allow describing LISA
REAL8 rDetector[3]
Cartesian coords of detector position in ICRS J2000.
LIGOTimeGPS tGPS
GPS timestamps corresponding to this entry.
SymmTensor3 detT
Detector-tensor components in SSB-fixed, Cartesian coordinates.
REAL8 LMST
local mean sidereal time at the detector-location in radians
Timeseries of DetectorState's, representing the detector-info at different timestamps.
REAL8 deltaT
timespan centered on each timestamp (e.g.
CoordinateSystem system
The coordinate system used for detector's position/velocity and detector-tensor.
DetectorState * data
array of DetectorState entries
UINT4 length
total number of entries
LALDetector detector
detector-info corresponding to this timeseries
Basic output structure of LALBarycenterEarth.c.
REAL8 gmstRad
Greenwich Mean Sidereal Time (GMST) in radians, at tgps.
Basic output structure produced by LALBarycenter.c.
REAL8 rDetector[3]
Cartesian coords (0=x,1=y,2=z) of detector position at $t_a$ (GPS), in ICRS J2000 coords.
REAL8 vDetector[3]
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
REAL8 location[3]
A vector of 'timestamps' of type LIGOTimeGPS.
Definition: SFTfileIO.h:188
REAL8 deltaT
'length' of each timestamp (e.g.
Definition: SFTfileIO.h:194
LIGOTimeGPS * data
array of timestamps
Definition: SFTfileIO.h:193
UINT4 length
number of timestamps
Definition: SFTfileIO.h:192
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.
Definition: SFTfileIO.h:198
array of detector-specific 'noise floors' (ie PSD values), assumed constant over the frequency-band o...
REAL8 sqrtSn[PULSAR_MAX_DETECTORS]
per-IFO sqrt(PSD) values , where
UINT4 length
number of detectors
A multi-SFT-catalogue "view": a multi-IFO vector of SFT-catalogs.
Definition: SFTfileIO.h:255
SFTCatalog * data
array of SFT-catalog pointers
Definition: SFTfileIO.h:260
UINT4 length
number of detectors
Definition: SFTfileIO.h:259
A collection of SFT vectors – one for each IFO in a multi-IFO search.
Definition: SFTfileIO.h:179
SFTDescriptor * data
array of data-entries describing matched SFTs
Definition: SFTfileIO.h:243
SFTtype header
SFT-header info.
Definition: SFTfileIO.h:228
A symmetric 3x3 tensor (such as detector-tensors), storing only the upper triangle.
enum @4 site