-
Notifications
You must be signed in to change notification settings - Fork 128
Enable pawly refinement batch processing for GSASII GUI #39963
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
Conversation
43b9c36
to
a009fc8
Compare
a009fc8
to
336f8f3
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.
Thanks for this - I was able to batch process a sequence of runs in GSASII tab (for single and multiple spectra grouping).
Aside from some small comments below there are a few more things required:
- If you run a refinement with an
all_banks.prm
and two .gss files with one spectrum each (i.e.bank_1
andbank_2
) you get this error
GSAS-II call failed with error: Traceback (most recent call last):
File "C:\Users\xhg73778\AppData\Local\gsas2full\GSAS-II\GSASII\GSASIIscriptable.py", line 522, in load_pwd_from_reader
Iparm1, Iparm2 = instprm
^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 2)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\mantid-conda\mantid\qt\python\mantidqtinterfaces\mantidqtinterfaces\Engineering\gui\engineering_diffraction\tabs\gsas2\call_G2sc.py", line 273, in <module>
main()
File "C:\mantid-conda\mantid\qt\python\mantidqtinterfaces\mantidqtinterfaces\Engineering\gui\engineering_diffraction\tabs\gsas2\call_G2sc.py", line 244, in main
add_histograms(data_files, gsas_project, instrument_files, number_of_regions)
File "C:\mantid-conda\mantid\qt\python\mantidqtinterfaces\mantidqtinterfaces\Engineering\gui\engineering_diffraction\tabs\gsas2\call_G2sc.py", line 45, in add_histograms
project.add_powder_histogram(
File "C:\Users\xhg73778\AppData\Local\gsas2full\GSAS-II\GSASII\GSASIIscriptable.py", line 980, in add_powder_histogram
histname, new_names, pwdrdata = load_pwd_from_reader(r, iparams,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xhg73778\AppData\Local\gsas2full\GSAS-II\GSASII\GSASIIscriptable.py", line 524, in load_pwd_from_reader
Iparm1, Iparm2 = load_iprms(instprm, reader, bank=bank)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xhg73778\AppData\Local\gsas2full\GSAS-II\GSASII\GSASIIscriptable.py", line 504, in load_iprms
raise G2ImportException("Instrument parameter file has {} banks, select one with instbank param."
GSASIIscriptable.G2ImportException: Instrument parameter file has 2 banks, select one with instbank param.
This was previously possible but won't be after this change - that's as expected but the error needs to be caught. I think the relevant code is here
Lines 571 to 577 in cabd02b
def understand_data_structure(self) -> None: | |
self.x_limits.data_x_min = [] | |
self.x_limits.data_x_max = [] | |
number_of_regions = 0 | |
for input_file in self.file_paths.data_files: | |
loop_focused_workspace = LoadGSS(Filename=input_file, OutputWorkspace="GSASII_input_data", EnableLogging=False) | |
for workspace_index in range(loop_focused_workspace.getNumberHistograms()): |
-
I think the unit tests in
test_gsas2_model.py
need to be updated to cover this new functionality. -
I think the manual testing insturctions need to be updated (or another test added)
-
I think this section of the GUI docs need updating
GSAS-II Refinement
I'm happy for 3-4 to be done as maintenance!
...dqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/gsas2/model.py
Outdated
Show resolved
Hide resolved
...dqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/gsas2/model.py
Outdated
Show resolved
Hide resolved
...dqtinterfaces/mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/gsas2/model.py
Show resolved
Hide resolved
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.
Thanks for this - nice idea to try call GSAS only once but not sure this is working as expected.
- The logic checking the .rpm and .gss files correctly errors for a for all_banks.prm files with single spectra .gss files, but it also errors for e.g. bank_1.prm and multiple bank_1.gss and bank_1.prm and a single all_banks.gss
The latter error is not handled
GSAS-II call failed with error: Traceback (most recent call last):
File "C:\Users\xhg73778\AppData\Local\gsas2full\GSAS-II\GSASII\GSASIIscriptable.py", line 522, in load_pwd_from_reader
Iparm1, Iparm2 = instprm
^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 2)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\mantid-conda\mantid\qt\python\mantidqtinterfaces\mantidqtinterfaces\Engineering\gui\engineering_diffraction\tabs\gsas2\call_G2sc.py", line 267, in <module>
main()
File "C:\mantid-conda\mantid\qt\python\mantidqtinterfaces\mantidqtinterfaces\Engineering\gui\engineering_diffraction\tabs\gsas2\call_G2sc.py", line 238, in main
add_histograms(data_files, gsas_project, instrument_files, number_of_regions, banks_per_file)
File "C:\mantid-conda\mantid\qt\python\mantidqtinterfaces\mantidqtinterfaces\Engineering\gui\engineering_diffraction\tabs\gsas2\call_G2sc.py", line 46, in add_histograms
project.add_powder_histogram(
File "C:\Users\xhg73778\AppData\Local\gsas2full\GSAS-II\GSASII\GSASIIscriptable.py", line 980, in add_powder_histogram
histname, new_names, pwdrdata = load_pwd_from_reader(r, iparams,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\xhg73778\AppData\Local\gsas2full\GSAS-II\GSASII\GSASIIscriptable.py", line 524, in load_pwd_from_reader
Iparm1, Iparm2 = load_iprms(instprm, reader, bank=bank)
^^^^^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 0)
- It looks to me like it's only refining one set of lattice parameters over multiple runs/spectra (though it is refining instrument parameters for each spectra)

892c3f8
to
ffc7320
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.
Works great thanks so much - just a question about the tests but otherwise happy to approve!
...mantidqtinterfaces/Engineering/gui/engineering_diffraction/tabs/gsas2/test/test_call_G2sc.py
Show resolved
Hide resolved
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.
Thanks - I'm approving this PR as working wonderfully!
Additional unit tests will be added as a maintenance issue #40007
Description of work
This PR introduces batch processing of focused files for Pawly refinement in the GSASII GUI. The interface now supports handling multiple files at once, producing three output files per input, similar to single-file processing. Currently, the plot results are only available for the last refinement, but ideally, they should be generated for all files. This feature will be implemented in the future.
Closes #39606
To test:
Follow GSASII test instructions but using multiple focused files (i.e. 305793-305795): https://developer.mantidproject.org/Testing/EngineeringDiffraction/EngineeringDiffractionTestGuide.html
Reviewer
Your comments will be used as part of the gatekeeper process. Comment clearly on what you have checked and tested during your review. Provide an audit trail for any changes requested.
As per the review guidelines:
Gatekeeper
As per the gatekeeping guidelines: