Gunnstein / fatpack

fatpack provides functions and classes for fatigue analysis of data series.
ISC License
113 stars 23 forks source link

Error in find_rainflow_ranges for boundary cases #14

Open abhijeet-pandey opened 1 year ago

abhijeet-pandey commented 1 year ago

find_rainflow_ranges gives error for arbitrary numpy array. For example if the array doesn't contain any cycles - fatpack.find_rainflow_ranges(np.array([1,2,3,4,5]), return_means=True, k=2**14) produces error.

image

Gunnstein commented 1 year ago

Hey @abhijeet-pandey,

Since you mention "arbitrary": Are there more cases which gives error than if an array does not contain any cycles?

For the case of no cycles in the array, there should at the very least be a different error (FatpackError?) and more descriptive error message. A better solution would perhaps be if an empty array was returned since there are no cycles. I will think a bit more on this issue, but I welcome any help or comments.

Best regards, Gunnstein

abhijeet-pandey commented 1 year ago

I agree, that in case of no cycles - it should return empty array or None. Yes, I did observe this error on a long data set (gigabyte size) that I had which is hard to share. One characteristic of the data was that it had sections with no cycles. Hence, I tried fatpack with artificial data with no cycles and was able to reproduce the same error. I hacked myself out of this error by using a try-except block over the if statement throwing the error and do nothing (do a "pass") in case of an exception. This may not be a correct approach though.

wweijtje commented 1 year ago

Just thinking out loud but would a strain history of np.array([1,2,3,4,5] result in a single residual/half cycle as there is a cycle initiated but not closed.

abhijeet-pandey commented 1 year ago

Half cycle as per the pagoda method.

On Mon, 26 June 2023, 19:43 wweijtje, @.***> wrote:

Just thinking out loud but would a strain history of np.array([1,2,3,4,5] result in a single residual/half cycle as there is a cycle initiated but not closed.

— Reply to this email directly, view it on GitHub https://github.com/Gunnstein/fatpack/issues/14#issuecomment-1607097499, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF3LUVYPYRRDJ67XDK3NXOLXNFKVBANCNFSM6AAAAAARNPHLZI . You are receiving this because you were mentioned.Message ID: @.***>