39#include <boost/algorithm/string/trim.hpp>
40#include <boost/regex.hpp>
41#include <nexus/NeXusException.hpp>
54using namespace DataObjects;
55using namespace Kernel;
58using Mantid::Types::Event::TofEvent;
59using Types::Core::DateAndTime;
83using SpectraInfo_optional = boost::optional<SpectraInfo>;
92SpectraInfo extractMappingInfo(
const NXEntry &mtd_entry,
Logger &logger) {
93 SpectraInfo spectraInfo;
97 logger.
information() <<
"No NXinstrument group called `instrument` under "
98 "NXEntry. The workspace will not "
99 "contain any detector information.\n";
104 logger.
information() <<
"Detector block not found. The workspace will not "
105 "contain any detector information.\n";
117 spectra_block.
load();
118 spectraInfo.spectraNumbers = spectra_block.
vecBuffer();
119 spectraInfo.nSpectra = spectra_block.
dim0();
120 spectraInfo.hasSpectra =
true;
121 }
catch (std::runtime_error &) {
122 spectraInfo.hasSpectra =
false;
131 detlist_group.
load();
132 spectraInfo.detectorList = detlist_group.
vecBuffer();
133 }
catch (std::runtime_error &) {
134 logger.
information() <<
"detector_list block not found. The workspace will "
135 "not contain any detector information.\n";
143 spectraInfo.detectorCount = det_count.
vecBuffer();
147 spectraInfo.nSpectra = det_index.
dim0();
148 spectraInfo.detectorIndex = det_index.
vecBuffer();
161 bool isMultiPeriod =
false;
163 const std::string nPeriodsLogEntryName =
"nperiods";
164 const Run &run = expInfo->run();
167 if (nPeriods == nWorkspaceEntries) {
168 isMultiPeriod =
true;
169 log.
information(
"Loading as MultiPeriod group workspace.");
173 return isMultiPeriod;
180 : m_shared_bins(false), m_xbins(0), m_axis1vals(), m_list(false), m_interval(false), m_spec_min(0),
181 m_spec_max(
Mantid::
EMPTY_INT()), m_spec_list(), m_filtered_spec_idxs(), m_nexusFile() {}
194 if (descriptor.
pathExists(
"/mantid_workspace_1"))
209 const std::vector<std::string> exts{
".nxs",
".nx5",
".xml"};
211 "The name of the Nexus file to read, as a full or relative path.");
213 "The name of the workspace to be created as the output of "
214 "the algorithm. A workspace of this name will be created "
215 "and stored in the Analysis Data Service. For multiperiod "
216 "files, one workspace may be generated for each period. "
217 "Currently only one workspace can be saved at a time so "
218 "multiperiod Mantid files are not generated.");
221 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
222 mustBePositive->setLower(0);
225 declareProperty(
"SpectrumMin",
static_cast<int>(1), mustBePositive,
"Number of first spectrum to read.");
227 "Number of last spectrum to read.");
230 "0 indicates that every entry is loaded, into a separate "
231 "workspace within a group. "
232 "A positive number identifies one entry to be loaded, into "
234 declareProperty(
"LoadHistory",
true,
"If true, the workspace history will be loaded");
236 "For multiperiod workspaces. Copy instrument, parameter and x-data "
237 "rather than loading it directly for each workspace. Y, E and log "
238 "information is always loaded.");
253 const size_t nWorkspaceEntries,
const size_t p) {
257 const size_t nHistograms = periodWorkspace->getNumberHistograms();
258 for (
size_t i = 0; i < nHistograms; ++i) {
259 periodWorkspace->setSharedX(i, tempMatrixWorkspace->sharedX(i));
271 NXEntry mtdEntry(root, entryName);
274 NXData wsEntry(mtdEntry,
"workspace");
276 std::stringstream buffer;
277 buffer <<
"Group entry " << p - 1
278 <<
" is not a workspace 2D. Retry with "
279 "FastMultiPeriod option set off.\n";
280 throw std::runtime_error(buffer.str());
283 if (wsEntry.
isValid(
"frac_area")) {
284 std::stringstream buffer;
285 buffer <<
"Group entry " << p - 1
286 <<
" has fractional area present. Try "
287 "reloading with FastMultiPeriod set "
289 throw std::runtime_error(buffer.str());
297 const int nChannels = data.
dim1();
302 static_cast<int>(nHistograms) / blockSize;
303 const int readOptimumStop = (nFullBlocks * blockSize);
305 const int finalBlockSize = readStop - readOptimumStop;
310 for (; histIndex < readStop;) {
311 if (histIndex >= readOptimumStop) {
312 blockSize = finalBlockSize;
315 data.
load(blockSize, histIndex);
316 errors.
load(blockSize, histIndex);
318 double *dataStart = data();
319 double *dataEnd = dataStart + nChannels;
321 double *errorStart = errors();
322 double *errorEnd = errorStart + nChannels;
324 int final(histIndex + blockSize);
325 while (histIndex <
final) {
326 auto &
Y = periodWorkspace->mutableY(wsIndex);
327 Y.assign(dataStart, dataEnd);
328 dataStart += nChannels;
329 dataEnd += nChannels;
330 auto &E = periodWorkspace->mutableE(wsIndex);
331 E.assign(errorStart, errorEnd);
332 errorStart += nChannels;
333 errorEnd += nChannels;
351 periodWorkspace->loadSampleAndLogInfoNexus(
m_nexusFile.get());
352 }
catch (std::exception &e) {
362 const double fractionComplete = double(p - 1) / double(nWorkspaceEntries);
363 progress(fractionComplete,
"Loading multiperiod entry");
364 return periodWorkspace;
376 int nWorkspaceEntries = 0;
390 nWorkspaceEntries =
static_cast<int>((root.
groups().size()));
395 bool bDefaultEntryNumber = entryNumberProperty->
isDefault();
397 if (!bDefaultEntryNumber && entrynumber > nWorkspaceEntries) {
398 g_log.
error() <<
"Invalid entry number specified. File only contains " << nWorkspaceEntries <<
" entries.\n";
399 throw std::invalid_argument(
"Invalid entry number specified.");
402 const std::string basename =
"mantid_workspace_";
404 std::ostringstream os;
405 if (bDefaultEntryNumber) {
409 os << basename << entrynumber;
410 const std::string targetEntryName = os.str();
414 tempWS =
loadEntry(root, targetEntryName, 0, 1);
416 if (nWorkspaceEntries == 1 || !bDefaultEntryNumber) {
423 const bool bFastMultiPeriod = this->
getProperty(
"FastMultiPeriod");
424 const bool bIsMultiPeriod = isMultiPeriodFile(nWorkspaceEntries, tempWS,
g_log);
429 auto wksp_group = std::make_shared<WorkspaceGroup>();
444 alg->setProperty(
"Workspace", base_name);
449 const std::string prop_name =
"OutputWorkspace_";
452 bool bAccelleratedMultiPeriodLoading =
false;
453 if (tempMatrixWorkspace) {
456 bAccelleratedMultiPeriodLoading = bIsMultiPeriod && bFastMultiPeriod && !
m_list;
459 tempMatrixWorkspace->mutableRun().clearLogs();
462 if (bAccelleratedMultiPeriodLoading) {
468 for (
int p = 1; p <= nWorkspaceEntries; ++p) {
482 if (bAccelleratedMultiPeriodLoading) {
487 const auto nWorkspaceEntries_d =
static_cast<double>(nWorkspaceEntries);
488 local_workspace =
loadEntry(root, basename + indexStr,
static_cast<double>(p - 1) / nWorkspaceEntries_d,
489 1. / nWorkspaceEntries_d);
495 wksp_group->addWorkspace(local_workspace);
496 setProperty(prop_name + indexStr, local_workspace);
500 setProperty(
"OutputWorkspace", std::static_pointer_cast<Workspace>(wksp_group));
533 boost::smatch results;
534 const boost::regex exp(
".*_(\\d+$)");
536 if (boost::regex_search(
name, results, exp)) {
537 wsName = baseName + std::string(results[1].first, results[1].second);
540 wsName = baseName +
index;
557 for (
int i = 0; !noClash; ++i) {
579 std::vector<std::string> names(nWorkspaceEntries + 1);
580 for (
size_t p = 1; p <= nWorkspaceEntries; ++p) {
587 auto it = std::unique(names.begin(), names.end());
588 if (it != names.end()) {
589 auto size = names.size();
605 std::string workspaceName = std::string();
607 workspaceName = mtd_entry.
getString(
"workspace_name");
608 }
catch (std::runtime_error &) {
611 return workspaceName;
626 const double &progressStart,
const double &progressRange) {
629 size_t numspec = indices_data.
dim0() - 1;
637 int num_xbins = xbins.
dim0();
638 if (xbins.
rank() == 2) {
639 num_xbins = xbins.
dim1();
647 ws->setYUnit(indices_data.
attributes(
"units"));
648 std::string unitLabel = indices_data.
attributes(
"unit_label");
649 if (unitLabel.empty())
651 ws->setYUnitLabel(unitLabel);
655 std::vector<int64_t> pulsetimes;
656 if (wksp_cls.
isValid(
"pulsetime")) {
662 std::vector<double> tofs;
669 std::vector<float> error_squareds;
670 if (wksp_cls.
isValid(
"error_squared")) {
672 error_squared.
load();
673 error_squareds = error_squared.
vecBuffer();
676 std::vector<float> weights;
677 if (wksp_cls.
isValid(
"weight")) {
685 if (!tofs.empty() && !pulsetimes.empty() && !weights.empty() && !error_squareds.empty())
687 else if ((!tofs.empty() && !weights.empty() && !error_squareds.empty()))
689 else if (!pulsetimes.empty() && !tofs.empty())
692 throw std::runtime_error(
"Could not figure out the type of event list!");
695 std::vector<int64_t> indices = indices_data.
vecBuffer();
700 for (int64_t j = 0; j < max; ++j) {
703 int64_t index_start = indices[wi];
704 int64_t index_end = indices[wi + 1];
705 if (index_end >= index_start) {
710 el.
reserve(index_end - index_start);
713 for (int64_t i = index_start; i < index_end; i++)
732 for (
int i = 0; i < xbins.
dim1(); i++)
733 x[i] = xbins(
static_cast<int>(wi), i);
755template <
typename ColumnType,
typename NexusType>
759 std::string columnTitle = data.
attributes(
"name");
760 if (!columnTitle.empty()) {
762 auto length =
static_cast<size_t>(data.
dim0());
763 auto rowCount = tableWs->rowCount();
766 tableWs->setRowCount(length);
767 }
else if (rowCount != length) {
768 throw std::runtime_error(
"Columns have different sizes.");
771 auto column = tableWs->addColumn(columnType, columnTitle);
772 for (
size_t i = 0; i < length; i++) {
773 column->cell<ColumnType>(i) =
static_cast<ColumnType
>(*(data() + i));
788 int columnNumber = 1;
790 std::string dataSetName =
"column_" +
std::to_string(columnNumber);
793 if (info.
stat == NX_ERROR) {
798 if (info.
rank == 1) {
799 if (info.
type == NX_FLOAT64) {
800 loadNumericColumn<double, double>(nx_tw, dataSetName,
workspace,
"double");
801 }
else if (info.
type == NX_INT32) {
802 loadNumericColumn<int, int32_t>(nx_tw, dataSetName,
workspace,
"int");
803 }
else if (info.
type == NX_UINT32) {
804 loadNumericColumn<uint32_t, uint32_t>(nx_tw, dataSetName,
workspace,
"uint");
805 }
else if (info.
type == NX_INT64) {
806 loadNumericColumn<int64_t, int64_t>(nx_tw, dataSetName,
workspace,
"long64");
807 }
else if (info.
type == NX_UINT64) {
808 loadNumericColumn<size_t, uint64_t>(nx_tw, dataSetName,
workspace,
"size_t");
809 }
else if (info.
type == NX_FLOAT32) {
810 loadNumericColumn<float, float>(nx_tw, dataSetName,
workspace,
"float");
811 }
else if (info.
type == NX_UINT8) {
812 loadNumericColumn<bool, bool>(nx_tw, dataSetName,
workspace,
"bool");
814 throw std::logic_error(
"Column with Nexus data type " +
std::to_string(info.
type) +
" cannot be loaded.");
816 }
else if (info.
rank == 2) {
817 if (info.
type == NX_CHAR) {
819 std::string columnTitle = data.
attributes(
"name");
820 if (!columnTitle.empty()) {
821 workspace->addColumn(
"str", columnTitle);
822 int nRows = info.
dims[0];
825 const int maxStr = info.
dims[1];
827 for (
int iR = 0; iR < nRows; ++iR) {
828 auto &cellContents =
workspace->cell<std::string>(iR, columnNumber - 1);
829 auto startPoint = data() + maxStr * iR;
830 cellContents.assign(startPoint, startPoint + maxStr);
831 boost::trim_right(cellContents);
834 }
else if (info.
type == NX_INT32) {
835 loadVectorColumn<int>(nx_tw, dataSetName,
workspace,
"vector_int");
836 }
else if (info.
type == NX_FLOAT64) {
838 if (data.attributes(
"interpret_as") ==
"V3D") {
841 loadVectorColumn<double>(nx_tw, dataSetName,
workspace,
"vector_double");
850 return std::static_pointer_cast<API::Workspace>(
workspace);
860template <
typename Type>
864 std::string columnTitle = data.
attributes(
"name");
865 if (!columnTitle.empty()) {
866 tableWs->addColumn(columnType, columnTitle);
869 const size_t rowCount = info.
dims[0];
870 const size_t blockSize = info.
dims[1];
873 tableWs->setRowCount(rowCount);
877 for (
size_t i = 0; i < rowCount; ++i) {
878 auto &cell = tableWs->cell<std::vector<Type>>(i, tableWs->columnCount() - 1);
880 Type *from = data() + blockSize * i;
882 cell.assign(from, from + blockSize);
884 std::ostringstream rowSizeAttrName;
885 rowSizeAttrName <<
"row_size_" << i;
888 std::istringstream rowSizeStr(data.
attributes(rowSizeAttrName.str()));
891 rowSizeStr >> rowSize;
893 cell.resize(rowSize);
904 std::string columnTitle = data.
attributes(
"name");
905 if (!columnTitle.empty()) {
908 const int rowCount = data.
dim0();
911 tableWs->setRowCount(rowCount);
915 for (
int i = 0; i < rowCount; ++i) {
917 cell(data(i, 0), data(i, 1), data(i, 2));
940 int columnNumber = 1;
942 std::vector<std::string> columnNames;
947 if (info.
stat == NX_ERROR) {
953 columnNames.emplace_back(str);
958 if (info.
type == NX_FLOAT64) {
960 std::string columnTitle = nxDouble.
attributes(
"name");
961 if (!columnTitle.empty() && numberPeaks == 0) {
962 numberPeaks = nxDouble.
dim0();
971 std::string parameterStr;
975 }
catch (std::runtime_error &re) {
976 throw std::runtime_error(
"Error while opening a path in a Peaks entry in a "
977 "Nexus processed file. "
978 "This path is wrong: " +
979 entry.
path() +
". Lower level error description: " + re.what());
985 peakWS->readParameterMap(parameterStr);
986 }
catch (std::exception &e) {
993 const std::string peaksWSName =
"peaks_workspace";
996 }
catch (std::runtime_error &re) {
997 throw std::runtime_error(
"Error while opening a peaks workspace in a Nexus processed file. "
998 "Cannot open gropu " +
999 peaksWSName +
". Lower level error description: " + re.what());
1002 uint32_t loadCoord(0);
1003 m_nexusFile->readData(
"coordinate_system", loadCoord);
1005 }
catch (::NeXus::Exception &) {
1007 auto logs = peakWS->logs();
1008 if (logs->hasProperty(
"CoordinateSystem")) {
1011 int value((*prop)());
1017 std::string m_QConvention =
"Inelastic";
1019 m_nexusFile->getAttr(
"QConvention", m_QConvention);
1020 }
catch (std::exception &) {
1029 if (convention != m_QConvention)
1032 for (
int r = 0; r < numberPeaks; r++) {
1034 const auto goniometer = peakWS->run().getGoniometer();
1038 peakWS->addPeak(peak);
1041 for (
const auto &str : columnNames) {
1042 if (str ==
"column_1") {
1046 for (
int r = 0; r < numberPeaks; r++) {
1047 double val = qSign * nxDouble[r];
1048 peakWS->getPeak(r).setH(val);
1050 }
else if (str ==
"column_2") {
1054 for (
int r = 0; r < numberPeaks; r++) {
1055 double val = qSign * nxDouble[r];
1056 peakWS->getPeak(r).setK(val);
1058 }
else if (str ==
"column_3") {
1062 for (
int r = 0; r < numberPeaks; r++) {
1063 double val = qSign * nxDouble[r];
1064 peakWS->getPeak(r).setL(val);
1066 }
else if (str ==
"column_4") {
1070 for (
int r = 0; r < numberPeaks; r++) {
1071 double val = nxDouble[r];
1072 peakWS->getPeak(r).setIntensity(val);
1074 }
else if (str ==
"column_5") {
1078 for (
int r = 0; r < numberPeaks; r++) {
1079 double val = nxDouble[r];
1080 peakWS->getPeak(r).setSigmaIntensity(val);
1082 }
else if (str ==
"column_6") {
1086 for (
int r = 0; r < numberPeaks; r++) {
1087 double val = nxDouble[r];
1088 peakWS->getPeak(r).setBinCount(val);
1090 }
else if (str ==
"column_7") {
1094 for (
int r = 0; r < numberPeaks; r++) {
1095 double val = nxDouble[r];
1096 peakWS->getPeak(r).setWavelength(val);
1098 }
else if (str ==
"column_10") {
1102 for (
int r = 0; r < numberPeaks; r++) {
1103 int ival = nxInt[r];
1105 peakWS->getPeak(r).setRunNumber(ival);
1107 }
else if (str ==
"column_11") {
1111 for (
int r = 0; r < numberPeaks; r++) {
1112 int ival = nxInt[r];
1113 peakWS->getPeak(r).setPeakNumber(ival);
1115 }
else if (str ==
"column_12") {
1119 for (
int r = 0; r < numberPeaks; r++) {
1120 double val = nxDouble[r];
1121 peakWS->getPeak(r).setAbsorptionWeightedPathLength(val);
1123 }
else if (str ==
"column_13") {
1128 for (
int r = 0; r < numberPeaks; r++) {
1129 for (
int j = 0; j < 9; j++) {
1130 double val = nxDouble[k];
1132 gm[j % 3][j / 3] = val;
1134 peakWS->getPeak(r).setGoniometerMatrix(gm);
1136 }
else if (str ==
"column_15") {
1140 for (
int r = 0; r < numberPeaks; ++r) {
1141 qlab =
V3D(nxDouble[r * 3], nxDouble[r * 3 + 1], nxDouble[r * 3 + 2]);
1142 peakWS->getPeak(r).setQLabFrame(qlab, 0.0);
1147 for (
int r = 0; r < numberPeaks; r++) {
1148 V3D intHKL =
V3D(peakWS->getPeak(r).getH(), peakWS->getPeak(r).getK(), peakWS->getPeak(r).getL());
1149 peakWS->getPeak(r).setIntHKL(intHKL);
1153 return std::static_pointer_cast<API::Workspace>(peakWS);
1170 int columnNumber = 1;
1171 int numberPeaks = 0;
1172 std::vector<std::string> columnNames;
1177 if (info.
stat == NX_ERROR) {
1183 columnNames.emplace_back(str);
1188 if (info.
type == NX_FLOAT64) {
1190 std::string columnTitle = nxDouble.
attributes(
"name");
1191 if (!columnTitle.empty() && numberPeaks == 0) {
1192 numberPeaks = nxDouble.
dim0();
1201 std::string parameterStr;
1205 }
catch (std::runtime_error &re) {
1206 throw std::runtime_error(
"Error while opening a path in a Peaks entry in a "
1207 "Nexus processed file. "
1208 "This path is wrong: " +
1209 entry.
path() +
". Lower level error description: " + re.what());
1215 peakWS->readParameterMap(parameterStr);
1216 }
catch (std::exception &e) {
1223 const std::string peaksWSName =
"peaks_workspace";
1226 }
catch (std::runtime_error &re) {
1227 throw std::runtime_error(
"Error while opening a peaks workspace in a Nexus processed file. "
1228 "Cannot open gropu " +
1229 peaksWSName +
". Lower level error description: " + re.what());
1232 uint32_t loadCoord(0);
1233 m_nexusFile->readData(
"coordinate_system", loadCoord);
1235 }
catch (::NeXus::Exception &) {
1237 auto logs = peakWS->logs();
1238 if (logs->hasProperty(
"CoordinateSystem")) {
1241 int value((*prop)());
1247 std::string m_QConvention =
"Inelastic";
1249 m_nexusFile->getAttr(
"QConvention", m_QConvention);
1250 }
catch (std::exception &) {
1259 if (convention != m_QConvention)
1262 for (
int r = 0; r < numberPeaks; r++) {
1268 const auto goniometer = peakWS->run().getGoniometer();
1273 peakWS->addPeak(std::move(peak));
1276 for (
const auto &str : columnNames) {
1277 if (str ==
"column_1") {
1281 for (
int r = 0; r < numberPeaks; r++) {
1282 int ival = nxInt[r];
1284 peakWS->getPeak(r).setDetectorID(ival);
1286 }
else if (str ==
"column_2") {
1290 for (
int r = 0; r < numberPeaks; r++) {
1291 double val = qSign * nxDouble[r];
1292 peakWS->getPeak(r).setH(val);
1294 }
else if (str ==
"column_3") {
1298 for (
int r = 0; r < numberPeaks; r++) {
1299 double val = qSign * nxDouble[r];
1300 peakWS->getPeak(r).setK(val);
1302 }
else if (str ==
"column_4") {
1306 for (
int r = 0; r < numberPeaks; r++) {
1307 double val = qSign * nxDouble[r];
1308 peakWS->getPeak(r).setL(val);
1310 }
else if (str ==
"column_5") {
1314 for (
int r = 0; r < numberPeaks; r++) {
1315 double val = nxDouble[r];
1316 peakWS->getPeak(r).setIntensity(val);
1318 }
else if (str ==
"column_6") {
1322 for (
int r = 0; r < numberPeaks; r++) {
1323 double val = nxDouble[r];
1324 peakWS->getPeak(r).setSigmaIntensity(val);
1326 }
else if (str ==
"column_7") {
1330 for (
int r = 0; r < numberPeaks; r++) {
1331 double val = nxDouble[r];
1332 peakWS->getPeak(r).setBinCount(val);
1334 }
else if (str ==
"column_10") {
1338 for (
int r = 0; r < numberPeaks; r++) {
1339 double val = nxDouble[r];
1340 peakWS->getPeak(r).setWavelength(val);
1342 }
else if (str ==
"column_14") {
1346 for (
int r = 0; r < numberPeaks; r++) {
1347 int ival = nxInt[r];
1349 peakWS->getPeak(r).setRunNumber(ival);
1351 }
else if (str ==
"column_17") {
1355 for (
int r = 0; r < numberPeaks; r++) {
1356 int ival = nxInt[r];
1357 peakWS->getPeak(r).setPeakNumber(ival);
1359 }
else if (str ==
"column_18") {
1363 for (
int r = 0; r < numberPeaks; r++) {
1364 double val = nxDouble[r];
1365 peakWS->getPeak(r).setAbsorptionWeightedPathLength(val);
1367 }
else if (str ==
"column_15") {
1372 for (
int r = 0; r < numberPeaks; r++) {
1373 for (
int j = 0; j < 9; j++) {
1374 double val = nxDouble[k];
1376 gm[j % 3][j / 3] = val;
1378 peakWS->getPeak(r).setGoniometerMatrix(gm);
1380 }
else if (str ==
"column_16") {
1388 peakFactoryEllipsoid->setSuccessor(peakFactorySphere);
1389 peakFactorySphere->setSuccessor(peakFactoryNone);
1394 const int maxShapeJSONLength = info.
dims[1];
1396 for (
int i = 0; i < numberPeaks; ++i) {
1399 auto startPoint = data() + (maxShapeJSONLength * i);
1400 std::string shapeJSON(startPoint, startPoint + maxShapeJSONLength);
1401 boost::trim_right(shapeJSON);
1407 peakWS->getPeak(i).setPeakShape(peakShape);
1411 for (
int r = 0; r < numberPeaks; r++) {
1412 V3D intHKL =
V3D(peakWS->getPeak(r).getH(), peakWS->getPeak(r).getK(), peakWS->getPeak(r).getL());
1413 peakWS->getPeak(r).setIntHKL(intHKL);
1417 return std::static_pointer_cast<API::Workspace>(peakWS);
1436 const double &progressStart,
1437 const double &progressRange,
const NXEntry &mtd_entry,
1438 const int xlength, std::string &workspaceType) {
1441 int nchannels = data.
dim1();
1442 size_t nspectra = data.
dim0();
1448 if (nchannels == 1 && nspectra == 1) {
1452 if (hasInstrument) {
1453 std::string inst_name = mtd_entry.
getString(
"instrument/name");
1454 boost::algorithm::trim(inst_name);
1455 if (inst_name ==
"")
1456 hasInstrument =
false;
1461 hasInstrument =
true;
1465 for (
auto instrumentName : facility->instruments()) {
1466 if (instrumentName.name() !=
"" && mtd_entry.
containsGroup(instrumentName.name())) {
1467 hasInstrument =
true;
1480 hasMetadata =
false;
1484 if (!hasInstrument && !hasMetadata)
1485 workspaceType =
"WorkspaceSingleValue";
1487 bool hasFracArea =
false;
1488 if (wksp_cls.
isValid(
"frac_area")) {
1491 workspaceType =
"RebinnedOutput";
1497 local_workspace->setTitle(mtd_entry.
getString(
"title"));
1498 }
catch (std::runtime_error &) {
1503 local_workspace->setYUnit(data.
attributes(
"units"));
1504 std::string unitLabel = data.
attributes(
"unit_label");
1505 if (unitLabel.empty())
1507 local_workspace->setYUnitLabel(unitLabel);
1517 auto rbWS = std::dynamic_pointer_cast<RebinnedOutput>(local_workspace);
1518 auto finalizedValue = fracarea.
attributes(
"finalized");
1519 auto finalized = (finalizedValue.empty() ? true : finalizedValue ==
"1");
1520 rbWS->setFinalized(finalized);
1521 auto sqrdErrsValue = fracarea.
attributes(
"sqrd_errors");
1522 auto sqrdErrs = (sqrdErrsValue.empty() ? false : sqrdErrsValue ==
"1");
1523 rbWS->setSqrdErrors(sqrdErrs);
1528 auto hasXErrors = wksp_cls.
isValid(
"xerrors");
1529 auto xErrors = hasXErrors ? wksp_cls.
openNXDouble(
"xerrors") : errors;
1531 if (xErrors.dim1() == nchannels + 1)
1532 g_log.
warning() <<
"Legacy X uncertainty found in input file, i.e., "
1533 "delta-Q for each BIN EDGE. Uncertainties will be "
1534 "re-interpreted as delta-Q of the BIN CENTRE and the "
1535 "last value will be dropped.\n";
1542 int fullblocks =
static_cast<int>(total_specs) / blocksize;
1543 int read_stop = (fullblocks * blocksize);
1544 const double progressBegin = progressStart + 0.25 * progressRange;
1545 const double progressScaler = 0.75 * progressRange;
1557 fullblocks = (interval_specs) / blocksize;
1558 read_stop = (fullblocks * blocksize) +
m_spec_min - 1;
1560 if (interval_specs < blocksize) {
1561 blocksize =
static_cast<int>(total_specs);
1566 for (; hist_index < read_stop;) {
1567 progress(progressBegin + progressScaler *
static_cast<double>(hist_index) /
static_cast<double>(read_stop),
1568 "Reading workspace data...");
1569 loadBlock(data, errors, fracarea, hasFracArea, xErrors, hasXErrors, blocksize, nchannels, hist_index, wsIndex,
1572 size_t finalblock =
m_spec_max - 1 - read_stop;
1573 if (finalblock > 0) {
1574 loadBlock(data, errors, fracarea, hasFracArea, xErrors, hasXErrors,
static_cast<int>(finalblock), nchannels,
1575 hist_index, wsIndex, local_workspace);
1582 int specIndex = itr - 1;
1584 progressScaler *
static_cast<double>(specIndex) /
static_cast<double>(
m_spec_list.size()),
1585 "Reading workspace data...");
1586 loadBlock(data, errors, fracarea, hasFracArea, xErrors, hasXErrors, 1, nchannels, specIndex, wsIndex,
1591 for (; hist_index < read_stop;) {
1592 progress(progressBegin + progressScaler *
static_cast<double>(hist_index) /
static_cast<double>(read_stop),
1593 "Reading workspace data...");
1594 loadBlock(data, errors, fracarea, hasFracArea, xErrors, hasXErrors, blocksize, nchannels, hist_index, wsIndex,
1597 size_t finalblock = total_specs - read_stop;
1598 if (finalblock > 0) {
1599 loadBlock(data, errors, fracarea, hasFracArea, xErrors, hasXErrors,
static_cast<int>(finalblock), nchannels,
1600 hist_index, wsIndex, local_workspace);
1608 fullblocks = (interval_specs) / blocksize;
1609 read_stop = (fullblocks * blocksize) +
m_spec_min - 1;
1611 if (interval_specs < blocksize) {
1612 blocksize = interval_specs;
1617 for (; hist_index < read_stop;) {
1618 progress(progressBegin + progressScaler *
static_cast<double>(hist_index) /
static_cast<double>(read_stop),
1619 "Reading workspace data...");
1620 loadBlock(data, errors, fracarea, hasFracArea, xErrors, hasXErrors, xbins, blocksize, nchannels, hist_index,
1621 wsIndex, local_workspace);
1623 size_t finalblock =
m_spec_max - 1 - read_stop;
1624 if (finalblock > 0) {
1625 loadBlock(data, errors, fracarea, hasFracArea, xErrors, hasXErrors, xbins,
static_cast<int>(finalblock),
1626 nchannels, hist_index, wsIndex, local_workspace);
1632 int specIndex = itr - 1;
1633 progress(progressBegin + progressScaler *
static_cast<double>(specIndex) /
static_cast<double>(read_stop),
1634 "Reading workspace data...");
1635 loadBlock(data, errors, fracarea, hasFracArea, xErrors, hasXErrors, xbins, 1, nchannels, specIndex, wsIndex,
1640 for (; hist_index < read_stop;) {
1641 progress(progressBegin + progressScaler *
static_cast<double>(hist_index) /
static_cast<double>(read_stop),
1642 "Reading workspace data...");
1643 loadBlock(data, errors, fracarea, hasFracArea, xErrors, hasXErrors, xbins, blocksize, nchannels, hist_index,
1644 wsIndex, local_workspace);
1646 size_t finalblock = total_specs - read_stop;
1647 if (finalblock > 0) {
1648 loadBlock(data, errors, fracarea, hasFracArea, xErrors, hasXErrors, xbins,
static_cast<int>(finalblock),
1649 nchannels, hist_index, wsIndex, local_workspace);
1653 return local_workspace;
1670 const double &progressStart,
const double &progressRange) {
1671 progress(progressStart,
"Opening entry " + entry_name +
"...");
1683 }
catch (std::exception &) {
1690 bool isEvent =
false;
1691 std::string workspaceType =
"Workspace2D";
1692 std::string group_name =
"workspace";
1695 group_name =
"event_workspace";
1697 workspaceType =
"OffsetsWorkspace";
1698 group_name =
"offsets_workspace";
1700 workspaceType =
"MaskWorkspace";
1701 group_name =
"mask_workspace";
1712 std::string unit1 = xbins.
attributes(
"units");
1715 if (xbins.
rank() == 2) {
1716 xlength = xbins.
dim1();
1718 }
else if (xbins.
rank() == 1) {
1719 xlength = xbins.
dim0();
1722 m_xbins = HistogramData::HistogramX(xbins(), xbins() + xlength);
1724 throw std::runtime_error(
"Unknown axis1 dimension encountered.");
1729 std::string unit2 = axis2.
attributes(
"units");
1734 local_workspace =
loadEventEntry(wksp_cls, xbins, progressStart, progressRange);
1737 loadNonEventEntry(wksp_cls, xbins, progressStart, progressRange, mtd_entry, xlength, workspaceType);
1739 size_t nspectra = local_workspace->getNumberHistograms();
1742 bool verticalHistogram(
false);
1745 if (unit1 ==
"Label") {
1746 auto label = std::dynamic_pointer_cast<Mantid::Kernel::Units::Label>(local_workspace->getAxis(0)->unit());
1748 label->setLabel(ax.attributes(
"caption"), ax.attributes(
"label"));
1755 if (
static_cast<size_t>(axis2.
size()) == nspectra + 1)
1756 verticalHistogram =
true;
1758 }
catch (std::runtime_error &) {
1759 g_log.
information() <<
"Axis 0 set to unitless quantity \"" << unit1 <<
"\"\n";
1763 if (unit2 ==
"TextAxis") {
1764 auto newAxis = std::make_unique<Mantid::API::TextAxis>(nspectra);
1765 local_workspace->replaceAxis(1, std::move(newAxis));
1766 }
else if (unit2 !=
"spectraNumber") {
1768 auto newAxis = (verticalHistogram) ? std::make_unique<API::BinEdgeAxis>(nspectra + 1)
1769 : std::make_unique<API::NumericAxis>(nspectra);
1770 auto newAxisRaw = newAxis.get();
1771 local_workspace->replaceAxis(1, std::move(newAxis));
1773 if (unit2 ==
"Label") {
1774 auto label = std::dynamic_pointer_cast<Mantid::Kernel::Units::Label>(newAxisRaw->unit());
1776 label->setLabel(ax.attributes(
"caption"), ax.attributes(
"label"));
1778 }
catch (std::runtime_error &) {
1779 g_log.
information() <<
"Axis 1 set to unitless quantity \"" << unit2 <<
"\"\n";
1784 std::string dist = xbins.
attributes(
"distribution");
1786 local_workspace->setDistribution(
true);
1788 local_workspace->setDistribution(
false);
1792 std::string parameterStr;
1794 progress(progressStart + 0.05 * progressRange,
"Reading the sample details...");
1804 progress(progressStart + 0.11 * progressRange,
"Reading the parameter maps...");
1805 local_workspace->readParameterMap(parameterStr);
1806 }
catch (std::exception &e) {
1811 g_log.
warning(
"Error loading Instrument section of nxs file");
1813 g_log.
warning(
"Try running LoadInstrument Algorithm on the Workspace to "
1814 "update the geometry");
1819 if (!local_workspace->getAxis(1)->isSpectra()) {
1824 progress(progressStart + 0.15 * progressRange,
"Reading the workspace history...");
1829 local_workspace->history().loadNexus(
m_nexusFile.get());
1830 }
catch (std::out_of_range &) {
1831 g_log.
warning() <<
"Error in the workspaces algorithm list, its processing "
1832 "history is incomplete\n";
1835 progress(progressStart + 0.2 * progressRange,
"Reading the workspace history...");
1838 if (local_workspace->getTitle().empty())
1839 local_workspace->setTitle(mtd_entry.
getString(
"title"));
1840 }
catch (std::runtime_error &) {
1844 return std::static_pointer_cast<API::Workspace>(local_workspace);
1856 SpectraInfo spectraInfo = extractMappingInfo(mtd_entry, this->
g_log);
1862 for (
int i = 1; i <= spectraInfo.nSpectra; ++i) {
1870 if (spectraInfo.hasSpectra) {
1871 spectrum = spectraInfo.spectraNumbers[i - 1];
1872 }
else if (haveSpectraAxis && !
m_axis1vals.empty()) {
1884 if (!spectraInfo.detectorIndex.empty()) {
1885 const int start = spectraInfo.detectorIndex[i - 1];
1886 const int end = start + spectraInfo.detectorCount[i - 1];
1887 spec.setDetectorIDs(
1888 std::set<detid_t>(spectraInfo.detectorList.data() + start, spectraInfo.detectorList.data() + end));
1899 using namespace std;
1900 map<string, string> errorList;
1906 if (specMax < specMin) {
1907 errorList[
"SpectrumMin"] =
"SpectrumMin must be smaller than SpectrumMax";
1908 errorList[
"SpectrumMax"] =
"SpectrumMax must be larger than SpectrumMin";
1925 Axis *axis = local_workspace->getAxis(1);
1930 for (
int i = 0; i < static_cast<int>(axis->
length()); i++) {
1933 }
else if (axis->
isText()) {
1935 std::string axisLabels;
1938 axisLabels = std::string(axisData(), axisData.
dim0());
1939 }
catch (std::runtime_error &) {
1945 auto *textAxis =
static_cast<TextAxis *
>(axis);
1961 std::string::size_type index1, index2;
1962 std::string num1, num2;
1964 index1 = elem1.
nxname.find(
'_');
1965 if (index1 != std::string::npos) {
1966 num1 = elem1.
nxname.substr(index1 + 1, elem1.
nxname.length() - index1);
1968 index2 = elem2.
nxname.find(
'_');
1969 if (index2 != std::string::npos) {
1970 num2 = elem2.
nxname.substr(index2 + 1, elem2.
nxname.length() - index2);
1972 std::stringstream is1, is2;
1981 return execNum1 < execNum2;
1997 if (data.
count() != 3) {
1998 g_log.
warning() <<
"Algorithm list line " + words3 +
" is not of the correct format\n";
1999 throw std::out_of_range(words3);
2021 if (data.
count() != 4) {
2022 g_log.
warning() <<
"Algorithm list line " + words4 +
" is not of the correct format\n";
2023 throw std::out_of_range(words4);
2049 const int n = spec.
dim0();
2050 const int n1 =
n - 1;
2051 for (
int i = 0; i <
n; ++i) {
2052 int si = spec(i, 0);
2053 int j0 = spec(i, 1);
2054 int j1 = i < n1 ? spec(i + 1, 1) : bins.
dim0();
2055 for (
int j = j0; j < j1; ++j) {
2056 local_workspace->flagMasked(si, bins[j], weights[j]);
2079 int blocksize,
int nchannels,
int &hist,
2081 data.
load(blocksize, hist);
2082 errors.
load(blocksize, hist);
2083 double *data_start = data();
2084 double *data_end = data_start + nchannels;
2085 double *err_start = errors();
2086 double *err_end = err_start + nchannels;
2087 double *farea_start =
nullptr;
2088 double *farea_end =
nullptr;
2089 double *xErrors_start =
nullptr;
2090 double *xErrors_end =
nullptr;
2091 size_t dx_increment = nchannels;
2096 size_t dx_input_increment = xErrors.
dim1();
2099 farea.
load(blocksize, hist);
2100 farea_start = farea();
2101 farea_end = farea_start + nchannels;
2102 rb_workspace = std::dynamic_pointer_cast<RebinnedOutput>(local_workspace);
2105 xErrors.
load(blocksize, hist);
2106 xErrors_start = xErrors();
2107 xErrors_end = xErrors_start + dx_increment;
2110 int final(hist + blocksize);
2111 while (hist <
final) {
2112 auto &
Y = local_workspace->mutableY(hist);
2113 Y.assign(data_start, data_end);
2114 data_start += nchannels;
2115 data_end += nchannels;
2116 auto &E = local_workspace->mutableE(hist);
2117 E.assign(err_start, err_end);
2118 err_start += nchannels;
2119 err_end += nchannels;
2121 MantidVec &F = rb_workspace->dataF(hist);
2122 F.assign(farea_start, farea_end);
2123 farea_start += nchannels;
2124 farea_end += nchannels;
2127 local_workspace->setSharedDx(hist, Kernel::make_cow<HistogramData::HistogramDx>(xErrors_start, xErrors_end));
2128 xErrors_start += dx_input_increment;
2129 xErrors_end += dx_input_increment;
2132 local_workspace->setSharedX(hist,
m_xbins.cowData());
2157 int blocksize,
int nchannels,
int &hist,
int &wsIndex,
2159 data.
load(blocksize, hist);
2160 errors.
load(blocksize, hist);
2161 double *data_start = data();
2162 double *data_end = data_start + nchannels;
2163 double *err_start = errors();
2164 double *err_end = err_start + nchannels;
2165 double *farea_start =
nullptr;
2166 double *farea_end =
nullptr;
2167 double *xErrors_start =
nullptr;
2168 double *xErrors_end =
nullptr;
2169 size_t dx_increment = nchannels;
2174 size_t dx_input_increment = xErrors.
dim1();
2177 farea.
load(blocksize, hist);
2178 farea_start = farea();
2179 farea_end = farea_start + nchannels;
2180 rb_workspace = std::dynamic_pointer_cast<RebinnedOutput>(local_workspace);
2183 xErrors.
load(blocksize, hist);
2184 xErrors_start = xErrors();
2185 xErrors_end = xErrors_start + dx_increment;
2188 int final(hist + blocksize);
2189 while (hist <
final) {
2190 auto &
Y = local_workspace->mutableY(wsIndex);
2191 Y.assign(data_start, data_end);
2192 data_start += nchannels;
2193 data_end += nchannels;
2194 auto &E = local_workspace->mutableE(wsIndex);
2195 E.assign(err_start, err_end);
2196 err_start += nchannels;
2197 err_end += nchannels;
2199 MantidVec &F = rb_workspace->dataF(wsIndex);
2200 F.assign(farea_start, farea_end);
2201 farea_start += nchannels;
2202 farea_end += nchannels;
2205 local_workspace->setSharedDx(wsIndex, Kernel::make_cow<HistogramData::HistogramDx>(xErrors_start, xErrors_end));
2206 xErrors_start += dx_input_increment;
2207 xErrors_end += dx_input_increment;
2209 local_workspace->setSharedX(wsIndex,
m_xbins.cowData());
2235 NXDouble &xbins,
int blocksize,
int nchannels,
int &hist,
int &wsIndex,
2237 data.
load(blocksize, hist);
2238 double *data_start = data();
2239 double *data_end = data_start + nchannels;
2240 errors.
load(blocksize, hist);
2241 double *err_start = errors();
2242 double *err_end = err_start + nchannels;
2243 double *farea_start =
nullptr;
2244 double *farea_end =
nullptr;
2245 double *xErrors_start =
nullptr;
2246 double *xErrors_end =
nullptr;
2247 size_t dx_increment = nchannels;
2252 size_t dx_input_increment = xErrors.
dim1();
2255 farea.
load(blocksize, hist);
2256 farea_start = farea();
2257 farea_end = farea_start + nchannels;
2258 rb_workspace = std::dynamic_pointer_cast<RebinnedOutput>(local_workspace);
2260 xbins.
load(blocksize, hist);
2261 const int nxbins(xbins.
dim1());
2262 double *xbin_start = xbins();
2263 double *xbin_end = xbin_start + nxbins;
2264 int final(hist + blocksize);
2267 xErrors.
load(blocksize, hist);
2268 xErrors_start = xErrors();
2269 xErrors_end = xErrors_start + dx_increment;
2272 while (hist <
final) {
2273 auto &
Y = local_workspace->mutableY(wsIndex);
2274 Y.assign(data_start, data_end);
2275 data_start += nchannels;
2276 data_end += nchannels;
2277 auto &E = local_workspace->mutableE(wsIndex);
2278 E.assign(err_start, err_end);
2279 err_start += nchannels;
2280 err_end += nchannels;
2282 MantidVec &F = rb_workspace->dataF(wsIndex);
2283 F.assign(farea_start, farea_end);
2284 farea_start += nchannels;
2285 farea_end += nchannels;
2288 local_workspace->setSharedDx(wsIndex, Kernel::make_cow<HistogramData::HistogramDx>(xErrors_start, xErrors_end));
2289 xErrors_start += dx_input_increment;
2290 xErrors_end += dx_input_increment;
2292 auto &
X = local_workspace->mutableX(wsIndex);
2293 X.assign(xbin_start, xbin_end);
2294 xbin_start += nxbins;
2323 throw std::invalid_argument(
"Spectra max is less than 0");
2326 if (maxlist >
static_cast<int>(numberofspectra) || minlist == 0) {
2328 throw std::invalid_argument(
"Inconsistent properties defined");
2337 m_spec_max =
static_cast<int>(numberofspectra);
2339 if (m_spec_max < m_spec_min || m_spec_max >
static_cast<int>(numberofspectra)) {
2340 g_log.
error(
"Invalid Spectrum min/max properties");
2341 throw std::invalid_argument(
"Inconsistent properties defined");
2365 m_spec_max =
static_cast<int>(numberofspectra);
2370 if (gen_filtered_list) {
2392 if (gen_filtered_list) {
2400 total_specs = numberofspectra;
2402 m_spec_max =
static_cast<int>(numberofspectra) + 1;
2404 if (gen_filtered_list) {
2406 for (
int j = 0; j < static_cast<int>(total_specs); j++)
2419 auto mWorkspace = std::dynamic_pointer_cast<MatrixWorkspace>(local_workspace);
2421 auto run = mWorkspace->run();
double value
The value of the point.
IPeaksWorkspace_sptr workspace
std::map< DeltaEMode::Type, std::string > index
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_FOR_NO_WSP_CHECK()
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
#define DECLARE_NEXUS_FILELOADER_ALGORITHM(classname)
DECLARE_NEXUS_FILELOADER_ALGORITHM should be used in place of the standard DECLARE_ALGORITHM macro wh...
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
Class to represent the axis of a workspace.
virtual bool isText() const
Returns true if the axis is Text.
virtual std::size_t length() const =0
Get the length of the axis.
virtual void setValue(const std::size_t &index, const double &value)=0
Sets the value at the specified index.
virtual bool isNumeric() const
Returns true if the axis is numeric.
virtual bool isSpectra() const
Returns true is the axis is a Spectra axis.
ColumnVector gives access to the column elements without alowing its resizing.
@ Load
allowed here which will be passed to the algorithm
void setHistogram(T &&...data)
Sets the Histogram associated with this spectrum.
void clearDetectorIDs()
Clear the detector IDs set.
void setSpectrumNo(specnum_t num)
Sets the the spectrum number of this spectrum.
bool hasProperty(const std::string &name) const
Does the property exist on the object.
HeldType getPropertyValueAsType(const std::string &name) const
Get the value of a property as the given TYPE.
Base MatrixWorkspace Abstract Class.
virtual ISpectrum & getSpectrum(const size_t index)=0
Return the underlying ISpectrum ptr at the given workspace index.
virtual Axis * getAxis(const std::size_t &axisIndex) const
Get a non owning pointer to a workspace axis.
Helper class for reporting progress from algorithms.
This class stores information regarding an experimental run as a series of log entries.
Class to represent a text axis of a workspace.
void setLabel(const std::size_t &index, const std::string &lbl)
Set the label at the given index.
A property class for workspaces.
static void applyLogFiltering(Mantid::API::Run &exptRun)
applies log filtering for a run
API::Workspace_sptr loadTableEntry(const Mantid::NeXus::NXEntry &entry)
Load a table.
int m_spec_min
The value of the spectrum_min property.
void loadBlock(Mantid::NeXus::NXDataSetTyped< double > &data, Mantid::NeXus::NXDataSetTyped< double > &errors, Mantid::NeXus::NXDataSetTyped< double > &farea, bool hasFArea, Mantid::NeXus::NXDouble &xErrors, bool hasXErrors, int blocksize, int nchannels, int &hist, const API::MatrixWorkspace_sptr &local_workspace)
Load a block of data into the workspace where it is assumed that the x bins have already been cached.
bool m_interval
Flag set if interval of spectra to write is set.
API::MatrixWorkspace_sptr loadNonEventEntry(Mantid::NeXus::NXData &wksp_cls, Mantid::NeXus::NXDouble &xbins, const double &progressStart, const double &progressRange, const Mantid::NeXus::NXEntry &mtd_entry, const int xlength, std::string &workspaceType)
Load a Workspace2D.
int confidence(Kernel::NexusDescriptor &descriptor) const override
Returns a confidence value that this algorithm can load a file.
void exec() override
Overwrites Algorithm method.
~LoadNexusProcessed() override
Destructor.
HistogramData::BinEdges m_xbins
The cached x binning if we have bins.
void loadNumericColumn(const Mantid::NeXus::NXData &tableData, const std::string &dataSetName, const API::ITableWorkspace_sptr &tableWs, const std::string &columnType)
Load a numeric column to the TableWorkspace.
void checkOptionalProperties(const std::size_t numberofspectra)
Validates the optional 'spectra to read' properties, if they have been set.
void correctForWorkspaceNameClash(std::string &wsName)
Add an index to the name if it already exists in the workspace.
virtual void readSpectraToDetectorMapping(Mantid::NeXus::NXEntry &mtd_entry, Mantid::API::MatrixWorkspace &ws)
std::string loadWorkspaceName(Mantid::NeXus::NXRoot &root, const std::string &entry_name)
Load the workspace name attribute if it exists.
API::Workspace_sptr loadLeanElasticPeaksEntry(Mantid::NeXus::NXEntry &entry)
Load LeanElasticPeakWorkspace.
void readInstrumentGroup(Mantid::NeXus::NXEntry &mtd_entry, API::MatrixWorkspace &local_workspace)
Read the spectra.
std::vector< std::string > extractWorkspaceNames(Mantid::NeXus::NXRoot &root, size_t nWorkspaceEntries)
Extract the workspace name.
int m_spec_max
The value of the spectrum_max property.
void loadV3DColumn(Mantid::NeXus::NXDouble &data, const API::ITableWorkspace_sptr &tableWs)
Loads a V3D column to the TableWorkspace.
bool m_list
Flag set if list of spectra to save is specifed.
void getWordsInString(const std::string &words3, std::string &w1, std::string &w2, std::string &w3)
Splits a string of exactly three words into the separate words.
virtual bool loadNexusGeometry(Mantid::API::Workspace &, const int, Kernel::Logger &, const std::string &)
Load nexus geometry and apply to workspace.
API::Workspace_sptr loadEntry(Mantid::NeXus::NXRoot &root, const std::string &entry_name, const double &progressStart, const double &progressRange)
Load a single entry.
std::vector< int > m_filtered_spec_idxs
list of spectra filtered by min/max/list, currently used only when loading data into event_workspace
void readBinMasking(const Mantid::NeXus::NXData &wksp_cls, const API::MatrixWorkspace_sptr &local_workspace)
Read the bin masking information.
bool m_shared_bins
Does the current workspace have uniform binning.
std::vector< int > m_spec_list
The value of the spectrum_list property.
Mantid::API::Workspace_sptr doAccelleratedMultiPeriodLoading(Mantid::NeXus::NXRoot &root, const std::string &entryName, Mantid::API::MatrixWorkspace_sptr &tempMatrixWorkspace, const size_t nWorkspaceEntries, const size_t p)
Accellerated multiperiod loading.
std::map< std::string, std::string > validateInputs() override
Validates the input Min < Max and Max < Maximum_Int.
API::MatrixWorkspace_sptr loadEventEntry(Mantid::NeXus::NXData &wksp_cls, Mantid::NeXus::NXDouble &xbins, const double &progressStart, const double &progressRange)
Load an event_workspace field.
std::string buildWorkspaceName(const std::string &name, const std::string &baseName, size_t wsIndex)
Create the workspace name if it's part of a group workspace.
void init() override
Overwrites Algorithm method.
MantidVec m_axis1vals
Numeric values for the second axis, if applicable.
void loadNonSpectraAxis(const API::MatrixWorkspace_sptr &local_workspace, Mantid::NeXus::NXData &data)
Load the data from a non-spectra axis (Numeric/Text) into the workspace.
API::Workspace_sptr loadPeaksEntry(Mantid::NeXus::NXEntry &entry)
Load peaks.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
std::unique_ptr<::NeXus::File > m_nexusFile
void loadVectorColumn(const Mantid::NeXus::NXData &tableData, const std::string &dataSetName, const API::ITableWorkspace_sptr &tableWs, const std::string &columnType)
Loads a vector column to the TableWorkspace.
std::size_t calculateWorkspaceSize(const std::size_t numberofspectra, bool gen_filtered_list=false)
calculates the workspace size
LoadNexusProcessed()
Default constructor.
void applyLogFiltering(const Mantid::API::Workspace_sptr &local_workspace)
applies log filtering of the loaded logs if required
void setRunNumber(int m_runNumber) override
Set the run number that measured this peak.
void setGoniometerMatrix(const Mantid::Kernel::Matrix< double > &goniometerMatrix) override
Set the goniometer rotation matrix at which this peak was measured.
void reserve(size_t num) override
Reserve a certain number of entries in event list of the specified eventType.
void switchTo(Mantid::API::EventType newType) override
Switch the EventList to use the given EventType (TOF, WEIGHTED, or WEIGHTED_NOTIME)
void addEventQuickly(const Types::Event::TofEvent &event)
Append an event to the histogram, without clearing the cache, to make it faster.
Structure describing a single-crystal peak.
Structure describing a single-crystal peak.
void setInstrument(const Geometry::Instrument_const_sptr &inst)
Set the instrument (and save the source/sample pos).
Info about a single neutron detection event, including a weight and error value, but excluding the pu...
Info about a single neutron detection event, including a weight and error value:
PeakShape : Abstract type to describes the shape of a peak.
Support for a property that holds an array of values.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
static const std::string statusLogName()
Returns the name of the log created that defines the status during a run.
static const std::string periodsLogName()
Returns the name of the log that contains all of the periods.
The Logger class is in charge of the publishing messages from the framework through various channels.
void debug(const std::string &msg)
Logs at debug level.
void notice(const std::string &msg)
Logs at notice level.
void error(const std::string &msg)
Logs at error level.
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
Defines a wrapper around a file whose internal structure can be accessed using the NeXus API.
bool pathExists(const std::string &path) const
Query if a path exists.
The concrete, templated class for properties.
Base class for properties.
virtual bool isDefault() const =0
Overriden function that returns if property has the same value that it was initialised with,...
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
@ TOK_IGNORE_EMPTY
ignore empty tokens
@ TOK_TRIM
remove leading and trailing whitespace from tokens
std::size_t count() const
Get the total number of tokens.
bool openLocal(const std::string &nxclass="")
Opens this NXClass using NXopengroup.
NXSize openNXSize(const std::string &name) const
Creates and opens a size_t dataset.
NXInt openNXInt(const std::string &name) const
Creates and opens an integer dataset.
NXDouble openNXDouble(const std::string &name) const
Creates and opens a double dataset.
void close()
Close this class.
NXClass openNXGroup(const std::string &name) const
Creates and opens an arbitrary (non-standard) class (group).
bool containsGroup(const std::string &query) const
Returns whether an individual group (or group) is present.
std::vector< NXClassInfo > & groups() const
Returns a list of all classes (or groups) in this NXClass.
NXInfo getDataSetInfo(const std::string &name) const
Returns NXInfo for a dataset.
NXDataSetTyped< T > openNXDataSet(const std::string &name) const
Templated method for creating datasets.
NXFloat openNXFloat(const std::string &name) const
Creates and opens a float dataset.
bool isValid(const std::string &path) const
Check if a path exists relative to the current class path.
NXChar openNXChar(const std::string &name) const
Creates and opens a char dataset.
std::string getString(const std::string &name) const
Returns a string.
Templated class implementation of NXDataSet.
container_T< T > & vecBuffer()
Returns a the internal buffer.
void load(const int blocksize=1, int i=-1, int j=-1, int k=-1, int l=-1) override
Implementation of the virtual NXDataSet::load(...) method.
int size() const
Returns the size of the data buffer.
int dim0() const
Returns the number of elements along the first dimension.
int rank() const
Returns the rank (number of dimensions) of the data. The maximum is 4.
void openLocal()
Opens datasets faster but the parent group must be already open.
int dim1() const
Returns the number of elements along the second dimension.
Implements NXdata Nexus class.
NXDouble openDoubleData()
Opens data of double type.
Implements NXdetector Nexus class.
Implements NXentry Nexus class.
NXData openNXData(const std::string &name) const
Opens a NXData.
NXInstrument openNXInstrument(const std::string &name) const
Opens a NXInstrument.
Implements NXinstrument Nexus class.
NXDetector openNXDetector(const std::string &name)
Opens a NXDetector.
NXhandle m_fileID
Nexus file id.
std::string path() const
Returns the absolute path to the object.
NXAttributes attributes
Attributes.
Implements NXroot Nexus class.
NXEntry openEntry(const std::string &name)
Opens an entry – a topmost Nexus class.
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< ExperimentInfo > ExperimentInfo_sptr
Shared pointer to ExperimentInfo.
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
Mantid::Kernel::StringTokenizer tokenizer
EventType
What kind of event list is being stored.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
bool UDlesserExecCount(const Mantid::NeXus::NXClassInfo &elem1, const Mantid::NeXus::NXClassInfo &elem2)
to sort the algorithmhistory vector
std::shared_ptr< RebinnedOutput > RebinnedOutput_sptr
shared pointer to the RebinnedOutput class
std::shared_ptr< PeakShapeFactory > PeakShapeFactory_sptr
Helper typedef.
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
SpecialCoordinateSystem
Special coordinate systems for Q3D.
Helper class which provides the Collimation Length for SANS instruments.
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
int32_t specnum_t
Typedef for a spectrum Number.
Eigen::Array< IntT, static_cast< int >(ND), 1 > IntArray
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Input
An input workspace.
@ Output
An output workspace.
Information about a Nexus class.
std::string nxname
name of the object
C++ implementation of NeXus classes.
NXstatus stat
return status
int rank
number of dimensions of the data
int type
type of the data, e.g. NX_CHAR, NX_FLOAT32, see napi.h
int dims[4]
sizes along each dimension