Skip to content

Conversation

ktactac-ornl
Copy link
Contributor

@ktactac-ornl ktactac-ornl commented May 5, 2025

Description of work

Summary of work

Introduces a new python algorithm RefineSingleCrystalGoniometer to handle a special case where FindUBUsingIndexedPeaks did not index all peaks.

Purpose of work

# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np

from scipy.spatial.transform import Rotation
import scipy.optimize

filename = '/SNS/TOPAZ/IPTS-33878/shared/RFMBA2PbI4/RFMBA2PbI4_mantid_295K_find_peaks/RFMBA2PbI4_Monoclinic_P_5sig.integrate'

LoadIsawPeaks(Filename=filename, OutputWorkspace='peaks')

FindUBUsingIndexedPeaks(PeaksWorkspace='peaks', Tolerance=0.12)
IndexPeaks(PeaksWorkspace='peaks'', Tolerance=0.12)


The above script shows peculiar behavior. Running FindUBUsingIndexedPeaks only indexes about half the peaks. Running index peaks right after indexes nearly all of them. It seems the FindUBUsingIndexedPeaks algorithm is not working properly.

The problem is actually with the goniometer settings of the requested angles not reflecting reality.

The solution is a new mantid algorithm that refines the UB-matrix and goniometer offsets simultaneously. This improves the indexing of the peaks for those cases when there is sample misorientation.

Fixes 9593: [Story] RefineSingleCrystalGoniometer: FindUBUsingIndexed peaks only indexes half the number of reflections as IndexPeaks.

Further detail of work

To test:

PYTHONPATH=/path/to/build/bin python3 /path/to/src/Framework/PythonInterface/test/python/plugins/algorithms/RefineSingleCrystalGoniometerTest.py


Reviewer

Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.

Code Review

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • If there are changes in the release notes then do they describe the changes appropriately?
  • Do the release notes conform to the release notes guide?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed?
  • Do the changes handle unexpected situations, e.g. bad input?
  • Has the relevant (user and developer) documentation been added/updated?

Does everything look good? Mark the review as Approve. A member of @mantidproject/gatekeepers will take care of it.

Gatekeeper

If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.

@ktactac-ornl ktactac-ornl self-assigned this May 5, 2025
@ktactac-ornl ktactac-ornl added Single Crystal Issues and pull requests related to single crystal Framework Issues and pull requests related to components in the Framework ORNL Team Issues and pull requests managed by the ORNL development team labels May 5, 2025
@ktactac-ornl ktactac-ornl added this to the Release 6.13 milestone May 5, 2025
@ktactac-ornl ktactac-ornl marked this pull request as draft May 5, 2025 17:03
@sf1919
Copy link
Contributor

sf1919 commented May 6, 2025

The Linux Systems Test and Windows Test failures are genuine. Please ignore OSX. I won't re-run though as there will be further commit(s) to fix the failing tests.

@zjmorgan
Copy link
Contributor

zjmorgan commented May 6, 2025

image
Use Mantid-like variable names

tol -> Tolerance
cell -> Cell
n_iter - NumIterations

@zjmorgan
Copy link
Contributor

zjmorgan commented May 6, 2025

Add a check for an oriented lattice. Don't run without the UB/oriented lattice

Error in execution of algorithm RefineSingleCrystalGoniometer:
Sample::getOrientedLattice - No OrientedLattice has been defined.
  at line 76 in '/home/zgf/git/mantid/Framework/PythonInterface/plugins/algorithms/RefineSingleCrystalGoniometer.py'

@ktactac-ornl ktactac-ornl requested a review from zjmorgan May 6, 2025 17:43
@zjmorgan
Copy link
Contributor

zjmorgan commented May 6, 2025

Once the test passes, It should be good to approve

Copy link
Contributor

@zjmorgan zjmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works well for the dataset provided.

@peterfpeterson peterfpeterson merged commit 82b8c6a into main May 7, 2025
10 checks passed
@peterfpeterson peterfpeterson deleted the ewm9593-newPythonAlgorithm-RefineSingleCrystalGoniometer branch May 7, 2025 12:29
rboston628 pushed a commit that referenced this pull request May 7, 2025
Introduces a new python algorithm `RefineSingleCrystalGoniometer` to handle a special case where `FindUBUsingIndexedPeaks` did not index all peaks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues and pull requests related to components in the Framework ORNL Team Issues and pull requests managed by the ORNL development team Single Crystal Issues and pull requests related to single crystal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants