Skip to content

Commit

Permalink
Re #5925 Allow user to enter data file path
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Oct 9, 2012
1 parent 12981a9 commit 37d2dfa
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 15 deletions.
10 changes: 10 additions & 0 deletions Code/Mantid/Framework/WorkflowAlgorithms/src/RefReduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,16 @@ IEventWorkspace_sptr RefReduction::loadData(const std::string dataRun,
catch(Exception::NotFoundError&) { /* Pass. We report the missing file later. */ }
}

if (path.size()==0 || !Poco::File(path).exists())
{
try
{
std::vector<std::string> paths = FileFinder::Instance().findRuns(dataRun);
path = paths[0];
}
catch(Exception::NotFoundError&) { /* Pass. We report the missing file later. */ }
}

if (Poco::File(path).exists()) {
g_log.notice() << "Found: " << path << std::endl;
m_output_message += " |Loading from " + path + "\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def to_script(self, for_automated_reduction=False):
if for_automated_reduction:
return self._automated_reduction()

script = "a = RefReduction(DataRun=%s,\n" % ','.join([str(i) for i in self.data_files])
script += " NormalizationRun=%d,\n" % self.norm_file
script = "a = RefReduction(DataRun='%s',\n" % ','.join([str(i) for i in self.data_files])
script += " NormalizationRun='%s',\n" % str(self.norm_file)
script += " Instrument='REF_M',\n"
script += " PolarizedData=True,\n"

Expand Down Expand Up @@ -104,7 +104,8 @@ def to_script(self, for_automated_reduction=False):

# The output should be slightly different if we are generating
# a script for the automated reduction
script += " OutputWorkspacePrefix='reflectivity_%s')\n" % str(self.data_files[0])
basename = os.path.basename(str(self.data_files[0]))
script += " OutputWorkspacePrefix='reflectivity_%s')\n" % basename
script += "\n"

script += "output_msg = a.getPropertyValue('OutputMessage')\n"
Expand All @@ -113,10 +114,10 @@ def to_script(self, for_automated_reduction=False):
script += "reducer_log.log_text += output_msg\n\n"

# Save the reduced data
script += "ws_list = ['reflectivity_%s-Off_Off',\n" % str(self.data_files[0])
script += " 'reflectivity_%s-On_Off',\n" % str(self.data_files[0])
script += " 'reflectivity_%s-Off_On',\n" % str(self.data_files[0])
script += " 'reflectivity_%s-On_On']\n" % str(self.data_files[0])
script += "ws_list = ['reflectivity_%s-Off_Off',\n" % basename
script += " 'reflectivity_%s-On_Off',\n" % basename
script += " 'reflectivity_%s-Off_On',\n" % basename
script += " 'reflectivity_%s-On_On']\n" % basename

script += "outdir = '%s'\n" % self.output_dir
script += "if not os.path.isdir(outdir):\n"
Expand All @@ -141,8 +142,8 @@ def _automated_reduction(self):
script += "peak_min_norm = estimates.getProperty('PeakMin').value\n"
script += "peak_max_norm = estimates.getProperty('PeakMax').value\n\n"

script += "RefReduction(DataRun=%s,\n" % ','.join([str(i) for i in self.data_files])
script += " NormalizationRun=%d,\n" % self.norm_file
script += "RefReduction(DataRun='%s',\n" % ','.join([str(i) for i in self.data_files])
script += " NormalizationRun='%s',\n" % str(self.norm_file)
script += " Instrument='REF_M',\n"
script += " PolarizedData=True,\n"
script += " SignalPeakPixelRange=[peak_min, peak_max],\n"
Expand All @@ -161,7 +162,8 @@ def _automated_reduction(self):

# The output should be slightly different if we are generating
# a script for the automated reduction
script += " OutputWorkspacePrefix='reflectivity_'+%s)\n" % str(self.data_files[0])
basename = os.path.basename(str(self.data_files[0]))
script += " OutputWorkspacePrefix='reflectivity_'+%s)\n" % basename

return script

Expand Down Expand Up @@ -281,7 +283,7 @@ def from_xml_element(self, instrument_dom):
self.TOFstep = BaseScriptElement.getFloatElement(instrument_dom, "tof_step",
default = DataSets.TOFstep)

self.data_files = BaseScriptElement.getIntList(instrument_dom, "data_sets")
self.data_files = BaseScriptElement.getStringList(instrument_dom, "data_sets")

#with or without norm
self.NormFlag = BaseScriptElement.getBoolElement(instrument_dom, "norm_flag",
Expand All @@ -300,7 +302,7 @@ def from_xml_element(self, instrument_dom):
self.NormBackgroundRoi = [BaseScriptElement.getIntElement(instrument_dom, "norm_from_back_pixels"),
BaseScriptElement.getIntElement(instrument_dom, "norm_to_back_pixels")]

self.norm_file = BaseScriptElement.getIntElement(instrument_dom, "norm_dataset")
self.norm_file = BaseScriptElement.getStringElement(instrument_dom, "norm_dataset")

# Q cut
self.q_min = BaseScriptElement.getFloatElement(instrument_dom, "q_min", default=DataSets.q_min)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,15 @@ def _integrated_plot(self, is_high_res, file_ctrl, min_ctrl, max_ctrl):
if not IS_IN_MANTIDPLOT:
return

f = FileFinder.findRuns("%s%s" % (self.instrument_name, str(file_ctrl.text())))
f = []
try:
f = FileFinder.findRuns("%s%s" % (self.instrument_name, str(file_ctrl.text())))
except:
try:
f = FileFinder.findRuns(str(file_ctrl.text()))
except:
print "Could not find file for %s" % str(file_ctrl.text())
return

range_min = int(min_ctrl.text())
range_max = int(max_ctrl.text())
Expand Down Expand Up @@ -860,7 +868,7 @@ def get_editing_state(self):
m.TOFstep = float(self._summary.tof_bin_width_edit.text())

datafiles = str(self._summary.data_run_number_edit.text()).split(',')
m.data_files = [int(i) for i in datafiles]
m.data_files = [str(i) for i in datafiles]

# Normalization flag
m.NormFlag = self._summary.norm_switch.isChecked()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _load_entry(entry, ws, title=""):

if mtd[ws].getNumberEvents()==0:
#mtd.deleteWorkspace(ws)
print 'You are trying to load an empty event nexus file!!!!'
print 'No data in entry %s' % entry
return

instr_dir = mtd.getSettings().getInstrumentDirectory()
Expand Down

0 comments on commit 37d2dfa

Please sign in to comment.