Skip to content

Latest commit

 

History

History
225 lines (100 loc) · 3.61 KB

noise_example.rst

File metadata and controls

225 lines (100 loc) · 3.61 KB

Table of Contents

Noise Analysis Test

Imports

from qetpy import Noise
from qetpy.sim import TESnoise
from qetpy.plotting import compare_noise, plot_noise_sim
import numpy as np
import matplotlib.pyplot as plt

Load test data

pathToTraces = ''
traces_PT_on = np.load(pathToTraces+'traces.npy')

Create noise object

Noise?
#savePath = 'example_Figs/' #used for test, user should define new path for test so they don't save over these figs
savePath = '' #user needs to define new path

fs = 625e3 #define sample rate
channels = [ 'PCS1' , 'PES1' , 'PFS1' , 'PAS2' , 'PBS2' , 'PES2' , 'PDS2' ] #define the channel names
g124_noise = Noise(traces=traces_PT_on,
                   fs=fs, 
                   channames=channels,
                   name= 'G124 SLAC Run 37 Pulse Tube On') #initialize a noise object

Calculate the PSD and corrCoeff

g124_noise.calculate_psd()
g124_noise.calculate_corrcoeff()
g124_noise.calculate_csd()

Calculate unCorrelated noise

g124_noise.calculate_uncorr_noise()

Test saving.

Uncomment to save and re-load

#saveName = pathToTraces + g124_noise.name.replace(" ", "_") + '.pkl'
#g124_noise.save(pathToTraces)
#del g124_noise
# with open(pathToTraces,'rb') as savefile:
#     g124_noise = pickle.load(savefile)

Test plotting of PSD and corrCoeff

g124_noise.plot_psd(lgcoverlay=True)

image

g124_noise.plot_psd(lgcoverlay=False)

image

g124_noise.plot_corrcoeff(lgcsave=False, lgcsmooth=True, nwindow=13 )

image

Plot a few CSDs

g124_noise.plot_csd(whichcsd=['66','26'])

image

image

Try to plot a CSD for a non existant channel

g124_noise.plot_csd(whichcsd=['68'])

index out of range

Try to save a figure with a bad path

g124_noise.plot_csd(whichcsd=['11'], lgcsave=True, savepath = 'yay/python/is/great')

Invalid save path. Figure not saved

image

Plot Real vs Imaginary PSDs

g124_noise.plot_reim_psd()

image

Plot unCorrelated part of the noise PSD

g124_noise.calculate_uncorr_noise()
g124_noise.plot_decorrelatednoise(lgccorrelated=True,lgcsum = True, lgcsave=False)

image

g124_noise.plot_decorrelatednoise(lgcoverlay = True)

image

Create noise simulation object

noise_sim = TESnoise(freqs = g124_noise.freqs[1:])

Note, these default noise parameters are completely made up, just for demostration

plot_noise_sim(g124_noise.freqs, g124_noise.psd[0,:], noise_sim, istype='power', qetbias=0)

image