/** Create a DetectorStateSeries */ void LALCreateDetectorStateSeries (LALStatus *status, /**< pointer to LALStatus structure */ DetectorStateSeries **vect, /**< output vector */ UINT4 length ) /**< number of entries */ { DetectorStateSeries *ret = NULL; INITSTATUS(status); ASSERT ( vect, status, DETECTORSTATES_ENULL, DETECTORSTATES_MSGENULL); ASSERT ( *vect == NULL, status, DETECTORSTATES_ENONULL, DETECTORSTATES_MSGENONULL); if ( (ret = XLALCreateDetectorStateSeries ( length )) == NULL ) { ABORT ( status, DETECTORSTATES_EXLAL, DETECTORSTATES_MSGEXLAL ); } /* return result */ (*vect) = ret; RETURN (status); } /* LALCreateDetectorStateSeries() */
/** * Get the 'detector state' (ie detector-tensor, position, velocity, etc) for the given * vector of timestamps, shifted by a common time-shift \a tOffset. * * This function just calls XLALBarycenterEarth() and XLALBarycenter() for the * given vector of timestamps (shifted by tOffset) and returns the positions, * velocities and LMSTs of the detector, stored in a DetectorStateSeries. * There is also an entry containing the EarthState at each timestamp, which * can be used as input for subsequent calls to XLALBarycenter(). * * \a tOffset allows one to easily use the midpoints of SFT-timestamps, for example. * */ DetectorStateSeries * XLALGetDetectorStates ( const LIGOTimeGPSVector *timestamps, /**< array of GPS timestamps t_i */ const LALDetector *detector, /**< detector info */ const EphemerisData *edat, /**< ephemeris file data */ REAL8 tOffset /**< compute detector states at timestamps SHIFTED by tOffset */ ) { /* check input consistency */ if ( !timestamps || !detector || !edat ) { XLALPrintError ("%s: invalid NULL input, timestamps=%p, detector=%p, edat=%p\n", __func__, timestamps, detector, edat ); XLAL_ERROR_NULL ( XLAL_EINVAL ); } /* prepare return vector */ UINT4 numSteps = timestamps->length; DetectorStateSeries *ret = NULL; if ( ( ret = XLALCreateDetectorStateSeries ( numSteps )) == NULL ) { XLALPrintError ("%s: XLALCreateDetectorStateSeries(%d) failed.\n", __func__, numSteps ); XLAL_ERROR_NULL ( XLAL_EFUNC ); } /* enter detector-info into the head of the state-vector */ ret->detector = (*detector); /* set 'time-span' associated with each timestamp */ ret->deltaT = timestamps->deltaT; /* set SSB coordinate system used: EQUATORIAL for Earth-based, ECLIPTIC for LISA */ if ( detector->frDetector.prefix[0] == 'Z' ) /* LISA */ ret->system = COORDINATESYSTEM_ECLIPTIC; else /* Earth-based */ ret->system = COORDINATESYSTEM_EQUATORIAL; /* now fill all the vector-entries corresponding to different timestamps */ UINT4 i; for ( i=0; i < numSteps; i++ ) { BarycenterInput baryinput; EmissionTime emit; DetectorState *state = &(ret->data[i]); EarthState *earth = &(state->earthState); LIGOTimeGPS tgps; /* shift timestamp by tOffset */ tgps = timestamps->data[i]; XLALGPSAdd(&tgps, tOffset); /*----- first get earth-state */ if ( XLALBarycenterEarth ( earth, &tgps, edat ) != XLAL_SUCCESS ) { XLALDestroyDetectorStateSeries ( ret ); XLALPrintError("%s: XLALBarycenterEarth() failed with xlalErrno=%d\n", __func__, xlalErrno ); XLAL_ERROR_NULL ( XLAL_EFAILED ); } /*----- then get detector-specific info */ baryinput.tgps = tgps; baryinput.site = (*detector); baryinput.site.location[0] /= LAL_C_SI; baryinput.site.location[1] /= LAL_C_SI; baryinput.site.location[2] /= LAL_C_SI; baryinput.alpha = baryinput.delta = 0; /* irrelevant */ baryinput.dInv = 0; if ( XLALBarycenter ( &emit, &baryinput, earth) != XLAL_SUCCESS ) { XLALDestroyDetectorStateSeries( ret ); XLALPrintError("%s: XLALBarycenterEarth() failed with xlalErrno=%d\n", __func__, xlalErrno ); XLAL_ERROR_NULL ( XLAL_EFAILED ); } /*----- extract the output-data from this */ UINT4 j; for (j=0; j < 3; j++) /* copy detector's position and velocity */ { state->rDetector[j] = emit.rDetector[j]; state->vDetector[j] = emit.vDetector[j]; } /* for j < 3 */ /* local mean sidereal time = GMST + longitude */ state->LMST = earth->gmstRad + detector->frDetector.vertexLongitudeRadians; state->LMST = fmod (state->LMST, LAL_TWOPI ); /* normalize */ /* insert timestamp */ state->tGPS = tgps; /* compute the detector-tensor at this time-stamp in SSB-fixed Cartesian coordinates * [EQUATORIAL for Earth-based, ECLIPTIC for LISA] */ if ( XLALFillDetectorTensor ( state, detector ) != 0 ) { XLALDestroyDetectorStateSeries(ret); XLALPrintError ( "%s: XLALFillDetectorTensor() failed ... errno = %d\n\n", __func__, xlalErrno ); XLAL_ERROR_NULL ( XLAL_EFUNC ); } } /* for i < numSteps */ /* return result */ return ret; } /* XLALGetDetectorStates() */