24 #include <lal/LALConfig.h>
25 #ifndef LAL_FRAME_ENABLED
26 int main(
void ) {
return 77; }
28 #include <sys/types.h>
36 #include <lal/LALDatatypes.h>
37 #include <lal/LALStdlib.h>
38 #include <lal/LALStdio.h>
39 #include <lal/FileIO.h>
40 #include <lal/AVFactories.h>
41 #include <lal/LALCache.h>
42 #include <lal/LALFrStream.h>
44 #include <lal/PrintFTSeries.h>
45 #include <lal/Window.h>
46 #include <lal/Calibration.h>
48 #define MAXLINERS 76800
49 #define MAXLINESEGS 10000
51 struct CommandLineArgsTag {
65 struct SegmentListTag {
74 LALFrStream *framestream=NULL;
80 static FrChanIn chanin_darm;
81 static FrChanIn chanin_asq;
82 static FrChanIn chanin_exc;
91 SegmentList SL[MAXLINESEGS];
93 LALWindowParams winparams;
95 REAL4Vector *asqwin=NULL,*excwin=NULL,*darmwin=NULL;
98 int ReadCommandLine(
int argc,
char *argv[],
struct CommandLineArgsTag *CLA);
99 int ReadFiles(
struct CommandLineArgsTag CLA);
100 int GetChannelNames(
struct CommandLineArgsTag CLA);
107 int main(
int argc,
char *argv[])
112 if (ReadCommandLine(argc,argv,&CommandLineArgs))
return 1;
113 if (ReadFiles(CommandLineArgs))
return 3;
114 if (GetChannelNames(CommandLineArgs))
return 4;
116 for(i=0;i<numsegs;i++)
118 for(j=0;j<SL[i].nseg;j++)
120 REAL4 magexc, magdarm, magasq;
122 REAL8 t=SL[i].tgps+j*SL[i].seglength;
123 FloatToTime(&
epoch, &t);
126 LALFrGetPos(&
status,&pos,framestream);
128 LALFrGetREAL4TimeSeries(&
status,&exc,&chanin_exc,framestream);
129 LALFrSetPos(&
status,&pos,framestream);
131 LALFrGetREAL4TimeSeries(&
status,&darm,&chanin_darm,framestream);
132 LALFrSetPos(&
status,&pos,framestream);
134 LALFrGetREAL4TimeSeries(&
status,&asq,&chanin_asq,framestream);
135 LALFrSetPos(&
status,&pos,framestream);
138 for(k=0;k<(
INT4)(SL[i].seglength/asq.
deltaT +0.5);k++)
142 for(k=0;k<(
INT4)(SL[i].seglength/darm.
deltaT +0.5);k++)
144 darm.
data->
data[k] *= 2.0*darmwin->data[k];
146 for(k=0;k<(
INT4)(SL[i].seglength/exc.
deltaT +0.5);k++)
148 exc.
data->
data[k] *= 2.0*excwin->data[k];
156 params.outputMatrix = CommandLineArgs.k;
157 params.actuationFactor.re = Af0.re/4000.0;
158 params.actuationFactor.im = Af0.im/4000.0;
159 params.responseFactor = Rf0;
160 params.sensingFactor = Cf0;
164 magexc=sqrt(factors.
exc.re*factors.
exc.re+factors.
exc.im*factors.
exc.im)*2/SL[i].seglength;
165 magasq=sqrt(factors.
asq.re*factors.
asq.re+factors.
asq.im*factors.
asq.im)*2/SL[i].seglength;
166 magdarm=sqrt(factors.
darm.re*factors.
darm.re+factors.
darm.im*factors.
darm.im)*2/SL[i].seglength;
168 fprintf(stdout,
"%20.15f %20.15f %20.15f %20.15f %20.15f %20.15f %20.15f %20.15f\n",t,
170 factors.
alphabeta.im,magexc,magdarm,magasq);
177 if(FreeMem())
return 4;
185 REAL8 temp0, temp2, temp3;
189 temp1 = (*f) * 1.e10;
190 temp2 = fmod(temp1, 1.e10);
191 temp3 = fmod(temp1, 1.e2);
192 temp4 = (temp2-temp3) * 0.1;
201 int GetChannelNames(
struct CommandLineArgsTag CLA)
206 chanin_asq.type=ADCDataChannel;
207 chanin_darm.type=ADCDataChannel;
208 chanin_exc.type=ADCDataChannel;
210 chanin_asq.name = CLA.asq_chan;
211 chanin_darm.name= CLA.darm_chan;
212 chanin_exc.name = CLA.exc_chan;
216 epoch.gpsSeconds=SL[0].tgps;
217 epoch.gpsNanoSeconds=0;
219 LALFrGetPos(&
status,&pos1,framestream);
220 LALFrGetREAL4TimeSeries(&
status,&asq,&chanin_asq,framestream);
221 LALFrSetPos(&
status,&pos1,framestream);
222 LALFrGetREAL4TimeSeries(&
status,&darm,&chanin_darm,framestream);
223 LALFrSetPos(&
status,&pos1,framestream);
224 LALFrGetREAL4TimeSeries(&
status,&exc,&chanin_exc,framestream);
225 LALFrRewind(&
status,framestream);
242 winparams.length=(
INT4)(SL[0].seglength/asq.
deltaT +0.5);
243 LALWindow(&
status,asqwin,&winparams);
246 winparams.length=(
INT4)(SL[0].seglength/darm.
deltaT +0.5);
247 LALWindow(&
status,darmwin,&winparams);
250 winparams.length=(
INT4)(SL[0].seglength/exc.
deltaT +0.5);
251 LALWindow(&
status,excwin,&winparams);
254 fprintf(stdout,
"# GPStime alpha real alpha im alpha*beta real alpha*beta im exc. amplitude darm amplitude AS_Q amplitude\n");
255 fprintf(stdout,
"# ----------------------------------------------------------------------------------------------------------------------------------------------------------\n");
265 int ReadFiles(
struct CommandLineArgsTag CLA)
269 FILE *fpS,*fpR,*fpA,*fpSeg;
270 REAL8 Cmag,Cphase,Rmag,Rphase,Amag,Aphase,freq,
x,
y;
291 fpS=fopen(CLA.CFile,
"r");
294 fprintf(stderr,
"That's weird... %s doesn't exist!\n",CLA.CFile);
297 while(fgets(line,
sizeof(line),fpS))
299 if(*line ==
'#')
continue;
300 if(*line ==
'%')
continue;
306 sscanf(line,
"%le %le %le",&freq,&Cmag,&Cphase);
307 C0.
data->
data[i].re=Cmag*cos(Cphase);
308 C0.
data->
data[i].im=Cmag*sin(Cphase);
316 fpR=fopen(CLA.RFile,
"r");
319 fprintf(stderr,
"That's weird... %s doesn't exist!\n",CLA.RFile);
322 while(fgets(line,
sizeof(line),fpR))
324 if(*line ==
'#')
continue;
325 if(*line ==
'%')
continue;
331 sscanf(line,
"%le %le %le",&freq,&Rmag,&Rphase);
332 R0.
data->
data[i].re=Rmag*cos(Rphase);
333 R0.
data->
data[i].im=Rmag*sin(Rphase);
341 fpA=fopen(CLA.AFile,
"r");
344 fprintf(stderr,
"That's weird... %s doesn't exist!\n",CLA.AFile);
347 while(fgets(line,
sizeof(line),fpA))
349 if(*line ==
'#')
continue;
350 if(*line ==
'%')
continue;
356 sscanf(line,
"%le %le %le",&freq,&Amag,&Aphase);
357 A0.
data->
data[i].re=Amag*cos(Aphase);
358 A0.
data->
data[i].im=Amag*sin(Aphase);
366 fpSeg=fopen(CLA.SegmentsFile,
"r");
369 fprintf(stderr,
"That's weird... %s doesn't exist!\n",CLA.SegmentsFile);
372 while(fgets(line,
sizeof(line),fpSeg))
374 if(*line ==
'#')
continue;
375 if(*line ==
'%')
continue;
376 if (i > MAXLINESEGS-1)
378 fprintf(stderr,
"Too many lines in file %s! Exiting... \n", CLA.SegmentsFile);
381 sscanf(line,
"%d %d %f",&SL[i].nseg,&SL[i].tgps,&SL[i].seglength);
393 Rf0.re = ( 1 -
x ) * R0.
data->
data[i].re;
395 Rf0.im = ( 1 -
x ) * R0.
data->
data[i].im;
399 Cf0.re = ( 1 -
x ) * C0.
data->
data[i].re;
401 Cf0.im = ( 1 -
x ) * C0.
data->
data[i].im;
405 Af0.re = ( 1 -
x ) * A0.
data->
data[i].re;
407 Af0.im = ( 1 -
x ) * A0.
data->
data[i].im;
412 LALFrCacheOpen(&
status,&framestream,framecache);
425 int ReadCommandLine(
int argc,
char *argv[],
struct CommandLineArgsTag *CLA)
437 CLA->SegmentsFile=
"";
443 while (!errflg && ((c =
LALgetopt(argc, argv,
"hf:F:r:S:c:A:E:D:a:k:"))!=-1))
487 fprintf(stdout,
"All arguments are required. They are:\n");
488 fprintf(stdout,
"\t-f\tFLOAT\t Calibration line frequency in Hz.\n");
489 fprintf(stdout,
"\t-k\tFLOAT\t Darm to etmx output matrix value.\n");
490 fprintf(stdout,
"\t-F\tSTRING\t Name of frame cache file.\n");
491 fprintf(stdout,
"\t-r\tSTRING\t Name of response function file.\n");
492 fprintf(stdout,
"\t-c\tSTRING\t Name of sensing function file.\n");
493 fprintf(stdout,
"\t-a\tSTRING\t Name of actuation function file.\n");
494 fprintf(stdout,
"\t-S\tSTRING\t Name of segment list file.\n");
495 fprintf(stdout,
"\t-A\tSTRING\t AS_Q channel name (eg, L1:LSC-AS_Q).\n");
496 fprintf(stdout,
"\t-E\tSTRING\t Excitation channel name (eg, L1:LSC-ETMX_EXC_DAQ)\n");
497 fprintf(stdout,
"\t-D\tSTRING\t Darm channel name (eg, L1:LSC-DARM_CTRL)\n");
498 fprintf(stdout,
"Caution: There are a few hardwired quantities in this code. Look for 'HARDWIRED!!' in the code.\n");
504 fprintf(stderr,
"Unrecognized option argument %c\n",c);
510 fprintf(stderr,
"No calibration line frequency specified.\n");
511 fprintf(stderr,
"Try ./CCFDriver -h \n");
516 fprintf(stderr,
"No value of the output matrix to x arm specified.\n");
517 fprintf(stderr,
"Try ./CCFDriver -h \n");
522 fprintf(stderr,
"No sensing function file specified.\n");
523 fprintf(stderr,
"Try ./CCFDriver -h \n");
528 fprintf(stderr,
"No response function file specified.\n");
529 fprintf(stderr,
"Try ./CCFDriver -h \n");
534 fprintf(stderr,
"No actuation function file specified.\n");
535 fprintf(stderr,
"Try ./CCFDriver -h \n");
538 if(CLA->FrCacheFile==
"")
540 fprintf(stderr,
"No frame cache file specified.\n");
541 fprintf(stderr,
"Try ./CCFDriver -h \n");
544 if(CLA->SegmentsFile==
"")
546 fprintf(stderr,
"No segments file specified.\n");
547 fprintf(stderr,
"Try ./CCFDriver -h \n");
550 if(CLA->exc_chan ==
"")
552 fprintf(stderr,
"No excitation channel specified.\n");
553 fprintf(stderr,
"Try ./CCFDriver -h \n");
556 if(CLA->darm_chan ==
"")
558 fprintf(stderr,
"No darm channel specified.\n");
559 fprintf(stderr,
"Try ./CCFDriver -h \n");
562 if(CLA->asq_chan ==
"")
564 fprintf(stderr,
"No asq channel specified.\n");
565 fprintf(stderr,
"Try ./CCFDriver -h \n");
579 LALFrClose(&
status,&framestream);
void LALComputeCalibrationFactors(LALStatus *status, CalFactors *output, UpdateFactorsParams *input)
void LALCheckMemoryLeaks(void)
int LALgetopt(int argc, char *const *argv, const char *optstring)
static double f(double theta, double y, double xi)
LALCache * XLALCacheImport(const char *fname)
Reads a LAL cache file and produces a LALCache structure.
void XLALDestroyCache(LALCache *cache)
Destroys a LALCache structure.
double complex COMPLEX16
Double-precision floating-point complex number (16 bytes total)
double REAL8
Double precision real floating-point number (8 bytes).
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
void LALZDestroyVector(LALStatus *, COMPLEX16Vector **)
void LALDestroyVector(LALStatus *, REAL4Vector **)
void LALCreateVector(LALStatus *, REAL4Vector **, UINT4)
void LALZCreateVector(LALStatus *, COMPLEX16Vector **, UINT4)
See DATATYPE-FrequencySeries types for documentation.
COMPLEX16 * data
Pointer to the data array.
The LALCache structure is an array of entries.
LAL status structure, see The LALStatus structure for more details.
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
INT4 gpsSeconds
Seconds since 0h UTC 6 Jan 1980.
INT4 gpsNanoSeconds
Residual nanoseconds.
Time series of REAL4 data, see DATATYPE-TimeSeries types for more details.
REAL4Sequence * data
The sequence of sampled data.
REAL8 deltaT
The time step between samples of the time series in seconds.
Vector of type REAL4, see DATATYPE-Vector types for more details.
REAL4 * data
Pointer to the data array.
REAL4TimeSeries * darmCtrl