Mantid
Loading...
Searching...
No Matches
SaveNexusProcessed.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
10#include "MantidAPI/Progress.h"
11#include "MantidDataHandling/DllConfig.h"
13#include "MantidNexus/NexusFile.h"
14#include <climits>
15#include <optional>
16
17namespace Mantid {
18namespace Nexus {
19class NexusFileIO;
20}
21namespace DataHandling {
37class MANTID_DATAHANDLING_DLL SaveNexusProcessed : public API::Algorithm {
38public:
40 const std::string name() const override { return "SaveNexusProcessed"; }
42 const std::string summary() const override {
43 return "The SaveNexusProcessed algorithm will write the given Mantid "
44 "workspace to a Nexus file. SaveNexusProcessed may be invoked by "
45 "SaveNexus.";
46 }
47
49 int version() const override { return 1; }
50 const std::vector<std::string> seeAlso() const override { return {"SaveNexus", "LoadNexusProcessed"}; }
52 const std::string category() const override { return "DataHandling\\Nexus"; }
53
54 void saveSpectraDetectorMapNexus(const API::MatrixWorkspace &ws, Nexus::File *file, const std::vector<int> &wsIndices,
55 const NXcompression compression = NXcompression::LZW) const;
56
57 void saveSpectrumNumbersNexus(const API::MatrixWorkspace &ws, Nexus::File *file, const std::vector<int> &wsIndices,
58 const NXcompression compression = NXcompression::LZW) const;
59
60 virtual bool saveLegacyInstrument() { return true; }
61
62protected:
64 bool processGroups() override;
65
67 void init() override;
69 void exec() override;
70
71private:
72 void getWSIndexList(std::vector<int> &indices, const Mantid::API::MatrixWorkspace_const_sptr &matrixWorkspace);
73
74 template <class T>
75 static void appendEventListData(const std::vector<T> &events, size_t offset, double *tofs, float *weights,
76 float *errorSquareds, int64_t *pulsetimes);
77
78 void execEvent(const Mantid::Nexus::NexusFileIO *nexusFile, const bool uniformSpectra, const bool raggedSpectra,
79 const std::vector<int> &spec);
81 void setOtherProperties(IAlgorithm *alg, const std::string &propertyName, const std::string &propertyValue,
82 int perioidNum) override;
83 void doExec(const Mantid::API::Workspace_sptr &inputWorkspace, std::shared_ptr<Mantid::Nexus::NexusFileIO> &nexusFile,
84 const bool keepFile = false, std::optional<size_t> entryNumber = std::optional<size_t>());
85
91 double m_timeProgInit{0.0};
93 std::unique_ptr<API::Progress> m_progress;
94};
95
96} // namespace DataHandling
97} // namespace Mantid
NXcompression
The available compression types:
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
IAlgorithm is the interface implemented by the Algorithm base class.
Definition IAlgorithm.h:45
Base MatrixWorkspace Abstract Class.
DataHandling/SaveNexusProcessed.h.
DataObjects::EventWorkspace_const_sptr m_eventWorkspace
Pointer to the local workspace, cast to EventWorkspace.
const std::string summary() const override
Summary of algorithms purpose.
API::MatrixWorkspace_const_sptr m_inputWorkspace
Pointer to the local workspace.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
int version() const override
Algorithm's version for identification overriding a virtual method.
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
std::unique_ptr< API::Progress > m_progress
Progress bar.
Utility methods for saving Mantid Workspaces in NeXus format.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< const EventWorkspace > EventWorkspace_const_sptr
shared pointer to a const Workspace2D
Helper class which provides the Collimation Length for SANS instruments.