HoughMap.c

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2005 Badri Krishnan, Alicia Sintes, Bernd Machenschalk
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  *
00022  * \file HoughMap.c
00023  * \brief Subroutines for initialization and construction of Hough-map derivatives and total Hough-maps.
00024  * \author Sintes, A.M., 
00025  * \ingroup pulsarHough
00026  * Revision: $Id: HoughMap.c,v 1.12 2008/01/30 22:56:13 bema Exp $
00027  *
00028  * History:   Created by Sintes June 22, 2001
00029  *            Modified    "    August 6, 2001
00030  *
00031  
00032 \par Description 
00033 
00034 The function  LALHOUGHInitializeHD() initializes the Hough map derivative
00035 space  HOUGHMapDeriv *hd to zero. Note that the length of the map
00036 hd->map should be hd->ySide * (hd->xSide + 1).
00037 
00038 The function  LALHOUGHInitializeHT() initializes the total Hough map 
00039 HOUGHMapTotal *ht  to zero and checks consistency between 
00040 the number of physical pixels in the
00041 map  and  those given by the grid information structure 
00042 HOUGHPatchGrid *patch.
00043 
00044 Given an initial Hough map derivative HOUGHMapDeriv *hd and a representation
00045 of a phmd HOUGHphmd *phmd, the function  LALHOUGHAddPHMD2HD() accumulates
00046 the partial Hough map derivative *phmd to *hd by adding +1 or
00047 -1 to the pixels corresponding to the left or right borders respectively. 
00048 It takes into account corrections due to border effects as well.
00049  
00050 The function  LALHOUGHIntegrHD2HT() constructs a total Hough map 
00051 HOUGHMapTotal *ht from its derivative HOUGHMapDeriv *hd by
00052 integrating each row (x-direction).
00053 
00054 
00055  */
00056 
00057 /************************************ <lalVerbatim file="HoughMapCV">
00058 Author: Sintes, A. M., Krishnan, B.
00059 $Id: HoughMap.c,v 1.12 2008/01/30 22:56:13 bema Exp $
00060 ************************************* </lalVerbatim> */
00061 
00062 
00063 /* <lalLaTeX>
00064 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00065 \subsection{Module \texttt{HoughMap.c}}
00066 \label{ss:HoughMap.c}
00067 Subroutines for 
00068 initialization and construction of Hough-map derivatives and total Hough-maps.
00069 
00070 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00071 \subsubsection*{Prototypes}
00072 \vspace{0.1in}
00073 \input{HoughMapD}
00074 \index{\verb&LALHOUGHInitializeHD()&}
00075 \index{\verb&LALHOUGHInitializeHT()&}
00076 \index{\verb&LALHOUGHAddPHMD2HD()&}
00077 \index{\verb&LALHOUGHIntegrHD2HT()&}
00078 
00079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00080 \subsubsection*{Description}
00081 
00082 ${}$
00083 
00084 
00085 The function \verb&LALHOUGHInitializeHD()& initializes the Hough map derivative
00086 space \verb&HOUGHMapDeriv *hd& to zero. Note that the length of the map
00087 \verb@hd->map@ should be \verb@hd->ySide * (hd->xSide + 1)@.\\
00088 
00089 The function \verb&LALHOUGHInitializeHT()& initializes the total Hough map 
00090 \verb&HOUGHMapTotal *ht&  to zero and checks consistency between 
00091 the number of physical pixels in the
00092 map  and  those given by the grid information structure 
00093 \verb&HOUGHPatchGrid *patch&.\\
00094 
00095  Given an initial Hough map derivative \verb@HOUGHMapDeriv *hd@ and a representation
00096   of a {\sc phmd}
00097  \verb@HOUGHphmd *phmd@, the function \verb&LALHOUGHAddPHMD2HD()& accumulates
00098  the partial Hough map derivative \verb@*phmd@ to \verb@*hd@ by adding $+1$ or
00099  $-1$ to
00100  the pixels corresponding to the {\it left} or {\it right} borders respectively.
00101  It takes into account corrections due to {\it border} effects as well.\\
00102  
00103 The function \verb&LALHOUGHIntegrHD2HT()& constructs a total Hough map 
00104 \verb&HOUGHMapTotal *ht& from its derivative \verb@HOUGHMapDeriv *hd@ by
00105 integrating each row (x-direction).
00106  
00107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00108 \subsubsection*{Uses}
00109 %%\begin{verbatim}
00110 %%LALZDestroyVector()
00111 %%\end{verbatim}
00112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00113 \subsubsection*{Notes}
00114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00115 \vfill{\footnotesize\input{HoughMapCV}}
00116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00117 </lalLaTeX> */
00118 
00119 
00120 
00121 #include <lal/HoughMap.h>
00122 
00123 NRCSID (HOUGHMAPC, "$Id: HoughMap.c,v 1.12 2008/01/30 22:56:13 bema Exp $");
00124 
00125 
00126 /*
00127  * The functions that make up the guts of this module
00128  */
00129 
00130 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
00131 /* *******************************  <lalVerbatim file="HoughMapD"> */
00132 void LALHOUGHInitializeHD (LALStatus      *status,
00133                           HOUGHMapDeriv   *hd) /* the Hough map derivative */
00134 { /*   *********************************************  </lalVerbatim> */
00135 
00136   INT4     k, maxk;
00137   HoughDT  *pointer;
00138 
00139    /* --------------------------------------------- */
00140   INITSTATUS (status, "LALHOUGHInitializeHD", HOUGHMAPC);
00141   ATTATCHSTATUSPTR (status); 
00142 
00143   /*   Make sure the arguments are not NULL: */ 
00144   ASSERT (hd,    status, HOUGHMAPH_ENULL, HOUGHMAPH_MSGENULL);
00145   /* Make sure the map contains some pixels */
00146   ASSERT (hd->xSide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00147   ASSERT (hd->ySide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00148   
00149   /* -------------------------------------------   */
00150 
00151   /* initializing the Hough map derivative space */
00152   pointer = &( hd->map[0]);
00153   maxk    = hd->ySide*(hd->xSide+1);
00154   
00155   for ( k=0; k< maxk; ++k ){
00156     *pointer = 0;
00157     ++pointer;
00158   }
00159 
00160   /* -------------------------------------------   */
00161   
00162   DETATCHSTATUSPTR (status);
00163   
00164   /* normal exit */
00165   RETURN (status);
00166 }
00167 
00168 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
00169 /* *******************************  <lalVerbatim file="HoughMapD"> */
00170 void LALHOUGHInitializeHT (LALStatus      *status,
00171                            HOUGHMapTotal   *ht,     /* the total Hough map */
00172                            HOUGHPatchGrid  *patch) /* patch information */
00173 { /*   *********************************************  </lalVerbatim> */
00174 
00175   INT4     k,maxk;
00176   HoughTT  *pointer;
00177 
00178    /* --------------------------------------------- */
00179   INITSTATUS (status, "LALHOUGHInitializeHT", HOUGHMAPC);
00180 
00181   /*   Make sure the arguments are not NULL: */ 
00182   ASSERT (ht, status, HOUGHMAPH_ENULL, HOUGHMAPH_MSGENULL);
00183   ASSERT (patch, status, HOUGHMAPH_ENULL, HOUGHMAPH_MSGENULL);
00184   /* Make sure the map contains some pixels */
00185   ASSERT (ht->xSide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00186   ASSERT (ht->ySide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00187   ASSERT (patch->xSide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00188   ASSERT (patch->ySide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00189   /*   Check consistency between patch and ht size  (size mismatch) */
00190   ASSERT (ht->xSide == patch->xSide, status, HOUGHMAPH_ESZMM, HOUGHMAPH_MSGESZMM);
00191   ASSERT (ht->ySide == patch->ySide, status, HOUGHMAPH_ESZMM, HOUGHMAPH_MSGESZMM);
00192 
00193   /* -------------------------------------------   */
00194 
00195   /* number of physical pixels */
00196   maxk = ht->ySide * ht->xSide;
00197  
00198   /* initializing the Hough map space */
00199    pointer = &(ht->map[0]); 
00200    for ( k=0; k< maxk; ++k ){ 
00201      *pointer = 0; 
00202      ++pointer;  
00203    } 
00204 
00205   /* normal exit */
00206   RETURN (status);
00207 }
00208 
00209 
00210 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
00211 /** Adds a hough map derivative into a total hough map derivative WITHOUT 
00212     taking into account the weight of the partial hough map */
00213 /* *******************************  <lalVerbatim file="HoughMapD"> */
00214 void LALHOUGHAddPHMD2HD (LALStatus      *status, /**< the status pointer */
00215                          HOUGHMapDeriv  *hd,  /**< the Hough map derivative */
00216                          HOUGHphmd      *phmd) /**< info from a partial map */ 
00217 { /*   *********************************************  </lalVerbatim> */
00218 
00219   INT2     k,j;
00220   INT2     yLower, yUpper;
00221   UINT2    lengthLeft,lengthRight, xSide,ySide;
00222   COORType     *xPixel;
00223   HOUGHBorder  *borderP;
00224 
00225    /* --------------------------------------------- */
00226   INITSTATUS (status, "LALHOUGHAddPHMD2HD", HOUGHMAPC);
00227   ATTATCHSTATUSPTR (status); 
00228 
00229   /*   Make sure the arguments are not NULL: */ 
00230   ASSERT (hd,   status, HOUGHMAPH_ENULL, HOUGHMAPH_MSGENULL);
00231   ASSERT (phmd, status, HOUGHMAPH_ENULL, HOUGHMAPH_MSGENULL);
00232   /* -------------------------------------------   */
00233   /* Make sure the map contains some pixels */
00234   ASSERT (hd->xSide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00235   ASSERT (hd->ySide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00236 
00237   xSide = hd->xSide;
00238   ySide = hd->ySide;
00239   
00240   /* first column correction */
00241   for ( k=0; k< ySide; ++k ){
00242     hd->map[k*(xSide+1) + 0] += phmd->firstColumn[k];
00243   }
00244 
00245   lengthLeft = phmd->lengthLeft;
00246   lengthRight= phmd->lengthRight;
00247 
00248   /* left borders =>  +1 increase */
00249   for (k=0; k< lengthLeft; ++k){
00250 
00251     /*  Make sure the arguments are not NULL: (Commented for performance) */ 
00252     /*  ASSERT (phmd->leftBorderP[k], status, HOUGHMAPH_ENULL,
00253         HOUGHMAPH_MSGENULL); */
00254 
00255     borderP = phmd->leftBorderP[k];
00256 
00257     yLower = (*borderP).yLower;
00258     yUpper = (*borderP).yUpper;
00259     xPixel =  &( (*borderP).xPixel[0] );
00260 
00261    
00262     if (yLower < 0) {
00263       fprintf(stderr,"WARNING: Fixing yLower (%d -> 0) [HoughMap.c %d]\n",
00264               yLower, __LINE__);
00265       yLower = 0;
00266     }
00267     if (yUpper >= ySide) {
00268       fprintf(stderr,"WARNING: Fixing yUpper (%d -> %d) [HoughMap.c %d]\n",
00269               yUpper, ySide-1, __LINE__);
00270       yUpper = ySide - 1;
00271     }
00272 
00273     for(j=yLower; j<=yUpper;++j){
00274       hd->map[j *(xSide+1) + xPixel[j] ] += 1;
00275     }
00276   }
00277 
00278   /* right borders =>  -1 decrease */
00279   for (k=0; k< lengthRight; ++k){
00280   
00281     /*  Make sure the arguments are not NULL: (Commented for performance) */ 
00282     /*  ASSERT (phmd->rightBorderP[k], status, HOUGHMAPH_ENULL,
00283         HOUGHMAPH_MSGENULL); */
00284 
00285     borderP = phmd->rightBorderP[k];
00286         
00287     yLower = (*borderP).yLower;
00288     yUpper = (*borderP).yUpper;
00289     xPixel =  &( (*borderP).xPixel[0] );
00290 
00291    
00292     if (yLower < 0) {
00293       fprintf(stderr,"WARNING: Fixing yLower (%d -> 0) [HoughMap.c %d]\n",
00294               yLower, __LINE__);
00295       yLower = 0;
00296     }
00297     if (yUpper >= ySide) {
00298       fprintf(stderr,"WARNING: Fixing yUpper (%d -> %d) [HoughMap.c %d]\n",
00299               yUpper, ySide-1, __LINE__);
00300       yUpper = ySide - 1;
00301     }
00302 
00303     for(j=yLower; j<=yUpper;++j){
00304       hd->map[j*(xSide+1) + xPixel[j] ] -= 1;
00305     }
00306   }
00307 
00308 
00309   /* -------------------------------------------   */
00310   
00311   DETATCHSTATUSPTR (status);
00312   
00313   /* normal exit */
00314   RETURN (status);
00315 }
00316 
00317 
00318 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
00319 /** Adds a hough map derivative into a total hough map derivative taking into
00320     account the weight of the partial hough map */
00321 /* *******************************  <lalVerbatim file="HoughMapD"> */
00322 void LALHOUGHAddPHMD2HD_W (LALStatus      *status, /**< the status pointer */
00323                            HOUGHMapDeriv  *hd,  /**< the Hough map derivative */
00324                            HOUGHphmd      *phmd) /**< info from a partial map */ 
00325 { /*   *********************************************  </lalVerbatim> */
00326 
00327   INT2     k,j;
00328   INT2     yLower, yUpper;
00329   UINT2    lengthLeft,lengthRight, xSide,ySide;
00330   COORType     *xPixel;
00331   HOUGHBorder  *borderP;
00332   HoughDT    weight;
00333   INT4       sidx; /* pre-calcuted array index for sanity check */
00334 
00335    /* --------------------------------------------- */
00336   INITSTATUS (status, "LALHOUGHAddPHMD2HD_W", HOUGHMAPC);
00337   ATTATCHSTATUSPTR (status); 
00338 
00339   /*   Make sure the arguments are not NULL: */ 
00340   ASSERT (hd,   status, HOUGHMAPH_ENULL, HOUGHMAPH_MSGENULL);
00341   ASSERT (phmd, status, HOUGHMAPH_ENULL, HOUGHMAPH_MSGENULL);
00342   /* -------------------------------------------   */
00343   /* Make sure the map contains some pixels */
00344   ASSERT (hd->xSide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00345   ASSERT (hd->ySide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00346 
00347   weight = phmd->weight;
00348 
00349   xSide = hd->xSide;
00350   ySide = hd->ySide;
00351   
00352   /* first column correction */
00353   for ( k=0; k< ySide; ++k ){
00354     hd->map[k*(xSide+1) + 0] += phmd->firstColumn[k] * weight;
00355   }
00356 
00357   lengthLeft = phmd->lengthLeft;
00358   lengthRight= phmd->lengthRight;
00359 
00360   /* left borders =>  increase according to weight*/
00361   for (k=0; k< lengthLeft; ++k){
00362 
00363     /*  Make sure the arguments are not NULL: (Commented for performance) */ 
00364     /*  ASSERT (phmd->leftBorderP[k], status, HOUGHMAPH_ENULL,
00365         HOUGHMAPH_MSGENULL); */
00366 
00367     borderP = phmd->leftBorderP[k];
00368 
00369     yLower = (*borderP).yLower;
00370     yUpper = (*borderP).yUpper;
00371     xPixel =  &( (*borderP).xPixel[0] );
00372    
00373     if (yLower < 0) {
00374       fprintf(stderr,"WARNING: Fixing yLower (%d -> 0) [HoughMap.c %d]\n",
00375               yLower, __LINE__);
00376       yLower = 0;
00377     }
00378     if (yUpper >= ySide) {
00379       fprintf(stderr,"WARNING: Fixing yUpper (%d -> %d) [HoughMap.c %d]\n",
00380               yUpper, ySide-1, __LINE__);
00381       yUpper = ySide - 1;
00382     }
00383 
00384     for(j=yLower; j<=yUpper;++j){
00385       sidx = j *(xSide+1) + xPixel[j];
00386       if ((sidx < 0) || (sidx >= ySide*(xSide+1))) {
00387         fprintf(stderr,"\nERROR: %s %d: map index out of bounds: %d [0..%d] j:%d xp[j]:%d\n",
00388                 __FILE__,__LINE__,sidx,ySide*(xSide+1),j,xPixel[j] );
00389         ABORT(status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00390       }
00391       hd->map[sidx] += weight;
00392     }
00393   }
00394 
00395   /* right borders => decrease according to weight*/
00396   for (k=0; k< lengthRight; ++k){
00397   
00398     /*  Make sure the arguments are not NULL: (Commented for performance) */ 
00399     /*  ASSERT (phmd->rightBorderP[k], status, HOUGHMAPH_ENULL,
00400         HOUGHMAPH_MSGENULL); */
00401 
00402     borderP = phmd->rightBorderP[k];
00403         
00404     yLower = (*borderP).yLower;
00405     yUpper = (*borderP).yUpper;
00406     xPixel =  &( (*borderP).xPixel[0] );
00407    
00408     if (yLower < 0) {
00409       fprintf(stderr,"WARNING: Fixing yLower (%d -> 0) [HoughMap.c %d]\n",
00410               yLower, __LINE__);
00411       yLower = 0;
00412     }
00413     if (yUpper >= ySide) {
00414       fprintf(stderr,"WARNING: Fixing yUpper (%d -> %d) [HoughMap.c %d]\n",
00415               yUpper, ySide-1, __LINE__);
00416       yUpper = ySide - 1;
00417     }
00418 
00419     for(j=yLower; j<=yUpper;++j){
00420       sidx = j*(xSide+1) + xPixel[j];
00421       if ((sidx < 0) || (sidx >= ySide*(xSide+1))) {
00422         fprintf(stderr,"\nERROR: %s %d: map index out of bounds: %d [0..%d] j:%d xp[j]:%d\n",
00423                 __FILE__,__LINE__,sidx,ySide*(xSide+1),j,xPixel[j] );
00424         ABORT(status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00425       }
00426       hd->map[sidx] -= weight;
00427     }
00428   }
00429 
00430 
00431   /* -------------------------------------------   */
00432   
00433   DETATCHSTATUSPTR (status);
00434   
00435   /* normal exit */
00436   RETURN (status);
00437 }
00438 
00439 
00440 
00441 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
00442 /* *******************************  <lalVerbatim file="HoughMapD"> */
00443 void LALHOUGHIntegrHD2HT (LALStatus       *status,
00444                           HOUGHMapTotal   *ht,     /* the total Hough map */
00445                           HOUGHMapDeriv   *hd) /* the Hough map derivative */
00446 { /*   *********************************************  </lalVerbatim> */
00447 
00448   INT2    i,j;
00449   UINT2   xSide,ySide;
00450   HoughTT accumulator;
00451 
00452    /* --------------------------------------------- */
00453   INITSTATUS (status, "LALHOUGHIntegrHD2HT", HOUGHMAPC);
00454   ATTATCHSTATUSPTR (status); 
00455 
00456   /*   Make sure the arguments are not NULL: */ 
00457   ASSERT (hd, status, HOUGHMAPH_ENULL, HOUGHMAPH_MSGENULL);
00458   ASSERT (ht, status, HOUGHMAPH_ENULL, HOUGHMAPH_MSGENULL);
00459   /* Make sure the map contains some pixels */
00460   ASSERT (hd->xSide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00461   ASSERT (hd->ySide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00462   ASSERT (ht->xSide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00463   ASSERT (ht->ySide, status, HOUGHMAPH_ESIZE, HOUGHMAPH_MSGESIZE);
00464   /*   Check consistency between hd and ht size  (size mismatch) */
00465   ASSERT (ht->xSide == hd->xSide, status, HOUGHMAPH_ESZMM, HOUGHMAPH_MSGESZMM);
00466   ASSERT (ht->ySide == hd->ySide, status, HOUGHMAPH_ESZMM, HOUGHMAPH_MSGESZMM);
00467   /* -------------------------------------------   */
00468 
00469   /* number of physical pixels */
00470   xSide = ht->xSide;
00471   ySide = ht->ySide;
00472 
00473   /* To construct the Hough map from the derivative, 
00474      the latter must be integrated row-wise (x direction) */
00475 
00476   /* Loop on the rows */
00477   for (j=0; j< ySide; ++j){
00478     accumulator = 0;
00479     for ( i=0; i<xSide; ++i){
00480       ht->map[j*xSide +i] = ( accumulator += hd->map[j*(xSide+1) +i]);
00481     }
00482   }
00483 
00484 
00485 
00486   /* -------------------------------------------   */
00487   
00488   DETATCHSTATUSPTR (status);
00489   
00490   /* normal exit */
00491   RETURN (status);
00492 }
00493 
00494 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
00495 /* *******************************  <lalVerbatim file="HoughMapD"> */
00496 /**  Find source sky location given stereographic coordinates indexes */
00497 void LALStereo2SkyLocation (LALStatus  *status,
00498          REAL8UnitPolarCoor *sourceLocation, /* output*/
00499          UINT2              xPos,
00500          UINT2              yPos,
00501          HOUGHPatchGrid    *patch,
00502          HOUGHDemodPar     *parDem)
00503 {  /*   *********************************************  </lalVerbatim> */
00504     
00505   REAL8Cart2Coor        sourceProjected;
00506   REAL8UnitPolarCoor    sourceRotated;
00507   REAL8UnitPolarCoor    skyPatchCenter;
00508   /* --------------------------------------------- */
00509   INITSTATUS (status, "Stereo2SkyLocation", HOUGHMAPH);
00510   ATTATCHSTATUSPTR (status);
00511 
00512   ASSERT (sourceLocation, status, HOUGHMAPH_ENULL,HOUGHMAPH_MSGENULL);
00513   ASSERT (patch , status, HOUGHMAPH_ENULL,HOUGHMAPH_MSGENULL);
00514   ASSERT (parDem, status, HOUGHMAPH_ENULL,HOUGHMAPH_MSGENULL);
00515 
00516   sourceProjected.x = patch->xCoor[xPos];
00517   sourceProjected.y = patch->yCoor[yPos];
00518 
00519   skyPatchCenter.alpha = parDem->skyPatch.alpha;
00520   skyPatchCenter.delta = parDem->skyPatch.delta;
00521   
00522   /* invert the stereographic projection for a point on the projected plane */
00523   TRY( LALStereoInvProjectCart( status->statusPtr, 
00524                                 &sourceRotated, &sourceProjected ), status );
00525   
00526   /* undo roation in case the patch is not centered at the south pole */
00527   TRY( LALInvRotatePolarU( status->statusPtr,
00528        sourceLocation, &sourceRotated, &skyPatchCenter ), status );
00529 
00530   DETATCHSTATUSPTR (status);
00531   /* normal exit */
00532   RETURN (status);
00533 }

Generated on Tue Oct 7 02:39:51 2008 for LAL by  doxygen 1.5.2