# neonel21/qkit-gla architecture

> Architecture diagram of the GitHub repository neonel21/qkit-gla, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/neonel21/qkit-gla
- Repository: https://github.com/neonel21/qkit-gla

## Overview

##### What this repository is
Qkit is a Python-based quantum measurement framework. Its architecture centers on three concerns: controlling laboratory hardware, orchestrating measurement runs, and storing/analyzing the resulting data. The repository is organized as a reusable package plus notebooks, GUI tools, and hardware/service extensions.

##### Core startup and runtime bootstrap
The `qkit.core` package is the runtime backbone. Startup is not a single monolith; it is assembled through staged initialization modules in `qkit/core/s_init`, which handle logging, directory setup, module discovery, update checks, service loading, instrument creation, and final user initialization. This makes startup a pipeline of environment preparation, hardware/service binding, then session readiness.

##### Instrument abstraction layer
Hardware access is concentrated in `qkit/core/instrument_base*`, `instrument_tools.py`, and the large `qkit/drivers` collection. Drivers wrap specific device families such as VNAs, microwave sources, AWGs, DAQs, power supplies, cryostat controllers, and virtual/dummy instruments. The architectural boundary here is “instrument interface vs. concrete hardware implementation,” allowing measurement code to depend on a common driver contract rather than vendor APIs directly.

##### Measurement orchestration layer
The `qkit.measure` package defines how experiments are structured. It contains shared measurement base classes, sample/JSON handling, and domain-specific measurement modules for spectroscopy, transport, oscilloscope, and time-domain experiments. Time-domain support is especially layered, with waveform generation, pulse sequences, AWG loading, and Quantum Machines integration separated into distinct submodules.

##### Data flow from instruments to stored experiments
Typical runtime flow is: notebook or GUI triggers a measurement object → measurement code talks to instrument drivers → acquired arrays/scalars are written into the storage layer → analysis and viewers consume the saved HDF5 output. The repository’s design clearly separates live acquisition from persisted data handling, which is important for traceability and post-processing.

##### Storage subsystem
Persistent experiment data is handled by `qkit.storage`, which is HDF5-centric and built around file, dataset, library, and view helpers. This is the primary data boundary in the system: the measurement layer produces structured data, while the storage layer owns file organization, metadata, date/time handling, and HDF5-specific conventions. The README and docs indicate support for 1D/2D/3D data plus a viewer.

##### Analysis and fitting subsystem
`qkit.analysis` contains post-acquisition computation tools: resonator fitting, circle fits, IV-curve analysis, avoided crossing fits, point tracking, and related helpers. This is not part of the measurement path; it is downstream of storage and is intended for notebook-driven or offline analysis. The circle-fit subpackage is a notable specialized subsystem with both “classic” and newer implementations.

##### User-facing interaction: notebooks and GUI
The repo exposes two main interaction styles. First, Jupyter notebooks/templates under `qkit/doc/notebooks` and `templates/` provide the primary scripting and tutorial surface for experiments and analysis. Second, `qkit.gui` provides graphical tools such as `qviewkit` and plotting helpers for browsing data and monitoring runs. The launch scripts and `jupyter_lab_config.py` indicate that notebook-based operation is a first-class runtime mode.

##### Communication and network services
`qkit.core.lib.com` and `qkit.core.lib.network` support internal communication patterns, including TCP client utilities and signal-based service coordination. This is complemented by a set of service-oriented components under `qkit/services`, which provide standalone or companion processes for lab infrastructure rather than direct measurement logic.

##### External/service-oriented device control
The `qkit.services` tree contains hardware-facing service processes such as switchboxes, nitrogen control, cryostat/fridge monitoring, step attenuator servers, and other Raspberry Pi–style utility servers. These services act as remote control or automation endpoints for equipment that is better managed outside the main measurement process, often via local network or process boundaries.

##### Documentation, examples, and sample data
The `qkit/doc` tree is substantial and includes notebooks, sample HDF5 data, and Sphinx docs. This is not just documentation; it reflects how the framework is intended to be used: interactive notebooks for measurements and analysis, sample artifacts for reproducibility, and generated docs for module-level discovery. The templates in `templates/` reinforce that new experiments are expected to start from notebook templates.

