testing¶
Overview
Generate sampled time vectors and synthetic signals for examples and tests.
py_fatigue.testing ¶
Functions:¶
get_random_data ¶
get_random_data(
t,
seed=2,
random_type="normal",
min_=-10.0,
range_=50.0,
**kwargs
)
Get random data from a given array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
array_like
|
Array from which to get data (time). |
required |
seed
|
int
|
Seed for the random generator. |
2
|
random_type
|
str
|
Type of random data to generate. The default is "normal". See
|
'normal'
|
min_
|
float
|
Minimum value of the random data. The default is -10.0. |
-10.0
|
range_
|
float
|
Range of the random data. The default is 50.0. |
50.0
|
**kwargs
|
Any
|
Keyword arguments for the random generators, see: https://numpy.org/doc/stable/reference/random/generator.html |
{}
|
Returns:
| Type | Description |
|---|---|
array_like
|
Random data. |
Source code in py_fatigue/testing.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
get_sampled_time ¶
get_sampled_time(fs, duration, start=0.0)
Get the time vector of the signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fs
|
float
|
Sampling frequency in Hz. |
required |
duration
|
float
|
Duration of the signal in s. |
required |
start
|
float
|
Start time of the signal in s. The default is 0.0. |
0.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Time vector of the signal. |
Source code in py_fatigue/testing.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |