{"id":8622,"library":"scikit-rf","title":"Scikit-RF","description":"Scikit-RF is an object-oriented Python library for microwave engineering. It provides tools for network analysis, circuit simulation, calibration, and visualization of S-parameters and other RF components. The current version is 1.11.0, and it maintains an active, though not strictly time-bound, release cadence.","status":"active","version":"1.11.0","language":"en","source_language":"en","source_url":"https://github.com/scikit-rf/scikit-rf","tags":["RF","microwave engineering","network analysis","S-parameters","circuit simulation","touchstone","electrical engineering"],"install":[{"cmd":"pip install scikit-rf","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Fundamental for numerical operations and array handling.","package":"numpy"},{"reason":"Provides scientific computing tools, including signal processing and interpolation.","package":"scipy"},{"reason":"Used for plotting and visualization of RF data.","package":"matplotlib"},{"reason":"Used for data manipulation, particularly for tabular data and time series.","package":"pandas"},{"reason":"Optimizes numerical expressions, speeding up computations.","package":"numexpr"},{"reason":"For handling HDF5 files, often used for data storage.","package":"h5py"}],"imports":[{"note":"The common convention is to import `skrf` as `rf` and access classes through it. `Network` is the core class representing a multi-port network.","wrong":"from scikit_rf import Network","symbol":"Network","correct":"import skrf as rf\nntwk = rf.Network(...)"},{"note":"While functional, direct import from submodules is less common than accessing via the `skrf` namespace.","wrong":"from skrf.frequency import Frequency","symbol":"Frequency","correct":"import skrf as rf\nfreq = rf.Frequency(...)"},{"note":"Similar to `Frequency`, the preferred way is through the top-level `skrf` namespace.","wrong":"from skrf.circuit import Circuit","symbol":"Circuit","correct":"import skrf as rf\ncir = rf.Circuit(...)"}],"quickstart":{"code":"import skrf as rf\nimport matplotlib.pyplot as plt\n\n# Create a dummy 2-port network for demonstration\nf = rf.Frequency(1, 10, 101, 'ghz') # 1-10 GHz, 101 points\ns = rf.Touchstone(f, name='my_network')\n\n# Populate with some dummy S-parameters (e.g., ideal thru) for 2-port\ns.s[:,0,0] = 0 # S11\ns.s[:,1,1] = 0 # S22\ns.s[:,0,1] = 1 # S12\ns.s[:,1,0] = 1 # S21\n\n# Create a Network object from the Touchstone data\nntwk = rf.Network(s=s.s, frequency=f, name='Dummy Thru')\n\n# Plot S21 magnitude in dB\nntwk.plot_s_db(m=1, n=0)\nplt.title(f'{ntwk.name} S21 Magnitude')\nplt.xlabel('Frequency (GHz)')\nplt.ylabel('S21 Magnitude (dB)')\n# plt.show() # Uncomment to display plot\n\nprint(f\"Network name: {ntwk.name}\")\nprint(f\"Network frequency range: {ntwk.frequency.f_ghz[0]:.2f} GHz to {ntwk.frequency.f_ghz[-1]:.2f} GHz\")","lang":"python","description":"This quickstart demonstrates how to create a simple 2-port `Network` object in scikit-rf, populate it with dummy S-parameter data, and then plot its S21 magnitude in dB. It highlights the use of `Frequency` and `Network` classes and the common `plot_s_db` method."},"warnings":[{"fix":"When creating a `Frequency` object, ensure the `unit` argument matches your numerical input (e.g., `rf.Frequency(1, 10, 101, 'ghz')` for GHz input). For existing `Network` objects, access frequency in desired units via properties like `ntwk.f`, `ntwk.f_khz`, `ntwk.f_mhz`, `ntwk.f_ghz`.","message":"Scikit-RF handles frequency units internally, but users often confuse input units (Hz, kHz, MHz, GHz) leading to incorrect calculations or plots. Always be explicit.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the scikit-rf changelog and upgrade guide if migrating from very old versions. Common breaking changes include `Network` constructor arguments or internal attribute restructuring. Ensure your code aligns with the `1.x` series API.","message":"Prior to version 0.16, the `skrf.network.Network` class and other components had different constructors or attribute names. Code written for older versions might fail due to these changes.","severity":"breaking","affected_versions":"< 0.16"},{"fix":"Validate your Touchstone file format. If issues persist, try loading the file into a text editor to confirm its structure and headers. For programmatic inspection, `rf.Network(file='path/to/file.s2p').nports` can confirm the detected port count.","message":"When loading Touchstone files, scikit-rf automatically determines the number of ports. If the file is malformed or unusual, this can lead to incorrect network dimensions or parsing errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Utilize Matplotlib's extensive customization options. After calling `ntwk.plot_s_db(...)`, you can use `plt.xlabel()`, `plt.ylabel()`, `plt.title()`, `plt.grid(True)`, `plt.ylim()`, `plt.style.use('seaborn-v0_8-darkgrid')` (or other styles) to enhance plots. Scikit-rf plots return Matplotlib axes, allowing direct manipulation.","message":"Default plotting styles might not always be ideal for publication or specific analysis. Matplotlib's default may hide details or look unpolished.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"The canonical way to use `Network` is `import skrf as rf; ntwk = rf.Network(...)`. Ensure you are consistently using `rf.Network` after `import skrf as rf` or `from skrf import Network` if you prefer direct import.","cause":"Attempting to access `Network` directly as `skrf.Network` after using `from skrf import Network` or similar, or vice-versa, or due to a partial/incorrect import.","error":"AttributeError: module 'skrf' has no attribute 'Network'"},{"fix":"Correct the `unit` string to one of the accepted values: 'hz', 'khz', 'mhz', 'ghz', or 'thz'. For example: `rf.Frequency(1, 10, 101, 'ghz')`.","cause":"An invalid string was provided for the `unit` argument when creating a `Frequency` object.","error":"ValueError: Frequency unit must be one of ['hz', 'khz', 'mhz', 'ghz', 'thz']"},{"fix":"Double-check the file path. Ensure the file exists, the path is absolute or correct relative to your script's execution directory, and that you have read permissions. Use `os.path.exists()` for debugging.","cause":"The specified Touchstone file path is incorrect, or the file does not exist at the given location.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'my_file.s2p'"},{"fix":"Ensure the `Network` object has valid S-parameter data and dimensions. If creating from scratch, provide `s` (S-parameters array) and `frequency` to the `Network` constructor. If loading, verify the source file's integrity.","cause":"This often occurs when trying to access elements of an S-parameter matrix (e.g., `ntwk.s[:,0,0]`) on a `Network` object that hasn't been properly initialized with S-parameter data or has zero ports/frequencies.","error":"IndexError: index 0 is out of bounds for axis 1 with size 0"}]}