The LoadCollective class

class pylife.stress.LoadCollective(pandas_obj)[source]

A Load collective.

The usual use of this signal is to process hysteresis loop data from a rainflow recording. Usually the keys from and to are used to describe the hysteresis loops. Alternatively also the keys range and mean can be given. In that case the frame is internally converted to from and to where the from values are the lower ones.

property R

Calculate the R values of the load collective.

Returns:

R – The R values of the load collective

Return type:

pd.Series

property amplitude

Calculate the amplitudes of the load collective.

Returns:

amplitude – The amplitudes of the load collective

Return type:

pd.Series

property cycles

The cycles of each member of the collective is 1.0. when no cycles are given

This is for compatibility with LoadHistogram

histogram(bins, axis=None)[source]

Calculate the histogram of cycles along a given axis.

Parameters:
  • bins (int, sequence of scalars or pd.IntervalIndex) – The bins of the histogram to be calculated

  • axis (str, optional) – The index axis along which the histogram is calculated. If missing the histogram is calculated over the whole collective.

Returns:

range histogram

Return type:

LoadHistogram

See also

range_histogram

Examples

Calculate a range histogram of a simple load collective

>>> df = pd.DataFrame(
...     {'range': [1.0, 2.0, 1.0, 2.0, 1.0], 'mean': [0.5, 1.5, 1.0, 1.5, 0.5]},
...     columns=['range', 'mean'],
... )
>>> df.load_collective.histogram([0, 1, 2, 3]).to_pandas()
range   mean
(0, 1]  (0, 1]    0.0
        (1, 2]    0.0
        (2, 3]    0.0
(1, 2]  (0, 1]    2.0
        (1, 2]    1.0
        (2, 3]    0.0
(2, 3]  (0, 1]    0.0
        (1, 2]    2.0
        (2, 3]    0.0
Name: cycles, dtype: float64

Calculate a range histogram of a load collective collection for multiple nodes. The axis along which to aggregate the histogram is given as cycle_number.

>>> element_idx = pd.Index([10, 20], name='element_id')
>>> cycle_idx = pd.Index([0, 1, 2], name='cycle_number')
>>> index = pd.MultiIndex.from_product((element_idx, cycle_idx))
>>> df = pd.DataFrame({
...     'range': [1., 2., 2., 0., 1., 2.],
...     'mean': [0.5, 1.0, 1.0, 0.0, 1.0, 1.5]
... }, columns=['range', 'mean'], index=index)
>>> h = df.load_collective.histogram([0, 1, 2, 3], 'cycle_number')
>>> h.to_pandas()
element_id  range   mean
10          (0, 1]  (0, 1]    0.0
                    (1, 2]    0.0
                    (2, 3]    0.0
            (1, 2]  (0, 1]    1.0
                    (1, 2]    0.0
                    (2, 3]    0.0
            (2, 3]  (0, 1]    0.0
                    (1, 2]    2.0
                    (2, 3]    0.0
20          (0, 1]  (0, 1]    1.0
                    (1, 2]    0.0
                    (2, 3]    0.0
            (1, 2]  (0, 1]    0.0
                    (1, 2]    1.0
                    (2, 3]    0.0
            (2, 3]  (0, 1]    0.0
                    (1, 2]    1.0
                    (2, 3]    0.0
Name: cycles, dtype: float64
property lower

Calculate the lower load values of the load collective.

Returns:

lower – The lower load values of the load collective

Return type:

pd.Series

property meanstress

Calculate the mean load values of the load collective.

Returns:

mean – The mean load values of the load collective

Return type:

pd.Series

range_histogram(bins, axis=None)[source]

Calculate the histogram of cycles for range intervals along a given axis.

Parameters:
  • bins (int, sequence of scalars or pd.IntervalIndex) – The bins of the histogram to be calculated

  • axis (str, optional) – The index axis along which the histogram is calculated. If missing the histogram is calculated over the whole collective.

Returns:

range histogram

Return type:

LoadHistogram

Note

This resulting histogram does not contain any information on the mean stress. Neither does it perform any kind of mean stress transformation

See also

histogram

Examples

Calculate a range histogram of a simple load collective

>>> df = pd.DataFrame(
...     {'range': [1.0, 2.0, 1.0, 2.0, 1.0], 'mean': [0, 0, 0, 0, 0]},
...     columns=['range', 'mean'],
... )
>>> df.load_collective.range_histogram([0, 1, 2, 3]).to_pandas()
range
(0, 1]    0
(1, 2]    3
(2, 3]    2
Name: cycles, dtype: int64

Calculate a range histogram of a load collective collection for multiple nodes. The axis along which to aggregate the histogram is given as cycle_number.

>>> element_idx = pd.Index([10, 20, 30], name='element_id')
>>> cycle_idx = pd.Index([0, 1, 2], name='cycle_number')
>>> index = pd.MultiIndex.from_product((element_idx, cycle_idx))
>>> df = pd.DataFrame({
...     'range': [1., 2., 2., 0., 1., 2., 1., 1., 2.],
...     'mean': [0, 0, 0, 0, 0, 0, 0, 0, 0]
... }, columns=['range', 'mean'], index=index)
>>> h = df.load_collective.range_histogram([0, 1, 2, 3], 'cycle_number')
>>> h.to_pandas()
element_id  range
10          (0, 1]    0
            (1, 2]    1
            (2, 3]    2
20          (0, 1]    1
            (1, 2]    1
            (2, 3]    1
30          (0, 1]    0
            (1, 2]    2
            (2, 3]    1
Name: cycles, dtype: int64
scale(factors)[source]

Scale the collective.

Parameters:

factors (scalar or pandas.Series) – The factor(s) to scale the collective ‘from’ and ‘to’ with.

Returns:

scaled – The scaled histogram.

Return type:

LoadHistogram

shift(diffs)[source]

Shift the collective.

Parameters:

diffs (scalar or pandas.Series) – The diff(s) to shift the collective by.

Returns:

shifted – The shifted histogram.

Return type:

LoadHistogram

property upper

Calculate the upper load values of the load collective.

Returns:

upper – The upper load values of the load collective

Return type:

pd.Series