-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RotateSampleShape algorithm created #37908
Conversation
1ffe77f
to
d8a6acc
Compare
d8a6acc
to
f96da9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's some comments - sorry haven't been able to test yet getting boost errors which i think means I need to do a clean rebuild...
return false; | ||
} | ||
|
||
void RotateSampleShape::prepareGoniometerAxes(Goniometer &gon, const API::ExperimentInfo_sptr &ei) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be the same as SetGoniometer
code - I wonder if it's possible to refactor and put in a place it can be called from both algorithms? Like a goniometer helperfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although they appear to be the same code, there are some differences in terms of some additional validations, throw errors I have added in RotateSampleShape
's code and in the below line(angle
was set as 0 in SetGoniometer
alg)
gon.pushAxis(axisName, x, y, z, angle, ccw);
If you think those validations are better to be included in SetGoniometer algorithm as well, then I can move to a utility class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, is there any reason why the validation has to be different in this case? If so then I'm OK to duplicate some code here - I definitely don't want to change the behaviour of SetGoniometer
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1- Validation was done a little bit different to give more detailed information to the user such as
if (!Strings::convert(tokens[1], x))
throw std::invalid_argument("Error converting x string '" + tokens[1] + "' to a number.");
vs
if (!Strings::convert(tokens[1], x))
throw std::invalid_argument("Error converting string '" + tokens[1] + "' to a number.");
2- For SetGoniometer
the below is a valid axis but not valid for RotateSampleShape
as it needs the rotation angle as an input and hence needs a different validation.
Axis0="Motor1,0,1,0,1"
3- The name of the TimeSeriesProperty(axisName
) added as a log value in RotateSampleShape
below needs to differ from SetGoniometer
as well to keep them separate when both algorithms are used for the same sample(which can be an input to helper class).
if (ei->mutableRun().hasProperty(axisName)) {
ei->mutableRun().removeLogData(axisName);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK sounds good thanks!
'Center': [0.,0.,0.]}, | ||
Material={'ChemicalFormula': '(Li7)2-C-H4-N-Cl6', | ||
'NumberDensity': 0.1}) | ||
RotateSampleShape(Workspace=ws, Axis0="45,1,1,0,1", Axis1="15,0,0,1,-1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be overkill to print out some shape xml in the test code so the user can see something has actually changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this has broken the doctests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry! Is that because we don't have a .. testoutput::
block? Doesn't need to be a doc test, can just make it
**Example:**
.. code-block:: python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functional testing done - it works well!
Co-authored-by: RichardWaiteSTFC <[email protected]>
…mantid into 1643930_RotateSampleShape
if (ei->mutableRun().hasProperty(axisName)) { | ||
ei->mutableRun().removeLogData(axisName); | ||
} | ||
ei->mutableRun().addLogData(tsp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this again, I don't think it's necessary to add the gonio axis to the logs as in SetGoniometer
- here everything we need is saved on the sample shape/xml right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is not necessary to add this gonio axis log values (with a different name opposed to SetGoniometer
) this bit can be removed, since it does not affect the functionality.
Changes look good, just an unused parameter causing clang failure. Once fixed I will approve! |
Where can I see this Clang failure? locally it builds fine to me. |
If you look at the OSX build it says Clang: One warning - if you click on that it shows you |
@warunawickramasingha I won't re-run the linux tests as it looks like you need to make another commit and it will re-run then. |
Thanks for the reviews @RichardWaiteSTFC! This has been fixed and now the CI is green |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great thanks!
That PR causes a dynamic library loading problem in the release.
This reverts commit 6bac453.
This reverts commit 6bac453.
Description of work
Created a new algorithm named
RotateSampleShape
to define the initial orientation of a sample wrt the beam and instrument.Summary of work
Using
RotateSampleShape
the sample shape can be rotated by the goniometer before being used in the calculation of various attenuation corrections. It would change the orientation of a sample on a workspace and work for CSG shapes (e.g. cylinders, flat plates etc.) and Mesh files.Fixes #34565.
To test:
Test 1:
RotateSampleShape
for a workspace containing a CSG sample shape:ws
->Show Sample Shape
RotateSampleShape
algorithm and observe the new orientation of the sample.Test 2:
RotateSampleShape
for a workspace containing a Mesh shape:ws
->Show Sample Shape
RotateSampleShape
algorithm and observe the new orientation of the sample.Test 3:
RotateSampleShape supports upto 6 axes of rotations. Play around with different combination of axes and configurations to observe the resulting orientation of the sample. Observe the resulting sample orientation when there is already a goniometer set with
SetGoniometer
as below.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
Functional Tests
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.