Update compute_light, good shape now
This commit is contained in:
parent
3af1d68122
commit
0587b5fbe3
4 changed files with 52 additions and 14 deletions
|
@ -1,7 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from numpy.typing import NDArray
|
from numpy.typing import NDArray
|
||||||
from numpy import arange
|
from numpy import arange
|
||||||
from scipy.interpolate import CubicSpline
|
|
||||||
|
|
||||||
|
|
||||||
def interpolate_abciss(signals: tuple[Signal, ...]) -> NDArray:
|
def interpolate_abciss(signals: tuple[Signal, ...]) -> NDArray:
|
||||||
|
@ -21,7 +20,7 @@ def interpolate(signals: tuple[Signal, ...]) -> tuple[Signal, ...]:
|
||||||
Interpolate multiple signals with a single abciss list, which has
|
Interpolate multiple signals with a single abciss list, which has
|
||||||
the smallest interval and the bigget rate
|
the smallest interval and the bigget rate
|
||||||
"""
|
"""
|
||||||
splines = [CubicSpline(signal.x, signal.y) for signal in signals]
|
splines = [signal.spline() for signal in signals]
|
||||||
|
|
||||||
x = interpolate_abciss(signals)
|
x = interpolate_abciss(signals)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from sys import argv as options
|
||||||
from backscattering_analyzer.settings import Settings
|
from backscattering_analyzer.settings import Settings
|
||||||
from backscattering_analyzer.signal import Signal
|
from backscattering_analyzer.signal import Signal
|
||||||
from backscattering_analyzer import interpolate, interpolate_abciss
|
from backscattering_analyzer import interpolate, interpolate_abciss
|
||||||
from numpy import loadtxt, array
|
from numpy import loadtxt
|
||||||
from scipy.io.matlab import loadmat
|
from scipy.io.matlab import loadmat
|
||||||
|
|
||||||
# maths
|
# maths
|
||||||
|
@ -140,14 +140,14 @@ class Analyzer:
|
||||||
)
|
)
|
||||||
|
|
||||||
# frequencies depends of psd result, which we do not have yet
|
# frequencies depends of psd result, which we do not have yet
|
||||||
frequencies = 0
|
frequencies = zeros(len(result))
|
||||||
|
|
||||||
for index in range(len(self.coupling)):
|
for index in range(len(self.coupling)):
|
||||||
phase = (index + 1) * 4 * pi / self.settings.wavelength
|
phase = (index + 1) * 4 * pi / (self.settings.wavelength*1e6)
|
||||||
|
|
||||||
factor_n = (self.movement * phase).sin().psd()
|
factor_n = (self.movement * phase).sin().psd().sqrt()
|
||||||
coupling_n = self.coupling[0].abs()
|
coupling_n = self.coupling[0].abs()
|
||||||
factor_d = (self.movement * phase).cos().psd()
|
factor_d = (self.movement * phase).cos().psd().sqrt()
|
||||||
coupling_d = self.coupling[1].abs()
|
coupling_d = self.coupling[1].abs()
|
||||||
|
|
||||||
factor_n, coupling_n, factor_d, coupling_d = interpolate(
|
factor_n, coupling_n, factor_d, coupling_d = interpolate(
|
||||||
|
@ -163,9 +163,20 @@ class Analyzer:
|
||||||
/ self.settings.power_out
|
/ self.settings.power_out
|
||||||
* (coupling_n * factor_n + coupling_d * factor_d).y
|
* (coupling_n * factor_n + coupling_d * factor_d).y
|
||||||
)
|
)
|
||||||
return array(
|
"""
|
||||||
[
|
result += (
|
||||||
|
sqrt(self.settings.scattering_factor[index])
|
||||||
|
* self.settings.wavelength
|
||||||
|
/ (4 * pi)
|
||||||
|
* (coupling_n**2 * factor_n + coupling_d**2 * factor_d)
|
||||||
|
.sqrt()
|
||||||
|
.y
|
||||||
|
) ** 2
|
||||||
|
"""
|
||||||
|
|
||||||
|
self.projection = Signal(
|
||||||
frequencies,
|
frequencies,
|
||||||
result,
|
result,
|
||||||
]
|
self.settings,
|
||||||
)
|
)
|
||||||
|
return self.projection
|
||||||
|
|
|
@ -34,7 +34,7 @@ class Settings:
|
||||||
|
|
||||||
self.calib_bench = 1.15
|
self.calib_bench = 1.15
|
||||||
self.calib_mirror = 1.15
|
self.calib_mirror = 1.15
|
||||||
self.scattering_factor = [1e-3, 0] # parameter to change
|
self.scattering_factor = [1.3e-3, 1e-12] # parameter to change
|
||||||
self.vibration_frequency = 0.2
|
self.vibration_frequency = 0.2
|
||||||
|
|
||||||
index = 0
|
index = 0
|
||||||
|
|
|
@ -5,7 +5,8 @@ from backscattering_analyzer import interpolate
|
||||||
|
|
||||||
from scipy.signal import welch, detrend
|
from scipy.signal import welch, detrend
|
||||||
from scipy.fft import irfft, rfft, rfftfreq
|
from scipy.fft import irfft, rfft, rfftfreq
|
||||||
from numpy import where, sin, cos, array
|
from scipy.interpolate import CubicSpline
|
||||||
|
from numpy import where, sin, cos, array, sqrt
|
||||||
|
|
||||||
|
|
||||||
class Signal:
|
class Signal:
|
||||||
|
@ -44,6 +45,14 @@ class Signal:
|
||||||
self.settings,
|
self.settings,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def sqrt(self) -> Signal:
|
||||||
|
""" """
|
||||||
|
return Signal(
|
||||||
|
self.x,
|
||||||
|
sqrt(self.y),
|
||||||
|
self.settings,
|
||||||
|
)
|
||||||
|
|
||||||
def detrend(self, type: str = "linear") -> Signal:
|
def detrend(self, type: str = "linear") -> Signal:
|
||||||
"""
|
"""
|
||||||
Short alias for scipy.detrend with default value
|
Short alias for scipy.detrend with default value
|
||||||
|
@ -106,6 +115,15 @@ class Signal:
|
||||||
self.settings,
|
self.settings,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def spline(self) -> CubicSpline:
|
||||||
|
"""
|
||||||
|
Return interpolation of this signal
|
||||||
|
"""
|
||||||
|
return CubicSpline(
|
||||||
|
self.x,
|
||||||
|
self.y,
|
||||||
|
)
|
||||||
|
|
||||||
def __sub__(self, other: float | Signal) -> Signal:
|
def __sub__(self, other: float | Signal) -> Signal:
|
||||||
"""
|
"""
|
||||||
Substract float or a signal to another
|
Substract float or a signal to another
|
||||||
|
@ -204,3 +222,13 @@ class Signal:
|
||||||
Get length of a signal
|
Get length of a signal
|
||||||
"""
|
"""
|
||||||
return len(self.x)
|
return len(self.x)
|
||||||
|
|
||||||
|
def __pow__(self, other) -> Signal:
|
||||||
|
"""
|
||||||
|
Signal put to power
|
||||||
|
"""
|
||||||
|
return Signal(
|
||||||
|
self.x,
|
||||||
|
self.y**other,
|
||||||
|
self.settings,
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue