Skip to content

Commit

Permalink
refs #6667 Maps system tests run but do not pass
Browse files Browse the repository at this point in the history
Both old and new tests failing, which is probably due to different defaults
  • Loading branch information
abuts committed Jun 17, 2013
1 parent b7f7f08 commit c0e66a5
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 73 deletions.
61 changes: 39 additions & 22 deletions Code/Mantid/instrument/MAPS_Parameters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parameter name="det_cal_file" type="string">
<value val="None"/>
</parameter>
<!-- The file which defines detectors to spectra mapping;
<!-- The file which defines detectors to spectra mapping; File extension has to be specified here but filepath not
if None - one2one map is used -->
<parameter name="map_file" type="string">
<value val="4to1.map"/>
Expand Down Expand Up @@ -86,16 +86,6 @@
<value val="1000"/>
</parameter>

<!-- integration range for background tests (in TOF) - composite property -->
<parameter name="bkgd-range-min">
<value val="15000"/>
</parameter>
<parameter name="bkgd-range-max">
<value val="19000"/>
</parameter>
<parameter name="background_range" type="string">
<value val="bkgd-range-min:bkgd-range-max"/>
</parameter>
<!-- Remove the count rate seen in the regions of the histograms defined as the background regions -->
<parameter name="background" type="bool">
<value val="False"/>
Expand All @@ -119,8 +109,6 @@
</parameter>




<parameter name="monovan-integr-min">
<value val="-1"/>
</parameter>
Expand All @@ -131,12 +119,22 @@
<value val="monovan-integr-min:monovan-integr-max"/>
</parameter>



<parameter name="vanadium-mass">
<value val="30.1"/>
</parameter>


<!-- integration range for background tests (in TOF) - composite property -->
<parameter name="bkgd-range-min">
<value val="15000"/>
</parameter>
<parameter name="bkgd-range-max">
<value val="19000"/>
</parameter>
<parameter name="background_range" type="string">
<value val="bkgd-range-min:bkgd-range-max"/>
</parameter>

<!-- ******************************** DIAGNOSTICS DEFAILTS **************************************** -->

<!-- Perform diag by bank. These are the spectrum numbers -->
Expand Down Expand Up @@ -207,7 +205,8 @@
<parameter name="diag_variation">
<value val="1.1"/>
</parameter>

<parameter name="diag_background_range">
</parameter>
<!-- **************************************** DIAGNOSTICS DEFAILTS END **************************************** -->
<!-- -->

Expand All @@ -220,30 +219,48 @@
<value val="100"/>
</parameter>

<!-- This property is the part of the composite definition for abs_units_van_range
It specifies the relative to incident energy lower integration limit for monochromatic vanadium in the mono-vanadium integration -->
<parameter name="monovan_lo_frac">
<value val="0.8"/>
</parameter>

<!-- This property is the part of the composite definition for abs_units_van_range
It specifies the the lower limit of energy range in the monochromatic-vanadium integration
Used only if abs_units_van_range is set to val="monovan_lo_value,monovan_hi_value"-->
<parameter name="monovan_lo_value">
<value val="-40."/>
</parameter>


<!-- This property is the part of the composite definition for abs_units_van_range
It specifies the relative to incident energy higher integration limit for monochromatic vanadium in the mono-vanadium integration -->
<parameter name="monovan_hi_frac">
<value val="1.2"/>
</parameter>
<!-- This property is the part of the composite definition for abs_units_van_range
It specifies the the higher limit of energy range in the monochromatic-vanadium integration
Used only if abs_units_van_range is set to val="monovan_lo_value,monovan_hi_value"-->
<parameter name="monovan_hi_value">
<value val="40."/>
</parameter>

