Search code examples
octave

Installation of Rainflow algorithm for Octave


I woud like to ask you a question regarding of installation of Rainflow package from this site: https://github.com/AmritaLonkar/rainflow-octave

I should be this https://de.mathworks.com/matlabcentral/fileexchange/3026-rainflow-counting-algorithm modified Matlab package for Octave, but it does not work. Installation is written here, but I am not able to do so. I am NOT a programmer, so I would like to ask you for help and detailed procedure of installation.

Compilation and installation for GNU Octave

  1. Do the following to create a compiled mex-file from "rainflow.c" and to test the result: $ cd ./rainflow-octave$ make$ ls ./src/rainflow.mexrainflow.mex$ make test
  2. Move files: rainflow.mex, rainflow.m and sig2ext.m to a place where GNU Octave can find them. Octave will locate oct- or mex- files automatically if they are in a directory listed in the search path. To figure out the search path, do: $ octaveoctave> path Octave's search path contain the following directories: . /usr/local/share/octave/site-m Please do not hesitate to ask more questions if needed.

Best regards Michal

My system


Solution

  • I was able to build and run the rainflow package just using Octave 6.2.0 on my Windows 10 system.

    Octave is capable of performing some compilation internally in order to build packages. I have no idea how to use the rainflow tool once built, but the following process worked to create it:

    1. download the rainflow source tree and unzip it to it's own folder. This is normally the purpose of the git program mentioned above. It downloads and manages source code. Instead, manually download the source code.
    • Start from the rainflow page
    • click the Green button that says Code
    • click Download ZIP, save the file in a folder named rainflow where you'll be able to find it again. I used C:\Octave\rainflow\.

    Now open Octave. You can use the pkg tool to build an installable package from the downloaded source code and then install it. This package is simple enough that the Octave-Windows environment is sufficient to perform the build:

    • in Octave, use either the cd command or the folder tree in the upper left of Octave to navigate to the folder where you saved rainflow. In my case, using the cd command I would type cd c:\octave\rainflow\. Yours might be different.

    • the only file in that folder should be rainflow-octave-master.zip

    • now, use the pkg tool to compile the package using the command pkg build . rainflow-octave-master.zip (the . means it will save the package in the current folder.)

    • When it finishes there should now be a second file in that folder named rainflow-1.0.2-x86_64-w64-mingw32-api-v55.tar.gz

    • install the package using the command pkg install rainflow-1.0.2-x86_64-w64-mingw32-api-v55.tar.gz (It will give some warnings about documentation, but the package should still install.)

    • verify installation by listing installed packages using the command pkg list. you should see rainflow in the list of packages. if not, try pkg rebuild then another pkg list. In my case, I see partway down the list:

         rainflow  |   1.0.2 | C:\Users\USERNAME\octave\rainflow-1.0.2
      

    You can now use the package by first loading it using the command pkg load rainflow.

    Testing it out a bit:

    octave:76> rainflow
    error: rainflow: RAINFLOW requires at least one input argument.
    octave:77> rainflow(1)
    ans = [](3x0)
    octave:78> A = magic(3)
    A =
    
       8   1   6
       3   5   7
       4   9   2
    
    octave:79> rainflow(A)
    ans =
    
       0.5000   2.0000   0.5000   0.5000   3.5000
       3.5000   3.0000   8.5000   6.5000   5.5000
       1.0000   1.0000   0.5000   1.0000   0.5000
    

    The only issue I see is that afterward help rainflow does not show the help from rainflow.m, I suspect it should be included in the rainflow.c file. maybe this has to do with a change in octave since rainflow was created? if you want to read the help, you need to navigate to the package installation location or the location of the source files you unzipped and type help rainflow, at which point it will show:

    octave:49> help rainflow
    'rainflow' is a script from the file C:\octave\rainflow\src\rainflow.m
     RAINFLOW cycle counting.
       RAINFLOW counting function allows you to extract
       cycle from random loading.
    
     SYNTAX
       rf = RAINFLOW(ext)
       rf = RAINFLOW(ext, dt)
       rf = RAINFLOW(ext, extt)
    
     OUTPUT
       rf - rainflow cycles: matrix 3xn or 5xn dependend on input,
         rf(1,:) Cycles amplitude,
         rf(2,:) Cycles mean value,
         rf(3,:) Number of cycles (0.5 or 1.0),
         rf(4,:) Begining time (when input includes dt or extt data),
         rf(5,:) Cycle period (when input includes dt or extt data),
    
     INPUT
       ext  - signal points, vector nx1, ONLY TURNING POINTS!,
       dt   - sampling time, positive number, when the turning points
              spaced equally,
       extt - signal time, vector nx1, exact time of occurrence of turning points.
    
    
       See also SIG2EXT, RFHIST, RFMATRIX, RFPDF3D.
    

    those other functions appear to be included as well and the help works, so you can try help sig2ext, help rfhist, help rfmatrix, and help rfpdf3d. I have not tested to see if they all actually work. But this will get the package up and running for you to start using. Good luck!