#{{{ Import modules
import numpy as np
import matplotlib.pyplot as plt 
import fds
import os

pi = np.pi
#}}}


#{{{ HeatLink 1
os.chdir('/home/aso/exp/LCGT/2010/HeatLink/HeatLink1/Data')

data = np.loadtxt('TFX.dat')
frqX = data[:,0]
TFX = data[:,1]

data = np.loadtxt('TFY.dat')
frqY = data[:,0]
TFY = data[:,1]

data = np.loadtxt('TFZ.dat')
frqZ = data[:,0]
TFZ = data[:,1]

fig = plt.figure()
ax = fig.add_subplot(1,1,1)

ax.loglog(frqX, TFX, label='HeatLink 1 TFX', color=(1,0,0), lw=2)
ax.loglog(frqY, TFY, label='HeatLink 1 TFY', color=(0,1,0), lw=2)
ax.loglog(frqZ, TFZ, label='HeatLink 1 TFZ', color=(0,0,1), lw=2)

ax.set_ylim([1e-7,1e2])
ax.grid(True, color=(0.6,0.6,0.8),ls='-')
ax.grid(True, which='minor',color=(0.6,0.6,0.6),ls='--')
for label in ax.get_xticklabels() + ax.get_yticklabels():
      label.set_fontsize(16)
ax.legend(loc='best', ncol=1)

ax.set_xlabel('Frequency [Hz]', size=16)
ax.set_ylabel('Transmissivity',size=16)

ax.figure.set_size_inches(10,7, forward=True)
ax.set_position([0.13,0.13,0.8,0.8])

ax.figure.savefig('/home/aso/exp/LCGT/2010/HeatLink/Slides/Plots/HL1.png',\
                  format='png',dpi=200)


#}}}

#{{{ HeatLink 2
os.chdir('/home/aso/exp/LCGT/2010/HeatLink/HeatLink2/Data')

data = np.loadtxt('TFX.dat')
frqX = data[:,0]
TFX = data[:,1]

data = np.loadtxt('TFY.dat')
frqY = data[:,0]
TFY = data[:,1]

data = np.loadtxt('TFZ.dat')
frqZ = data[:,0]
TFZ = data[:,1]

fig = plt.figure()
ax = fig.add_subplot(1,1,1)

ax.loglog(frqX, TFX, label='HeatLink 2 TFX', color=(1,0,0), lw=2)
ax.loglog(frqY, TFY, label='HeatLink 2 TFY', color=(0,1,0), lw=2)
ax.loglog(frqZ, TFZ, label='HeatLink 2 TFZ', color=(0,0,1), lw=2)

ax.set_ylim([1e-7,1e2])
ax.grid(True, color=(0.6,0.6,0.8),ls='-')
ax.grid(True, which='minor',color=(0.6,0.6,0.6),ls='--')
for label in ax.get_xticklabels() + ax.get_yticklabels():
      label.set_fontsize(16)
ax.legend(loc='best', ncol=1)

ax.set_xlabel('Frequency [Hz]', size=16)
ax.set_ylabel('Transmissivity',size=16)

ax.figure.set_size_inches(10,7, forward=True)
ax.set_position([0.13,0.13,0.8,0.8])

ax.figure.savefig('/home/aso/exp/LCGT/2010/HeatLink/Slides/Plots/HL2.png',\
                  format='png',dpi=200)



#}}}

#{{{ HeatLink 2-2
os.chdir('/home/aso/exp/LCGT/2010/HeatLink/HeatLink2-2/Data')

data = np.loadtxt('TFX.dat')
frqX = data[:,0]
TFX = data[:,1]

data = np.loadtxt('TFY.dat')
frqY = data[:,0]
TFY = data[:,1]

data = np.loadtxt('TFZ.dat')
frqZ = data[:,0]
TFZ = data[:,1]

fig = plt.figure()
ax = fig.add_subplot(1,1,1)

ax.loglog(frqX, TFX, label='HeatLink 2-2 TFX', color=(1,0,0), lw=2)
ax.loglog(frqY, TFY, label='HeatLink 2-2 TFY', color=(0,1,0), lw=2)
ax.loglog(frqZ, TFZ, label='HeatLink 2-2 TFZ', color=(0,0,1), lw=2)

ax.set_ylim([1e-7,1e2])
ax.grid(True, color=(0.6,0.6,0.8),ls='-')
ax.grid(True, which='minor',color=(0.6,0.6,0.6),ls='--')
for label in ax.get_xticklabels() + ax.get_yticklabels():
      label.set_fontsize(16)
