Closed jacco-oosterhuis closed 2 years ago
Well, that is the way the bins are situated. If you check the unbinned collective
In [7]: rfc.recorder.collective
Out[7]:
from to
0 7.3 4.2
1 4.9 4.2
2 2.1 6.0
3 4.0 5.0
there is loop with index 1
from 4.9
to 4.2
. If you have only one bin class between 4 and 5 both, from
and to
will be in it. It just means that both, from
and to
are "somewhere between 4.0 and 5.0".
That is why LoopValueRecorder.histogram()
returns an IntervalIndex
ed 2D histogram like
In [8]: hist = rfc.recorder.histogram(bins=np.linspace(1,8,8))
In [9]: hist[hist>0.0]
Out[9]:
from to
(2.0, 3.0] (6.0, 7.0] 1.0
(4.0, 5.0] (4.0, 5.0] 1.0
(5.0, 6.0] 1.0
(7.0, 8.0] (4.0, 5.0] 1.0
dtype: float64
That clearly shows that there is one loop from interval (4.0, 5.0]
to interval (4.0, 5.0]
.
P. S.
LoopValueRecorder.matrix()
is obsolete since 2.0.0 BTW
Ok, but isn't the purpose of binning discretization? This is how I interpret this. This also means that if two turning points, after binning, belong to the same bin, only one of them is actually a turning point. This affects the algorithm and outcome.
Even if it isn't, I think binning like
centers = (np_bins[1:] + np_bins[:-1]) / 2
res_df = np.digitize(df, bins=centers)
makes more sense, as it rounds to the bin centers. (I used matrix() because this is easier for us in postprocessing =) ).
The purpose of the binning is to classify the collected hysteresis loops into a 2D-histogram, hence the new names of the methods .histogram()
and histogram_numpy()
(the former .matrix()
).
What you might want to do is to digitize the time signal before the rainflow analysis. You can do that easily by
bins = np.linspace(1.0, 8.0, 8)
digitized_signal = bins[np.digitize(timesignal, bins)]
rfc.process(digitized_signal)
As you said this will drop all the hysteresis loops that happen do fall into the same bin.
Edit: corrected the np.digitize()
call.
Closing this. Please reopen if there are more things to discuss.
Given slightly noisy data, the rainflow counting algorithm gives incorrect results, due to the order of the algorithm (counting before binning) and the way binning is performed
Environment (please complete the following information):
Additional context Add any other context about the problem here.