Main entry points: [`qkit/measure/measurement_base.py`](https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/measurement_base.py) (Measure), [`qkit/core/s_init`](https://github.com/neonel21/qkit-gla/tree/master/qkit/core/s_init) (Startup), [`qkit/services/__init__.py`](https://github.com/neonel21/qkit-gla/blob/master/qkit/services/__init__.py) (Services), [`qkit/storage/hdf_file.py`](https://github.com/neonel21/qkit-gla/blob/master/qkit/storage/hdf_file.py) (Storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_startup["Startup<br/>bootstrap pipeline"]
  node_core["Core<br/>[__init__.py]"]
  node_instrument_api["Instruments<br/>instrument API<br/>[instrument_base.py]"]
  node_drivers[("Drivers<br/>[__init__.py]")]
  node_measure_core["Measure<br/>orchestration"]
  node_spectroscopy["Spectroscopy<br/>measurement family<br/>[spectroscopy.py]"]
  node_transport["Transport<br/>measurement family<br/>[transport.py]"]
  node_timedomain["Time Domain<br/>measurement family<br/>[measure_td.py]"]
  node_awg["AWG Pipeline<br/>timedomain stage"]
  node_qm["QM Layer<br/>quantum machines<br/>[qm_qkit_wrapper.py]"]
end

subgraph group_data["Data"]
  node_storage[("Storage<br/>[hdf_file.py]")]
  node_analysis["Analysis<br/>[__init__.py]"]
  node_circle_fit["Circle Fit<br/>fit subsystem<br/>[circlefit.py]"]
end

subgraph group_ui["User Interfaces"]
  node_gui["GUI<br/>qt tools<br/>[__init__.py]"]
  node_qviewkit["QViewKit<br/>data viewer<br/>[main.py]"]
  node_notebooks["Notebooks<br/>interactive surface"]
end

subgraph group_extensions["Extensions"]
  node_services["Services<br/>[__init__.py]"]
  node_raspi_misc["Raspi Misc<br/>utility services"]
  node_qsurveilkit["SurveilKit<br/>monitoring service"]
  node_config["Config<br/>[environment.py]"]
end

subgraph group_docs["Docs & Templates"]
  node_templates["Templates"]
end

node_core -->|"boots"| node_startup
node_startup -->|"loads"| node_config
node_startup -->|"creates"| node_instrument_api
node_startup -->|"binds"| node_services
node_instrument_api -->|"implements"| node_drivers
node_measure_core -->|"uses"| node_instrument_api
node_measure_core -->|"writes"| node_storage
node_measure_core -->|"specializes"| node_spectroscopy
node_measure_core -->|"specializes"| node_transport
node_measure_core -->|"specializes"| node_timedomain
node_timedomain -->|"includes"| node_awg
node_timedomain -->|"includes"| node_qm
node_awg -->|"loads"| node_drivers
node_qm -->|"controls"| node_drivers
node_storage -->|"feeds"| node_analysis
node_analysis -->|"contains"| node_circle_fit
node_gui -->|"hosts"| node_qviewkit
node_gui -->|"browses"| node_storage
node_notebooks -->|"drives"| node_measure_core
node_notebooks -->|"explores"| node_analysis
node_templates -->|"starts from"| node_notebooks
node_services -->|"includes"| node_raspi_misc
node_services -->|"includes"| node_qsurveilkit
node_raspi_misc -->|"mirrors"| node_drivers
node_qsurveilkit -->|"observes"| node_storage
node_config -.->|"configures"| node_services

click node_startup "https://github.com/neonel21/qkit-gla/tree/master/qkit/core/s_init"
click node_core "https://github.com/neonel21/qkit-gla/blob/master/qkit/core/__init__.py"
click node_instrument_api "https://github.com/neonel21/qkit-gla/blob/master/qkit/core/instrument_base.py"
click node_drivers "https://github.com/neonel21/qkit-gla/blob/master/qkit/drivers/__init__.py"
click node_measure_core "https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/measurement_base.py"
click node_spectroscopy "https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/spectroscopy/spectroscopy.py"
click node_transport "https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/transport/transport.py"
click node_timedomain "https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/timedomain/measure_td.py"
click node_awg "https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/timedomain/awg/generate_waveform.py"
click node_qm "https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/timedomain/quantum_machine/qm_qkit_wrapper.py"
click node_storage "https://github.com/neonel21/qkit-gla/blob/master/qkit/storage/hdf_file.py"
click node_analysis "https://github.com/neonel21/qkit-gla/blob/master/qkit/analysis/__init__.py"
click node_circle_fit "https://github.com/neonel21/qkit-gla/blob/master/qkit/analysis/circle_fit/circle_fit_classic/circlefit.py"
click node_gui "https://github.com/neonel21/qkit-gla/blob/master/qkit/gui/__init__.py"
click node_qviewkit "https://github.com/neonel21/qkit-gla/blob/master/qkit/gui/qviewkit/main.py"
click node_notebooks "https://github.com/neonel21/qkit-gla/tree/master/qkit/doc/notebooks"
click node_templates "https://github.com/neonel21/qkit-gla/tree/master/templates"
click node_services "https://github.com/neonel21/qkit-gla/blob/master/qkit/services/__init__.py"
click node_raspi_misc "https://github.com/neonel21/qkit-gla/tree/master/qkit/services/raspi_misc"
click node_qsurveilkit "https://github.com/neonel21/qkit-gla/tree/master/qkit/services/qsurveilkit"
click node_config "https://github.com/neonel21/qkit-gla/blob/master/qkit/config/environment.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_startup,node_core,node_instrument_api,node_drivers,node_measure_core,node_spectroscopy,node_transport,node_timedomain,node_awg,node_qm toneBlue
class node_storage,node_analysis,node_circle_fit toneAmber
class node_gui,node_qviewkit,node_notebooks toneMint
class node_services,node_raspi_misc,node_qsurveilkit,node_config toneRose
class node_templates toneIndigo
```

## Components

### Runtime

Startup, hardware access, and measurement execution

- [Startup](https://github.com/neonel21/qkit-gla/tree/master/qkit/core/s_init): bootstrap pipeline · Staged initialization for logging, directories, services, instruments, and user startup. · `qkit/core/s_init`
- [Core](https://github.com/neonel21/qkit-gla/blob/master/qkit/core/__init__.py): runtime core · Main package entry points and runtime coordination helpers. · `qkit/core/__init__.py`
- [Instruments](https://github.com/neonel21/qkit-gla/blob/master/qkit/core/instrument_base.py): instrument API · Common instrument base classes and tooling that define the driver contract. · `qkit/core/instrument_base.py`
- [Drivers](https://github.com/neonel21/qkit-gla/blob/master/qkit/drivers/__init__.py): hardware drivers · Concrete instrument implementations for VNAs, sources, AWGs, DAQs, cryo hardware, and virtual devices. · `qkit/drivers/__init__.py`
- [Measure](https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/measurement_base.py): orchestration · Measurement base classes, JSON/sample handling, and experiment coordination. · `qkit/measure/measurement_base.py`
- [Spectroscopy](https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/spectroscopy/spectroscopy.py): measurement family · Spectroscopy-specific measurement flows and helpers. · `qkit/measure/spectroscopy/spectroscopy.py`
- [Transport](https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/transport/transport.py): measurement family · Transport and IV-style measurement routines. · `qkit/measure/transport/transport.py`
- [Time Domain](https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/timedomain/measure_td.py): measurement family · Pulse-based experiments, waveform generation, AWG loading, and Quantum Machines support. · `qkit/measure/timedomain/measure_td.py`
- [AWG Pipeline](https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/timedomain/awg/generate_waveform.py): timedomain stage · Waveform generation and AWG/tAWG loading utilities. · `qkit/measure/timedomain/awg/generate_waveform.py`
- [QM Layer](https://github.com/neonel21/qkit-gla/blob/master/qkit/measure/timedomain/quantum_machine/qm_qkit_wrapper.py): quantum machines · Quantum Machines qubit experiment wrappers, configs, and scripts. · `qkit/measure/timedomain/quantum_machine/qm_qkit_wrapper.py`

### Data

Persistence and offline analysis

- [Storage](https://github.com/neonel21/qkit-gla/blob/master/qkit/storage/hdf_file.py): HDF5 storage · HDF5 file, dataset, library, and view handling for persisted experiment data. · `qkit/storage/hdf_file.py`
- [Analysis](https://github.com/neonel21/qkit-gla/blob/master/qkit/analysis/__init__.py): offline analysis · Post-acquisition fitting, tracking, and resonator analysis tools. · `qkit/analysis/__init__.py`
- [Circle Fit](https://github.com/neonel21/qkit-gla/blob/master/qkit/analysis/circle_fit/circle_fit_classic/circlefit.py): fit subsystem · Specialized resonator circle-fit implementations and calibration helpers. · `qkit/analysis/circle_fit/circle_fit_classic/circlefit.py`

### User Interfaces

Notebook and GUI entry points

- [GUI](https://github.com/neonel21/qkit-gla/blob/master/qkit/gui/__init__.py): qt tools · Graphical plotting and data-view applications. · `qkit/gui/__init__.py`
- [QViewKit](https://github.com/neonel21/qkit-gla/blob/master/qkit/gui/qviewkit/main.py): data viewer · Main HDF5 browsing and plotting application. · `qkit/gui/qviewkit/main.py`
- [Notebooks](https://github.com/neonel21/qkit-gla/tree/master/qkit/doc/notebooks): interactive surface · Tutorial and workflow notebooks used for measurement control and analysis. · `qkit/doc/notebooks`

### Extensions

Standalone service processes and device-side helpers

- [Services](https://github.com/neonel21/qkit-gla/blob/master/qkit/services/__init__.py): device services · Standalone control and monitoring services for lab infrastructure. · `qkit/services/__init__.py`
- [Raspi Misc](https://github.com/neonel21/qkit-gla/tree/master/qkit/services/raspi_misc): utility services · Raspberry Pi-style control servers for cryo, nitrogen, attenuators, motors, and related utilities. · `qkit/services/raspi_misc`
- [SurveilKit](https://github.com/neonel21/qkit-gla/tree/master/qkit/services/qsurveilkit): monitoring service · Monitoring client/server and GUI for cryostat or facility supervision. · `qkit/services/qsurveilkit`
- [Config](https://github.com/neonel21/qkit-gla/blob/master/qkit/config/environment.py): environment config · Environment-specific configuration templates and runtime settings. · `qkit/config/environment.py`

### Docs & Templates

Tutorials, samples, and experiment templates

- [Templates](https://github.com/neonel21/qkit-gla/tree/master/templates): experiment templates · Starter notebook templates for new measurement and analysis workflows. · `templates`

## Connections

- Core → Startup: boots · Core runtime is initialized through the staged startup pipeline.
- Startup → Config: loads · Startup resolves environment and service configuration.
- Startup → Instruments: creates · Startup prepares instrument abstractions and device registry.
- Startup → Services: binds · Startup can load service endpoints and companion processes.
- Instruments → Drivers: implements · Drivers provide concrete hardware backends behind the shared interface.
- Measure → Instruments: uses · Measurement orchestration talks to instruments through the common API.
- Measure → Storage: writes · Measurements persist results and metadata into HDF5 storage.
- Measure → Spectroscopy: specializes · Spectroscopy builds on the shared measurement base.
- Measure → Transport: specializes · Transport experiments build on the shared measurement base.
- Measure → Time Domain: specializes · Time-domain experiments build on the shared measurement base.
- Time Domain → AWG Pipeline: includes · Time-domain experiments depend on waveform generation and AWG loading.
- Time Domain → QM Layer: includes · Time-domain experiments can delegate to Quantum Machines integrations.
- AWG Pipeline → Drivers: loads · AWG pipelines push sequences to instrument drivers.
- QM Layer → Drivers: controls · QM experiments coordinate hardware through driver-backed interfaces.
- Storage → Analysis: feeds · Persisted experiment data is consumed by offline analysis.
- Analysis → Circle Fit: contains · Circle-fit routines are a central analysis specialization.
- GUI → QViewKit: hosts · The GUI package includes the main data viewer application.
- GUI → Storage: browses · GUI tools read saved HDF5 experiments for inspection.
- Notebooks → Measure: drives · Notebook workflows commonly instantiate and run measurements.
- Notebooks → Analysis: explores · Notebooks are also used for post-processing and fitting.
- Templates → Notebooks: starts from · Templates seed new notebook-based workflows.
- Services → Raspi Misc: includes · The services tree includes multiple Raspberry Pi utility servers.
- Services → SurveilKit: includes · The services tree includes monitoring and supervision tooling.
- Raspi Misc → Drivers: mirrors · Service processes often expose device control used by drivers or clients.
- SurveilKit → Storage: observes · Monitoring services can track lab state and related data.
- Config → Services: configures · Configuration determines which services and devices are available.
