Skip to content

Commit

Permalink
refs #6667 Intermediate checkout
Browse files Browse the repository at this point in the history
Old system test for MAPS runs with modified DirectEnergyConversion
  • Loading branch information
abuts committed Jun 14, 2013
1 parent 3af63f7 commit 4fe78d1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
12 changes: 8 additions & 4 deletions Code/Mantid/instrument/MAPS_Parameters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<!-- The file which defines detectors to spectra mapping;
if None - one2one map is used -->
<parameter name="map_file" type="string">
<value val="4to1_124.map"/>
<value val="4to1.map"/>
</parameter>

<!-- Extension of the data files obtained from DAE -->
Expand Down Expand Up @@ -45,18 +45,19 @@
<value val="direct"/>
</parameter>

<!-- Monitor used to estimate total current on the sample -->
<!-- Monitor used to estimate total current on the sample. -->
<parameter name="norm-mon1-spec">
<value val="41473"/>
</parameter>
<!-- Time interval used for integration to estimate current on the sample -->
<!-- Time interval used for integration to estimate current on the sample
This interval is usually taken around the monitor peak-->
<parameter name="norm-mon1-min">
<value val="1000"/>
</parameter>
<parameter name="norm-mon1-max">
<value val="2000"/>
</parameter>
<parameter name="mon_norm_range" type="string">
<parameter name="norm_mon_integration_range" type="string">
<value val="norm-mon1-min:norm-mon1-max"/>
</parameter>

Expand Down Expand Up @@ -300,6 +301,9 @@
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;
Expand Down
35 changes: 23 additions & 12 deletions Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def diagnose(self, white, **kwargs):
IncludePartialBins=True)
total_counts = Integration(result_ws, IncludePartialBins=True)
background_int = ConvertUnits(background_int, "Energy", AlignBins=0)
background_int *= 1.7016e8
background_int *= self.scale_factor
diagnostics.normalise_background(background_int, whiteintegrals, kwargs.get('second_white',None))
kwargs['background_int'] = background_int
kwargs['sample_counts'] = total_counts
Expand Down Expand Up @@ -549,8 +549,8 @@ def normalise(self, data_ws, result_name, method, range_offset=0.0,mon_number=No
CloneWorkspace(InputWorkspace=data_ws, OutputWorkspace=result_name)
output = mtd[result_name]
elif method == 'monitor-1':
range_min = self.mon1_norm_range[0] + range_offset
range_max = self.mon1_norm_range[1] + range_offset
range_min = self.norm_mon_integration_range[0] + range_offset
range_max = self.norm_mon_integration_range[1] + range_offset
if mon_number is None:
mon_spectr_num=int(self.mon1_norm_spec)
else:
Expand Down Expand Up @@ -580,9 +580,10 @@ def calc_average(self, data_ws,energy_incident):
where only those detectors that are unmasked are used and the weight[i] = 1/errorValue[i].
"""

if self.monovan_integr_range is None :
self.monovan_integr_range[0] = energy_incident*self.monovan_lo_frac;
self.monovan_integr_range[1] = energy_incident*self.monovan_hi_frac;
self.monovan_integr_range = [self.monovan_lo_frac*energy_incident,self.monovan_hi_frac*energy_incident];


e_low = self.monovan_integr_range[0]
e_upp = self.monovan_integr_range[1]
Expand Down Expand Up @@ -635,10 +636,11 @@ def monovan_abs(self, ei_workspace):
ei_prop = run['Ei']
except KeyError:
raise RuntimeError('The given workspace "%s" does not contain an Ei value. Run GetEi first.' % str(ei_workspace))

ei_value = ei_prop.value
absnorm_factor = self.calc_average(ei_workspace,ei_value)

absnorm_factor = self.calc_average(ei_workspace,ei_prop)

ei_value = ei_prop.value

if ei_value >= 200.0:
xsection = 421.0
else:
Expand Down Expand Up @@ -1160,21 +1162,21 @@ def test_set_non_default_comples_value(self):
# should do nothing as already initialized above, but if not will initiate the instrument
tReducer.initialise("MAP");

self.assertEqual(tReducer.mon_norm_range,[1000.,2000.]," Default integration range on MAPS should be as described in MAPS_Parameters.xml file")
self.assertEqual(tReducer.norm_mon_integration_range,[1000.,2000.]," Default integration range on MAPS should be as described in MAPS_Parameters.xml file")
self.assertEqual(tReducer.ei_mon_spectra,[41474,41475]," Default ei monitors on MAPS should be as described in MAPS_Parameters.xml file")

self.assertRaises(KeyError,tReducer.set_input_parameters,mon_norm_range=1)
self.assertRaises(KeyError,tReducer.set_input_parameters,mon_norm_range=[10,100,100])

kw=dict();
kw["mon_norm_range"]=[50,1050]
kw["norm_mon_integration_range"]=[50,1050]
kw["ei-mon1-spec"]=10
prop_changed=tReducer.set_input_parameters(**kw)

self.assertAlmostEqual(tReducer.mon_norm_range,[50,1050],7)
self.assertAlmostEqual(tReducer.norm_mon_integration_range,[50,1050],7)
self.assertEqual(tReducer.ei_mon_spectra,[10,41475])

self.assertTrue("mon_norm_range" in prop_changed,"mon_norm_range should change")
self.assertTrue("norm_mon_integration_range" in prop_changed,"mon_norm_range should change")
self.assertTrue("ei_mon_spectra" in prop_changed,"changing ei-mon1-spec should change ei_mon_spectra")

def test_set_non_default_comples_value_synonims(self):
Expand All @@ -1194,6 +1196,15 @@ def test_set_non_default_comples_value_synonims(self):
self.assertEqual(tReducer.ei_mon_spectra,[10000,2000])
self.assertTrue("ei_mon_spectra" in prop_changed,"changing test_mon_spectra_composite should change ei_mon_spectra")

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

energy_incident = 100
if tReducer.monovan_integr_range is None :
tReducer.monovan_integr_range = [tReducer.monovan_lo_frac*energy_incident,tReducer.monovan_hi_frac*energy_incident]


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

0 comments on commit 4fe78d1

Please sign in to comment.