00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <unistd.h>
00021 #include <stdio.h>
00022 #include <string.h>
00023 #include <stdlib.h>
00024 #include <math.h>
00025 #include <glob.h>
00026 #include <lal/LALDatatypes.h>
00027 #include <lal/LALBarycenter.h>
00028 #include <lal/LALInitBarycenter.h>
00029 #include <lal/LALDemod.h>
00030
00031 #define MAXFILES 70000
00032 #define MAXFILENAMELENGTH 256
00033
00034 #define MAXLINESRS 4000000
00035 #define MAXLINESF 100000
00036
00037 struct CommandLineArgsTag
00038 {
00039 char *directory;
00040 char *caldirectory;
00041 char *run;
00042 char *IFO;
00043 char *outputdirectory;
00044 } CommandLineArgs;
00045
00046 struct headertag
00047 {
00048 REAL8 endian;
00049 INT4 gps_sec;
00050 INT4 gps_nsec;
00051 REAL8 tbase;
00052 INT4 firstfreqindex;
00053 INT4 nsamples;
00054 } header;
00055
00056 typedef struct ResponseFunctionTag
00057 {
00058 REAL4 Frequency[MAXLINESRS];
00059 REAL4 Magnitude[MAXLINESRS];
00060 REAL4 Phase[MAXLINESRS];
00061 REAL4 re[MAXLINESRS];
00062 REAL4 im[MAXLINESRS];
00063 } Response;
00064
00065 typedef struct SensingFunctionTag
00066 {
00067 REAL4 Frequency[MAXLINESRS];
00068 REAL4 Magnitude[MAXLINESRS];
00069 REAL4 Phase[MAXLINESRS];
00070 REAL4 re[MAXLINESRS];
00071 REAL4 im[MAXLINESRS];
00072 } Sensing;
00073
00074 struct FactorsTag
00075 {
00076 INT4 t[MAXLINESF];
00077 REAL4 alpha[MAXLINESF];
00078 REAL4 alpha_beta[MAXLINESF];
00079 } Factors;
00080
00081 int ReadCommandLine(int argc,char *argv[],struct CommandLineArgsTag *CLA);
00082 int ReadSFTDirectory(struct CommandLineArgsTag CLA);
00083 int ReadCalibrationFiles(struct CommandLineArgsTag CLA);
00084 int ComputeInitialRSFunctions(struct CommandLineArgsTag CLA);
00085 int CalibrateSfts(struct CommandLineArgsTag CLA);
00086 int Freemem();
00087
00088
00089 COMPLEX8 tmpa, tmpb, tmpc;
00090 REAL4 tmpx, tmpy;
00091
00092 #define cmul( a, b ) \
00093 ( tmpa = (a), tmpb = (b), \
00094 tmpc.re = tmpa.re * tmpb.re - tmpa.im * tmpb.im, \
00095 tmpc.im = tmpa.re * tmpb.im + tmpa.im * tmpb.re, \
00096 tmpc )
00097
00098 #define cdiv( a, b ) \
00099 ( tmpa = (a), tmpb = (b), \
00100 fabs( tmpb.re ) >= fabs( tmpb.im ) ? \
00101 ( tmpx = tmpb.im / tmpb.re, \
00102 tmpy = tmpb.re + tmpx * tmpb.im, \
00103 tmpc.re = ( tmpa.re + tmpx * tmpa.im ) / tmpy, \
00104 tmpc.im = ( tmpa.im - tmpx * tmpa.re ) / tmpy, \
00105 tmpc ) : \
00106 ( tmpx = tmpb.re / tmpb.im, \
00107 tmpy = tmpb.im + tmpx * tmpb.re, \
00108 tmpc.re = ( tmpa.re * tmpx + tmpa.im ) / tmpy, \
00109 tmpc.im = ( tmpa.im * tmpx - tmpa.re ) / tmpy, \
00110 tmpc ) )
00111