LAL  7.5.0.1-b72065a
NoisePSDTest.c
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2007 Bernd Machenschalk, David Churches, Duncan Brown, Jolien Creighton, B.S. Sathyaprakash
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 Sathyaprakash, B. S.
22  * \ingroup LALNoiseModels_h
23  * \file
24  *
25  * \brief This program can be used generate expected noise
26  * NoiseSpectralDensity in various interferometers.
27  *
28  * ### Synopsis ###
29  * This test code makes four
30  * successive calls to the function \c LALNoiseSpectralDensity()
31  * successively passing a pointer to the functions LALGEOPsd(),
32  * LALLIGOIPsd(), LALTAMAPsd() and LALVIRGOPsd().
33  * The function LALNoiseSpectralDensity() returns the power
34  * spectrum in units \f$\mathrm{Hz}^{-1}\f$ while the test code NoisePSDTest.c
35  * outputs the amplitude spectrum in units \f$\mathrm{Hz}^{-1/2}\f$ The figure
36  * below shows the output of the test code.
37  *
38  * \anchor NoisePSDTest
39  * \image html NoisePSDTest.png ""
40  *
41  * ### Uses ###
42  *
43  * \code
44  * LALDCreateVector
45  * LALNoiseSpectralDensity
46  * LALGEOPsd
47  * LALLIGOIPsd
48  * LALTAMAPsd
49  * LALVIRGOPsd
50  * LALAdvLIGOPsd
51  * LALDDestroyVector
52  * LALCheckMemoryLeaks
53  * \endcode
54  *
55  */
56 #include <lal/AVFactories.h>
57 #include <lal/LALNoiseModels.h>
58 
59 /** \cond DONT_DOXYGEN */
60 
61 /** \endcond */
62 
63 int main ( void )
64 {
65 
66  static LALStatus status;
67  REAL8Vector *psd=NULL;
68  REAL8 df;
69  INT4 i, length;
70  FILE *NoisePsdFile;
71 
72  fprintf(stderr, "This test code computes the amplitude spectrum \n");
73  fprintf(stderr, "of GEO, LIGO, VIRGO, TAMA and AdvLIGO and writes them in \n");
74  fprintf(stderr, "NoisePSDTest.out in a format suitable for \n");
75  fprintf(stderr, "display with xmgr/xgrace\n");
76 
77  if ( (NoisePsdFile = fopen("NoisePSDTest.out", "w")) == NULL)
78  {
79  fprintf(stderr, "Can't open output file\n");
80  exit(0);
81  }
82  df = 1.0;
83  length = 8193;
84 
85  LALDCreateVector(&status, &psd, length);
86  fprintf(stderr, "Length of vector=%d\n", psd->length);
87 
89 
90  for (i=2; i<length; i++) {
91  if (psd->data[i]) fprintf (NoisePsdFile, "%d %e\n", i, sqrt(psd->data[i]));
92  }
93  fprintf(NoisePsdFile, "&\n");
95  for (i=2; i<length; i++) {
96  if (psd->data[i]) fprintf (NoisePsdFile, "%d %e\n", i, sqrt(psd->data[i]));
97  }
98  fprintf(NoisePsdFile, "&\n");
100  for (i=2; i<length; i++) {
101  if (psd->data[i]) fprintf (NoisePsdFile, "%d %e\n", i, sqrt(psd->data[i]));
102  }
103  fprintf(NoisePsdFile, "&\n");
105  for (i=2; i<length; i++) {
106  if (psd->data[i]) fprintf (NoisePsdFile, "%d %e\n", i, sqrt(psd->data[i]));
107  }
108  fprintf(NoisePsdFile, "&\n");
110  for (i=2; i<length; i++) {
111  if (psd->data[i]) fprintf (NoisePsdFile, "%d %e\n", i, sqrt(psd->data[i]));
112  }
113  LALDDestroyVector(&status, &psd);
115  return 0;
116 }
void LALCheckMemoryLeaks(void)
Definition: LALMalloc.c:784
int main(void)
Definition: NoisePSDTest.c:63
#define fprintf
double REAL8
Double precision real floating-point number (8 bytes).
int32_t INT4
Four-byte signed integer.
void LALTAMAPsd(LALStatus *status, REAL8 *shf, REAL8 x)
void LALAdvLIGOPsd(LALStatus UNUSED *status, REAL8 *psd, REAL8 f)
Module to calculate the noise power spectral density for the initial LIGO detector.
Definition: LALAdvLIGOPsd.c:50
void LALGEOPsd(LALStatus UNUSED *status, REAL8 *psd, REAL8 f)
Module to calculate the expected noise power spectral density for the GEO600 detector.
Definition: LALGEOPsd.c:52
void LALNoiseSpectralDensity(LALStatus *status, REAL8Vector *psd, void(*NoisePsd)(LALStatus *status, REAL8 *shf, REAL8 f), REAL8 f)
This function generates an array of size specified in the vector psd, that is psd....
void LALLIGOIPsd(LALStatus UNUSED *status, REAL8 *psd, REAL8 f)
Legacy LAL wrapper of XLALLIGOIPsd().
Definition: LALLIGOIPsd.c:65
void LALVIRGOPsd(LALStatus *status, REAL8 *shf, REAL8 x)
void LALDCreateVector(LALStatus *, REAL8Vector **, UINT4)
void LALDDestroyVector(LALStatus *, REAL8Vector **)
LAL status structure, see The LALStatus structure for more details.
Definition: LALDatatypes.h:947
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