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.
- 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
lmfitfor intuitive and powerful fit exploration - Python API leveraging popular libraries like
numpyandpandas - 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
- 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
pip install git+https://github.com/TsvikiHirsh/nrespip install nresgit 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'".
- 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]"# 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()For more detailed examples and advanced usage, please refer to our Jupyter notebook demo or to our documentation page.
See CONTRIBUTING.md for instructions on how to contribute.
Distributed under the terms of the MIT license.
For questions, issues, or contributions, please visit the GitHub repository.
