mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-13 10:03:32 +01:00
Simulation: add utils
This commit is contained in:
parent
598d883c3e
commit
e6d6d595d4
3 changed files with 24 additions and 0 deletions
|
@ -1,2 +1,3 @@
|
||||||
from .travelsignal import *
|
from .travelsignal import *
|
||||||
from .location import *
|
from .location import *
|
||||||
|
from .util import *
|
||||||
|
|
|
@ -77,6 +77,9 @@ class Emitter(Location):
|
||||||
"""
|
"""
|
||||||
Emit a signal from position x_0 (and time t_0)
|
Emit a signal from position x_0 (and time t_0)
|
||||||
"""
|
"""
|
||||||
|
def __repr__(self):
|
||||||
|
return "Emitter({})".format(repr(self.x))
|
||||||
|
|
||||||
def emit(self, travel_signal: TravelSignal) -> TravelSignal:
|
def emit(self, travel_signal: TravelSignal) -> TravelSignal:
|
||||||
return partial(travel_signal, x_0=self.x)
|
return partial(travel_signal, x_0=self.x)
|
||||||
|
|
||||||
|
|
20
simulations/lib/util.py
Normal file
20
simulations/lib/util.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
"""
|
||||||
|
Various useful utilities (duh)
|
||||||
|
"""
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
def sampled_time(sample_rate=1, start=0, end=1, offset=0):
|
||||||
|
return offset + np.arange(start, end, 1/sample_rate)
|
||||||
|
|
||||||
|
def rot_vector(phi1=0.12345):
|
||||||
|
"""
|
||||||
|
Return a unit vector rotated by phi radians.
|
||||||
|
"""
|
||||||
|
|
||||||
|
unit = np.array([
|
||||||
|
phi1,
|
||||||
|
phi1 - np.pi/2
|
||||||
|
])
|
||||||
|
|
||||||
|
return np.cos(unit)
|
Loading…
Reference in a new issue