src.pynanovna.pynanovna.VNA
- class VNA(vna_index=0, logging_level='info')[source]
Bases:
objectInitialize a VNA object for the NanoVNA.
- Args:
vna_index (int): If multiple NanoVNAs are connected you can specify which to use. logging_level (str): The level of outputs. ‘critical’, ‘info’ or ‘debug’. Defaults to ‘info’.
Methods
Calculates a calibration from the steps.
Runs a sweep and uses the data for calibration.
Get info about your NanoVNA and the connection to it.
Check if the NanoVNA is connected.
Disconnect the NanoVNA.
Load a previous calibration from a file.
Save the current calibration.
Manually set offset delay.
Set the sweep parameters.
There is a small sleep time in the communication with the NanoVNA, which is needed.
Creates a data stream from the continuous sweeping.
Function to save the stream to a csv file.
Run a single sweep and return the data.
- calibrate()[source]
Calculates a calibration from the steps.
- Raises:
Exception: If the calibration is not successfully calculated.
- calibration_step(step)[source]
Runs a sweep and uses the data for calibration.
- Args:
step (str): The calibration step.
- info()[source]
Get info about your NanoVNA and the connection to it.
- Return type:
- Returns:
dict: A dictionary with the info.
- is_connected()[source]
Check if the NanoVNA is connected.
- Return type:
- Returns:
bool: If it is connected or not.
- kill()[source]
Disconnect the NanoVNA.
- Raises:
Exception: If the NanoVNA was not successfully disconnected.
- load_calibration(filename)[source]
Load a previous calibration from a file.
- Args:
filename (str): The file containing the previous calibration.
- save_calibration(filename)[source]
Save the current calibration.
- Args:
filename (str): The filename for the calibration.
- set_offset_delay(delay)[source]
Manually set offset delay. This is used in calibration.
- Args:
delay (float): The delay.
- set_sweep(start, stop, points)[source]
Set the sweep parameters.
- Args:
start (int): The start frequnecy. stop (int): The stop frequency. points (int): Number of points in the sweep.
- set_vna_wait(wait)[source]
- There is a small sleep time in the communication with the NanoVNA, which is needed.
You can change the sleep time in order to speed up the communication. Beware of unexpected errors if setting this to lower than 0.05.
- Args:
wait (float): Time in seconds
- stream(overwrite_wait=0.05)[source]
Creates a data stream from the continuous sweeping.
- Args:
- overwrite_wait: Do not change if you don’t know what youre doing.
This can be used to lower the wait in the hardware functions.
- Yields:
tuple: Yields a list of data when new data is available. Each datapoint: (s11, s21, frequencies)
- stream_to_csv(filename, nr_sweeps=inf, skip_start=5, sweepdivider='sweepnumber: ')[source]
Function to save the stream to a csv file.
- Args:
filename (str): The filename to save to. nr_sweeps (int): Number of sweeps to run. Defaults to 10. skip_start (int): The NanoVNA usually gives bad data in the beginning, therefore this data can be skipped. Defaults to 5. sweepdivider (str): A string to write between every sweep data to divide.
- Raises:
TypeError: If the filename is not a string.