mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 10:03:32 +01:00
SimuLib: signal time offset functions (small tweaks)
This commit is contained in:
parent
80a79bb4c6
commit
81ec1ad7e2
1 changed files with 13 additions and 3 deletions
|
@ -43,7 +43,7 @@ class Signal():
|
||||||
|
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def spatial_time(self, x_f, velocity=None, x_0=None):
|
def spatial_time_offset(self, x_f, velocity=None, x_0=None):
|
||||||
"""
|
"""
|
||||||
Calculate the time offset caused by a spatial difference.
|
Calculate the time offset caused by a spatial difference.
|
||||||
"""
|
"""
|
||||||
|
@ -55,6 +55,16 @@ class Signal():
|
||||||
|
|
||||||
return np.sum(np.sqrt( (x_f - x_0)**2 )/velocity)
|
return np.sum(np.sqrt( (x_f - x_0)**2 )/velocity)
|
||||||
|
|
||||||
|
def temporal_time_offset(self, t_f, t_0=None):
|
||||||
|
"""
|
||||||
|
Calculate the time offset caused by a temporal difference.
|
||||||
|
"""
|
||||||
|
if t_0 is None:
|
||||||
|
t_0 = self.t_0
|
||||||
|
|
||||||
|
return t_f - t_0
|
||||||
|
|
||||||
|
|
||||||
def total_time_offset(self, t_f = None, x_f = None, t_0 = None, x_0 = None, velocity = None):
|
def total_time_offset(self, t_f = None, x_f = None, t_0 = None, x_0 = None, velocity = None):
|
||||||
"""
|
"""
|
||||||
Calculate how much time shifting is needed to go from (t_0, x_0) to (t_f, x_f).
|
Calculate how much time shifting is needed to go from (t_0, x_0) to (t_f, x_f).
|
||||||
|
@ -75,7 +85,7 @@ class Signal():
|
||||||
if x_0 is None:
|
if x_0 is None:
|
||||||
x_0 = self.x_0
|
x_0 = self.x_0
|
||||||
|
|
||||||
spatial_time_offset = self.spatial_time(x_f, x_0=x_0, velocity=velocity)
|
spatial_time_offset = self.spatial_time_offset(x_f, x_0=x_0, velocity=velocity)
|
||||||
|
|
||||||
## temporal offset
|
## temporal offset
|
||||||
if t_f is None:
|
if t_f is None:
|
||||||
|
@ -86,6 +96,6 @@ class Signal():
|
||||||
if t_0 is None:
|
if t_0 is None:
|
||||||
t_0 = self.t_0
|
t_0 = self.t_0
|
||||||
|
|
||||||
temporal_time_offset = t_f - t_0
|
temporal_time_offset = self.temporal_time_offset(t_f, t_0=t_0)
|
||||||
|
|
||||||
return temporal_time_offset - spatial_time_offset
|
return temporal_time_offset - spatial_time_offset
|
||||||
|
|
Loading…
Reference in a new issue