DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

diadem remove weird value from channel

Dear All,

 

I am facing the following issue:

 

I have weird value as peaks, in one channel that are due to noise and have no physical meaning.

How can I suppress those peaks using a script?

 

I join the data with this post.

 

Thank you very much for your help,

 

Best regards,

 

Louval

Download All
0 Kudos
Message 1 of 10
(7,685 Views)

Hi,

if you need to do this quickly, there is a possibility in VIEW, mark peaks, then press set flags, remove data points and interpolate no values.

if you need to do this repeatedly, use script and delete values which difference is higher then the natural difference of two samples in signal.

 

Simyfren

0 Kudos
Message 2 of 10
(7,664 Views)

Or, try to use Smooth function for this signal.

 

Simyfren

0 Kudos
Message 3 of 10
(7,663 Views)

Hi louval,

 

How about running a digital filter?  This looks pretty good to me (30 Hz low pass):

 

Call ChnFiltCalc("[1]/Time","[1]/IDCCT_HF","/FilteredSignal_30","IIR","Bessel","Low pass",2,30,0,0,1.2,25,"Hamming",1,1)

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 10
(7,650 Views)

Good envening,

 

That works well! Great,

But it is losing the information between 0 and 0.004 s...

 

Would it exist a awy to keep track of the curve at that time as well?

 

Thank you very much,

 

Louval

0 Kudos
Message 5 of 10
(7,644 Views)
Hi,
If you cut only the "weird" values it is possible to use script for this. I usualy use script for this signals.
You might use something like this:
Length - channel length
For i = 1 to Length - 1
Old = chd(i, "[1]/[2]")
New = chd(i+1, "[1]/[2]")
If (Old - New) > 0,1 then
Chd(i+1, "[1]/[2]") = Old
End if
Next

This part of cody is only for inspiration. Sorry for not complete code, I'm without DIAdem during the weekend and I'm writing this help on my phone.
Regards
Simyfren
0 Kudos
Message 6 of 10
(7,637 Views)

Hi Again,

 

If you want to take semyfren's approach, I recommend using red DIAdem commands instead of a VBScript loop and VBScript comparisons-- it will run much faster.

 

R1 = 0.01 ' maximum deviation allowed between points
Set Group = Data.Root.ActiveChannelGroup
Set TimeChannel  = Group.Channels("Time")
Set DataChannel  = Group.Channels("IDCCT_HF")
Set DeltaChannel = Group.Channels.Add("Delta", DataTypeFloat64)

Call ChnDeltaCalc(DataChannel, DeltaChannel)
ChnLength(DeltaChannel) = ChnLength(DataChannel)

Channels = Array(DataChannel, DeltaChannel)
Symbols  = Array("Data", "Delta")
Formula  = "Data = IIF(abs(Delta)>R1, Null, Data)"
Call Calculate(Formula, Symbols, Channels, "")
Call ChnNovHandle(TimeChannel, DataChannel, "Interpolate", "XY", 1, 0)
Call Group.Channels.Remove(DeltaChannel.Name)

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 7 of 10
(7,624 Views)

Hi Brad,

thank you for your code. I must say that your example will help me very much. Your way is more elegant and and faster of course. Ideal for this example.

 

Thanks for inspiration into my future projects!

 

Simyfren

0 Kudos
Message 8 of 10
(7,617 Views)

Hello Brad, firstly i'm sure its nice to hear that your reply is still helping people 5 years on. I have used your piece of code and adapted it for a signal that i am using, bu ti would like to make 1 tweak that i cant figure out. I do not want to delete the original data.

 

Many thanks

0 Kudos
Message 9 of 10
(3,319 Views)

Hi Simyfren,

 

There are two spots in the code that operate "in place".  The first is in the Calculate() command and the second is in the ChnNoVHandle() command (because the 5th parameter is a 1=TRUE).  I think the best thing for you would be to give the "Delta" channel the name of the new channel you want to create ("NewData"), change the Calculate() formula to assign values to the "Delta" channel instead of the "Data" channel, and choose not to delete the "Delta" channel at the end, because it now has your results:

 

R1 = 0.01 ' maximum deviation allowed between points
Set Group = Data.Root.ActiveChannelGroup
Set TimeChannel  = Group.Channels("Time")
Set DataChannel  = Group.Channels("IDCCT_HF")
Set DeltaChannel = Group.Channels.Add("NewData", DataTypeFloat64)

Call ChnDeltaCalc(DataChannel, DeltaChannel)
ChnLength(DeltaChannel) = ChnLength(DataChannel)

Channels = Array(DataChannel, DeltaChannel)
Symbols  = Array("Data", "Delta")
Formula  = "Delta = IIF(abs(Delta)>R1, Null, Data)"
Call Calculate(Formula, Symbols, Channels, "")
Call ChnNovHandle(TimeChannel, DeltaChannel, "Interpolate", "XY", 1, 0)

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 10 of 10
(3,277 Views)