00001 /* 00002 * Copyright (C) 2005 Badri Krishnan, Alicia Sintes 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with with program; see the file COPYING. If not, write to the 00016 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00017 * MA 02111-1307 USA 00018 */ 00019 00020 /** 00021 * \author Alicia Sintes, Badri Krishnan 00022 * \ingroup pulsarHough 00023 * \file ParamPLUT.c 00024 * \brief Routines for creating Look-Up-Tables for demodulated data 00025 */ 00026 00027 /*----------------------------------------------------------------------- 00028 * 00029 * File Name: ParamPLUT.c 00030 * 00031 * Authors: Sintes, A.M., Krishnan, B., 00032 * 00033 * Revision: $Id: ParamPLUT.c,v 1.5 2006/02/11 09:45:11 badri Exp $ 00034 * 00035 * History: Created by Sintes May 15, 2001 00036 * Modified by Badri Krishnan Feb 2003 00037 * 00038 *----------------------------------------------------------------------- 00039 * 00040 * NAME 00041 * ParamPLUT.c 00042 * 00043 * SYNOPSIS 00044 * 00045 * DESCRIPTION 00046 * 00047 * DIAGNOSTICS 00048 * 00049 *----------------------------------------------------------------------- 00050 */ 00051 00052 /************************************ <lalVerbatim file="ParamPLUTCV"> 00053 Author: Sintes, A. M., Krishnan, B. 00054 $Id: ParamPLUT.c,v 1.5 2006/02/11 09:45:11 badri Exp $ 00055 ************************************* </lalVerbatim> */ 00056 00057 00058 /* <lalLaTeX> 00059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00060 \subsection{Module \texttt{ParamPLUT.c}} 00061 \label{ss:ParamPLUT.c} 00062 Function that calculates the parameters needed for generating the look-up-table. 00063 00064 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00065 \subsubsection*{Prototypes} 00066 \vspace{0.1in} 00067 \input{ParamPLUTD} 00068 \index{\verb&LALHOUGHParamPLUT()&} 00069 00070 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00071 \subsubsection*{Description} 00072 This routine calculates the parameters needed for generating the look-up-table. 00073 It is valid for all cases in which the Hough transform 00074 master equation is of the form: 00075 $f(t)$-\verb@f0@ = $\vec\xi \cdot (\hat n-\hat N)$, or 00076 equivalently, 00077 $\cos(\phi)$ = ($f(t)-$\verb@f0@ + $\vec\xi \cdot\hat N$)/$\vert\vec\xi\vert$. 00078 $\vec\xi$, hereafter \verb@xi@, is calculated according to the demodulation procedure used in a 00079 first stage.\\ 00080 00081 00082 00083 The inputs are: 00084 \begin{description} 00085 \item[\texttt{INT8 f0Bin}]: The frequency bin to construct the {\sc lut}. 00086 \item[\texttt{HOUGHDemodPar *par}]: The demodulation parameters: 00087 \begin{description} 00088 \item[\texttt{par->deltaF }]: Frequency resolution: \texttt{df=1/TCOH}. 00089 \item[\texttt{par->skyPatch }]: $N_{center}$ (alpha, delta): 00090 position of the center of the patch. 00091 \item[\texttt{par->patchSizeX }]: Size of sky patch along x-axis measured in radians. 00092 \item[\texttt{par->patchSizeY }]: Size of sky patch along y-axis measured in radians. 00093 \item[\texttt{par->veloC }]: $v(t)/c$ (x,y,z): relative detector 00094 velocity. 00095 \item[\texttt{par->positC }]: $(\vec x(t)-\vec x(\hat t_0))/c$ (x,y,z). Position 00096 of the detector. 00097 \item[\texttt{par->timeDiff }]: $T_{\hat N}(t)-T_{\hat N}(\hat t_0)$: Time difference. 00098 \item[\texttt{par->spin }]: \texttt{length}: Maximum order of 00099 spin-down parameter. 00100 \texttt{*data}: Pointer to spin-down parameter set $F_k$. 00101 \end{description} 00102 \end{description} 00103 00104 The output \verb@*out@ of type \verb@HOUGHParamPLUT@ contains 00105 all the parameters needed to build the look-up-table for constructing 00106 the partial Hough maps. Those are: 00107 \begin{description} 00108 \item[\texttt{out->f0Bin }]: Frequency bin for which it has been constructed. 00109 \item[\texttt{out->deltaF }]: Frequency resolution: \texttt{df=1/TCOH}. 00110 \item[\texttt{out->xi }]: Center of the circle on the celestial 00111 sphere, xi(alpha,delta) in the rotated coordinates. 00112 \item[\texttt{out->cosDelta }]: $\Delta \cos(\phi)$ corresponding to 00113 one annulus: \verb@deltaF/|xi|@. 00114 \item[\texttt{out->cosPhiMax0 }]: $\max(\cos(\phi))$ of the 00115 \texttt{f0Bin} : \verb@(xi*N +deltaF/2)/|xi|@. 00116 \item[\texttt{out->cosPhiMin0 }]: $\min(\cos(\phi))$ of the 00117 \texttt{f0Bin} : \verb@cosPhiMax0-cosDelta@. 00118 \item[\texttt{out->epsilon }]: Maximum angle (distance in radians) from the pole 00119 to consider a circle as a line in the projected plane: 00120 \verb@8.* LINERR * f0Bin* VEPI * VEPI / VTOT@. For explanations see Sintes' 00121 notes. 00122 \end{description} 00123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00124 \subsubsection*{Uses} 00125 \begin{verbatim} 00126 LALRotatePolarU() 00127 \end{verbatim} 00128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00129 \subsubsection*{Notes} 00130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00131 \vfill{\footnotesize\input{ParamPLUTCV}} 00132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00133 </lalLaTeX> */ 00134 00135 00136 #include <lal/LUT.h> 00137 00138 NRCSID (PARAMPLUTC, "$Id: ParamPLUT.c,v 1.5 2006/02/11 09:45:11 badri Exp $"); 00139 00140 /* <lalVerbatim file="ParamPLUTD"> */ 00141 void LALHOUGHParamPLUT (LALStatus *status, 00142 HOUGHParamPLUT *out, /* parameters needed build LUT*/ 00143 HOUGHSizePar *size, 00144 HOUGHDemodPar *par) /* demodulation parameters */ 00145 { /* </lalVerbatim> */ 00146 00147 /* --------------------------------------------- */ 00148 00149 REAL8 f0; /* frequency corresponding to f0Bin */ 00150 INT8 f0Bin; 00151 REAL8 deltaF; /* df=1/TCOH */ 00152 REAL8 delta; 00153 REAL8 vFactor, xFactor; 00154 REAL8 xiX, xiY, xiZ; 00155 REAL8 modXi,invModXi; 00156 REAL8UnitPolarCoor xiInit; 00157 UINT4 spinOrder, i; 00158 REAL8 *spinF; 00159 REAL8 timeDiff; /* T(t)-T(t0) */ 00160 REAL8 timeDiffProd; 00161 /* --------------------------------------------- */ 00162 00163 INITSTATUS (status, "LALHOUGHParamPLUT", PARAMPLUTC); 00164 ATTATCHSTATUSPTR (status); 00165 00166 /* Make sure the arguments are not NULL: */ 00167 ASSERT (out, status, LUTH_ENULL, LUTH_MSGENULL); 00168 ASSERT (par, status, LUTH_ENULL, LUTH_MSGENULL); 00169 ASSERT (size, status, LUTH_ENULL, LUTH_MSGENULL); 00170 00171 /* Make sure f0Bin is not zero: */ 00172 f0Bin = size->f0Bin; 00173 ASSERT (f0Bin, status, LUTH_EFREQ, LUTH_MSGEFREQ); 00174 00175 out->f0Bin = f0Bin; 00176 deltaF = out->deltaF = size->deltaF; 00177 00178 f0 = f0Bin * deltaF; 00179 00180 out->epsilon = size->epsilon; 00181 out->nFreqValid = size->nFreqValid; 00182 /* ------------------------------------------- */ 00183 00184 00185 /* ------------------------------------------- */ 00186 /* *********** xi calculation ***************** */ 00187 00188 vFactor = f0; 00189 xFactor = 0.0; 00190 00191 spinOrder = par->spin.length; 00192 00193 if(spinOrder){ 00194 ASSERT (par->spin.data , status, LUTH_ENULL, LUTH_MSGENULL); 00195 timeDiff = par->timeDiff; 00196 timeDiffProd = 1.0; 00197 spinF = par->spin.data; 00198 00199 for (i=0; i<spinOrder; ++i ){ 00200 xFactor += spinF[i] * timeDiffProd * (i+1.0); 00201 timeDiffProd *= timeDiff; 00202 vFactor += spinF[i] * timeDiffProd; 00203 } 00204 } 00205 00206 xiX = vFactor * (par->veloC.x) + xFactor * (par->positC.x); 00207 xiY = vFactor * (par->veloC.y) + xFactor * (par->positC.y); 00208 xiZ = vFactor * (par->veloC.z) + xFactor * (par->positC.z); 00209 00210 /* ------------------------------------------- */ 00211 /* ***** convert xi into Polar coordinates ***** */ 00212 00213 modXi = sqrt(xiX*xiX + xiY*xiY + xiZ*xiZ); 00214 /* for testing we used: modXi = F0* 1.06e-4; */ 00215 invModXi = 1./modXi; 00216 00217 xiInit.delta = asin( xiZ*invModXi); 00218 /* the arc sine is in the interval [-pi/2,pi/2] */ 00219 00220 if( xiX || xiY ){ 00221 xiInit.alpha = atan2(xiY, xiX); 00222 }else{ 00223 xiInit.alpha = 0.0; 00224 } 00225 00226 /* if( (xiX == 0.0 ) && (xiY == 0.0 ) ){ */ 00227 /* xiInit.alpha = 0.0; */ 00228 /* }else{ xiInit.alpha = atan2(xiY, xiX); } */ 00229 00230 /* ------------------------------------------- */ 00231 /* **** Rotate Patch, so that its center becomes */ 00232 /* **** the south pole {x,y,z} = {0,0,-1} ***** */ 00233 /* Calculate xi in the new coordinate system. */ 00234 00235 TRY(LALRotatePolarU(status->statusPtr, 00236 &(*out).xi ,&xiInit, &(*par).skyPatch), status); 00237 00238 /* ------------------------------------------- */ 00239 delta = out->xi.delta; 00240 00241 out->cosDelta = deltaF*invModXi; 00242 out->cosPhiMax0 = deltaF*0.5*invModXi -sin(delta); 00243 out->cosPhiMin0 = (out->cosPhiMax0) -(out->cosDelta); 00244 out->offset = 0; 00245 00246 /* ------------------------------------------- */ 00247 00248 DETATCHSTATUSPTR (status); 00249 00250 /* normal exit */ 00251 RETURN (status); 00252 } 00253 00254 00255 00256
1.5.2