Python How to remove attenuation

Dear Sirs,

I have a signal which has an attenuation of 20dB per decade, how do I remove this attenuation using SCIPY? Alternatively how to do it in MATLAB if there are no SCIPY users here?

I'm a SCIPY/MATLAB novice fyg.

Thank you for your kind assistance

Abim
 
10,332
3,865
If you search you might find MATLAB examples of removing attenuation from signals.

I found one such example here where high frequency signals are removed:

https://www.mathworks.com/help/thingspeak/remove-high-frequency-noise-in-measured-data.html

and here's some examples of working with sound in MATLAB:

http://users.jyu.fi/~maarhart/sound-processing-matlab/sound-processing-matlab.html

and here's some SCIpy signal module processing examples:

https://www.dsprelated.com/showarticle/194.php

In your case, I think you may have to write a simple algorithm for it where successive data points are multiplied by a factor to counter the attenuation with the factor increasing in time at the same rate as the attenuation happens.
 
Show us what you have tried so far.
Dale,

I didn't try anything regarding attenuation, I can't really find any clues on the web. So far I only filtered (butterworth low-pass 1st order), integrated and then phase shifted the signal, as I understand an integration is equivalent to -90 degree phase shift and 20dB attenuation per decade. So now I need to correct for the attenuation.
 
If you search you might find MATLAB examples of removing attenuation from signals.

I found one such example here where high frequency signals are removed:

https://www.mathworks.com/help/thingspeak/remove-high-frequency-noise-in-measured-data.html

and here's some examples of working with sound in MATLAB:

http://users.jyu.fi/~maarhart/sound-processing-matlab/sound-processing-matlab.html

and here's some SCIpy signal module processing examples:

https://www.dsprelated.com/showarticle/194.php

In your case, I think you may have to write a simple algorithm for it where successive data points are multiplied by a factor to counter the attenuation with the factor increasing in time at the same rate as the attenuation happens.
jedishrfu, thank you, I know the above methods, but I couldn't find anything about attenuation. So I think you may be right, I have to make my own algorithm but I'm uncertain how to do "factor increasing in time at the same rate as the attenuation happens", I would really appreciate if you have a small pseudo code example to point me in the right direction.
 
10,332
3,865
Sadly no I don't but I think if you think about how db changes then that might help.

As an example, db of the voice changes by -6db each time you double the distance from the source so that suggests a linear function of just adding some db value for each decade.
 

Svein

Science Advisor
Insights Author
1,923
579
I didn't try anything regarding attenuation, I can't really find any clues on the web. So far I only filtered (butterworth low-pass 1st order), integrated and then phase shifted the signal, as I understand an integration is equivalent to -90 degree phase shift and 20dB attenuation per decade. So now I need to correct for the attenuation.
Yes. A Butterworth low-pass 1st order filter has an attenuation of 6dB/octave. That is the purpose of such a filter. So, what do you really want to do?

Hint: A filter with no attenuation is called an all-pass filter (https://en.wikipedia.org/wiki/All-pass_filter).
 
Yes. A Butterworth low-pass 1st order filter has an attenuation of 6dB/octave. That is the purpose of such a filter. So, what do you really want to do?

Hint: A filter with no attenuation is called an all-pass filter (https://en.wikipedia.org/wiki/All-pass_filter).
Svein, thank you for the hint. But I need a low-pass to filter out some noise. Anyway it is not the attenuation of the filter that is my concern, it is the integration which I understand causes a -90 degree phase shift and 20dB attenuation per decade, and it is this attenuation I want to remove.
 

Svein

Science Advisor
Insights Author
1,923
579
Svein, thank you for the hint. But I need a low-pass to filter out some noise. Anyway it is not the attenuation of the filter that is my concern, it is the integration which I understand causes a -90 degree phase shift and 20dB attenuation per decade, and it is this attenuation I want to remove.
An integrator is the ultimate low-pass filter (corner frequency = 0Hz). If you skip the Butterworth, you will have your integrator and low-pass filter combined.
 

Tom.G

Science Advisor
2,506
1,341
Your overall description indicates you are low-pass filtering a signal to reduce noise but you don't want to lose the high frequency part of the signal. Do you see the conflict here? You can add a high-pass filter, but you will also be recovering the noise.

If the signal is 'known' by you, there are a few common ways of accomplishing this.
1) Use a bandpass filter centered on the signal center frequency
2) Use synchronous detection of one sort or another; including a Phase Locked Loop (PLL) for instance to regenerate a clock signal
3) Auto-correlation of the signal is another approach

