Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/11096/SumFilesAndDiagMultipleRuns'
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Feb 26, 2015
2 parents 1591aca + 9636db4 commit 9bef2e6
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 23 deletions.
111 changes: 111 additions & 0 deletions SystemTests/AnalysisTests/ISISDirectInelastic.py
@@ -1,6 +1,7 @@
import stresstesting
from mantid.simpleapi import *
from mantid.api import Workspace
import os,shutil

from abc import ABCMeta, abstractmethod
from Direct.PropertyManager import PropertyManager
Expand Down Expand Up @@ -95,6 +96,66 @@ def get_result_workspace(self):
return "outWS"
def get_reference_file(self):
return "MARIReduction.nxs"

class MARIReductionFromFileCache(ISISDirectInelasticReduction):

def __init__(self):
ISISDirectInelasticReduction.__init__(self)
self.tolerance = 1e-9
from ISIS_MariReduction import ReduceMARIFromFile

self.red = ReduceMARIFromFile()
self.red.def_advanced_properties()
self.red.def_main_properties()

def prepare_test_file(self):
""" This method will run instead of pause and
would copy run file 11001 into 11002 emulating
appearance of this file from instrument
"""
self._counter+=1
if self._counter>= 3:
source = FileFinder.findRuns('11001')[0]
targ_path = config['defaultsave.directory']
targ_file = os.path.join(targ_path,'MAR11002.raw')
shutil.copy2(source ,targ_file )

self._file_to_clear = targ_file
self._counter = 0



def runTest(self):
self.red.wait_for_file = 10
self.red._debug_wait_for_files_operation = self.prepare_test_file
self._counter=0

self.red.reducer.prop_man.sample_run = [11001,11002]
MARreducedRuns = self.red.run_reduction()

RenameWorkspace(InputWorkspace=MARreducedRuns[0],OutputWorkspace='MARreducedFromFile')
RenameWorkspace(InputWorkspace=MARreducedRuns[1],OutputWorkspace='MARreducedWithCach')

self.red.wait_for_file =0
self.red._debug_wait_for_files_operation = None
os.remove(self._file_to_clear)

def validate(self):
"""Returns the name of the workspace & file to compare"""
super(MARIReductionFromFileCache,self).validate()
self.tolerance = 1e-9
return 'MARreducedFromFile', 'MARreducedWithCach'

def validateMethod(self):
return "validateWorkspaceToWorkspace"


def get_result_workspace(self):
"""Returns the result workspace to be checked"""
return "outWS"
def get_reference_file(self):
return "MARIReduction.nxs"


class MARIReductionFromWorkspace(ISISDirectInelasticReduction):

Expand Down Expand Up @@ -213,6 +274,56 @@ def get_result_workspace(self):
def get_reference_file(self):
return "MARIReductionSum.nxs"

class MARIReductionWaitAndSum(ISISDirectInelasticReduction):

def __init__(self):

ISISDirectInelasticReduction.__init__(self)
from ISIS_MariReduction import MARIReductionSum

self.red = MARIReductionSum()
self.red.def_advanced_properties()
self.red.def_main_properties()

def prepare_test_file(self):
""" This method will run instead of pause and
would copy run file 11015 into 11002 emulating
appearance of this file from instrument
"""
self._counter+=1
if self._counter>= 3:
source = FileFinder.findRuns('11015')[0]
targ_path = config['defaultsave.directory']
targ_file = os.path.join(targ_path,'MAR11002.raw')
shutil.copy2(source ,targ_file )

self._file_to_clear = targ_file
self._counter = 0

def runTest(self):
"""Defines the workflow for the test
It verifies operation on summing two files on demand. with wait for
files appearing on data search path
"""
self.red.wait_for_file = 100
self.red._debug_wait_for_files_operation = self.prepare_test_file
self._counter=0

self.red.reducer.prop_man.sample_run=[11001,11002]
outWS = self.red.run_reduction()

self.red.wait_for_file =0
self.red._debug_wait_for_files_operation = None
os.remove(self._file_to_clear)


def get_result_workspace(self):
"""Returns the result workspace to be checked"""
return "outWS"

def get_reference_file(self):
return "MARIReductionSum.nxs"

#------------------------- MAPS tests -------------------------------------------------

class MAPSDgreduceReduction(ISISDirectInelasticReduction):
Expand Down
8 changes: 5 additions & 3 deletions SystemTests/AnalysisTests/ISISDirectReductionComponents.py
Expand Up @@ -50,10 +50,14 @@ def runTest(self):

