Repository navigation
Conversation
Key bug fixes to padf.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Take dev's calibration, ellipticity, polar (PDF) and widget removal; keep 2D/3D input support in polar_transform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ange and l_max Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ine plots Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- padf_from_clusters / padf2d_from_clusters: model PADFs from all interatomic vectors (2-, 3-, 4-body terms), band-limited like the data - lattices.random_clusters / cluster_patterns: kinematic patterns of random clusters with the Weickenmeier-Kohl scattering factor - PairAngleDistributionFunction: l_max and r-grid kwargs; simple_plot in physical units with an optional volume to plot - PairAngleDistributionFunction2D.plot_diagonal: optional volume to plot - torch in place of scipy except spherical_jn / jv Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…methods for batched correlation Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- subtract_angular_median, used by PairAngleDistributionFunction - l_taper / n_taper (cos^2 over the harmonic orders) in the data reconstructions and in padf_from_clusters / padf2d_from_clusters, to suppress ringing from truncating at l_max / n_max - simple_plot: several volumes side by side, fixed-r slices, r marks, color limits from the displayed r range; plot_angular_correlation - plot_diagonal: several volumes side by side - random_clusters / cluster_patterns: random_orientation=False keeps the cell axes (zone-axis patterns) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Render atoms as sampled Gaussians and divide the Gaussian out; patterns match a direct structure-factor sum to 6e-5. blur_px applies a real-space Gaussian blur for partial coherence (a Fourier-space blur truncated at Nyquist rang along the axes next to the central beam). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rounds - bg_model='power': c + sum_i a_i (1 + k^2/s_i^2)^(-p_i), 1 or 2 terms, all parameters positive so f(k) = B - c is positive and monotonic - bg_model='known': N <f>^2 + c from tabulated scattering factors (the standard ePDF normalization), N, c >= 0 by weighted least squares - bg_weight='k' or 'k/I' (error in F(k)) besides the py4DSTEM weighting - windowed_model_pdf: model g(r) through the same k window, for comparison Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- default background: one power law with k / I(k) weighting - background weights per curve, so batched and single fits agree - low-r density correction acts over the window, not the bg fit range - remove windowed_model_pdf - tests: each background model recovers a background of its own form Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes: - random_clusters works for any cell shape (fractional minimum image, radius capped at half the smallest face spacing); hcp clusters were missing atoms - cluster_patterns raises when the cluster does not fit the render grid and returns a calibrated Dataset4dstem - padf_from_clusters / padf2d_from_clusters accept r grids not starting at 0 - PairAngleDistributionFunction: accepts a list of polar datasets (averaged angular correlation), fq as a function of q, exposes q, skips the origin search when polar data is given, constructor r grid includes r_max, Na = 1 - k/I background weights floor I(k) at 1e-3 of its median Cleanup: - one batched Levenberg-Marquardt helper for the power and Gaussian backgrounds; 'default' weighting renamed 'py4dstem'; stale docs fixed - torch Legendre polynomials and Hankel transforms in place of scipy/numpy - plot_diagonal: full r range by default, (r r')^p weighting as in simple_plot, median subtracted over angle for display - gr_truth_2d folded into gr_truth (identical for 3D cells) - dead code and stale comments removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Testing notebooks for PADF |
…ee steps - simple_plot / plot_diagonal: per-panel r_fixed, theta_marks and r_marks, so several structures fit in one row; angle axes end at 180 (or 360) deg with 30 (or 60) degree ticks - plot_angular_correlation and plot_g2_g3 use the same angle ticks - show_1d: xlim and xticks options Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Updated notebooks: |
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.
Pair-angle distribution function (PADF)
PADF from orientation-averaged diffraction, following pypadf (Martin et al.). Primarily Emanuel Tsegaye's work, with Karen Ehrhardt's fixes to the Legendre fit and output.
What's here
diffraction/padf.py:PairAngleDistributionFunction(per-pattern angular correlation, median subtraction, Legendre fit with |sin θ| weights, spherical Bessel transform, PADF Θ(r, r′, θ) with an optional taper of the Legendre orders to suppress ringing in θ),plot_g2_g3,simple_plot(side-by-side and fixed-r maps),plot_angular_correlationbandlimit_volume: band-limits a model g3 to the measured q range and l_maxpadf_from_clusters: model PADF from all interatomic vectors of atomic clusters (2-, 3- and 4-body terms, as the diffraction PADF measures)diffraction/padf2d.py:PairAngleDistributionFunction2D, an in-plane variant (circular harmonics and Hankel transforms) for 2D samples that only rotate in plane, which also retains odd harmonics when Friedel symmetry is broken, pluspadf2d_from_clustersdiffraction/bispectrum.py: angular bispectrum for Friedel-symmetry breakingdiffraction/gr_truth.py: three-body g3 histograms of 3D and 2D atomic models (adapted from Arthur McCray's PDFs_3batch)diffraction/lattices.py,multislice.py: test-image and pattern simulation (2D lattices, random clusters of 3D structures with Weickenmeier-Kohl scattering factors)polar_transform: accepts 2D patterns and 3D stacks as well as 4D-STEMPairDistributionFunction: the default background is now a constant plus one power law, B(k) = c + a (1 + k²/s²)^(−p), with positive parameters so the single scattering f(k) = B − c is positive and monotonic, fit with k / I(k) weighting (the error in F(k)).bg_model="power"with two terms,"known"(N⟨f⟩² + c from tabulated scattering factors) and the previous"gaussian"are options. The low-r density correction now acts over the transform window rather than the background fit range.core.visualization.show_1d(identical to the copy ondiffractive_imaging)Validation (notebooks, not in the repo)
padf_from_clusters), not only triplets. With the known-scattering-factor background (fit at k > 1 1/Å) over the full k range and the low-r correction below 2 Å, g(r) is zero below the first shell and the first peak matches the model (2.30 Å, height 4.0 vs 4.3).🤖 Generated with Claude Code