Skip to main content

The most comprehensive Python SDK for processing WITS (Wellsite Information Transfer Standard) data in the oil & gas drilling industry.

Project description

๐Ÿ› ๏ธ WitsKit

WitsKit is a Python toolkit for decoding and working with WITS (Wellsite Information Transfer Standard) data.

*Please note: Iโ€™m still learning, so if you spot something incorrect or suboptimal, feel free to submit a PR. The codebase isnโ€™t perfect yet, but Iโ€™m working on it!

๐Ÿšฉ What It Does

  • Parses raw WITS frames into structured, validated Python objects
  • Ships with 724 symbols across 20+ record typesโ€”auto-parsed from the spec
  • Includes CLI tools for symbol search, frame decoding, and validation
  • ๐Ÿ—„๏ธ SQL Storage: Stream WITS data directly to SQLite, PostgreSQL, or MySQL databases
  • ๐Ÿ“Š Time-series Analysis: Query and analyze historical drilling data with time-based filtering
  • Built to be extended: transports (serial, TCP) and outputs (SQL, JSON) are plug-and-play

๐Ÿ’ก Why Use It?

  • ๐Ÿง  You get the full WITS symbol database, not someone's half-finished Excel copy
  • ๐Ÿ” CLI lets you find, filter, and explore symbols without opening the spec (again)
  • ๐Ÿ“ Works in both metric and FPSโ€”because a boat sank and now we have 2 standards
  • ๐Ÿ—„๏ธ Production-ready SQL storage for time-series drilling data analysis
  • ๐Ÿ“Š Query historical data with time filters, symbol selection, and export to CSV/JSON
  • ๐Ÿงฑ Modular and testable, built with real-world telemetry in mind
  • ๐Ÿ”’ Type-checked with pydantic, so your data actually means what you think it does

๐Ÿง‘โ€๐Ÿ’ป Getting Started

Installation

For Development:

git clone https://github.com/Critlist/witskit
cd witskit
pip install -e .

For Production (when published):

pip install witskit

With SQL storage support:

pip install witskit[sql]  # Includes PostgreSQL and MySQL drivers

With uv (recommended):

git clone https://github.com/yourusername/witskit
cd witskit
uv pip install -e .

Quick Start - Decode a WITS Frame

from witskit import decode_frame

frame = """&&
01083650.40
01133.5
01142850.7
!!"""

result = decode_frame(frame)
for dp in result.data_points:
    print(f"{dp.symbol_name}: {dp.parsed_value} {dp.unit}")

Output:

DBTM: 3650.4 M
ROPA: 3.5 M/HR
HKLA: 2850.7 KDN

๐Ÿ•น๏ธ CLI Commands

After installation, the witskit command is available globally:

Try the demo:

witskit demo

Explore symbol database:

witskit symbols --list-records
witskit symbols --search "depth"
witskit symbols --record 8 --search "resistivity"

Decode WITS from a file:

witskit decode sample.wits
witskit decode sample.wits --fps
witskit decode sample.wits --output results.json

Decode WITS directly:

witskit decode "&&\n01083650.40\n!!" --format table

Validate WITS data:

witskit validate "&&\n01083650.40\n!!"

Convert units:

witskit convert 3650.4 M F  # Convert 3650.4 meters to feet
witskit convert 1000 PSI KPA  # Convert 1000 PSI to kilopascals

WITS File Format

Example WITS file format (sample.wits):

&&
01083650.40
01133.5
01142850.7
!!
&&
01083651.20
01133.7
01142855.3
!!

Each frame must include:

  • Start line (&&)
  • One or more data lines (4-digit symbol code + value)
  • End line (!!)

Multiple frames can be included in a single file.

๐Ÿ—„๏ธ SQL Storage & Time-Series Analysis

WitsKit includes production-ready SQL storage for time-series drilling data analysis:

Supported Databases

  • SQLite: Perfect for development and single-user analysis
  • PostgreSQL: Production-ready with advanced time-series capabilities
  • MySQL: Enterprise database support

Key Features

  • Optimized Schema: Time-series optimized tables with proper indexing
  • Batch Processing: Configurable batch sizes for high-performance streaming
  • Time-Based Queries: Filter data by time ranges with ISO timestamp support
  • Symbol Management: Automatic population of WITS symbol definitions
  • Export Options: JSON, CSV, and table formats for data analysis
  • Multi-source Support: Handle data from multiple drilling rigs simultaneously

Quick Example

from witskit.storage.sql_writer import SQLWriter, DatabaseConfig

# Configure database
config = DatabaseConfig.sqlite("drilling_data.db")
writer = SQLWriter(config)

# Stream and store data
await writer.initialize()
async for frame in stream_source:
    await writer.store_frame(frame)

