Skip to main content

A lightweight Python package for NMR research.

Project description

nmrkit

PyPI version Python 3.12+ License Poetry

nmrkit is a Python library for nuclear magnetic resonance (NMR) data processing and analysis.

This is an early-stage project under active development. Contributions are welcome to help expand its capabilities!

Features

  • Data Import/Export: Support for common NMR formats including TopSpin and Delta
  • Basic Processing: Fourier transform, apodization (exponential multiplication), zero filling, phase correction
  • Acquisition Planning: Calculate DOSY diffusion experiment timing and gradient settings
  • Visualization: Interactive plotting with customizable parameters
  • Simple API: Intuitive functions for data processing workflows

Requirements

  • Python >= 3.12
  • NumPy
  • SciPy
  • Matplotlib (optional, for visualization)

Installation

From PyPI (Recommended)

pip install nmrkit

With visualization support:

pip install nmrkit[visualization]

Quick Start

Automatic Processing

Use the auto_process function for automated application of common processing steps:

import nmrkit as nk

# Load NMR data
data = nk.read('path/to/data')

# Automatically process the spectrum
data = nk.auto_process(data)

# Save the plot to a PDF file
nk.plot(data, output_path="spectrum.pdf")

Manual Processing

For more control, use individual processing functions:

import nmrkit as nk

# Load data with explicit format specification
data = nk.read('path/to/data.jdf', format='delta')

# Apply exponential multiplication (apodization) with 1.0 Hz line broadening
data = nk.em(data, lb=1.0)

# Zero fill to 2048 points for improved resolution
data = nk.zf(data, size=2048)

# Perform Fourier transform
data = nk.ft(data)

# Apply phase correction
data = nk.phase(data, ph0=10.0, ph1=25.0)

# Plot the manually processed spectrum
nk.plot(data)

DOSY Acquisition Planning

Use acquisition helpers to estimate DOSY experiment settings from a diffusion coefficient and the maximum gradient strength of an instrument:

dosy_params = nk.calculate_dosy_settings(
    diffusion_coefficient_m2_s=5.8e-10,
    max_gradient_t_m=0.535,
    target_attenuation=0.05,
)

print(f"Diffusion time (big delta):   {dosy_params.diffusion_time_ms:.2f} ms")
print(f"Gradient duration (little delta): {dosy_params.gradient_duration_ms:.4f} ms")
print(f"Achieved residual signal:     {dosy_params.achieved_attenuation:.4f}")

License

nmrkit is released under the Apache License 2.0. See the LICENSE file for more information.

Contributing

The nmrkit project welcomes your expertise and enthusiasm!

Reporting Issues

If you encounter a bug or have an idea for a new feature, please open an issue on GitHub. When reporting bugs, please include:

  • A clear description of the issue
  • Steps to reproduce (if applicable)
  • Expected vs actual behavior
  • Your Python version and operating system

Contributing Code

To contribute code to nmrkit:

  1. Fork and Clone: Fork the repository and clone it locally
  2. Set up Development Environment:
    poetry install
    
  3. Create a Branch: Create a new branch for your feature or bug fix
    git checkout -b feature/your-feature-name
    
  4. Make Changes: Implement your changes following the existing code style
  5. Run Tests: Ensure all tests pass
    poetry run pytest
    
  6. Commit: Commit your changes with clear, descriptive messages
  7. Push and Submit PR: Push to your fork and submit a pull request

Development Guidelines

  • Follow PEP 8 style guidelines
  • Add type hints for new functions
  • Include docstrings following the existing format
  • Add tests for new functionality
  • Ensure all tests pass before submitting PR

Small improvements or fixes are always appreciated. Even minor contributions can make a significant difference!

Contact

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

nmrkit-1.0.1.tar.gz (41.4 kB view details)

Uploaded Source

Built Distribution

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

nmrkit-1.0.1-py3-none-any.whl (50.9 kB view details)

Uploaded Python 3

File details

Details for the file nmrkit-1.0.1.tar.gz.

File metadata

  • Download URL: nmrkit-1.0.1.tar.gz
  • Upload date:
  • Size: 41.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nmrkit-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6ad550b42a73821d3e73e273c53fa2487c06e0c087ca8f959209d4b3a7ec5d18
MD5 87b3b82dacece230e31506cb7a6a6625
BLAKE2b-256 300220475f76f4d785cfab1b66fc013a35ac0d0898ed07e8160c91f41f3c8938

See more details on using hashes here.

Provenance

The following attestation bundles were made for nmrkit-1.0.1.tar.gz:

Publisher: publish-pypi.yml on nmrtist/nmrkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nmrkit-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: nmrkit-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 50.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nmrkit-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eb50f222cbddc305b39d046f1eac2852f07f9156524ddd3c20f94530b7b1bec4
MD5 376427293474a83c3209aae896596611
BLAKE2b-256 5d5a76292bc4452cd7cec667e12bb38c64ea6637605b3b329b732e0775e018d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for nmrkit-1.0.1-py3-none-any.whl:

Publisher: publish-pypi.yml on nmrtist/nmrkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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