|
Mantid
|
Utility methods for saving Mantid Workspaces in NeXus format. More...
#include <NeXus/SaveNexusProcessedHelper.h>
Public Types | |
| using | optional_size_t = std::optional< size_t > |
Public Member Functions | |
| void | closeGroup () |
| Close the group. | |
| void | closeNexusFile () |
| close the nexus file | |
| std::shared_ptr< Nexus::File > | filehandle () const |
| Nexus file handle. | |
| NexusFileIO () | |
| Default constructor. | |
| NexusFileIO (API::Progress *prog) | |
| Contructor with Progress supplied. | |
| void | openNexusWrite (const std::string &fileName, optional_size_t entryNumber=optional_size_t(), const bool append_to_file=true) |
| open the nexus file for writing | |
| void | resetProgress (Mantid::API::Progress *prog) |
| Reset the pointer to the progress object. | |
| template<typename NumT > | |
| void | writeData (const char *name, NXnumtype datatype, Nexus::DimVector dims_array, NumT const *data, bool compress=false) const |
| Write out an array to the open file. | |
| bool | writeNexusBinMasking (const API::MatrixWorkspace_const_sptr &ws) const |
| write bin masking information | |
| int | writeNexusProcessedData2D (const API::MatrixWorkspace_const_sptr &localworkspace, const bool &uniformSpectra, const bool &raggedSpectra, const std::vector< int > &indices, const std::string &group_name, bool write2Ddata) const |
| write the workspace data | |
| int | writeNexusProcessedDataEventCombined (const DataObjects::EventWorkspace_const_sptr &ws, std::vector< int64_t > const &indices, double const *tofs, float const *weights, float const *errorSquareds, int64_t const *pulsetimes, bool compress) const |
| Write out a combined chunk of event data. | |
| int | writeNexusProcessedHeader (const std::string &title, const std::string &wsName="") const |
| write the header ifon for the Mantid workspace format | |
| int | writeNexusTableWorkspace (const API::ITableWorkspace_const_sptr &itableworkspace, const char *group_name) const |
| write table workspace | |
| ~NexusFileIO () | |
| Destructor. | |
Private Member Functions | |
| int | findMantidWSEntries () const |
| search for exisiting MantidWorkpace_n entries in opened file | |
| template<typename VecType , typename ElemType > | |
| void | writeNexusVectorColumn (const API::Column_const_sptr &col, const std::string &columnName, NXnumtype nexusType, const std::string &interpret_as) const |
| Writes given vector column to the currently open Nexus file. | |
| bool | writeNxValue (const std::string &name, const std::string &value, const std::vector< std::string > &attributes, const std::vector< std::string > &avalues) const |
| Write a simple value plus possible attributes. | |
| template<typename ColumnT , typename NexusT > | |
| void | writeTableColumn (NXnumtype type, const std::string &interpret_as, const API::Column &col, const std::string &columnName) const |
| Save a numeric columns of a TableWorkspace to currently open nexus file. | |
Private Attributes | |
| std::shared_ptr< Nexus::File > | m_filehandle |
| C++ API file handle. | |
| std::string | m_filename |
| nexus file name | |
| NXcompression | m_nexuscompression |
| Nexus compression method. | |
| API::Progress * | m_progress |
| Allow an externally supplied progress object to be used. | |
Utility methods for saving Mantid Workspaces in NeXus format.
This class interfaces to the C Nexus API. This is written for use by Save and Load NexusProcessed classes, though it could be extended to other Nexus formats. It might be replaced in future by methods using the new Nexus C++ API.
Definition at line 39 of file SaveNexusProcessedHelper.h.
| using Mantid::Nexus::NexusFileIO::optional_size_t = std::optional<size_t> |
Definition at line 43 of file SaveNexusProcessedHelper.h.
| Mantid::Nexus::NexusFileIO::NexusFileIO | ( | ) |
Default constructor.
Empty default constructor.
Definition at line 47 of file SaveNexusProcessedHelper.cpp.
| Mantid::Nexus::NexusFileIO::NexusFileIO | ( | API::Progress * | prog | ) |
Contructor with Progress supplied.
Constructor that supplies a progress object.
Definition at line 51 of file SaveNexusProcessedHelper.cpp.
| Mantid::Nexus::NexusFileIO::~NexusFileIO | ( | ) |
Destructor.
Definition at line 775 of file SaveNexusProcessedHelper.cpp.
| void Mantid::Nexus::NexusFileIO::closeGroup | ( | ) |
Close the group.
Definition at line 152 of file SaveNexusProcessedHelper.cpp.
References m_filehandle.
| void Mantid::Nexus::NexusFileIO::closeNexusFile | ( | ) |
close the nexus file
Definition at line 155 of file SaveNexusProcessedHelper.cpp.
References m_filehandle.
|
inline |
Nexus file handle.
Definition at line 87 of file SaveNexusProcessedHelper.h.
|
private |
search for exisiting MantidWorkpace_n entries in opened file
Definition at line 706 of file SaveNexusProcessedHelper.cpp.
References count, and m_filehandle.
Referenced by openNexusWrite().
| void Mantid::Nexus::NexusFileIO::openNexusWrite | ( | const std::string & | fileName, |
| NexusFileIO::optional_size_t | entryNumber = optional_size_t(), |
||
| const bool | append_to_file = true |
||
| ) |
open the nexus file for writing
Definition at line 82 of file SaveNexusProcessedHelper.cpp.
References count, CREATE5, findMantidWSEntries(), m_filehandle, m_filename, and RDWR.
| void Mantid::Nexus::NexusFileIO::resetProgress | ( | Mantid::API::Progress * | prog | ) |
Reset the pointer to the progress object.
Definition at line 54 of file SaveNexusProcessedHelper.cpp.
References m_progress.
| void Mantid::Nexus::NexusFileIO::writeData | ( | const char * | name, |
| NXnumtype | datatype, | ||
| Nexus::DimVector | dims_array, | ||
| NumT const * | data, | ||
| bool | compress = false |
||
| ) | const |
Write out an array to the open file.
Definition at line 691 of file SaveNexusProcessedHelper.cpp.
References m_filehandle, m_nexuscompression, and name.
Referenced by writeNexusProcessedDataEventCombined(), writeNexusVectorColumn(), and writeTableColumn().
| bool Mantid::Nexus::NexusFileIO::writeNexusBinMasking | ( | const API::MatrixWorkspace_const_sptr & | ws | ) | const |
write bin masking information
Write bin masking information.
| ws | :: The workspace |
Definition at line 726 of file SaveNexusProcessedHelper.cpp.
References NXnumtype::FLOAT64, NXnumtype::INT32, m_filehandle, and NXnumtype::UINT64.
Referenced by writeNexusProcessedData2D().
| int Mantid::Nexus::NexusFileIO::writeNexusProcessedData2D | ( | const API::MatrixWorkspace_const_sptr & | localworkspace, |
| const bool & | uniformSpectra, | ||
| const bool & | raggedSpectra, | ||
| const std::vector< int > & | indices, | ||
| const std::string & | group_name, | ||
| bool | write2Ddata | ||
| ) | const |
write the workspace data
Write out a MatrixWorkspace's data as a 2D matrix.
Use writeNexusProcessedDataEvent if writing an EventWorkspace.
Definition at line 276 of file SaveNexusProcessedHelper.cpp.
References NXnumtype::CHAR, Mantid::API::MatrixWorkspace::dx(), Mantid::API::MatrixWorkspace::e(), NXnumtype::FLOAT64, Mantid::API::Axis::isSpectra(), Mantid::API::Axis::isText(), Mantid::API::Axis::label(), Mantid::API::Axis::length(), m_filehandle, m_nexuscompression, m_progress, NONE, Mantid::DataObjects::RebinnedOutput::readF(), Mantid::Kernel::ProgressBase::reportIncrement(), Mantid::API::Axis::unit(), writeNexusBinMasking(), Mantid::API::MatrixWorkspace::x(), and Mantid::API::MatrixWorkspace::y().
Referenced by Mantid::DataHandling::SaveNexusProcessed::execEvent().
| int Mantid::Nexus::NexusFileIO::writeNexusProcessedDataEventCombined | ( | const DataObjects::EventWorkspace_const_sptr & | ws, |
| std::vector< int64_t > const & | indices, | ||
| double const * | tofs, | ||
| float const * | weights, | ||
| float const * | errorSquareds, | ||
| int64_t const * | pulsetimes, | ||
| bool | compress | ||
| ) | const |
Write out a combined chunk of event data.
| ws | :: an EventWorkspace |
| indices | :: array of event list indexes |
| tofs | :: array of TOFs |
| weights | :: array of event weights |
| errorSquareds | :: array of event squared errors |
| pulsetimes | :: array of pulsetimes |
| compress | :: if true, compress the entry |
Definition at line 652 of file SaveNexusProcessedHelper.cpp.
References NXnumtype::FLOAT32, NXnumtype::FLOAT64, NXnumtype::INT64, m_filehandle, m_nexuscompression, and writeData().
Referenced by Mantid::DataHandling::SaveNexusProcessed::execEvent().
| int Mantid::Nexus::NexusFileIO::writeNexusProcessedHeader | ( | const std::string & | title, |
| const std::string & | wsName = "" |
||
| ) | const |
write the header ifon for the Mantid workspace format
Write Nexus mantid workspace header fields for the NXentry/IXmantid/NXprocessed field.
The URLs are not correct as they do not exist presently, but follow the format for other Nexus specs.
| title | :: title field. |
| wsName | :: workspace name. |
Definition at line 170 of file SaveNexusProcessedHelper.cpp.
References writeNxValue().
| int Mantid::Nexus::NexusFileIO::writeNexusTableWorkspace | ( | const API::ITableWorkspace_const_sptr & | itableworkspace, |
| const char * | group_name | ||
| ) | const |
write table workspace
Write out a table Workspace's.
Definition at line 544 of file SaveNexusProcessedHelper.cpp.
References NXnumtype::CHAR, NXnumtype::FLOAT32, NXnumtype::FLOAT64, NXnumtype::INT32, NXnumtype::INT64, LZW, m_filehandle, std::to_string(), NXnumtype::UINT32, NXnumtype::UINT64, and NXnumtype::UINT8.
|
private |
Writes given vector column to the currently open Nexus file.
| col | :: Column to write |
| columnName | :: Name of NXdata to write to |
| nexusType | :: Nexus type to use to store data |
| interpret_as | :: Name of the type to use for "interpret_as" attribute |
Definition at line 484 of file SaveNexusProcessedHelper.cpp.
References m_filehandle, Mantid::API::ConstColumnVector< T >::size(), and writeData().
|
inlineprivate |
Write a simple value plus possible attributes.
Write a single valued entry to the Nexus file (specialization for a string)
| name | :: The name of the entry |
| value | :: The value of the entry |
| attributes | :: A list of attributes 1:1 mapped to their values in the avalues argument |
| avalues | :: A list of attribute values in the same order as the attributes argument |
Definition at line 126 of file SaveNexusProcessedHelper.h.
References m_filehandle, name, and value.
Referenced by writeNexusProcessedHeader().
|
private |
Save a numeric columns of a TableWorkspace to currently open nexus file.
| type | :: Nexus code for the element data type. |
| interpret_as | :: Value of the interpret_as attribute. |
| col | :: Reference to the column being svaed. |
| columnName | :: Name of the nexus data set in which the column values are saved. |
Definition at line 447 of file SaveNexusProcessedHelper.cpp.
References Mantid::API::Column::cell(), m_filehandle, Mantid::API::Column::size(), and writeData().
|
private |
C++ API file handle.
Definition at line 91 of file SaveNexusProcessedHelper.h.
Referenced by closeGroup(), closeNexusFile(), findMantidWSEntries(), openNexusWrite(), writeData(), writeNexusBinMasking(), writeNexusProcessedData2D(), writeNexusProcessedDataEventCombined(), writeNexusTableWorkspace(), writeNexusVectorColumn(), writeNxValue(), and writeTableColumn().
|
private |
nexus file name
Definition at line 103 of file SaveNexusProcessedHelper.h.
Referenced by openNexusWrite().
|
private |
Nexus compression method.
Definition at line 93 of file SaveNexusProcessedHelper.h.
Referenced by writeData(), writeNexusProcessedData2D(), and writeNexusProcessedDataEventCombined().
|
private |
Allow an externally supplied progress object to be used.
Definition at line 95 of file SaveNexusProcessedHelper.h.
Referenced by resetProgress(), and writeNexusProcessedData2D().