Skip to content
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

Add polarisation spin state to ISIS ORSO file metadata #38468

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

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 Team: LSS Issue and pull requests managed by the LSS subteam 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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ISIS Team: LSS Issue and pull requests managed by the LSS subteam 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
2 participants