Skip to content

Commit

Permalink
refs #8614 spectra_list property for reduction
Browse files Browse the repository at this point in the history
and unit test for this property.

Added new property which contains list of the monitors to copy to detectors in event mode. Testes assignment for this property
  • Loading branch information
abuts committed Feb 12, 2014
1 parent 29c44a7 commit ee898da
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Code/Mantid/instrument/LET_Parameters.xml
Expand Up @@ -69,8 +69,8 @@
<value val="5506"/>
</parameter>

<!--if you use some detectors as monitors and work in event mode, one needs to specify the list of these detectors here
to copy detectors spectra to monitors spectra collected in histohram mode. If no such monitors is used "None"
<!--if you use some detectors as monitors and work in event mode, one needs to specify the comma separated list of these detectors here
to copy detectors spectra to monitors spectra collected in histogram mode. If no such monitors are used "None"
(with brackets) has to be specified as the value
-->
<parameter name="copy_spectra_to_monitors" type="string">
Expand Down
6 changes: 4 additions & 2 deletions Code/Mantid/instrument/MERLIN_Parameters.xml
Expand Up @@ -79,8 +79,10 @@
<parameter name="ei_mon_spectra" type="string">
<value val="ei-mon1-spec:ei-mon2-spec"/>
</parameter>
<!--if you use some detectors as monitors and work in event mode, one needs to specify the list of these detectors here
to copy detectors spectra to monitors spectra collected in histohram mode.

<!--if you use some detectors as monitors and work in event mode, one needs to specify the comma separated list of these detectors here
to copy detectors spectra to monitors spectra collected in histogram mode. If no such monitors are used "None"
(with brackets) has to be specified as the value
-->
<parameter name="copy_spectra_to_monitors" type="string">
<value val="None"/>
Expand Down
31 changes: 31 additions & 0 deletions Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py
Expand Up @@ -821,6 +821,37 @@ def __init__(self, instr_name=None):
# Complex setters/getters
#----------------------------------------------------------------------------------
@property
def copy_spectra_to_monitors(self):
return self._copy_spectra_to_monitors;
@copy_spectra_to_monitors.setter
def copy_spectra_to_monitors(self,spectra_list):
""" Sets copy spectra to monitors variable as a list of monitors using different forms of input
"""
if spectra_list is None:
self._copy_spectra_to_monitors=None;
return;

if isinstance(spectra_list,str):
if spectra_list is 'None':
self._copy_spectra_to_monitors=None;
else:
spectra = spectra_list.split(',');
self._copy_spectra_to_monitors = [];
for spectum in spectra :
self._copy_spectra_to_monitors.append(int(spectum));
else:
if isinstance(spectra_list,list):
if len(spectra_list) == 0:
self._copy_spectra_to_monitors=None;
else:
self._copy_spectra_to_monitors=[];
for i in range(0,len(spectra_list)):
self._copy_spectra_to_monitors.append(int(spectra_list[i]));
else:
self._copy_spectra_to_monitors =[int(spectra_list)];
return;
@property
def instr_name(self):
return self._instr_name
@instr_name.setter
Expand Down
27 changes: 27 additions & 0 deletions Code/Mantid/scripts/test/DirectEnergyConversionTest.py
Expand Up @@ -308,6 +308,33 @@ def f_nxs(workspace, filename):
tReducer.save_results(pws,'ofn')
self.assertEquals(file_long_name,tReducer.test_name)

def test_set_spectra_to_mon(self):
tReducer = self.reducer;

tReducer.copy_spectra_to_monitors = 35;
self.assertTrue(isinstance(tReducer.copy_spectra_to_monitors,list));
self.assertEquals(35,tReducer.copy_spectra_to_monitors[0]);

tReducer.copy_spectra_to_monitors = None;
self.assertTrue(tReducer.copy_spectra_to_monitors is None);
tReducer.copy_spectra_to_monitors = 'None';
self.assertTrue(tReducer.copy_spectra_to_monitors is None);
tReducer.copy_spectra_to_monitors = [];
self.assertTrue(tReducer.copy_spectra_to_monitors is None);

tReducer.copy_spectra_to_monitors = '467';
self.assertEquals(467,tReducer.copy_spectra_to_monitors[0]);

tReducer.copy_spectra_to_monitors = '467,444';
self.assertEquals(467,tReducer.copy_spectra_to_monitors[0]);
self.assertEquals(444,tReducer.copy_spectra_to_monitors[1]);

tReducer.copy_spectra_to_monitors = ['467','444'];
self.assertEquals(467,tReducer.copy_spectra_to_monitors[0]);
self.assertEquals(444,tReducer.copy_spectra_to_monitors[1]);




def test_process_copy_spectra_to_monitors(self):
pass
Expand Down

0 comments on commit ee898da

Please sign in to comment.