# benschneider/generic-sweepscript architecture

> Architecture diagram of the GitHub repository benschneider/generic-sweepscript, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/benschneider/generic-sweepscript
- Repository: https://github.com/benschneider/generic-sweepscript

## Overview

##### Project type and purpose
- This is a measurement‐automation and data‐acquisition tool written in Python.
- It provides instrument driver abstractions (e.g., for Yokogawa source, VNA, Keithley, etc.), sweep orchestration scripts (e.g., Gsweep, AfDigi, etc.), data‐storage routines, and post‐processing helpers (covfunc, IQcorr).

##### File structure
Top‐level files and directories fall into these categories:
- Instrument drivers: AgilentPSG.py, Yoko.py, RSZNB20.py, keithley2000.py, …
- Sweep scripts / orchestration: Gsweep*.py, AfDigi.py, D1D2meastype.py, …
- Data storage & file format: DataStorer.py, parsers.py, covfunc.py, histogram.py
- Runner / entry point: run_scripts.bat, Sim928.py (simulated driver)
- Documentation: doc/ (Sphinx source and generated HTML)
- Utilities & wrappers: PXIDigitizer_wrapper.py, dummydriver.py, ramp_mod.py

##### README for additional insights
- Sweeps both a Yokogawa source and a VNA in CW mode.
- VNA manual settings are required outside of automation.
- Outputs an *.mtx file: a header + 3D NumPy binary array.
- Data is visualized by an external tool, “spyview.”

##### Main components & interactions
a. Instrument‐Control Layer
- Each driver module connects to a hardware device via VISA/SCPI.
- Drivers expose a uniform API: set voltage/frequency, trigger sweep, read data.
b. Sweep Orchestrator
- Entry scripts (e.g., GsweepSN11.py) import drivers, coordinate multi‐instrument sweeps.
- Loop over parameters, collect raw measurements.
c. Data‐Storage Layer
- DataStorer.py implements the .mtx writer (header + binary NumPy array).
- Parsers.py & covfunc.py provide readback and analysis functions.
d. Post‐Processing / Visualization
- External “spyview” tool reads .mtx.
- Local helper modules (histogram.py, IQcorr.py) can preprocess data before plotting.
e. Documentation
- Sphinx docs under doc/ illustrate driver usage and API.