ax.legend(loc='best', ncol=1)

ax.set_xlabel('Frequency [Hz]', size=16)
ax.set_ylabel('Transmissivity',size=16)

ax.figure.set_size_inches(10,7, forward=True)
ax.set_position([0.13,0.13,0.8,0.8])

ax.figure.savefig('/home/aso/exp/LCGT/2010/HeatLink/Slides/Plots/HL2-2.png',\
                  format='png',dpi=200)

#}}}

#{{{ HeatLink 7
os.chdir('/home/aso/exp/LCGT/2010/HeatLink/HeatLink7/Data')

data = np.loadtxt('TFX.dat')
frqX = data[:,0]
TFX = data[:,1]

data = np.loadtxt('TFY.dat')
frqY = data[:,0]
TFY = data[:,1]

data = np.loadtxt('TFZ.dat')
frqZ = data[:,0]
TFZ = data[:,1]

fig = plt.figure()
ax = fig.add_subplot(1,1,1)

ax.loglog(frqX, TFX, label='HeatLink 7 TFX', color=(1,0,0), lw=2)
ax.loglog(frqY, TFY, label='HeatLink 7 TFY', color=(0,1,0), lw=2)
ax.loglog(frqZ, TFZ, label='HeatLink 7 TFZ', color=(0,0,1), lw=2)

ax.set_ylim([1e-7,1e2])
ax.grid(True, color=(0.6,0.6,0.8),ls='-')
ax.grid(True, which='minor',color=(0.6,0.6,0.6),ls='--')
for label in ax.get_xticklabels() + ax.get_yticklabels():
      label.set_fontsize(16)
ax.legend(loc='best', ncol=1)

ax.set_xlabel('Frequency [Hz]', size=16)
ax.set_ylabel('Transmissivity',size=16)

ax.figure.set_size_inches(10,7, forward=True)
ax.set_position([0.13,0.13,0.8,0.8])

ax.figure.savefig('/home/aso/exp/LCGT/2010/HeatLink/Slides/Plots/HL7.png',\
                  format='png',dpi=200)

#}}}

#{{{ HeatLink 7 complex
os.chdir('/home/aso/exp/LCGT/2010/HeatLink/HeatLink7/Data')

data = np.loadtxt('TFXreal.dat', comments='%')
frqX = data[:,0]
TFXr = data[:,1]

data = np.loadtxt('TFXimag.dat', comments='%')
frqX = data[:,0]
TFXi = data[:,1]

TFXc = TFXr+1j*TFXi


data = np.loadtxt('TFYreal.dat')
frqY = data[:,0]
TFYr = data[:,1]

data = np.loadtxt('TFYimag.dat')
frqY = data[:,0]
TFYi = data[:,1]

TFYc = TFYr+1j*TFYi

data = np.loadtxt('TFZreal.dat')
frqZ = data[:,0]
TFZr = data[:,1]

data = np.loadtxt('TFZimag.dat')
frqZ = data[:,0]
TFZi = data[:,1]

TFZc = TFZr+1j*TFZi

fig = plt.figure()
ax = fig.add_subplot(1,1,1)

ax.loglog(frqX, np.abs(TFXc), label='HeatLink 7 TFX', color=(1,0,0), lw=2)
ax.loglog(frqY, np.abs(TFYc), label='HeatLink 7 TFY', color=(0,1,0), lw=2)
ax.loglog(frqZ, np.abs(TFZc), label='HeatLink 7 TFZ', color=(0,0,1), lw=2)

ax.set_ylim([1e-7,1e2])
ax.grid(True, color=(0.6,0.6,0.8),ls='-')
ax.grid(True, which='minor',color=(0.6,0.6,0.6),ls='--')
for label in ax.get_xticklabels() + ax.get_yticklabels():
      label.set_fontsize(16)
ax.legend(loc='best', ncol=1)

ax.set_xlabel('Frequency [Hz]', size=16)
ax.set_ylabel('Transmissivity',size=16)

ax.figure.set_size_inches(10,7, forward=True)
ax.set_position([0.13,0.13,0.8,0.8])

ax.figure.savefig('/home/aso/exp/LCGT/2010/HeatLink/Slides/Plots/HL7.png',\
                  format='png',dpi=200)


#}}}

#{{{ SAS

os.chdir('/home/aso/Desktop/aso/exp/LCGT/2010/HeatLink/Suspension/data')

data = np.loadtxt('TotalX.dat', delimiter=',')
frq = data[:,0]
TFX = data[:,1]+1j*data[:,2]
seisX = data[:,3]
gnd = data[:,4]

