From 55930f230ab23113bd4c1a4c381b8d504e7139f7 Mon Sep 17 00:00:00 2001
From: Gregory Ashton <gregory.ashton@ligo.org>
Date: Mon, 10 Apr 2017 11:16:19 +0200
Subject: [PATCH] New examples on using the glitch_robust search

---
 examples/glitch_robust_search.py              | 54 +++++++++++++++++++
 ...litch_robust_search_make_simulated_data.py | 40 ++++++++++++++
 2 files changed, 94 insertions(+)
 create mode 100644 examples/glitch_robust_search.py
 create mode 100644 examples/glitch_robust_search_make_simulated_data.py

diff --git a/examples/glitch_robust_search.py b/examples/glitch_robust_search.py
new file mode 100644
index 0000000..86e16b7
--- /dev/null
+++ b/examples/glitch_robust_search.py
@@ -0,0 +1,54 @@
+import numpy as np
+import pyfstat
+
+outdir = 'data'
+label = 'glitch_robust_search'
+
+# Properties of the GW data
+tstart = 1000000000
+Tspan = 60 * 86400
+
+# Fixed properties of the signal
+F0s = 30
+F1s = -1e-8
+F2s = 0
+Alpha = np.radians(83.6292)
+Delta = np.radians(22.0144)
+
+tref = tstart + .5 * Tspan
+
+sftfilepath = 'data/*glitching_signal*sft'
+
+F0_width = np.sqrt(3)/(np.pi*Tspan)
+F1_width = np.sqrt(45/4.)/(np.pi*Tspan**2)
+DeltaF0 = 50 * F0_width
+DeltaF1 = 50 * F1_width
+
+theta_prior = {'F0': {'type': 'unif',
+                      'lower': F0s-DeltaF0,
+                      'upper': F0s+DeltaF0},
+               'F1': {'type': 'unif',
+                      'lower': F1s-DeltaF1,
+                      'upper': F1s+DeltaF1},
+               'F2': F2s,
+               'delta_F0': {'type': 'unif',
+                            'lower': 0,
+                            'upper': 1e-5},
+               'delta_F1': {'type': 'unif',
+                            'lower': -1e-11,
+                            'upper': 1e-11},
+               'tglitch': {'type': 'unif',
+                           'lower': tstart+0.1*Tspan,
+                           'upper': tstart+0.9*Tspan},
+               'Alpha': Alpha,
+               'Delta': Delta,
+               }
+
+search = pyfstat.MCMCGlitchSearch(
+    label=label, outdir=outdir, sftfilepath=sftfilepath,
+    theta_prior=theta_prior, nglitch=1, tref=tref, nsteps=[500, 500],
+    ntemps=3, log10temperature_min=-0.5, minStartTime=tstart,
+    maxStartTime=tstart+Tspan)
+search.run()
+search.plot_corner(label_offset=0.8, add_prior=True)
+search.print_summary()
diff --git a/examples/glitch_robust_search_make_simulated_data.py b/examples/glitch_robust_search_make_simulated_data.py
new file mode 100644
index 0000000..106edda
--- /dev/null
+++ b/examples/glitch_robust_search_make_simulated_data.py
@@ -0,0 +1,40 @@
+import numpy as np
+import pyfstat
+
+outdir = 'data'
+label = 'simulated_glitching_signal'
+
+# Properties of the GW data
+tstart = 1000000000
+Tspan = 60 * 86400
+
+tref = tstart + .5 * Tspan
+
+# Fixed properties of the signal
+F0s = 30
+F1s = -1e-8
+F2s = 0
+Alpha = np.radians(83.6292)
+Delta = np.radians(22.0144)
+h0 = 1e-25
+sqrtSX = 1e-24
+psi = -0.1
+phi = 0
+cosi = 0.5
+
+# Glitch properties
+dtglitch = 0.45 * Tspan  # time (in secs) after minStartTime
+dF0 = 5e-6
+dF1 = 1e-12
+
+
+detectors = 'H1'
+
+glitch_data = pyfstat.Writer(
+    label=label, outdir=outdir, tref=tref, tstart=tstart,
+    F0=F0s, F1=F1s, F2=F2s, duration=Tspan, Alpha=Alpha,
+    Delta=Delta, sqrtSX=sqrtSX, dtglitch=dtglitch,
+    h0=h0, cosi=cosi, phi=phi, psi=psi,
+    delta_F0=dF0, delta_F1=dF1, add_noise=True)
+
+glitch_data.make_data()
-- 
GitLab