2022-03-24 12:13:34 +01:00
|
|
|
from functools import partial
|
|
|
|
|
2022-03-24 15:45:40 +01:00
|
|
|
from .location import Location
|
2022-03-24 15:48:12 +01:00
|
|
|
from ..signals import Signal
|
2022-03-24 12:13:34 +01:00
|
|
|
|
|
|
|
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))
|
|
|
|
|
2022-03-24 15:48:12 +01:00
|
|
|
def emit(self, signal: Signal) -> callable:
|
|
|
|
return partial(signal, x_0=self.x)
|
|
|
|
|
|
|
|
def recv(self, signal: Signal) -> callable:
|
2022-03-24 12:13:34 +01:00
|
|
|
"""
|
|
|
|
Return a function that traces the signal as a function of time
|
|
|
|
at the antenna's location
|
|
|
|
"""
|
2022-03-24 15:48:12 +01:00
|
|
|
return partial(signal, x_f=self.x)
|
2022-03-24 12:13:34 +01:00
|
|
|
|
|
|
|
receive = recv
|
|
|
|
|
|
|
|
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))
|