DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

moving average calculation

Hello,
Is there a way to optimaize a moving average calculation?
 
This is currently how I'm doing it:
intEndRange=cint(dblFreq*sngInterval)-1 'get the number of points given the time interval and sample rate
intStartrange=1
do
  Call STATBLOCKCALC("Channel",intStartrange & "-" & intStartrange+intEndRange ,intDataChannel) '... STATDIREC,ROWNOSTR,CHNNOSTR
  if abs(statarithmean)>abs(dblMaxValue) then
    dblMaxValue=statarithmean
    dblMaxTime=(chd(intStartrange,intTimeChannel)+chd(intStartrange+intEndRange,intTimeChannel))/2
  end if
    intStartrange=intStartrange+1
loop until intStartrange+intEndRange>cl(intDataChannel)
 
This works but it is slow for long channels.
Thanx,
Bill.
0 Kudos
Message 1 of 11
(7,767 Views)
Hello punkmonkey,
 
Have you tried using the "Smoothing" function in the "Curve fitting" library? It calculates a running average for a selectable interval of points. The parameters for this calculation are:
 
 
Channel = the data column you wish to calculate the sliding average for
 
Smoothing width = number of points to one side of the data point to be smoothed (i.e. a value of 3 in this field results in 7 points that will be averaged -> the data point itself, plus three neighbors to the left and three to the right).
 
Points to be used = Defines the number of data points DIAdem will use at the beginning or end of the data column (when there aren't enough data points to one side).
 
This function works rather quickly even for large data sets.
 
Please let me know if this is what you were looking for,
 
     Otmar
Otmar D. Foehner
0 Kudos
Message 2 of 11
(7,747 Views)

This works close to what I need. What I am trying to do is get the Moving average from the time interval used in the ASI calculation. The brute force method listed above returns for each Axis:

X = -8.7g at 114.7ms, Y=1.5g at 49.2 ms, Z=2.7g at 44.1ms

The method you described lists

X = -8.7g at 114.7ms, Y=-1.8g at 368.6 ms, Z=-3.4g at 105.3ms

The frequency is 10kHz and the time interval is .05s so my interval about each point should be 2499 samples. The call to the function you presented is listed below:

intEndRange=cint(dblFreq*sngInterval)-1
  Call CHNSMOOTH(intDataChannel,"/Y_smooth",cint(intEndRange/2),"maxNumber")

The values I calculate matched the values calculated by the TRAP (Test Risk Assessment Program) written by the Texas Transportation Institute. I have also noticed a discrepancy between the DIAdem THIV and the calculation from the TRAP program.

Anywho, thanx for you help so far.

Bill

0 Kudos
Message 3 of 11
(7,720 Views)

Bill,

I have forwarded your question to the developer of the Crash functions. He is out of this office at the moment, but he should reply once he returns.

I hope that helps,

    Otmar

Otmar D. Foehner
0 Kudos
Message 4 of 11
(7,671 Views)

Hello Bill,

I've attached a VBS implemenation of DIAdem's ASI calculation routine.

I hope this helps you for further comparison.

If not please provide me some test data with the expected results.

Best regards,

Christian

0 Kudos
Message 5 of 11
(7,511 Views)

I too am having troubles getting the same results for the THIV calculation as calculated by hand (in Excel) using the steps in the EN 1317-1:1998 standard. I am getting the same value for 'Time of Flight' but a slightly different value for the THIV result each time. This is strange, as the Time of Flight value is determined from the theoretical head displacement and the THIV value is a simple calculation once the time of flight has been determined.

 

Does the THIV calculation in Diadem follow the methodology of EN 1317 or does it take a shortcut somewhere?

0 Kudos
Message 6 of 11
(6,531 Views)

Hello David,

 

The THIV calculation in DIAdem follows EN 1317-1.

If you provide me some test data with you Excel calculation I will have a look at this and compare it with DIAdem.

 

Christian

0 Kudos
Message 7 of 11
(6,485 Views)

Hi Christian,

 

I've attached some example data and an excel sheet that follows the calculations from EN 1317-1:1998.

 

In this example, my calculations give a THIV of 18.33km/h, whereas Diadem returns 18.84km/h. Both methods have the same Time of Flight (198.05ms).

 

Thanks for looking into this.

 

David

0 Kudos
Message 8 of 11
(6,448 Views)

Hello again.

David, where is the X.c condition at time 0?

 

We have gone through another round of testing the NCHRP350 calculations and we still do not match the TRAP software. I wrote a THIV calculation script to use in diadem from EN-1317 and the numbers processed from our data come out to be closer to the canned Diadem routine than the TRAP values.

 

Also looking at the spreadsheet provided by David, I wonder about the differences in the integration routines between the Excel method, TRAP and Diadem and any compounded errors that can be propogated.  Typically the velocity is higher in the Diadem calculations.

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

Hi Punkmonkey,

 

My understanding of the THIV calculation is that at time zero the value of ΔX.c (i.e. the integration of vehicular acceleration in ground reference - step 4 in the NCHRP350 document and equation (23) in the EN 1317-1:1998 document) is always set to be zero. In my speadsheet this can be seen in cell J4. Does this answer your question? 

 

I don't have a copy of TRAP so I can't comment on that. However, whenever I compare my calculations with Diadem, I also find that the velocity is higher in Diadem - generally by about 0.5km/h.

 

I too have wondered whether the integration technique would change the values, but what I can't understand is why I always get the same Time of Flight as the Diadem function. If the problem is the integration, it would affect the displacement even more than the velocity (as this is integrated twice), which would affect the impact time, but this has never been a problem when comparing my calculations with Diadem. Do you get the same Time of Flight with your script or TRAP?

Message Edited by David Corless on 02-04-2009 03:48 PM
0 Kudos
Message 10 of 11
(6,229 Views)