Skip to content

Commit

Permalink
Refs #4593 - Aclimax save format option added to CTE for TOSCA.
Browse files Browse the repository at this point in the history
Checkbox added and reduction step inserted.  Also, change made to code included in the commit for #4621.
  • Loading branch information
PeterParker committed Jan 24, 2012
1 parent c7d848b commit 60c72a9
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/DataHandling/test/LoadRaw3Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class LoadRaw3Test : public CxxTest::TestSuite
TS_ASSERT_EQUALS( ptrDet->getID(), 60);

Mantid::Geometry::ParameterMap& pmap = output2D->instrumentParameters();
TS_ASSERT_EQUALS( static_cast<int>(pmap.size()), 154);
TS_ASSERT_EQUALS( static_cast<int>(pmap.size()), 155);
AnalysisDataService::Instance().remove("parameterIDF");
}

Expand Down
18 changes: 10 additions & 8 deletions Code/Mantid/MantidQt/CustomInterfaces/src/Indirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,18 @@ void Indirect::runConvertToEnergy()
pyInput += "reducer.set_fold_multiple_frames(False)\n";
}

if( m_uiForm.ckCm1Units->isChecked() )
{
pyInput +=
"reducer.set_save_to_cm_1(True)\n";
}

pyInput += "reducer.set_save_formats([" + savePyCode() + "])\n";

pyInput +=
"reducer.reduce()\n"
"ws_list = reducer.get_result_workspaces()\n";

if( m_uiForm.ckCm1Units->isChecked() )
{
pyInput +=
"for ws in ws_list:"
" ConvertUnits(InputWorkspace=ws,OutputWorkspace=ws,EMode='Indirect',Target='DeltaE_inWavenumber')";
}

// Plot Output options
switch ( m_uiForm.ind_cbPlotOutput->currentIndex() )
{
Expand Down Expand Up @@ -360,7 +359,8 @@ void Indirect::setIDFValues(const QString & prefix)
*/
void Indirect::performInstSpecific()
{
setInstSpecificWidget("cm-1-convert_choice", m_uiForm.ckCm1Units, QCheckBox::Off);
setInstSpecificWidget("cm-1-convert-choice", m_uiForm.ckCm1Units, QCheckBox::Off);
setInstSpecificWidget("save-aclimax-choice", m_uiForm.save_ckAclimax, QCheckBox::Off);
}

/**
Expand Down Expand Up @@ -491,6 +491,8 @@ QString Indirect::savePyCode()
fileFormats << "nxspe";
if ( m_uiForm.save_ckAscii->isChecked() )
fileFormats << "ascii";
if ( m_uiForm.save_ckAclimax->isChecked() )
fileFormats << "aclimax";

if ( fileFormats.size() != 0 )
fileFormatList = "'" + fileFormats.join("', '") + "'";
Expand Down
7 changes: 5 additions & 2 deletions Code/Mantid/instrument/TOSCA_Parameters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
<value val="002" />
</parameter>
<!-- Available options are "Show" or "Hide". -->
<parameter name="cm-1-convert_choice" type="string">
<parameter name="cm-1-convert-choice" type="string">
<value val="Show" />
</parameter>
<parameter name="save-aclimax-choice" type="string">
<value val="Show" />
</parameter>

Expand Down Expand Up @@ -57,7 +60,7 @@
<parameter name="Workflow.Summary" type="string">
<value val="Average" />
</parameter>

</component-link>

</parameter-file>
9 changes: 9 additions & 0 deletions Code/Mantid/scripts/Inelastic/inelastic_indirect_reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class IndirectReducer(MSGReducer):
_background_end = None
_detailed_balance_temp = None
_rename_result = True
_save_to_cm_1 = False

def __init__(self):
"""
Expand Down Expand Up @@ -98,10 +99,15 @@ def _setup_steps(self):
step = steps.Summary(MultipleFrames=self._multiple_frames)
self.append_step(step)

step = steps.ConvertToCm1(MultipleFrames=self._multiple_frames)
step.set_save_to_cm_1(self._save_to_cm_1)
self.append_step(step)

# The "SaveItem" step saves the files in the requested formats.
if (len(self._save_formats) > 0):
step = steps.SaveItem()
step.set_formats(self._save_formats)
step.set_save_to_cm_1(self._save_to_cm_1)
self.append_step(step)

if self._rename_result:
Expand All @@ -111,6 +117,9 @@ def _setup_steps(self):
def set_grouping_policy(self, policy):
self._grouping_policy = policy

def set_save_to_cm_1(self, save_to_cm_1):
self._save_to_cm_1 = save_to_cm_1

def set_calibration_workspace(self, workspace):
if mtd[workspace] is None:
raise ValueError("Selected calibration workspace not found.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,42 @@ def execute(self, reducer, file_ws):
# Note: Detector info of the output becomes spurious as there will be a third entry for a detector
# that does not exist.
ConjoinWorkspaces(wsName, tempName, False)


class ConvertToCm1(ReductionStep):
"""
Converts the workspaces to cm-1.
"""

_multiple_frames = False
_save_to_cm_1 = False

def __init__(self, MultipleFrames=False):
super(ConvertToCm1, self).__init__()
self._multiple_frames = MultipleFrames

def execute(self, reducer, file_ws):

if self._save_to_cm_1 == False:
return

if ( self._multiple_frames ):
try:
workspaceNames = mtd[file_ws].getNames()
except AttributeError:
workspaceNames = [file_ws]
else:
workspaceNames = [file_ws]

for wsName in workspaceNames:
try:
ws = mtd[wsName]
except:
continue
ConvertUnits(InputWorkspace=ws,OutputWorkspace=ws,EMode='Indirect',Target='DeltaE_inWavenumber')

def set_save_to_cm_1(self, save_to_cm_1):
self._save_to_cm_1 = save_to_cm_1

class ConvertToEnergy(ReductionStep):
"""
"""
Expand Down Expand Up @@ -841,6 +875,7 @@ class SaveItem(ReductionStep):
Flight if not already in that unit for saving in this format).
"""
_formats = []
_save_to_cm_1 = False

def __init__(self):
super(SaveItem, self).__init__()
Expand All @@ -862,9 +897,19 @@ def execute(self, reducer, file_ws):
ConvertUnits(file_ws, "__save_item_temp", "TOF")
SaveGSS("__save_item_temp", filename+".gss")
DeleteWorkspace("__save_item_temp")

elif format == 'aclimax':
if (self._save_to_cm_1 == False):
bins = '-2.5, 0.01, 3, -0.005, 500' #meV
else:
bins = '24, -0.005, 4000' #cm-1
Rebin(file_ws, file_ws + '_aclimax_save_temp', bins)
SaveAscii(file_ws + '_aclimax_save_temp', filename+ '_aclimax.dat', Separator='Tab')
DeleteWorkspace(file_ws + '_aclimax_save_temp')

def set_formats(self, formats):
self._formats = formats
def set_save_to_cm_1(self, save_to_cm_1):
self._save_to_cm_1 = save_to_cm_1

class Naming(ReductionStep):
"""Takes the responsibility of naming the results away from the Grouping
Expand Down

0 comments on commit 60c72a9

Please sign in to comment.