Giter Club home page Giter Club logo

pynanovna's Introduction

pynanovna

This is a python module for using a NanoVNA.

Installation

Install with pip install pynanovna or pip3 install pynanovna.

Example

import pynanovna

worker = pynanovna.NanoVNAWorker()
stream = worker.stream_data()
for sweep in stream:
    print(sweep)

See src/pynanovna/example.py for a more detailed example on some use cases of the project.

History

Originally this was the fork nanovna-saver-headless from nanovna-saver but when that project no longer shared much code with the original we decided to create a new project.

pynanovna's People

Contributors

tbergkvist avatar

Stargazers

 avatar  avatar Emilis avatar Otto Edgren avatar  avatar Oscar avatar

Watchers

Oscar avatar  avatar

pynanovna's Issues

worker.kill() produces error

worker.kill() produces an error.

Example

from pynanovna import NanoVNAWorker

worker = NanoVNAWorker(verbose=True)
worker.set_sweep(2.9e9,3.1e9,1,101)
worker.calibrate(load_file="signal-processing/oscars_cal.cal")

data = worker.single_sweep()
worker.kill()

produces the error:

NanoVNASaverHeadless is stopping sweepworker now.
Traceback (most recent call last):
  File "c:\Users\Oscar Gren\Documents\PICC\signalprocessing\record.py", line 39, in <module>
    worker.kill()
  File "C:\Users\Oscar Gren\AppData\Local\Programs\Python\Python312\Lib\site-packages\pynanovna\pynanovna.py", line 259, in kill
    self._stop_worker()
  File "C:\Users\Oscar Gren\AppData\Local\Programs\Python\Python312\Lib\site-packages\pynanovna\pynanovna.py", line 190, in _stop_worker
    self.worker_thread.join()
    ^^^^^^^^^^^^^^^^^^
AttributeError: 'NanoVNAWorker' object has no attribute 'worker_thread'

single_sweep() returns same sweep everytime

If you run singe_sweep() you get the same data everytime, example:

from pynanovna import NanoVNAWorker
from time import sleep

worker = NanoVNAWorker(verbose=False)
worker.set_sweep(2.95e9,3.05e9,1,11)
datafile = False #  Set this to a path if you want to play a previously recorded file.

while(True):
    data = worker.single_sweep()
    sleep(1.0)
    print(data[0])

There is however a fix, you simply copy the data object everytime, eg.

while(True):
    data = worker.single_sweep()
    data = (data[0].copy(), data[1].copy())
    sleep(1.0)
    print(data[0])

Bad error message when no vna is connected an no playback file is passed.

This error is shown when the vna is not connected and no playback file is passed:

NanoVNA not found, is it connected? Entering playback mode.
Cannot set sweep in playback mode. Connect NanoVNA and restart.
Cannot calibrate in playback mode. Connect NanoVNA and restart.
Traceback (most recent call last):
File "/Users/teo/repos/picc/signal-processing/test_fourier.py", line 44, in
for s11, s21 in stream:
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pynanovna/pynanovna.py", line 104, in stream_data
self._stream_data()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pynanovna/pynanovna.py", line 132, in _stream_data
self.worker.sweep.set_mode("CONTINOUS")
^^^^^^^^^^^
AttributeError: 'NanoVNAWorker' object has no attribute 'worker'

This is not clear and should be changed to something more informative.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.