8000 refactored demo_waterfall to not use depricated libraries, runs much smoother now. by atkinson · Pull Request #165 · pyrtlsdr/pyrtlsdr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactored demo_waterfall to not use depricated libraries, runs much smoother now. #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

atkinson
Copy link

The demo waterfall app used a number of depricated libraries and techniques.

  • Replaced pylab with pyplot
  • Replaced psd with welch from scipy.signal.
  • Used f-strings for better readability.
  • Added type hints for better clarity.
  • Simplified blit check for FuncAnimation.
  • Refactored the loop structure to avoid unnecessary recalculations.
  • Used np.roll to manage the buffer without excessive copying.
  • Optimised Log Calculation using Numba to optimise the log calculation part for the PSD.
  • Supressed FuncAnimation Warning. (The warning regarding cache_frame_data can be ignored or explicitly set cache_frame_data=False).
  • I have left from future import divsion alone.

I hope my autoformatter doesn't cause any style issues.

import numpy as np
import sys
from rtlsdr import RtlSdr
from scipy.signal import welch
from numba import jit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be optional? I'd rather not add any dependencies than necessary.

Maybe if you move the related log10 function up here and wrap it all in a

try:
    from numba import jit

    @jit(...)
    def log10(...):
        ...

except ImportError:
    log10 = np.log10


# A simple waterfall, spectrum plotter
#
# Controls:
#
# * Scroll mouse-wheel up or down, or press the left or right arrow keys, to
# change the center frequency (hold shift for finer control).
# change the centre frequency (hold shift for finer control).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these spelling and single/double quote changes seem a bit unnecessary. I don't really mind one way or another, but it just seems like a lot of noise for a functional PR.

Not really a big deal in this case. For other types of pull requests though (especially in other projects) I would imagine maintainers not being incredibly thrilled. (FWIW)

keyboard_buffer = []
shift_key_down = False
image_buffer = -100*np.ones((NUM_BUFFERED_SWEEPS,\
NUM_SCANS_PER_SWEEP*NFFT))
image_buffer = -100 * np.ones((NUM_BUFFERED_SWEEPS, NUM_SCANS_PER_SWEEP * NFFT))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These indentation and line-break changes however are much appreciated! (as well as the ones below)

@nocarryr
Copy link
Collaborator

@atkinson thanks for the PR

The failing tests should be fixed (#166) so if you can merge them in and push to your branch, they should be good

@atkinson
Copy link
Author

Thanks for the review. Will remove numba as it doesn't work as a standalone function (I haven't looked into why). Yes sorry about the pedantic quotes etc - I use the formatter, "black" and it's ruthless and unforgiving.

@coveralls
Copy link
coveralls commented Jul 31, 2024

Pull Request Test Coverage Report for Build 10189619615

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 86.308%

Totals Coverage Status
Change from base Build 10189243022: 0.0%
Covered Lines: 851
Relevant Lines: 986

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0