Skip to content

Commit f3820bf

Browse files
authored
Merge pull request #31 from upb-lea/CorrectionFunctionParameterDescription
Review function parameter description and correct findings
2 parents 4fac695 + 916d834 commit f3820bf

File tree

2 files changed

+76
-65
lines changed

2 files changed

+76
-65
lines changed

pysignalscope/functions.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,29 @@ def fft(period_vector_t_i: Union[List[List[float]], np.ndarray], sample_factor:
3838
>>> out = pss.fft(example_waveform, plot=True, mode='rad', f0=25000, title='ffT input current')
3939
4040
:param period_vector_t_i: numpy-array [[time-vector[,[current-vector]]. One period only
41-
:type period_vector_t_i: np.array
42-
:param sample_factor: f_sampling/f_period, defaults to 1000
41+
:type period_vector_t_i: np.array or List[List[float]
42+
:param sample_factor: f_sampling/f_period with default = 1000 (optional parameter)
4343
:type sample_factor: int
44-
:param plot: insert anything else than "no" or 'False' to show a plot to visualize input and output
44+
:param plot: insert anything else than "no" or 'False' to show a plot to visualize input and output (optional parameter)
4545
:type plot: str
46-
:param mode: 'rad'[default]: full period is 2*pi, 'deg': full period is 360°, 'time': time domain.
46+
:param mode: 'rad'[default]: full period is 2*pi, 'deg': full period is 360°, 'time': time domain. (optional parameter)
4747
:type mode: str
48-
:param f0: fundamental frequency. Needs to be set in 'rad'- or 'deg'-mode
48+
:param f0: fundamental frequency. Needs to be set in 'rad'- or 'deg'-modewith (optional parameter)
4949
:type f0: float
50-
:param title: plot window title, defaults to 'ffT'
50+
:param title: plot window title, defaults to 'ffT' (optional parameter)
5151
:type title: str
52-
:param filter_type: 'factor'[default] or 'harmonic' or 'disabled'.
52+
:param filter_type: 'factor'[default] or 'harmonic' or 'disabled'. (optional parameter)
5353
:type filter_type: str
54-
:param filter_value_factor: filters out amplitude-values below a certain factor of max. input amplitude.
54+
:param filter_value_factor: filters out amplitude-values below a certain factor of max. input amplitude. (optional parameter)
5555
Should be 0...1, default to 0.01 (1%)
5656
:type filter_value_factor: float
57-
:param filter_value_harmonic: filters out harmonics up to a certain number. Default value is 100.
57+
:param filter_value_harmonic: filters out harmonics up to a certain number with default = 100 (optional parameter)
5858
Note: count 1 is DC component, count 2 is the fundamental frequency
5959
:type filter_value_harmonic: int
60-
:param figure_directory: full path with file extension
61-
:type figure_directory: Tuple
62-
:param figure_size: None for auto-fit; fig_size for matplotlib (width, length)
60+
:param figure_size: None for auto-fit; fig_size for matplotlib (width, length) (optional parameter)
6361
:type figure_size: Tuple
62+
:param figure_directory: full path with file extension (optional parameter)
63+
:type figure_directory: Tuple
6464
6565
:return: numpy-array [[frequency-vector],[amplitude-vector],[phase-vector]]
6666
:rtype: npt.NDArray[list]

pysignalscope/scope.py

Lines changed: 64 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,20 @@ def generate_channel(time: Union[List[float], np.ndarray], data: Union[List[floa
4747
Generate a channel object.
4848
4949
:param time: time series
50-
:type time: Union[List[float], np.ndarray]
50+
:type time: List[float] or np.ndarray
5151
:param data: channel data
52-
:type data: Union[List[float], np.ndarray]
53-
:param label: channel label
54-
:type label: Optional[str]
55-
:param unit: channel unit
56-
:type unit: Optional[str]
57-
:param color: channel color
58-
:type color: Union[str, tuple, None]
59-
:param source: channel source
60-
:type source: Optional[str]
61-
:param linestyle: channel linestyle
62-
:type linestyle: Optional[str]
52+
:type data: List[float] or np.ndarray
53+
:param label: channel label (optional parameter)
54+
:type label: str
55+
:param unit: channel unit (optional parameter)
56+
:type unit: str
57+
:param color: channel color (optional parameter)
58+
:type color: str or tuple
59+
:param source: channel source (optional parameter)
60+
:type source: str
61+
:param linestyle: channel linestyle (optional parameter) e.g.'-' '--' '-.' ':'
62+
see also https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html
63+
:type linestyle: str
6364
"""
6465
# check time for a valid type, convert to numpy if necessary
6566
if isinstance(time, List):
@@ -143,28 +144,29 @@ def modify(channel: Channel, data_factor: Optional[float] = None, data_offset: O
143144
144145
:param channel: Scope channel object
145146
:type channel: Channel
146-
:param data_factor: multiply self.data by data_factor
147+
:param data_factor: multiply self.data by data_factor (optional parameter)
147148
:type data_factor: float
148-
:param data_offset: add an offset to self.data
149+
:param data_offset: add an offset to self.data (optional parameter)
149150
:type data_offset: float
150-
:param label: label to add to the Channel-class
151+
:param label: label to add to the Channel-class (optional parameter)
151152
:type label: str
152-
:param unit: unit to add to the Channel-class
153+
:param unit: unit to add to the Channel-class (optional parameter)
153154
:type unit: str
154-
:param color: Color of a channel
155-
:type color: str
156-
:param source: Source of a channel, e.g. 'GeckoCIRCUITS', 'Numpy', 'Tektronix-Scope', ...
155+
:param color: Color of a channel (optional parameter)
156+
:type color: str or tuple
157+
:param source: Source of a channel, e.g. 'GeckoCIRCUITS', 'Numpy', 'Tektronix-Scope', ... (optional parameter)
157158
:type source: str
158-
:param time_shift: add time to the time base
159+
:param time_shift: add time to the time base (optional parameter)
159160
:type time_shift: float
160161
:param time_shift_rotate: shifts a signal by the given time, but the end of the signal will
161-
come to the beginning of the signal. Only recommended for periodic signals!
162+
come to the beginning of the signal. Only recommended for periodic signals! (optional parameter)
162163
:type time_shift_rotate: float
163-
:param time_cut_min: removes all time units smaller than the given one
164+
:param time_cut_min: removes all time units smaller than the given one (optional parameter)
164165
:type time_cut_min: float
165-
:param time_cut_max: removes all time units bigger than the given one
166+
:param time_cut_max: removes all time units bigger than the given one (optional parameter)
166167
:type time_cut_max: float
167-
:param linestyle: channel linestyle, e.g. '--'
168+
:param linestyle: channel linestyle (optional parameter)
169+
for details see parameter description of method 'generate_channel'
168170
:type linestyle: str
169171
:return: Channel object
170172
:rtype: Channel
@@ -548,11 +550,11 @@ def from_numpy(period_vector_t_i: np.ndarray, mode: str = 'rad', f0: Union[float
548550
:type period_vector_t_i: npt.ArrayLike
549551
:param mode: 'rad' [default], 'deg' or 'time'
550552
:type mode: str
551-
:param f0: fundamental frequency in Hz
553+
:param f0: fundamental frequency in Hz (optional parameter)
552554
:type f0: float
553-
:param label: channel label
555+
:param label: channel label (optional parameter)
554556
:type label: str
555-
:param unit: channel unit
557+
:param unit: channel unit (optional parameter)
556558
:type unit: str
557559
558560
:Example:
@@ -595,7 +597,7 @@ def from_geckocircuits(txt_datafile: str, f0: Optional[float] = None) -> List['C
595597
596598
:param txt_datafile: path to text file, generated by geckoCIRCUITS
597599
:type txt_datafile: str
598-
:param f0: fundamental frequency [optional]
600+
:param f0: fundamental frequency (optional parameter)
599601
:type f0: float
600602
:return: List of Channels
601603
:rtype: list[Channel]
@@ -652,7 +654,7 @@ def multiply(channel_1: 'Channel', channel_2: 'Channel', label: Optional[str] =
652654
:type channel_1: Channel
653655
:param channel_2: channel_2, e.g. current channel
654656
:type channel_2: Channel
655-
:param label: label for new dataset_channel
657+
:param label: label for new dataset_channel (optional parameter)
656658
:type label: str
657659
:return: Multiplication of two datasets, e.g. power from voltage and current
658660
:rtype: Channel
@@ -677,7 +679,7 @@ def multiply(channel_1: 'Channel', channel_2: 'Channel', label: Optional[str] =
677679
return channel_power
678680

679681
@staticmethod
680-
def integrate(channel: 'Channel', label: Optional[str] = None):
682+
def integrate(channel: 'Channel', label: Optional[str] = None) -> 'Channel':
681683
"""
682684
Integrate a channels signal.
683685
@@ -686,8 +688,8 @@ def integrate(channel: 'Channel', label: Optional[str] = None):
686688
687689
:param channel: channel with power
688690
:type channel: Channel
689-
:param label: channel label
690-
:type label: Optional[str]
691+
:param label: channel label (optional parameter)
692+
:type label: str
691693
:return: returns a Channel-class, what integrates the input values
692694
:rtype: Channel
693695
"""
@@ -823,9 +825,9 @@ def plot_channels(*channel: List['Channel'], timebase: str = 's', figure_size: O
823825
:type channel: list[Channel]
824826
:param timebase: timebase, can be 's', 'ms', 'us', 'ns' or 'ps'
825827
:type timebase: str
826-
:param figure_size: None for auto-fit; fig_size for matplotlib (width, length in mm)
828+
:param figure_size: None for auto-fit; fig_size for matplotlib (width, length in mm) (optional parameter)
827829
:type figure_size: Tuple
828-
:param figure_directory: full path with file extension
830+
:param figure_directory: full path with file extension (optional parameter)
829831
:type figure_directory: str
830832
831833
:return: Plots
@@ -1237,14 +1239,21 @@ def unify_sampling_rate(*channel_datasets: 'Channel', sample_calc_mode: str, sam
12371239
12381240
:param channel_datasets: dataset according to Channel
12391241
:type channel_datasets: Channel
1240-
:param sample_calc_mode: keyword, which define the sampling rate calculation 'avg', 'max', 'min' 'user'
1242+
:param sample_calc_mode: keyword, which define the sampling rate calculation
1243+
possible keywords are 'avg', 'max', 'min' 'user'
12411244
:type sample_calc_mode: str
1242-
:param sampling_rate: sampling rate defined by the user (only valid, if sample_calc_mode is set to 'user'
1243-
:type sampling_rate: Optional[float]
1244-
:param shift: shift of the sample rate from origin. None corresponds to a shift to first time point of first channel
1245-
:type shift: Optional[float]
1246-
:param mastermode: Indicate, if only the first data set or all data sets are used for sampling rate calculation
1245+
:param sampling_rate: sampling rate defined by the user (optional parameter)
1246+
only valid, if sample_calc_mode is set to 'user'
1247+
:type sampling_rate: float
1248+
:param shift: shift of the sample rate from origin (optional parameter)
1249+
None corresponds to a shift to first time point of first channel
1250+
:type shift: float
1251+
:param mastermode: Indicates the channels, which are used for sampling rate calculation (optional parameter)
1252+
True (default): Only the first channel is used for sampling rate calculation
1253+
False: All channels are used for sampling rate calculation
12471254
:type mastermode: bool
1255+
:return: List of channels
1256+
:rtype: list['Channel']
12481257
12491258
If the mastermode is 'True' (default), only the first data set is used for sampling rate calculation.
12501259
This parameter is ignored, if the sample_calc_mode approach is set to 'user'
@@ -1423,12 +1432,12 @@ def compare_channels(*channels: 'Channel', shift: Optional[List[Union[None, floa
14231432
14241433
:param channels: dataset according to Channel
14251434
:type channels: Channel
1426-
:param shift: phase shift in a list for every input dataset
1427-
:type shift: list[Union[None, float]]
1428-
:param scale: channel scale factor in a list for every input dataset
1429-
:type scale: list[Union[None, float]]
1430-
:param offset: channel offset in a list for every input dataset
1431-
:type offset: list[Union[None, float]]
1435+
:param shift: phase shift in a list for every input dataset (optional parameter)
1436+
:type shift: list[float]
1437+
:param scale: channel scale factor in a list for every input dataset (optional parameter)
1438+
:type scale: list[float]
1439+
:param offset: channel offset in a list for every input dataset (optional parameter)
1440+
:type offset: list[float]
14321441
:param timebase: timebase, can be 's', 'ms', 'us', 'ns' or 'ps'
14331442
:type timebase: str
14341443
"""
@@ -1487,7 +1496,7 @@ def fft(channel: Channel, plot: bool = True):
14871496
14881497
:param channel: Scope channel object
14891498
:type channel: Channel
1490-
:param plot: True to show a figure
1499+
:param plot: True (default) to show a figure (optional parameter)
14911500
:type plot: bool
14921501
:return: numpy-array [[frequency-vector],[amplitude-vector],[phase-vector]]
14931502
:rtype: npt.NDArray[list]
@@ -1515,11 +1524,11 @@ def short_to_period(channel: Channel, f0: Union[float, int, None] = None, time_p
15151524
15161525
:param channel: Scope channel object
15171526
:type channel: Channel
1518-
:param f0: frequency in Hz
1527+
:param f0: frequency in Hz (optional parameter)
15191528
:type f0: float
1520-
:param time_period: time period in seconds
1529+
:param time_period: time period in seconds (optional parameter)
15211530
:type time_period: float
1522-
:param start_time: start time in seconds
1531+
:param start_time: start time in seconds (optional parameter)
15231532
:type start_time: float
15241533
"""
15251534
if not isinstance(f0, (float, int)) != f0 is not None:
@@ -1554,9 +1563,10 @@ def low_pass_filter(channel: Channel, order: int = 1, angular_frequency_rad: flo
15541563
15551564
:param channel: Channel object
15561565
:type channel: Channel
1557-
:param order: filter order
1566+
:param order: filter order with default = 1 (optional parameter)
15581567
:type order: int
1559-
:param angular_frequency_rad: angular frequency in rad. Valid for values 0...1. Smaller value means lower filter frequency.
1568+
:param angular_frequency_rad: angular frequency in rad. Valid for values 0...1. (optional parameter)
1569+
with default = 0.05. Smaller value means lower filter frequency.
15601570
:type angular_frequency_rad: float
15611571
:return: Channel object with filtered data
15621572
:rtype: Channel
@@ -1596,7 +1606,8 @@ def derivative(channel: Channel, order: int = 1) -> Channel:
15961606
15971607
:param channel: Channel object
15981608
:type channel: Channel
1599-
:param order: oder of derivative, e.g. 1st order, ...
1609+
:param order: order of derivative with default = 1 (optional parameter)
1610+
1 corresponds to 1st order
16001611
:type order: int
16011612
:return: Channel object
16021613
:rtype: Channel

0 commit comments

Comments
 (0)