Jump to content

Finding the low Peaks on a line chart


Recommended Posts

Hello,

I have an interesting topic, that I kind of solved it partially. 

I have a line chart with a shape that is similar to sinus and I would like to create a trigger (a 1) every time the signal peaks down (or up). I created a calculated column for that (using LastPeriods) and I get some of the peaks but I am missing some. Maybe the interval is wrong (40), I tried a different numbers but this was my best guess. The line is ROP_FT (purple).

Here is my column:

case  WHEN 
[ROP_FT]=Min([ROP_FT]) over (LastPeriods(40,[EPOCH])) then 1 else 0 END

Is it possible to refine the query, maybe. not sure how. Many thanks

image.thumb.png.6dcc63732781ec318f2ab660343cc9e4.png

Link to comment
Share on other sites

Hi Christian,

Could you elaborate a bit more about the other variables? And do you want a trigger, each time the purple line is diverting from a straight line? Because that seems to be always the case in your screenshot.
Also, it would be great if you could share a dataset and/or your dxp file so we can look into it more in depth.

Kind regards,

David

Link to comment
Share on other sites

  • 5 weeks later...

Hi David, sorry for the late reply, I was on vacation. I attached the .dxp file and the data table is LIC query (581_303BH) and the interval is the one in the previous screenshot (April 30 from 7pm to 7:20pm). The idea for this project is to identify a drilling dysfunction that would make ROP to fluctuate (as a sinusoidal wave). If I can catch the peaks (max or min) for this behavior then we can create a trigger if we have 5 peaks in 30 sec for example. Otherwise, will not be important.

Thank you for trying to look into it. I hope we can find a solution.

581-303BH-LIC query.dxp

Link to comment
Share on other sites

Hi Cristian

Can I make this suggestion? 


Could you consider looking for a "local" outlier in the sense that you want to identify high or low values during the last n periods (you can find the right value for n later as explained in the next paragraphs)
First, calculate the following columns 

  • the min, ROPBetweenRows_MIN:::min([ROPBetweenRows]) OVER (LastPeriods(${Periods},[DATE_TIME]))
  • the max , ROPBetweenRows_MAX:::MAX([ROPBetweenRows]) OVER (LastPeriods(${Periods},[DATE_TIME]))
  • the average , ROPBetweenRows_AVG::::AVG([ROPBetweenRows]) OVER (LastPeriods(${Periods},[DATE_TIME]))
  • the standard deviation ROPBetweenRows_STDEV:::StdDev([ROPBetweenRows]) OVER (LastPeriods(${Periods},[DATE_TIME])). 

where ${Periods} is a Document Property

image.thumb.png.ec266a10dea54d6c5d6138b7d52448e7.png

A graphical presentation shows you this. To adjust these curves, you can change the ${Periods} value (via a text area).

Then you add the z-score on the plot like this 

  • avg([ROPBetweenRows]) as [value], 
  • Sum(([ROPBetweenRows] - [ROPBetweenRows_AVG]) / [ROPBetweenRows_STDEV]) as [z-score]

 

image.thumb.png.37ac27e1e2b1a8d6ab2048e8fe0c1ada.png

The z-score values are more normalized and help you decide when to trigger an anomaly.

The same approach can be adopted to calculate a different metric.

I hope this helps.

THE DXP is attached for any further help

581-303BH-LIC query-otadaake.dxp

Edited by Olivier Keugue Tadaa
Link to comment
Share on other sites

Hello.

I worked recently on a very related problem and I have a data function that might work very well for this usecase as well. It is based on a bit different approach than in the previous answer. I will try to use my approach and let you know with the results.

Thanks

Tomas

  • Like 1
Link to comment
Share on other sites

While waiting , here is the next step of the previous approach

Add a calculated column: z-Score :::: ([ROPBetweenRows] - [ROPBetweenRows_AVG]) / [ROPBetweenRows_STDEV]

 

and these custom expressions on your line chart.

  • avg([ROPBetweenRows]) as [value], 
  • Sum(if(Abs([z-Score])>${zscoreMAX},1,0)) as [trigger]. // trigger when the z-score absolute value  is higher than a max-limit

where ${zscoreMAX}, is a document property controlled in a text area via a property control 

image.thumb.png.239d5eefb5dc3425b7897e8f3d741700.png

Playing with the ${zscoreMAX} and the ${Periods} values will certainly provide an acceptable solution

Use the zoom slider in the attached example to see how it works 

581-303BH-LIC query-otadaake.dxp

 

Edited by Olivier Keugue Tadaa
Link to comment
Share on other sites

Thank you, Olivier, for your support. With the zscore we get triggers too many times even though the signal doesn't have a sinusoidal shape. I have something in excel that works a bit better. We identified the sinusoidal shape of the signal and compare it with the entire dataset. When there is a similarity it will trigger (red marks). I was wondering if we can do something similar in Spotfire. I attached some screenshots with the results from excel.

Sample signal.png

Result - trigger.png

Link to comment
Share on other sites

  • 3 weeks later...

I am very sorry for the late reply. I tried my approach but unfortunately, my procedure cannot be applied directly to your data (it is true, it was a bit different use-case as well). There will be some customization needed to my script to achieve this.

Regards

Tomas

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...