From c004f38fcf6b911288c824986bac4c6e0f0b5736 Mon Sep 17 00:00:00 2001
From: Lee McCuller <Lee.McCuller@gmail.com>
Date: Thu, 24 May 2018 22:51:14 -0400
Subject: [PATCH] add ifo to plot_noises to fix displacement plotting

---
 gwinc/__main__.py | 3 ++-
 gwinc/gwinc.py    | 8 ++++----
 gwinc/plot.py     | 3 ++-
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/gwinc/__main__.py b/gwinc/__main__.py
index 2700f86b..e211b958 100644
--- a/gwinc/__main__.py
+++ b/gwinc/__main__.py
@@ -148,13 +148,14 @@ You may interact with plot using "plt." methods, e.g.:
 >>> plt.savefig("foo.pdf")
 ''')
         ipshell.enable_pylab()
-        ipshell.run_code("plot_noise(noises)")
+        ipshell.run_code("plot_noise(ifo, noises)")
         ipshell.run_code("plt.title('{}')".format(title))
         ipshell()
     elif args.plot:
         fig = plt.figure()
         ax = fig.add_subplot(1, 1, 1)
         plot_noise(
+            ifo,
             noises,
             ax = ax,
             displacement = args.displacement,
diff --git a/gwinc/gwinc.py b/gwinc/gwinc.py
index b2398421..e4af794a 100644
--- a/gwinc/gwinc.py
+++ b/gwinc/gwinc.py
@@ -98,7 +98,7 @@ def noise_calc(ifo, f):
             noises['Seismic'] *= Ndispl**2
             noises['Coating Thermo-Optic'] *= N_TO
         #noises['Mirror Thermal'] = noises['Substrate Brownian'] + noises['Coating Brownian'] + \
-        #                           noises['Substrate Thermo-Elastic'] + noises['Coating Thermo-Optic'] # total mirror thermal 
+        #                           noises['Substrate Thermo-Elastic'] + noises['Coating Thermo-Optic'] # total mirror thermal
 
     noises['Total'] = sum(noises[curve] for curve in noises)
     noises['Freq'] = f
@@ -150,7 +150,7 @@ def gwinc(freq, ifoin, source=None, fig=False, PRfixed=True):
         # Report input parameters
         if ifo.Optics.Type == 'DualCarrier_new':     #include the case for Dual carrier
             finesseA = 2*pi/ifo.Optics.ITM.TransmittanceD1
-            finesseB = 2*pi/ifo.Optics.ITM.TransmittanceD2 
+            finesseB = 2*pi/ifo.Optics.ITM.TransmittanceD2
             pbsA = ifo.Laser.PBSD1
             pbsB = ifo.Laser.PBSD2
             logging.info('Finesse for carrier A:  %7.2f' % finesseA)
@@ -185,7 +185,7 @@ def gwinc(freq, ifoin, source=None, fig=False, PRfixed=True):
                     np.hstack([(finesse*2/pi) * ifo.Optics.ITM.CoatingAbsorption,
                                (2 * ifo.Materials.MassThickness) * ifo.Optics.ITM.SubstrateAbsorption])
 
-        # Stefan's Mysterious TCS Section ~~~~ `~~ ` ` 324@#%@#$ !    
+        # Stefan's Mysterious TCS Section ~~~~ `~~ ` ` 324@#%@#$ !
         M = np.array([[ifo.TCS.s_cc, ifo.TCS.s_cs], [ifo.TCS.s_cs, ifo.TCS.s_ss]])
         S_uncorr = PowAbsITM.T*M*PowAbsITM
         TCSeff = 1-sqrt(ifo.TCS.SRCloss/S_uncorr)
@@ -201,6 +201,6 @@ def gwinc(freq, ifoin, source=None, fig=False, PRfixed=True):
             logging.info('BBH Inspiral Range:     ' + str(score.effr0bh) + ' Mpc/ z = ' + str(score.zHorizonBH))
             logging.info('Stochastic Omega: %4.1g Universes' % score.Omega)
 
-        plot.plot_noise(noises)
+        plot.plot_noise(ifo, noises)
 
     return score, noises, ifo
diff --git a/gwinc/plot.py b/gwinc/plot.py
index fb24b314..ab2dbb79 100644
--- a/gwinc/plot.py
+++ b/gwinc/plot.py
@@ -61,6 +61,7 @@ STYLE_MAP = {
 
 
 def plot_noise(
+        ifo,
         noises,
         ax = None,
         displacement = True,
@@ -80,7 +81,7 @@ def plot_noise(
             Update second axis according with first axis.
             """
             y1, y2 = ax.get_ylim()
-            ax_d.set_ylim(y1 * 4000, y2 * 4000)
+            ax_d.set_ylim(y1 * ifo.Infrastructure.Length, y2 * ifo.Infrastructure.Length)
             ax_d.figure.canvas.draw()
         ax.callbacks.connect("ylim_changed", convert_ax_h_to_d)
         ax_d.set_ylabel(u"Displacement [m/\u221AHz]")
-- 
GitLab