Resample Operation: Mismatch between "Nr of Points" and "/RATE"
Dear all,
I'm trying to understand the impact in sampling rate in my system and decided to run a quick simulation on Igor using data simulated at 10 kHz and subsampled at different rates. For this purposed i used <igor>Resample</igor> operation
Make/O /N=1000 SampleRates=P+1
Wave DataWave
Variable i
For(i=0; i<dimSize(SampleRates,0); i+=1)
//Generate resampled wave
Variable SamplingRate = SampleRates[i]
Duplicate/O DataWave ResampledWave
Resample /rate=(SamplingRate) ResampledWave
String ResampledWaveName = "ResampledWave_"+num2str(SamplingRate)
Duplicate ResampledWave root:ResampledData:$ResampledWaveName
EndFor
I clipped the original code to focus more on the problem, hope I did not leave out any relevant bit (seems understandable).
In attachment I try to illustrate the behavior of show the result of the resampling the data shown by a dotted line. When data is subsampled to 2Hz over 1 second it produces 2 datapoints as expected, but when is resampled at 3Hz it still continues to produce only 2 datapoints, albeit at different timepoints.
The lower graph in attachment tries to illustrate how this difference between resampling frequency vs number of datapoints found in the generated resampled waves expands higher resampling frequencies.
Can anyone give me a hand with this? It is important that I actually do get a matching number of resampled datapoints to the resample frequency.
Many thanks,
R.
Seems I may have not included the figure as intended...
December 14, 2018 at 08:17 am - Permalink
Attaching your entire experiment would be more helpful.
It is not clear (to me, at least) what your goal is.
I presume you know that undersampling data can lead to "aliasing" (Google is your friend, here).
December 14, 2018 at 08:34 am - Permalink
In reply to Attaching your entire… by JimProuty
Hi Jim,
I can later attach the experiment, for now, simply my question is that if I sample my data at 3Hz for a dataset that spans over 1 second, I would expect to have datapoints for timepoints 0, 0.3333 and 0.66666 seconds. In my example however, for /Rate=3 I have only data for time points 0 and 0.333333 (so only 2 datapoints, not 3)
Hope I made a bit more clear my problem.
Best,
Ricardo
December 14, 2018 at 09:20 am - Permalink
Hello everyone,
I attach above the procedure I am using when describing the problem earlier.
Essentially the procedure does the following:
So, in this example since the time period of the pulse is one second, I would expect the number of data points generated by the resample operation flagged with /rate=3 to be 3 data points, instead I get only two. Likewise, for /rate=6 I get only 5 points and this occurs throughout the entire frequency range.
If anyone could give an idea of what could be wrong here it would be very helpful.
Many thanks,
R.
December 17, 2018 at 03:09 am - Permalink
It does look like an off-by-one bug in Igor.
I'm looking into it.
December 19, 2018 at 04:22 pm - Permalink
I've fixed this (rounding) error for the next release of Igor 8 and for the next Nightly Build.
Look for a Build number >= 32973.
Sorry for the trouble.
December 20, 2018 at 02:55 pm - Permalink
Great Jim!! Many thanks!
December 20, 2018 at 11:26 pm - Permalink