For any of use to come up with more ideas, we will need a lot more information about the signal, the noise, and their statistics/characteristics.
 
An integrator is the ultimate low-pass filter (corner frequency = 0Hz). If you skip the Butterworth, you will have your integrator and low-pass filter combined.
Dear Svein,

Duly noted, but then I'm still left with 20dB attenuation per decade caused by the integration, and it is this attenuation I want to remove.
 
Your overall description indicates you are low-pass filtering a signal to reduce noise but you don't want to lose the high frequency part of the signal. Do you see the conflict here? You can add a high-pass filter, but you will also be recovering the noise.
Dear Tom

I'm sorry if that is the way it came over, but I'm low-pass filtering to remove noise in the MHz area, while the signal itself is in the KHz area. Then I integrate the resulting signal and I'm left with 20dB attenuation per decade caused by the integration, and it is this attenuation I want to remove.
 

Svein

Science Advisor
Insights Author
1,923
579
Dear Svein,

Duly noted, but then I'm still left with 20dB attenuation per decade caused by the integration, and it is this attenuation I want to remove.
Sorry, but you are asking for miracles as integration equals 20dB attenuation per decade.

You need to rethink your approach!
 
Sorry, but you are asking for miracles as integration equals 20dB attenuation per decade.

You need to rethink your approach!
Dear Svein,

You could be right that my approach is wrong, I read the article Current sensing for energy metering, William Koon, Analog Devices, Inc. ref. "Designing the Integrator" paragraph where it states "an integration can be viewed as a -20dB/decade attenuation and a constant –90° phase shift."

In this context, do I want to compensate for attenuation and phase shift or not?
 

Svein

Science Advisor
Insights Author
1,923
579
In this context, do I want to compensate for attenuation and phase shift or not?
If you do compensate, you are in effect removing the integral.

I think I know what you are aiming for - energy metering. The usual way of doing that is (I am sketching the digital approach, but it can be done in an analog way).
  • Decide on the precision you want
  • Calculate the necessary sampling interval
  • At each sampling interval:
  • Sample the voltage(s) and the current(s)
  • Multiply voltage and current to get power
  • Accumulate the power values (power times sampling interval equals average energy in that interval)
Now it is up to you if you want to log the accumulated value in Joules or kWh (multiply by some constant).
 
If you do compensate, you are in effect removing the integral.

I think I know what you are aiming for - energy metering. The usual way of doing that is (I am sketching the digital approach, but it can be done in an analog way).
  • Decide on the precision you want
  • Calculate the necessary sampling interval
  • At each sampling interval:
  • Sample the voltage(s) and the current(s)
  • Multiply voltage and current to get power
  • Accumulate the power values (power times sampling interval equals average energy in that interval)
Now it is up to you if you want to log the accumulated value in Joules or kWh (multiply by some constant).
Dear Svein,

Yes it's for energy metering and I do follow the digital approach you sketched. However for measuring high frequency high energy pulses I am using a Rogowski coil. The output of the Rogowski coil is the currents time derivative, therefore the output needs to be integrated which means that the integrated signal suffers from attenuation and phase shift. I'm compensating for the phase shift but I'm in doubt whether or not I also should compensate for the attenuation in this context.
 

Tom.G

Science Advisor
2,506
1,341
The integration of a signal from a Rogowski coil is to cancel the inherent differentiation of the coil itself. If you recall your first course in magnetics, it is the change in current that induces a voltage in a conductor. The faster the current changes, the higher the induced voltage. That's why an integrator is needed in the read-out circuit, to give a flat frequency response.

If you search the forums here you will find a few threads that cover Rogowski coils. One of the more extensive ones is:
https://www.physicsforums.com/threads/adder-lp-filter.943146/

Cheers,
Tom
 
Dear Tom.

The integration of a signal from a Rogowski coil is to cancel the inherent differentiation of the coil itself. If you recall your first course in magnetics, it is the change in current that induces a voltage in a conductor. The faster the current changes, the higher the induced voltage. That's why an integrator is needed in the read-out circuit, to give a flat frequency response.
I vaguely remember my first course, yes. ;-) Since I'm trying to measure a current pulse, the issue I really can't completely wrap my head around is this:

