Skip to content

Combine cycle counts

a. List of signals (timeseries)

Count 30 adjacent windows of 144,000 samples each. A whole-record count is a useful comparison when the histories are available together. Use the same bins and curve for each calculation. The time offset records the start of each window in chronological order.

from datetime import datetime, timedelta, timezone

import numpy as np
from py_fatigue import CycleCount, SNCurve
from py_fatigue.damage import get_pm
from py_fatigue.testing import get_random_data, get_sampled_time

fs = 10
window_time = get_sampled_time(duration=14_400, fs=fs)
windows = [
    get_random_data(
        window_time, seed=i, min_=-30.0, range_=180.0,
        random_type="weibull", a=2.0,
    )
    for i in range(30)
]
start = datetime(2024, 1, 1, tzinfo=timezone.utc)
counts = [
    CycleCount.from_timeseries(
        window, timestamp=start + timedelta(seconds=i * len(window) / fs)
    )
    for i, window in enumerate(windows)
]
combined = sum(counts)
recovered = combined.solve_lffd()
whole = CycleCount.from_timeseries(np.concatenate(windows))
curve = SNCurve(3, 12)
for label, spectrum in (
    ("Separate windows", combined),
    ("Recovered", recovered),
    ("Whole history", whole),
):
    print(label, get_pm(spectrum, curve).sum())

The recovered count processes the residual sequence from the joined windows. Compare the two totals under the same S–N curve and inspect the residuals or binning if the difference matters to your analysis. Residual concatenation.

Worked notebook