FitToPulsarTest.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Jolien Creighton
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 /************************************ <lalVerbatim file="FitToPulsarCV">
00021 Author: Dupuis, R. J.
00022 $Id: FitToPulsarTest.c,v 1.4 2007/06/08 14:41:52 bema Exp $  
00023 ************************************* </lalVerbatim> */
00024 
00025 /********************************************************** <lalLaTeX>
00026 \subsection{Module \texttt{FitToPulsar.c}}
00027 Calculates the best fit parameters for a GW signal originating from a
00028 non-precessing pulsar.
00029 
00030 \subsubsection*{Prototypes}
00031 \idx{LALCoarseFitToPulsar()}
00032 \idx{LALFineFitToPulsar}
00033 \input{FitToPulsarCP}
00034 \begin{verbatim}
00035 void
00036 LALFineFitToPulsar      (            LALStatus            *status,
00037                                 FineFitOutput        *output,
00038                                 FineFitInput         *input,
00039                                 FineFitParams        *params )
00040 \end{verbatim}
00041 
00042 \subsubsection*{Description}
00043 
00044 This routine calculates the best fit of parameters by minimizing $\chi^2$ by going through 
00045 fixed grid for $\iota, \psi, \phi_{0}$ and  $h_{0}$.  The best fit parameters 
00046 returned by \texttt{LALCoarseFitToPulsar()} are then used as initial parameters for 
00047 \texttt{LALFineFitToPulsar()}.
00048 
00049 The function \texttt{LALFineFitToPulsar()} refines the fit using the Levenberg-Marquardt method for nonlinear fitting. This is
00050 done by calculating the Hessian and the gradient of $\chi^2$ ...
00051 
00052 \subsubsection*{Algorithm}
00053 To be completed.
00054 
00055 \subsubsection*{Uses}
00056 \begin{verbatim}
00057 LALSCreateVector()
00058 LALSDestroyVector()
00059 LALComputeDetAMResponse()
00060 \end{verbatim}
00061 
00062 \subsubsection*{Notes}
00063 
00064 \vfill{\footnotesize\input{FitToPulsarCV}}
00065 
00066 ******************************************************* </lalLaTeX> */ 
00067 
00068 /******* INCLUDE STANDARD LIBRARY HEADERS; ************/
00069 /* note LALStdLib.h already includes stdio.h and stdarg.h */
00070 #include <math.h>
00071 
00072 /******* INCLUDE ANY LDAS LIBRARY HEADERS ************/
00073 
00074 /******* INCLUDE ANY LAL HEADERS ************/
00075 #include <lal/LALStdlib.h>
00076 #include <lal/FitToPulsar.h>
00077 
00078 /******* DEFINE RCS ID STRING ************/
00079 NRCSID( FITTOPULSARC, "$Id: FitToPulsarTest.c,v 1.4 2007/06/08 14:41:52 bema Exp $" );
00080 
00081 /******* DEFINE LOCAL CONSTANTS AND MACROS ************/
00082 #define INICHISQU 1.e50
00083 #define INIMAXEH 0
00084 #define INIMINEH 1e10
00085 
00086 /******* DECLARE LOCAL (static) FUNCTIONS ************/
00087 /* (definitions can go here or at the end of the file) */
00088 
00089 /******* DEFINE GLOBAL FUNCTIONS ************/
00090 
00091 /* <lalVerbatim file="FitToPulsarCP"> */
00092 void
00093 LALCoarseFitToPulsar    (       LALStatus            *status,
00094                                 CoarseFitOutput      *output,
00095                                 CoarseFitInput       *input,
00096                                 CoarseFitParams      *params )
00097                 
00098 /* </lalVerbatim> */
00099 {
00100   /******* DECLARE VARIABLES ************/
00101 
00102         UINT4                   n,i;            /* integer indices */
00103         REAL8                   psi;
00104         REAL8                   h0,h;
00105         REAL8                   cosIota;
00106         REAL8                   phase;
00107         REAL8                   chiSquare;
00108         LALDetector             detector;
00109         LALSource               pulsar;
00110         LALDetAndSource         detAndSource;
00111         LALDetAMResponse        computedResponse;
00112         REAL4Vector             *Fp, *Fc;       /* pointers to amplitude responses of the detector */
00113         REAL8Vector             *var;
00114         REAL8                   cos2phase,sin2phase;
00115         COMPLEX16               Xp, Xc;
00116         REAL8                   Y, cosIota2;
00117         COMPLEX16               A,B;
00118         REAL8                   sumAA, sumBB, sumAB;    
00119         REAL8                   h0BestFit=0,phaseBestFit=0, psiBestFit=0, cosIotaBestFit=0;
00120         REAL8                   minChiSquare;
00121         COMPLEX16               eh0;
00122         REAL8 oldMinEh0, oldMaxEh0, weh0;
00123         UINT4                   iH0, iCosIota, iPhase, iPsi, arg;
00124         LALGPSandAcc            pGPSandAcc;
00125         
00126         
00127   INITSTATUS(status, "LALCoarseFitToPulsar", FITTOPULSARC);
00128   ATTATCHSTATUSPTR(status);
00129 
00130   /******* CHECK VALIDITY OF ARGUMENTS  ************/    
00131   ASSERT(output != (CoarseFitOutput *)NULL, status,
00132          FITTOPULSARH_ENULLOUTPUT, FITTOPULSARH_MSGENULLOUTPUT);         
00133 
00134   ASSERT(params != (CoarseFitParams *)NULL, status,
00135          FITTOPULSARH_ENULLPARAMS, FITTOPULSARH_MSGENULLPARAMS);
00136          
00137   ASSERT(input != (CoarseFitInput *)NULL, status,
00138          FITTOPULSARH_ENULLINPUT, FITTOPULSARH_MSGENULLINPUT);
00139 
00140   ASSERT(input->B->length == input->var->length, status, 
00141   FITTOPULSARH_EVECSIZE , FITTOPULSARH_MSGEVECSIZE );
00142 
00143   /******* EXTRACT INPUTS AND PARAMETERS ************/
00144 
00145   n = input->B->length;
00146 
00147   for (i = 0; i < n; i++)
00148      ASSERT(input->var->data[i].re > 0.0 && input->var->data[i].im > 0.0, status,
00149          FITTOPULSARH_EVAR, FITTOPULSARH_MSGEVAR);
00150 
00151   detector = params->detector;
00152   detAndSource.pDetector = &detector;
00153 
00154   pulsar = params->pulsarSrc;
00155 
00156   /******* ALLOCATE MEMORY TO VECTORS **************/
00157 
00158   Fp = NULL;
00159   LALSCreateVector(status->statusPtr, &Fp, n);
00160   Fp->length = n;
00161 
00162   Fc = NULL;
00163   LALSCreateVector(status->statusPtr, &Fc, n);
00164   Fc->length = n;
00165 
00166   var = NULL;
00167   LALDCreateVector(status->statusPtr, &var, n);
00168   var->length = n; 
00169   /******* INITIALIZE VARIABLES *******************/
00170 
00171   minChiSquare = INICHISQU;
00172   oldMaxEh0 = INIMAXEH;
00173   oldMinEh0 = INIMINEH;
00174 
00175 
00176   for (i=0;i<n;i++)
00177   {  
00178     var->data[i] = input->var->data[i].re + input->var->data[i].im;
00179   }
00180   /******* DO ANALYSIS ************/
00181 
00182   for (iPsi = 0; iPsi < params->meshPsi[2]; iPsi++)
00183   {
00184     psi = params->meshPsi[0] + iPsi*params->meshPsi[1];
00185     pulsar.orientation = psi;
00186     detAndSource.pSource = &pulsar;
00187 
00188     pGPSandAcc.accuracy = 1.0; 
00189    /* create vectors containing amplitude response of detector for specified times */ 
00190    for (i=0;i<n;i++)
00191    {     
00192      pGPSandAcc.gps =   input->t[i];
00193      LALComputeDetAMResponse(status->statusPtr, &computedResponse,&detAndSource, &pGPSandAcc);
00194      Fp->data[i] = (REAL8)computedResponse.plus;
00195      Fc->data[i] = (REAL8)computedResponse.cross;
00196    }
00197 
00198    for (iPhase = 0; iPhase < params->meshPhase[2]; iPhase++)
00199    {   
00200      phase = params->meshPhase[0] + iPhase*params->meshPhase[1];
00201      cos2phase = cos(2.0*phase);
00202      sin2phase = sin(2.0*phase);
00203      for (iCosIota = 0; iCosIota < params->meshCosIota[2]; iCosIota++)
00204      {
00205        cosIota = params->meshCosIota[0] + iCosIota*params->meshCosIota[1];
00206        cosIota2 = 1.0 + cosIota*cosIota; 
00207        Xp.re = cosIota2 * cos2phase;
00208        Xp.im = cosIota2 * sin2phase;
00209 
00210        Y = 2.0*cosIota;
00211                 
00212        Xc.re = Y*sin2phase;
00213        Xc.im = -Y*cos2phase; 
00214           
00215        sumAB = 0.0;
00216        sumAA = 0.0;
00217        sumBB = 0.0;
00218        eh0.re=0.0;
00219        eh0.im=0.0;
00220 
00221        for (i = 0; i < n; i++)
00222        {
00223          B.re = input->B->data[i].re;
00224          B.im = input->B->data[i].im;
00225             
00226          A.re = Fp->data[i]*Xp.re + Fc->data[i]*Xc.re;
00227          A.im = Fp->data[i]*Xp.im + Fc->data[i]*Xc.im;  
00228         
00229          sumBB += (B.re*B.re + B.im*B.im) / var->data[i];
00230          sumAA += (A.re*A.re + A.im*A.im) / var->data[i];   
00231          sumAB += (B.re*A.re + B.im*A.im) / var->data[i];
00232           
00233          /**** calculate error on h0 **********/
00234          eh0.re += (Fp->data[i]*cosIota2*cos2phase
00235                 + 2.0*Fc->data[i]*cosIota*sin2phase) 
00236                 * (Fp->data[i]*cosIota2*cos2phase
00237                 + 2.0*Fc->data[i]*cosIota*sin2phase) / input->var->data[i].re;
00238            
00239          eh0.im += (Fp->data[i]*cosIota2*sin2phase
00240                 - 2.0*Fc->data[i]*cosIota*cos2phase)
00241                 * (Fp->data[i]*cosIota2*sin2phase
00242                 - 2.0*Fc->data[i]*cosIota*cos2phase) / input->var->data[i].im;    
00243         }
00244 
00245         for (iH0 = 0; iH0 < params->meshH0[2]; iH0++)
00246         {
00247           h0 = params->meshH0[0] + iH0*params->meshH0[1];
00248           chiSquare = sumBB - 2.0*h0*sumAB + h0*h0*sumAA;
00249         
00250           if (chiSquare<minChiSquare)
00251           {
00252             minChiSquare = chiSquare;
00253             h0BestFit = h0;
00254             cosIotaBestFit = cosIota;
00255             psiBestFit = psi;
00256             phaseBestFit = phase;
00257             output->eh0[0] = 1.0 /sqrt(sqrt(eh0.re*eh0.re + eh0.im*eh0.im));
00258           }
00259            
00260           weh0 = 1.0 /sqrt(sqrt(eh0.re*eh0.re + eh0.im*eh0.im));
00261         
00262           if (weh0>oldMaxEh0)
00263           {
00264             output->eh0[2] = weh0;
00265             oldMaxEh0 = weh0;
00266           }
00267         
00268           if (weh0<oldMinEh0)
00269           {
00270             output->eh0[1] = weh0;
00271             oldMinEh0 = weh0;
00272           }
00273           arg = iH0 + params->meshH0[2]*(iCosIota +  params->meshCosIota[2]*(iPhase + params->meshPhase[2]*iPsi));
00274           output->mChiSquare->data[arg] = chiSquare;
00275         }
00276       }  
00277     }
00278   }
00279 
00280   /******* CONSTRUCT OUTPUT ************/
00281 
00282   output->h0 = h0BestFit;
00283   output->cosIota = cosIotaBestFit;
00284   output->phase = phaseBestFit;
00285   output->psi = psiBestFit;
00286   output->chiSquare = minChiSquare;
00287 
00288 
00289   ASSERT(minChiSquare < INICHISQU,  status,
00290   FITTOPULSARH_EMAXCHI , FITTOPULSARH_MSGEMAXCHI); 
00291 
00292   LALSDestroyVector(status->statusPtr, &Fp);
00293   LALSDestroyVector(status->statusPtr, &Fc);
00294   LALDDestroyVector(status->statusPtr, &var);
00295   DETATCHSTATUSPTR(status);
00296   RETURN(status);
00297 
00298 
00299 }
00300 /******************************** <lalVerbatim file="FitToPulsarTestCV">
00301 Author: Dupuis, R.J.
00302 $Id: FitToPulsarTest.c,v 1.4 2007/06/08 14:41:52 bema Exp $
00303 ********************************* </lalVerbatim> */
00304 
00305 /********************************************************** <lalLaTeX>
00306 \subsection{Program \texttt{FitToPulsarTest.c}}
00307 
00308 This test program demonstrates the correct usage of the functions
00309 \texttt{LALCoarseFitToPulsar} and \texttt{LALFineFitToPulsar}.
00310 
00311 \subsubsection*{Usage}
00312 \begin{verbatim}
00313 FitToPulsarTest
00314 \end{verbatim}
00315 
00316 \subsubsection*{Description}
00317 To be completed.
00318 \subsubsection*{Exit codes}
00319 \input{FitToPulsarTestCE}
00320 
00321 \subsubsection*{Uses}
00322 \begin{verbatim}
00323 LALCoarseFitToPulsar()
00324 LALFineFitToPulsar()
00325 \end{verbatim}
00326 
00327 \subsubsection*{Notes}
00328 
00329 \vfill{\footnotesize\input{FitToPulsarCV}}
00330 ******************************************************* </lalLaTeX> */
00331 
00332 /******* INCLUDE STANDARD LIBRARY HEADERS; ************/
00333 /* note LALStdLib.h already includes stdio.h and stdarg.h */
00334 
00335 /******* INCLUDE ANY LDAS LIBRARY HEADERS ************/
00336 
00337 /******* INCLUDE ANY LAL HEADERS ************/
00338 #include <lal/FitToPulsar.h>
00339 #include <lal/Random.h>
00340 
00341 /******* DEFINE RCS ID STRING ************/
00342 
00343 NRCSID( FitToPulsarTestC, "$Id: FitToPulsarTest.c,v 1.4 2007/06/08 14:41:52 bema Exp $" );
00344 
00345 /******* DEFINE LOCAL CONSTANTS AND MACROS ************/
00346 
00347 /***************************** <lalErrTable file="FitToPulsarTestCE"> */
00348 #define FITTOPULSARTESTC_ENOM 0
00349 #define FITTOPULSARTESTC_ECHK 1
00350 #define FITTOPULSARTESTC_EFLS 2
00351 
00352 #define FITTOPULSARTESTC_MSGENOM "Nominal exit"
00353 #define FITTOPULSARTESTC_MSGECHK "Error checking failed to catch bad data"
00354 #define FITTOPULSARTESTC_MSGEFLS "Incorrect answer for valid data"
00355 /***************************** </lalErrTable> */
00356 
00357 /* might also wish to define parameters and expected results for test
00358    cases here, for example */
00359 
00360 #define FITTOPULSARTEST_LENGTH 24*10
00361 #define FITTOPULSARTEST_T0 630720013  /* Jan 1, 2000, 00:00:00 */
00362 
00363 /* int lalDebugLevel = LALMSGLVL1; */
00364 int lalDebugLevel = 0;
00365 int main(void)
00366 {
00367   static LALStatus      status;
00368   LALDetector           detector;
00369   LALSource             pulsar;
00370   CoarseFitOutput       output;
00371   CoarseFitInput        input;
00372   CoarseFitParams       params;
00373   LIGOTimeGPS           tgps[FITTOPULSARTEST_LENGTH];
00374   REAL4                 cosIota;
00375   REAL4                 phase;
00376   REAL4                 psi;
00377   REAL4                 h0;
00378   REAL4                 cos2phase, sin2phase;
00379   static RandomParams   *randomParams;
00380   static REAL4Vector    *noise;
00381   INT4                  seed = 0;
00382   LALDetAndSource       detAndSource;
00383   LALDetAMResponseSeries        pResponseSeries = {NULL,NULL,NULL};
00384   REAL4TimeSeries               Fp, Fc, Fs;
00385   LALTimeIntervalAndNSample     time_info;
00386   UINT4                         i;
00387   LALGPSandAcc          pGPSandAcc;
00388 
00389 
00390 
00391   /* Allocate memory */
00392   input.B = NULL;
00393   input.var = NULL;
00394 
00395   LALZCreateVector( &status, &input.B, FITTOPULSARTEST_LENGTH);
00396   LALZCreateVector( &status, &input.var, FITTOPULSARTEST_LENGTH);
00397 
00398   noise = NULL;
00399   LALCreateVector( &status, &noise, FITTOPULSARTEST_LENGTH);
00400   LALCreateRandomParams( &status, &randomParams, seed);
00401 
00402   Fp.data = NULL;
00403   Fc.data = NULL;
00404   Fs.data = NULL;
00405 
00406   pResponseSeries.pPlus   = &(Fp);
00407   pResponseSeries.pCross  = &(Fc);
00408   pResponseSeries.pScalar = &(Fs);
00409 
00410   LALSCreateVector(&status, &(pResponseSeries.pPlus->data), 1);
00411   LALSCreateVector(&status, &(pResponseSeries.pCross->data), 1);
00412   LALSCreateVector(&status, &(pResponseSeries.pScalar->data), 1);
00413 
00414   input.t = tgps;
00415   /******** GENERATE FAKE INPUT **********/
00416 
00417   time_info.epoch.gpsSeconds     = FITTOPULSARTEST_T0;
00418   time_info.epoch.gpsNanoSeconds = 0;
00419   time_info.deltaT               = 60;
00420   time_info.nSample              = FITTOPULSARTEST_LENGTH;
00421   time_info.accuracy              = 1.0;  /*tmp*/
00422 
00423   cosIota = 0.5;
00424   psi = 0.1;
00425   phase = 0.4;
00426   h0 = 5.0;
00427 
00428   cos2phase = cos(2.0*phase);
00429   sin2phase = sin(2.0*phase); 
00430 
00431   detector = lalCachedDetectors[LALDetectorIndexGEO600DIFF];     /* use GEO 600 detector for tests */
00432   pulsar.equatorialCoords.longitude = 1.4653;                   /* right ascention of pulsar */
00433   pulsar.equatorialCoords.latitude = -1.2095;                   /* declination of pulsar */
00434   pulsar.equatorialCoords.system = COORDINATESYSTEM_EQUATORIAL; /* coordinate system */
00435   pulsar.orientation = psi;                                     /* polarization angle */
00436   strcpy(pulsar.name, "fakepulsar");                            /* name of pulsar */
00437 
00438   detAndSource.pDetector = &detector;
00439   detAndSource.pSource = &pulsar;
00440 
00441   LALNormalDeviates( &status, noise, randomParams ); 
00442 
00443   LALComputeDetAMResponseSeries(&status, &pResponseSeries, &detAndSource, &time_info);
00444 
00445   for (i = 0;i < FITTOPULSARTEST_LENGTH; i++)
00446   {
00447     input.t[i].gpsSeconds = FITTOPULSARTEST_T0 + 60*i;
00448     input.t[i].gpsNanoSeconds = 0;
00449 
00450     input.B->data[i].re =  pResponseSeries.pPlus->data->data[i]*h0*(1.0 + cosIota*cosIota)*cos2phase
00451                          + 2.0*pResponseSeries.pCross->data->data[i]*h0*cosIota*sin2phase;
00452     input.B->data[i].im =  pResponseSeries.pPlus->data->data[i]*h0*(1.0 + cosIota*cosIota)*sin2phase
00453                          - 2.0*pResponseSeries.pCross->data->data[i]*h0*cosIota*cos2phase;                   
00454     input.var->data[i].re = noise->data[FITTOPULSARTEST_LENGTH-i-1]*noise->data[FITTOPULSARTEST_LENGTH-i-1];
00455     input.var->data[i].im = noise->data[i]*noise->data[i];
00456   }
00457 
00458   input.B->length = FITTOPULSARTEST_LENGTH;
00459   input.var->length = FITTOPULSARTEST_LENGTH;  
00460 
00461   /*******  TEST RESPONSE TO VALID DATA  ************/
00462 /* Test that valid data generate the correct answers */
00463   params.detector = detector;
00464   params.pulsarSrc = pulsar;
00465 
00466   params.meshH0[0] = 4.0;
00467   params.meshH0[1] = 0.2;
00468   params.meshH0[2] = 10;
00469 
00470   params.meshCosIota[0] = 0.0;
00471   params.meshCosIota[1] =  0.1;
00472   params.meshCosIota[2] =  10;
00473 
00474   params.meshPhase[0] = 0.0;
00475   params.meshPhase[1] = 0.1;
00476   params.meshPhase[2] = 10;
00477 
00478   params.meshPsi[0] =  0.0;
00479   params.meshPsi[1] =  0.1;
00480   params.meshPsi[2] =  10;
00481 
00482   output.mChiSquare = NULL;
00483   LALDCreateVector( &status, &output.mChiSquare,params.meshH0[2]*params.meshCosIota[2]*params.meshPhase[2]*params.meshPsi[2]);
00484 
00485 
00486   LALCoarseFitToPulsar(&status,&output, &input, &params);
00487 
00488   if(status.statusCode) 
00489   {
00490     printf("Unexpectedly got error code %d and message %s\n",
00491             status.statusCode, status.statusDescription);
00492     return FITTOPULSARTESTC_EFLS;
00493   }
00494 
00495 
00496   if(output.phase > phase + params.meshPhase[2] || output.phase < phase - params.meshPhase[2])
00497   {
00498     printf("Got incorrect phase %f when expecting %f \n",
00499             output.phase, phase);
00500     return FITTOPULSARTESTC_EFLS;
00501   }
00502 
00503   if(output.cosIota > cosIota + params.meshCosIota[2] || output.cosIota < cosIota - params.meshCosIota[2])
00504   {
00505     printf("Got incorrect cosIota %f when expecting %f \n",
00506             output.cosIota, cosIota);
00507     return FITTOPULSARTESTC_EFLS;
00508   }
00509 
00510     if(output.psi > psi + params.meshPsi[2] || output.psi < psi - params.meshPsi[2])
00511   {
00512     printf("Got incorrect psi %f when expecting %f \n",
00513             output.psi, psi);
00514     return FITTOPULSARTESTC_EFLS;
00515   }
00516 
00517   /*******  TEST RESPONSE OF LALCoarseFitToPulsar TO INVALID DATA  ************/
00518 
00519 #ifndef LAL_NDEBUG
00520 if ( ! lalNoDebug ) {
00521 
00522  /* Test that all the error conditions are correctly detected by the function */
00523 
00524  LALCoarseFitToPulsar(&status, NULL, &input, &params);
00525 
00526   if (status.statusCode != FITTOPULSARH_ENULLOUTPUT
00527        || strcmp(status.statusDescription, FITTOPULSARH_MSGENULLOUTPUT)) 
00528   {
00529     printf( "Got error code %d and message %s\n",
00530             status.statusCode, status.statusDescription);
00531     printf( "Expected error code %d and message %s\n",
00532             FITTOPULSARH_ENULLOUTPUT, FITTOPULSARH_MSGENULLOUTPUT);
00533     return FITTOPULSARTESTC_ECHK;
00534   }
00535 
00536  LALCoarseFitToPulsar(&status, &output, NULL, &params);
00537 
00538   if (status.statusCode != FITTOPULSARH_ENULLINPUT
00539        || strcmp(status.statusDescription, FITTOPULSARH_MSGENULLINPUT)) 
00540   {
00541     printf( "Got error code %d and message %s\n",
00542             status.statusCode, status.statusDescription);
00543     printf( "Expected error code %d and message %s\n",
00544             FITTOPULSARH_ENULLINPUT, FITTOPULSARH_MSGENULLINPUT);
00545     return FITTOPULSARTESTC_ECHK;
00546   }
00547 
00548  LALCoarseFitToPulsar(&status, &output, &input, NULL);
00549 
00550   if (status.statusCode != FITTOPULSARH_ENULLPARAMS
00551        || strcmp(status.statusDescription, FITTOPULSARH_MSGENULLPARAMS)) 
00552   {
00553     printf( "Got error code %d and message %s\n",
00554             status.statusCode, status.statusDescription);
00555     printf( "Expected error code %d and message %s\n",
00556             FITTOPULSARH_ENULLPARAMS, FITTOPULSARH_MSGENULLPARAMS);
00557     return FITTOPULSARTESTC_ECHK;
00558   }
00559 
00560   /* try having two input vectors of different length */
00561   input.var->length = 1;
00562   LALCoarseFitToPulsar(&status, &output, &input, &params);
00563 
00564   if (status.statusCode != FITTOPULSARH_EVECSIZE
00565        || strcmp(status.statusDescription, FITTOPULSARH_MSGEVECSIZE)) 
00566   {
00567     printf( "Got error code %d and message %s\n",
00568             status.statusCode, status.statusDescription);
00569     printf( "Expected error code %d and message %s\n",
00570             FITTOPULSARH_EVECSIZE, FITTOPULSARH_MSGEVECSIZE);
00571     return FITTOPULSARTESTC_ECHK;
00572   }
00573 
00574   input.var->length = FITTOPULSARTEST_LENGTH;
00575 
00576 } /* if ( ! lalNoDebug ) */
00577 #endif /* LAL_NDEBUG */
00578 
00579   /*******  CLEAN UP  ************/
00580 
00581   LALZDestroyVector(&status, &input.B);
00582   LALZDestroyVector(&status, &input.var); 
00583   LALDestroyVector(&status, &noise);  
00584   LALDDestroyVector(&status, &output.mChiSquare);
00585   LALDestroyRandomParams(&status, &randomParams);
00586   LALSDestroyVector(&status, &(pResponseSeries.pPlus->data));
00587   LALSDestroyVector(&status, &(pResponseSeries.pCross->data));
00588   LALSDestroyVector(&status, &(pResponseSeries.pScalar->data));  
00589 
00590   LALCheckMemoryLeaks();
00591 
00592   return FITTOPULSARTESTC_ENOM;
00593 }
00594 

Generated on Fri Sep 5 03:06:51 2008 for LAL by  doxygen 1.5.2