<!-- energy range for integration calculating absolute units correction vanadium data
<!-- energy range for integration calculating absolute units correction vanadium data.
if None, range is calculated from monovan_hi_frac/monovan_lo_frac
- providing the fractions of the incident energy
if one wants to specify the energy values here it has to be defined in the form:
<value val="monovan_lo_value,monovan_hi_value"/>
-->
<value val="monovan_lo_value,monovan_hi_value"/> -->
<parameter name="abs_units_van_range" type="string">
<value val="None"/>
</parameter>
<!-- Sample mass should usually be changed by user-->
<parameter name="sample_mass">
<value val="1"/>
</parameter>
<!-- Sample rmm should usually be changed by user -->
<parameter name="sample_rmm">
<value val="1"/>
</parameter>


<!-- -->
<!-- Bleeding corrections -->
Expand Down Expand Up @@ -300,13 +317,13 @@
sum_runs=sum;
wb_integr_range=detector_van_range;
van_mass=vanadium-mass;
background_range=bkgd_range;
mon1_norm_spec=norm-mon1-spec;
scale_factor=scale-factor;
wb_scale_factor=wb-scale-factor;
monovan_integr_range=abs_units_van_range;
hard_mask_file=hardmaskPlus;
use_hard_mask_only=hardmaskOnly;
background_range = bkgd_range;
van_out_lo = diag_van_median_rate_limit_lo=diag_van_out_lo;
van_out_hi = diag_van_median_rate_limit_hi=diag_van_out_hi;
van_lo = diag_van_median_sigma_lo=diag_van_lo;
Expand All @@ -319,7 +336,7 @@
samp_hi = diag_samp_median_sigma_hi=diag_samp_hi;
samp_sig = diag_samp_median_sigma=diag_samp_sig;
variation = diag_variation;
bleed_test=bleed=diag_bleed_test;
bleed_test = bleed = diag_bleed_test;
ei-mon2-spec = test_ei2_mon_spectra;
ei_mon_spectra=test_mon_spectra_composite"
/>
Expand Down
48 changes: 32 additions & 16 deletions Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def diagnose(self, white, **kwargs):
var_name = "diag_mask"