# Query historical data
async for data_point in writer.query_data_points(
    symbol_codes=["0108", "0113"], 
    start_time=datetime(2024, 1, 1),
    limit=1000
):
    print(f"{data_point.symbol_name}: {data_point.parsed_value}")

See docs/sql_storage.md for complete documentation.

๐Ÿงฑ Project Layout

witskit/
โ”œโ”€โ”€ witskit/             # Main package
โ”‚   โ”œโ”€โ”€ models/          # Symbol metadata, Pydantic schemas
โ”‚   โ”œโ”€โ”€ decoder/         # WITS frame parsing
โ”‚   โ”œโ”€โ”€ transport/       # Serial, TCP, file readers
โ”‚   โ”œโ”€โ”€ storage/         # SQL storage backends
โ”‚   โ”‚   โ”œโ”€โ”€ base.py      # Abstract storage interface
โ”‚   โ”‚   โ”œโ”€โ”€ schema.py    # Database schema definitions
โ”‚   โ”‚   โ””โ”€โ”€ sql_writer.py # SQL storage implementation
โ”‚   โ””โ”€โ”€ cli.py          # Command-line interface
โ”œโ”€โ”€ tests/              # Unit tests
โ”œโ”€โ”€ docs/               # Documentation
โ”‚   โ”œโ”€โ”€ sql_storage.md  # Complete SQL storage guide
โ”‚   โ”œโ”€โ”€ guide/          # User guides
โ”‚   โ”‚   โ”œโ”€โ”€ getting-started.md
โ”‚   โ”‚   โ”œโ”€โ”€ cli-usage.md
โ”‚   โ”‚   โ””โ”€โ”€ wits-format.md
โ”‚   โ””โ”€โ”€ api/            # API documentation
โ”œโ”€โ”€ examples/           # Example scripts and demos
โ”œโ”€โ”€ pyproject.toml      # Package configuration
โ””โ”€โ”€ README.md           # This file

๐Ÿ“Š Supported Record Types

Record Category Description Symbols
1 Drilling Time-Based 40
2 Drilling Depth-Based 26
8 MWD/LWD Formation Evaluation 46
15 Evaluation Cuttings/Lithology 54
19 Configuration Equipment setup 89
... ... 20+ types total 724

Records 5, 22โ€“25 are defined but not implemented. You're not missing much.

๐Ÿงช Testing

# Run the full test suite
pytest tests/ -v

# Run specific test categories
pytest tests/test_decoder.py -v
pytest tests/test_symbols.py -v

๐Ÿ“ˆ Roadmap

  • โœ… Symbol parser & decoder engine
  • ๐Ÿšง Transport support (serial, TCP, file) (WIP)
  • โœ… SQL Storage (SQLite, PostgreSQL, MySQL)
  • โœ… Time-series analysis with time-based filtering and export
  • ๐Ÿ”œ Real-time decoding pipeline with WebSocket/MQTT
  • ๐Ÿ”œ Web UI for monitoring decoded streams
  • ๐Ÿ”œ Parquet export for big data analysis

๐Ÿค Contributing

This project uses:

  • Python 3.11+
  • pydantic for type validation
  • typer for CLI
  • rich for terminal formatting
  • pytest for testing
  • SQLAlchemy for SQL storage
  • asyncpg/aiomysql for async database drivers

PRs welcome. Bonus points if you've ever debugged WITS Comms while on standby waiting for the Rig to pick up tools.

๐Ÿ“š References

๐Ÿ“„ License

MIT. Do what you want with itโ€”just don't sell it back to Halliburton.


Made by someone who got bored and wanted a tool to create a diferent approach to WITS data transfer. If you work with WITS data, WitsKit's here to make your life less painful.

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

witskit-0.1.0.tar.gz (69.3 kB view details)

Uploaded Source

Built Distribution

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

witskit-0.1.0-py3-none-any.whl (63.6 kB view details)

Uploaded Python 3

File details

Details for the file witskit-0.1.0.tar.gz.

File metadata

  • Download URL: witskit-0.1.0.tar.gz
  • Upload date:
  • Size: 69.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for witskit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d2318474a7ef1d9908d7e8282495c603aec0e47b7fd0daafedc1188ae76e85c
MD5 85aec57d033d525a01f2839fc30d2bab
BLAKE2b-256 c9a2371ae3d9b87c4165a48da49f60a3f95e93b0ebab2da286e51c09b2402bac

See more details on using hashes here.

File details

Details for the file witskit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: witskit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 63.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.4

File hashes

Hashes for witskit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d704fb8aa35a60e246553439bf09a26bbc181be627383e19edb975a4bf7afa4
MD5 a8a444a0d17992061766886655d32c79
BLAKE2b-256 e0839d0fb5487b5d568350f963a506c379f19c6da30722a0fd7de2bfe0eea5aa

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