User Guide

This comprehensive guide covers all aspects of using nbragg for neutron Bragg edge transmission analysis.

Contents:

Overview

Core Concepts

Cross Sections

nbragg uses NCrystal to calculate neutron cross sections for crystalline materials. Learn how to define materials, handle multi-phase samples, and work with oriented crystals.

Transmission Models

The TransmissionModel class provides flexible fitting capabilities with multi-stage refinement strategies including true Rietveld refinement.

Parameter Control

Fine-grained control over which parameters vary during fitting, including basic parameters (thickness, norm), weights, orientations, and more.

Key Features

  • Grouped/Gridded Data: Analyze spatially-resolved or multi-sample datasets with parallel fitting

  • Multi-phase Analysis: Model powder and textured samples with multiple phases

  • Oriented Materials: Full support for single crystal and textured polycrystals

  • MTEX Integration: Import orientation distributions from MTEX for texture analysis

  • Flexible Fitting: Rietveld and staged refinement strategies

  • Parameter Management: Control all aspects of your fit with vary_* parameters

What’s New

Recent additions to nbragg include:

Grouped/Gridded Data Fitting
  • Data.from_grouped() for loading spatially-resolved or multi-sample data

  • Parallel fitting with n_jobs parameter

  • plot_parameter_map() with auto-detection of plot type (heatmap/line/bar)

  • Flexible indexing: tuples (0,0), strings "(0,0)", integers, or names

  • GroupedFitResult with save(), load(), and fit_report() methods

  • See Grouped Data Fitting for complete documentation

Save and Load Functionality
  • result.save() method for easy saving of fit results

  • TransmissionModel.load() automatically detects model or result files

  • Initialize models directly from saved files: TransmissionModel("fit.json")

  • Loaded results have all methods (plot, save, etc.)

  • JSON-based format avoids ctypes pickle issues

  • See Saving and Loading Fits for complete documentation

Model Parameter Control
  • New vary_basic parameter to control thickness and norm fitting

  • Automatic initialization of orientation parameters from material properties

  • Temperature parameter now fixed by default

MTEX Integration Improvements
  • from_mtex() now accepts material as string or dictionary

  • Automatic short_name generation from material filenames

  • Better handling of powder phases in oriented materials

Enhanced Documentation
  • Comprehensive save/load guide

  • Crystal orientation guide

  • Quick reference cards for common operations

  • Executable examples for all major features

Getting Help