A pulse has a start at t0 and I can see on the scope that both the voltage measurement (voltage probe) and the current (Rogowski coil) at t0 is 0 zero i.e. the start of the event. Which is logical because nothing is happening before t0.

But if the subsequent operation of numerical integration (I don't have any hardware implemented integrator) on the Rogowski coil output causes a -90° phase shift, then that brings the start of the integrated Rogowski coil output trace to t-90° which doesn't make sense to me as nothing is happening before t0. And if I compensate for -90° phase shift, I get a sample data-gap from t to t90° and that can't be correct either as the Rogowski coil has an immediate response to current change. You see my logical predicament?

If you search the forums here you will find a few threads that cover Rogowski coils. One of the more extensive ones is:
https://www.physicsforums.com/threads/adder-lp-filter.943146/
Thank you. Very educational thread. I like the combo with the Hall effect sensor, I will try to incorporate that in my own solution when I have the need.

And the challenges I see of designing the "evaluation circuit" makes it a whole project in itself, and since I wanted to measure current and do not have time for a complete current measuring solution, I opted for the digital implementation since I already have a storage scope and a computer to do DSP.

In your discussion I don't see any provisions for correct scaling the Rogowski coil output, which I have read in other papers is -1/M.
 

Tom.G

Science Advisor
2,506
1,341
In your discussion I don't see any provisions for correct scaling the Rogowski coil output, which I have read in other papers is -1/M
Scaling of course depends on the sensitivity and frequency response of the particular Rogowski coil you use. There is some scaling info in the post I referenced above, see posts 28 thru 31: https://www.physicsforums.com/threads/adder-lp-filter.943146/page-2#post-5974713. If I recall correctly, there is a little bit more scattered throughout the thread.

I think you would be much better off purchasing a commercial Rogowski coil subsystem rather than trying to build and calibrate one. For a place to start, see the last post (#31) in the above linked thread. If your time is worth anything that is very likely a lower-cost approach. Or just use a series resistor and float your measuring instruments.

Cheers,
Tom
 
Dear Tom.G

Thank you for your kind comments.

Scaling of course depends on the sensitivity and frequency response of the particular Rogowski coil you use. There is some scaling info in the post I referenced above, see posts 28 thru 31: https://www.physicsforums.com/threads/adder-lp-filter.943146/page-2#post-5974713. If I recall correctly, there is a little bit more scattered throughout the thread.
Yes, the sensitivity is the mutual inductance M, and if you stay on the flat part of the frequency response, then one can just plug the coil directly into the scope and start measuring currents.

If there is no objection by moderators, then I will create a new thread with my question in #18 along with supporting illustrations, I really need to get to the bottom of this phase-shift or no.

I think you would be much better off purchasing a commercial Rogowski coil subsystem rather than trying to build and calibrate one. For a place to start, see the last post (#31) in the above linked thread. If your time is worth anything that is very likely a lower-cost approach. Or just use a series resistor and float your measuring instruments.
I agree with you that that would be the cheapest to do under normal conditions. However I expect my measurements to be disputed, in order to be able to repudiate claims I must have intimate knowledge of the measurements, and I can't do that if I buy a coil from e.g. Pearson. Secondly the whole measurement operation is hampered by high voltages and high currents.
 

Tom.G

Science Advisor
2,506
1,341
if you stay on the flat part of the frequency response, then one can just plug the coil directly into the scope and start measuring currents.
Well, there is a disconnect. A Rogowski coil has no flat part in its frequency response. A Rogowski coil works with a very high load impedance. If you load it with a low impedance you then have a Current transformer; they operate on different principles.
  • A Rogowski coil, being essentially unloaded, has the typical 20dB per decade rising frequency response of an inductor.
  • A current transformer, up to the limits of its core, has rather flat response because the burden resistor on the secondary is reflected back to the primary as an extremely low resistive impedance; it is essentially a step-up transformer with a shorted load.
They are two different critters.
 
Well, there is a disconnect. A Rogowski coil has no flat part in its frequency response. A Rogowski coil works with a very high load impedance. If you load it with a low impedance you then have a Current transformer; they operate on different principles.
  • A Rogowski coil, being essentially unloaded, has the typical 20dB per decade rising frequency response of an inductor.
  • A current transformer, up to the limits of its core, has rather flat response because the burden resistor on the secondary is reflected back to the primary as an extremely low resistive impedance; it is essentially a step-up transformer with a shorted load.
They are two different critters.
Dear Tom.G.

Thank you for your nice and simple distinction between those two methods. I can not count the number of scientific papers I have read that involves the measurement of current using a Rogowski coil, and they all make compelling arguments for the methods chosen, so it is difficult for me to get to the essence of it being a practical type of person.

Regarding the very high load impedance required for the Rogowski coil, it has been suggested that the 1MΩ input impedance of the scope should be sufficient to yield reliable results, obviously the 50Ω impedance of the coax cable should be factored in.

A Rogowski coil, being essentially unloaded, has the typical 20dB per decade rising frequency response of an inductor.
A Rogowski coil output has a 20dB/decade gain and a 90° phase shift, then if I integrate that the gain and phase shift is equalized/gone, and that's what I meant by the "flat part", I'm sorry if I did not express myself technically correct. And by this I answered my own question: No I don't need to remove attenuation and phase shift after the integration.

Thank you for guiding me.
Abim
 

Tom.G

Science Advisor
2,506
1,341
Regarding coax, I would be more concerned with its distributed capacitance. Probably best to use a 10X probe if connecting directly to the coil. Or if there is not enough signal for a 10X probe, use either an active (amplified) probe or build a battery powered pre-amp installed at the coil.
Even some 300 Ohm twin-lead antenna lead-in wire could improve on coax if interference is not a problem.

Since you are interested in 'fast risetime' pulses you may need to pay attention to RF transmission line techniques for any cabling over 1/10 wavelength of the fastest edge you are considering. This does not necessarily apply to scope leads with a 10X probe. For instance with a 40nS risetime, either keep leads under 1 meter long or impedance match all cabling as transmission lines.

There is another thing to consider since you are doing the integration in software. If this is realtime processing, take into account the processing time delay if trying to align the current with another signal, such as voltage. Of course if you are using a digital scope and using it to process the captured waveform, this will all be handled for you.

You've got me curious about the signal source. Can you describe what you are measuring without giving away any secrets?

Cheers,
Tom
 
Dear Tom

Regarding coax, I would be more concerned with its distributed capacitance. Probably best to use a 10X probe if connecting directly to the coil. Or if there is not enough signal for a 10X probe, use either an active (amplified) probe or build a battery powered pre-amp installed at the coil.
Even some 300 Ohm twin-lead antenna lead-in wire could improve on coax if interference is not a problem.
I am connecting directly to the probe which is set at 10X. And here's the great advantage of Rogowski coils; they are easy to roll-up, it takes me five minutes to make a Rogowski coil with sufficient output signal, no need for pre-amp.

And yes interference is very high, but since it's all in the 10's of MHz it's easy to filter out with a butterworth filter. And if you don't want the attenuation and phase shift of a butterworth, you can use SCIPY's filtfilt() function which is lossless.

Since you are interested in 'fast risetime' pulses you may need to pay attention to RF transmission line techniques for any cabling over 1/10 wavelength of the fastest edge you are considering. This does not necessarily apply to scope leads with a 10X probe. For instance with a 40nS risetime, either keep leads under 1 meter long or impedance match all cabling as transmission lines.
Thank you, duly noted. At first I was interested in the widest bandwith possible as I did not know where the pulse were and how it looked, now that I have found the pulse I see that 100KHz is sufficient.

There is another thing to consider since you are doing the integration in software. If this is realtime processing, take into account the processing time delay if trying to align the current with another signal, such as voltage. Of course if you are using a digital scope and using it to process the captured waveform, this will all be handled for you.
I only use the capturing function of the scope, since there is no documentation for how the math functions (here including integration) are implemented.

You've got me curious about the signal source.
That was not my intention.

Can you describe what you are measuring without giving away any secrets?
There are no secrets as such and I would love to tell you about the source, because everything is know, studied and peer-reviewed and can be explained very easily with classical physics. However in my experience when I share information about this source, people shun me, so for that reason I chose not talk about it anymore and walk alone. Which is actually a shame because this project is interesting both from a technical and pecuniary point of view. So I'm sorry about that but you asked and I might as well answer you truthfully, it's just the way things work in a human society.

Kind regards
Abim
 

Want to reply to this thread?

"How to remove attenuation" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top