data = np.loadtxt('HLonlyX.dat', delimiter=',')
frq = data[:,0]
TFHLX = data[:,1]+1j*data[:,2]
seisHLX = data[:,3]
gnd = data[:,4]

data = np.loadtxt('TotalY.dat', delimiter=',')
frq = data[:,0]
TFY = data[:,1]+1j*data[:,2]
seisY = data[:,3]
gnd = data[:,4]

data = np.loadtxt('HLonlyY.dat', delimiter=',')
frq = data[:,0]
TFHLY = data[:,1]+1j*data[:,2]
seisHLY = data[:,3]
gnd = data[:,4]

data = np.loadtxt('TotalZ.dat', delimiter=',')
TFZ = data[:,1]+1j*data[:,2]
seisZ = data[:,3]


data = np.loadtxt('HLonlyZ.dat', delimiter=',')
TFHLZ = data[:,1]+1j*data[:,2]
seisHLZ = data[:,3]

fig = plt.figure()
ax = fig.add_subplot(1,1,1)

ax.loglog(frq, seisX, label='Mirror motion Total X', color=(1,0.3,0.3), lw=2)
ax.loglog(frq, seisHLX, label='Mirror motion HL X', color=(0.6,0,0), ls='--',lw=2)
ax.loglog(frq, seisY, label='Mirror motion Total Y', color=(0.3,1,0.3), lw=2)
ax.loglog(frq, seisHLY, label='Mirror motion HL Y', color=(0,0.6,0), ls='--',lw=2)
ax.loglog(frq, seisZ, label='Mirror motion Total Z', color=(0.3,0.3,1), lw=2)
ax.loglog(frq, seisHLZ, label='Mirror motion HL Z', color=(0,0,0.6), ls='--',lw=2)

ax.loglog(frq, gnd, label='Ground', color=(0,0,0), lw=2)

#ax.set_ylim([1e-7,1e2])
ax.set_xlim([1e-2,20])
ax.grid(True, color=(0.6,0.6,0.8),ls='-')
ax.grid(True, which='minor',color=(0.6,0.6,0.6),ls='--')
for label in ax.get_xticklabels() + ax.get_yticklabels():
      label.set_fontsize(16)
ax.legend(loc='best', ncol=1)

ax.set_xlabel('Frequency [Hz]', size=16)
ax.set_ylabel('Vibration [$\mathsf{m/\sqrt{Hz}}$]',size=16)

ax.figure.set_size_inches(10,7, forward=True)
ax.set_position([0.13,0.13,0.8,0.8])

ax.figure.savefig('/home/aso/exp/LCGT/2010/HeatLink/Slides/Plots/SAS.png',\
                  format='png',dpi=200)


#}}}

#{{{ Sensitivity

data = np.loadtxt('TotalXModel1.dat', delimiter=',')
frq = data[:,0]
seisX = data[:,3]
gnd1 = data[:,4]

data = np.loadtxt('TotalYModel1.dat', delimiter=',')
seisY = data[:,3]

data = np.loadtxt('TotalZModel1.dat', delimiter=',')
TFZ = data[:,1]+1j*data[:,2]
seisZ = data[:,3]

data = np.loadtxt('/home/aso/exp/LCGT/IFO/NoiseBudget/Somiya/data/BRSETotal.dat')
frq2 = data[:,0]
BRSE = data[:,1]

L = 3000.0
fig = plt.figure()
ax = fig.add_subplot(1,1,1)

ax.loglog(frq, 2*seisX/L, label='Inline seismic', color=(1,0.3,0.3), lw=2)
ax.loglog(frq, 2*seisY/L/100, label='Perpendicular seismic', color=(0.3,1,0.3), lw=2)
ax.loglog(frq, 2*seisZ/L/100, label='Vertical seismic', color=(0.3,0.3,1), lw=2)
ax.loglog(frq2, BRSE, label='Design sensitivity', color=(0,0,0), lw=2)

ax.set_ylim([1e-30,1e-12])
ax.set_xlim([1e-1,100])
ax.grid(True, color=(0.6,0.6,0.8),ls='-')
ax.grid(True, which='minor',color=(0.6,0.6,0.6),ls='--')
for label in ax.get_xticklabels() + ax.get_yticklabels():
      label.set_fontsize(16)
ax.legend(loc='best', ncol=1)

ax.set_xlabel('Frequency [Hz]', size=16)
ax.set_ylabel('Strain [$\mathsf{1/\sqrt{Hz}}$]',size=16)

