Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
ba7a24a2
Commit
ba7a24a2
authored
Nov 14, 2012
by
Marie Yao
Browse files
Refs #5439. Load NeXus logs for HYSPEC (HYSPECA) and SNAP.
parent
bbf1c5c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/AppendGeometryToSNSNexus.h
View file @
ba7a24a2
...
...
@@ -64,6 +64,10 @@ namespace DataHandling
bool
runLoadInstrument
(
const
std
::
string
&
idf_filename
,
API
::
MatrixWorkspace_sptr
localWorkspace
,
Algorithm
*
alg
);
/// Load logs from the NeXus file
static
bool
runLoadNexusLogs
(
const
std
::
string
&
nexusFileName
,
API
::
MatrixWorkspace_sptr
localWorkspaceName
,
Algorithm
*
alg
);
/// Are we going to make a copy of the NeXus file to operate on ?
bool
m_makeNexusCopy
;
...
...
Code/Mantid/Framework/DataHandling/src/AppendGeometryToSNSNexus.cpp
View file @
ba7a24a2
...
...
@@ -164,16 +164,23 @@ namespace DataHandling
// Modified to call LoadInstrument directly as a sub-algorithm
ws
=
WorkspaceFactory
::
Instance
().
create
(
"Workspace2D"
,
1
,
2
,
1
);
// Load NeXus logs for HYSPEC, HYSPECA(testing), and SNAP
if
(
m_instrument
==
"HYSPEC"
||
m_instrument
==
"HYSPECA"
||
m_instrument
==
"SNAP"
)
{
g_log
.
debug
()
<<
"Run LoadNexusLogs sub-algorithm."
<<
std
::
endl
;
logs_loaded_correctly
=
runLoadNexusLogs
(
m_filename
,
ws
,
this
);
if
(
!
logs_loaded_correctly
)
throw
std
::
runtime_error
(
"Failed to run LoadNexusLogs sub-algorithm."
);
}
g_log
.
debug
()
<<
"Run LoadInstrument sub-algorithm."
<<
std
::
endl
;
instrument_loaded_correctly
=
runLoadInstrument
(
m_idf_filename
,
ws
,
this
);
if
(
!
this
->
instrument_loaded_correctly
)
if
(
!
instrument_loaded_correctly
)
throw
std
::
runtime_error
(
"Failed to run LoadInstrument sub-algorithm."
);
// Load NeXus logs as needed
//logs_loaded_correctly
// Get the number of detectors (just for progress reporting)
// Get the number of histograms/detectors
const
size_t
numDetectors
=
ws
->
getInstrument
()
->
getDetectorIDs
().
size
();
...
...
@@ -384,7 +391,7 @@ namespace DataHandling
*/
bool
AppendGeometryToSNSNexus
::
runLoadInstrument
(
const
std
::
string
&
idf_filename
,
API
::
MatrixWorkspace_sptr
localWorkspace
,
Algorithm
*
alg
)
API
::
MatrixWorkspace_sptr
localWorkspace
,
Algorithm
*
alg
)
{
IAlgorithm_sptr
loadInst
=
createSubAlgorithm
(
"LoadInstrument"
,
0
,
1
,
true
);
...
...
@@ -416,5 +423,39 @@ namespace DataHandling
return
executionSuccessful
;
}
//-----------------------------------------------------------------------------
/** Load the logs from the input NeXus file.
*
* @param nexusFileName :: Name of the NeXus file to load logs from.
* @param localWorkspace :: MatrixWorkspace in which to put the logs.
* @param alg :: Handle of an algorithm for logging access.
* @return true if successful.
*/
bool
AppendGeometryToSNSNexus
::
runLoadNexusLogs
(
const
std
::
string
&
nexusFileName
,
API
::
MatrixWorkspace_sptr
localWorkspace
,
Algorithm
*
alg
)
{
IAlgorithm_sptr
loadLogs
=
alg
->
createSubAlgorithm
(
"LoadNexusLogs"
,
0
,
1
,
true
);
// Execute the sub-algorithm, catching errors without stopping.
bool
executionSuccessful
(
true
);
try
{
alg
->
getLogger
().
information
()
<<
"Loading logs from the NeXus file..."
<<
std
::
endl
;
loadLogs
->
setPropertyValue
(
"Filename"
,
nexusFileName
);
loadLogs
->
setProperty
<
MatrixWorkspace_sptr
>
(
"Workspace"
,
localWorkspace
);
loadLogs
->
executeAsSubAlg
();
}
catch
(
std
::
invalid_argument
&
e
)
{
alg
->
getLogger
().
information
(
"Invalid argument to LoadNexusLogs sub-algorithm"
);
alg
->
getLogger
().
information
(
e
.
what
());
executionSuccessful
=
false
;
}
catch
(
std
::
runtime_error
&
)
{
alg
->
getLogger
().
information
(
"Unable to successfully run runLoadNexusLogs sub-algorithm./n"
);
executionSuccessful
=
false
;
}
return
executionSuccessful
;
}
}
// namespace Mantid
}
// namespace DataHandling
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment