Skip to content

Commit 0ac61e5

Browse files
committed
Updated docs, dictionary input instead of tuple
1 parent 2c24e9f commit 0ac61e5

File tree

5 files changed

+54
-46
lines changed

5 files changed

+54
-46
lines changed

FLife Showcase.ipynb

Lines changed: 30 additions & 28 deletions
Large diffs are not rendered by default.

FLife/spectralData.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ def __init__(self, input=None, window='hann', nperseg=1280,
214214

215215
# If input is tuple, dictionary is created (backwards compatibility)
216216
elif isinstance(input, tuple) and len(input) == 2:
217+
warnings.warn('Tuple input has been deprecated. Use dictionary input instead.')
217218
# If input is time signal
218219
if isinstance(input[0], np.ndarray) and isinstance(input[1], (int, float)):
219220
input = {'time_history': input[0], 'dt': input[1]}
@@ -265,7 +266,6 @@ def __init__(self, input=None, window='hann', nperseg=1280,
265266

266267
# Uniaxial PSD
267268
elif input['PSD'].ndim==1:
268-
print('Input PSD is uniaxial')
269269
psd = input['PSD']
270270
f = input['f']
271271
self.psd = np.column_stack((f, psd))
@@ -285,9 +285,6 @@ def __init__(self, input=None, window='hann', nperseg=1280,
285285
):
286286
if self.multiaxial_amplitude_spectrum[0].ndim == 3:
287287
self.multipoint = True
288-
289-
290-
#print('Input PSD is correct shape')
291288

292289
if T is not None and fs is not None:
293290
self.t = T

README.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ Here is a simple example on how to use the code:
7070
k = 7.3 # S-N curve inverse slope [/]
7171
7272
# Spectral data
73-
sd = FLife.SpectralData(input=(x, dt))
73+
input_dict = {'time_history': x, 'dt': dt}
74+
sd = FLife.SpectralData(input=input_dict)
7475
7576
# Rainflow reference fatigue life
7677
# (do not be confused here, spectral data object also holds the time domain data)
@@ -90,9 +91,8 @@ SpectralData object contains data, required for fatigue-life estimation: power s
9091
SpectralData is instantiated with `input` parameter:
9192

9293
- `input` = 'GUI' - PSD is provided by user via GUI (graphically and tabulary)
93-
- `input` = (PSD, freq) - tuple of PSD and frequency vector is provided.
94-
- `input` = (x, dt) - tuple of time history and sampling period is provided.
95-
94+
- `input` = dictionary with PSD and frequency vector is provided. (keys ``PSD`` and ``f``)
95+
- `input` = dictionary with time history and sampling period is provided. (keys ``time_history`` and ``dt``)
9696
GUI
9797
***
9898
.. code-block:: python
@@ -137,9 +137,11 @@ Optional parameter for time-history is random generator instance `rg` (numpy.ran
137137
A = 1 # PSD value
138138
PSD = np.interp(freq, [f_low, f_high], [A,A], left=0, right=0) # Flat-shaped one-sided PSD
139139
140-
sd4 = FLife.SpectralData(input = (PSD, freq))
140+
input_dict = {'PSD': PSD, 'f': freq}
141+
142+
sd4 = FLife.SpectralData(input = input_dict)
141143
# time-history can be generated at SpectralData object instantiation. Sampling frequency `fs` and signal length `T` parameter are needed.
142-
sd5 = FLife.SpectralData(input = (PSD, freq), T=1, fs=1e5, rg=rg)
144+
sd5 = FLife.SpectralData(input = input_dict, T=1, fs=1e5, rg=rg)
143145
144146
time_history = sd5.data
145147
# time-history duration and sampling period are dependent on frequency vector length and step
@@ -164,7 +166,9 @@ Time history `x` and sampling period `dt` are given as input. `x` must be of typ
164166
time, signal = FLife.tools.random_gaussian(freq=freq, PSD=PSD, T=10, fs=1e3, rg=rg)
165167
dt = time[1]
166168
167-
sd6 = FLife.SpectralData(input=(signal,dt))
169+
input_dict = {'time_history': signal, 'dt': dt}
170+
171+
sd6 = FLife.SpectralData(input=input_dict)
168172
169173
# Get PSD data from spectralData object
170174
freq = sd6.psd[:,0]

docs/source/FLife.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ Here is a simple example on how to use the code:
5959
k = 7.3 # S-N curve inverse slope [/]
6060
6161
# Spectral data
62-
sd = FLife.SpectralData(input=(x, dt))
62+
input_dict = {'time_history': x, 'dt': dt}
63+
sd = FLife.SpectralData(input=input_dict)
6364
6465
# Rainflow reference fatigue life
6566
# (do not be confused here, spectral data object also holds the time domain data)
@@ -79,8 +80,8 @@ SpectralData object contains data, required for fatigue-life estimation: power s
7980
SpectralData is instantiated with `input` parameter:
8081

8182
- `input` = 'GUI' - PSD is provided by user via GUI (graphically and tabulary)
82-
- `input` = (PSD, freq) - tuple of PSD and frequency vector is provided.
83-
- `input` = (x, dt) - tuple of time history and sampling period is provided.
83+
- `input` = dictionary with PSD and frequency vector is provided. (keys ``PSD`` and ``f``)
84+
- `input` = dictionary with time history and sampling period is provided. (keys ``time_history`` and ``dt``)
8485

8586
GUI
8687
***
@@ -126,9 +127,11 @@ Optional parameter for time-history is random generator instance `rg` (numpy.ran
126127
A = 1 # PSD value
127128
PSD = np.interp(freq, [f_low, f_high], [A,A], left=0, right=0) # Flat-shaped one-sided PSD
128129
129-
sd4 = FLife.SpectralData(input = (PSD, freq))
130+
input_dict = {'PSD': PSD, 'f': freq}
131+
132+
sd4 = FLife.SpectralData(input = input_dict)
130133
# time-history can be generated at SpectralData object instantiation. Sampling frequency `fs` and signal length `T` parameter are needed.
131-
sd5 = FLife.SpectralData(input = (PSD, freq), T=1, fs=1e5, rg=rg)
134+
sd5 = FLife.SpectralData(input = input_dict, T=1, fs=1e5, rg=rg)
132135
133136
time_history = sd5.data
134137
# time-history duration and sampling period are dependent on frequency vector length and step
@@ -153,7 +156,9 @@ Time history `x` and sampling period `dt` are given as input. `x` must be of typ
153156
time, signal = FLife.tools.random_gaussian(freq=freq, PSD=PSD, T=10, fs=1e3, rg=rg)
154157
dt = time[1]
155158
156-
sd6 = FLife.SpectralData(input=(signal,dt))
159+
input_dict = {'time_history': signal, 'dt': dt}
160+
161+
sd6 = FLife.SpectralData(input=input_dict)
157162
158163
# Get PSD data from spectralData object
159164
freq = sd6.psd[:,0]

tests/multiaxial_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_data():
2323
'coin_liwi': 2044.550993026664, #k_a=1.70, k_phi=0.90
2424
'EVMS_out_of_phase': 2083.2568582803156,
2525
'Nieslony': 1592.0621836751761, #s_af = 1, tau_af = 1
26-
'Lemaitre': 1942.5082573579468 # poisson_ratio = 0.5
26+
'Lemaitre': 1942.5082573579468 # poisson_ratio = 0.3
2727
}
2828

2929
#test_PSD

0 commit comments

Comments
 (0)