Wrapper for the Table Stable Ltd. Ghost Software
Project description
Ghosty - GHOST Brillouin Spectrometer Control
Python interface for controlling the GHOST Brillouin spectrometer software via TCP/IP communication.
Features
- Asynchronous control interface for the GHOST spectrometer
- Automatic timing calculations based on clock frequency
- Robust acquisition with timeout handling and retry logic
- Acquisition timing logging
- Working directory management
- Comprehensive error handling and recovery
- Support for both standard (4 kHz) and high-speed (10 kHz) modes
Installation
From Git Repository
- Clone the repository:
git clone https://github.com/timm-landes/ghosty.git
cd ghosty
- Create and activate a virtual environment (recommended):
python -m venv venv
# On Windows:
.\venv\Scripts\activate
# On Linux/Mac:
source venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Install in development mode:
pip install -e .
Quick Start
import asyncio
from ghosty import BrillouinSpectrometer
async def main():
# Create spectrometer instance (4 kHz standard mode)
spec = BrillouinSpectrometer(clock_frequency_khz=4)
try:
# Initialize connection
await spec.initialize()
# Set working directory
await spec.set_working_directory("C:/Data")
# Acquire data
await spec.acquire_and_save(cycles=10, fname="spectrum.DAT")
finally:
# Clean up
await spec.close()
asyncio.run(main())
Operating Modes
Standard Mode (4 kHz)
- Uses full 2048 MCA channels
- Scan time: ~512 ms
- Total cycle time: ~615 ms (scan + retract)
High-Speed Mode (10 kHz)
- Uses 512 MCA channels
- Scan time: ~205 ms
- Total cycle time: ~250 ms (scan + retract)
- Requires hardware modifications
Communication Protocol
The GHOST software uses a TCP/IP protocol with the following specifications:
- Port: 4000 (default)
- Encoding: UTF-8
- Command termination: \r\n (CR+LF)
- Maximum command length: 80 characters
- Default timeout: 5 seconds
Key Components
BrillouinSpectrometer
High-level interface providing:
- Connection management
- Acquisition control
- Timing calculations
- Error handling
- Status monitoring
TcpIpController
Low-level communication handling:
- TCP/IP connection management
- Command sending/receiving
- Protocol implementation
- Basic error checking
Command Reference
Available commands through the TcpIpController:
| Command | Description | Response Expected |
|---|---|---|
| OBSERVE | Start observation | No |
| STATUS | Get system status | Yes |
| START n | Start n acquisition cycles | No |
| STOP | Stop acquisition | No |
| SAVE name | Save data to file | No |
| DELETE | Clear data buffer | No |
| WDIR path | Set working directory | No |
Timing Details
Timing calculations are based on the spectrometer's clock frequency:
cycle_time_ms = (2460 / clock_frequency) * 1000
Safety margins:
- Minimum wait: 60% of theoretical time
- Timeout: theoretical time + 10 cycles
- Status confirmation: 2 consecutive IDLE states
Error Handling
The library implements multiple layers of error handling:
- Connection-level errors
- Command validation
- Response verification
- Timeout protection
- Status monitoring
- Resource cleanup
Logging
Uses loguru for comprehensive logging:
- Debug level: Command details
- Info level: Operation status
- Warning level: Timing issues
- Error level: Operation failures
- Trace level: Detailed status
Requirements
- Python ≤ 3.12.9 (for telnetlib) or telnetlib3 when using Python ≥ 3.13
- asyncio
- loguru
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
License
MIT License - See LICENSE file for details
Acknowledgments
Based on the GHOST spectrometer software communication protocol.
Development Setup
For development work:
- Clone the repository as described above
- Install development dependencies:
pip install -r requirements.txt
- Setup pre-commit hooks:
pre-commit install
Repository
The project is hosted on GitLab at the University of Hannover: https://gitlab.uni-hannover.de/phytophotonics/ghosty (internal use) and publically available hosted at GitHub: https://github.com/timm-landes/ghosty
Authors
Project Lead:
- Timm Landes
- Leibniz University Hannover
- Email: timm.landes@hot.uni-hannover.de
- ORCID: https://orcid.org/0000-0001-8953-3003
Contributors:
- Dag Heinemann
- Leibniz University Hannover
- Email: da.heinemann@hot.uni-hannover.de
- ORCID: https://orcid.org/0000-0003-3506-1762
Citing Ghosty
If you use Ghosty in your research, please cite it as follows:
BibTeX
@software{ghosty2024,
author = {Landes, Timm and Heinemann, Dag},
title = {Ghosty: A Python Interface for GHOST Brillouin Spectrometer Control},
year = {2025},
version = {0.1.1},
url = {https://gitlab.uni-hannover.de/phytophotonics/ghosty},
institution = {Leibniz University Hannover}
}
APA Style
Landes, T., & Heinemann, D. (2025). Ghosty: A Python Interface for GHOST Brillouin
Spectrometer Control (Version 0.1.1) [Computer software].
Leibniz University Hannover. https://gitlab.uni-hannover.de/phytophotonics/ghosty
Related Publications
If applicable, please also cite the following related publications:
Landes, T., Khanal, B.P., Bethge, H.L. et al. Micromechanical behavior of the apple fruit cuticle investigated by Brillouin light scattering microscopy. Commun Biol 8, 174 (2025). https://doi.org/10.1038/s42003-025-07555-5
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ghosty-0.1.2.tar.gz.
File metadata
- Download URL: ghosty-0.1.2.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05414de77a5bc00b597478ab2a392ac57506d3e567a133d6c3e9624df9503c47
|
|
| MD5 |
7c5a3a98bf8d4850edda138617e4e57b
|
|
| BLAKE2b-256 |
02548777137b65ce8163d175f8642b6c09a136d0e1fc89008bb04c75e30faf6a
|
File details
Details for the file ghosty-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ghosty-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7349a6b371e67f132043cc4b9c031bda868ce83abd381e5c661a4e8a3d3479c1
|
|
| MD5 |
26704032e5fd9d8499e5994bff6f5b9a
|
|
| BLAKE2b-256 |
da6009b398b7fa79167035d520fec38317864e180918806157c07e53f643e65c
|