def get_result_workspace(self):
"""Returns the result workspace to be checked"""
if 'outWS' in mtd:
return 'outWS'
saveFileName = self.rd.reducer.save_file_name
outWS = Load(Filename=saveFileName+'.nxs')
outWS *= 0.997979227566217
return "outWS"
fullRezPath =FileFinder.getFullPath(saveFileName+'.nxs')
os.remove(fullRezPath)
return 'outWS'
def get_reference_file(self):
return "MARIReduction.nxs"

Expand Down Expand Up @@ -120,8 +124,6 @@ def runTest(self):

self.assertEqual(ws.getNumberHistograms(),919)
self.assertEqual(mon_ws.getNumberHistograms(),3)
wsName = ws.name()
self.assertEqual(wsName,PropertyManager.sample_run.get_ws_name())

#
propman = PropertyManager('MAPS')
Expand Down
8 changes: 5 additions & 3 deletions SystemTests/AnalysisTests/ISIS_LETReduction.py
Expand Up @@ -402,8 +402,8 @@ def __init__(self,rv=None):
config['defaultsave.directory'] = data_dir # folder to save resulting spe/nxspe files. Defaults are in

# execute stuff from Mantid
rd =ReduceLET_MultiRep2015()
#rd =ReduceLET_MultiRep2014()
#rd =ReduceLET_MultiRep2015()
rd =ReduceLET_MultiRep2014()
#rd = ReduceLET_OneRep()
rd.def_advanced_properties()
rd.def_main_properties()
Expand All @@ -415,4 +415,6 @@ def __init__(self,rv=None):
# file = os.path.join(run_dir,'reduce_vars.py')
# rd.export_changed_values(file)

rd.reduce()
###### Run reduction over all files provided as parameters ######
red_ws = rd.run_reduction()

38 changes: 21 additions & 17 deletions SystemTests/AnalysisTests/ISIS_MariReduction.py
Expand Up @@ -19,6 +19,8 @@ def def_main_properties(self):
prop['incident_energy'] = 12
prop['energy_bins'] = [-11,0.05,11]

#prop['sum_runs'] = False

# Absolute units reduction properties.
prop['monovan_run'] = 11015
prop['sample_mass'] = 10
Expand Down Expand Up @@ -47,10 +49,7 @@ def reduce(self,input_file=None,output_directory=None):
outWS = ReductionWrapper.reduce(self,input_file,output_directory)
#SaveNexus(outWS,Filename = 'MARNewReduction.nxs')
return outWS
#
def validate_result(self,build_vaidatrion=False):
""" overloaded function provides filename for validation"""
return

def validate_result(self,build_validation=False):
""" Change this method to verify different results """
# build_validation -- if true, build and save new workspace rather then validating the old one
Expand All @@ -60,7 +59,9 @@ def validate_result(self,build_validation=False):
def __init__(self,web_var=None):
""" sets properties defaults for the instrument with Name"""
ReductionWrapper.__init__(self,'MAR',web_var)
#----------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------#
#-------------------------------------------------------------------------------------------------#
#-------------------------------------------------------------------------------------------------#
def main(input_file=None,output_directory=None):
""" This method is used to run code from web service
and should not be touched except changing the name of the
Expand Down Expand Up @@ -285,22 +286,25 @@ def __init__(self,web_var=None):
config['defaultsave.directory'] = data_dir # folder to save resulting spe/nxspe files. Defaults are in

# execute stuff from Mantid
rd = ReduceMARIFromFile()
#rd = ReduceMARIFromFile()
#rd= ReduceMARIMon2Norm()
#rd = ReduceMARIMonitorsSeparate()
rd = ReduceMARIMonitorsSeparate()
#rd = ReduceMARIFromWorkspace()
rd.def_advanced_properties()
rd.def_main_properties()

# Save web variables
run_dir = os.path.dirname(os.path.realpath(__file__))
file = os.path.join(run_dir,'reduce_vars.py')
rd.save_web_variables(file)
#### Set up time interval (sec) for reducer to check for input data file. ####
# If this file is not present and this value is 0,reduction fails
# if this value >0 the reduction wait until file appears on the data
# search path checking after time specified below.
rd.wait_for_file = 0 # waiting time interval

#run_dir = os.path.dirname(os.path.realpath(__file__))
#file = os.path.join(run_dir,'reduce_vars.py')
#rd.save_web_variables(file)
###### Run reduction over all run numbers or files assigned to ######
# sample_run variable
red_ws = rd.run_reduction()

if rd.reducer.sum_runs:
red_ws=rd.reduce()
else:
runs = PropertyManager.sample_run.get_run_list()
for run in runs:
red_ws=rd.reduce(run)
#end

0 comments on commit 9bef2e6

Please sign in to comment.