Skip to main content

CLI tool to query and analyze simulation CSV data with natural language

Project description

simpyQ

Banner python3.x Documentation Status GPLv3 license Open Source? Yes!

CLI tool for querying simulation CSV data using natural language.

Analyze and visualize simulation data from CSV files using natural language queries interpreted via spaCy and a rule-enhanced NLP pipeline.


Features

  • Terminal-based CLI tool with live interactive mode
  • Natural language processing of signal queries (e.g., mean of Vout)
  • Signal name indexing and pretty terminal display using Rich
  • Plotting of signal vs time with auto-saving to file
  • Logging of results and errors to timestamped log files
  • Lightweight, extensible, and easy to adapt to other domains

Installation

Note : you need to have Spacy installed on your machine before installing.

🧠 spaCy Setup (Required Before Using simpyq)

Before installing and using the simpyq CLI tool, you need to install spaCy along with its transformer-based English language model.

1. Install spaCy (choose CPU or CUDA based on your system):

For CPU-only systems:

pip install -U pip setuptools wheel
pip install -U 'spacy[cuda11x]'
python -m spacy download en_core_web_trf



```bash
# Create environment (recommended)
conda create -n simpyq_env python=3.10
conda activate simpyq_env

# Install dependencies
pip install -r requirements.txt

# Or install manually
pip install pandas numpy matplotlib rich pyfiglet spacy
python -m spacy download en_core_web_trf

or if you have Spacy already installed then : pip install simpyq

Usage

# Run in one-shot mode (process query then exit)
python simpyq/cli.py path/to/data.csv "mean of Vout"

# Show available signals
python simpyq/cli.py path/to/data.csv --show

# Plot signal(s)
python simpyq/cli.py path/to/data.csv --plot Vout Iload --start 0.1 --end 0.9

Interactive Mode

# Start interactive REPL
python simpyq/cli.py path/to/data.csv

Then just type queries like:

mean of Vout
rms of Iin
(mean of Vout) + (rms of Iload) / 2
exit()

Example Queries

Query Description
mean of Vout Computes the average value of Vout
rms of Iload Root-mean-square of Iload
max of Temp - min of Temp Temperature swing
integral of Pin Energy under the Pin curve
rms of Vout + mean of Iin * 2 Composite math query
plot of Vout and Iin (Use --plot flag instead)

Supported Operations

OPERATIONS = {
    "mean": np.mean,
    "average": np.mean,
    "rms": lambda x: np.sqrt(np.mean(np.square(x))),
    "std": np.std,
    "variance": np.var,
    "max": np.max,
    "min": np.min,
    "abs max": lambda x: np.max(np.abs(x)),
    "abs min": lambda x: np.min(np.abs(x)),
    "sum": np.sum,
    "peak-to-peak": lambda x: np.ptp(x),
    "median": np.median,
    "integral": lambda x: np.trapz(x),
    "squared mean": lambda x: np.mean(np.square(x)),
    "derivative": lambda x: np.gradient(x),
    "diff": np.diff,
}

How It Works

  • Loads CSV data and extracts signal names
  • Injects them as named entities into the spaCy NLP pipeline
  • Parses user query and extracts operations and signals
  • Computes the operations and evaluates full expressions
  • Plots and saves results as needed

NLP Training / Fine-tuning

You can customize the NLP model to better understand domain-specific expressions.

To train or adapt:

  1. Edit get_nlp() to support additional patterns
  2. Add EntityRuler rules:
patterns = [{"label": "ELECTRONIC_SIGNAL", "pattern": name} for name in signal_names]
ruler.add_patterns(patterns)
  1. (Optional) Fine-tune spaCy model with labeled data:
python -m spacy train config.cfg --output ./model --paths.train ./train.spacy --paths.dev ./dev.spacy

License

GPL v3 License


Acknowledgments

Thanks to the open-source community and tools like:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simpyq-1.0.2.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simpyq-1.0.2-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file simpyq-1.0.2.tar.gz.

File metadata

  • Download URL: simpyq-1.0.2.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for simpyq-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b540e8dbab233a6c007795cea83e64f83fdcd70dd2bab3b313217f18476ba758
MD5 cb593fc2c6a7c2d6c284cea7da2a3f23
BLAKE2b-256 6984fa654f91e7813d8f1c0f7716315cf09559595fc793af11ac39a24eee28b0

See more details on using hashes here.

File details

Details for the file simpyq-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: simpyq-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for simpyq-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0413a8e82c6fd08d3ea270242a18a7180adbd6fd7eed15f88468b60ef323379f
MD5 2708ff2b552c7e0856023e8c9dd0d317
BLAKE2b-256 4c347dc87afa5c1aa6efbfcf6205e3dc80b1ccf9117c78e1c3648eb33ee5ecd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page