Home > . > ifodelay.m

ifodelay

PURPOSE ^

IFODELAY - find time delay for IFO from source sky location

SYNOPSIS ^

function samp = ifodelay(detId, cosTheta, phi, sampFreq)

DESCRIPTION ^

 IFODELAY - find time delay for IFO from source sky location

 samp = ifodelay(detID, theta, phi, sampFreq);

 detId         detector identifier string
 cosTheta      cosine of source co-declination angle
               N.B. only cos(theta) for 0<=theta<=pi supported
 phi           source longitude in rad
 sampFreq      sampling frequency of IFO

 samp          number of samples to ADD for delay

 SEE ALSO: GRAVEN, GETIFO

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function samp = ifodelay(detId, cosTheta, phi, sampFreq)
0002 
0003 % IFODELAY - find time delay for IFO from source sky location
0004 %
0005 % samp = ifodelay(detID, theta, phi, sampFreq);
0006 %
0007 % detId         detector identifier string
0008 % cosTheta      cosine of source co-declination angle
0009 %               N.B. only cos(theta) for 0<=theta<=pi supported
0010 % phi           source longitude in rad
0011 % sampFreq      sampling frequency of IFO
0012 %
0013 % samp          number of samples to ADD for delay
0014 %
0015 % SEE ALSO: GRAVEN, GETIFO
0016 
0017 % $Id: ifodelay.m,v 1.9 2004/05/12 00:47:22 stuver Exp $
0018 
0019 % Theory: Find the projection of the vector pointing from the center of the
0020 % Earth to the detector onto the GW's unit vector (pointing from the center
0021 % of the Earth to the source's sky location) and convert this into time of
0022 % flight in units of samples.
0023 
0024 % CHECK for errors
0025 % GET the WGS-84 X, Y & Z coordinates for detId
0026 % DEFINE the gravitational wave's unit vector from sky location
0027 % DETERMINE the number of samples to add to the start time
0028 
0029 samp = [];
0030 
0031 errorcheck(detId, cosTheta, phi, sampFreq);
0032 
0033 % Get the WGS-84 coordinates for detId
0034 Cordnt = getifo(detId);
0035 % Make sure that Cordnt is not empty
0036 if isempty(Cordnt)
0037     Cordnt
0038     error('ifodelay: getifo returned empty Cordnt')
0039 end
0040 
0041 
0042 % Define the X, Y & Z WGS-84 coordinates for detId
0043 XIFO = Cordnt.WGS84(1); % m
0044 YIFO = Cordnt.WGS84(2); % m
0045 ZIFO = Cordnt.WGS84(3); % m
0046 
0047 % From the given cosine of the source's co-dec to line-of-sight,
0048 % define the sine
0049 sinTheta = sqrt(1-cosTheta.^2);
0050 % N.B. only cos(theta) for 0<=theta<=pi supported
0051 
0052 % Define the X, Y & Z coordinates of the GW's sky location
0053 xgw = sinTheta*cos(phi);
0054 ygw = sinTheta*sin(phi);
0055 zgw = cosTheta;
0056 
0057 % Define the GW's unit vector
0058 gwhat = sqrt((xgw^2)+(ygw^2)+(zgw^2)); 
0059 
0060 % Define the speed of light
0061 C0=299792458; % m/s
0062 
0063 % Determine the number of samples to add to the start time from the
0064 % definition of dot product, speed of light and sampling frequency
0065 %
0066 % t = -(XIFO*xgw + YIFO*ygw + ZIFO*zgw)/c*gwhat
0067 % samp = t*sampFreq
0068 
0069 samp = -(((XIFO*xgw)+(YIFO*ygw)+(ZIFO*zgw))/(C0*gwhat))*sampFreq;
0070 
0071 return
0072 
0073 % ~~~ END MAIN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0074 
0075 function errorcheck(detId, cosTheta, phi, sampFreq);
0076 
0077 % ERRORCHECK - checks ifodelay's input data for errors and stops the code if
0078 %              an error is found
0079 %
0080 % errorcheck(detId, cosTheta, phi, sampFreq)
0081 %
0082 % detId         detector identifier string
0083 % cosTheta      cosine of source co-declination angle
0084 % phi           source longitude in rad
0085 % sampFreq      sampling frequency of IFO
0086 
0087 % CHECK variables for error
0088 
0089 % detId must be a string
0090 if ~strcmp(class(detId), 'char')
0091     detId
0092     error('ifodelay: detId must be a string')
0093 end
0094 
0095 % cosTheta must be real and bewteen -1 and 1
0096 if abs(cosTheta) > 1 | ~isreal(cosTheta)
0097     cosTheta
0098     error('ifodelay: cosTheta must be real and bewteen -1 and 1')
0099 end
0100 
0101 % phi must be real and between -pi and pi
0102 if phi < -pi | phi > pi | ~isreal(phi)
0103     phi
0104     error('ifodelay: phi must be real and between -pi and pi')
0105 end
0106     
0107 % sampFreq must be a real positive number
0108 if sampFreq <= 0 | isinf(sampFreq) | isnan(sampFreq) | ~isreal(sampFreq)
0109     sampFreq
0110     error('ifodelay: sampFreq must be a real finite number > 0')
0111 end
0112 
0113 return

Generated on Tue 05-Oct-2004 10:40:50 by m2html © 2003