mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-12-22 11:33:32 +01:00
Simu: move Emitter/Receiver into Antenna file
This commit is contained in:
parent
7553808bfb
commit
01689f7b7e
5 changed files with 47 additions and 44 deletions
|
@ -1,3 +1,2 @@
|
|||
from .location import *
|
||||
from .emitter import *
|
||||
from .receiver import *
|
||||
from .antenna import *
|
||||
|
|
45
simulations/lib/location/antenna.py
Normal file
45
simulations/lib/location/antenna.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
from functools import partial
|
||||
|
||||
try:
|
||||
from .location import Location
|
||||
except ImportError:
|
||||
from location import Location
|
||||
|
||||
class Antenna(Location):
|
||||
"""
|
||||
A location able to interact with a signal.
|
||||
|
||||
Either emitting or receiving.
|
||||
|
||||
Optionally applies a transformation to the traced signal.
|
||||
"""
|
||||
def __repr__(self):
|
||||
return "Antenna({})".format(repr(self.x))
|
||||
|
||||
def recv(self, travel_signal: callable) -> callable:
|
||||
"""
|
||||
Return a function that traces the signal as a function of time
|
||||
at the antenna's location
|
||||
"""
|
||||
return partial(travel_signal, x_f=self.x)
|
||||
|
||||
receive = recv
|
||||
|
||||
def emit(self, travel_signal: callable) -> callable:
|
||||
return partial(travel_signal, x_0=self.x)
|
||||
|
||||
class Receiver(Antenna):
|
||||
"""
|
||||
An antenna which main purpose is to trace a signal over time.
|
||||
|
||||
Optionally applies a transformation to the traced signal.
|
||||
"""
|
||||
def __repr__(self):
|
||||
return "Receiver({})".format(repr(self.x))
|
||||
|
||||
class Emitter(Antenna):
|
||||
"""
|
||||
An antenna which main purpose is to emit a signal.
|
||||
"""
|
||||
def __repr__(self):
|
||||
return "Emitter({})".format(repr(self.x))
|
|
@ -1,16 +0,0 @@
|
|||
from functools import partial
|
||||
|
||||
try:
|
||||
from .location import Location
|
||||
except ImportError:
|
||||
from location import Location
|
||||
|
||||
class Emitter(Location):
|
||||
"""
|
||||
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: callable) -> callable:
|
||||
return partial(travel_signal, x_0=self.x)
|
|
@ -3,8 +3,7 @@
|
|||
import matplotlib.pyplot as plt
|
||||
from mpl_toolkits.mplot3d import axes3d
|
||||
|
||||
from receiver import Receiver
|
||||
from emitter import Emitter
|
||||
from antenna import Receiver, Emitter
|
||||
|
||||
# 2D showcase
|
||||
source = Emitter([1,1])
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
from functools import partial
|
||||
|
||||
try:
|
||||
from .location import Location
|
||||
except ImportError:
|
||||
from location import Location
|
||||
|
||||
class Receiver(Location):
|
||||
"""
|
||||
A location able to trace a signal over time.
|
||||
|
||||
Optionally applies a transformation to the traced signal.
|
||||
"""
|
||||
def __repr__(self):
|
||||
return "Receiver({})".format(repr(self.x))
|
||||
|
||||
def recv(self, travel_signal: callable) -> callable:
|
||||
"""
|
||||
Return a function that traces the signal as a function of time
|
||||
at the receiver's location
|
||||
"""
|
||||
return partial(travel_signal, x_f=self.x)
|
||||
|
||||
receive = recv
|
Loading…
Reference in a new issue