Caps
pysdrlib.base.caps ¶
What a device can do: tuning and rate ranges, gain stages, filters, antennas, settings
Device.caps is a Capabilities. Before open() it describes the device class (from the class's CAPS); after, the
driver refines it for the unit that is attached (a tuner's real gain steps, the rates its firmware offers...).
caps = sdr.caps
caps.freq # [Range(lo, hi)]: tunable ranges
caps.rates # [Range]: a Range with lo == hi is one discrete rate
caps.gains["rx"] # {stage name: GainStage}, names as the device calls them
caps.settings # {name: Setting}: the device's own controls (sdr.set_setting(name, value))
Classes:
| Name | Description |
|---|---|
GainStage |
One adjustable gain element of a device (its name is whatever the device calls it), in dB |
Range |
A closed interval [lo, hi] (lo == hi: one value). step: spacing of the values in it (0: continuous) |
Chain |
Hardware between a radio and the air that moves frequencies (an LNB, an up/downconverter, a mixer + power amplifier) |
Setting |
A device-specific control. kind: bool, int, float or str; choices: allowed values (None: any of |
Capabilities |
See the module docstring. Lists are empty when the device has no such control |
Functions:
| Name | Description |
|---|---|
nearest |
The value closest to |
at_least |
The smallest value of |
from_json |
The inverse of Capabilities.json() (a remote device's capabilities) |
for_class |
A fresh copy of the capabilities a device class declares in |
GainStage
dataclass
¶
GainStage(step: float, min: float, max: float, default: Optional[float] = None, values: Optional[tuple] = None)
One adjustable gain element of a device (its name is whatever the device calls it), in dB
step: spacing of its values (0: continuous). values: the gains it really has, when they are uneven steps (a
tuner's table); set gains snap to the nearest. default: what set_rx_gain() with no value sets.
Range
dataclass
¶
A closed interval [lo, hi] (lo == hi: one value). step: spacing of the values in it (0: continuous)
Chain
dataclass
¶
Chain(direction: str = 'rx', port: Optional[str] = None, antenna: Optional[str] = None, lo: float = 0.0, invert: bool = False, lo_accuracy: Optional[float] = None, usable: list = list(), optimal: list = list(), name: str = '', channel: Optional[int] = None, polarization: Optional[str] = None, info: dict = dict())
Hardware between a radio and the air that moves frequencies (an LNB, an up/downconverter, a mixer + power amplifier) and the antenna on it. Frequencies a program asks for are over the air ("RF"); the radio tunes "IF".
direction: "rx" or "tx" (a radio can have a chain of each). port: the radio's antenna port it sits behind (None: the
one for any port that has no chain of its own). channel: the radio's channel it is on (None: any), for a radio whose
channels' ports share names (a B210's RX2 on channels 0 and 1, a dual-feed LNB's two outputs on them). lo: Hz of the external LO (0: none, RF == IF); a measured one where it
has been measured. lo_accuracy: how well lo is known, a standard error [Hz] (None: not known; an LNB's LO is off by
tens of kHz to a MHz unless measured or locked). invert: the LO is above the
signal, RF = lo - IF and the spectrum arrives mirrored (RF = IF + lo otherwise).
antenna: the standard of antenna fitted to it (see pysdrlib.base.antennas). usable: [Range] of RF Hz it works at at all
(empty: the antenna's, else whatever the radio's tuning gives). optimal: [Range] of RF Hz it is best at (empty: the antenna's).
polarization: what the feed takes in, one of POLARIZATIONS ("H", "V", "RHCP", "LHCP"; None: not said). It describes
the feed, not the signal.
Methods:
| Name | Description |
|---|---|
to_if |
The radio frequency for an over-the-air one |
to_rf |
The over-the-air frequency for one the radio tunes |
rf_ranges |
|
describe |
What is known about the antenna on it ( |
to_if ¶
to_rf ¶
rf_ranges ¶
ranges (what the radio tunes) as the over-the-air ranges they give through this chain, held to what it is usable at
Source code in src/pysdrlib/base/caps.py
describe ¶
What is known about the antenna on it (pysdrlib.base.antennas.Antenna.describe), None when it names none: from the
registry where it has it, else what the server said
Source code in src/pysdrlib/base/caps.py
Setting
dataclass
¶
Setting(kind: type, doc: str, method: str, choices: Optional[tuple] = None, getter: Optional[str] = None, default: Any = None, per_channel: bool = False)
A device-specific control. kind: bool, int, float or str; choices: allowed values (None: any of kind)
method: the device method that applies it (called with the value). getter: one that reads it back, if any.
per_channel: those methods also take channel= (the setting is per channel).
Capabilities
dataclass
¶
Capabilities(driver: str, channels: dict = (lambda: {'rx': 1, 'tx': 0})(), shared: dict = (lambda: {'freq': 'device', 'rate': 'device', 'gain': 'channel', 'bandwidth': 'channel', 'antenna': 'channel'})(), freq: list = list(), rates: list = list(), default_freq: Optional[float] = None, default_rate: Optional[float] = None, bandwidths: dict = (lambda: {'rx': [], 'tx': []})(), gains: dict = (lambda: {'rx': {}, 'tx': {}})(), gain_modes: dict = (lambda: {'rx': ['manual'], 'tx': ['manual']})(), antennas: dict = (lambda: {'rx': [], 'tx': []})(), clock_sources: list = list(), settings: dict = dict(), chains: list = list(), retune_settle: float = 0.0, retune_samples: int = 0, info: dict = dict())
See the module docstring. Lists are empty when the device has no such control
Methods:
| Name | Description |
|---|---|
stage |
The named gain stage of a direction, or None if the device has no such stage |
gain_range |
Range of the total gain across a direction's stages |
json |
Plain types only (for the remote protocol, logs, UIs) |
stage ¶
The named gain stage of a direction, or None if the device has no such stage
gain_range ¶
Range of the total gain across a direction's stages
json ¶
Plain types only (for the remote protocol, logs, UIs)
Source code in src/pysdrlib/base/caps.py
nearest ¶
The value closest to value that one of ranges allows (a step is honoured)
Source code in src/pysdrlib/base/caps.py
at_least ¶
The smallest value of ranges that is value or more (a step is honoured: the next step up), None when they all stop short of it
Source code in src/pysdrlib/base/caps.py
from_json ¶
The inverse of Capabilities.json() (a remote device's capabilities)
Source code in src/pysdrlib/base/caps.py
for_class ¶
A fresh copy of the capabilities a device class declares in CAPS (what is known before opening one)
Source code in src/pysdrlib/base/caps.py
pysdrlib.base.antennas ¶
Standards of antenna, by name: the band each works at and the band it is best at
A Chain (see pysdrlib.base.caps) names the antenna fitted to a radio instead of repeating its ranges, and selection
(pysdrlib.remote.choose) prefers a radio whose antenna is optimal at the frequency a program wants.
from pysdrlib.base import antennas
antennas.get("ANT500").optimal # [Range(75e6, 1e9)]
antennas.register(antennas.Antenna("MYDISH", kind="dish", size=(0.6, 0.6), impedance=50, optimal=[Range(10e9, 12e9)]))
antennas.find_kind("lpda").measures # "boom length"
antennas.format_antenna(antennas.get("ANT500").describe()) # "ANT500 (Whip / monopole, length 20-88 cm, 50 ohm)"
Classes:
| Name | Description |
|---|---|
Kind |
A type of antenna. key: its short id. name: how it is shown. measures: what an antenna's |
Antenna |
name: how a chain refers to it. usable: [Range] of Hz it works at at all (empty: no limit known). |
Functions:
| Name | Description |
|---|---|
register_kind |
Make |
find_kind |
The |
register |
Make |
find |
The antenna called |
get |
The antenna called |
format_antenna |
One antenna as text, e.g. |
Kind
dataclass
¶
A type of antenna. key: its short id. name: how it is shown. measures: what an antenna's size is for this type
Antenna
dataclass
¶
Antenna(name: str, usable: list = list(), optimal: list = list(), doc: str = '', kind: Optional[str] = None, size: Optional[tuple] = None, impedance: Optional[float] = None)
name: how a chain refers to it. usable: [Range] of Hz it works at at all (empty: no limit known).
optimal: [Range] of Hz it is best at (empty: none declared, so it is never preferred or avoided).
kind: what type it is: a key or name from KINDS, or any text for one that is not there. size: (smallest, largest) in metres
of what that type measures (length of a whip, diameter of a dish; Kind.measures), the same twice for a fixed one.
impedance: ohms
Methods:
| Name | Description |
|---|---|
describe |
Plain types only: what is known about the antenna, for clients and |
describe ¶
Plain types only: what is known about the antenna, for clients and list
Source code in src/pysdrlib/base/antennas.py
register_kind ¶
Make kind known (by its key and its name, case ignored). Raises ValueError for a key that is taken, unless replace
Source code in src/pysdrlib/base/antennas.py
find_kind ¶
The Kind whose key or name is text (case ignored), or None
Source code in src/pysdrlib/base/antennas.py
register ¶
Make antenna known by its name (case ignored). Raises ValueError for a name that is taken, unless replace
Source code in src/pysdrlib/base/antennas.py
find ¶
get ¶
The antenna called name. Raises ValueError listing the known ones when there is none
Source code in src/pysdrlib/base/antennas.py
format_antenna ¶
One antenna as text, e.g. ANT500 (Whip / monopole, length 20-88 cm, 50 ohm); info is Antenna.describe()