# Check for any keywords that have not been supplied and put in the defaults
for par in self.diag_params:
for par in self.__diag_params:
arg = par.lstrip('diag_')
if arg not in kwargs:
kwargs[arg] = getattr(self, arg)
Expand Down Expand Up @@ -230,7 +230,7 @@ def mono_van(self, mono_van, ei_guess, white_run=None, map_file=None,
monovan = self._do_mono(sample_data, sample_data, result_name, ei_guess,
white_run, map_file, spectra_masks, Tzero)
# Normalize by vanadium sample weight
monovan /= float(self.van_mass)/float(self.van_rmm)
monovan /= float(self.van_mass)/float(self.__van_rmm)
return monovan

def mono_sample(self, mono_run, ei_guess, white_run=None, map_file=None,
Expand Down Expand Up @@ -593,13 +593,13 @@ def calc_average(self, data_ws,energy_incident):
data_ws=ConvertToMatrixWorkspace(InputWorkspace=data_ws,OutputWorkspace= data_ws)

args = {}
args['tiny'] = self.diag_tiny
args['huge'] = self.diag_huge
args['tiny'] = self.tiny
args['huge'] = self.huge
args['van_out_lo'] = self.monovan_lo_bound
args['van_out_hi'] = self.monovan_hi_bound
args['van_lo'] = self.monovan_lo_frac
args['van_hi'] = self.monovan_hi_frac
args['van_sig'] = self.diag_samp_sig
args['van_sig'] = self.samp_sig

diagnostics.diagnose(data_ws, **args)
monovan_masks,det_ids = ExtractMask(InputWorkspace=data_ws,OutputWorkspace='monovan_masks')
Expand Down Expand Up @@ -663,11 +663,16 @@ def save_results(self, workspace, save_path, formats = None):
pass

if formats is None:
formats = self.save_formats
formats = self.__save_formats
if type(formats) == str:
formats = [formats]
#Make sure we just have a file stem
ext = self.save_format

# if ext is none, no need to write anything
if ext == None :
return

if len(ext) == 0:
ext = '.spe'

Expand Down Expand Up @@ -757,7 +762,13 @@ def init_idf_params(self, reload_instrument=False):
specify some parameters which may be not in IDF Parameters file
"""
self.save_formats = ['.spe','.nxs','.nxspe']
# fomats availible for saving. As the reducer has to have a method to process one of this, it is private property
self.__save_formats = ['.spe','.nxs','.nxspe']
# Diag parameters -- keys used by diag method to pick from default parameters. Diag cuts these keys removing diag_ word
self.__diag_params = ['diag_tiny', 'diag_huge', 'diag_samp_zero', 'diag_samp_lo', 'diag_samp_hi','diag_samp_sig',\
'diag_van_out_lo', 'diag_van_out_hi', 'diag_van_lo', 'diag_van_hi', 'diag_van_sig', 'diag_variation',\
'diag_bleed_test']

self.fix_ei=False
self.energy_bins = None
self.background = False
Expand Down Expand Up @@ -788,8 +799,6 @@ def init_idf_params(self, reload_instrument=False):
# Absolute normalisation
self.abs_map_file = None
self.abs_spectra_masks = None
self.sample_mass = 1.0
self.sample_rmm = 1.0

# All this stuff should go to IDF file
# Detector Efficiency Correction
Expand All @@ -804,11 +813,8 @@ def init_idf_params(self, reload_instrument=False):
self.relocate_dets = False

#The rmm of Vanadium is a constant, should not be instrument parameter. Atom not exposed to python :(
self.van_rmm = 50.9415
self.__van_rmm = 50.9415

# Diag parameters -- keys used by diag method to pick from default parameters
self.diag_params = ['diag_tiny', 'diag_huge', 'diag_samp_zero', 'diag_samp_lo', 'diag_samp_hi','diag_samp_sig',\
'diag_van_out_lo', 'diag_van_out_hi', 'diag_van_lo', 'diag_van_hi', 'diag_van_sig', 'diag_variation']

# special property -- synonims -- how to treat external parameters.
try:
Expand Down Expand Up @@ -1065,17 +1071,20 @@ def help(self,keyword=None) :
print "****: IDF value for keyword: ",keyword," is: ",self.get_default_parameter(keyword)
if keyword in self.synonims :
fieldName = self.synonims[keyword]
print "****: This keyword is reamed by reducer to: ",fieldName," and its value is: ",self.fieldName
print "****: This keyword is known to reducer as: ",fieldName," and its value is: ",self.fieldName
else:
print "****: Its current value in reducer is: ",getattr(self,keyword)

print "****: help for "+keyword+" is not yet implemented, read "+self.instr_name+"_Parameters.xml\n"\
"****: in folder "+config.getString('instrumentDefinition.directory')+" for help containing on this key there"
"****: in folder "+config.getString('instrumentDefinition.directory')+" for its description there"
print "****: ***************************************************************************** ";
else:
raise ValueError('Instrument parameter file does not contain a definition for "%s". Cannot continue' % keyword)

#-----------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------------
class DirectEnergyConversionTest(unittest.TestCase):
def __init__(self, methodName):
self.reducer = None
Expand Down Expand Up @@ -1205,6 +1214,13 @@ def test_set_mono_range(self):
if tReducer.monovan_integr_range is None :
tReducer.monovan_integr_range = [tReducer.monovan_lo_frac*energy_incident,tReducer.monovan_hi_frac*energy_incident]

#def test_diag_call(self):
# tReducer = self.reducer
# # should do nothing as already initialized above, but if not will initiate the instrument
# tReducer.initialise("MAP")

# tReducet.di


#-----------------------------------------------------------------
if __name__=="__main__":
Expand Down

0 comments on commit c0e66a5

Please sign in to comment.