Ticket #10917 (closed: fixed)
Subtle bug in ISIS reduction
| Reported by: | Alex Buts | Owned by: | Alex Buts |
|---|---|---|---|
| Priority: | major | Milestone: | Release 3.4 |
| Component: | Framework | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: | Tester: | Federico M Pouzols |
Description
ISIS Reduction script for Merlin provided below fails with current Mantid. Fix is trivial but should be done for current reduction to work.
""" Sample MERLIN reduction scrip """
import os
os.environ["PATH"] = r"d:\Data\Mantid_GIT_test\Code\builds\br_master\bin\Release;"+os.environ["PATH"]
from ReductionWrapper import *
try:
import reduce_vars as rv
except:
rv = None
class ReduceMERLIN(ReductionWrapper):
@MainProperties
def def_main_properties(self):
""" Define main properties used in reduction """
prop = {};
prop['sample_run'] = 18995;
prop['wb_run'] = 18962
prop['incident_energy'] = 18;
prop['energy_bins'] = [-10, 0.2, 15]
# Absolute units reduction properties.
#prop['monovan_run'] = 17589
#prop['sample_mass'] = 10/(94.4/13) # -- this number allows to get approximately the same system test intensities for MAPS as the old test
#prop['sample_rmm'] = 435.96 #
return prop
@AdvancedProperties
def def_advanced_properties(self):
""" separation between simple and advanced properties depends
on scientist, experiment and user.
main properties override advanced properties.
"""
prop = {};
prop['map_file'] = 'one2one_125.map'
#prop['monovan_mapfile'] = 'default' #'4to1_mid_lowang.map' # default
prop['hardmaskOnly'] ='Bjorn_mask.msk'
prop['det_cal_file'] = 'det_corr_125.dat' #
prop['save_format']=''
return prop;
#
@iliad
def main(self,input_file=None,output_directory=None):
# run reduction, write auxiliary script to add something here.
red = DirectEnergyConversion()
red.initialise(self.iliad_prop)
runno=range(18995,19100)
ei=[52,23]
ebin=[-0.5,0.005,0.950]
bg_range=[12000,19000] # change from 12000 to 16000 for 7meV range of times to take background in
# loads the whitebeam (or rather the long monovan ). Does it as a raw file to save time as the event mode is very large
present_run=-1
if 'wb_wksp' in mtd:
m=mtd['wb_wksp']
present_run= m.getRunNumber()
if present_run !=red.prop_man.wb_run:
LoadRaw(Filename=str(red.prop_man.wb_run),OutputWorkspace="wb_wksp") # load whitebeam
for run in runno: #loop around runs
file='MER'+str(run)+'.nxs'
LoadEventNexus(Filename=file,OutputWorkspace='w1',SingleBankPixelsOnly='0',LoadMonitors='1',MonitorsAsEvents='0',Precount=True)
AddSampleLog(Workspace='w1',LogName='run_number',LogText=str(run),LogType='Number') #only have to do this as run_number is passed to workspace for event files
ExtractSingleSpectrum(InputWorkspace='w1_monitors',OutputWorkspace='mon',WorkspaceIndex='5') #extract monitor 6
Rebin(InputWorkspace='mon',OutputWorkspace='mon',Params=[1000,100,90000])
ConvertToMatrixWorkspace(InputWorkspace='mon',OutputWorkspace='mon')
ConvertUnits(InputWorkspace='mon',OutputWorkspace='mon',Target='Energy')
NormaliseByCurrent(InputWorkspace='mon',OutputWorkspace='mon') #monitor 6 converted to energy and normalised
#now loop around all energies for the run
for energy in ei:
energy=float(energy)
print (energy)
emin=0.05*energy #minimum energy is with 80% energy loss
lam=(81.81/energy)**0.5
lam_max=(81.81/emin)**0.5
tsam=252.82*lam*11.8 #time at sample
tmon2=252.82*lam*10. #time to monitor 2 on MERLIN
tmax=tsam+(252.82*lam_max*2.8868) #maximum time to measure inelastic signal to
t_elastic=tsam+(252.82*lam*2.8868) #maximum time of elastic signal
tbin=[int(tmon2),1.0,int(tmax)]
energybin=[ebin[0]*energy,ebin[1]*energy,ebin[2]*energy]
energybin = [ '%.4f' % elem for elem in energybin ]
ebinstring=str(energybin[0])+','+str(energybin[1])+','+str(energybin[2])
print ebinstring
Rebin(InputWorkspace='w1',OutputWorkspace='w1reb',Params=[tmon2,1.0,tmax],PreserveEvents=False)
Rebin(InputWorkspace='w1_monitors',OutputWorkspace='w1_mon',Params=[tmon2,1.0,tmax],PreserveEvents=False)
######################################################################
ConjoinWorkspaces(InputWorkspace1='w1reb',InputWorkspace2='w1_mon')
# diag does not always work well on MERLIN. At present only use a hard mask HCW has create
out=red.convert_to_energy("wb_wksp","w1reb",energy,ebinstring,fixei=False,bleed=True,norm_method='current',\
detector_van_range=[0.5,200])
SaveNXSPE("out",'MER'+str(run)+'_'+str(energy)+'meV_one2one125.nxspe')
#when run from web service, return additional path for web server to copy data to";
return ""
def __init__(self):
""" sets properties defaults for the instrument with Name"""
ReductionWrapper.__init__(self,'MER',rv)
#----------------------------------------------------------------------------------------------------------------------
if __name__=="__main__":
#maps_dir ='/home/merlin/mprogs/InstrumentFiles/merlin/'
#maps_dir = 'd:/Data/MantidSystemTests/Data'
maps_dir = r'c:\Users\wkc26243\Documents\work\InstrumentFiles\merlin'
data_dir ='d:/Data/Mantid_Testing/14_12_15'
ref_data_dir = 'd:/Data/MantidSystemTests/SystemTests/AnalysisTests/ReferenceResults'
config.setDataSearchDirs('{0};{1};{2}'.format(data_dir,maps_dir,ref_data_dir))
#config.appendDataSearchDir('d:/Data/Mantid_GIT/Test/AutoTestData')
config['defaultsave.directory'] = data_dir # folder to save resulting spe/nxspe files. Defaults are in
# execute stuff from Mantid
rd = ReduceMERLIN()
rd.def_advanced_properties()
rd.def_main_properties()
rd.main()
Change History
comment:2 Changed 6 years ago by Alex Buts
To tester -- This is trivial fix but it make sense only if it goes to Release 3.3
I made substantial changes for Release 3.4 which should fix bug and make this ticket unnecessary.
The branch remains just as reference point for some time.
comment:4 Changed 6 years ago by Alex Buts
- Status changed from assigned to verify
- Resolution set to fixed
comment:5 Changed 6 years ago by Federico M Pouzols
- Status changed from verify to verifying
- Tester set to Federico M Pouzols
comment:6 follow-up: ↓ 7 Changed 6 years ago by Federico M Pouzols
Is this ticket fixed and should it be merged into master, or has it become invalid?
comment:7 in reply to: ↑ 6 Changed 6 years ago by Alex Buts
Replying to Federico M Pouzols:
Its fixed but should not be merged to master -- I made changes to develop which make this ticket redundant. (and they may be already in master) But this is bugfix for reduction in Release 3.3, so this should sit ready to case if somebody needs it for release 3.3 and is not ready to change to develop version or pull the changes I made to reduction.
I think this just should stay as it is for a while in case of patch release is requested

Re #10917 This should fix it
Changeset: 5b43f7a9f3e306355f835fabdd93b035b6d85a79