Depth data timeseries - How to process?

jensen
Posts: 2
Joined: 2017-06-19
Location: Germany

Hi everybody,

as the subject title suggests, I am currently working on timeseries of an animal tracking project. The data includes one depth reading every 30 seconds over a complete period of 2 month.

I am looking for some kind of mask or filter that marks parts within the timeseries, in which the depth values stay within a certain range for an extended period of time. For instance, the filter should only consider depth values between 20meters and 40 meters that occured for 5 minutes (10 data points) continiously.

In the end, I want to anaylse the abundance or percentage of such filtered events across the whole timeseries of 2 month.

I'd be grateful for any idea or help.

PS: I have used the "Ethographer" plugin for a similiar task previously. However, the "Ethographer mask analysis" seems to miss that duration component I am looking for, or maybe I just did not find that function yet.

Thanks in advance,
Jens


s.r.chinn
Posts: 346
Joined: 2007-08-16
Location: United States

Here are some suggestions that may get you started.
(1) use logical conditions to amplitude-mask your data, so that 'Amp_mask' is unity only when your data is between your 20 and 40 meter ranges, and 0 elsewhere.
(2) make a temporal filter wave (using your same data x-scaling) that is a unit-height square pulse 10 points wide.
(3) duplicate 'Amp_mask' into a destination wave 'wDest' , and convolve the the temporal filter wave with 'wDest', e.g.
Convolve wfilter, wDest
(4) 'wDest' should have an amplitude of 10 when the data conditions satisfy your requirement, and for as long as your 'extended period of time occurs'. It should decrease when there are less than 10 successive data points.

You should be able to refine any small details I may have over-looked.


Igor's picture
Posts: 810
Joined: 2007-06-29
Location: United States

Suppose your data are in depthWave and suppose you are looking for readings between depth1 and dept2. First execute the following to get a wave that shows when the depth is between the specified limits:

  MatrixOP/O pWave=greater(depthWave,depth1)*greater(depth2,depthWave)

Next use the following function to count and locate the places where the duration (number of consecutive points in the depth range) is greater or equal to a given width (measured as the number of points of depthWave)
Function locateMinWidth(inWave,width)
	Wave inWave
	Variable width
 
	Variable rows=DimSize(inWave,0)
	Make/FREE/N=(2*rows) w1=0
	w1[0,rows-1]=inWave[p]					// double width to support rotation
	Duplicate/FREE w1,w2
	Variable i
	width-=1			
	for(i=0;i<width;i+=1)
		rotate 1,w2
		MatrixOP/O/FREE w1=w1*w2
	endfor
 
	Duplicate/FREE/O w1,w2
	rotate 1,w2
	MatrixOP/O locWave=greater(w1,w2)
	Print "Found ",sum(locWave),"instance(s) of width >=",(width+1)
End

I hope this helps,

A.G.
WaveMetrics, Inc.


[ last edited June 29, 2017 - 10:28 ]
ajleenheer
Posts: 71
Joined: 2013-04-26
Location: United States

A.G.'s solution above is probably great, especially since MatrixOP is fast. If for some reason it doesn't work, another possible solution is to use the command FindSequence along with FindValue in a loop.


jensen
Posts: 2
Joined: 2017-06-19
Location: Germany

Hey guys,
first of all thank you very much for your fast and helpful replies. I tested A.G's solution as it seemed very straight forward to me. However I am real beginner when it comes to IGOR programming, because I used IGOR only for data visualization so far. So please don't mind me asking very basic questions now:

(1) I executed the first command line and created a 1,0 matrix for values that apply to my chosen range (depth1 = 20, depht2 =40) with the depth wave called "D"

Just like this:
MatrixOP/O pWave=greater(D,20)*greater(40,D)

(2) I created a new procedure with A.G's function setting "width-=10". This determines the number of consecutive points to be considered for the duration filter, right?

(3) After compiling the procedure I do not get a direct output, so I would like to know which options do I have for visualization? Guess there is an easy way to get an output wave or matrix? Or could this be directly incorporated into a depth timeseries graph?

Once again looking forward to your replies,

Jens


Igor's picture
Posts: 810
Joined: 2007-06-29
Location: United States

If you executed the procedure it should have printed to the history the count of intervals that satisfied the required conditions.

I think you would benefit from using the Data Browser. After executing the code you should browse through the relevant waves and display all those that interest you. In particular you should look at pWave which will contain all the instances where the depth was within the specified range. You can then display locWave for all the instances there the depth was within the specified range for the specified duration.

A.G.


Back to top