DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How to adjust sample rate of data?

I have some data collected at 1683 Hz (yes, that was what I had!) and would like to reduce the sampling rate to some meaningful number, say 1024, 500, 400, or similar.

What should I do?

0 Kudos
Message 1 of 11
(9,216 Views)

Hello Zhi_lu,

could you please provide an example of your data? One channel is enough.

0 Kudos
Message 2 of 11
(9,203 Views)

You can try with any data, as long as you can adjust the sample rate, that is:  reduce or increase number of data points for the same waveform.

 

0 Kudos
Message 3 of 11
(9,192 Views)

Last year I did the similar recalculation with following code:

 

Option Explicit
dim i, k(3), n(2), freq(2)
'
freq(0) = 1/Data.Root.ChannelGroups(1).Channels(1).Properties("wf_increment").Value
freq(1) = 20  ' here set the new (requested) frequency in Hz
'
n(0) = Data.Root.ChannelGroups(1).Channels(1).Size
n(1) = freq(1)*n(0)/freq(0)
'
Dim oCh : Set oCh = Data.Root.ChannelGroups(1).Channels
'
for i = 1 to oCh.Count
  k(1) = oCh(i).Properties(1).Value
  k(2) = oCh(i).Properties(2).Value
  k(3) = oCh(i).Properties(3).Value
      Call ChnSplineXYCalc("",ChnName(i),"",ChnName(i),"approximating","Partition complete area",n(1),1,1)
  oCh(i).Properties(1).Value = k(1)
  oCh(i).Properties(2).Value = k(2)
  oCh(i).Properties(3).Value = k(3)
next

Hopefully it helps.

0 Kudos
Message 4 of 11
(9,187 Views)

Thank you!  Could you please add some comments and explain what you were doing, especially why do channel property swapping near the end?  I am a beginner with coding..........

0 Kudos
Message 5 of 11
(9,163 Views)

Well, the calculation is the approximation of your channel (variables with index 0) to a new one (index 1).

The freq(0) and freq(1) are the sampling frequencies for the channels for the case you have waveform channels.

 

The n(0) and n(1) are the numbers of the data points inside the channels. The new created channel should have the number n(1), calculated from n(0) with regard to different sampling ratios.

 

The real code is the line Call ChnSplineXYCalc(..... The properties swapping can be commented out, but then the new channel would have a "system name", something like "Approximated XY", and the same for description and units... Probably one can avoid it by changing of settings, but I use to do it by code.

In short, here you copy the properties from the "old" channel and paste them to the new one.

0 Kudos
Message 6 of 11
(9,137 Views)

Hi ULIHZ,

 

I think the simplest solution would be to create the new Time channel you want with the 1kHz or whatever sampling rate using the ANALYSIS function "Generate Numereric Channel" function in the "Channel Functions" palette.  Then use the ANALYSIS function "Linear Mapping" in the "Curve Fitting" palette to resample the measured data to the desired new Time channel.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 7 of 11
(9,067 Views)

Thanks Brad!  I will give it a try.

0 Kudos
Message 8 of 11
(9,046 Views)

I can generate a time channel and map the data file to that channel, but the results was keeping every point in the data channel rather than removing some of the over sample values.

Did I do something wrong?

 

 

0 Kudos
Message 9 of 11
(9,041 Views)

Hi ULIHZ,

 

Make sure that the Time channel you create has the desired number of points you want the resampled channel to have.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 10 of 11
(9,010 Views)