##### Architectural patterns & design principles
- Layered design: hardware‐abstraction → orchestration → storage → analysis/visualization.
- Single‐process, procedural orchestration; each sweep script is a controller.
- Reusable driver modules for each instrument.
- Separation of concerns: DataStorer solely handles file I/O; parsers handle reading.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Runner
    Runner["run_scripts.bat"]:::software
    click Runner "https://github.com/benschneider/generic-sweepscript/blob/master/run_scripts.bat"

    %% Sweep Orchestrator
    subgraph "Sweep Orchestrator"
        Gsweep["Gsweep.py"]:::software
        click Gsweep "https://github.com/benschneider/generic-sweepscript/blob/master/Gsweep.py"
        AfDigi["AfDigi.py"]:::software
        click AfDigi "https://github.com/benschneider/generic-sweepscript/blob/master/AfDigi.py"
        D1D2["D1D2meastype.py"]:::software
        click D1D2 "https://github.com/benschneider/generic-sweepscript/blob/master/D1D2meastype.py"
        OthersOrch["... other orchestrators"]:::software
    end

    %% Instrument Drivers
    subgraph "Instrument Drivers"
        AgilentPSG["AgilentPSG.py"]:::software
        click AgilentPSG "https://github.com/benschneider/generic-sweepscript/blob/master/AgilentPSG.py"
        Yoko["Yoko.py"]:::software
        click Yoko "https://github.com/benschneider/generic-sweepscript/blob/master/Yoko.py"
        RSZNB20["RSZNB20.py"]:::software
        click RSZNB20 "https://github.com/benschneider/generic-sweepscript/blob/master/RSZNB20.py"
        Keithley2000["keithley2000.py"]:::software
        click Keithley2000 "https://github.com/benschneider/generic-sweepscript/blob/master/keithley2000.py"
        AnritzuSIG["AnritzuSIG.py"]:::software
        click AnritzuSIG "https://github.com/benschneider/generic-sweepscript/blob/master/AnritzuSIG.py"
        PXIDigitizer["PXIDigitizer_wrapper.py"]:::software
        click PXIDigitizer "https://github.com/benschneider/generic-sweepscript/blob/master/PXIDigitizer_wrapper.py"
        Sim928["Sim928.py"]:::software
        click Sim928 "https://github.com/benschneider/generic-sweepscript/blob/master/Sim928.py"
        DummyDriver["dummydriver.py"]:::software
        click DummyDriver "https://github.com/benschneider/generic-sweepscript/blob/master/dummydriver.py"
        SRsim["SRsim.py"]:::software
        click SRsim "https://github.com/benschneider/generic-sweepscript/blob/master/SRsim.py"
        nirack["nirack.py"]:::software
        click nirack "https://github.com/benschneider/generic-sweepscript/blob/master/nirack.py"
        SRS_bat_read["SRS_bat_read.py"]:::software
        click SRS_bat_read "https://github.com/benschneider/generic-sweepscript/blob/master/SRS_bat_read.py"
    end

    %% Hardware Instruments
    subgraph "Hardware Instruments"
        HW_Yoko["Yokogawa Source"]:::hardware
        HW_VNA["VNA"]:::hardware
        HW_Digitizer["PXI Digitizer"]:::hardware
        HW_Multimeter["Keithley 2000"]:::hardware
    end

    %% Data Storage Layer
    subgraph "Data Storage"
        DataStorer["DataStorer.py"]:::software
        click DataStorer "https://github.com/benschneider/generic-sweepscript/blob/master/DataStorer.py"
        Parsers["parsers.py"]:::software
        click Parsers "https://github.com/benschneider/generic-sweepscript/blob/master/parsers.py"
        Covfunc["covfunc.py"]:::software
        click Covfunc "https://github.com/benschneider/generic-sweepscript/blob/master/covfunc.py"
        MTXFile[".mtx File"]:::artifact
    end

    %% Post-Processing / Analysis
    subgraph "Post-Processing"
        Histogram["histogram.py"]:::software
        click Histogram "https://github.com/benschneider/generic-sweepscript/blob/master/histogram.py"
        IQcorr["IQcorr.py"]:::software
        click IQcorr "https://github.com/benschneider/generic-sweepscript/blob/master/IQcorr.py"
        IQcorr2["IQcorr2.py"]:::software
        click IQcorr2 "https://github.com/benschneider/generic-sweepscript/blob/master/IQcorr2.py"
        RampMod["ramp_mod.py"]:::software
        click RampMod "https://github.com/benschneider/generic-sweepscript/blob/master/ramp_mod.py"
    end

    %% External Visualization
    Spyview["spyview"]:::external

    %% Connections
    Runner --> Gsweep
    Runner --> AfDigi
    Runner --> D1D2
    Runner --> OthersOrch

    Gsweep -->|uses| AgilentPSG
    Gsweep -->|uses| Yoko
    Gsweep -->|uses| RSZNB20
    AfDigi -->|uses| Keithley2000
    AfDigi -->|uses| PXIDigitizer
    D1D2 -->|uses| AgilentPSG
    OthersOrch -->|uses| Sim928
    OthersOrch -->|uses| DummyDriver

    AgilentPSG -->|SCPI command| HW_Yoko
    Yoko -->|SCPI command| HW_Yoko
    RSZNB20 -->|SCPI command| HW_VNA
    Keithley2000 -->|SCPI command| HW_Multimeter
    PXIDigitizer -->|SCPI command| HW_Digitizer

    Gsweep -->|measurement data| DataStorer
    AfDigi -->|measurement data| DataStorer
    D1D2 -->|measurement data| DataStorer
    OthersOrch -->|measurement data| DataStorer

    DataStorer -->|writes .mtx| MTXFile
    Parsers -->|reads .mtx| MTXFile
    Covfunc -->|reads .mtx| MTXFile

    MTXFile -->|input| Histogram
    MTXFile -->|input| IQcorr
    MTXFile -->|input| IQcorr2
    MTXFile -->|input| RampMod

    MTXFile -->|raw data| Spyview
    Histogram -->|processed data| Spyview
    IQcorr -->|processed data| Spyview

    %% Styling
    classDef software fill:#b2f2bb,stroke:#2f6627,color:#000
    classDef hardware fill:#bae7ff,stroke:#1f4a74,color:#000
    classDef external fill:#d9d9d9,stroke:#595959,color:#000
    classDef artifact fill:#fff4e6,stroke:#7a4100,color:#000
```
