Skip to content

Commit

Permalink
refactor(agents and metrological_streams and streams): renames 'ampl'…
Browse files Browse the repository at this point in the history
… to 'amplitude' and 'phase_ini' to 'initial_phase'
  • Loading branch information
anupam-prasad committed Jul 2, 2021
1 parent ab81aaf commit d0d8271
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
8 changes: 6 additions & 2 deletions agentMET4FOF/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ class SineGeneratorAgent(AgentMET4FOF):
to connected agents via its output channel.
"""

def init_parameters(self, sfreq=500, sine_freq=5, ampl=1, phase_ini=0):
def init_parameters(self, sfreq=500, sine_freq=5, amplitude=1, initial_phase=0):
"""Initialize the input data
Initialize the input data stream as an instance of the :class:`SineGenerator`
Expand All @@ -2116,8 +2116,12 @@ def init_parameters(self, sfreq=500, sine_freq=5, ampl=1, phase_ini=0):
sampling frequency for the underlying signal
sine_freq : float
frequency of the generated sine wave
amplitude : float
amplitude of the generated sine wave
initial_phase : float
initial phase (at t=0) of the generated sine wave
"""
self._sine_stream = SineGenerator(sfreq=sfreq, sine_freq=sine_freq, ampl=ampl, phase_ini=phase_ini)
self._sine_stream = SineGenerator(sfreq=sfreq, sine_freq=sine_freq, amplitude=amplitude, initial_phase=initial_phase)

def agent_loop(self):
"""Model the agent's behaviour
Expand Down
8 changes: 4 additions & 4 deletions agentMET4FOF/metrological_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ class MetrologicalSineGenerator(MetrologicalDataStreamMET4FOF):
called. Defaults to 500.
sine_freq : float, optional
Frequency of the wave function. Defaults to 50.
ampl : float, optional
amplitude : float, optional
Amplitude of the wave function. Defaults to 1.
phase_ini : float, optional
initial_phase : float, optional
Initial phase of the wave function. Defaults to 0.
device_id : str, optional
Name of the represented generator. Defaults to 'SineGenerator'.
Expand Down Expand Up @@ -278,9 +278,9 @@ def __init__(
phase_ini=phase_ini
)

def _sine_wave_function(self, time, sine_freq, ampl, phase_ini):
def _sine_wave_function(self, time, sine_freq, amplitude, initial_phase):
"""A simple sine wave generator"""
value = ampl * np.sin(np.multiply(2 * np.pi * sine_freq, time) + phase_ini)
value = amplitude * np.sin(np.multiply(2 * np.pi * sine_freq, time) + initial_phase)
value += np.random.normal(0, self.value_unc, value.shape)
return value

Expand Down
28 changes: 14 additions & 14 deletions agentMET4FOF/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,25 +384,25 @@ class SineGenerator(DataStreamMET4FOF):
is called
sine_freq : float
frequency of wave function
ampl : float, optional
amplitude : float, optional
Amplitude of the wave function. Defaults to 1.
phase_ini : float, optional
initial_phase : float, optional
Initial phase of the wave function. Defaults to 0.
"""
def __init__(self, sfreq=500, sine_freq=50, ampl: float = 1, phase_ini: float = 0):
def __init__(self, sfreq=500, sine_freq=50, amplitude: float = 1, initial_phase: float = 0):
super().__init__()
self.set_metadata("SineGenerator","time","s",("Voltage"),("V"),"Simple sine wave generator")
self.set_generator_function(
generator_function=self.sine_wave_function,
sfreq=sfreq,
sine_freq=sine_freq,
ampl=ampl,
phase_ini=phase_ini
ampl=amplitude,
phase_ini=initial_phase
)

def sine_wave_function(self, time, sine_freq, ampl, phase_ini):
def sine_wave_function(self, time, sine_freq, amplitude, initial_phase):
"""A simple sine wave generator"""
value = ampl * np.sin(2 * np.pi * sine_freq * time + phase_ini)
value = amplitude * np.sin(2 * np.pi * sine_freq * time + initial_phase)
return value


Expand All @@ -422,25 +422,25 @@ class CosineGenerator(DataStreamMET4FOF):
is called
F : int
frequency of wave function
ampl : float, optional
amplitude : float, optional
Amplitude of the wave function. Defaults to 1.
phase_ini : float, optional
initial_phase : float, optional
Initial phase of the wave function. Defaults to 0.
"""
def __init__(self, sfreq = 500, cosine_freq=50, ampl: float = 1, phase_ini: float = 0):
def __init__(self, sfreq = 500, cosine_freq=50, amplitude: float = 1, initial_phase: float = 0):
super().__init__()
self.set_metadata("CosineGenerator","time","s",("Voltage"),("V"),"Simple cosine wave generator")
self.set_generator_function(
generator_function=self.cosine_wave_function,
sfreq=sfreq,
cosine_freq=cosine_freq,
ampl=ampl,
phase_ini = phase_ini
ampl=amplitude,
phase_ini = initial_phase
)

def cosine_wave_function(self, time, cosine_freq, ampl, phase_ini):
def cosine_wave_function(self, time, cosine_freq, amplitude, initial_phase):
"""A simple cosine wave generator"""
value = ampl * np.cos(2 * np.pi * cosine_freq * time + phase_ini)
value = amplitude * np.cos(2 * np.pi * cosine_freq * time + initial_phase)
return value


Expand Down

0 comments on commit d0d8271

Please sign in to comment.