Skip to content

Conversation

MohamedAlmaki
Copy link
Contributor

@MohamedAlmaki MohamedAlmaki commented Jul 1, 2025

Description of work

This PR add two new options to the PlotPeakByLogValue algorithm that are enabled when the "CreateOutput" option is true. First option "AppendIdxToOutputName", appends the index of the corresponding output depending on which format is used in the input (either spectrum number, workspace index, or numeric value). This is enabled now by default for the sequential fit output. The second option, "Output2D", creates a 2D workspace of the results table, displaying the workspace index versus parameter value. This option groups the parameter results together to create a workspace index vs parameters
It also adds a new UI option to the Sequential fit dialogue to enable this new 2D option.

Fixes #39294

Further detail of work

The implementation involves enabling the alwaysStoreInAds option in the child Fit algorithms. It turned out that because this option was not enabled, the output workspace returned by the Fit algorithm was an empty string. This is why the output names are the same as the group workspace name, numbered by their position. One thing to note is that the final outputs seem to be duplicated using both the workspace names and workspace objects. This is because if you enable alwaysStoreInAds, then the returned workspace objects from the algorithm will be null, and the only way to access the workspaces is from the ADS. In the case of alwaysStoreInAds being false, the returned workspaces will contain the actual workspace, but their names will be null. This is one of the drawbacks of using ADS vs not.

To test:

1- Load any data (e.g. iris26176_graphite002_red)
2- Go to Plot Spectrum and click Fit
3- Add a peak (e.g. Lorentzian)
4- Press Sequential Fit, and a dialogue will open
5- Check the Create Output check box
6- In the table view, set Range to any preferred workspace index range (e.g. 4-6)
7- Press Fit
8- You will see 3 output group workspaces suffixed with "_Parameters", "_NormalisedCovarianceMatrices" and "_Workspaces"
9- Each group workspace will have the same number of spectra in the selected range
10- You can see that each workspace name includes the spectrum number and is suffixed with "_Parameters", "_NormalisedCovarianceMatrix" and "_Workspace" in each group, respectively (e.g. iris26176_graphite002_red_res_3_Parameters)

11- Try to enable the new "Output spectrum vs params" in the sequential fit dialogue, and a new output suffixed with "_ws" will appear. Plot the workspace, and it will contain a plot for each parameter.


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.

@MohamedAlmaki MohamedAlmaki changed the title Include spectrum number in sequential fit output workspace names Include spectrum number in sequential fit output workspaces names Jul 1, 2025
@MohamedAlmaki MohamedAlmaki added ISIS: Core Issue and pull requests at ISIS that relate to Core features and functions Reported By User Issues that were found or highlighted by a user/scientist labels Jul 1, 2025
@MohamedAlmaki MohamedAlmaki added this to the Release 6.14 milestone Jul 1, 2025
@MohamedAlmaki MohamedAlmaki marked this pull request as ready for review July 1, 2025 12:01
@MialLewis
Copy link
Contributor

MialLewis commented Jul 17, 2025

Sorry for taking so long to review this.

I've just done some functional testing, and it's not clear to me what the numbers appended to each workspace are.

You say in the PR that they are spectrum numbers. The range input into the table appears to be workspace index.

If I do a range of 4:6, I see workspaces appended 3, 4 and 5. I would have expected 4, 5, 6.

Are the numbers in the table in spectrum number, and the numbers appended to the workspace in workspace index?

It makes sense to me to align these.

@MohamedAlmaki
Copy link
Contributor Author

MohamedAlmaki commented Jul 17, 2025

Yes, the range in the table is workspace index, and numbers appended to the output names are the spectrum numbers. It is implemented like that because the Fit algorithm output uses spectrum numbers. Either we change the interface workspace index to be spectrum numbers, or maybe modify the Fit algorithm to include the workspace index instead. I could add a new property for the name mode to either the workspace index or the spectrum number to the algorithm

@MialLewis
Copy link
Contributor

