From 3e85a32b0efb092828b2ac5cdaa1b5fdb3080ff7 Mon Sep 17 00:00:00 2001
From: Ansel Neunzert <ansel.neunzert@ligo.org>
Date: Mon, 24 Oct 2016 10:31:59 -0700
Subject: [PATCH] Added the comb finding bash script for daily summaries

---
 autoCombFind.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100755 autoCombFind.sh

diff --git a/autoCombFind.sh b/autoCombFind.sh
new file mode 100755
index 0000000..806a5a7
--- /dev/null
+++ b/autoCombFind.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+source /home/aneunzert/gwpybokeh/bin/activate
+
+TEMP_DIR=~/public_html/latest/
+CONSEC=4
+
+echo "Removing old file from temp directory..."
+
+rm $TEMP_DIR/*
+
+echo "Finding latest spectrum file and copying to temp directory..."
+RECENTSPECT=$(ls ~/public_html/comb_plots/combCheck*_fscan_cumulsince_2016-09-18/* | grep dat_ | tail -n1)
+echo $RECENTSPECT > $TEMP_DIR/foundcombs.txt
+cp $RECENTSPECT $TEMP_DIR
+RECENTSPECT=$(ls -t $TEMP_DIR/* | head -n1)
+
+echo "Running comb finding algorithm..."
+COMBSTATS=$(python findComb.py --inputfile=$RECENTSPECT --knowncombfile="preER10combs.txt" --fmin 0 --fmax 100 --spacingmin 0.3 --spacingmax 20 --scalerange 10 --nmostcommoncombs 1000 --ntoppeaks 1000 --consecutive $CONSEC --checkrange 1 --printmaxstat True --printmax 10 | tail -n2)
+
+TAGCOMBS=$(echo "$COMBSTATS" | tail -n1)
+MAXSTAT=$(echo "$COMBSTATS" | head -n1)
+
+echo $TAGCOMBS >> $TEMP_DIR/foundcombs.txt
+echo $MAXSTAT >> $TEMP_DIR/foundcombs.txt
+
+MAXSTAT=${MAXSTAT%.*}
+if [ $MAXSTAT -gt 100 ]
+then
+	ALERTMSG="<span style='background-color:red!important;' id='alert'>High</span>"
+elif [ $MAXSTAT -gt 10 ]
+then
+	ALERTMSG="<span style='background-color:orange;!important;' id='alert'>Moderate</span>"
+else
+	ALERTMSG="<span style='background-color:limegreen;!important;' id='alert'>Low</span>"
+fi
+
+SUMMARY="<h2> Unidentified comb alerts </h2>
+<p>Probability of unidentified comb(s) in the latest cumulative spectrum: ${ALERTMSG}
+<br>Plot showing the top comb candidates (max 10): <span><a href='https://ldas-jobs.ligo-wa.caltech.edu/~aneunzert/latest/H1:LSC-DARM_OUT_DQ.html' target='_blank'>here</a></span>" 
+
+echo "$SUMMARY" > $TEMP_DIR/summary.txt
+
+echo "Plotting..."
+
+python chplot.py --truefcutoff=True --fmin 0 --fmax 100 --consecutive $CONSEC --checkrange 1 --overwrite=True --scalerange=0 --knowncombfile="preER10combs.txt" --tagcombs $TAGCOMBS --inputfolder $TEMP_DIR
+
+HTMLFILE=$(ls $TEMP_DIR/*.html)
+
+echo "Plot successfully generated at $HTMLFILE"
-- 
GitLab