Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-00ddc7f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ComputeTransferTest.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Bernd Machenschalk, Jolien Creighton
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/*
21 * Author: Patrick R. Brady
22 */
23
24#include <stdio.h>
25#include <string.h>
26#include <lal/LALStdlib.h>
27#include <lal/PrintFTSeries.h>
28#include <lal/Calibration.h>
29
30#define TESTSTATUS( pstat ) \
31 if ( (pstat)->statusCode ) { REPORTSTATUS( pstat ); return 1; } \
32 else ((void)0)
33
34#define TESTSTATUSERR( pstat, code ) \
35 if ( (pstat)->statusCode != code ) { REPORTSTATUS( pstat ); return 1; } \
36 else ((void)0)
37
38const char *usage = "Usage: %s [options]\nOptions:\n"
39 "\t-h\t\tprint this message and exit\n"
40 "\t-d lvl\t\tset debug level to lvl\n"
41 "\t-v\t\tverbose output\n";
42
43
44int verbose = 0;
45const char *program;
46
47int main( int argc, char *argv[] )
48{
49 enum { TransferLength = 16384 };
50 const REAL8 df = 1.0;
51 static LALStatus status;
52 static CalibrationRecord calrec;
53 static LIGOTimeGPS now;
54 static LALUnit units;
55 REAL8 poles[] = { 0.3, 0.5 };
56 REAL8 zeros[] = { 0.1, 0.2, 0.4 };
57 REAL8Vector pvec;
58 REAL8Vector zvec;
59 COMPLEX8 fdata[TransferLength];
60 COMPLEX8Vector fvec;
62
63
64 /* initialization */
65 pvec.length = sizeof( poles ) / sizeof( *poles );
66 pvec.data = poles;
67 zvec.length = sizeof( zeros ) / sizeof( *zeros );
68 zvec.data = zeros;
69 fvec.length = sizeof( fdata ) / sizeof( *fdata );
70 fvec.data = fdata;
71 fser.epoch = now;
72 fser.f0 = 0;
73 fser.deltaF = df;
74 fser.data = &fvec;
75 fser.sampleUnits = units;
76 strncpy( fser.name, "transfer", sizeof( fser.name ) );
77
78 /* parse options */
79 program = *argv;
80 while ( ++argv && --argc > 0 )
81 {
82 if ( ! strcmp( *argv, "-d" ) )
83 {
84 --argc;
85 }
86 else if ( ! strcmp( *argv, "-v" ) )
87 {
88 verbose = 1;
89 }
90 else if ( ! strcmp( *argv, "-h" ) )
91 {
92 fprintf( stderr, usage, program );
93 return 0;
94 }
95 else
96 {
97 fprintf( stderr, "invalid option %s\n", *argv );
98 fprintf( stderr, usage, program );
99 }
100 }
101
102 calrec.type = CalibrationZPG;
103 calrec.zeros = &zvec;
104 calrec.poles = &pvec;
105 calrec.transfer = &fser;
106
107 /* check response to invalid input */
108 CalibrationRecord badcalrec;
109
110 LALComputeTransfer( &status, NULL );
112
113 badcalrec = calrec;
114 badcalrec.zeros = NULL;
115 LALComputeTransfer( &status, &badcalrec );
117
118 badcalrec = calrec;
119 badcalrec.poles = NULL;
120 LALComputeTransfer( &status, &badcalrec );
122
123 badcalrec = calrec;
124 badcalrec.transfer = NULL;
125 LALComputeTransfer( &status, &badcalrec );
127
128 fputs( "PASS: Test response to invalid data\n", stderr );
129
130 LALComputeTransfer( &status, &calrec );
131 TESTSTATUS( &status );
132 LALCPrintFrequencySeries( calrec.transfer, "transfer.out" );
133
134 fputs( "PASS: Test response to valid data\n", stderr );
135
137 fputs( "PASS: All tests\n", stderr );
138 return 0;
139}
const char * usage
int verbose
int main(int argc, char *argv[])
#define TESTSTATUS(pstat)
#define TESTSTATUSERR(pstat, code)
const char * program
void LALCheckMemoryLeaks(void)
Definition: LALMalloc.c:784
#define fprintf
#define CALIBRATIONH_ENULL
Null pointer.
Definition: Calibration.h:49
@ CalibrationZPG
Definition: Calibration.h:74
void LALComputeTransfer(LALStatus *status, CalibrationRecord *calrec)
UNDOCUMENTED.
double REAL8
Double precision real floating-point number (8 bytes).
float complex COMPLEX8
Single-precision floating-point complex number (8 bytes total)
void LALCPrintFrequencySeries(COMPLEX8FrequencySeries *series, const CHAR *filename)
See DATATYPE-FrequencySeries types for documentation.
Definition: LALDatatypes.h:899
CHAR name[LALNameLength]
Definition: LALDatatypes.h:900
COMPLEX8Sequence * data
Definition: LALDatatypes.h:905
Vector of type COMPLEX8, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:163
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:167
COMPLEX8 * data
Pointer to the data array.
Definition: LALDatatypes.h:168
UNDOCUMENTED.
Definition: Calibration.h:111
REAL8Vector * zeros
Definition: Calibration.h:122
COMPLEX8FrequencySeries * transfer
Definition: Calibration.h:121
REAL8Vector * poles
Definition: Calibration.h:123
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
This structure stores units in the mksA system (plus Kelvin, Strain, and ADC Count).
Definition: LALDatatypes.h:498
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
Definition: LALDatatypes.h:458
Vector of type REAL8, see DATATYPE-Vector types for more details.
Definition: LALDatatypes.h:154
REAL8 * data
Pointer to the data array.
Definition: LALDatatypes.h:159
UINT4 length
Number of elements in array.
Definition: LALDatatypes.h:158