Repository navigation
Conversation
gemmi (>=0.6,<0.8) reads CIF files and gives structure factors for pyrs.pole_figures. trimesh and rtree go in the test feature only: the pole-figure integration tests use them as an independent cross-check of the STL ray tracer. pixi.lock adds only these packages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stage 1 of bringing the HB-2B path-length-corrected pole figure tool into PyRS. Physics core only (no GUI, plots or file output): - stl_mesh: closed STL mesh of the sample and a ray tracer for beam paths - geometry: the HB-2B cradle (chi, phi, omega) and the sample mount - gauge: gauge-volume Monte Carlo and the attenuated intensity factor F - prediction: predicted correction F(0,0)/F on a chi/phi grid, per plane - runs, peaks, polefig: read reduced HB2B runs, peak rates per sub-run, corrected pole figures with points above a cutoff ignored - materials: phases (presets or CIF via gemmi), allowed reflections and mu; HB-2B wavelengths from MonoSetting - table_scan, combine, parallel: scan planning, merging runs, worker pool Tests: unit in tests/unit/pyrs/pole_figures (in-memory meshes; mu checked against Sears 1992 cross sections; analytic sphere chords and attenuation), integration in tests/integration/test_pole_figures_*.py (parity with the reference script's outputs, STL fixtures with a trimesh cross-check, a 13-sub-run HB2B test file; full runs when HIDRA_PF_TEST_DATA is set). Fixtures in tests/data/pole_figures (test data anonymized), helpers in tests/util/pole_figures_helpers.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ground_truths.md: the frames and angles of pyrs.pole_figures, the exact mapping to PoleFigureCalculator (chi_PyRS = 90 - chi_HB2B, PyRS (x, y, normal) = (vy, vz, -vx), checked at five 2theta/omega settings to 2e-8), the attenuation model and the empirical parameters approved by the instrument scientist. Defects recorded, not fixed: - DD-37: the texture window's chi zero differs from the HB-2B cradle's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
jefrbunn
marked this pull request as ready for review
November 26, 2026 16:50
From the design review of this PR. Results are unchanged (the parity tests pass). - correction: Beams, check_reference and gauge_corrections, shared by prediction and polefig; GaugeCorrections groups the Monte Carlo results on PolePeak and PlanePrediction - protocols.PoleFigureLike for the later plotting stage - types: array aliases and progress callbacks in one place - geometry split into rotation, projection and geometry; materials into neutron_xs, phase, reflections and hb2b; the grid into grid; peak measurement into peaks - combine refuses runs with a different omega or mount - text and table helpers moved out of core (they return in the file output stage); the reference brute-force tracer moved to the tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
@fanchercm @walshmm this is ready for review. It is stage 1 of 4 of the path-length-corrected pole figure tool for HB-2B (physics core only). Stage 2 (plots and file output) is #1166, stacked on this one, so please review this PR first. I could not request reviewers from my fork. |
This was referenced Nov 27, 2026
|
Add Carrot credits or activate Agent usage billing to use Autofix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds
pyrs.pole_figures.core, the physics core of a tool that corrects HB-2B pole figures for the beam path through the sample. The sample shape comes from a closed STL mesh. The tool predicts the correction for each χ, φ before any data exist, and it corrects measured pole figures from reduced HB2B runs.This is stage 1 of 4. It has no GUI, plots or file output. Those follow in later PRs (see below).
What is in this PR
stl_mesh: reads binary and ASCII STL files, checks that the mesh is closed and consistently wound, and traces beam paths through it.rotation,geometry,projection: rotations, the HB-2B cradle (χ, φ, ω) with the sample mount and the pole for each orientation, and the equal-area projection.gauge,correction: a Monte Carlo gauge volume, the attenuated intensity factor F and the correction F(0,0)/F. Prediction and measured runs share one correction step.grid,prediction: the χ, φ grid with its solid-angle weights, and the predicted correction for each plane before any data exist.runs,peaks,polefig: read reduced HB2B runs, measure peak rates for each sub-run, and build corrected pole figures. Points with a correction above a cutoff are flagged and left out.neutron_xs,phase,reflections,hb2b: cross sections and μ from the composition, phases from presets or CIF files, allowed reflections, and HB-2B constants. The wavelengths come fromMonoSetting.table_scan,combine,parallel: scan planning, merging runs of the same hkl, and a process pool for the Monte Carlo work.types,protocols: shared array and callback types, and the pole-figure interface the plotting stage will use.Conventions and approved parameters
The new section "Path-length-corrected pole figures" in
docs/ground_truths.mdrecords the frames and angles. It also gives the exact mapping toPoleFigureCalculator. The two agree to 2e-8 with χ_PyRS = 90° − χ_HB-2B and PyRS (x, y, normal) = (vy, vz, −vx). This was checked at five 2θ, ω settings.PoleFigureCalculatortakes χ = 0 as φ along Q. On the HB-2B cradle the φ axis lies along Q at χ = 90°. This is recorded as DD-37 and is not changed here. Changing the texture window is a production change and needs a separate decision.The empirical parameters (cutoff, peak windows, sub-run rejection and others) are listed in that section. The HB-2B instrument scientist approved them. Each one is a named constant or an argument with a default.
Dependencies
gemmi >=0.6,<0.8in the package and every environment. It reads CIF files and gives structure factors.trimeshandrtreein the test feature only. They give an independent check of the ray tracer.pixi.lockadds only these packages.Tests
tests/unit/pyrs/pole_figures, 327 tests): in-memory meshes, μ against Sears (1992) cross sections, analytic box and sphere chords, analytic attenuation, and geometry checks.tests/integration/test_pole_figures_*.py, 188 tests): parity with the reference script's outputs, STL fixtures with the trimesh cross-check, and a 13-sub-run HB2B test file (0.26 MB) read in CI.HIDRA_PF_TEST_DATApoints to the reduced runs (about 20 MB each).tests/data/pole_figuresis anonymized.pixi run mypy pyrs scripts testsand the unit tier (1718 passed) are clean.Later stages
pyrs/interface/pole_figures, opened from a standard button in the PyRS main window.Questions for the maintainers
🤖 Generated with Claude Code