Using time stamp data to select a point/range in a wave

Good morning, I'm attempting to perform what I believe to be a pretty simple task, but I can't seem to find the precise command I need. I've been using the Igor GUI for a while but a total novice when it comes to writing commands...I'll try to word this as accurately as possible, let me know if I miss the mark.

The short version: For date/time stamped data, is there a command which can reference which data point in the wave corresponds to a specific date/time? For instance, if I have a a stream of data collected on 05/17/1989 from 10:15:00 to 10:17:00, and wanted to get the point in the wave which corresponded to 05/17/1989 10:16:00, how do I reference this in the command line?

A longer description:
I have several waveforms I want to compare to each other; these waveforms were collected from different locations on the same day, at roughly the same time. Each individual data set is arbitrary in length (each has a different number of points), and wave A is longer than wave B (so some points in wave A can't be compared with wave B, for my purposes). Each waveform, however, was referenced to the same clock, so the time stamp information is synchronized between each wave. There is a length of time when they were both being collected, and only that time period is what I want to compare.

What I want to do is duplicate a snippet of each waveform that represents the exact same time period for comparison. A clunky way I've considered doing this is by graphing each dataset and setting my desired time range manually, then duplicating each wave using the displayed portion of their respective graph, but this seems to be more complicated than it needs to be. Is there a way to reference timestamp data when selecting a /R=[,] range for a simple Duplicate operation? I got hung up on this since that operation works using wave points for /R selection rather than date/time values.

My file sizes are quite large, and getting the specific point in each wave that correlates to my desired date/time range seems like it'd make things much easier. Thanks in advance!

-Heath


I take it that the time stamps are in a second wave, so you have an XY pair. If the time stamps are evenly spaced, I would set the X scaling of the Y wave to reflect the time data. Then you can use x2pnt() to get the points corresponding to a particular time.

If the times are not evenly spaced, then you have to keep the X wave of the pair and work from there. In that case, you can use BinarySearch() or BinarySearchInterp() to get the point number corresponding to a time. BinarySearch requires monotonic data, but time usually works that way :)

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
johnweeks wrote:
I take it that the time stamps are in a second wave, so you have an XY pair. If the time stamps are evenly spaced, I would set the X scaling of the Y wave to reflect the time data. Then you can use x2pnt() to get the points corresponding to a particular time.

If the times are not evenly spaced, then you have to keep the X wave of the pair and work from there. In that case, you can use BinarySearch() or BinarySearchInterp() to get the point number corresponding to a time. BinarySearch requires monotonic data, but time usually works that way :)

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com


x2pnt() is exactly what I needed, thank you! That will save me a ton of time...every tiny tidbit I learn about Igor makes me want to gobble up more information, I've been a sponge with this program since I started using using the command line.

I actually just have a start date/time for collection, with a delta value in seconds/sample rate, but it looks like x2pnt() works either way as long as the wave is appropriately scaled.

Much appreciated!
Quote:
I actually just have a start date/time for collection, with a delta value in seconds/sample rate, but it looks like x2pnt() works either way as long as the wave is appropriately scaled.

Sounds like you are describing wave scaling, so I guess your time stamps have already been expressed as X scaling. So, yes, x2pnt() is what you want.

Glad you are enjoying learning about Igor!

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com

In reply to by johnweeks

Hi,

How can I put a particular time as X1? When this particular time is a date/time format:dd/mm/yyyy HH:MM:SS.xxx

Cheers,

Zixuan

Use date2secs as the first parameter to SetScale.

From the help for date2secs:

// This next example sets the X scaling of a wave to 1 day per point, starting January 1, 1993:
Make/N=125 myData = 100 + gnoise(50)
SetScale/P x,date2secs(1993,1,1),24*60*60,"dat",myData
Display myData;ModifyGraph mode=5

// See Also
// For further discussion of how Igor represents dates, see Date/Time Waves, Secs2Date, Secs2Time, time