From 36911fa4d25c9cfb8664493af891444db8a72d49 Mon Sep 17 00:00:00 2001
From: "gregory.ashton" <gregory.ashton@ligo.org>
Date: Tue, 20 Dec 2016 11:41:19 +0100
Subject: [PATCH] Adds macros for NoiseOnly study and forgotten files

---
 .../AllSkyMCNoiseOnly_repeat.sh               | 11 +++++
 Paper/AllSkyMCNoiseOnly/plot_data.py          |  4 ++
 Paper/DirectedMCNoiseOnly/plot_data.py        | 44 +++++++++++++++++++
 Paper/macros.tex                              |  2 +
 4 files changed, 61 insertions(+)
 create mode 100755 Paper/AllSkyMCNoiseOnly/AllSkyMCNoiseOnly_repeat.sh
 create mode 100644 Paper/DirectedMCNoiseOnly/plot_data.py
 create mode 100644 Paper/macros.tex

diff --git a/Paper/AllSkyMCNoiseOnly/AllSkyMCNoiseOnly_repeat.sh b/Paper/AllSkyMCNoiseOnly/AllSkyMCNoiseOnly_repeat.sh
new file mode 100755
index 0000000..ab5264c
--- /dev/null
+++ b/Paper/AllSkyMCNoiseOnly/AllSkyMCNoiseOnly_repeat.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+. /home/gregory.ashton/lalsuite-install/etc/lalapps-user-env.sh
+export PATH="/home/gregory.ashton/anaconda2/bin:$PATH"
+export MPLCONFIGDIR=/home/gregory.ashton/.config/matplotlib
+
+for ((n=0;n<90;n++))
+do
+/home/gregory.ashton/anaconda2/bin/python generate_data.py "$1" /local/user/gregory.ashton --no-template-counting --no-interactive
+done
+cp /local/user/gregory.ashton/NoiseOnlyMCResults_"$1".txt $(pwd)/CollectedOutput
diff --git a/Paper/AllSkyMCNoiseOnly/plot_data.py b/Paper/AllSkyMCNoiseOnly/plot_data.py
index ed0bd07..fd6c56a 100644
--- a/Paper/AllSkyMCNoiseOnly/plot_data.py
+++ b/Paper/AllSkyMCNoiseOnly/plot_data.py
@@ -38,3 +38,7 @@ ax.set_xlabel('$\widetilde{2\mathcal{F}}$')
 ax.set_xlim(0, 60)
 fig.tight_layout()
 fig.savefig('allsky_noise_twoF_histogram.png')
+
+from latex_macro_generator import write_to_macro
+write_to_macro('AllSkyMCNoiseOnlyMaximum', '{:1.1f}'.format(np.max(df.twoF)),
+               '../macros.tex')
diff --git a/Paper/DirectedMCNoiseOnly/plot_data.py b/Paper/DirectedMCNoiseOnly/plot_data.py
new file mode 100644
index 0000000..8d99fd9
--- /dev/null
+++ b/Paper/DirectedMCNoiseOnly/plot_data.py
@@ -0,0 +1,44 @@
+import matplotlib.pyplot as plt
+import pandas as pd
+import numpy as np
+import os
+from tqdm import tqdm
+from oct2py import octave
+import glob
+
+filenames = glob.glob("CollectedOutput/*.txt")
+
+plt.style.use('paper')
+
+Tspan = 100 * 86400
+
+
+def maxtwoFinNoise(twoF, Ntrials):
+    F = twoF/2.0
+    alpha = (1 + F)*np.exp(-F)
+    a = Ntrials/2.0*F*np.exp(-F)
+    b = (1 - alpha)**(Ntrials-1)
+    return a*b
+
+
+df_list = []
+for fn in filenames:
+    df = pd.read_csv(
+        fn, sep=' ', names=['dF0', 'dF1', 'twoF', 'runTime'])
+    df['CLUSTER_ID'] = fn.split('_')[1]
+    df_list.append(df)
+df = pd.concat(df_list)
+print 'Number of samples = ', len(df)
+
+fig, ax = plt.subplots()
+ax.hist(df.twoF, bins=50, histtype='step', color='k', normed=True, linewidth=1)
+twoFsmooth = np.linspace(0, df.twoF.max(), 100)
+# ax.plot(twoFsmooth, maxtwoFinNoise(twoFsmooth, 2e3), '-r')
+ax.set_xlabel('$\widetilde{2\mathcal{F}}$')
+ax.set_xlim(0, 60)
+fig.tight_layout()
+fig.savefig('directed_noise_twoF_histogram.png')
+
+from latex_macro_generator import write_to_macro
+write_to_macro('DirectedMCNoiseOnlyMaximum', '{:1.1f}'.format(np.max(df.twoF)),
+               '../macros.tex')
diff --git a/Paper/macros.tex b/Paper/macros.tex
new file mode 100644
index 0000000..ef55d54
--- /dev/null
+++ b/Paper/macros.tex
@@ -0,0 +1,2 @@
+\def\DirectedMCNoiseOnlyMaximum{52.4}
+\def\AllSkyMCNoiseOnlyMaximum{59.8}
-- 
GitLab