Add simple pass filter
This commit is contained in:
parent
70e306bf42
commit
9b34f5b6b9
2 changed files with 42 additions and 21 deletions
|
@ -10,10 +10,10 @@ from numpy import loadtxt, array
|
||||||
from scipy.io.matlab import loadmat
|
from scipy.io.matlab import loadmat
|
||||||
|
|
||||||
# maths
|
# maths
|
||||||
from numpy import mean, zeros, pi, sin, cos, arange, sqrt
|
from numpy import mean, zeros, pi, sin, cos, arange, sqrt, where, real
|
||||||
from scipy.signal import welch as psd
|
from scipy.signal import welch as psd
|
||||||
from scipy.interpolate import CubicSpline
|
from scipy.interpolate import CubicSpline
|
||||||
|
from scipy.fft import fft, ifft, fftfreq
|
||||||
|
|
||||||
class Analyzer:
|
class Analyzer:
|
||||||
"""
|
"""
|
||||||
|
@ -128,6 +128,7 @@ class Analyzer:
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
self.movement[1] -= mean(self.movement[1])
|
self.movement[1] -= mean(self.movement[1])
|
||||||
|
self.movement = self.movement[:,:-500000]
|
||||||
|
|
||||||
def psd_signal(self, signal, fft_length=10):
|
def psd_signal(self, signal, fft_length=10):
|
||||||
"""
|
"""
|
||||||
|
@ -256,14 +257,8 @@ class Analyzer:
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
unpack = self.interpolate(
|
factor_n, coupling_n, factor_d, coupling_d = self.interpolate(
|
||||||
[factor_n, coupling_n, factor_d, coupling_d]
|
(factor_n, coupling_n, factor_d, coupling_d)
|
||||||
)
|
|
||||||
factor_n, coupling_n, factor_d, coupling_d = (
|
|
||||||
unpack[0],
|
|
||||||
unpack[1],
|
|
||||||
unpack[2],
|
|
||||||
unpack[3],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
frequencies = factor_n[0]
|
frequencies = factor_n[0]
|
||||||
|
@ -273,8 +268,8 @@ class Analyzer:
|
||||||
* self.settings.power_in
|
* self.settings.power_in
|
||||||
/ self.settings.power_out
|
/ self.settings.power_out
|
||||||
* (
|
* (
|
||||||
coupling_n[1] * factor_n[1]
|
sqrt(coupling_n[1]) * sqrt(factor_n[1])
|
||||||
+ coupling_d[1] * factor_d[1]
|
+ sqrt(coupling_d[1]) * sqrt(factor_d[1])
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return array(
|
return array(
|
||||||
|
@ -283,3 +278,14 @@ class Analyzer:
|
||||||
result,
|
result,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def low_pass_filter(self, signal, cutoff):
|
||||||
|
"""
|
||||||
|
Cut higher frequencies than cutoff for a given temporal signal
|
||||||
|
"""
|
||||||
|
sample_spacing = signal[0,1] - signal[0,0]
|
||||||
|
freq_signal = fft(signal[1])
|
||||||
|
frequencies = fftfreq(signal[1].shape[0], sample_spacing)
|
||||||
|
index_to_remove = where(abs(frequencies) > cutoff)
|
||||||
|
freq_signal[index_to_remove] = 0
|
||||||
|
return array([signal[0], real(ifft(freq_signal))])
|
||||||
|
|
|
@ -6,22 +6,20 @@ class Settings:
|
||||||
self.version = "0.0.1"
|
self.version = "0.0.1"
|
||||||
self.help = (
|
self.help = (
|
||||||
"[main]display[/main] [option]\\[options][/option]"
|
"[main]display[/main] [option]\\[options][/option]"
|
||||||
"\n [argument]-b --bench[argument] [description]bench of the experiment[/description]"
|
"\n [argument]-b --bench[/argument] [description]bench of the experiment[/description]"
|
||||||
"\n [argument]-d --date[argument] [description]date of the experiment[/description]"
|
"\n [argument]-d --date[/argument] [description]date of the experiment[/description]"
|
||||||
"\n [argument]-h --help[argument] [description]print this help and exit[/description]"
|
"\n [argument]-h --help[/argument] [description]print this help and exit[/description]"
|
||||||
"\n [argument]-v --verbose[argument] [description]be verbose[/description]"
|
"\n [argument]-v --verbose[/argument] [description]be verbose[/description]"
|
||||||
"\n [argument]-V --version[argument] [description]print version number and exit[/description]"
|
"\n [argument]-V --version[/argument] [description]print version number and exit[/description]"
|
||||||
)
|
)
|
||||||
self.verbose = False
|
self.verbose = False
|
||||||
self.bench = "SWEB"
|
self.bench = "SWEB"
|
||||||
self.date = "2023_03_24"
|
self.date = "2023_03_24"
|
||||||
self.folder = Path("/home/demagny/data")
|
self.folder = Path("/home/demagny/data")
|
||||||
self.modelisation = "scatterCouplingO4.mat"
|
self.wavelength = 1.064e-6 # m
|
||||||
|
|
||||||
self.calib_bench = 1.15
|
self.calib_bench = 1.15
|
||||||
self.calib_mirror = 1.15
|
self.calib_mirror = 1.15
|
||||||
self.wavelength = 1.064e-6 # m
|
|
||||||
self.power_in = 23 # W
|
|
||||||
self.power_out = 8e-3 # W
|
|
||||||
self.scattering_factor = [1e-17, 0] # parameter to change
|
self.scattering_factor = [1e-17, 0] # parameter to change
|
||||||
|
|
||||||
index = 0
|
index = 0
|
||||||
|
@ -112,6 +110,23 @@ class Settings:
|
||||||
pass
|
pass
|
||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
|
if self.date == "2023_03_24":
|
||||||
|
self.modelisation = "scatterCouplingO4.mat"
|
||||||
|
self.power_in = 23 # W
|
||||||
|
self.power_out = 8e-3 # W
|
||||||
|
elif self.date == "2023_12_21":
|
||||||
|
self.modelisation = "scatterCouplingMisalignSR.mat"
|
||||||
|
self.power_in = 12.1 # W
|
||||||
|
self.power_out = 8e-3 # W
|
||||||
|
elif self.date == "2024_01_21":
|
||||||
|
self.modelisation = "scatterCouplingMisalignSR.mat"
|
||||||
|
self.power_in = 12.1 # W
|
||||||
|
self.power_out = 8e-3 # W
|
||||||
|
else:
|
||||||
|
self.modelisation = "scatterCouplingO4.mat"
|
||||||
|
self.power_in = 23 # W
|
||||||
|
self.power_out = 8e-3 # W
|
||||||
|
|
||||||
def bench_file(self):
|
def bench_file(self):
|
||||||
return self.folder / (
|
return self.folder / (
|
||||||
"{bench}_{date}_ben.csv".format(
|
"{bench}_{date}_ben.csv".format(
|
||||||
|
|
Loading…
Reference in a new issue