LALApps 10.1.0.1-eeff03c
power.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2007 Denny Mackin, Duncan Brown, Ik Siong Heng, Jolien
3 * Creighton, Kipp Cannon, Mark Williamsen, Patrick Brady, Robert Adam
4 * Mercer, Saikat Ray-Majumder, Stephen Fairhurst
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with with program; see the file COPYING. If not, write to the Free
18 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 */
21
22
23/*
24 * ============================================================================
25 *
26 * Preamble
27 *
28 * ============================================================================
29 */
30
31
32#include "config.h"
33
34#include <math.h>
35#include <stdarg.h>
36#include <stdio.h>
37#include <stdlib.h>
38#include <string.h>
39#include <sys/time.h>
40#include <gsl/gsl_rng.h>
41#include <gsl/gsl_randist.h>
42
43#include <lal/LALgetopt.h>
44#include <lal/BandPassTimeSeries.h>
45#include <lal/Date.h>
46#include <lal/EPSearch.h>
47#include <lal/LALFrStream.h>
48#include <lal/FrequencySeries.h>
49#include <lal/GenerateBurst.h>
50#include <lal/LALConstants.h>
51#include <lal/LALDatatypes.h>
52#include <lal/LALError.h>
53#include <lal/LALFrameIO.h>
54#include <lal/LALStdlib.h>
55#include <lal/LIGOLwXML.h>
56#include <lal/LIGOLwXMLArray.h>
57#include <lal/LIGOLwXMLRead.h>
58#include <lal/LIGOMetadataTables.h>
59#include <lal/LIGOMetadataUtils.h>
60#include <lal/Random.h>
61#include <lal/RealFFT.h>
62#include <lal/ResampleTimeSeries.h>
63#include <lal/SnglBurstUtils.h>
64#include <lal/TimeFreqFFT.h>
65#include <lal/TimeSeries.h>
66#include <lal/Units.h>
67#include <lal/Window.h>
68
69#include <LALAppsVCSInfo.h>
70
71
72
73#define PROGRAM_NAME "lalapps_power"
74#define CVS_REVISION "$Revision$"
75#define CVS_SOURCE "$Source$"
76#define CVS_DATE "$Date$"
77
78
79/*
80 * ============================================================================
81 *
82 * Misc Utilities
83 *
84 * ============================================================================
85 */
86
87
88/*
89 * Return the smaller of two size_t variables.
90 */
91
92
93static size_t min(size_t a, size_t b)
94{
95 return a < b ? a : b;
96}
97
98
99/*
100 * Return non-zero if the given integer is an integer power of 2. The
101 * trick here is that integer powers of 2 (and only integer powers of 2)
102 * share exactly 0 bits with the integer 1 less than themselves, so we
103 * check to see if that's the case.
104 */
105
106
107static int is_power_of_2(int x)
108{
109 return !((x - 1) & x);
110}
111
112
113/*
114 * Return non-zero if the given double is an integer power of 2.
115 */
116
117
118static int double_is_power_of_2(double x)
119{
120 if(x <= 0)
121 return 0;
122 if(x < 1)
123 /* might be a -ve power */
124 return double_is_power_of_2(1 / x);
125 if(x == trunc(x))
126 /* is an integer */
127 return is_power_of_2(x);
128 return 0;
129}
130
131
132/*
133 * ============================================================================
134 *
135 * Initialize and parse arguments
136 *
137 * ============================================================================
138 */
139
140
141/*
142 * Parameters from command line
143 */
144
145
146struct options {
147 /*
148 * search parameters
149 */
150
151 /* number of samples to use for PSD */
153 /* number of samples separating PSD starts */
155 /* number of samples not tiled at the start of each analysis window
156 * */
158 /* time-frequency plane stride */
160 /* random number generator seed */
161 unsigned long seed;
162
163 /*
164 * frame data input
165 */
166
169 /* name of file with frame cache info */
171 /* name of the calibration cache file */
173 /* channel to analyze */
175 /* two character interferometer */
176 char ifo[3];
177 /* don't read a time series longer than this (e.g., because of
178 * available memory) */
180
181 /*
182 * data conditioning
183 */
184
185 /* sample rate after resampling */
187 /* conditioning high pass freq (Hz) */
188 double high_pass;
189 /* samples corrupted by conditioning */
191
192 /*
193 * injection support
194 */
195
196 /* Gaussian white noise RMS */
197 double noise_rms;
198 /* name of mdc signal cache file */
200 /* mdc signal only channnel info */
202 /* XML file with list(s) of injections */
204
205 /*
206 * XLALEPSearch() parmaters
207 */
208
210 double bandwidth;
211 double flow;
216
217 /*
218 * output control
219 */
220
221 /* user comment */
222 char *comment;
223 /* safety valve (Hz), 0 == disable */
226
227 /*
228 * diagnostics support
229 */
230
232};
233
234
235static struct options *options_new(void)
236{
237 static char default_comment[] = "";
238 struct options *options = malloc(sizeof(*options));
239
240 if(!options)
241 return NULL;
242
243 options->cal_cache_filename = NULL; /* default == disable */
244 options->channel_name = NULL; /* impossible */
245 options->comment = default_comment; /* default = "" */
246 options->filter_corruption = -1; /* impossible */
247 options->mdc_cache_filename = NULL; /* default == disable */
248 options->mdc_channel_name = NULL; /* impossible */
249 options->noise_rms = -1; /* default == disable */
250 options->diagnostics = NULL; /* default == disable */
251 options->psd_length = 0; /* impossible */
252 options->psd_shift = 0; /* impossible */
253 options->resample_rate = 0; /* impossible */
254 options->seed = 0; /* default == use system clock */
255 options->max_series_length = 0; /* default == disable */
256 options->high_pass = -1; /* impossible */
257 options->max_event_rate = 0; /* default == disable */
258 options->output_filename = NULL; /* impossible */
259 options->injection_filename = NULL; /* default == disable */
260 options->cache_filename = NULL; /* default == disable */
262 options->bandwidth = 0; /* impossible */
263 options->flow = -1; /* impossible */
264 options->maxTileBandwidth = 0; /* impossible */
265 options->maxTileDuration = 0; /* impossible */
266 options->fractional_stride = 0; /* impossible */
267 options->window = NULL; /* impossible */
268
269 memset(options->ifo, 0, sizeof(options->ifo)); /* default = "" */
270 XLALINT8NSToGPS(&options->gps_start, 0); /* impossible */
271 XLALINT8NSToGPS(&options->gps_end, 0); /* impossible */
272
273 return options;
274}
275
276
277static void options_free(struct options *options)
278{
279 if(options) {
281 }
282 free(options);
283}
284
285
286/*
287 * Friendly messages.
288 */
289
290
291static void print_usage(const char *program)
292{
293 fprintf(stderr,
294"Usage: %s [option ...]\n" \
295"The following options are recognized. Options not surrounded in [] are\n" \
296"required.\n" \
297" --bandwidth <Hz>\n" \
298" [--calibration-cache <cache file name>]\n" \
299" --channel-name <name>\n" \
300" --confidence-threshold <confidence>\n" \
301" [--dump-diagnostics <XML file name>]\n" \
302" --filter-corruption <samples>\n" \
303" --frame-cache <cache file name>\n" \
304" [--gaussian-noise-rms <RMS amplitude>]\n", program);
305 fprintf(stderr,
306" --gps-end-time <seconds>\n" \
307" --gps-start-time <seconds>\n" \
308" [--help]\n" \
309" --high-pass <Hz>\n" \
310" [--injection-file <XML file name>]\n" \
311" --low-freq-cutoff <Hz>\n" \
312" [--max-event-rate <Hz>]\n" \
313" --max-tile-bandwidth <Hz>\n" \
314" --max-tile-duration <seconds>\n" \
315" [--mdc-cache <cache file name>]\n" \
316" [--mdc-channel <name>]\n" \
317" [--output <filename>]\n" \
318" --psd-average-points <samples>\n" \
319" [--ram-limit <MebiBytes>]\n" \
320" --resample-rate <Hz>\n" \
321" [--seed <seed>]\n");
322 fprintf(stderr,
323" --tile-stride-fraction <fraction>\n" \
324" [--user-tag <comment>]\n" \
325" --window-length <samples>\n");
326}
327
328
329static void print_bad_argument(const char *prog, const char *arg, const char *msg)
330{
331 XLALPrintError("%s: error: invalid argument for --%s: %s\n", prog, arg, msg);
332}
333
334
335static void print_missing_argument(const char *prog, const char *arg)
336{
337 XLALPrintError("%s: error: --%s not specified\n", prog, arg);
338}
339
340
341/*
342 * Check for missing command line arguments.
343 */
344
345
346static int all_required_arguments_present(char *prog, struct LALoption *long_options, const struct options *options)
347{
348 int option_index;
349 int got_all_arguments = 1;
350 int arg_is_missing;
351
352 for(option_index = 0; long_options[option_index].name; option_index++) {
353 switch(long_options[option_index].val) {
354 case 'A':
355 arg_is_missing = !options->bandwidth;
356 break;
357
358 case 'C':
359 arg_is_missing = !options->channel_name;
360 break;
361
362 case 'K':
363 arg_is_missing = !XLALGPSToINT8NS(&options->gps_end);
364 break;
365
366 case 'M':
367 arg_is_missing = !XLALGPSToINT8NS(&options->gps_start);
368 break;
369
370 case 'Q':
371 arg_is_missing = options->flow < 0.0;
372 break;
373
374 case 'W':
375 arg_is_missing = !options->window;
376 break;
377
378 case 'Z':
379 arg_is_missing = !options->psd_length;
380 break;
381
382 case 'e':
383 arg_is_missing = !options->resample_rate;
384 break;
385
386 case 'f':
387 arg_is_missing = !options->fractional_stride;
388 break;
389
390 case 'g':
392 break;
393
394 case 'j':
395 arg_is_missing = options->filter_corruption < 0;
396 break;
397
398 case 'l':
399 arg_is_missing = !options->maxTileBandwidth;
400 break;
401
402 case 'm':
403 arg_is_missing = !options->maxTileDuration;
404 break;
405
406 case 'o':
407 arg_is_missing = options->high_pass < 0.0;
408 break;
409
410 default:
411 arg_is_missing = 0;
412 break;
413 }
414 if(arg_is_missing) {
415 print_missing_argument(prog, long_options[option_index].name);
416 got_all_arguments = 0;
417 }
418 }
419
420 if(!!options->cache_filename + (options->noise_rms > 0.0) != 1) {
421 XLALPrintError("%s: must provide exactly one of --frame-cache or --gaussian-noise-rms\n", prog);
422 got_all_arguments = 0;
423 }
424
425 return got_all_arguments;
426}
427
428
429/*
430 * Helper function for adding an entry to the process params table.
431 */
432
433
434static ProcessParamsTable **add_process_param(ProcessParamsTable **proc_param, const ProcessTable *process, const char *type, const char *param, const char *value)
435{
437 snprintf((*proc_param)->program, sizeof((*proc_param)->program), PROGRAM_NAME);
438 snprintf((*proc_param)->type, sizeof((*proc_param)->type), "%s", type);
439 snprintf((*proc_param)->param, sizeof((*proc_param)->param), "--%s", param);
440 snprintf((*proc_param)->value, sizeof((*proc_param)->value), "%s", value ? value : "");
441
442 return &(*proc_param)->next;
443}
444
445
446#define ADD_PROCESS_PARAM(process, type) \
447 do { paramaddpoint = add_process_param(paramaddpoint, process, type, long_options[option_index].name, LALoptarg); } while(0)
448
449
450/*
451 * Parse the command line arguments.
452 */
453
454
455static struct options *parse_command_line(int argc, char *argv[], const ProcessTable *process, ProcessParamsTable **paramaddpoint)
456{
457 struct options *options;
458 char msg[240];
459 int args_are_bad = 0;
460 int c;
461 int option_index;
462 struct LALoption long_options[] = {
463 {"bandwidth", required_argument, NULL, 'A'},
464 {"injection-file", required_argument, NULL, 'P'},
465 {"calibration-cache", required_argument, NULL, 'B'},
466 {"channel-name", required_argument, NULL, 'C'},
467 {"confidence-threshold", required_argument, NULL, 'g'},
468 {"dump-diagnostics", required_argument, NULL, 'X'},
469 {"filter-corruption", required_argument, NULL, 'j'},
470 {"frame-cache", required_argument, NULL, 'G'},
471 {"gaussian-noise-rms", required_argument, NULL, 'V'},
472 {"gps-end-time", required_argument, NULL, 'K'},
473 {"gps-start-time", required_argument, NULL, 'M'},
474 {"help", no_argument, NULL, 'O'},
475 {"high-pass", required_argument, NULL, 'o'},
476 {"low-freq-cutoff", required_argument, NULL, 'Q'},
477 {"max-event-rate", required_argument, NULL, 'F'},
478 {"max-tile-bandwidth", required_argument, NULL, 'l'},
479 {"max-tile-duration", required_argument, NULL, 'm'},
480 {"mdc-cache", required_argument, NULL, 'R'},
481 {"mdc-channel", required_argument, NULL, 'S'},
482 {"output", required_argument, NULL, 'b'},
483 {"psd-average-points", required_argument, NULL, 'Z'},
484 {"ram-limit", required_argument, NULL, 'a'},
485 {"resample-rate", required_argument, NULL, 'e'},
486 {"seed", required_argument, NULL, 'c'},
487 {"tile-stride-fraction", required_argument, NULL, 'f'},
488 {"user-tag", required_argument, NULL, 'h'},
489 {"window-length", required_argument, NULL, 'W'},
490 {NULL, 0, NULL, 0}
491 };
492
493 /*
494 * Allocate and initialize options structure
495 */
496
498 if(!options)
499 return NULL;
500
501 /*
502 * Parse command line.
503 */
504
505 LALopterr = 1; /* enable error messages */
506 LALoptind = 0; /* start scanning from argv[0] */
507 do switch (c = LALgetopt_long(argc, argv, "", long_options, &option_index)) {
508 case 'A':
509 options->bandwidth = atof(LALoptarg);
511 sprintf(msg, "must be greater than 0 and a power of 2 (%g specified)", options->bandwidth);
512 print_bad_argument(argv[0], long_options[option_index].name, msg);
513 args_are_bad = 1;
514 }
516 break;
517
518 case 'B':
520 ADD_PROCESS_PARAM(process, "string");
521 break;
522
523 case 'C':
525 memcpy(options->ifo, LALoptarg, sizeof(options->ifo) - 1);
526 ADD_PROCESS_PARAM(process, "string");
527 break;
528
529 case 'F':
531 if(options->max_event_rate < 0) {
532 sprintf(msg, "must not be negative (%d specified)", options->max_event_rate);
533 print_bad_argument(argv[0], long_options[option_index].name, msg);
534 args_are_bad = 1;
535 }
537 break;
538
539 case 'G':
541 ADD_PROCESS_PARAM(process, "string");
542 break;
543
544 case 'K':
545 if(XLALStrToGPS(&options->gps_end, LALoptarg, NULL)) {
546 sprintf(msg, "range error parsing \"%s\"", LALoptarg);
547 print_bad_argument(argv[0], long_options[option_index].name, msg);
548 args_are_bad = 1;
549 }
550 ADD_PROCESS_PARAM(process, "string");
551 break;
552
553 case 'M':
555 sprintf(msg, "range error parsing \"%s\"", LALoptarg);
556 print_bad_argument(argv[0], long_options[option_index].name, msg);
557 args_are_bad = 1;
558 }
559 ADD_PROCESS_PARAM(process, "string");
560 break;
561
562 case 'O':
563 print_usage(argv[0]);
564 exit(0);
565 break;
566
567 case 'P':
569 ADD_PROCESS_PARAM(process, "string");
570 break;
571
572 case 'Q':
573 options->flow = atof(LALoptarg);
574 if(options->flow < 0) {
575 sprintf(msg, "must not be negative (%f Hz specified)", options->flow);
576 print_bad_argument(argv[0], long_options[option_index].name, msg);
577 args_are_bad = 1;
578 }
579 ADD_PROCESS_PARAM(process, "float");
580 break;
581
582 case 'R':
584 ADD_PROCESS_PARAM(process, "string");
585 break;
586
587 case 'S':
589 ADD_PROCESS_PARAM(process, "string");
590 break;
591
592 case 'V':
593 options->noise_rms = atof(LALoptarg);
594 if(options->noise_rms <= 0.0) {
595 sprintf(msg, "must be greater than 0 (%f specified)", options->noise_rms);
596 print_bad_argument(argv[0], long_options[option_index].name, msg);
597 args_are_bad = 1;
598 }
599 ADD_PROCESS_PARAM(process, "float");
600 break;
601
602 case 'W':
603 {
604 int window_length = atoi(LALoptarg);
605 if((window_length < 4) || !is_power_of_2(window_length)) {
606 sprintf(msg, "must be greater than or equal to 4 and a power of 2 (%i specified)", window_length);
607 print_bad_argument(argv[0], long_options[option_index].name, msg);
608 args_are_bad = 1;
609 }
610 options->window = XLALCreateHannREAL8Window(window_length);
611 if(!options->window) {
612 sprintf(msg, "failure generating %d sample Hann window", window_length);
613 print_bad_argument(argv[0], long_options[option_index].name, msg);
614 args_are_bad = 1;
615 /* silence "missing required argument" message */
616 options->window = (void *) 1;
617 }
619 }
620 break;
621
622 case 'X':
623#if 0
625#else
626 sprintf(msg, "--dump-diagnostics given but diagnostic code not included at compile time");
627 args_are_bad = 1;
628#endif
629 break;
630
631 case 'Z':
634 break;
635
636 case 'a':
637 /*
638 * Convert the available RAM (in MebiBytes) to a
639 * guestimated limit on the length of a time series to read
640 * in.
641 */
642 options->max_series_length = atoi(LALoptarg) * 1024 * 1024 / (8 * sizeof(REAL8));
643 if(options->max_series_length <= 0) {
644 sprintf(msg, "must be greater than 0 (%i specified)", atoi(LALoptarg));
645 print_bad_argument(argv[0], long_options[option_index].name, msg);
646 args_are_bad = 1;
647 }
649 break;
650
651 case 'b':
653 ADD_PROCESS_PARAM(process, "string");
654 break;
655
656 case 'c':
658 ADD_PROCESS_PARAM(process, "long");
659 break;
660
661 case 'e':
664 sprintf(msg, "must be a power of 2 in the rage [2,16384] (%d specified)", options->resample_rate);
665 print_bad_argument(argv[0], long_options[option_index].name, msg);
666 args_are_bad = 1;
667 }
669 break;
670
671 case 'f':
674 sprintf(msg, "must be less than or equal to 1 and a power of 2 (%g specified)", options->fractional_stride);
675 print_bad_argument(argv[0], long_options[option_index].name, msg);
676 args_are_bad = 1;
677 }
678 ADD_PROCESS_PARAM(process, "float");
679 break;
680
681 case 'g':
684 sprintf(msg, "must not be negative (%g specified)", options->confidence_threshold);
685 print_bad_argument(argv[0], long_options[option_index].name, msg);
686 args_are_bad = 1;
687 }
688 ADD_PROCESS_PARAM(process, "float");
689 break;
690
691 case 'h':
693 ADD_PROCESS_PARAM(process, "string");
694 break;
695
696 case 'j':
698 if(options->filter_corruption < 0) {
699 sprintf(msg, "must not be negative (%d specified)", options->filter_corruption);
700 print_bad_argument(argv[0], long_options[option_index].name, msg);
701 args_are_bad = 1;
702 }
704 break;
705
706 case 'l':
709 sprintf(msg, "must be greater than 0 and a power of 2 (%f specified)", options->maxTileBandwidth);
710 print_bad_argument(argv[0], long_options[option_index].name, msg);
711 args_are_bad = 1;
712 }
713 ADD_PROCESS_PARAM(process, "float");
714 break;
715
716 case 'm':
719 sprintf(msg, "must be greater than 0 and a power of 2 (%f specified)", options->maxTileDuration);
720 print_bad_argument(argv[0], long_options[option_index].name, msg);
721 args_are_bad = 1;
722 }
723 ADD_PROCESS_PARAM(process, "float");
724 break;
725
726 case 'o':
727 options->high_pass = atof(LALoptarg);
728 if(options->high_pass < 0) {
729 sprintf(msg, "must not be negative (%f Hz specified)", options->high_pass);
730 print_bad_argument(argv[0], long_options[option_index].name, msg);
731 args_are_bad = 1;
732 }
733 ADD_PROCESS_PARAM(process, "float");
734 break;
735
736 /* option sets a flag */
737 case 0:
738 LALoptarg = NULL;
739 ADD_PROCESS_PARAM(process, "string");
740 break;
741
742 /* end of arguments */
743 case -1:
744 break;
745
746 /* unrecognized option */
747 case '?':
748 print_usage(argv[0]);
749 exit(1);
750
751 /* missing argument for an option */
752 case ':':
753 print_usage(argv[0]);
754 exit(1);
755 } while(c != -1);
756
757 /*
758 * Check for missing command line arguments.
759 */
760
761 if(!all_required_arguments_present(argv[0], long_options, options))
762 args_are_bad = 1;
763
764 /*
765 * Check the order of the start and stop times.
766 */
767
769 XLALPrintError("%s: error: GPS start time > GPS stop time\n", argv[0]);
770 args_are_bad = 1;
771 }
772
773 /*
774 * Warn if calibration cache is not provided that a unit response
775 * will be used for injections and h_rss.
776 */
777
779 XLALPrintWarning("warning: no calibration cache is provided: software injections and hrss will be computed with unit response\n");
780
781 /*
782 * Exit if anything was wrong with the command line.
783 */
784
785 if(args_are_bad)
786 exit(1);
787
788 /*
789 * Compute timing parameters.
790 */
791
792 {
793 int tiling_length; /* unused */
795 XLALPrintError("calculation of timing parameters failed\n");
796 exit(1);
797 }
798 }
799
800 /*
801 * Ensure RAM limit is comensurate with the psd_length and its
802 * shift.
803 */
804
807
808 /*
809 * Sanitize filter frequencies.
810 */
811
812 if(options->high_pass > options->flow - 10.0)
813 XLALPrintWarning("%s: warning: data conditioning high-pass frequency (%f Hz) greater than 10 Hz below TF plane low frequency (%f Hz)\n", argv[0], options->high_pass, options->flow);
814
815 /*
816 * Set output filename to default value if needed.
817 */
818
820 int size = 1024, required_size;
821 while(1) {
822 options->output_filename = calloc(size, sizeof(*options->output_filename));
824 XLALPrintError("memory error");
825 exit(1);
826 }
827 required_size = snprintf(options->output_filename, size, "%s-POWER_%s-%d-%d.xml", options->ifo, options->comment, options->gps_start.gpsSeconds, options->gps_end.gpsSeconds - options->gps_start.gpsSeconds);
828 if(required_size < size)
829 break;
831 size = required_size;
832 }
833 options->output_filename = realloc(options->output_filename, (required_size + 1) * sizeof(*options->output_filename));
835 XLALPrintError("memory error");
836 exit(1);
837 }
838 }
839
840 /*
841 * Miscellaneous chores.
842 */
843
844 XLALPrintInfo("%s: using --psd-average-points %i\n", argv[0], options->psd_length);
846 XLALPrintInfo("%s: available RAM limits analysis to %d samples (%g s)\n", argv[0], options->max_series_length, options->max_series_length / (double) options->resample_rate);
847
848 return options;
849}
850
851
852/*
853 * ============================================================================
854 *
855 * Input
856 *
857 * ============================================================================
858 */
859
860
861static REAL8TimeSeries *get_time_series(const char *cachefilename, const char *chname, LIGOTimeGPS start, LIGOTimeGPS end, size_t lengthlimit)
862{
863 double duration = XLALGPSDiff(&end, &start);
865 LALFrStream *stream;
866 LALTYPECODE series_type;
868
869 if(duration < 0)
871
872 /*
873 * Open frame stream.
874 */
875
876 cache = XLALCacheImport(cachefilename);
877 if(!cache)
881 if(!stream)
883
884 /*
885 * Turn on checking for missing data.
886 */
887
889
890 /*
891 * Get the data.
892 */
893
894 series_type = XLALFrStreamGetTimeSeriesType(chname, stream);
895 if((int) series_type < 0) {
896 XLALFrStreamClose(stream);
898 }
899
900 switch(series_type) {
901 case LAL_S_TYPE_CODE: {
902 /*
903 * Read data as single-precision and convert to double.
904 */
905
906 REAL4TimeSeries *tmp = XLALFrStreamReadREAL4TimeSeries(stream, chname, &start, duration, lengthlimit);
907 unsigned i;
908 if(!tmp) {
909 XLALFrStreamClose(stream);
911 }
912 series = XLALCreateREAL8TimeSeries(tmp->name, &tmp->epoch, tmp->f0, tmp->deltaT, &tmp->sampleUnits, tmp->data->length);
913 if(!series) {
915 XLALFrStreamClose(stream);
917 }
918 for(i = 0; i < tmp->data->length; i++)
919 series->data->data[i] = tmp->data->data[i];
921 break;
922 }
923
924 case LAL_D_TYPE_CODE:
925 series = XLALFrStreamReadREAL8TimeSeries(stream, chname, &start, duration, lengthlimit);
926 if(!series) {
927 XLALFrStreamClose(stream);
929 }
930 break;
931
932 default:
933 XLALPrintError("get_time_series(): error: invalid channel data type %d\n", series_type);
934 XLALFrStreamClose(stream);
936 }
937
938 /*
939 * Check for missing data.
940 */
941
942 if(stream->state & LAL_FR_STREAM_GAP) {
943 XLALPrintError("get_time_series(): error: gap in data detected between GPS times %d.%09u s and %d.%09u s\n", start.gpsSeconds, start.gpsNanoSeconds, end.gpsSeconds, end.gpsNanoSeconds);
946 }
947
948 /*
949 * Close stream.
950 */
951
952 XLALFrStreamClose(stream);
953
954 /*
955 * Verbosity.
956 */
957
958 XLALPrintInfo("get_time_series(): read %u samples (%.9lf s) at GPS time %u.%09u s\n", series->data->length, series->data->length * series->deltaT, start.gpsSeconds, start.gpsNanoSeconds);
959
960 return series;
961}
962
963
964/*
965 * Condition the time series prior to analysis by the power code
966 */
967
968
971 REAL8 flow,
972 REAL8 resampledeltaT,
973 INT4 corruption
974)
975{
976 const REAL8 epsilon = 1.0e-3;
977
978 XLALPrintInfo("%s(): conditioning %u samples (%.9f s) at GPS time %d.%09u s ...\n", __func__, series->data->length, series->data->length * series->deltaT, series->epoch.gpsSeconds, series->epoch.gpsNanoSeconds);
979
980 /*
981 * High-pass filter the time series.
982 */
983
984 if(flow > 0.0) {
985 PassBandParamStruc highpassParam;
986 highpassParam.nMax = 8;
987 highpassParam.f2 = flow;
988 highpassParam.f1 = -1.0;
989 highpassParam.a2 = 0.9;
990 highpassParam.a1 = -1.0;
991 if(XLALButterworthREAL8TimeSeries(series, &highpassParam))
993 }
994
995 /*
996 * Resample the time series if necessary
997 */
998
999 if(fabs(resampledeltaT - series->deltaT) / series->deltaT >= epsilon)
1000 if(XLALResampleREAL8TimeSeries(series, resampledeltaT))
1002
1003 /*
1004 * Chop off the ends of the time series.
1005 */
1006
1007 if(!XLALShrinkREAL8TimeSeries(series, corruption, series->data->length - 2 * corruption))
1009
1010 /*
1011 * Done.
1012 */
1013
1014 XLALPrintInfo("%s(): %u samples (%.9f s) at GPS time %d.%09u s remain after conditioning\n", __func__, series->data->length, series->data->length * series->deltaT, series->epoch.gpsSeconds, series->epoch.gpsNanoSeconds);
1015
1016 return(0);
1017}
1018
1019
1020/*
1021 * ============================================================================
1022 *
1023 * Fill a time series with white noise
1024 *
1025 * ============================================================================
1026 */
1027
1028
1029static void gaussian_noise(REAL8TimeSeries *series, REAL8 rms, gsl_rng *rng)
1030{
1031 unsigned i;
1032
1033 for(i = 0; i < series->data->length; i++)
1034 series->data->data[i] = gsl_ran_gaussian(rng, rms);
1035}
1036
1037
1038/*
1039 * ============================================================================
1040 *
1041 * Injections
1042 *
1043 * ============================================================================
1044 */
1045
1046
1047/*
1048 * Load file
1049 */
1050
1051
1059};
1060
1061
1063{
1064 if(doc) {
1070 }
1071}
1072
1073
1075{
1076 struct injection_document *new;
1077
1078 new = malloc(sizeof(*new));
1079 if(!new)
1081
1082 /*
1083 * load required tables
1084 */
1085
1086 new->process_table_head = XLALProcessTableFromLIGOLw(filename);
1087 new->process_params_table_head = XLALProcessParamsTableFromLIGOLw(filename);
1088 new->search_summary_table_head = XLALSearchSummaryTableFromLIGOLw(filename);
1089 new->time_slide_table_head = XLALTimeSlideTableFromLIGOLw(filename);
1090
1091 /*
1092 * load optional sim_burst table
1093 */
1094
1095 new->has_sim_burst_table = XLALLIGOLwHasTable(filename, "sim_burst");
1096 if(new->has_sim_burst_table) {
1097 new->sim_burst_table_head = XLALSimBurstTableFromLIGOLw(filename);
1098 } else
1099 new->sim_burst_table_head = NULL;
1100
1101 /*
1102 * did we get it all?
1103 */
1104
1105 if(
1106 !new->process_table_head ||
1107 !new->process_params_table_head ||
1108 !new->search_summary_table_head ||
1109 !new->time_slide_table_head ||
1110 (new->has_sim_burst_table && !new->sim_burst_table_head)
1111 ) {
1114 }
1115
1116 /*
1117 * success
1118 */
1119
1120 return new;
1121}
1122
1123
1124/*
1125 * This is the function that gets called.
1126 */
1127
1128
1130{
1131 /*
1132 * sim_burst
1133 */
1134
1136 XLALPrintInfo("%s(): computing sim_burst injections ...\n", __func__);
1139 XLALPrintInfo("%s(): done\n", __func__);
1140 }
1141
1142 /*
1143 * done
1144 */
1145
1146 return 0;
1147}
1148
1149
1150/*
1151 * ============================================================================
1152 *
1153 * MDC injections
1154 *
1155 * ============================================================================
1156 */
1157
1158
1159static REAL8TimeSeries *add_mdc_injections(const char *mdccachefile, const char *channel_name, REAL8TimeSeries *series)
1160{
1161 LIGOTimeGPS stop;
1162 REAL8TimeSeries *mdc;
1163 unsigned i;
1164
1165 XLALPrintInfo("%s(): mixing data from MDC frames\n", __func__);
1166
1167 stop = series->epoch;
1168 XLALGPSAdd(&stop, series->data->length * series->deltaT);
1169
1170 mdc = get_time_series(mdccachefile, channel_name, series->epoch, stop, 0);
1171 if(!mdc)
1173 /* FIXME: ARGH!!! frame files cannot be trusted to provide units
1174 * for their contents! */
1175 series->sampleUnits = lalStrainUnit;
1176
1177 for(i = 0; i < series->data->length; i++)
1178 series->data->data[i] += mdc->data->data[i];
1179
1181
1182 return series;
1183}
1184
1185
1186/*
1187 * ============================================================================
1188 *
1189 * Analysis Loop
1190 *
1191 * ============================================================================
1192 */
1193
1194
1195/*
1196 * Analyze a time series in intervals corresponding to the length of time
1197 * for which the instrument's noise is stationary.
1198 */
1199
1200
1201static SnglBurst **analyze_series(SnglBurst **addpoint, REAL8TimeSeries *series, int psd_length, int psd_shift, struct options *options)
1202{
1203 unsigned i;
1204
1205 if((unsigned) psd_length > series->data->length) {
1206 XLALPrintWarning("%s(): warning: PSD length (%.9lf s) exceeds available data (%.9lf s), skipping series\n", __func__, psd_length * series->deltaT, series->data->length * series->deltaT);
1207 return addpoint;
1208 }
1209
1210 for(i = 0; i + psd_length < series->data->length + psd_shift; i += psd_shift) {
1211 int errnum;
1212 int start = min(i, series->data->length - psd_length);
1214
1215 if(!interval)
1217
1218 XLALPrintInfo("%s(): ", __func__);
1219 XLALPrintProgressBar(i / (double) (series->data->length + psd_shift - psd_length));
1220 XLALPrintInfo(" complete\n");
1221 XLALPrintInfo("%s(): analyzing samples %i -- %i (%.9lf s -- %.9lf s)\n", __func__, start, start + interval->data->length, start * interval->deltaT, (start + interval->data->length) * interval->deltaT);
1222
1223 XLAL_TRY(*addpoint = XLALEPSearch(
1225 interval,
1226 options->window,
1227 options->flow,
1233 ), errnum);
1234 while(*addpoint)
1235 addpoint = &(*addpoint)->next;
1236
1238
1239 if(errnum) {
1240 XLALSetErrno(errnum);
1242 }
1243
1244 }
1245
1246 return addpoint;
1247}
1248
1249
1250/*
1251 * ============================================================================
1252 *
1253 * Output
1254 *
1255 * ============================================================================
1256 */
1257
1258
1259static void output_results(char *file, const ProcessTable *_process_table, const ProcessParamsTable *_process_params_table, const SearchSummaryTable *_search_summary_table, const SnglBurst *_sngl_burst_table)
1260{
1261 LIGOLwXMLStream *xml;
1262
1264
1265 /*
1266 * process table
1267 */
1268
1269 if(XLALWriteLIGOLwXMLProcessTable(xml, _process_table)) {
1270 /* FIXME: error occured. do something smarter */
1271 exit(1);
1272 }
1273
1274 /*
1275 * process params table
1276 */
1277
1278 if(XLALWriteLIGOLwXMLProcessParamsTable(xml, _process_params_table)) {
1279 /* FIXME: error occured. do something smarter */
1280 exit(1);
1281 }
1282
1283 /*
1284 * search summary table
1285 */
1286
1287 if(XLALWriteLIGOLwXMLSearchSummaryTable(xml, _search_summary_table)) {
1288 /* FIXME: error occured. do something smarter */
1289 exit(1);
1290 }
1291
1292 /*
1293 * burst table
1294 */
1295
1296 if(XLALWriteLIGOLwXMLSnglBurstTable(xml, _sngl_burst_table)) {
1297 /* FIXME: error occured. do something smarter */
1298 exit(1);
1299 }
1300
1301 /*
1302 * done
1303 */
1304
1306}
1307
1308
1309/*
1310 * ============================================================================
1311 *
1312 * Entry point
1313 *
1314 * ============================================================================
1315 */
1316
1317
1318int main(int argc, char *argv[])
1319{
1320 struct options *options;
1322 LIGOTimeGPS boundepoch;
1323 int overlap;
1324 REAL8TimeSeries *series = NULL;
1326 SnglBurst *_sngl_burst_table = NULL;
1327 SnglBurst **EventAddPoint = &_sngl_burst_table;
1328 /* the ugly underscores are because some badger put global symbols
1329 * in LAL with exactly these names. it's a mad house, a maad house
1330 * */
1331 ProcessTable *_process_table;
1332 ProcessParamsTable *_process_params_table = NULL;
1333 SearchSummaryTable *_search_summary_table;
1334 gsl_rng *rng = NULL;
1335
1336 /*
1337 * Command line
1338 */
1339
1341
1342 /*
1343 * Create the process and process params tables.
1344 *
1345 * FIXME: hard-coded process ID 9 is used to avoid conflicts with
1346 * input injection files. 9 is high-enough for current use cases,
1347 * but a better solution would be to set it to 0 and find a way to
1348 * merge injection tables with existing process and process params
1349 * tables from thsi process.
1350 */
1351
1352 _process_table = XLALCreateProcessTableRow();
1354 exit(1);
1355
1356 XLALGPSTimeNow(&_process_table->start_time);
1357
1358 /*
1359 * Parse arguments and fill _process_params_table table.
1360 */
1361
1362 options = parse_command_line(argc, argv, _process_table, &_process_params_table);
1363 snprintf(_process_table->ifos, sizeof(_process_table->ifos), "%s", options->ifo);
1364 snprintf(_process_table->comment, sizeof(_process_table->comment), "%s", options->comment);
1365
1366 /*
1367 * Create the search summary table. The number of nodes for a
1368 * standalone job is always 1
1369 */
1370
1371 _search_summary_table = XLALCreateSearchSummaryTableRow(_process_table);
1372 snprintf(_search_summary_table->comment, sizeof(_search_summary_table->comment), "%s", options->comment);
1373 snprintf(_search_summary_table->ifos, sizeof(_search_summary_table->ifos), "%s", options->ifo);
1374 _search_summary_table->nnodes = 1;
1375 _search_summary_table->in_start_time = options->gps_start;
1376 _search_summary_table->in_end_time = options->gps_end;
1377
1378 /*
1379 * determine the input time series post-conditioning overlap, and
1380 * set the outer loop's upper bound
1381 */
1382
1384 XLALPrintInfo("%s: time series overlap is %i samples (%.9lf s)\n", argv[0], overlap, overlap / (double) options->resample_rate);
1385
1386 boundepoch = options->gps_end;
1387 XLALGPSAdd(&boundepoch, -(2 * options->filter_corruption + (int) overlap) / (double) options->resample_rate);
1388 XLALPrintInfo("%s: time series epochs must be less than %u.%09u s\n", argv[0], boundepoch.gpsSeconds, boundepoch.gpsNanoSeconds);
1389
1390 /*
1391 * load injections if requested
1392 */
1393
1396 if(!injection_document) {
1397 XLALPrintError("%s: error: failure reading injections file \"%s\"\n", argv[0], options->injection_filename);
1398 exit(1);
1399 }
1400 }
1401
1402 /*
1403 * ====================================================================
1404 *
1405 * Outer Loop
1406 *
1407 * ====================================================================
1408 */
1409
1410 /*
1411 * Split the total length of time to be analyzed into time series
1412 * small enough to fit in RAM.
1413 */
1414
1415 for(epoch = options->gps_start; XLALGPSCmp(&epoch, &boundepoch) < 0;) {
1416 /*
1417 * Progress bar.
1418 */
1419
1420 XLALPrintInfo("%s: ", argv[0]);
1422 XLALPrintInfo(" complete\n");
1423
1424 /*
1425 * Get the data.
1426 */
1427
1428 if(options->cache_filename) {
1429 /*
1430 * Read from frame files
1431 */
1432
1434 if(!series) {
1435 XLALPrintError("%s: error: failure reading input data\n", argv[0]);
1436 exit(1);
1437 }
1438 /* FIXME: ARGH!!! frame files cannot be trusted
1439 * to provide units for their contents! assume ADC
1440 * counts if a calibration cache has been provided,
1441 * otherwise assume strain. */
1443 } else if(options->noise_rms > 0.0) {
1444 /*
1445 * Synthesize Gaussian white noise.
1446 */
1447
1448 unsigned length = XLALGPSDiff(&options->gps_end, &epoch) * options->resample_rate;
1450 length = min(options->max_series_length, length);
1451 /* for units, assume ADC counts if a calibration
1452 * cache has been provided, otherwise assume
1453 * strain. */
1455 if(!series) {
1456 XLALPrintError("%s: error: failure allocating data for Gaussian noise\n", argv[0]);
1457 exit(1);
1458 }
1459 if(!rng) {
1460 rng = gsl_rng_alloc(gsl_rng_mt19937);
1461 if(options->seed)
1462 gsl_rng_set(rng, options->seed);
1463 else {
1464 /* use time in milliseconds */
1465 struct timeval t;
1466 unsigned long seed;
1467 if(gettimeofday(&t, NULL)) {
1468 /* failure */
1469 XLALPrintError("%s: error: cannot get time of day to seed random number generator\n", argv[0]);
1470 exit(1);
1471 }
1472 seed = 1000 * (t.tv_sec + t.tv_usec * 1e-6);
1473 XLALPrintInfo("%s: using random number seed %lu\n", argv[0], seed);
1474 gsl_rng_set(rng, seed);
1475 }
1476 }
1478 } else {
1479 /*
1480 * Should never get here.
1481 */
1482 XLALPrintError("%s: error: oops, don't know how to get data\n", argv[0]);
1483 exit(1);
1484 }
1485
1486 /*
1487 * Add XML injections into the time series if requested.
1488 */
1489
1490 if(injection_document) {
1491 /* perform XML injections */
1493 exit(1);
1494 }
1495
1496 /*
1497 * Add MDC injections into the time series if requested.
1498 */
1499
1502
1503 /*
1504 * Condition the time series data.
1505 */
1506
1508 XLALPrintError("%s: XLALEPConditionData() failed.\n", argv[0]);
1509 exit(1);
1510 }
1511
1512 /*
1513 * Store the start and end times of the data that actually
1514 * gets analyzed.
1515 */
1516
1517 if(!_search_summary_table->out_start_time.gpsSeconds) {
1518 _search_summary_table->out_start_time = series->epoch;
1519 XLALGPSAdd(&_search_summary_table->out_start_time, series->deltaT * options->window_pad);
1520 }
1521 _search_summary_table->out_end_time = series->epoch;
1522 XLALGPSAdd(&_search_summary_table->out_end_time, series->deltaT * (series->data->length - options->window_pad));
1523
1524 /*
1525 * Analyze the data
1526 */
1527
1528 EventAddPoint = analyze_series(EventAddPoint, series, options->psd_length, options->psd_shift, options);
1529 if(!EventAddPoint)
1530 exit(1);
1531
1532 /*
1533 * Reset for next run
1534 *
1535 * Advancing the epoch by the post-conditioning series length
1536 * provides exactly the overlap needed to account for
1537 * conditioning corruption. The post-conditioning overlap
1538 * computed earlier provides the additional overlap needed
1539 * for the time-frequency tiling.
1540 */
1541
1542 XLALGPSAdd(&epoch, (series->data->length - overlap) * series->deltaT);
1544 }
1545
1546 /*
1547 * Sort the events, and assign IDs.
1548 */
1549
1551 XLALSnglBurstAssignIDs(_sngl_burst_table, _process_table->process_id, 0);
1552
1553 /*
1554 * Check event rate limit.
1555 */
1556
1557 _search_summary_table->nevents = XLALSnglBurstTableLength(_sngl_burst_table);
1558 if((options->max_event_rate > 0) && (_search_summary_table->nevents > XLALGPSDiff(&_search_summary_table->out_end_time, &_search_summary_table->out_start_time) * options->max_event_rate)) {
1559 XLALPrintError("%s: event rate limit exceeded!", argv[0]);
1560 exit(1);
1561 }
1562
1563 /*
1564 * Output the results.
1565 */
1566
1567 XLALGPSTimeNow(&_process_table->end_time);
1568 output_results(options->output_filename, _process_table, _process_params_table, _search_summary_table, _sngl_burst_table);
1569
1570 /*
1571 * Final cleanup.
1572 */
1573
1574 if(rng)
1575 gsl_rng_free(rng);
1576
1577 XLALDestroyProcessTable(_process_table);
1578 XLALDestroyProcessParamsTable(_process_params_table);
1579 XLALDestroySearchSummaryTable(_search_summary_table);
1580 XLALDestroySnglBurstTable(_sngl_burst_table);
1582
1583 if(options->diagnostics)
1586
1588 exit(0);
1589}
int XLALButterworthREAL8TimeSeries(REAL8TimeSeries *series, PassBandParamStruc *params)
const char * program
#define __func__
int XLALStrToGPS(LIGOTimeGPS *t, const char *nptr, char **endptr)
const LALVCSInfo lalAppsVCSIdentInfo
Identable VCS and build information for LALApps.
lal_errhandler_t lal_errhandler
int LAL_ERR_EXIT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
void LALCheckMemoryLeaks(void)
int LALgetopt_long(int argc, char *const *argv, const char *options, const struct LALoption *long_options, int *opt_index)
int LALopterr
int LALoptind
char * LALoptarg
#define no_argument
#define required_argument
int XLALCloseLIGOLwXMLFile(LIGOLwXMLStream *xml)
LIGOLwXMLStream * XLALOpenLIGOLwXMLFile(const char *path)
int XLALWriteLIGOLwXMLSnglBurstTable(LIGOLwXMLStream *, const SnglBurst *)
int XLALWriteLIGOLwXMLProcessTable(LIGOLwXMLStream *, const ProcessTable *)
int XLALWriteLIGOLwXMLProcessParamsTable(LIGOLwXMLStream *, const ProcessParamsTable *)
int XLALWriteLIGOLwXMLSearchSummaryTable(LIGOLwXMLStream *, const SearchSummaryTable *)
int XLALLIGOLwHasTable(const char *filename, const char *table_name)
ProcessParamsTable * XLALProcessParamsTableFromLIGOLw(const char *filename)
ProcessTable * XLALProcessTableFromLIGOLw(const char *filename)
TimeSlide * XLALTimeSlideTableFromLIGOLw(const char *filename)
SearchSummaryTable * XLALSearchSummaryTableFromLIGOLw(const char *fileName)
SimBurst * XLALSimBurstTableFromLIGOLw(const char *filename)
void XLALDestroyProcessParamsTable(ProcessParamsTable *)
SearchSummaryTable * XLALCreateSearchSummaryTableRow(const ProcessTable *)
void XLALDestroyTimeSlideTable(TimeSlide *)
void XLALDestroySimBurstTable(SimBurst *head)
ProcessTable * XLALCreateProcessTableRow(void)
void XLALDestroyProcessTable(ProcessTable *)
int XLALPopulateProcessTable(ProcessTable *ptable, const char *program_name, const char *cvs_revision, const char *cvs_source, const char *cvs_date, long process_id)
ProcessParamsTable * XLALCreateProcessParamsTableRow(const ProcessTable *)
void XLALDestroySearchSummaryTable(SearchSummaryTable *)
void XLALDestroySnglBurstTable(SnglBurst *head)
long XLALSnglBurstAssignIDs(SnglBurst *head, long process_id, long event_id)
int XLALSnglBurstTableLength(SnglBurst *head)
int XLALCompareSnglBurstByPeakTimeAndSNR(const SnglBurst *const *a, const SnglBurst *const *b)
SnglBurst ** XLALSortSnglBurst(SnglBurst **head, int(*comparefunc)(const SnglBurst *const *, const SnglBurst *const *))
#define fprintf
double e
INT4 duration
Definition: blindinj.c:123
double flow
LIGOTimeGPS * XLALGPSTimeNow(LIGOTimeGPS *gpstime)
int XLALOverlappedSegmentsCommensurate(int target_length, int segment_length, int segment_shift)
int XLALEPGetTimingParameters(int window_length, int max_tile_length, double fractional_tile_stride, int *psd_length, int *psd_shift, int *window_shift, int *window_pad, int *tiling_length)
SnglBurst * XLALEPSearch(LIGOLwXMLStream *diagnostics, const REAL8TimeSeries *tseries, REAL8Window *window, double flow, double bandwidth, double confidence_threshold, double fractional_stride, double maxTileBandwidth, double maxTileDuration)
void XLALDestroyCache(LALCache *cache)
LALCache * XLALCacheImport(const char *fname)
LALTYPECODE
double REAL8
int32_t INT4
LAL_S_TYPE_CODE
LAL_D_TYPE_CODE
int XLALFrStreamClose(LALFrStream *stream)
LALFrStream * XLALFrStreamCacheOpen(LALCache *cache)
int XLALFrStreamSetMode(LALFrStream *stream, int mode)
LAL_FR_STREAM_VERBOSE_MODE
LAL_FR_STREAM_GAP
LALTYPECODE XLALFrStreamGetTimeSeriesType(const char *chname, LALFrStream *stream)
REAL8TimeSeries * XLALFrStreamReadREAL8TimeSeries(LALFrStream *stream, const char *chname, const LIGOTimeGPS *start, REAL8 duration, size_t lengthlimit)
REAL4TimeSeries * XLALFrStreamReadREAL4TimeSeries(LALFrStream *stream, const char *chname, const LIGOTimeGPS *start, REAL8 duration, size_t lengthlimit)
static const INT4 a
int XLALResampleREAL8TimeSeries(REAL8TimeSeries *series, REAL8 dt)
REAL8TimeSeries * XLALShrinkREAL8TimeSeries(REAL8TimeSeries *series, size_t first, size_t length)
void XLALDestroyREAL8TimeSeries(REAL8TimeSeries *series)
void XLALDestroyREAL4TimeSeries(REAL4TimeSeries *series)
REAL8TimeSeries * XLALCutREAL8TimeSeries(const REAL8TimeSeries *series, size_t first, size_t length)
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
const LALUnit lalStrainUnit
const LALUnit lalADCCountUnit
void XLALDestroyREAL8Window(REAL8Window *window)
REAL8Window * XLALCreateHannREAL8Window(UINT4 length)
#define XLAL_ERROR_NULL(...)
int int int XLALPrintInfo(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
#define XLAL_ERROR(...)
int XLALSetErrno(int errnum)
#define XLAL_REAL8_FAIL_NAN
#define XLAL_TRY(statement, errnum)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int int XLALPrintWarning(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int XLALPrintProgressBar(double)
XLAL_ENOMEM
XLAL_EDATA
XLAL_EFUNC
XLAL_EINVAL
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
int XLALGPSCmp(const LIGOTimeGPS *t0, const LIGOTimeGPS *t1)
REAL8 XLALGPSDiff(const LIGOTimeGPS *t1, const LIGOTimeGPS *t0)
LIGOTimeGPS * XLALINT8NSToGPS(LIGOTimeGPS *epoch, INT8 ns)
INT8 XLALGPSToINT8NS(const LIGOTimeGPS *epoch)
int XLALBurstInjectSignals(REAL8TimeSeries *h, const SimBurst *sim_burst, const TimeSlide *time_slide_table_head, const COMPLEX16FrequencySeries *response)
char name[LIGOMETA_SOURCE_MAX]
Definition: inspinj.c:561
int i
Definition: inspinj.c:596
type
size
c
interval
seed
start
int t
float atol
static int is_power_of_2(int x)
Definition: power.c:107
int main(int argc, char *argv[])
Definition: power.c:1318
static void gaussian_noise(REAL8TimeSeries *series, REAL8 rms, gsl_rng *rng)
Definition: power.c:1029
#define ADD_PROCESS_PARAM(process, type)
Definition: power.c:446
#define PROGRAM_NAME
Definition: power.c:73
static ProcessParamsTable ** add_process_param(ProcessParamsTable **proc_param, const ProcessTable *process, const char *type, const char *param, const char *value)
Definition: power.c:434
static int XLALEPConditionData(REAL8TimeSeries *series, REAL8 flow, REAL8 resampledeltaT, INT4 corruption)
Definition: power.c:969
static void options_free(struct options *options)
Definition: power.c:277
static size_t min(size_t a, size_t b)
Definition: power.c:93
static void print_missing_argument(const char *prog, const char *arg)
Definition: power.c:335
static void destroy_injection_document(struct injection_document *doc)
Definition: power.c:1062
static REAL8TimeSeries * get_time_series(const char *cachefilename, const char *chname, LIGOTimeGPS start, LIGOTimeGPS end, size_t lengthlimit)
Definition: power.c:861
static struct injection_document * load_injection_document(const char *filename)
Definition: power.c:1074
static REAL8TimeSeries * add_mdc_injections(const char *mdccachefile, const char *channel_name, REAL8TimeSeries *series)
Definition: power.c:1159
static SnglBurst ** analyze_series(SnglBurst **addpoint, REAL8TimeSeries *series, int psd_length, int psd_shift, struct options *options)
Definition: power.c:1201
static void print_usage(const char *program)
Definition: power.c:291
static struct options * options_new(void)
Definition: power.c:235
static int all_required_arguments_present(char *prog, struct LALoption *long_options, const struct options *options)
Definition: power.c:346
static struct options * parse_command_line(int argc, char *argv[], const ProcessTable *process, ProcessParamsTable **paramaddpoint)
Definition: power.c:455
static int double_is_power_of_2(double x)
Definition: power.c:118
static void print_bad_argument(const char *prog, const char *arg, const char *msg)
Definition: power.c:329
static int add_xml_injections(REAL8TimeSeries *h, const struct injection_document *injection_document)
Definition: power.c:1129
static void output_results(char *file, const ProcessTable *_process_table, const ProcessParamsTable *_process_params_table, const SearchSummaryTable *_search_summary_table, const SnglBurst *_sngl_burst_table)
Definition: power.c:1259
LALFrStreamState state
const char *const vcsDate
const char *const vcsStatus
const char *const vcsId
const char * name
INT4 gpsNanoSeconds
LIGOTimeGPS start_time
CHAR ifos[LIGOMETA_IFOS_MAX]
LIGOTimeGPS end_time
CHAR comment[LIGOMETA_COMMENT_MAX]
CHAR name[LALNameLength]
REAL4Sequence * data
LALUnit sampleUnits
LIGOTimeGPS epoch
REAL4 * data
REAL8Sequence * data
REAL8 * data
REAL8Sequence * data
CHAR comment[LIGOMETA_COMMENT_MAX]
LIGOTimeGPS out_start_time
LIGOTimeGPS in_end_time
CHAR ifos[LIGOMETA_IFOS_MAX]
LIGOTimeGPS in_start_time
LIGOTimeGPS out_end_time
struct tagSnglBurst * next
SearchSummaryTable * search_summary_table_head
Definition: power.c:1055
SimBurst * sim_burst_table_head
Definition: power.c:1058
ProcessTable * process_table_head
Definition: power.c:1053
int has_sim_burst_table
Definition: power.c:1057
ProcessParamsTable * process_params_table_head
Definition: power.c:1054
TimeSlide * time_slide_table_head
Definition: power.c:1056
Definition: join.c:30
double fractional_stride
Definition: power.c:214
int filter_corruption
Definition: power.c:190
char * channel_name
Definition: power.c:174
double maxTileBandwidth
Definition: power.c:212
double flow
Definition: power.c:211
LIGOTimeGPS gps_start
Definition: power.c:167
char * comment
Definition: power.c:222
int max_event_rate
Definition: power.c:224
char * mdc_channel_name
Definition: power.c:201
char * mdc_cache_filename
Definition: power.c:199
REAL8Window * window
Definition: power.c:215
int psd_length
Definition: power.c:152
double maxTileDuration
Definition: power.c:213
int window_pad
Definition: power.c:157
LIGOLwXMLStream * diagnostics
Definition: power.c:231
char * cache_filename
Definition: power.c:170
char ifo[3]
Definition: power.c:176
double bandwidth
Definition: power.c:210
LIGOTimeGPS gps_end
Definition: power.c:168
char * output_filename
Definition: power.c:225
double confidence_threshold
Definition: power.c:209
int max_series_length
Definition: power.c:179
unsigned long seed
Definition: binj.c:104
char * injection_filename
Definition: power.c:203
char * cal_cache_filename
Definition: power.c:172
int resample_rate
Definition: power.c:186
int window_shift
Definition: power.c:159
double high_pass
Definition: power.c:188
double noise_rms
Definition: power.c:197
int psd_shift
Definition: power.c:154
Definition: series.h:36
float * data
Definition: series.h:46
enum @1 epoch