LALApps 10.1.0.1-eeff03c
exc_resp.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Duncan Brown, Jolien Creighton, Patrick Brady
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20#include <config.h>
21#include <math.h>
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25#include <LALAppsVCSInfo.h>
26#include <lal/LALStdlib.h>
27#include <lal/LALConstants.h>
28#include <lal/LALgetopt.h>
29
30/* Calibration Constants for L1:LSC-ETMX */
31/* Based on mail from Gaby Mon, 24 Jun 2002 */
32/* #define L1_DC_RESP 2.63 */ /* nm/count */
33/* Based on e-log entry http://www.ligo-la.caltech.edu/ilog/pub/ilog.cgi?group=detector&date_to_view=02/01/2003&anchor_to_scroll_to=2003:02:02:00:28:03-brian */
34#define L1_DC_RESP 0.39 /* +/- 0.02 (nm/ct) */
35#define L1_PEND_F0 0.76 /* Hz */
36#define L1_LENGTH 4000 /* m */
37
38/* Calibration constants for H2:LSC-ETMX */
39/* Based on E7 calibration web page */
40/* #define H2_DC_RESP 1.33 */ /* nm/count */
41/* Based on e-mail from Mike Landry Wed, 12 Feb 2003 11:21:12 -0800 */
42#define H2_DC_RESP 1.05 /* nm/count */
43#define H2_PEND_F0 0.74 /* Hz */
44#define H2_LENGTH 2000 /* m */
45
46/* Calibration constants for H1:LSC-ETMX */
47/* Based on e-mail from Mike Landry Wed, 12 Feb 2003 11:21:12 -0800 */
48#define H1_DC_RESP 0.93 /* nm/count */
49#define H1_PEND_F0 0.74 /* Hz */
50#define H1_LENGTH 4000 /* m */
51
52#define usgfmt \
53"Usage: %s [options]\n"\
54"Options [default in brackets]:\n"\
55" -h print this message\n"\
56" -V print version info\n"\
57" -v verbose\n"\
58" -L flow low frequency cutoff for response function [25.0]\n"\
59" -H fhigh high frequency cutoff for response function [3000.0]\n"\
60" -n numpoints number of points in response function [8192]\n"
61
62#define usage( program ) fprintf( stderr, usgfmt, program )
63
64extern int vrbflg;
65
66int main ( int argc, char *argv[] )
67{
68 const char *program = argv[0];
69 int k;
70 int opt;
71 int numpts = 8192;
72 REAL4 f_min = 25.0;
73 REAL4 f_max = 3000.0;
74 REAL4 df;
75 FILE *l1_fp = NULL, *h2_fp = NULL, *h1_fp = NULL;
76
77 /* parse options */
78 while ( 0 < ( opt = LALgetopt( argc, argv, "hVvL:H:n:" ) ) )
79 {
80 switch ( opt )
81 {
82 case 'h':
83 usage( program );
84 return 0;
85 case 'V':
86 XLALOutputVCSInfo(stderr, lalAppsVCSInfoList, 0, "%% ");
87 return 0;
88 case 'v':
89 vrbflg = 1;
90 break;
91 case 'L':
92 f_min = (REAL4) atof(LALoptarg);
93 break;
94 case 'H':
95 f_max = (REAL4) atof(LALoptarg);
96 break;
97 case 'n':
98 numpts = atoi(LALoptarg);
99 break;
100 default:
101 usage( program );
102 return 1;
103 }
104 }
105 if ( LALoptind < argc )
106 {
107 usage( program );
108 return 1;
109 }
110
111 df = (f_max - f_min) / ( (REAL4) numpts );
112
113 l1_fp = fopen( "L1:LSC-ETMX_response", "w" );
114 h2_fp = fopen( "H2:LSC-ETMX_response", "w" );
115 h1_fp = fopen( "H1:LSC-ETMX_response", "w" );
116 if ( !l1_fp || !h2_fp || !h1_fp )
117 {
118 fprintf( stderr, "error opening response function files for writing\n" );
119 return 1;
120 }
121
122 fprintf( l1_fp, "# epoch = %lli\n", 0LL );
123 fprintf( l1_fp, "# f0 = %e\n", (REAL8) f_min );
124 fprintf( l1_fp, "# deltaF = %e\n", (REAL8) df );
125 fprintf( h2_fp, "# epoch = %lli\n", 0LL );
126 fprintf( h2_fp, "# f0 = %e\n", (REAL8) f_min );
127 fprintf( h2_fp, "# deltaF = %e\n", (REAL8) df );
128 fprintf( h1_fp, "# epoch = %lli\n", 0LL );
129 fprintf( h1_fp, "# f0 = %e\n", (REAL8) f_min );
130 fprintf( h1_fp, "# deltaF = %e\n", (REAL8) df );
131
132 for ( k = 0; k < numpts; ++k )
133 {
134 REAL4 f = f_min + (REAL4) k * df;
135 REAL4 l1_r = ( L1_PEND_F0 * L1_PEND_F0 * L1_DC_RESP * 1e-9 ) /
136 ( L1_LENGTH * f * f );
137 REAL4 h2_r = ( H2_PEND_F0 * H2_PEND_F0 * H2_DC_RESP * 1e-9 ) /
138 ( H2_LENGTH * f * f );
139 REAL4 h1_r = ( H1_PEND_F0 * H1_PEND_F0 * H1_DC_RESP * 1e-9 ) /
140 ( H1_LENGTH * f * f );
141 fprintf( l1_fp, "%e %e\n", l1_r, 0.0 );
142 fprintf( h2_fp, "%e %e\n", h2_r, 0.0 );
143 fprintf( h1_fp, "%e %e\n", h1_r, 0.0 );
144 }
145
146 fclose( l1_fp );
147 fclose( h2_fp );
148 fclose( h1_fp );
149
150 return 0;
151}
const char * program
const LALVCSInfoList lalAppsVCSInfoList
NULL-terminated list of VCS and build information for LALApps and its dependencies
int k
int LALgetopt(int argc, char *const *argv, const char *optstring)
int LALoptind
char * LALoptarg
#define fprintf
double e
#define L1_LENGTH
Definition: exc_resp.c:36
int main(int argc, char *argv[])
Definition: exc_resp.c:66
#define H1_LENGTH
Definition: exc_resp.c:50
#define L1_DC_RESP
Definition: exc_resp.c:34
#define H2_LENGTH
Definition: exc_resp.c:44
#define H1_DC_RESP
Definition: exc_resp.c:48
#define H2_DC_RESP
Definition: exc_resp.c:42
#define H2_PEND_F0
Definition: exc_resp.c:43
#define usage(program)
Definition: exc_resp.c:62
#define H1_PEND_F0
Definition: exc_resp.c:49
int vrbflg
#define L1_PEND_F0
Definition: exc_resp.c:35
double REAL8
float REAL4
int XLALOutputVCSInfo(FILE *fp, const LALVCSInfoList vcs_list, const int verbose, const char *prefix)
f
double f_min
double f_max
double df