Maintenance will be performed on git.ligo.org, chat.ligo.org, containers.ligo.org, and docs.ligo.org on Tuesday 7th July 2020 starting at approximately 10am PDT and lasting for around 15 minutes. There will be a short period of downtime towards the end of the maintenance window. Please direct any comments, questions, or concerns to uwm-help@cgca.uwm.edu.

Commit 30a466f1 authored by Anchal Gupta's avatar Anchal Gupta

Added option of plotting noise budget in displacement units

parent 8c175895
......@@ -971,6 +971,30 @@ class noiseBudget:
totalPTPSD_lb, totalPTPSD_ub]
return totalPTPSD
def calculateTotalEstNoise(self):
totalPSD = np.zeros(len(self.freq))
totalPSDlb = np.zeros(len(self.freq))
totalPSDub = np.zeros(len(self.freq))
for key in self.calcPSDList:
if key in self.PSDList:
PSD = self.PSDList[key][0]
if isinstance(PSD[0], unc.core.AffineScalarFunc):
totalPSD = totalPSD + unpnv(PSD)
totalPSDlb = totalPSDlb + unpnv(PSD) - unpstd(PSD)
totalPSDub = totalPSDub + unpnv(PSD) + unpstd(PSD)
elif len(self.PSDList[key]) == 5:
totalPSD = totalPSD + PSD
totalPSDlb = totalPSDlb + self.PSDList[key][3]
totalPSDub = totalPSDub + self.PSDList[key][4]
else:
totalPSD = totalPSD + PSD
totalPSDlb = totalPSDlb + PSD
totalPSDub = totalPSDub + PSD
self.PSDList['total'] = [totalPSD, self.freq,
'Total expected noise',
totalPSDlb, totalPSDub]
return totalPSD
# :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Plotting Functions:
def plotOptThickProfile(self, **kwargs):
......@@ -1023,7 +1047,7 @@ class noiseBudget:
return fig
def plotPSD(self, plotList=None, title=None, filename=None, doTotal=True,
savePlot=True, **kwargs):
savePlot=True, displacementUnits=False, **kwargs):
'''
This function plots the PSDs from the PSDList.
Input arguments:
......@@ -1032,6 +1056,8 @@ class noiseBudget:
title: Title of the plot
filename: If provided, figure will be saved with this filename
doTotal: If true, total expected noise is calculated and plotted.
savePlot: If true, plot will be saved.
displacementUnits: If true., units of m/rtHz will be used.
**kwargs: Any arguments (color, linestyle, label, etc.) to pass
to the plot
Output: Handle to the figure generated.
......@@ -1039,39 +1065,27 @@ class noiseBudget:
if plotList is None:
plotList = self.calcPSDList
if title is None:
title = 'Frequency Noise ASD '+self.Name
if displacementUnits:
fac = 1/self.fConv.nominal_value
ylabel = r'ASD of Coating Displacement Noise $[m/Hz^{1/2}]$'
if title is None:
title = 'Coating Displacement Noise ASD '+self.Name
else:
fac = 1
ylabel = r'ASD of beat note frequency $[Hz/Hz^{1/2}]$'
if title is None:
title = 'Frequency Noise ASD '+self.Name
if doTotal:
self.calculateTotalEstNoise()
if 'total' not in plotList:
plotList += ['total']
cList = ['#800000', '#9a6324', '#808000', '#000075', '#e6194b',
'#f58231', '#3cb44b', '#4363d8', '#911eb4', '#f032e6']
cno = len(cList)
lsList = ['-', '--', '-.']
lno = len(lsList)
# Creating total expected noise
if doTotal:
totalPSD = np.zeros(len(self.freq))
totalPSDlb = np.zeros(len(self.freq))
totalPSDub = np.zeros(len(self.freq))
for key in self.calcPSDList:
if key in self.PSDList:
PSD = self.PSDList[key][0]
if isinstance(PSD[0], unc.core.AffineScalarFunc):
totalPSD = totalPSD + unpnv(PSD)
totalPSDlb = totalPSDlb + unpnv(PSD) - unpstd(PSD)
totalPSDub = totalPSDub + unpnv(PSD) + unpstd(PSD)
elif len(self.PSDList[key]) == 5:
totalPSD = totalPSD + PSD
totalPSDlb = totalPSDlb + self.PSDList[key][3]
totalPSDub = totalPSDub + self.PSDList[key][4]
else:
totalPSD = totalPSD + PSD
totalPSDlb = totalPSDlb + PSD
totalPSDub = totalPSDub + PSD
self.PSDList['total'] = [totalPSD, self.freq,
'Total expected noise',
totalPSDlb, totalPSDub]
if 'total' not in plotList:
plotList += ['total']
psdPlot = plt.figure(figsize=(16, 12))
ax = psdPlot.add_subplot(111)
for ii, psd in enumerate(plotList):
......@@ -1089,8 +1103,8 @@ class noiseBudget:
np.ones(len(PSD))*1e-12],
axis=0))
fillCieling = np.sqrt(unpnv(PSD) + unpstd(PSD))
ax.fill_between(self.PSDList[psd][1], fillFloor,
fillCieling, alpha=0.2,
ax.fill_between(self.PSDList[psd][1], fillFloor * fac,
fillCieling * fac, alpha=0.2,
color=color,
lw=0, **kwargs)
else:
......@@ -1100,11 +1114,11 @@ class noiseBudget:
np.ones(len(ASD))*1e-12],
axis=0))
fillCieling = np.sqrt(self.PSDList[psd][4])
ax.fill_between(self.PSDList[psd][1], fillFloor,
fillCieling, alpha=0.2,
ax.fill_between(self.PSDList[psd][1], fillFloor * fac,
fillCieling * fac, alpha=0.2,
color=color,
lw=0, **kwargs)
ax.loglog(self.PSDList[psd][1], ASD,
ax.loglog(self.PSDList[psd][1], ASD * fac,
label=self.PSDList[psd][2],
alpha=0.8, c=color,
linestyle=lineStyle,
......@@ -1112,12 +1126,12 @@ class noiseBudget:
else:
print(psd+' has not been calculated yet.')
ax.set_xlabel('Frequency [Hz]')
ax.set_ylabel(r'ASD of beat note frequency $[Hz/Hz^{1/2}]$')
ax.set_ylabel(ylabel)
ax.legend(loc='best', fontsize=18, numpoints=2, borderpad=0.1,
ncol=2, columnspacing=0.5, framealpha=0.7)
ax.grid(linestyle='solid', which='major', alpha=0.75)
ax.grid(linestyle='dashed', which='minor', alpha=0.25)
ylimits = [6e-5, 2e3]
ylimits = [6e-5 * fac, 2e3 * fac]
ax.set_ylim(ylimits[0], ylimits[1])
ax.set_title(title)
if savePlot:
......@@ -1151,27 +1165,7 @@ class noiseBudget:
# Creating total expected noise
if doTotal:
totalPSD = np.zeros(len(self.freq))
totalPSDlb = np.zeros(len(self.freq))
totalPSDub = np.zeros(len(self.freq))
for key in self.calcPSDList:
if key in self.PSDList:
PSD = self.PSDList[key][0]
if isinstance(PSD[0], unc.core.AffineScalarFunc):
totalPSD = totalPSD + unpnv(PSD)
totalPSDlb = totalPSDlb + unpnv(PSD) - unpstd(PSD)
totalPSDub = totalPSDub + unpnv(PSD) + unpstd(PSD)
elif len(self.PSDList[key]) == 5:
totalPSD = totalPSD + PSD
totalPSDlb = totalPSDlb + self.PSDList[key][3]
totalPSDub = totalPSDub + self.PSDList[key][4]
else:
totalPSD = totalPSD + PSD
totalPSDlb = totalPSDlb + PSD
totalPSDub = totalPSDub + PSD
self.PSDList['total'] = [totalPSD, self.freq,
'Total expected noise',
totalPSDlb, totalPSDub]
self.calculateTotalEstNoise()
if 'total' not in saveList:
saveList += ['total']
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment