Skip to content

scattering/tasreduction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tasreduction

Self-contained triple-axis spectrometer reduction toolkit.

Installation

# optional: create conda env (requires writeable pkgs/envs dirs)
CONDA_ENVS_PATH=$PWD/conda-envs \
CONDA_PKGS_DIRS=$PWD/conda-pkgs \
    conda create -y -n tasreduction python=3.10 numpy

Add tasreduction to PYTHONPATH or install in editable mode:

python -m pip install -e ./tasreduction

# lattice + geometry helpers
python -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org icp-lattice-calculator
# optional resolution calculator (requires the legacy rescalculator source on PYTHONPATH)
# python -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org rescalculator
# peak fitting / optimization helpers
python -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org bumps

If the legacy rescalculator package is available on your PYTHONPATH, tasreduction will use it for resolution-volume calculations. Polarization corrections are not yet implemented in this port.

Capabilities

  • Rich metadata ported from the classic ICE/NICE headers with "distinct" rules enforced during reductions via TripleAxisMetadata.
  • Instrument models capture monochromator/analyzer blades, collimators, filters, sample environment channels, PSD/single/diffraction/door detectors, and monitor streams to keep the workflow in sync with bt7_stuff.txt and data_abstraction.py.
  • Translators for classic ASCII .bt7 files and modern .nxs.bt7 NeXus files build TripleAxisScan objects with spectator channels (temperature, timestamps, live times, etc.) that are kept in register during combinations.
  • Combination helpers replicate the IDL simple_combine monitor normalization and quadrature error propagation so scan sums honour the uncertainty mathematics without relying on the uncertainties package.
  • tasreduction.lattice exposes thin wrappers around icp-lattice-calculator for hkℓ/angle queries, and tasreduction.resolution wires those results into the python resolution calculator for Cooper–Nathans style estimates.
  • tasreduction.polarization solves the four-channel analyzer equations so finite-efficiency incident/analyzer corrections can be applied to TripleAxisScan objects.
  • tasreduction.peaks uses Paul Kienzle’s bumps optimizer with BIC model selection to smooth, detect, and fit multiple peaks (wavelet-based detectors can be added later if you want more aggressive peak discovery).

Usage

from tasreduction import translate_ice_file, translate_nexus_file, ReducePipeline

scan = translate_ice_file("/path/to/file.bt7")
# or load newer NICE/ICE NeXus output (*.nxs.bt7)
nexus_scan = translate_nexus_file("/path/to/scan.nxs.bt7")
scan.normalize_to_monitor()

	pipeline = ReducePipeline()
	pipeline.add_signal(scan)
	combined = pipeline.sum_signals()
	combined.record_treatment("custom step")

	# polarization correction (requires all four spin states)
	from tasreduction import PolarizationConfig, polarization_correct
	corrected = polarization_correct(spin_channels, PolarizationConfig(incident_polarization=0.9, analyzer_polarization=0.85))

	# automatic multi-peak fitting
	from tasreduction.peaks import auto_peak_fit
	peak_fit = auto_peak_fit(combined.axis, combined.counts)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages