gstlal-inspiral  0.4.2
 All Classes Namespaces Files Functions Variables Pages
gstlal_inspiral_marginalize_likelihoods_online
1 #!/bin/bash
2 #
3 # Copyright (C) 2012,2014 Kipp Cannon
4 #
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 # Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 
19 ## @file gstlal_inspiral_marginalize_likelihoods_online
20 #
21 # This program runs gstlal_inspiral_marginalize_likelihood in a while True
22 # loop; See gstlal_inspiral_marginalize_likelihoods_online for more details
23 #
24 #
25 # This program is not meant to be executed standalone by a user. It should be
26 # part of a DAG managing a running gstlal_inspiral online analysis.
27 #
28 # This program takes two or more arguments;
29 #
30 # - The path of the output file name
31 # - One or more root URLs of the web servers from which to retrieve event
32 # parameter distribution data (e.g., "http://node001.ligo.caltech.edu")
33 #
34 # This program queries each running gstlal_inspiral job via the URL,
35 # computes PDFs of the likelihood ratio ranking statistics from the
36 # parameter distribution data, then marginalizes the ranking statistic PDFs
37 # across jobs and writes the result to the given output file.
38 #
39 # It continues to do that in an infinite loop with a 10 minute pause on
40 # each iteration. Files are not overwritten directly, but rather via a
41 # temporary file and mv operation to ensure that no files are corrupted in
42 # a POSIX file environment.
43 #
44 
45 #
46 # get the output file name
47 #
48 
49 OUTPUT="${1}"
50 shift
51 
52 #
53 # path on the web server to the trigger parameter file
54 #
55 
56 LIKELIHOOD_PATH="likelihood.xml"
57 
58 #
59 # pause for each iteration (seconds)
60 #
61 
62 SLEEP="600"
63 
64 #
65 # loop forever
66 #
67 
68 while true ; do
69  echo "... sleeping for ${SLEEP} seconds ..."
70  sleep ${SLEEP}
71  RANKING_PDF_FILES=
72  for REG in "$@" ; do
73  SERVER=$(cat ${REG})
74  RANKING_PDF_FILE=$(mktemp)
75  RANKING_PDF_FILES="${RANKING_PDF_FILES} ${RANKING_PDF_FILE}"
76  gstlal_inspiral_calc_rank_pdfs --ranking-stat-samples 100000 --verbose --output ${RANKING_PDF_FILE} --samples-file ${SERVER}${LIKELIHOOD_PATH} ${SERVER}${LIKELIHOOD_PATH} || break
77  done || break
78  gstlal_inspiral_marginalize_likelihood --verbose --output ${OUTPUT}.next.gz ${RANKING_PDF_FILES} || break
79  rm -vf ${RANKING_PDF_FILES}
80  mv -f ${OUTPUT}.next.gz ${OUTPUT} || break
81 done
82 
83 #
84 # this program ends its an error, always, so condor will restart it
85 #
86 
87 exit 1