From aa3ad0b9543bb42e1b824e699474e0cb2042a1cc Mon Sep 17 00:00:00 2001
From: Grant Meadors <gdmeadors@gmail.com>
Date: Wed, 15 May 2013 09:26:31 -0700
Subject: [PATCH] Added a nice python plotter to display the ratio of before
 and after SNR calculated by Ian Harry from iHope CBC data

---
 AMPSplotSNR.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100755 AMPSplotSNR.py

diff --git a/AMPSplotSNR.py b/AMPSplotSNR.py
new file mode 100755
index 0000000..20b136c
--- /dev/null
+++ b/AMPSplotSNR.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+import os, re, sys
+import matplotlib as matplotlib
+matplotlib.use('Agg')
+import matplotlib.pyplot as plt
+import matplotlib.cm as cm
+import numpy as np
+
+# Generate scatterplots of the AMPS and LDAS SNR
+# Using the data set of recovered iHope S6 hardware
+# Injections generated by Ian Harry
+# Description of methods:
+# https://www.lsc-group.phys.uwm.edu/ligovirgo/cbcnote/S6Plan/130422155409DQandVetoesHWInjs_in_AMPS_data
+# Location of files on the CIT cluster:
+# /home/spxiwh/S6/AMPS-STRAIN/hardware_inj_test/dump_snr/[H,L]1-HWINJS_WITH_SNR.dat
+# 02013-05-15 (JD 2456428)
+# Grant David Meadors
+# g m e a d o r s @  u m i c h . e d u
+
+def scatterplotter(observatory):
+    print 'Plotting SNR scatterplot for this observatory:'
+    print observatory
+
+    # Assume that the file is in the local directory:
+    # Since this is S6 data, the detector will be number 1,
+    # Either H1 or L1
+    SNRfile = observatory + '1-HWINJS_WITH_SNR.dat'
+    LDAS, AMPS = np.loadtxt(SNRfile, delimiter = ' ', usecols=(0, 1), unpack=True)
+    plt.figure()
+    p1 = plt.scatter(LDAS, AMPS)
+    plt.grid(True)
+    plt.xlabel('SNR before feedforward (LDAS)')
+    plt.ylabel('SNR after feedforward (AMPS)')
+    plt.title('iHope SNR after vs before feedforward')
+    plt.savefig('AMPSplotSNR.png')
+    plt.savefig('AMPSplotSNR.pdf')
+    plt.close()
+
+    plt.figure()
+    p2 = plt.scatter(LDAS, (AMPS-LDAS)/LDAS)
+    plt.grid(True)
+    plt.xlabel('SNR before feedforward (LDAS)')
+    plt.ylabel('SNR ratio: (AMPS-LDAS)/LDAS')
+    plt.title('iHope SNR (after-before)/before feedforward')
+    plt.savefig('AMPSratioSNR.png')
+    plt.savefig('AMPSratioSNR.pdf')
+    plt.close()
+
+scatterplotter(sys.argv[1])
-- 
GitLab