Coder Social home page Coder Social logo

rainflow's Introduction

Rainflow

Rainflow is a Python implementation of the rainflow cycle counting algorythm for fatigue analysis according to ASTM E1049-85. No dependencies beside Python's standard library. Supports both Python 2 and 3.

Basic usage

Let's generate a sample time series of some load (here we create a numpy array but any iterable of numbers would work):

>>> import numpy as np
>>> x = np.linspace(0, 4, 200)
>>> y = 0.2 + 0.5 * np.sin(x) + 0.2 * np.cos(10*x) + 0.2 * np.sin(4*x)

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

>>> import rainflow
>>> cycles = rainflow.extract_cycles(y)
    [(0.11022406179686783, 1.0), (0.11316419853821802, 0.5), (0.20607635324664902, 1.0),
     (0.2148070281383265, 0.5), (0.36749670533564682, 0.5), (0.4389628182518176, 0.5),
     (0.48294318988133728, 0.5), (0.52799626197601901, 0.5), (0.78150280937784777, 0.5),
     (1.102640610792428, 0.5)]

Not interested in all the decimals? Use ndigits:

>>> cycles = rainflow.extract_cycles(y, ndigits=2)
    [(0.11, 1.5), (0.21, 1.5), (0.37, 0.5), (0.44, 0.5), (0.48, 0.5), (0.53, 0.5),
     (0.78, 0.5), (1.1, 0.5)]

rainflow's People

Contributors

iamlikeme avatar

Watchers

James Cloos avatar Pierre Haessig avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.