Ticket #9312 (closed: fixed)

Opened 7 years ago

Last modified 5 years ago

Calculate Flat background removes backgound from monitors.

Reported by: Alex Buts Owned by: Alex Buts
Priority: major Milestone: Release 3.2
Component: Framework Keywords:
Cc: Blocked By:
Blocking: #9135 Tester: Karl Palmen

Description (last modified by Alex Buts) (diff)

This should never happens.

The script below provides workspace 2 match either when calculateFlatBackground is disabled or when one explicitly provides the list of the spectra, which excludes monitors. This actually means that it removes background from monitors which is useless operation and dangerous operation. Instrument scientists were complaining to me about strange behaviour of the background removal, but I did not understood the reason behind this.

Should be fixed.

######################################################################
#Python Script Generated by GeneratePythonScript Algorithm
######################################################################
Load(Filename=r'd:\Data\MantidSystemTests\Data\MAR11001.raw',OutputWorkspace='MAR11001.raw')
LoadDetectorInfo(Workspace='MAR11001.raw',DataFilename=r'd:\Data\MantidSystemTests\Data\MAR11060.raw',RelocateDets='1')

GetEi(InputWorkspace='MAR11001.raw',Monitor1Spec='2',Monitor2Spec='3',EnergyEstimate='12')
ScaleX(InputWorkspace='MAR11001.raw',OutputWorkspace='11001.spe',Factor='-6536.707778516824',Operation='Add',InstrumentParameter='DelayTime',Combine='1')
MoveInstrumentComponent(Workspace='11001.spe',ComponentName='Moderator',Z='-1.4419999999999999',RelativePosition='0')

ConvertToDistribution(Workspace='11001.spe')
spectra=range(3,921);
CalculateFlatBackground(InputWorkspace='11001.spe',OutputWorkspace='11001.spe',WorkspaceIndexList=spectra,StartX='11463.292221483176',EndX='12963.292221483176',Mode='Mean')
ConvertFromDistribution(Workspace='11001.spe')
#
CropWorkspace(InputWorkspace='11001.spe',OutputWorkspace='11001_OldCFine.spe',StartWorkspaceIndex='3',EndWorkspaceIndex='921')
#
NormaliseToMonitor(InputWorkspace='11001.spe',OutputWorkspace='11001.spe',MonitorSpectrum='1',IntegrationRangeMin='-5536.7077785199999',IntegrationRangeMax='-4536.7077785199999',IncludePartialBins='1')
CropWorkspace(InputWorkspace='11001.spe',OutputWorkspace='11001_step1aOldC.spe',StartWorkspaceIndex='3',EndWorkspaceIndex='921')
############################################################################################################

######################################################################
#Python Script Generated by GeneratePythonScript Algorithm
######################################################################
Load(Filename=r'd:\Data\MantidSystemTests\Data\MAR11001.raw',OutputWorkspace='MAR11001.raw',LoadMonitors='Separate')
LoadDetectorInfo(Workspace='MAR11001.raw',DataFilename=r'd:\Data\MantidSystemTests\Data\MAR11060.raw',RelocateDets='1')

GetEi(InputWorkspace='MAR11001.raw_Monitors',Monitor1Spec='2',Monitor2Spec='3',EnergyEstimate='12')
AddSampleLog(Workspace='MAR11001.raw',LogName='Ei',LogText='12.9728953307',LogType='Number')
ScaleX(InputWorkspace='MAR11001.raw_Monitors',OutputWorkspace='11001.spe_monitors',Factor='-6536.707778516824',Operation='Add',InstrumentParameter='DelayTime',Combine='1')
ScaleX(InputWorkspace='MAR11001.raw',OutputWorkspace='11001.spe',Factor='-6536.707778516824',Operation='Add',InstrumentParameter='DelayTime',Combine='1')
MoveInstrumentComponent(Workspace='11001.spe',ComponentName='Moderator',Z='-1.4419999999999999',RelativePosition='0')
#
ConvertToDistribution(Workspace='11001.spe')
CalculateFlatBackground(InputWorkspace='11001.spe',OutputWorkspace='11001.spe',StartX='11463.292221483176',EndX='12963.292221483176',Mode='Mean')
ConvertFromDistribution(Workspace='11001.spe')
#
CloneWorkspace(InputWorkspace='11001.spe',OutputWorkspace='11001NewFine')

