00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #if 0
00032 <lalVerbatim file="SkyAnnulusCV">
00033 Author: Dietz, A.
00034 $Id: SkyAnnulus.c,v 1.6 2007/06/08 14:41:43 bema Exp $
00035 </lalVerbatim>
00036 #endif
00037
00038 #include <math.h>
00039 #include <stdio.h>
00040 #include <stdlib.h>
00041 #include <lal/LALStdlib.h>
00042 #include <lal/LALStdio.h>
00043 #include <lal/Date.h>
00044 #include <lal/SkyCoordinates.h>
00045 #include <lal/DetectorSite.h>
00046 #include <lal/TimeDelay.h>
00047 #include <lal/DetectorSite.h>
00048 #include <lal/AVFactories.h>
00049 #include <lal/SkyAnnulus.h>
00050
00051 NRCSID( SKYANNULUSSC, "$Id: SkyAnnulus.c,v 1.6 2007/06/08 14:41:43 bema Exp $" );
00052
00053 #if 0
00054 <lalLaTeX>
00055 \subsection{Module \texttt{SkyAnnulus.c}}
00056
00057 \noindent
00058 Provides methods to calculate the annulus given two or three detectors with a certain time difference.
00059
00060 \subsubsection*{Prototypes}
00061 \vspace{0.1in}
00062 \input{SkyAnnulusCP}
00063 \idx{LALComputeSingleAnnulus(
00064 LALStatus *status,
00065 INT2Vector *sky,
00066 LALPlaceAndGPS *placetime1,
00067 LALPlaceAndGPS *placetime2,
00068 REAL4 dtErr,
00069 INT2 nx,
00070 INT2 ny)}
00071 \idx{LALComputeTripleAnnuli( LALStatus *status,
00072 INT2Vector **sky,
00073 LALPlaceAndGPS *placetime1,
00074 LALPlaceAndGPS *placetime2,
00075 LALPlaceAndGPS *placetime3,
00076 REAL4 dtErr,
00077 INT2 nx,
00078 INT2 ny)}
00079 \idx{LALExistTripleAnnuli( LALStatus
00080 *status,
00081 INT2 *exist,
00082 LALPlaceAndGPS *placetime1,
00083 LALPlaceAndGPS *placetime2,
00084 LALPlaceAndGPS *placetime3,
00085 REAL4 dtErr,
00086 INT2 nx,
00087 INT2 ny)}
00088
00089 \subsubsection*{Description}
00090
00091 \noident
00092 \texttt{LALComputeSingleAnnulus} calculates the single annulus when two detectors and two times are given in \texttt{placetime1} and \texttt{placetime2} assuming an error in time resolution of \texttt{dtErr}. The result is a vector \texttt{sky} with dimensions \texttt{nx}x\texttt{ny} representing the whole sky. The index of the vector ($\mathrm{index} = i + j\cdot nx$) represents the coordinates ($\alpha=360^\circ \cdot i / nx$ and $\delta= 180^\circ \cdot i / ny -90$.
00093 If the desired position lies within the annulus the element of the vector is 1, 0 else.
00094 \texttt{LALComputeTripleAnnuli} calculates the annuli when {\em three} detectors and times are given. The result is a vector of four vectors, with the first vector (index 0) containing the complete overlap of all annuli and the next three vectors (indixes 1,2,3) containing the annuli of two of the time intervals each.
00095 \texttt{LALExistTripleAnnuli} just checks if there is at least one position in the sky overlapped by all three annuli created with \texttt{LALComputeTripleAnnuli}.
00096 If that is the case, \texttt{exist} will contain the value 1, 0 else.
00097
00098
00099 \subsubsection*{Algorithm}
00100
00101 \noindent
00102
00103 \subsubsection*{Uses}
00104
00105 \noindent For each module it is not needed to allocate some memory for the structure \option{sky}, this is done in the code.
00106
00107 \subsubsection*{Notes}
00108 %% Any relevant notes.
00109
00110 \vfill{\footnotesize\input{SkyAnnulusCV}}
00111
00112 </lalLaTeX>
00113 #endif
00114
00115
00116 void
00117 LALComputeSingleAnnulus (
00118 LALStatus *status,
00119 INT2Vector *sky,
00120 LALPlaceAndGPS *placetime1,
00121 LALPlaceAndGPS *placetime2,
00122 REAL4 dtErr,
00123 INT2 nx,
00124 INT2 ny
00125 )
00126
00127 {
00128
00129
00130
00131
00132 INT4 i,j, myindex;
00133 REAL4 alpha, delta;
00134 REAL8 time1, time2;
00135 REAL8 dt, dtLow, dtUpp;
00136 REAL8 deltat;
00137
00138 SkyPosition coords;
00139 TwoDetsTimeAndASource tdtaas;
00140
00141
00142 INITSTATUS( status, "LALComputeSingleAnnulus", SKYANNULUSSC );
00143
00144
00145 LALI2CreateVector( status, &sky, nx*ny);
00146
00147
00148 LALGPStoFloat( status, &time1, placetime1->p_gps );
00149 LALGPStoFloat( status, &time2, placetime2->p_gps );
00150 dt=time2-time1;
00151 dtLow=dt-dtErr;
00152 dtUpp=dt+dtErr;
00153
00154
00155 for ( i=0;i<nx;i++ ) {
00156 for ( j=0;j<ny;j++ ) {
00157
00158
00159 alpha= ((REAL4) i)*360./((REAL4) nx);
00160 delta= ((REAL4) j)*180.0/((REAL4) ny)-90.0;
00161
00162 coords.longitude=alpha*LAL_PI_180;
00163 coords.latitude=delta*LAL_PI_180;
00164 coords.system=COORDINATESYSTEM_EQUATORIAL;
00165 tdtaas.p_det_and_time1=placetime1;
00166 tdtaas.p_det_and_time2=placetime2;
00167 tdtaas.p_source=&coords;
00168
00169
00170 LALTimeDelay(status, &deltat, &tdtaas);
00171
00172
00173 myindex=i+j*nx;
00174 if ( dtLow<deltat && deltat<dtUpp ) {
00175 sky->data[myindex]=1;
00176 } else {
00177 sky->data[myindex]=0;
00178 }
00179
00180 }
00181 }
00182
00183 RETURN( status );
00184
00185 }
00186
00187
00188
00189 void
00190 LALComputeTripleAnnuli (
00191 LALStatus *status,
00192 INT2Vector **sky,
00193 LALPlaceAndGPS *placetime1,
00194 LALPlaceAndGPS *placetime2,
00195 LALPlaceAndGPS *placetime3,
00196 REAL4 dtErr,
00197 INT2 nx,
00198 INT2 ny
00199 )
00200
00201 {
00202
00203
00204
00205
00206 INT4 i,j, myindex;
00207
00208 INITSTATUS( status, "LALComputeTripleAnnuli", SKYANNULUSSC );
00209
00210 LALI2CreateVector( status, &sky[0], nx*ny);
00211 LALI2CreateVector( status, &sky[1], nx*ny);
00212 LALI2CreateVector( status, &sky[2], nx*ny);
00213 LALI2CreateVector( status, &sky[3], nx*ny);
00214
00215
00216 LALComputeSingleAnnulus( status, sky[1], placetime1, placetime2, dtErr, nx, ny);
00217 LALComputeSingleAnnulus( status, sky[2], placetime2, placetime3, dtErr, nx, ny);
00218 LALComputeSingleAnnulus( status, sky[3], placetime1, placetime3, dtErr, nx, ny);
00219
00220
00221 for ( i=0;i<nx;i++ ) {
00222 for ( j=0;j<ny;j++ ) {
00223 myindex=i+j*nx;
00224
00225 if ( sky[1]->data[myindex]==1 && sky[2]->data[myindex]==1 && sky[3]->data[myindex]==1 ) {
00226 sky[0]->data[myindex]=1;
00227 } else {
00228 sky[0]->data[myindex]=0;
00229 }
00230
00231 }
00232 }
00233
00234 RETURN( status );
00235
00236 }
00237
00238
00239
00240
00241 void
00242 LALExistTripleAnnuli(
00243 LALStatus *status,
00244 INT2 *exist,
00245 LALPlaceAndGPS *placetime1,
00246 LALPlaceAndGPS *placetime2,
00247 LALPlaceAndGPS *placetime3,
00248 REAL4 dtErr,
00249 INT2 nx,
00250 INT2 ny
00251 )
00252
00253 {
00254
00255
00256
00257
00258 INT4 i,j,myindex;
00259 static INT2Vector* sky[4];
00260
00261 INITSTATUS( status, "LALExistTripleAnnuli", SKYANNULUSSC );
00262
00263
00264 LALComputeTripleAnnuli( status, sky, placetime1, placetime2, placetime3,
00265 dtErr, nx, ny);
00266
00267 *exist=0;
00268
00269
00270 for ( i=0;i<nx;i++ ) {
00271 for ( j=0;j<ny;j++ ) {
00272 myindex=i+j*nx;
00273
00274 if (sky[0]->data[myindex]==1 ) {
00275 *exist=1;
00276 continue;
00277 }
00278
00279 }
00280 }
00281
00282 RETURN( status );
00283 }