Skip to main content

Rainflow

Test rainflow

rainflow is a Python implementation of the ASTM E1049-85 rainflow cycle counting algorythm for fatigue analysis.

Installation

rainflow is available on PyPI:

pip install rainflow

and on conda-forge:

conda install rainflow --channel conda-forge

Usage

See release notes in CHANGELOG.md.

Let's generate a sample time series. Here we simply generate a list of floats but rainflow works with any sequence of numbers, including numpy arrays and pandas Series.

from math import sin, cos

time = [4.0 * i / 200 for i in range(200 + 1)]
signal = [0.2 + 0.5 * sin(t) + 0.2 * cos(10*t) + 0.2 * sin(4*t) for t in time]

Function count_cycles returns a sorted list of ranges and the corresponding number of cycles:

import rainflow

rainflow.count_cycles(signal)
# Output
[(0.04258965150708488, 0.5),
 (0.10973439445727551, 1.0),
 (0.11294628078612906, 0.5),
 (0.2057106991158965, 1.0),
 (0.21467990941625242, 1.0),
 (0.4388985979776988, 1.0),
 (0.48305748051348263, 0.5),
 (0.5286423866535466, 0.5),
 (0.7809330293159786, 0.5),
 (1.4343610172143002, 0.5)]

Cycle ranges can be binned or rounded to a specified number of digits using optional arguments binsize, nbins or ndigits:

rainflow.count_cycles(signal, binsize=0.5)
# Output
[(0.5, 5.5), (1.0, 1.0), (1.5, 0.5)]

rainflow.count_cycles(signal, ndigits=1)
# Output
[(0.0, 0.5),
 (0.1, 1.5),
 (0.2, 2.0),
 (0.4, 1.0),
 (0.5, 1.0),
 (0.8, 0.5),
 (1.4, 0.5)]

Full information about each cycle, including mean value, can be obtained using the extract_cycles function:

for rng, mean, count, i_start, i_end in rainflow.extract_cycles(signal): 
    print(rng, mean, count, i_start, i_end) 
# Output             
0.04258965150708488 0.4212948257535425 0.5 0 3
0.11294628078612906 0.38611651111402034 0.5 3 13
...
0.4388985979776988 0.18268137509849586 1.0 142 158
1.4343610172143002 0.3478109852897205 0.5 94 200

Running tests

pip install .[dev]
pytest

Metadata

Release files for rainflow 3.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rainflow 3.3.0
File Size Uploaded Provenance Actions
rainflow-3.3.0.tar.gz 4.3 kB With provenance Details for rainflow-3.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rainflow 3.3.0
File Interpreter ABI Platform Actions
rainflow-3.3.0-py3-none-any.whl Python 3 none any Details for rainflow-3.3.0-py3-none-any.whl

Total release size: 9.3 kB

Release files / rainflow-3.3.0.tar.gz

Download URL rainflow-3.3.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
de0622ce612c387c41f5efa6128ec007673787b1146e10d8632dbeee4b15ba33
BLAKE2b-256 checksum
How to use checksums
c43a0da42c6752575beb7c80e89d0aadc2a289b2d30c5068195877c2c12173ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / rainflow-3.3.0-py3-none-any.whl

Download URL rainflow-3.3.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5569de3cefe21e88ca1b136d7cc8849cac794fb3c1b61cace047f82b0b2f2614
BLAKE2b-256 checksum
How to use checksums
81143941502c5eef3caba948760729b0a0a2525c10e6caca876c7fb2fc116004
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for rainflow 3.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rainflow-3.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page