rez=CheckWorkspacesMatch('11001NewFine','11001_OldCFine.spe');
print ' Match1=',rez

# Causes difference:
NormaliseToMonitor(InputWorkspace='11001.spe',OutputWorkspace='11001.spe',MonitorWorkspace='11001.spe_monitors',IntegrationRangeMin='-5536.7077785199999',IntegrationRangeMax='-4536.7077785199999',IncludePartialBins='1')
#AddSampleLog(Workspace='11001.spe',LogName='DirectInelasticReductionNormalisedBy',LogText='monitor-1')


rez=CheckWorkspacesMatch('11001_step1aOldC.spe','11001.spe');
print ' Match2=',rez


Change History

comment:1 Changed 7 years ago by Alex Buts

  • Description modified (diff)

comment:2 Changed 7 years ago by Alex Buts

  • Blocking 9135 added

comment:3 Changed 7 years ago by Owen Arnold

I can see why this option might be desired, but these changes should also be discussed with Tim Charlton and Max Skoda if your solution involves changing the default behaviour of CalculateFlatBackground to make it ignore monitors because one of the scripts they provided to me:

https://github.com/mantidproject/mantid/blob/82fd32291923748ce439f3d388a81785ec0524fa/Code/Mantid/scripts/Reflectometry/isis_reflectometry/quick.py#L384

includes CalculateFlatBackground on monitor spectrum.

comment:4 Changed 7 years ago by Alex Buts

refs #9312 Added option to skip background removal from monitors.

Changeset: e0bcbd8ae9d3c702e21444207131d64e13828eac

comment:5 Changed 7 years ago by Alex Buts

refs #9312 Added unit test for the option

Changeset: 236174765e5d22ec1d334b3da72c911c1955fb63

comment:6 Changed 7 years ago by Alex Buts

refs #9312 Minor comments.

Changeset: fdba0c0425b961bcc0231dc1686f4dc999e17298

comment:7 Changed 7 years ago by Alex Buts

  • Status changed from new to assigned

The script above is an overkill to test this ticket.

As apparently some people do want to remove background from monitors (not an inelastic one), I've introduced new algorithm parameter which prohibit this but the background from monitors is still removed by default.

Changes are trivial, unit test for this written and works so it is easy to test this ticket by code review.

comment:8 Changed 7 years ago by Alex Buts

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

comment:9 Changed 7 years ago by Alex Buts

refs #9312 Add some Comments

Changeset: 2f99de646b372624bf409f6425086ec2ec50743d

comment:10 Changed 6 years ago by Alex Buts

refs #9312 Logging if no detector found.

Changeset: 12626c712fdaa43f8c728aa7f4b4d63a583e9e7f

comment:11 Changed 6 years ago by Alex Buts

  • Blocking 9135 removed

comment:12 Changed 6 years ago by Alex Buts

  • Blocking 9135 added

comment:13 Changed 6 years ago by Karl Palmen

  • Status changed from verify to verifying
  • Tester set to Karl Palmen

comment:14 Changed 6 years ago by Karl Palmen

  • Status changed from verifying to closed

Merge remote-tracking branch 'origin/bugfix/9312_backgroundNoMonitors'

Full changeset: 21d4d2d4b1c947f0fdae8885ad1f5672aafaface

comment:15 Changed 6 years ago by Alex Buts

Merge branch 'bugfix/9312_backgroundNoMonitors' into bugfix/9135_ISISRawAndMonitors

Full changeset: cc89ee70b106ca72f986fc64d7ef17183f088343

comment:16 Changed 6 years ago by Alex Buts

Merge branch 'bugfix/9312_backgroundNoMonitors' into bugfix/9135_ISISRawAndMonitors

Full changeset: b441bfcaf08758b4b1075d2f1e8c0afd24a8b72b

comment:17 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 10155

Note: See TracTickets for help on using tickets.