Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Python How to remove attenuation

  1. Jan 28, 2019 #1
    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
     
  2. jcsd
  3. Jan 28, 2019 #2

    Dale

    Staff: Mentor

    Show us what you have tried so far.
     
  4. Jan 28, 2019 #3

    jedishrfu

    Staff: Mentor

    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.
     
  5. Jan 28, 2019 #4
    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.
     
  6. Jan 28, 2019 #5
    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.
     
  7. Jan 28, 2019 #6

    jedishrfu

    Staff: Mentor

    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.
     
  8. Jan 28, 2019 #7

    Svein

    User Avatar
    Science Advisor

    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).
     
  9. Jan 28, 2019 #8
    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.
     
  10. Jan 28, 2019 #9

    Svein

    User Avatar
    Science Advisor

    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.
     
  11. Jan 28, 2019 #10

    Tom.G

    User Avatar
    Science Advisor

    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.
     
  12. Feb 10, 2019 at 7:05 AM #11
    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.
     
  13. Feb 10, 2019 at 7:09 AM #12
    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.
     
  14. Feb 11, 2019 at 11:48 AM #13

    Svein

    User Avatar
    Science Advisor

    Sorry, but you are asking for miracles as integration equals 20dB attenuation per decade.

    You need to rethink your approach!
     
  15. Feb 12, 2019 at 3:06 AM #14
    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?
     
  16. Feb 13, 2019 at 6:45 AM #15

    Svein

    User Avatar
    Science Advisor

    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).
     
  17. Feb 13, 2019 at 9:13 AM #16
    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.
     
  18. Feb 13, 2019 at 11:03 PM #17

    Tom.G

    User Avatar
    Science Advisor

    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
     
  19. Feb 14, 2019 at 5:04 AM #18
    Dear Tom.

    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?

    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.
     
  20. Feb 14, 2019 at 7:33 PM #19

    Tom.G

    User Avatar
    Science Advisor

    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
     
  21. Feb 15, 2019 at 3:22 AM #20
    Dear Tom.G

    Thank you for your kind comments.

    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 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.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?