11 #include <lal/LALInference.h>
12 #include <lal/TimeDelay.h>
13 #include <lal/LALDetectors.h>
14 #include <lal/LALStatusMacros.h>
15 #include <lal/SkyCoordinates.h>
24 fprintf(stderr,
"%s: Passed identical detectors as det0 and det1\n",__func__);
32 for(
i=0;
i<3;
i++) detnorm+=detvec[
i]*detvec[
i];
33 for(
i=0;
i<3;
i++) detvec[
i]/=sqrt(detnorm);
35 REAL8 NORTH[3]={0,0,1};
39 a[0]=detvec[1]*NORTH[2];
40 a[1]=-detvec[0]*NORTH[2];
52 REAL8 rotang=-acos(detvec[2]*NORTH[2]);
53 REAL8 c=cos(rotang),
s=sin(rotang);
55 REAL8 det2horiz[3][3]=
57 {
c+
a[0]*
a[0]*(1.-
c),
a[1]*
a[0]*(1.-
c)-
a[2]*
s,
a[0]*
a[2]*(1.-
c)+
a[1]*
s},
58 {
a[1]*
a[0]*(1.-
c)+
a[2]*
s,
c+
a[1]*
a[1]*(1.-
c),
a[1]*
a[2]*(1.-
c)-
a[0]*
s},
59 {
a[0]*
a[2]*(1.-
c)-
a[1]*
s,
a[1]*
a[2]*(1.-
c)+
a[0]*
s,
c+
a[2]*
a[2]*(1.-
c)}
64 for(
i=0;
i<3;
i++)
for(
j=0;
j<3;
j++) GEO[
i]+=det2horiz[
i][
j]*DETPOS[
j];
67 for(
i=0;
i<3;
i++)
r+=GEO[
i]*GEO[
i];
71 REAL8 longitude=atan2(GEO[1],GEO[0]);
72 REAL8 latitude=asin(GEO[2]/
r);
88 fprintf(stderr,
"Error in coordinate conversion.\n");
107 fprintf(stderr,
"%s: Passed identical detectors as det0 and det1\n",__func__);
115 for(
i=0;
i<3;
i++) detnorm+=detvec[
i]*detvec[
i];
116 for(
i=0;
i<3;
i++) detvec[
i]/=sqrt(detnorm);
118 REAL8 NORTH[3]={0,0,1};
122 a[0]=detvec[1]*NORTH[2];
123 a[1]=-detvec[0]*NORTH[2];
143 fprintf(stderr,
"Error in coordinate conversion.\n");
150 GEOPOS[0]=cos(latitude)*cos(longitude);
151 GEOPOS[1]=cos(latitude)*sin(longitude);
152 GEOPOS[2]=sin(latitude);
155 REAL8 rotang=-acos(detvec[2]*NORTH[2]);
156 REAL8 c=cos(rotang),
s=sin(rotang);
163 REAL8 horiz2det[3][3]=
165 {
c+
a[0]*
a[0]*(1.-
c),
a[1]*
a[0]*(1.-
c)+
a[2]*
s,
a[0]*
a[2]*(1.-
c)-
a[1]*
s},
166 {
a[1]*
a[0]*(1.-
c)-
a[2]*
s,
c+
a[1]*
a[1]*(1.-
c),
a[1]*
a[2]*(1.-
c)+
a[0]*
s},
167 {
a[0]*
a[2]*(1.-
c)+
a[1]*
s,
a[1]*
a[2]*(1.-
c)-
a[0]*
s,
c+
a[2]*
a[2]*(1.-
c)}
171 REAL8 DETPOS[3]={0,0,0};
172 for(
i=0;
i<3;
i++)
for(
j=0;
j<3;
j++) DETPOS[
i]+=horiz2det[
i][
j]*GEOPOS[
j];
175 for(
i=0;
i<3;
i++)
r+=DETPOS[
i]*DETPOS[
i];
179 *
theta=atan2(DETPOS[1],DETPOS[0]);
void REPORTSTATUS(LALStatus *status)
static REAL8 norm(const REAL8 x[3])
void LALInferenceEquatorialToDetFrame(LALDetector *det0, LALDetector *det1, REAL8 tg, REAL8 ra, REAL8 dec, REAL8 *t0, REAL8 *alpha, REAL8 *theta)
void LALInferenceDetFrameToEquatorial(LALDetector *det0, LALDetector *det1, REAL8 t0, REAL8 alpha, REAL8 theta, REAL8 *tg, REAL8 *ra, REAL8 *dec)
Conversion routines between Equatorial (RA,DEC) and detector-based coordinate systems,...
COORDINATESYSTEM_GEOGRAPHIC
COORDINATESYSTEM_EQUATORIAL
void LALEquatorialToGeographic(LALStatus *stat, SkyPosition *output, SkyPosition *input, LIGOTimeGPS *gpsTime)
void LALGeographicToEquatorial(LALStatus *stat, SkyPosition *output, SkyPosition *input, LIGOTimeGPS *gpsTime)
REAL8 XLALTimeDelayFromEarthCenter(const double detector_earthfixed_xyz_metres[3], double source_right_ascension_radians, double source_declination_radians, const LIGOTimeGPS *gpstime)
#define XLAL_ERROR_VOID(...)
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)