rainflow


Namerainflow JSON
Version 3.2.0 PyPI version JSON
download
home_pagehttps://github.com/iamlikeme/rainflow
SummaryImplementation of ASTM E1049-85 rainflow cycle counting algorithm
upload_time2023-04-17 07:05:24
maintainer
docs_urlNone
authorPiotr Janiszewski
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Rainflow
========

[![Test rainflow](https://github.com/iamlikeme/rainflow/actions/workflows/tests.yml/badge.svg)](https://github.com/iamlikeme/rainflow/actions/workflows/tests.yml)

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

Installation
------------

`rainflow` is available [on PyPI](https://pypi.org/project/rainflow/):

```
pip install rainflow
```

and [on conda-forge](https://github.com/conda-forge/rainflow-feedstock):

```
conda install rainflow --channel conda-forge
```

Usage
-----

See release notes in [`CHANGELOG.md`](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.

```python
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:

```python
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*:

```python
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:

```python
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
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/iamlikeme/rainflow",
    "name": "rainflow",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Piotr Janiszewski",
    "author_email": "i.am.like.me@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d4/59/57218a5eba4772d1422fe67d37aa3840f80b7bb2b360153d25484f2d32af/rainflow-3.2.0.tar.gz",
    "platform": null,
    "description": "Rainflow\n========\n\n[![Test rainflow](https://github.com/iamlikeme/rainflow/actions/workflows/tests.yml/badge.svg)](https://github.com/iamlikeme/rainflow/actions/workflows/tests.yml)\n\n`rainflow` is a Python implementation of the ASTM E1049-85 rainflow cycle counting\nalgorythm for fatigue analysis.\n\nInstallation\n------------\n\n`rainflow` is available [on PyPI](https://pypi.org/project/rainflow/):\n\n```\npip install rainflow\n```\n\nand [on conda-forge](https://github.com/conda-forge/rainflow-feedstock):\n\n```\nconda install rainflow --channel conda-forge\n```\n\nUsage\n-----\n\nSee release notes in [`CHANGELOG.md`](CHANGELOG.md).\n\nLet's generate a sample time series.\nHere we simply generate a list of floats but `rainflow` works\nwith any sequence of numbers, including numpy arrays and pandas Series.\n\n```python\nfrom math import sin, cos\n\ntime = [4.0 * i / 200 for i in range(200 + 1)]\nsignal = [0.2 + 0.5 * sin(t) + 0.2 * cos(10*t) + 0.2 * sin(4*t) for t in time]\n```\n\nFunction `count_cycles` returns a sorted list of ranges and the corresponding\nnumber of cycles:\n\n```python\nimport rainflow\n\nrainflow.count_cycles(signal)\n# Output\n[(0.04258965150708488, 0.5),\n (0.10973439445727551, 1.0),\n (0.11294628078612906, 0.5),\n (0.2057106991158965, 1.0),\n (0.21467990941625242, 1.0),\n (0.4388985979776988, 1.0),\n (0.48305748051348263, 0.5),\n (0.5286423866535466, 0.5),\n (0.7809330293159786, 0.5),\n (1.4343610172143002, 0.5)]\n```\n\nCycle ranges can be binned or rounded to a specified number of digits\nusing optional arguments *binsize*, *nbins* or *ndigits*:\n\n```python\nrainflow.count_cycles(signal, binsize=0.5)\n# Output\n[(0.5, 5.5), (1.0, 1.0), (1.5, 0.5)]\n\nrainflow.count_cycles(signal, ndigits=1)\n# Output\n[(0.0, 0.5),\n (0.1, 1.5),\n (0.2, 2.0),\n (0.4, 1.0),\n (0.5, 1.0),\n (0.8, 0.5),\n (1.4, 0.5)]\n```\n\nFull information about each cycle, including mean value, can be obtained\nusing the `extract_cycles` function:\n\n```python\nfor rng, mean, count, i_start, i_end in rainflow.extract_cycles(signal): \n    print(rng, mean, count, i_start, i_end) \n# Output             \n0.04258965150708488 0.4212948257535425 0.5 0 3\n0.11294628078612906 0.38611651111402034 0.5 3 13\n...\n0.4388985979776988 0.18268137509849586 1.0 142 158\n1.4343610172143002 0.3478109852897205 0.5 94 200\n```\n\nRunning tests\n-------------\n\n```\npip install .[dev]\npytest\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Implementation of ASTM E1049-85 rainflow cycle counting algorithm",
    "version": "3.2.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ec8a6d626326cec5eb7c2f8f0646607e90a24d862b64976fc8f111bdb30aa2d",
                "md5": "927bb733c1f3bf732ec22cbe188c72f8",
                "sha256": "cb6c254aa1a16a9e658ff3f39c6e5a77650d6c4e8304146169b36516d1f01660"
            },
            "downloads": -1,
            "filename": "rainflow-3.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "927bb733c1f3bf732ec22cbe188c72f8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4941,
            "upload_time": "2023-04-17T07:05:23",
            "upload_time_iso_8601": "2023-04-17T07:05:23.107465Z",
            "url": "https://files.pythonhosted.org/packages/3e/c8/a6d626326cec5eb7c2f8f0646607e90a24d862b64976fc8f111bdb30aa2d/rainflow-3.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d45957218a5eba4772d1422fe67d37aa3840f80b7bb2b360153d25484f2d32af",
                "md5": "26d69445abd140463959dba7ce7bcaad",
                "sha256": "a78f7cd0acab11ccb80567a5c5db9f3a619dee8ac89a5fc861685fe5ffe827fd"
            },
            "downloads": -1,
            "filename": "rainflow-3.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "26d69445abd140463959dba7ce7bcaad",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4515,
            "upload_time": "2023-04-17T07:05:24",
            "upload_time_iso_8601": "2023-04-17T07:05:24.604491Z",
            "url": "https://files.pythonhosted.org/packages/d4/59/57218a5eba4772d1422fe67d37aa3840f80b7bb2b360153d25484f2d32af/rainflow-3.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-17 07:05:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "iamlikeme",
    "github_project": "rainflow",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "rainflow"
}
        
Elapsed time: 0.07987s