Yes, the range in the table is workspace index, and numbers appended to the output names are the spectrum numbers

I don't think this is working in that way.

Intentionally or not, the numbers in the table are spectrum numbers. The logic is here:

The numbers then appended to the workspace are the workspace index.

The tool tip in the SequentialFitDialog window is unclear, can we improve it?

It references a numeric axes, which the underlying algorithm PlotPeakByLogValue is set up to handle. At least the test workspace we used here does not have a numeric axis, is actually at all relevant to the SequentialFitDiag?

@SpencerHowells
Copy link

@MialLewis The sequential fit dialogue & tooltip appears to be written for several workspaces. For a single workspace with many spectra they are incomprehensible. Hence my request!

@MohamedAlmaki
Copy link
Contributor Author

Yes, you are correct, thanks for spotting that. I got confused and switched the two numbers. I will unify the number used in the interface with the one appended to the names. The tests were mainly written to test if the output names are correct, but I will add a test to cover the numeric axis case

@MohamedAlmaki
Copy link
Contributor Author

Currently in PlotPeakByLogValue, the user can specify the range of fitting using three different indices: either workspace index, spectrum index or numeric value. I have added logic to include the type and value of each one in the output names.
New updates:

  • Handles all types of ranges, spectra, numeric and workspace index, where these abbreviations (sp, v, i) are used as prefixes for each, respectively.
  • Append the full range to the group output name, too.
  • Match the sequential fit interface output with the range provided; the range in the interface could either be a range of spectra numbers or a range of numeric values (sp is used for spectra and v for numeric values)
  • Add a note to the tooltip that the numeric axis could be a spectrum axis
  • Update tests to handle all three cases

@MohamedAlmaki MohamedAlmaki force-pushed the 39294_improve_output_names branch 5 times, most recently from 37f9131 to 92d9204 Compare August 11, 2025 15:24
@MohamedAlmaki MohamedAlmaki force-pushed the 39294_improve_output_names branch from 92d9204 to b5d312c Compare August 13, 2025 08:58
@MohamedAlmaki MohamedAlmaki force-pushed the 39294_improve_output_names branch from b2a71d1 to c018f74 Compare August 21, 2025 13:44
@MohamedAlmaki MohamedAlmaki changed the title Include spectrum number in sequential fit output workspaces names Add new output options to PlotPeakByLogValue algorithm and Sequetial Fit dialouge Aug 22, 2025
@MohamedAlmaki
Copy link
Contributor Author

The PR is ready for review now (last commit is a typo fix). I have updated the description with new details as the implementation has changed a lot. It probably could have been better to split it into two PRs. I have discussed and agreed with Spencer about these new changes.

@sf1919
Copy link
Contributor

sf1919 commented Aug 27, 2025

Thw Windows failure on commit 9e59adf looks genuine. The docs one less so but am presuming the Windows one will require a new commit so it will re-run then.

@MohamedAlmaki MohamedAlmaki force-pushed the 39294_improve_output_names branch from 9e59adf to dae6be3 Compare August 27, 2025 15:41
@MohamedAlmaki MohamedAlmaki force-pushed the 39294_improve_output_names branch from dae6be3 to 114b415 Compare September 2, 2025 09:13
@warunawickramasingha warunawickramasingha self-assigned this Sep 8, 2025
Copy link
Contributor

@warunawickramasingha warunawickramasingha left a comment

Choose a reason for hiding this comment

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

In addition, I think the input for Range needs to be validated, and I have noticed that for inputs such as 4-6 the algorithm seems to be stuck forever.

Copy link
Contributor

@warunawickramasingha warunawickramasingha left a comment

Choose a reason for hiding this comment

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

Thanks for the code changes. I have tested entering the range as -4:-2 which unfortunately crashed mantid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ISIS: Core Issue and pull requests at ISIS that relate to Core features and functions Reported By User Issues that were found or highlighted by a user/scientist
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Improve the naming of Sequential Fit output
5 participants