Skip to content

Commit

Permalink
feat(metrological_streams): adds ampl and phase_ini parameters to…
Browse files Browse the repository at this point in the history
… MetrologicalSineGenerator
  • Loading branch information
anupam-prasad committed Jun 29, 2021
1 parent ee45e1c commit fc9901e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions agentMET4FOF/metrological_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ class MetrologicalSineGenerator(MetrologicalDataStreamMET4FOF):
called. Defaults to 500.
sine_freq : float, optional
Frequency of the wave function. Defaults to 50.
ampl : float, optional
Amplitude of the wave function. Defaults to 1.
phase_ini : float, optional
Initial phase of the wave function. Defaults to 0.
device_id : str, optional
Name of the represented generator. Defaults to 'SineGenerator'.
time_name : str, optional
Expand All @@ -241,6 +245,8 @@ def __init__(
self,
sfreq: int = 500,
sine_freq: float = 50,
ampl: float = 1,
phase_ini: float = 0,
device_id: str = "SineGenerator",
time_name: str = "time",
time_unit: str = "s",
Expand Down Expand Up @@ -268,11 +274,13 @@ def __init__(
uncertainty_generator=self._default_uncertainty_generator,
sfreq=sfreq,
sine_freq=sine_freq,
ampl=ampl,
phase_ini=phase_ini
)

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

Expand Down

0 comments on commit fc9901e

Please sign in to comment.