=== Python ===


from mantid.simpleapi import *
import os
import sys
#load file
list_pwd =os.getcwd()
head = list_pwd + '/' + sys.argv[1]
os.chdir(head)
ws = Load('mccode.h5')

sample = Rebin(ws[0],'10', False)
sample = ConvertUnits(sample, 'Wavelength')
binning = '1.75,0.05,16.5'
sample = Rebin(sample, binning)
mcstasMonitor = CloneWorkspace(mtd['Edet1.dat_ws'])
mcstasMonitor = ConvertToHistogram(mcstasMonitor)
mcstasMonitor = rebin(mcstasMonitor, binning)
monitor = CreateWorkspace(mcstasMonitor.dataX(0), mcstasMonitor.dataY(0), mcstasMonitor.dataE(0), UnitX='Wavelength')
binningMASK = '0.0005,0.0005,0.4,0.01,0.7'
reduced_norm = Q1D(sample, binningMASK, WavelengthAdj='monitor')

# save as ascii
SaveAscii(InputWorkspace='reduced_norm',Filename='Iq_mcstas.dat',ScientificFormat=True,Separator="Tab")