The module for load collectives
There are two ways to deal with a load collective.
LoadCollectivelets you keep every load hysteresis in and then calculate the amplitude, meanstress and damage for each and every hyteresis indivudually.LoadHistogramkeeps the load information in a binned histogram. That means that not each and every hystresis is stored individually but there are bin classes for the load levels the hysteresis is originating from and one for the levels the hysteresis is open.
This tutorial shows the difference and how to use the two.
- class pylife.stress.collective.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
fromandtoare used to describe the hysteresis loops. Alternatively also the keysrangeandmeancan be given. In that case the frame is internally converted tofromandtowhere thefromvalues 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:
- Returns:
range histogram
- Return type:
LoadHistogram
See also
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:
- 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
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
- class pylife.stress.collective.LoadHistogram(pandas_obj)[source]
- 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 amplitude_histogram
- property cycles
The cycles of each class of the collective.
- Returns:
cycles – The cycles of each class of the collective
- Return type:
pd.Series
- property index_levels: list[str]
The index levels names defining the stress axis of the data object.
Either [“range”, “mean”] or [“from”, “to”]
- 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
- scale(factors)[source]
Scale the collective.
- Parameters:
factors (scalar or
pandas.Series) – The factor(s) to scale the collective with.- Returns:
scaled – The scaled collective.
- Return type:
LoadCollective
- shift(diffs)[source]
Shift the collective.
- Parameters:
diffs (scalar or
pandas.Series) – The diff(s) to shift the collective by.- Returns:
shifted – The shifted collective.
- Return type:
LoadCollective
- 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