48const std::string
SaveDiffCal::summary()
const {
return "Saves a calibration file for powder diffraction"; }
55 "An output workspace.");
59 "Optional: A GroupingWorkspace giving the grouping info.");
63 "Optional: A MaskWorkspace giving which detectors are masked.");
66 "Path to the .h5 file that will be created.");
70 std::map<std::string, std::string> result;
73 if (!
bool(calibrationWS)) {
74 result[
"CalibrationWorkspace"] =
"Cannot save empty table";
76 size_t numRows = calibrationWS->rowCount();
78 result[
"CalibrationWorkspace"] =
"Cannot save empty table";
81 if (
bool(groupingWS) && numRows < groupingWS->getNumberHistograms()) {
82 result[
"GroupingWorkspace"] =
"Must have equal or less number of spectra as the table has rows";
85 if (
bool(maskWS) && numRows < maskWS->getNumberHistograms()) {
86 result[
"MaskWorkspace"] =
"Must have equal or less number of spectra as the table has rows";
118 auto data = column->numeric_fill<int32_t>(
m_numValues);
132 const bool isMask = (
name ==
"use");
139 auto &ids = ws->getSpectrum(i).getDetectorIDs();
143 auto value =
static_cast<int32_t
>(ws->getValue(found->first));
151 values[found->second] =
value;
163 auto detids = detidCol->numeric_fill<
detid_t>();
165 const size_t numDets = detids.size();
166 for (
size_t i = 0; i < numDets; ++i) {
172 const std::vector<std::string> names =
m_calibrationWS->getColumnNames();
173 return std::any_of(names.cbegin(), names.cend(), [&ColumnName](
const auto &
name) { return name == ColumnName; });
189 if (
bool(groupingWS) && groupingWS->getNumberHistograms() <
m_numValues) {
192 if (
bool(maskWS) && maskWS->getNumberHistograms() <
m_numValues) {
197 if (Poco::File(filename).
exists()) {
198 Poco::File(filename).remove();
201 H5File file(filename, H5F_ACC_EXCL);
228 std::string instrumentName;
229 std::string instrumentSource;
230 if (
bool(groupingWS)) {
231 instrumentName = groupingWS->getInstrument()->getName();
232 instrumentSource = groupingWS->getInstrument()->getFilename();
235 if (instrumentName.empty()) {
236 instrumentName = maskWS->getInstrument()->getName();
238 if (instrumentSource.empty()) {
239 instrumentSource = maskWS->getInstrument()->getFilename();
242 if (!instrumentSource.empty()) {
243 instrumentSource = Poco::Path(instrumentSource).getFileName();
247 auto instrumentGroup = calibrationGroup.createGroup(
"instrument");
249 if (!instrumentName.empty()) {
252 if (!instrumentSource.empty()) {
253 H5Util::write(instrumentGroup,
"instrument_source", instrumentSource);
#define DECLARE_ALGORITHM(classname)
double value
The value of the point.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
A specialized class for dealing with file properties.
@ Save
to specify a file to write to, the file may or may not exist
ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same ...
A property class for workspaces.
SaveDiffCal : TODO: DESCRIPTION.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
void writeIntFieldFromTable(H5::Group &group, const std::string &name)
Create a dataset under a given group with a given name Use CalibrationWorkspace to retrieve the data.
API::ITableWorkspace_sptr m_calibrationWS
const std::string category() const override
Algorithm's category for identification.
void writeDoubleFieldFromTable(H5::Group &group, const std::string &name)
Create a dataset under a given group with a given name Use CalibrationWorkspace to retrieve the data.
int version() const override
Algorithm's version for identification.
void init() override
Initialize the algorithm's properties.
std::map< detid_t, size_t > m_detidToIndex
void generateDetidToIndex()
const std::string name() const override
Algorithms name for identification.
bool tableHasColumn(const std::string &ColumnName) const
std::map< std::string, std::string > validateInputs() override
Perform validation of ALL the input properties of the algorithm.
void exec() override
Execute the algorithm.
void writeIntFieldFromSVWS(H5::Group &group, const std::string &name, const DataObjects::SpecialWorkspace2D_const_sptr &ws)
Create a dataset under a given group with a given name Use GroupingWorkspace or MaskWorkspace to retr...
A GroupingWorkspace is a subclass of Workspace2D where each spectrum has a single number entry,...
void information(const std::string &msg)
Logs at information level.
std::shared_ptr< const ITableWorkspace > ITableWorkspace_const_sptr
shared pointer to Mantid::API::ITableWorkspace (const version)
void writeArray1D(H5::Group &group, const std::string &name, const std::vector< NumT > &values)
MANTID_DATAHANDLING_DLL H5::Group createGroupNXS(H5::H5File &file, const std::string &name, const std::string &nxtype)
MANTID_DATAHANDLING_DLL void write(H5::Group &group, const std::string &name, const std::string &value)
void writeStrAttribute(LocationType &location, const std::string &name, const std::string &value)
bool exists(::NeXus::File &file, const std::string &name)
Based on the current group in the file, does the named sub-entry exist?
std::shared_ptr< const GroupingWorkspace > GroupingWorkspace_const_sptr
shared pointer to a const GroupingWorkspace
std::shared_ptr< const SpecialWorkspace2D > SpecialWorkspace2D_const_sptr
shared pointer to a const SpecialWorkspace2D
std::shared_ptr< const MaskWorkspace > MaskWorkspace_const_sptr
shared pointer to a const MaskWorkspace
int32_t detid_t
Typedef for a detector ID.
Enumeration for a mandatory/optional property.
Describes the direction (within an algorithm) of a Property.
@ Input
An input workspace.