ax.figure.set_size_inches(10,7, forward=True)
ax.set_position([0.13,0.13,0.8,0.8])

ax.figure.savefig('/home/aso/exp/LCGT/2010/HeatLink/Slides/Plots/SeismicNoise.png',\
                  format='png',dpi=200)




#}}}

#{{{ Sensitivity 2
#If the seismic goes down by 1/f^2

data = np.loadtxt('TotalXModel2.dat', delimiter=',')
frq = data[:,0]
seisX = data[:,3]
gnd2 = data[:,4]

data = np.loadtxt('TotalYModel2.dat', delimiter=',')
seisY = data[:,3]

data = np.loadtxt('TotalZModel2.dat', delimiter=',')
TFZ = data[:,1]+1j*data[:,2]
seisZ = data[:,3]

data = np.loadtxt('/home/aso/exp/LCGT/IFO/NoiseBudget/Somiya/data/BRSETotal.dat')
frq2 = data[:,0]
BRSE = data[:,1]

L = 3000.0
fig = plt.figure()
ax = fig.add_subplot(1,1,1)

ax.loglog(frq, 2*seisX/L, label='Inline seismic', color=(1,0.3,0.3), lw=2)
ax.loglog(frq, 2*seisY/L/100, label='Perpendicular seismic', color=(0.3,1,0.3), lw=2)
ax.loglog(frq, 2*seisZ/L/100, label='Vertical seismic', color=(0.3,0.3,1), lw=2)
ax.loglog(frq2, BRSE, label='Design sensitivity', color=(0,0,0), lw=2)

ax.set_ylim([1e-30,1e-12])
ax.set_xlim([1e-1,100])
ax.grid(True, color=(0.6,0.6,0.8),ls='-')
ax.grid(True, which='minor',color=(0.6,0.6,0.6),ls='--')
for label in ax.get_xticklabels() + ax.get_yticklabels():
      label.set_fontsize(16)
ax.legend(loc='best', ncol=1)

ax.set_xlabel('Frequency [Hz]', size=16)
ax.set_ylabel('Strain [$\mathsf{1/\sqrt{Hz}}$]',size=16)

ax.figure.set_size_inches(10,7, forward=True)
ax.set_position([0.13,0.13,0.8,0.8])

ax.figure.savefig('/home/aso/exp/LCGT/2010/HeatLink/Slides/Plots/SeismicNoise2.png',\
                  format='png',dpi=200)

#}}}

#{{{ Sensitivity 3
#If the seismic goes down by 1/f^2

data = np.loadtxt('TotalXModel2.dat', delimiter=',')
frq = data[:,0]
seisX = data[:,3]
gnd2 = data[:,4]

data = np.loadtxt('TotalYModel2.dat', delimiter=',')
seisY = data[:,3]

data = np.loadtxt('TotalZModel2.dat', delimiter=',')
TFZ = data[:,1]+1j*data[:,2]
seisZ = data[:,3]

data = np.loadtxt('/home/aso/exp/LCGT/IFO/NoiseBudget/Somiya/data/BRSETotal.dat')
frq2 = data[:,0]
BRSE = data[:,1]

L = 3000.0
fig = plt.figure()
ax = fig.add_subplot(1,1,1)

ax.loglog(frq, 2*seisX/L/100, label='Perpendicular seismic', color=(1,0.3,0.3), lw=2)
ax.loglog(frq, 2*seisY/L, label='Inline seismic', color=(0.3,1,0.3), lw=2)
ax.loglog(frq, 2*seisZ/L/100, label='Vertical seismic', color=(0.3,0.3,1), lw=2)
ax.loglog(frq2, BRSE, label='Design sensitivity', color=(0,0,0), lw=2)

ax.set_ylim([1e-30,1e-12])
ax.set_xlim([1e-1,100])
ax.grid(True, color=(0.6,0.6,0.8),ls='-')
ax.grid(True, which='minor',color=(0.6,0.6,0.6),ls='--')
for label in ax.get_xticklabels() + ax.get_yticklabels():
      label.set_fontsize(16)
ax.legend(loc='best', ncol=1)

ax.set_xlabel('Frequency [Hz]', size=16)
ax.set_ylabel('Strain [$\mathsf{1/\sqrt{Hz}}$]',size=16)

ax.figure.set_size_inches(10,7, forward=True)
ax.set_position([0.13,0.13,0.8,0.8])

ax.figure.savefig('/home/aso/exp/LCGT/2010/HeatLink/Slides/Plots/SeismicNoise3.png',\
                  format='png',dpi=200)

#}}}






























