Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-3a66518
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
PrintDetectorState.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010 Reinhard Prix
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19
20/**
21 * \file
22 * \ingroup lalpulsar_bin_Tools
23 * \author Reinhard Prix
24 * \brief
25 * Simple standalone code to provide ASCII output for detector response
26 * and ephemeris state at given time, for given detector and sky-location
27 *
28 */
29
30/* ---------- includes ---------- */
31#include "config.h"
32
33#include <math.h>
34#include <errno.h>
35#include <string.h>
36
37#include <lal/UserInput.h>
38#include <lal/LALInitBarycenter.h>
39#include <lal/ComputeFstat.h>
40#include <lal/LALString.h>
41#include <lal/LALPulsarVCSInfo.h>
42
43/* ----- compile switches ----- */
44
45/*---------- local defines ---------- */
46
47/* ----- Macros ----- */
48
49/* ---------- local types ---------- */
50
51typedef struct {
52 LIGOTimeGPS timeGPS; /**< GPS time to compute detector state for (LIGOtimeGPS format) */
53 SkyPosition skypos; /**< skyposition Alpha,Delta in radians, equatorial coords. */
54 EphemerisData *edat; /**< ephemeris data (from XLALInitBarycenter()) */
55 const LALDetector *det; /**< LIGODetector struct holding detector info */
56 LIGOTimeGPSVector *timestamps; /**< timestamps vector holding 1 element: timeGPS */
57 REAL8 sinzeta; /**< detector-arm angle correction (needed for GEO) */
59
60
61typedef struct {
62 CHAR *detector; /**< detector name */
63
64 REAL8 Alpha; /**< skyposition Alpha: radians, equatorial coords. */
65 REAL8 Delta; /**< skyposition Delta: radians, equatorial coords. */
66
67 CHAR *ephemEarth; /**< Earth ephemeris file to use */
68 CHAR *ephemSun; /**< Sun ephemeris file to use */
69
70 REAL8 timeGPS; /**< GPS time to compute detector state for (REAL8 format) */
71
73
74/* ---------- global variables ----------*/
75extern int vrbflg;
76
77/* ---------- local prototypes ---------- */
79int XLALInitCode( ConfigVariables *cfg, const UserVariables_t *uvar, const char *app_name );
80
82
83/*============================================================
84 * FUNCTION definitions
85 *============================================================*/
86
87int
88main( int argc, char *argv[] )
89{
90
93
94 /* register user-variables */
95
97
98 /* read cmdline & cfgfile */
99 BOOLEAN should_exit = 0;
101 if ( should_exit ) {
102 exit( 1 );
103 }
104
105 /* basic setup and initializations */
106 XLAL_CHECK( XLALInitCode( &config, &uvar, argv[0] ) == XLAL_SUCCESS, XLAL_EFUNC );
107
108 /* ----- get detector-state series ----- */
109 DetectorStateSeries *detStates = NULL;
110 XLAL_CHECK( ( detStates = XLALGetDetectorStates( config.timestamps, config.det, config.edat, 0 ) ) != NULL, XLAL_EFUNC );
111
112 /* ----- compute associated SSB timing info ----- */
113 SSBtimes *tSSB = XLALGetSSBtimes( detStates, config.skypos, config.timeGPS, SSBPREC_RELATIVISTIC );
114 XLAL_CHECK( tSSB != NULL, XLAL_EFUNC, "XLALGetSSBtimes() failed with xlalErrno = %d\n", xlalErrno );
115
116 /* ===== compute AM-coeffs ===== */
117 REAL8 a0, b0;
118 if ( XLALComputeAntennaPatternCoeffs( &a0, &b0, &config.skypos, &config.timeGPS, config.det, config.edat ) != XLAL_SUCCESS ) {
119 XLALPrintError( "%s: XLALComputeAntennaPatternCoeffs() failed.\n", __func__ );
121 }
122
123
124 /* ==================== output the results ==================== */
125 printf( "\n" );
126 printf( "----- Input parameters:\n" );
127 printf( "tGPS = { %d, %d }\n", config.timeGPS.gpsSeconds, config.timeGPS.gpsNanoSeconds );
128 printf( "Detector = %s\n", config.det->frDetector.name );
129 printf( "Sky position: longitude = %g rad, latitude = %g rad [equatorial coordinates]\n", config.skypos.longitude, config.skypos.latitude );
130 printf( "\n" );
131
132 printf( "----- Antenna pattern functions:\n" );
133 printf( "a = %.8g\nb = %.8g\n", a0 / config.sinzeta, b0 / config.sinzeta );
134 printf( "\n" );
135
136 printf( "----- Detector & Earth state:\n" );
137 REAL8 *pos = detStates->data[0].rDetector;
138 printf( "Detector position [ICRS J2000. Units=sec]: rDet = {%g, %g, %g}\n", pos[0], pos[1], pos[2] );
139 REAL8 *vel = detStates->data[0].vDetector;
140 printf( "Detector velocity [ICRS J2000. Units=c]: vDet = {%g, %g, %g}\n", vel[0], vel[1], vel[2] );
141 printf( "Local mean sideral time: LMST = %g rad\n", detStates->data[0].LMST );
142 printf( "\n" );
143 printf( "----- SSB timing data:\n" );
144 printf( "TOA difference tSSB - tDet = %g s\n", tSSB->DeltaT->data[0] );
145 printf( "TOA rate of change dtSSB/dtDet - 1 = %g\n", tSSB->Tdot->data[0] - 1.0 );
146 printf( "\n\n" );
147
148
149 /* ----- done: free all memory */
151
153
156 XLALFree( tSSB );
157
159
160 return 0;
161} /* main */
162
163
164/** register all "user-variables" */
165int
167{
168 XLAL_CHECK( uvar != NULL, XLAL_EINVAL );
169
170 /* set a few defaults */
171 uvar->ephemEarth = XLALStringDuplicate( "earth00-40-DE405.dat.gz" );
172 uvar->ephemSun = XLALStringDuplicate( "sun00-40-DE405.dat.gz" );
173
174 uvar->timeGPS = 714180733;
175
176
177 /* register all user-variables */
178 XLALRegisterUvarMember( detector, STRING, 'I', REQUIRED, "Detector name (eg. H1,H2,L1,G1,etc)." );
179
180 XLALRegisterUvarMember( Alpha, REAL8, 'a', OPTIONAL, "skyposition Alpha in radians, equatorial coords." );
181 XLALRegisterUvarMember( Delta, REAL8, 'd', OPTIONAL, "skyposition Delta in radians, equatorial coords." );
182
183 XLALRegisterUvarMember( timeGPS, REAL8, 't', OPTIONAL, "GPS time at which to compute detector state" );
184
185 XLALRegisterUvarMember( ephemEarth, STRING, 0, OPTIONAL, "Earth ephemeris file to use" );
186 XLALRegisterUvarMember( ephemSun, STRING, 0, OPTIONAL, "Sun ephemeris file to use" );
187
188 return XLAL_SUCCESS;
189
190} /* XLALInitUserVars() */
191
192
193/**
194 * basic initializations: deal with user input and return standardized 'ConfigVariables'
195 */
196int
197XLALInitCode( ConfigVariables *cfg, const UserVariables_t *uvar, const char *app_name )
198{
199 if ( !cfg || !uvar || !app_name ) {
200 XLALPrintError( "%s: illegal NULL pointer input.\n\n", __func__ );
202 }
203
204 /* init ephemeris data */
205 XLAL_CHECK( ( cfg->edat = XLALInitBarycenter( uvar->ephemEarth, uvar->ephemSun ) ) != NULL, XLAL_EFUNC );
206
207 /* convert input REAL8 time into LIGOTimeGPS */
208 if ( XLALGPSSetREAL8( &cfg->timeGPS, uvar->timeGPS ) == NULL ) {
209 XLALPrintError( "%s: failed to convert input GPS %g into LIGOTimeGPS\n", __func__, uvar->timeGPS );
211 }
212
213 /* set up dummy timestamps vector containing just this one timestamps */
214 if ( ( cfg->timestamps = XLALCreateTimestampVector( 1 ) ) == NULL ) {
215 XLALPrintError( "%s: XLALCreateTimestampVector( 1 ) failed.", __func__ );
217 }
218 cfg->timestamps->data[0] = cfg->timeGPS;
219
220 /* convert detector name into site-info */
221 if ( ( cfg->det = XLALGetSiteInfo( uvar->detector ) ) == NULL ) {
222 XLALPrintError( "%s: XLALGetSiteInfo('%s') failed.\n", __func__, uvar->detector );
224 }
225
226 /* NOTE: the new function XLALComputeAMCoeffs()
227 * computes 'a * sinzeta' and 'b * sinzeta': for the comparison we therefore need to correct
228 * for GEO's opening-angle of 94.33degrees [JKS98]: */
229 if ( ! strcmp( cfg->det->frDetector.name, "GEO_600" ) ) {
230 cfg->sinzeta = 0.997146;
231 } else {
232 cfg->sinzeta = 1;
233 }
234
235
236 /* convert input skyposition to radians Alpha/Delta [trivial here] */
238 cfg->skypos.longitude = uvar->Alpha;
239 cfg->skypos.latitude = uvar->Delta;
240
241
242 return XLAL_SUCCESS;
243
244} /* XLALInitCode() */
245
246
247/** Destructor for internal configuration struct */
248int
250{
251 XLAL_CHECK( cfg != NULL, XLAL_EINVAL );
252
254
256
258
259 return XLAL_SUCCESS;
260
261} /* XLALDestroyConfig() */
#define __func__
log an I/O error, i.e.
void LALCheckMemoryLeaks(void)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
const double b0
int main(int argc, char *argv[])
int XLALDestroyConfig(ConfigVariables *cfg)
Destructor for internal configuration struct.
int vrbflg
defined in lal/lib/std/LALError.c
int XLALInitCode(ConfigVariables *cfg, const UserVariables_t *uvar, const char *app_name)
basic initializations: deal with user input and return standardized 'ConfigVariables'
int XLALInitUserVars(UserVariables_t *uvar)
register all "user-variables"
#define STRING(a)
void XLALDestroyDetectorStateSeries(DetectorStateSeries *detStates)
Get rid of a DetectorStateSeries.
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...
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.
int XLALComputeAntennaPatternCoeffs(REAL8 *ai, REAL8 *bi, const SkyPosition *skypos, const LIGOTimeGPS *tGPS, const LALDetector *site, const EphemerisData *edat)
Compute single time-stamp antenna-pattern coefficients a(t), b(t) Note: this function uses REAL8 prec...
Definition: LALComputeAM.c:79
unsigned char BOOLEAN
double REAL8
#define XLAL_INIT_DECL(var,...)
char CHAR
void XLALFree(void *p)
char char * XLALStringDuplicate(const char *s)
const LALDetector * XLALGetSiteInfo(const CHAR *name)
Find the site geometry-information 'LALDetector' for given a detector name (or prefix).
Definition: SFTnaming.c:218
LIGOTimeGPSVector * XLALCreateTimestampVector(UINT4 len)
Allocate a LIGOTimeGPSVector.
Definition: SFTtimestamps.c:47
void XLALDestroyTimestampVector(LIGOTimeGPSVector *vect)
De-allocate a LIGOTimeGPSVector.
Definition: SFTtimestamps.c:69
SSBtimes * XLALGetSSBtimes(const DetectorStateSeries *DetectorStates, SkyPosition pos, LIGOTimeGPS refTime, SSBprecision precision)
For a given DetectorStateSeries, calculate the time-differences , and their derivatives .
Definition: SSBtimes.c:518
@ SSBPREC_RELATIVISTIC
detailed relativistic:
Definition: SSBtimes.h:47
COORDINATESYSTEM_EQUATORIAL
int XLALUserVarReadAllInput(BOOLEAN *should_exit, int argc, char *argv[], const LALVCSInfoList vcs_list)
void XLALDestroyUserVars(void)
#define XLALRegisterUvarMember(name, type, option, category,...)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
#define xlalErrno
#define XLAL_ERROR(...)
#define XLAL_CHECK(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
XLAL_SUCCESS
XLAL_EFUNC
XLAL_EINVAL
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
pos
Configuration settings required for and defining a coherent pulsar search.
REAL8 sinzeta
detector-arm angle correction (needed for GEO)
SkyPosition skypos
(Alpha,Delta,system).
LIGOTimeGPS timeGPS
GPS time to compute detector state for (LIGOtimeGPS format)
const LALDetector * det
LIGODetector struct holding detector info.
LIGOTimeGPSVector * timestamps
timestamps vector holding 1 element: timeGPS
EphemerisData * edat
ephemeris data
REAL8 vDetector[3]
Cart.
REAL8 rDetector[3]
Cartesian coords of detector position in ICRS J2000.
REAL8 LMST
local mean sidereal time at the detector-location in radians
Timeseries of DetectorState's, representing the detector-info at different timestamps.
DetectorState * data
array of DetectorState entries
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
LALFrDetector frDetector
CHAR name[LALNameLength]
A vector of 'timestamps' of type LIGOTimeGPS.
Definition: SFTfileIO.h:188
LIGOTimeGPS * data
array of timestamps
Definition: SFTfileIO.h:193
REAL8 * data
Simple container for two REAL8-vectors, namely the SSB-timings DeltaT_alpha and Tdot_alpha,...
Definition: SSBtimes.h:60
REAL8Vector * Tdot
dT/dt : time-derivative of SSB-time wrt local time for SFT-alpha
Definition: SSBtimes.h:63
REAL8Vector * DeltaT
Time-difference of SFT-alpha - tau0 in SSB-frame.
Definition: SSBtimes.h:62
REAL8 longitude
REAL8 latitude
CoordinateSystem system
user input variables
Definition: compareFstats.c:51
REAL8 Alpha
Right ascension [radians] alpha of pulsar.
CHAR * ephemSun
Sun ephemeris file to use.
CHAR * ephemEarth
Earth ephemeris file to use.
REAL8 Delta
Declination [radians] delta of pulsar.
CHAR * detector
detector name
LALStringVector * timeGPS
GPS timestamps to compute detector state for (REAL8 format)
REAL8 timeGPS
GPS time to compute detector state for (REAL8 format)