DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Averaging sub sets of a channel

I am trying to average a  subset of a data channel during a DO LOOP (see below).   I have tried using the code below (using the call StatBlockCalc) but this generates several thousand enties into the Data group. ( How can I have one channel (eg "Averaged Ground speed")  with all the individual results in this channel.

 

Speed is also important since the data sets can be large.

 

Thanks

 

David

 

For

I = 1To23

 StatSel(I) = "No"

Next

StatSel(6) = "Yes"' Arith. mean

StatResChnNameFormat= "NameName"

StatResChn       = 1

 

iLoop =1

  

Do

        iLoop = iLoop +

1 + STARTOFFSET

        iPos =

ChnFind("ch(""" & oCO2mInt.GetReference(eRefTypeIndexName) & """) >"&str(MCO2ref+oCO2mInt(iLoop)), iLoop)

       

If iPos > 0Then

          oWindowStartTime(iLoop) = oTime(iPos)

          oWindowTime(iLoop)      = oTime(iPos)-oTime(iLoop)

          oNOXmWindow(iLoop)       = oNOXmInt(iPos) - oNOXmInt(iLoop)

          oDistanceWindow(iLoop)  = ODistanceInt(iPos) - ODistanceInt(iLoop)

          oDistanceStartWindow(iloop) = ODistanceInt(iPos)

Call StatBlockCalc("Channel",str(iLoop)&"-"&str(iPos),"Aligned Data/Aligned Ground Speed")      

EndIf

    

'iLoop = iLoop + 1 +STARTOFFSET

  

Loopuntil iPos = 0' end of file

0 Kudos
Message 1 of 4
(5,659 Views)

Hi David,

 

I need you to describe more exactly how you wish to automatically determine the start and stop X region (Time) over which you wish to run your average.  I also need you to describe more exactly what the "individual results" are you wish to see in the one result channel.  I believe I can help you achieve your goals once I understand better what you want.

 

Can you send over your data set?

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 4
(5,639 Views)

Brad

 

The calculations are for Emission calculations for vehicles.  The main input data set is a second-by-second file containing many channels / groups. For a number of the raw channels (eg distance) the raw data is first integrated and then analyzed into a series of windows

 

oDistanceWindow(iLoop)  = ODistanceInt(iPos) - ODistanceInt(iLoop)

(

Each window is defined by a start (iloop) and end index (ipos) referencing.Each result is then added to an output group.

 

However my problem is I want  to calculate a statistical parameter for each of these sub-groups of data and generate an output group with these results. An example being the mean speed. This is not a good example since this can be calcuated easily by dividing the distance and time already being calculated.

 

I hope this helps

 

David

 

 

 

0 Kudos
Message 3 of 4
(5,625 Views)

Hi David,

 

OK, it sounds like you're quite comfortable finding the multiple time windows over which you want to execute the channel averaging.  The code you submitted with the StatBlockCalc() command is also the most efficient way to run calculations over row subsets, so that also looks like it's done.

 

Is the main remaing question how to arrange the result averages the way you want?  You say you want N new groups for the N time windows.  What channels do you want to have in each of these groups?  Will these channels have N values, or will you use the rows differently?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 4
(5,605 Views)