Skip to content

TsvikiHirsh/nres

nres

nres logo

CI Status Documentation Status PyPI version PyPI platforms

Simple yet powerful package for fitting neutron resonances.

nres (pronounced N-res) allows quick and easy quantitative fitting of total cross-section for neutron absorption resonances transmission spectrum in the epithermal and fast energy regions.

Features

Core Capabilities

  • Flexible and simple way to generate and combine cross-sections from different isotopic materials
  • Built-in database of many useful materials and elements
  • Cross-sections taken from ENDF8.0
  • Built on lmfit for intuitive and powerful fit exploration
  • Python API leveraging popular libraries like numpy and pandas
  • Methods to define response functions and background functions
  • Plotting utilities for concise result visualization
  • Fast cross-section integration and convolution with response function using C++ core code

New in v0.4.0 🎉

  • Grouped Data Support: Fit imaging detector data and multi-sample measurements with parallel processing
  • Advanced Rebinning: Combine time-of-flight bins with automatic energy calibration preservation
  • Save/Load Functionality: Serialize models and fit results to JSON for reproducible analysis
  • Enhanced Visualization: Transmission maps, multi-parameter plots, and interactive HTML reports
  • Memory Management: Efficient parallel fitting with automatic memory optimization

Installation

Quick Install (Recommended)

pip install git+https://github.com/TsvikiHirsh/nres

From PyPI (when published)

pip install nres

From source (for development)

git clone https://github.com/TsvikiHirsh/nres
cd nres
pip install -e .[dev]

⚠️ Installation Issues? See INSTALLATION.md for troubleshooting guide, especially if you encounter "ModuleNotFoundError: No module named 'pybind11'".

Requirements

  • Python 3.8 or higher
  • C++ compiler with C++17 support (GCC/Clang/MSVC)

For detailed installation instructions and troubleshooting, see INSTALLATION.md.

For development:

pip install -e ".[dev]"

Basic Usage

# Import nres
import nres

# Define material
Si = nres.CrossSection("Silicon")

# Load data
data = nres.Data.from_transmission("silicon.dat")

# Define model
model = nres.TransmissionModel(Si, vary_background=True)

# Fit using lmfit
result = model.fit(data, emin=0.4e6, emax=1.7e6)

# Plot fit results
result.plot()

fit results

Usage

For more detailed examples and advanced usage, please refer to our Jupyter notebook demo or to our documentation page.

Contributing

See CONTRIBUTING.md for instructions on how to contribute.

License

Distributed under the terms of the MIT license.

Contact

For questions, issues, or contributions, please visit the GitHub repository.

About

Simple yet powerful package for fitting neutron resonances

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors