Mantid
Loading...
Searching...
No Matches
NexusClasses.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
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidAPI/Algorithm.h"
13#include "MantidAPI/Sample.h"
16#include "MantidNexus/DllConfig.h"
17
18#include <boost/container/vector.hpp>
19#include <nexus/napi.h>
20
21#include <map>
22#include <memory>
23#include <string>
24#include <vector>
25//----------------------------------------------------------------------
26// Forward declaration
27//----------------------------------------------------------------------
28
29namespace Mantid {
30namespace NeXus {
31
41struct NXInfo {
42 NXInfo() : nxname(), rank(0), dims(), type(-1), stat(NX_ERROR) {}
43 std::string nxname;
44 int rank;
45 int dims[4];
46 int type;
47 NXstatus stat;
48 operator bool() { return stat == NX_OK; }
49};
50
54 NXClassInfo() : nxname(), nxclass(), datatype(-1), stat(NX_ERROR) {}
55 std::string nxname;
56 std::string nxclass;
59 NXstatus stat;
60 operator bool() { return stat == NX_OK; }
61};
62
70
73class MANTID_NEXUS_DLL NXAttributes {
74public:
75 int n() const { return int(m_values.size()); }
76 std::vector<std::string> names() const;
77 std::vector<std::string> values() const;
78 std::string operator()(const std::string &name) const;
79 void set(const std::string &name,
80 const std::string &value);
81 void set(const std::string &name,
82 double value);
83private:
84 std::map<std::string, std::string> m_values;
85};
86
88class NXClass;
89
93class MANTID_NEXUS_DLL NXObject {
94 friend class NXDataSet;
95 friend class NXClass;
96 friend class NXRoot;
97public:
98 // Constructor
99 NXObject(const NXhandle fileID, const NXClass *parent, const std::string &name);
100 virtual ~NXObject() = default;
102 virtual std::string NX_class() const = 0;
103 // True if complies with our understanding of the www.nexusformat.org
104 // definition.
105 // virtual bool isStandard()const = 0;
107 std::string path() const { return m_path; }
109 std::string name() const;
113 NXhandle m_fileID;
114
115protected:
116 std::string m_path;
117 bool m_open;
118private:
119 NXObject() : m_fileID(), m_open(false) {}
120 void getAttributes();
121};
122
135class MANTID_NEXUS_DLL NXDataSet : public NXObject {
136public:
137 // Constructor
138 NXDataSet(const NXClass &parent, const std::string &name);
140 std::string NX_class() const override { return "SDS"; }
143 void open();
145 void openLocal();
147 int rank() const { return m_info.rank; }
149 int dims(int i) const { return i < 4 ? m_info.dims[i] : 0; }
151 int dim0() const;
153 int dim1() const;
155 int dim2() const;
157 int dim3() const;
159 std::string name() const { return m_info.nxname; }
161 int type() const { return m_info.type; }
180 virtual void load(const int blocksize = 1, int i = -1, int j = -1, int k = -1, int l = -1) {
181 // Avoid compiler warnings
182 (void)blocksize;
183 (void)i;
184 (void)j;
185 (void)k;
186 (void)l;
187 };
188
189protected:
190 void getData(void *data);
191 void getSlab(void *data, int start[], int size[]);
192
193private:
195};
196
197template <typename T>
198using container_T = std::conditional_t<std::is_same<T, bool>{}, boost::container::vector<bool>, std::vector<T>>;
199
203template <class T> class NXDataSetTyped : public NXDataSet {
204
205public:
211 NXDataSetTyped(const NXClass &parent, const std::string &name) : NXDataSet(parent, name), m_n(0) {}
217 const T *operator()() const {
218 if (m_data.empty())
219 throw std::runtime_error("Attempt to read uninitialized data from " + path());
220 return m_data.data();
221 }
222
224 if (m_data.empty())
225 throw std::runtime_error("Attempt to read uninitialized data from " + path());
226 return m_data.data();
227 }
228
235 const T &operator[](int i) const {
236 if (m_data.empty())
237 throw std::runtime_error("Attempt to read uninitialized data from " + path());
238 if (i < 0 || i >= m_n)
239 rangeError();
240 return m_data[i];
241 }
242
243 T &operator[](int i) { return const_cast<T &>(static_cast<const NXDataSetTyped &>(*this)[i]); }
251 const T &operator()(int i, int j) const { return this->operator[](i *dim1() + j); }
252 T &operator()(int i, int j) { return const_cast<T &>(static_cast<const NXDataSetTyped &>(*this)(i, j)); }
261 const T &operator()(int i, int j, int k) const { return this->operator[]((i * dim1() + j) * dim2() + k); }
262 T &operator()(int i, int j, int k) { return const_cast<T &>(static_cast<const NXDataSetTyped &>(*this)(i, j, k)); }
263
267 int size() const { return m_n; }
289 void load(const int blocksize = 1, int i = -1, int j = -1, int k = -1, int l = -1) override {
290 if (rank() > 4) {
291 throw std::runtime_error("Cannot load dataset of rank greater than 4");
292 }
293 int n = 0;
294 int start[4];
295 if (rank() == 4) {
296 if (i < 0) // load all data
297 {
298 n = dim0() * dim1() * dim2() * dim3();
299 alloc(n);
300 getData(m_data.data());
301 return;
302 } else if (j < 0) {
303 if (i >= dim0())
304 rangeError();
305 n = dim1() * dim2() * dim3();
306 start[0] = i;
307 m_size[0] = 1;
308 start[1] = 0;
309 m_size[1] = dim1();
310 start[2] = 0;
311 m_size[2] = dim2();
312 start[3] = 0;
313 m_size[3] = dim2();
314 } else if (k < 0) {
315 if (i >= dim0() || j >= dim1())
316 rangeError();
317 n = dim2() * dim3();
318 start[0] = i;
319 m_size[0] = 1;
320 start[1] = j;
321 m_size[1] = 1;
322 start[2] = 0;
323 m_size[2] = dim2();
324 start[3] = 0;
325 m_size[3] = dim2();
326 } else if (l < 0) {
327 if (i >= dim0() || j >= dim1() || k >= dim2())
328 rangeError();
329 n = dim3();
330 start[0] = i;
331 m_size[0] = 1;
332 start[1] = j;
333 m_size[1] = 1;
334 start[2] = k;
335 m_size[2] = 1;
336 start[3] = 0;
337 m_size[3] = dim2();
338 } else {
339 if (i >= dim0() || j >= dim1() || k >= dim2() || l >= dim3())
340 rangeError();
341 n = dim3();
342 start[0] = i;
343 m_size[0] = 1;
344 start[1] = j;
345 m_size[1] = 1;
346 start[2] = k;
347 m_size[2] = 1;
348 start[3] = l;
349 m_size[3] = 1;
350 }
351 } else if (rank() == 3) {
352 if (i < 0) {
353 n = dim0() * dim1() * dim2();
354 alloc(n);
355 getData(m_data.data());
356 return;
357 } else if (j < 0) {
358 if (i >= dim0())
359 rangeError();
360 n = dim1() * dim2();
361 start[0] = i;
362 m_size[0] = 1;
363 start[1] = 0;
364 m_size[1] = dim1();
365 start[2] = 0;
366 m_size[2] = dim2();
367 } else if (k < 0) {
368 if (i >= dim0() || j >= dim1())
369 rangeError();
370 int m = blocksize;
371 if (j + m > dim1())
372 m = dim1() - j;
373 n = dim2() * m;
374 start[0] = i;
375 m_size[0] = 1;
376 start[1] = j;
377 m_size[1] = m;
378 start[2] = 0;
379 m_size[2] = dim2();
380 } else {
381 if (i >= dim0() || j >= dim1() || k >= dim2())
382 rangeError();
383 n = 1;
384 start[0] = i;
385 m_size[0] = 1;
386 start[1] = j;
387 m_size[1] = 1;
388 start[2] = k;
389 m_size[2] = 1;
390 }
391 } else if (rank() == 2) {
392 if (i < 0) {
393 n = dim0() * dim1();
394 alloc(n);
395 getData(m_data.data());
396 return;
397 } else if (j < 0) {
398 if (i >= dim0())
399 rangeError();
400 int m = blocksize;
401 if (i + m > dim0())
402 m = dim0() - i;
403 n = dim1() * m;
404 start[0] = i;
405 m_size[0] = m;
406 start[1] = 0;
407 m_size[1] = dim1();
408 } else {
409 if (i >= dim0() || j >= dim1())
410 rangeError();
411 n = 1;
412 start[0] = i;
413 m_size[0] = 1;
414 start[1] = j;
415 m_size[1] = 1;
416 }
417 } else if (rank() == 1) {
418 if (i < 0) {
419 n = dim0();
420 alloc(n);
421 getData(m_data.data());
422 return;
423 } else {
424 if (i >= dim0())
425 rangeError();
426 n = 1 * blocksize;
427 start[0] = i;
428 m_size[0] = blocksize;
429 }
430 }
431 alloc(n);
432 getSlab(m_data.data(), start, m_size);
433 }
434
435private:
439 void alloc(int n) {
440 if (n <= 0) {
441 throw std::runtime_error("Attempt to load from an empty dataset " + path());
442 }
443 try {
444 if (m_n != n) {
445 m_data.resize(n);
446 m_n = n;
447 }
448 } catch (...) {
449 std::ostringstream ostr;
450 ostr << "Cannot allocate " << n * sizeof(T) << " bytes of memory to load the data";
451 throw std::runtime_error(ostr.str());
452 }
453 }
455 void rangeError() const { throw std::range_error("Nexus dataset range error"); }
456 // We cannot use an STL vector due to the dreaded std::vector<bool>
458 int m_size[4];
459 int m_n;
460};
461
474
475//-------------------- classes --------------------------//
476
487class MANTID_NEXUS_DLL NXClass : public NXObject {
488 friend class NXRoot;
489
490public:
496 NXClass(const NXClass &parent, const std::string &name);
498 std::string NX_class() const override { return "NXClass"; }
502 NXClassInfo getNextEntry();
504 // virtual void make(const std::string& path) = 0;
506 void reset();
512 bool isValid(const std::string &path) const;
519 template <class NX> NX openNXClass(const std::string &name) const {
520 NX nxc(*this, name);
521 nxc.open();
522 return nxc;
523 }
524
529 NXClass openNXGroup(const std::string &name) const { return openNXClass<NXClass>(name); }
530
536 template <class T> NXDataSetTyped<T> openNXDataSet(const std::string &name) const {
537 NXDataSetTyped<T> data(*this, name);
538 data.open();
539 return data;
540 }
541
546 NXInt openNXInt(const std::string &name) const { return openNXDataSet<int>(name); }
551 NXFloat openNXFloat(const std::string &name) const { return openNXDataSet<float>(name); }
556 NXDouble openNXDouble(const std::string &name) const { return openNXDataSet<double>(name); }
561 NXChar openNXChar(const std::string &name) const { return openNXDataSet<char>(name); }
566 NXSize openNXSize(const std::string &name) const { return openNXDataSet<std::size_t>(name); }
571 std::string getString(const std::string &name) const;
576 double getDouble(const std::string &name) const;
581 float getFloat(const std::string &name) const;
586 int getInt(const std::string &name) const;
587
589 std::vector<NXClassInfo> &groups() const { return *m_groups; }
591 bool containsGroup(const std::string &query) const;
593 std::vector<NXInfo> &datasets() const { return *m_datasets; }
598 NXInfo getDataSetInfo(const std::string &name) const;
600 bool containsDataSet(const std::string &query) const;
602 void close();
604 void open();
613 bool openLocal(const std::string &nxclass = "");
614
615protected:
616 std::shared_ptr<std::vector<NXClassInfo>> m_groups;
617 std::shared_ptr<std::vector<NXInfo>> m_datasets;
618 void readAllInfo();
619 void clear();
620private:
622 NXClass() : NXObject() { clear(); }
623};
624
625//------------------- auxiliary classes ----------------------------//
626
629class MANTID_NEXUS_DLL NXLog : public NXClass {
630public:
636 NXLog(const NXClass &parent, const std::string &name) : NXClass(parent, name) {}
638 std::string NX_class() const override { return "NXlog"; }
640 Kernel::Property *createProperty();
642 Kernel::Property *createTimeSeries(const std::string &start_time = "", const std::string &new_name = "");
643
644private:
646 Kernel::Property *createSingleValueProperty();
648 template <class TYPE>
649 Kernel::Property *parseTimeSeries(const std::string &logName, const TYPE &times, const std::string &time0 = "") {
650 std::string start_time = (!time0.empty()) ? time0 : times.attributes("start");
651 if (start_time.empty()) {
652 start_time = "2000-01-01T00:00:00";
653 }
654 auto start_t = Kernel::DateAndTimeHelpers::createFromSanitizedISO8601(start_time);
655 NXInfo vinfo = getDataSetInfo("value");
656 if (!vinfo)
657 return nullptr;
658
659 if (vinfo.dims[0] != times.dim0())
660 return nullptr;
661
662 if (vinfo.type == NX_CHAR) {
663 auto logv = new Kernel::TimeSeriesProperty<std::string>(logName);
664 NXChar value(*this, "value");
665 value.openLocal();
666 value.load();
667 for (int i = 0; i < value.dim0(); i++) {
668 auto t = start_t + boost::posix_time::seconds(int(times[i]));
669 for (int j = 0; j < value.dim1(); j++) {
670 char *c = &value(i, j);
671 if (!isprint(*c))
672 *c = ' ';
673 }
674 logv->addValue(t, std::string(value() + i * value.dim1(), value.dim1()));
675 }
676 return logv;
677 } else if (vinfo.type == NX_FLOAT64) {
678 if (logName.find("running") != std::string::npos || logName.find("period ") != std::string::npos) {
679 auto logv = new Kernel::TimeSeriesProperty<bool>(logName);
680 NXDouble value(*this, "value");
681 value.openLocal();
682 value.load();
683 for (int i = 0; i < value.dim0(); i++) {
684 auto t = start_t + boost::posix_time::seconds(int(times[i]));
685 logv->addValue(t, (value[i] == 0 ? false : true));
686 }
687 return logv;
688 }
689 NXDouble value(*this, "value");
690 return loadValues<NXDouble, TYPE>(logName, value, start_t, times);
691 } else if (vinfo.type == NX_FLOAT32) {
692 NXFloat value(*this, "value");
693 return loadValues<NXFloat, TYPE>(logName, value, start_t, times);
694 } else if (vinfo.type == NX_INT32) {
695 NXInt value(*this, "value");
696 return loadValues<NXInt, TYPE>(logName, value, start_t, times);
697 }
698 return nullptr;
699 }
700
707 template <class NX_TYPE, class TIME_TYPE>
708 Kernel::Property *loadValues(const std::string &logName, NX_TYPE &value, Types::Core::DateAndTime start_t,
709 const TIME_TYPE &times) {
710 value.openLocal();
711 auto logv = new Kernel::TimeSeriesProperty<double>(logName);
712 value.load();
713 for (int i = 0; i < value.dim0(); i++) {
714 if (i == 0 || value[i] != value[i - 1] || times[i] != times[i - 1]) {
715 auto t = start_t + boost::posix_time::seconds(int(times[i]));
716 logv->addValue(t, value[i]);
717 }
718 }
719 return logv;
720 }
721};
722
725class MANTID_NEXUS_DLL NXNote : public NXClass {
726public:
732 NXNote(const NXClass &parent, const std::string &name)
733 : NXClass(parent, name), m_author_ok(), m_data_ok(), m_description_ok() {}
735 std::string NX_class() const override { return "NXnote"; }
737 std::string author();
739 std::vector<std::string> &data();
741 std::string description();
742
743protected:
744 std::string m_author;
745 std::vector<std::string> m_data;
746 std::string m_description;
750};
751
754class MANTID_NEXUS_DLL NXBinary : public NXNote {
755public:
761 NXBinary(const NXClass &parent, const std::string &name) : NXNote(parent, name) {}
763 std::vector<char> &binary();
764
765private:
766 std::vector<char> m_binary;
767};
768
769//-------------------- main classes -------------------------------//
770
773class MANTID_NEXUS_DLL NXMainClass : public NXClass {
774public:
780 NXMainClass(const NXClass &parent, const std::string &name) : NXClass(parent, name) {}
785 NXLog openNXLog(const std::string &name) { return openNXClass<NXLog>(name); }
790 NXNote openNXNote(const std::string &name) { return openNXClass<NXNote>(name); }
791};
792
795class MANTID_NEXUS_DLL NXData : public NXMainClass {
796public:
802 NXData(const NXClass &parent, const std::string &name);
804 std::string NX_class() const override { return "NXdata"; }
807 template <typename T> NXDataSetTyped<T> openData() {
808 for (std::vector<NXInfo>::const_iterator it = datasets().begin(); it != datasets().end(); ++it) {
809 NXDataSet dset(*this, it->nxname);
810 dset.open();
811 // std::cerr << "NXData signal of " << it->nxname << " = " <<
812 // dset.attributes("signal") << "\n";
813 if (dset.attributes("signal") == "1") {
814 return openNXDataSet<T>(it->nxname);
815 }
816 }
817 // You failed to find the signal.
818 // So try to just open the "data" entry directly
819 return openNXDataSet<T>("data");
820 // throw std::runtime_error("NXData does not seem to contain the data");
821 // return NXDataSetTyped<T>(*this,"");
822 }
824 NXDouble openDoubleData() { return openData<double>(); }
826 NXFloat openFloatData() { return openData<float>(); }
828 NXInt openIntData() { return openData<int>(); }
830 NXSize openSizeData() { return openData<std::size_t>(); }
832 NXUInt openUIntData() { return openData<unsigned int>(); }
833};
834
837class MANTID_NEXUS_DLL NXDetector : public NXMainClass {
838public:
844 NXDetector(const NXClass &parent, const std::string &name) : NXMainClass(parent, name) {}
846 std::string NX_class() const override { return "NXdetector"; }
848 NXFloat openDistance() { return openNXFloat("distance"); }
850 NXFloat openAzimuthalAngle() { return openNXFloat("azimuthal_angle"); }
852 NXFloat openPolarAngle() { return openNXFloat("polar_angle"); }
853};
854
857class MANTID_NEXUS_DLL NXDiskChopper : public NXMainClass {
858public:
864 NXDiskChopper(const NXClass &parent, const std::string &name) : NXMainClass(parent, name) {}
866 std::string NX_class() const override { return "NXdisk_chopper"; }
868 NXFloat openRotationSpeed() { return openNXFloat("rotation_speed"); }
869};
870
873class MANTID_NEXUS_DLL NXInstrument : public NXMainClass {
874public:
880 NXInstrument(const NXClass &parent, const std::string &name) : NXMainClass(parent, name) {}
882 std::string NX_class() const override { return "NXinstrument"; }
887 NXDetector openNXDetector(const std::string &name) { return openNXClass<NXDetector>(name); }
888
893 NXDiskChopper openNXDiskChopper(const std::string &name) { return openNXClass<NXDiskChopper>(name); }
894};
895
898class MANTID_NEXUS_DLL NXEntry : public NXMainClass {
899public:
905 NXEntry(const NXClass &parent, const std::string &name) : NXMainClass(parent, name) {}
907 std::string NX_class() const override { return "NXentry"; }
912 NXData openNXData(const std::string &name) const { return openNXClass<NXData>(name); }
917 NXInstrument openNXInstrument(const std::string &name) const { return openNXClass<NXInstrument>(name); }
918};
919
922class MANTID_NEXUS_DLL NXRoot : public NXClass {
923public:
924 // Constructor
925 NXRoot(std::string fname);
926 // Constructor
927 NXRoot(std::string fname, const std::string &entry);
929 ~NXRoot() override;
931 std::string NX_class() const override { return "NXroot"; }
934 bool isStandard() const;
939 NXEntry openEntry(const std::string &name) { return openNXClass<NXEntry>(name); }
940 NXEntry openFirstEntry();
941
942private:
943 const std::string m_filename;
944};
945
946} // namespace NeXus
947} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
Base class for properties.
Definition: Property.h:94
A specialised Property class for holding a series of time-value pairs.
std::map< std::string, std::string > m_values
the list of attributes
Definition: NexusClasses.h:84
int n() const
number of attributes
Definition: NexusClasses.h:75
Implements NXnote Nexus class with binary data.
Definition: NexusClasses.h:754
std::vector< char > m_binary
content
Definition: NexusClasses.h:766
NXBinary(const NXClass &parent, const std::string &name)
Constructor.
Definition: NexusClasses.h:761
The base class for a Nexus class (group).
Definition: NexusClasses.h:487
std::vector< NXInfo > & datasets() const
Returns a list of all datasets in this NXClass.
Definition: NexusClasses.h:593
NX openNXClass(const std::string &name) const
Templated method for creating derived NX classes.
Definition: NexusClasses.h:519
NXSize openNXSize(const std::string &name) const
Creates and opens a size_t dataset.
Definition: NexusClasses.h:566
NXInt openNXInt(const std::string &name) const
Creates and opens an integer dataset.
Definition: NexusClasses.h:546
NXDouble openNXDouble(const std::string &name) const
Creates and opens a double dataset.
Definition: NexusClasses.h:556
std::shared_ptr< std::vector< NXClassInfo > > m_groups
Holds info about the child NXClasses.
Definition: NexusClasses.h:616
NXClass()
Pricate constructor.
Definition: NexusClasses.h:622
std::string NX_class() const override
The NX class identifier.
Definition: NexusClasses.h:498
NXClass openNXGroup(const std::string &name) const
Creates and opens an arbitrary (non-standard) class (group).
Definition: NexusClasses.h:529
std::vector< NXClassInfo > & groups() const
Returns a list of all classes (or groups) in this NXClass.
Definition: NexusClasses.h:589
std::shared_ptr< std::vector< NXInfo > > m_datasets
Holds info about the datasets in this NXClass.
Definition: NexusClasses.h:617
NXDataSetTyped< T > openNXDataSet(const std::string &name) const
Templated method for creating datasets.
Definition: NexusClasses.h:536
NXFloat openNXFloat(const std::string &name) const
Creates and opens a float dataset.
Definition: NexusClasses.h:551
NXChar openNXChar(const std::string &name) const
Creates and opens a char dataset.
Definition: NexusClasses.h:561
Templated class implementation of NXDataSet.
Definition: NexusClasses.h:203
T & operator()(int i, int j)
Definition: NexusClasses.h:252
const T & operator()(int i, int j) const
Returns a value assuming the data is a two-dimensional array.
Definition: NexusClasses.h:251
NXDataSetTyped(const NXClass &parent, const std::string &name)
Constructor.
Definition: NexusClasses.h:211
container_T< T > m_data
The data buffer.
Definition: NexusClasses.h:457
int m_size[4]
The sizes of the loaded data.
Definition: NexusClasses.h:458
T & operator()(int i, int j, int k)
Definition: NexusClasses.h:262
container_T< T > & vecBuffer()
Returns a the internal buffer.
Definition: NexusClasses.h:265
const T & operator[](int i) const
Returns the i-th value in the internal buffer.
Definition: NexusClasses.h:235
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.
Definition: NexusClasses.h:289
const T & operator()(int i, int j, int k) const
Returns a value assuming the data is a tree-dimensional array.
Definition: NexusClasses.h:261
void rangeError() const
A shortcut to "throw std::range_error("Nexus dataset range error");".
Definition: NexusClasses.h:455
int m_n
The buffer size.
Definition: NexusClasses.h:459
void alloc(int n)
Allocates memory for the data buffer.
Definition: NexusClasses.h:439
int size() const
Returns the size of the data buffer.
Definition: NexusClasses.h:267
const T * operator()() const
Returns a pointer to the internal data buffer.
Definition: NexusClasses.h:217
Abstract base class for a Nexus data set.
Definition: NexusClasses.h:135
virtual void load(const int blocksize=1, int i=-1, int j=-1, int k=-1, int l=-1)
Load the data from the file.
Definition: NexusClasses.h:180
int dim2() const
Returns the number of elements along the third dimension.
void getData(void *data)
Wrapper to the NXgetdata.
int dim0() const
Returns the number of elements along the first dimension.
void open()
Opens the data set.
std::string NX_class() const override
NX class name. Returns "SDS".
Definition: NexusClasses.h:140
int type() const
Returns the Nexus type of the data. The types are defied in napi.h.
Definition: NexusClasses.h:161
std::string name() const
Returns the name of the data set.
Definition: NexusClasses.h:159
void getSlab(void *data, int start[], int size[])
Wrapper to the NXgetslab.
int rank() const
Returns the rank (number of dimensions) of the data. The maximum is 4.
Definition: NexusClasses.h:147
int dim3() const
Returns the number of elements along the fourth dimension.
int dims(int i) const
Returns the number of elements along i-th dimension.
Definition: NexusClasses.h:149
NXInfo m_info
Holds the data info.
Definition: NexusClasses.h:194
int dim1() const
Returns the number of elements along the second dimension.
Implements NXdata Nexus class.
Definition: NexusClasses.h:795
NXFloat openFloatData()
Opens data of float type.
Definition: NexusClasses.h:826
NXDouble openDoubleData()
Opens data of double type.
Definition: NexusClasses.h:824
std::string NX_class() const override
Nexus class id.
Definition: NexusClasses.h:804
NXUInt openUIntData()
Opens data of unsigned int type.
Definition: NexusClasses.h:832
NXInt openIntData()
Opens data of int type.
Definition: NexusClasses.h:828
NXDataSetTyped< T > openData()
Opens the dataset within this NXData with signal=1 attribute.
Definition: NexusClasses.h:807
NXSize openSizeData()
Opens data of size type.
Definition: NexusClasses.h:830
Implements NXdetector Nexus class.
Definition: NexusClasses.h:837
NXDetector(const NXClass &parent, const std::string &name)
Constructor.
Definition: NexusClasses.h:844
NXFloat openAzimuthalAngle()
Opens the dataset containing pixel azimuthal angles.
Definition: NexusClasses.h:850
NXFloat openDistance()
Opens the dataset containing pixel distances.
Definition: NexusClasses.h:848
std::string NX_class() const override
Nexus class id.
Definition: NexusClasses.h:846
NXFloat openPolarAngle()
Opens the dataset containing pixel polar angles.
Definition: NexusClasses.h:852
Implements NXdisk_chopper Nexus class.
Definition: NexusClasses.h:857
NXFloat openRotationSpeed()
Opens the dataset containing pixel distances.
Definition: NexusClasses.h:868
std::string NX_class() const override
Nexus class id.
Definition: NexusClasses.h:866
NXDiskChopper(const NXClass &parent, const std::string &name)
Constructor.
Definition: NexusClasses.h:864
Implements NXentry Nexus class.
Definition: NexusClasses.h:898
NXData openNXData(const std::string &name) const
Opens a NXData.
Definition: NexusClasses.h:912
NXEntry(const NXClass &parent, const std::string &name)
Constructor.
Definition: NexusClasses.h:905
std::string NX_class() const override
Nexus class id.
Definition: NexusClasses.h:907
NXInstrument openNXInstrument(const std::string &name) const
Opens a NXInstrument.
Definition: NexusClasses.h:917
Implements NXinstrument Nexus class.
Definition: NexusClasses.h:873
NXDiskChopper openNXDiskChopper(const std::string &name)
Opens a NXDetector.
Definition: NexusClasses.h:893
NXInstrument(const NXClass &parent, const std::string &name)
Constructor.
Definition: NexusClasses.h:880
NXDetector openNXDetector(const std::string &name)
Opens a NXDetector.
Definition: NexusClasses.h:887
std::string NX_class() const override
Nexus class id.
Definition: NexusClasses.h:882
Implements NXlog Nexus class.
Definition: NexusClasses.h:629
Kernel::Property * loadValues(const std::string &logName, NX_TYPE &value, Types::Core::DateAndTime start_t, const TIME_TYPE &times)
Loads the values in the log into the workspace.
Definition: NexusClasses.h:708
Kernel::Property * parseTimeSeries(const std::string &logName, const TYPE &times, const std::string &time0="")
Parse a time series.
Definition: NexusClasses.h:649
std::string NX_class() const override
Nexus class id.
Definition: NexusClasses.h:638
NXLog(const NXClass &parent, const std::string &name)
Constructor.
Definition: NexusClasses.h:636
Main class is the one that can contain auxiliary classes.
Definition: NexusClasses.h:773
NXNote openNXNote(const std::string &name)
Opens a NXNote class.
Definition: NexusClasses.h:790
NXMainClass(const NXClass &parent, const std::string &name)
Constructor.
Definition: NexusClasses.h:780
NXLog openNXLog(const std::string &name)
Opens a NXLog class.
Definition: NexusClasses.h:785
Implements NXnote Nexus class.
Definition: NexusClasses.h:725
bool m_data_ok
data loaded indicator
Definition: NexusClasses.h:748
std::string m_author
author
Definition: NexusClasses.h:744
bool m_author_ok
author loaded indicator
Definition: NexusClasses.h:747
std::string NX_class() const override
Nexus class id.
Definition: NexusClasses.h:735
bool m_description_ok
description loaded indicator
Definition: NexusClasses.h:749
NXNote(const NXClass &parent, const std::string &name)
Constructor.
Definition: NexusClasses.h:732
std::string m_description
description
Definition: NexusClasses.h:746
std::vector< std::string > m_data
content
Definition: NexusClasses.h:745
The base abstract class for NeXus classes and data sets.
Definition: NexusClasses.h:93
NXhandle m_fileID
Nexus file id.
Definition: NexusClasses.h:113
std::string m_path
Keeps the absolute path to the object.
Definition: NexusClasses.h:116
virtual ~NXObject()=default
bool m_open
Set to true if the object has been open.
Definition: NexusClasses.h:117
NXObject()
Private default constructor.
Definition: NexusClasses.h:119
std::string path() const
Returns the absolute path to the object.
Definition: NexusClasses.h:107
virtual std::string NX_class() const =0
Return the NX class name for a class (HDF group) or "SDS" for a data set;.
NXAttributes attributes
Attributes.
Definition: NexusClasses.h:111
Implements NXroot Nexus class.
Definition: NexusClasses.h:922
const std::string m_filename
The file name.
Definition: NexusClasses.h:943
std::string NX_class() const override
Return the NX class for a class (HDF group) or "SDS" for a data set;.
Definition: NexusClasses.h:931
NXEntry openEntry(const std::string &name)
Opens an entry – a topmost Nexus class.
Definition: NexusClasses.h:939
std::conditional_t< std::is_same< T, bool >{}, boost::container::vector< bool >, std::vector< T > > container_T
Definition: NexusClasses.h:198
const int g_processed_blocksize
LoadNexusProcessed and SaveNexusProcessed need to share some attributes, put them at namespace level ...
Definition: NexusClasses.h:69
Helper class which provides the Collimation Length for SANS instruments.
Information about a Nexus class.
Definition: NexusClasses.h:53
std::string nxclass
NX class of the object or "SDS" if a dataset.
Definition: NexusClasses.h:56
std::string nxname
name of the object
Definition: NexusClasses.h:55
int datatype
NX data type if a dataset, e.g.
Definition: NexusClasses.h:57
C++ implementation of NeXus classes.
Definition: NexusClasses.h:41
NXstatus stat
return status
Definition: NexusClasses.h:47
int rank
number of dimensions of the data
Definition: NexusClasses.h:44
int type
type of the data, e.g. NX_CHAR, NX_FLOAT32, see napi.h
Definition: NexusClasses.h:46
int dims[4]
sizes along each dimension
Definition: NexusClasses.h:45
std::string nxname
name of the object
Definition: NexusClasses.h:43