Commit 7b110766 authored by Anchal Gupta's avatar Anchal Gupta
Browse files

Further optimization

parent 86babaf8
Pipeline #103131 failed with stage
in 2 minutes and 33 seconds
C3:PSL-TEMP_TABLE
C3:PSL-TEMP_VACCAN_INLOOP
C3:PSL-PRECAV_BEATNOTE_FREQ
C3:PSL-PLL_AUTOLOCKER_BEATNOTE_FREQ
C3:PSL-PLL_AUTOLOCKER_FREQ_MOD
C3:PSL-SCAV_TRANS_POW
C3:PSL-NCAV_TRANS_POW
C3:PSL-SCAV_REFL_POW
C3:PSL-NCAV_REFL_POW
C3:PSL-SCAV_MODE_MATCHING
C3:PSL-NCAV_MODE_MATCHING
C3:PSL-SCAV_FSS_SLOWOUT
C3:PSL-NCAV_FSS_SLOWOUT
C3:PSL-SCAV_FSS_COMGAIN_DB
C3:PSL-NCAV_FSS_COMGAIN_DB
C3:PSL-SCAV_FSS_FASTGAIN_DB
C3:PSL-NCAV_FSS_FASTGAIN_DB
C3:PSL-HEATER_SHIELD_DIFF_POUT
C3:PSL-HEATER_SHIELD_COM_POUT
%% Cell type:code id: tags:
``` python
import numpy as np
import matplotlib.pyplot as plt #For plotting
from matplotlib import cm
import matplotlib.colors as colors
import seaborn as sns;
from matplotlib.backends.backend_pdf import PdfPages #For saving figures to single pdf
figlist = []
#*******************************************************************************************************
#Setting RC Parameters for figure size and fontsizes
import matplotlib.pylab as pylab
params = {'legend.fontsize': 'xx-large',
'figure.figsize': (20, 10),
'axes.labelsize': 'xx-large',
'axes.titlesize':'xx-large',
'xtick.labelsize':'xx-large',
'ytick.labelsize':'xx-large',
'lines.linewidth': 2.0}
pylab.rcParams.update(params)
#********************************************************************************************************
import os
from noiseBudgetModule import noiseBudget
import uncertainties.unumpy as unp
import yaml
```
%% Cell type:code id: tags:
``` python
def gainValues(fn, data_dir='./'):
cwd = os.getcwd()
os.chdir(data_dir)
configFile = fn.replace('Spectrum', 'ExpConfig').replace('.txt', '.yml')
with open(configFile, 'r') as cf:
config = yaml.full_load(cf)
NCOM = config['C3:PSL-NCAV_FSS_COMGAIN_DB']
NFAST = config['C3:PSL-NCAV_FSS_FASTGAIN_DB']
SCOM = config['C3:PSL-SCAV_FSS_COMGAIN_DB']
SFAST = config['C3:PSL-SCAV_FSS_FASTGAIN_DB']
os.chdir(cwd)
return {'NCOM' : NCOM,
'NFAST' : NFAST,
'SCOM' : SCOM,
'SFAST' : SFAST}
```
%% Cell type:code id: tags:
``` python
def createBNDist(files, X, Y, fStart, fStop, y_ax, x_ax, data_dir='./'):
cwd = os.getcwd()
os.chdir(data_dir)
Z = np.ones(np.shape(X))*np.inf
for fn in files:
data = np.loadtxt(fn)
fStartInd = np.argmin(np.abs(data[:, 0] - fStart))
fStopInd = np.argmin(np.abs(data[:, 0] - fStop))
xG = gainValues(fn, data_dir)[x_ax]
yG = gainValues(fn, data_dir)[y_ax]
for ii in range(np.shape(Y)[0]):
if Y[ii, 0] == yG:
break
for jj in range(np.shape(X)[1]):
if X[0, jj] == xG:
break
#print('Ind', ii, jj)
#print(X[ii, jj], Y[ii, jj])
#print(yG, xG)
'''
Z[ii, jj] = np.sqrt(np.sum((((data[fStartInd:fStopInd, 1]**2)
* (data[fStartInd+1:fStopInd+1, 0]
- data[fStartInd:fStopInd, 0])
))))
'''
Z[ii, jj] = np.sum(data[fStartInd:fStopInd, 1])
os.chdir(cwd)
return Z
```
%% Cell type:code id: tags:
``` python
NFSS_Span_Files = [fn for fn in os.listdir() if (fn.find('.txt')!=-1
and fn.find('NFSS_Spanned')!=-1) ]
NCOM = np.array(sorted(list(set([gainValues(fn)['NCOM'] for fn in NFSS_Span_Files ]))))
NFAST = np.array(sorted(list(set([gainValues(fn)['NFAST'] for fn in NFSS_Span_Files ]))))
print(NCOM, NFAST)
```
%% Cell type:code id: tags:
``` python
X, Y = np.meshgrid(NCOM, NFAST)
Z = createBNDist(NFSS_Span_Files, X, Y, 300, 600, 'NFAST', 'NCOM')
minInd = np.unravel_index(np.argmin(Z), np.shape(Z))
print(minInd)
print(np.min(Z))
print('Minimum at COM Gain: '
+ str(X[0, minInd[1]]) + ' dB, FAST Gain: '
+ str(Y[minInd[0], 0])+ ' dB')
```
%% Cell type:code id: tags:
``` python
ax = sns.heatmap(Z, cmap=cm.jet,
cbar_kws = {'label' : 'Summed BN Noise [$Hz/\sqrt{Hz}$]'},
linewidths=0.5, annot=True,vmin=0.9, vmax=1.3)
#vmin=np.min(Z[np.nonzero(Z)]), vmax = 3.2)
ax.invert_yaxis()
ax.set_xticklabels(X[0, :])
ax.set_ylim([-0.5, len(Y[:, 0]) + 0.5])
ax.set_yticks(Y[:, 0] - Y[0, 0] + 0.5)
ax.set_yticklabels(Y[:, 0])
plt.setp(ax.get_yticklabels(), rotation=0, ha="right",
rotation_mode="anchor");
ax.set_xlabel('NFSS COM Gain (dB)', linespacing=4)
ax.set_ylabel('NFSS FAST Gain (dB)', linespacing=4)
ax.set_title('Beatnote frequency noise summed from 300 Hz to 600 Hz\n'
'South COM Gain = 23 dB; North Fast Gain = 15 dB')
fig = ax.get_figure()
fig.set_size_inches(11, 8.5, forward=True)
figlist = [fig]
```
%% Cell type:code id: tags:
``` python
SFSS_Span_Files = [fn for fn in os.listdir() if (fn.find('.txt')!=-1
and fn.find('SFSS_Spanned')!=-1) ]
SCOM = np.array(sorted(list(set([gainValues(fn)['SCOM'] for fn in SFSS_Span_Files ]))))
SFAST = np.array(sorted(list(set([gainValues(fn)['SFAST'] for fn in SFSS_Span_Files ]))))
print(SCOM, SFAST)
```
%% Cell type:code id: tags:
``` python
X, Y = np.meshgrid(SCOM, SFAST)
Z = createBNDist(SFSS_Span_Files, X, Y, 300, 600, 'SFAST', 'SCOM')
minInd = np.unravel_index(np.argmin(Z), np.shape(Z))
print(minInd)
print(np.min(Z))
print('Minimum at COM Gain: '
+ str(X[0, minInd[1]]) + ' dB, FAST Gain: '
+ str(Y[minInd[0], 0])+ ' dB')
```
%% Cell type:code id: tags:
``` python
ax = sns.heatmap(Z, cmap=cm.jet,
cbar_kws = {'label' : 'Summed BN Noise [$Hz/\sqrt{Hz}$]'},
linewidths=0.5, annot=True,vmin=0.9, vmax=1.3)
#vmin=np.min(Z[np.nonzero(Z)]), vmax = 3.2)
ax.invert_yaxis()
ax.set_xticklabels(X[0, :])
ax.set_ylim([-0.5, len(Y[:, 0]) + 0.5])
ax.set_yticks(Y[:, 0] - Y[0, 0] + 0.5)
ax.set_yticklabels(Y[:, 0])
plt.setp(ax.get_yticklabels(), rotation=0, ha="right",
rotation_mode="anchor");
ax.set_xlabel('SFSS COM Gain (dB)', linespacing=4)
ax.set_ylabel('SFSS FAST Gain (dB)', linespacing=4)
ax.set_title('Beatnote frequency noise summed from 300 Hz to 600 Hz\n'
'North COM Gain = 12 dB; North Fast Gain = 10 dB')
fig = ax.get_figure()
fig.set_size_inches(11, 8.5, forward=True)
figlist = [fig]
```
%% Cell type:code id: tags:
``` python
pp = PdfPages('FSS_Gain_Span.pdf')
for fig in figlist:
pp.savefig(fig,bbox_inches='tight')
pp.close()
```
C3:PSL-HEATER_SHIELD_COM_POUT: 0.5
C3:PSL-HEATER_SHIELD_DIFF_POUT: -0.12511
C3:PSL-NCAV_FSS_COMGAIN_DB: 10.0
C3:PSL-NCAV_FSS_FASTGAIN_DB: -1.0
C3:PSL-NCAV_FSS_SLOWOUT: 2.920692702579768
C3:PSL-NCAV_MODE_MATCHING: 68.87319526355358
C3:PSL-NCAV_REFL_POW: 2.562527031768
C3:PSL-NCAV_TRANS_POW: 5.511283463109001
C3:PSL-PLL_AUTOLOCKER_BEATNOTE_FREQ: 27.330584169659662
C3:PSL-PLL_AUTOLOCKER_FREQ_MOD: 2.0
C3:PSL-PRECAV_BEATNOTE_FREQ: 27.340926
C3:PSL-SCAV_FSS_COMGAIN_DB: 23.0
C3:PSL-SCAV_FSS_FASTGAIN_DB: 15.0
C3:PSL-SCAV_FSS_SLOWOUT: -6.2684230369509075
C3:PSL-SCAV_MODE_MATCHING: 77.52343146234584
C3:PSL-SCAV_REFL_POW: 1.798154960607
C3:PSL-SCAV_TRANS_POW: 6.210823990049999
C3:PSL-TEMP_TABLE: 18.994165397260673
C3:PSL-TEMP_VACCAN_INLOOP: 34.36323221692307
detector: SN101
instrument: moku
C3:PSL-HEATER_SHIELD_COM_POUT: 0.5
C3:PSL-HEATER_SHIELD_DIFF_POUT: -0.10985
C3:PSL-NCAV_FSS_COMGAIN_DB: 10.0
C3:PSL-NCAV_FSS_FASTGAIN_DB: 0.0
C3:PSL-NCAV_FSS_SLOWOUT: 2.9202595953303194
C3:PSL-NCAV_MODE_MATCHING: 69.31963979748339
C3:PSL-NCAV_REFL_POW: 2.554728314184
C3:PSL-NCAV_TRANS_POW: 5.772189288219001
C3:PSL-PLL_AUTOLOCKER_BEATNOTE_FREQ: 27.33637697765964
C3:PSL-PLL_AUTOLOCKER_FREQ_MOD: 2.0
C3:PSL-PRECAV_BEATNOTE_FREQ: 27.336738
C3:PSL-SCAV_FSS_COMGAIN_DB: 23.0
C3:PSL-SCAV_FSS_FASTGAIN_DB: 15.0
C3:PSL-SCAV_FSS_SLOWOUT: -6.26874916201885
C3:PSL-SCAV_MODE_MATCHING: 77.49815443086085
C3:PSL-SCAV_REFL_POW: 1.8042446000789998
C3:PSL-SCAV_TRANS_POW: 6.21396259335
C3:PSL-TEMP_TABLE: 18.993549544015725
C3:PSL-TEMP_VACCAN_INLOOP: 34.38228548461538
detector: SN101
instrument: moku
C3:PSL-HEATER_SHIELD_COM_POUT: 0.5
C3:PSL-HEATER_SHIELD_DIFF_POUT: -0.13685
C3:PSL-NCAV_FSS_COMGAIN_DB: 10.0
C3:PSL-NCAV_FSS_FASTGAIN_DB: 1.0
C3:PSL-NCAV_FSS_SLOWOUT: 2.9203445257731184
C3:PSL-NCAV_MODE_MATCHING: 69.3996853532704
C3:PSL-NCAV_REFL_POW: 2.55559483836
C3:PSL-NCAV_TRANS_POW: 5.795936405235
C3:PSL-PLL_AUTOLOCKER_BEATNOTE_FREQ: 27.344357036259623
C3:PSL-PLL_AUTOLOCKER_FREQ_MOD: 2.0
C3:PSL-PRECAV_BEATNOTE_FREQ: 27.344212
C3:PSL-SCAV_FSS_COMGAIN_DB: 23.0
C3:PSL-SCAV_FSS_FASTGAIN_DB: 15.0
C3:PSL-SCAV_FSS_SLOWOUT: -6.268878465487645
C3:PSL-SCAV_MODE_MATCHING: 77.60828825355192
C3:PSL-SCAV_REFL_POW: 1.797393755673
C3:PSL-SCAV_TRANS_POW: 6.229655609849999
C3:PSL-TEMP_TABLE: 18.975689799912132
C3:PSL-TEMP_VACCAN_INLOOP: 34.37982699846154
detector: SN101
instrument: moku
C3:PSL-HEATER_SHIELD_COM_POUT: 0.5
C3:PSL-HEATER_SHIELD_DIFF_POUT: -0.12186
C3:PSL-NCAV_FSS_COMGAIN_DB: 10.0
C3:PSL-NCAV_FSS_FASTGAIN_DB: 2.0
C3:PSL-NCAV_FSS_SLOWOUT: 2.9203917529077246
C3:PSL-NCAV_MODE_MATCHING: 69.34410696131138
C3:PSL-NCAV_REFL_POW: 2.557327886712
C3:PSL-NCAV_TRANS_POW: 5.819995984317
C3:PSL-PLL_AUTOLOCKER_BEATNOTE_FREQ: 27.341106106259613
C3:PSL-PLL_AUTOLOCKER_FREQ_MOD: 2.0
C3:PSL-PRECAV_BEATNOTE_FREQ: 27.340176
C3:PSL-SCAV_FSS_COMGAIN_DB: 23.0
C3:PSL-SCAV_FSS_FASTGAIN_DB: 15.0
C3:PSL-SCAV_FSS_SLOWOUT: -6.268846906653796
C3:PSL-SCAV_MODE_MATCHING: 77.59356668146043
C3:PSL-SCAV_REFL_POW: 1.792065321135
C3:PSL-SCAV_TRANS_POW: 6.229655609849999
C3:PSL-TEMP_TABLE: 18.98431174534145
C3:PSL-TEMP_VACCAN_INLOOP: 34.37644658
detector: SN101
instrument: moku
C3:PSL-HEATER_SHIELD_COM_POUT: 0.5
C3:PSL-HEATER_SHIELD_DIFF_POUT: -0.12174
C3:PSL-NCAV_FSS_COMGAIN_DB: 10.0
C3:PSL-NCAV_FSS_FASTGAIN_DB: 3.0
C3:PSL-NCAV_FSS_SLOWOUT: 2.920325446569629
C3:PSL-NCAV_MODE_MATCHING: 69.2565131436531
C3:PSL-NCAV_REFL_POW: 2.56426008012
C3:PSL-NCAV_TRANS_POW: 5.776563757143
C3:PSL-PLL_AUTOLOCKER_BEATNOTE_FREQ: 27.340672644419612
C3:PSL-PLL_AUTOLOCKER_FREQ_MOD: 2.0
C3:PSL-PRECAV_BEATNOTE_FREQ: 27.340128
C3:PSL-SCAV_FSS_COMGAIN_DB: 23.0
C3:PSL-SCAV_FSS_FASTGAIN_DB: 15.0
C3:PSL-SCAV_FSS_SLOWOUT: -6.268746970696589
C3:PSL-SCAV_MODE_MATCHING: 77.62978776540712
C3:PSL-SCAV_REFL_POW: 1.789020501399
C3:PSL-SCAV_TRANS_POW: 6.2083131074099995
C3:PSL-TEMP_TABLE: 18.989854424546017
C3:PSL-TEMP_VACCAN_INLOOP: 34.36691994615384
detector: SN101
instrument: moku
C3:PSL-HEATER_SHIELD_COM_POUT: 0.5
C3:PSL-HEATER_SHIELD_DIFF_POUT: -0.12181
C3:PSL-NCAV_FSS_COMGAIN_DB: 10.0
C3:PSL-NCAV_FSS_FASTGAIN_DB: 4.0
C3:PSL-NCAV_FSS_SLOWOUT: 2.9203841992276756
C3:PSL-NCAV_MODE_MATCHING: 69.3200317457405
C3:PSL-NCAV_REFL_POW: 2.563393555944
C3:PSL-NCAV_TRANS_POW: 5.791874398377
C3:PSL-PLL_AUTOLOCKER_BEATNOTE_FREQ: 27.340209219779588
C3:PSL-PLL_AUTOLOCKER_FREQ_MOD: 2.0
C3:PSL-PRECAV_BEATNOTE_FREQ: 27.339816
C3:PSL-SCAV_FSS_COMGAIN_DB: 23.0
C3:PSL-SCAV_FSS_FASTGAIN_DB: 15.0
C3:PSL-SCAV_FSS_SLOWOUT: -6.2689169691507125
C3:PSL-SCAV_MODE_MATCHING: 77.65572345941628
C3:PSL-SCAV_REFL_POW: 1.7791248372569999
C3:PSL-SCAV_TRANS_POW: 6.183204281009999
C3:PSL-TEMP_TABLE: 18.998476369975336
C3:PSL-TEMP_VACCAN_INLOOP: 34.3884317
detector: SN101
instrument: moku
C3:PSL-HEATER_SHIELD_COM_POUT: 0.5
C3:PSL-HEATER_SHIELD_DIFF_POUT: -0.12167
C3:PSL-NCAV_FSS_COMGAIN_DB: 10.0
C3:PSL-NCAV_FSS_FASTGAIN_DB: 5.0
C3:PSL-NCAV_FSS_SLOWOUT: 2.920356925786669
C3:PSL-NCAV_MODE_MATCHING: 69.36805493260513
C3:PSL-NCAV_REFL_POW: 2.55126221748
C3:PSL-NCAV_TRANS_POW: 5.775626370945001
C3:PSL-PLL_AUTOLOCKER_BEATNOTE_FREQ: 27.340602731219555
C3:PSL-PLL_AUTOLOCKER_FREQ_MOD: 2.0
C3:PSL-PRECAV_BEATNOTE_FREQ: 27.33989
C3:PSL-SCAV_FSS_COMGAIN_DB: 23.0
C3:PSL-SCAV_FSS_FASTGAIN_DB: 15.0
C3:PSL-SCAV_FSS_SLOWOUT: -6.268912163578876
C3:PSL-SCAV_MODE_MATCHING: 77.49554114035578
C3:PSL-SCAV_REFL_POW: 1.787498091531
C3:PSL-SCAV_TRANS_POW: 6.166883543849999
C3:PSL-TEMP_TABLE: 18.993549544015725
C3:PSL-TEMP_VACCAN_INLOOP: 34.36784187846153
detector: SN101
instrument: moku
C3:PSL-HEATER_SHIELD_COM_POUT: 0.5
C3:PSL-HEATER_SHIELD_DIFF_POUT: -0.12114
C3:PSL-NCAV_FSS_COMGAIN_DB: 10.0
C3:PSL-NCAV_FSS_FASTGAIN_DB: 6.0
C3:PSL-NCAV_FSS_SLOWOUT: 2.9200333973236683
C3:PSL-NCAV_MODE_MATCHING: 69.21405102923725
C3:PSL-NCAV_REFL_POW: 2.574658370232
C3:PSL-NCAV_TRANS_POW: 5.788437315651
C3:PSL-PLL_AUTOLOCKER_BEATNOTE_FREQ: 27.340221204899542
C3:PSL-PLL_AUTOLOCKER_FREQ_MOD: 2.0
C3:PSL-PRECAV_BEATNOTE_FREQ: 27.339902
C3:PSL-SCAV_FSS_COMGAIN_DB: 23.0
C3:PSL-SCAV_FSS_FASTGAIN_DB: 15.0
C3:PSL-SCAV_FSS_SLOWOUT: -6.269003167095315
C3:PSL-SCAV_MODE_MATCHING: 77.50670577497385
C3:PSL-SCAV_REFL_POW: 1.792065321135
C3:PSL-SCAV_TRANS_POW: 6.175043912429999
C3:PSL-TEMP_TABLE: 18.995397103750577