Ticket #9184 (closed: fixed)

Opened 7 years ago

Last modified 5 years ago

ReflectometryReductionOne should correct positions

Reported by: Owen Arnold Owned by: Owen Arnold
Priority: critical Milestone: Release 3.2
Component: Reflectometry Keywords:
Cc: Blocked By: #9389, #9401
Blocking: Tester: Keith Brown

Description (last modified by Owen Arnold) (diff)

This is a simple principle: If you have known incident theta angle, and a reflection condition, i.e. theta_in == theta_out, then you can correct the detector positions accordingly.

I've avoided this problem so far, because for the multi-detector case you may have a number of 'masked' pixels, in which case there is no easily identifiable vertical centre position.

Having had a chat with Tim about this, we've agreed that if you have a range of pixels in the processing instructions, you should find the centre location and use that, along with the theta position to correct location. Corrections should still be optional.

Changes should apply to ReflectometryReductionOne, ReflectometryReductionOneAuto, CreateTransmissionWorkspace and CreateTransmissionWorkspaceAuto.

As part of this. We should also update ReflectometryReductionOne (following #9401) to calculate The OuptutTheta value if Multiple Spectrum numbers are given instead of component names.

Change History

comment:1 Changed 7 years ago by Owen Arnold

  • Component changed from Framework to Reflectometry

comment:2 Changed 7 years ago by Nick Draper

  • Status changed from new to assigned

comment:3 Changed 6 years ago by Owen Arnold

This can be fixed around lines 308 of ReflectometryReductionOne.cpp. Instead of knowing the exact components to use in the multidetector case, we must determine them from the ProcessingCommands. Should be relatively easy given that we know the Reference frame and the detector positions corresponding to these workspace indexes.

comment:4 Changed 6 years ago by Owen Arnold

This is complex enough that the functionality to do it is deserving of it's own algorithm. I'm going to create a new blocking ticket to do this first.

comment:5 Changed 6 years ago by Owen Arnold

  • Blocked By 9389 added

comment:6 Changed 6 years ago by Owen Arnold

  • Description modified (diff)
  • Blocked By 9401 added

comment:7 Changed 6 years ago by Owen Arnold

  • Status changed from assigned to inprogress

refs #9184. Test point detector position correction.

Changeset: d0d12dd1ffc5e0c102d319b21acfde55f23527b2

comment:8 Changed 6 years ago by Owen Arnold

refs #9184. Employ and test position correction multidetector

Changeset: 759476e7b68a2c30968ca8a03ffb2ebc4dc2bec7

comment:9 Changed 6 years ago by Owen Arnold

Tester:

Unit tests demonstrate this new functionality behaving properly. To manually test...

1) Run the following. It prints out the x,y,z of the linear detector of the corrected component. This is taken from an existing system test. The z-offset is correct.

from mantid.simpleapi import *


class ReflectometryISIS():
    

    def get_workspace_name(self):
        return "POLREF4699"
    
    def runTest(self):
        
        workspace_name = self.get_workspace_name()
        workspace_nexus_file = workspace_name + ".nxs"
        
        PIX=1.1E-3 #m
        SC=75
        avgDB=29
        Load(Filename=workspace_nexus_file,OutputWorkspace=workspace_name)
        X=mtd[workspace_name]
        X = ConvertUnits(InputWorkspace=X,Target="Wavelength",AlignBins="1")
        # Reference intensity to normalise by
        CropWorkspace(InputWorkspace=X,OutputWorkspace='Io',XMin=0.8,XMax=14.5,StartWorkspaceIndex=2,EndWorkspaceIndex=2)
        # Crop out transmission and noisy data 
        CropWorkspace(InputWorkspace=X,OutputWorkspace='D',XMin=0.8,XMax=14.5,StartWorkspaceIndex=3)
        Io=mtd['Io']
        D=mtd['D']
    
        # Peform the normaisation step
        Divide(LHSWorkspace=D,RHSWorkspace=Io,OutputWorkspace='I',
               AllowDifferentNumberSpectra='1',ClearRHSWorkspace='1')
        I=mtd['I'][0]
        
        # Automatically determine the SC and averageDB 
        FindReflectometryLines(InputWorkspace=I, StartWavelength=10, OutputWorkspace='spectrum_numbers')
        spectrum_table = mtd['spectrum_numbers']
        
        x = CloneWorkspace(I)
        y = CloneWorkspace(I)
        
        # Move the detector so that the detector channel matching the reflected beam is at 0,0
        MoveInstrumentComponent(Workspace=y,ComponentName="lineardetector",X=0,Y=0,Z=-PIX*( (SC-avgDB)/2.0 +avgDB) )
        
        
        return x, y
        
   
# Specialisation for testing POLREF
z = ReflectometryISIS()
x, y = z.runTest()

print y.getInstrument().getComponentByName('lineardetector').getPos()

2) Now run ReflectometryReductionOneAuto below. This handles the same problem but the correction is made in the algorithm. The Z-offset should be similar to (1)

from mantid.simpleapi import *


class ReflectometryISIS():
    
    def get_workspace_name(self):
        return "POLREF4699"
    
    def runTest(self):
        
        workspace_name = self.get_workspace_name()
        workspace_nexus_file = workspace_name + ".nxs"
        ws = Load(workspace_nexus_file)
        
        out_lam, out_q, s = ReflectometryReductionOneAuto(ws, CorrectDetectorPositions=True, AnalysisMode='MultiDetectorAnalysis', ProcessingInstructions='73', ThetaIn=0.49/2)
        return out_lam, out_q

z = ReflectometryISIS()
x, y = z.runTest()

print y[0].getInstrument().getComponentByName('lineardetector').getPos()

comment:10 Changed 6 years ago by Owen Arnold

  • Status changed from inprogress to verify
  • Resolution set to fixed

comment:11 Changed 6 years ago by Owen Arnold

refs #9184. Merge branch 'master'

Merge branch 'master' into feature/9184_correct_positions_rro

Conflicts:

Code/Mantid/Framework/Algorithms/src/ReflectometryReductionOne.cpp

Changeset: 396ba4e249e42331b914f8e34b19b9e77de98988

comment:12 Changed 6 years ago by Martyn Gigg

  • Status changed from verify to reopened
  • Resolution fixed deleted

There is a cppcheck error in ReflectometryReductionOne: http://builds.mantidproject.org/job/cppcheck_develop/430/cppcheckResult/

comment:13 Changed 6 years ago by Owen Arnold

  • Status changed from reopened to inprogress

refs #9184. Unused var removed.

Changeset: 10ad21ac02469ab949e266094c4e6d5339477324

comment:14 Changed 6 years ago by Owen Arnold

  • Status changed from inprogress to verify
  • Resolution set to fixed

comment:15 Changed 6 years ago by Keith Brown

  • Status changed from verify to verifying
  • Tester set to Keith Brown

comment:16 Changed 6 years ago by Keith Brown

Scripts return the same values to 2 decimal places

comment:17 Changed 6 years ago by Keith Brown

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/feature/9184_correct_positions_rro'

Full changeset: 59a5abba7f9326fde8702242fc61387ad7b52b86

comment:18 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 10027

Note: See TracTickets for help on using tickets.