Skip to content

Conversation

adriazalvarez
Copy link
Contributor

Description of work

Explained in #36685

Summary of work

Fixes #36685.

Further detail of work

  1. In the original issue, is it described that the name of the workspaces contained in a group should be modified to contain the polarization as well as the theta angle. I have also included the name of the workspace in this string: {workspace_name}{theta}{polarization}.
  2. I'm not sure that is possible to add the polarization header without adding an instrument settings header. This has the consequence of adding two fields on the instrument settings header: theta and wavelength. We agreed upon the standard values these fields should have, so they are written as null for files with polarization.

To test:

Run the following script, a file named corrected.ort should be saved on your default save directory.

CreateSampleWorkspace(OutputWorkspace='out_00', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=48000, PeakCentre=2.65, FWHM=1.2', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)
CreateSampleWorkspace(OutputWorkspace='out_11', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=47000, PeakCentre=2.65, FWHM=1.2', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)
CreateSampleWorkspace(OutputWorkspace='out_10', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=22685, PeakCentre=2.55, FWHM=0.6', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)
CreateSampleWorkspace(OutputWorkspace='out_01', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=22685, PeakCentre=2.55, FWHM=0.6', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)
group = GroupWorkspaces(['out_00','out_11','out_10','out_01'])
group = ConvertUnits(group, "Wavelength")

ws1 = CreateWorkspace([0.01, 17.0, 34.0], [50000, 50000])
eff = JoinISISPolarizationEfficiencies(P1=ws1,   P2=ws1, F1=ws1, F2=ws1)
eff = ConvertUnits(eff, "Wavelength")
eff = RebinToWorkspace(eff, group[0], True)

corrected = PolarizationCorrectionWildes([group[0], group[1], group[2], group[3]], Efficiencies=eff, AddSpinStateToLog=True)

#Not correct transformation but need q units to save the data
corrected = ConvertUnits(corrected,'MomentumTransfer')
SaveISISReflectometryORSO(corrected,'corrected.ort')

Once the file is saved, open the file as text and check that the following entries are added on the instrument settings header before each data columns:
polarization:pp,
polarization:pm,
polarization:mp,
polarization:mm

Added release notes


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.

@adriazalvarez adriazalvarez added Reflectometry Issues and pull requests related to reflectometry ISIS: LSS Issue and pull requests relating to SANS and Reflectometry (Large Scale Structures) at ISIS labels Dec 3, 2024
@adriazalvarez adriazalvarez marked this pull request as ready for review December 5, 2024 08:48
@rbauststfc rbauststfc self-assigned this Dec 5, 2024
Copy link
Contributor

@rbauststfc rbauststfc left a comment

Choose a reason for hiding this comment

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

This is working really well for the majority of cases and the implementation is structured consistently with the rest of the code. Appropriate tests have been added. Great job getting to grips with the existing implementation on this one, there's a lot to get up to speed with.

The naming of datasets in the file currently isn't working for stitched polarised datasets. I've added some information below, but just let me know if you want to chat about this more and go through a demo of how to test this in the Reflectometry GUI.

I've also added a few suggestions from a maintainability/future-proofing perspective that might be worth considering.

@adriazalvarez adriazalvarez marked this pull request as draft December 9, 2024 18:11
Comment on lines +158 to +161
if self.is_polarized:
self._name = f"{self._name} {self._spin_state}"
return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
if self.is_polarized:
self._name = f"{self._name} {self._spin_state}"
return
if self.is_polarized:
self._name = f"{self._name} {self._spin_state}"
return

Here I have decided to return early because if the dataset is polarized is not necessary to prepend the ws name for unique datasets and in some cases the ws name would be repeated.

@adriazalvarez
Copy link
Contributor Author

I've built conda and standalone packages to test the Python Module. Everything seems to work correctly (tried on conda, windows and mac). I'll leave on draft as I still need to add a test for the module .

@adriazalvarez adriazalvarez marked this pull request as ready for review January 2, 2025 15:47
@sf1919
Copy link
Contributor

sf1919 commented Jan 3, 2025

For the moment I'll add a v6.12 milestone to this. It can always be changed if it looks like it won't get in by 16th January.

@sf1919 sf1919 added this to the Release 6.12 milestone Jan 3, 2025
Copy link
Contributor

@rbauststfc rbauststfc left a comment

Choose a reason for hiding this comment

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

Great job getting the import of the C++ constants to work, it's really nice for maintainability to be able to re-use those on the Python side too! Functionally the changes are all working really well for stitched and non-stitched datasets, and for workspace groups with and without polarisation corrections. 👍

I've added just a few minor comments, mostly just a couple of places where we might be able to make use of the log name constant. I've also suggested a slightly different update to the documentation about the dataset names, now that the logic for that has changed a little bit.

Copy link
Contributor

@rbauststfc rbauststfc left a comment

Choose a reason for hiding this comment

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

All code review comments have been addressed. The code changes are looking good and working really well, with appropriate test coverage. Thanks very much for all your work on this @adriazalvarez!

@SilkeSchomann SilkeSchomann self-assigned this Jan 8, 2025
@SilkeSchomann SilkeSchomann merged commit 0e5f44f into main Jan 8, 2025
10 checks passed
@SilkeSchomann SilkeSchomann deleted the save_pol_orso branch January 8, 2025 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ISIS: LSS Issue and pull requests relating to SANS and Reflectometry (Large Scale Structures) at ISIS Reflectometry Issues and pull requests related to reflectometry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add polarisation spin state to ISIS ORSO file metadata
4 participants