bar_response.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 David Chin
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: David Chin <dwchin@umich.edu> +1-734-709-9119
00022  * $Id: bar_response.c,v 1.2 2007/06/08 15:29:43 bema Exp $
00023  */
00024 
00025 #include "config.h"
00026 
00027 #include <lal/DetectorSite.h>
00028 
00029 #include <lalapps.h>
00030 
00031 #include "set_source_params.h"
00032 #include "util.h"
00033 #include "skygrid.h"
00034 #include "make_gridding.h"
00035 
00036 #include <string.h>
00037 
00038 int lalDebugLevel = 0;
00039 int verbosity_level = 0;
00040 struct gengetopt_args_info args_info;
00041 
00042 int main(int argc, char **argv)
00043 {
00044   static LALStatus s;
00045   FILE            *cross = NULL;
00046   FILE            *plus  = NULL;
00047   LALGPSandAcc     time_info;
00048   EphemerisData    ephem;
00049   LALSource        source;
00050   LALFrDetector    frdetector;
00051   LALDetector      detector;
00052   LALDetAndSource  det_and_src = {NULL,NULL};
00053   LALDetAMResponse response;
00054   gridding_t       g;
00055   UINT4            i, j;
00056   UINT4            n_ra, n_dec;
00057   REAL8            src_orientation;
00058   
00059   if (argc != 7)
00060   {
00061     fprintf(stderr, "Error: need N_RA, N_DEC, bar longitude, bar latitude, bar azimuth, src orientation\n");
00062     exit(13);
00063   }
00064 
00065   /* 
00066    * Initializations
00067    */
00068   s.statusPtr = NULL;
00069   init_ephemeris(&s, &ephem);
00070   init_gridding(&g);
00071 
00072   n_ra = atoi(argv[1]);
00073   n_dec = atoi(argv[2]);
00074 
00075   cross = xfopen("bar_cross.txt","wo");
00076   plus  = xfopen("bar_plus.txt","wo");
00077 
00078   src_orientation = atof(argv[6]);
00079 
00080   /*
00081    * there are no cached bar detectors, so need to construct one
00082    */
00083   (void)mystrlcpy(frdetector.name, "FOOBAR", LALNameLength);
00084   frdetector.vertexLongitudeRadians = atof(argv[3]);
00085   frdetector.vertexLatitudeRadians  = atof(argv[4]);
00086   frdetector.vertexElevation        = 0.0; 
00087   frdetector.xArmAltitudeRadians    = 0.0;
00088   frdetector.xArmAzimuthRadians     = atof(argv[5]);
00089   frdetector.yArmAltitudeRadians    = 0.0;
00090   frdetector.yArmAzimuthRadians     = 0.0;
00091 
00092   LALCreateDetector(&s, &detector, &frdetector, LALDETECTORTYPE_CYLBAR);
00093 
00094   if (verbosity_level > 0)
00095   {
00096     PrintLALDetector(&detector);
00097     printf("\n\n");
00098   }
00099   
00100   /*
00101    * set up time and sampling
00102    */
00103   time_info.accuracy           = LALLEAPSEC_STRICT;
00104   time_info.gps.gpsSeconds     = 709398013;
00105   time_info.gps.gpsNanoSeconds =         0;
00106 
00107   make_gridding(&s, &g, n_ra, DETRESP_REGGRID, n_dec, DETRESP_REGGRID,
00108                 &ephem, &(time_info.gps), time_info.accuracy);
00109 
00110   print_ra_grid(&g, "bar_ra_grid.txt");
00111   print_dec_grid(&g, "bar_dec_grid.txt");
00112 
00113   for (i = 0; i < g.ra->length; ++i)
00114   {
00115     for (j = 0; j < g.dec->length; ++j)
00116     {
00117       /* 
00118        * set up source
00119        */
00120       set_source_params(&source, "BIGSTAR", g.ra->data[i],
00121                         g.dec->data[j], src_orientation);
00122       
00123       /* print_source(&source); */
00124     
00125       /*
00126        * set up input structures
00127        */
00128       det_and_src.pDetector = &detector;
00129       det_and_src.pSource   = &source;
00130     
00131       LALComputeDetAMResponse(&s, &response, &det_and_src, &time_info);
00132 
00133       if (verbosity_level > 0)
00134       {
00135         print_response(&response);
00136         printf("\n\n");
00137       }
00138 
00139       fprintf(cross, "%14e\t", response.cross);
00140       fprintf(plus, "%14e\t", response.plus);
00141     }
00142     fprintf(cross, "\n");
00143     fprintf(plus, "\n");
00144   }
00145 
00146   /*
00147    * housekeeping
00148    */
00149   fclose(cross);
00150   fclose(plus);
00151 
00152   cleanup_ephemeris(&s, &ephem);
00153   cleanup_gridding(&s, &g);
00154             
00155   LALCheckMemoryLeaks();
00156   
00157   return 0;
00158 }

Generated on Tue Oct 14 02:31:25 2008 for LAL by  doxygen 1.5.2