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
d47c3861
Commit
d47c3861
authored
Jun 18, 2021
by
Peterson, Peter
Committed by
Walsh, Michael
Jun 29, 2021
Browse files
Checkpointing slightly modified code from classmaker
parent
b1b0dc98
Changes
4
Hide whitespace changes
Inline
Side-by-side
Framework/Algorithms/CMakeLists.txt
View file @
d47c3861
...
...
@@ -46,6 +46,7 @@ set(SRC_FILES
src/ClearInstrumentParameters.cpp
src/ClearMaskFlag.cpp
src/CloneWorkspace.cpp
src/CombineDiffCal.cpp
src/Comment.cpp
src/CommutativeBinaryOperation.cpp
src/CompareWorkspaces.cpp
...
...
@@ -382,6 +383,7 @@ set(INC_FILES
inc/MantidAlgorithms/ClearInstrumentParameters.h
inc/MantidAlgorithms/ClearMaskFlag.h
inc/MantidAlgorithms/CloneWorkspace.h
inc/MantidAlgorithms/CombineDiffCal.h
inc/MantidAlgorithms/Comment.h
inc/MantidAlgorithms/CommutativeBinaryOperation.h
inc/MantidAlgorithms/CompareWorkspaces.h
...
...
@@ -738,6 +740,7 @@ set(TEST_FILES
ClearInstrumentParametersTest.h
ClearMaskFlagTest.h
CloneWorkspaceTest.h
CombineDiffCalTest.h
CommentTest.h
CommutativeBinaryOperationTest.h
CompareWorkspacesTest.h
...
...
Framework/Algorithms/inc/MantidAlgorithms/CombineDiffCal.h
0 → 100644
View file @
d47c3861
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include
"MantidAPI/Algorithm.h"
#include
"MantidAlgorithms/DllConfig.h"
namespace
Mantid
{
namespace
Algorithms
{
/** CombineDiffCal : TODO: DESCRIPTION
*/
class
MANTID_ALGORITHMS_DLL
CombineDiffCal
:
public
API
::
Algorithm
{
public:
const
std
::
string
name
()
const
override
;
int
version
()
const
override
;
const
std
::
string
category
()
const
override
;
const
std
::
string
summary
()
const
override
;
std
::
map
<
std
::
string
,
std
::
string
>
validateInputs
()
override
;
private:
void
init
()
override
;
void
exec
()
override
;
};
}
// namespace Algorithms
}
// namespace Mantid
Framework/Algorithms/src/CombineDiffCal.cpp
0 → 100644
View file @
d47c3861
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include
"MantidAlgorithms/CombineDiffCal.h"
#include
"MantidAPI/TableRow.h"
#include
"MantidDataObjects/OffsetsWorkspace.h"
#include
"MantidDataObjects/TableWorkspace.h"
namespace
Mantid
{
namespace
Algorithms
{
using
Mantid
::
API
::
WorkspaceProperty
;
using
Mantid
::
Kernel
::
Direction
;
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM
(
CombineDiffCal
)
//----------------------------------------------------------------------------------------------
/// Algorithms name for identification. @see Algorithm::name
const
std
::
string
CombineDiffCal
::
name
()
const
{
return
"CombineDiffCal"
;
}
/// Algorithm's version for identification. @see Algorithm::version
int
CombineDiffCal
::
version
()
const
{
return
1
;
}
/// Algorithm's category for identification. @see Algorithm::category
const
std
::
string
CombineDiffCal
::
category
()
const
{
return
"Diffraction
\\
Utility"
;
}
/// Algorithm's summary for use in the GUI and help. @see Algorithm::summary
const
std
::
string
CombineDiffCal
::
summary
()
const
{
return
"Combine a per-pixel calibration with a grouped spectrum calibration"
;
}
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void
CombineDiffCal
::
init
()
{
declareProperty
(
std
::
make_unique
<
WorkspaceProperty
<
DataObjects
::
TableWorkspace
>>
(
"PixelCalibration"
,
""
,
Direction
::
Input
),
"OffsetsWorkspace generated from cross-correlation. This is the source of DIFCpixel."
);
declareProperty
(
std
::
make_unique
<
WorkspaceProperty
<
DataObjects
::
TableWorkspace
>>
(
"GroupedCalibration"
,
""
,
Direction
::
Input
),
"DiffCal table generated from calibrating grouped spectra. This is the source of DIFCgroup."
);
declareProperty
(
std
::
make_unique
<
WorkspaceProperty
<
DataObjects
::
Workspace2D
>>
(
"CalibrationWorkspace"
,
""
,
Direction
::
Input
),
"Workspace where conversion from d-spacing to time-of-flight for each spectrum is determined from. This is the "
"source of DIFCarb."
);
declareProperty
(
std
::
make_unique
<
WorkspaceProperty
<
DataObjects
::
TableWorkspace
>>
(
"OutputWorkspace"
,
""
,
Direction
::
Output
),
"DiffCal table generated from calibrating grouped spectra"
);
}
std
::
map
<
std
::
string
,
std
::
string
>
CombineDiffCal
::
validateInputs
()
{
std
::
map
<
std
::
string
,
std
::
string
>
results
;
return
results
;
}
//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void
CombineDiffCal
::
exec
()
{
// TODO Auto-generated execute stub
}
}
// namespace Algorithms
}
// namespace Mantid
Framework/Algorithms/test/CombineDiffCalTest.h
0 → 100644
View file @
d47c3861
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2021 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include
<cxxtest/TestSuite.h>
#include
"MantidAPI/ITableWorkspace.h"
#include
"MantidAPI/TableRow.h"
#include
"MantidAlgorithms/CombineDiffCal.h"
#include
"MantidDataObjects/TableWorkspace.h"
using
Mantid
::
Algorithms
::
CombineDiffCal
;
using
Mantid
::
API
::
ITableWorkspace_sptr
;
using
Mantid
::
API
::
TableRow
;
using
Mantid
::
DataObjects
::
TableWorkspace
;
class
CombineDiffCalTest
:
public
CxxTest
::
TestSuite
{
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static
CombineDiffCalTest
*
createSuite
()
{
return
new
CombineDiffCalTest
();
}
static
void
destroySuite
(
CombineDiffCalTest
*
suite
)
{
delete
suite
;
}
MatrixWorkspace_sptr
create_grouped_workspace
()
{
// CreateSampleWorkspace(OutputWorkspace=name,
// XUnit="dSpacing", NumBanks=1) gives 100 spectra with differenct locations
}
ITableWorkspace_sptr
create_diffcal_table
()
{
// create table with correct column names
ITableWorkspace_sptr
table
=
std
::
make_shared
<
TableWorkspace
>
();
table
->
addColumn
(
"int"
,
"detid"
);
table
->
addColumn
(
"double"
,
"difc"
);
table
->
addColumn
(
"double"
,
"difa"
);
table
->
addColumn
(
"double"
,
"tzero"
);
// fill the values
TableRow
new_row
=
table
->
appendRow
();
// new_row << entry.detector_id << entry.difc << entry.difa << entry.tzero;
return
table
;
}
void
test_init
()
{
CombineDiffCal
alg
;
TS_ASSERT_THROWS_NOTHING
(
alg
.
initialize
())
TS_ASSERT
(
alg
.
isInitialized
())
}
void
test_exec
()
{
// cases to cover (can be in the same dataset)
// single pixel with pixel==group==arb
// single pixel with pixel==arb!=group
// single pixel with pixel==arb!=group
// grouped with arb==group
// grouped with arb!=group
// test input
auto
difcal_table_pixel
=
create_diffcal_table
();
auto
difcal_table_group
=
create_diffcal_table
();
// TODO create calibration data
// set up algorithm
CombineDiffCal
alg
;
alg
.
setChild
(
true
);
// Don't put output in ADS by default
TS_ASSERT_THROWS_NOTHING
(
alg
.
initialize
());
TS_ASSERT
(
alg
.
isInitialized
());
TS_ASSERT_THROWS_NOTHING
(
alg
.
setProperty
(
"PixelCalibration"
,
difcal_table_pixel
));
TS_ASSERT_THROWS_NOTHING
(
alg
.
setProperty
(
"GroupedCalibration"
,
difcal_table_group
));
// TODO TS_ASSERT_THROWS_NOTHING( alg.setProperty("CalibrationWorkspace", difcal_table_pixel) );
TS_ASSERT_THROWS_NOTHING
(
alg
.
setPropertyValue
(
"OutputWorkspace"
,
"_unused_for_child"
));
// run the algorithm
TS_ASSERT_THROWS_NOTHING
(
alg
.
execute
(););
TS_ASSERT
(
alg
.
isExecuted
());
/*
// Retrieve the workspace from the algorithm. The type here will probably need to change. It should
// be the type using in declareProperty for the "OutputWorkspace" type.
// We can't use auto as it's an implicit conversion.
Workspace_sptr outputWS = alg.getProperty("OutputWorkspace");
TS_ASSERT(outputWS);
TS_FAIL("TODO: Check the results and remove this line");
*/
}
};
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