7 #include "NeXusFile.hpp"
8 #include "NeXusStream.hpp"
35 int writeData(
const char* data_name,
const std::vector<T>& value)
39 return writeData(data_name, &(value[0]), static_cast<int>(value.size()));
43 return writeData(data_name, static_cast<T*>(NULL), 0);
49 return s1.size() < s2.size();
53 int writeData(
const char* data_name,
const std::vector<std::string>& value)
56 std::vector<std::string>::const_iterator it = std::max_element(value.begin(), value.end(),
string_len_lt);
57 if (value.size() > 0 && it != value.end())
59 dims_array[0] =
static_cast<int>(value.size());
60 dims_array[1] =
static_cast<int>(it->size());
61 int n = dims_array[0] * dims_array[1];
62 char* char_array =
new char[n];
63 memset(char_array,
' ', n);
64 for(
int i=0; i<dims_array[0]; i++)
66 strncpy(char_array + i * dims_array[1], value[i].c_str(), value[i].size());
68 writeData(data_name, char_array, dims_array[0], dims_array[1]);
87 int getLink(
const char* name,
const char* nxclass, NXlink& link);
88 int makeLink(
const char* name,
const char* nxclass, NXlink& link);
89 int getLink(
const char* name, NXlink& link) {
return getLink(name, NULL, link); }
91 int writeData(
const char* data_name,
int value);
92 int writeData(
const char* data_name,
unsigned value) {
return writeData(data_name, (
int)value); }
94 int writeData(
const char* data_name,
unsigned long value) {
return writeData(data_name, (
long)value); }
95 int writeData(
const char* data_name,
float value);
96 int writeData(
const char* data_name,
double value);
97 int writeData(
const char* data_name, int64_t value);
98 int writeData(
const char* data_name, uint64_t value);
99 int writeData(
const std::string& data_name,
const std::string& value)
101 return writeData(data_name.c_str(), value.c_str());
103 int writeAttribute(
const std::string& data_name,
const std::string& attr_name,
const std::string& value)
105 return writeAttribute(data_name.c_str(), attr_name.c_str(), value.c_str());
108 int writeAttribute(
const char* data_name,
const char* attr_name,
int value);
109 int writeAttribute(
const char* data_name,
const char* attr_name,
float value);
110 int writeAttribute(
const char* data_name,
const char* attr_name,
double value);
111 int writeData(
const char* data_name,
const int64_t* value,
const int* dims_array,
int ndims);
112 int writeData(
const char* data_name,
const uint64_t* value,
const int* dims_array,
int ndims);
113 int writeData(
const char* data_name,
const int* value,
const int* dims_array,
int ndims);
114 int writeData(
const char* data_name,
const unsigned int* value,
const int* dims_array,
int ndims);
115 int writeData(
const char* data_name,
const float* value,
const int* dims_array,
int ndims);
116 int writeData(
const char* data_name,
const double* value,
const int* dims_array,
int ndims);
117 int writeData(
const char* data_name,
const int64_t* value,
int len);
118 int writeData(
const char* data_name,
const uint64_t* value,
int len);
119 int writeData(
const char* data_name,
const int* value,
int len);
120 int writeData(
const char* data_name,
const unsigned int* value,
int len);
121 int writeData(
const char* data_name,
const float* value,
int len);
122 int writeData(
const char* data_name,
const double* value,
int len);
123 int writeData(
const char* data_name,
const int* value,
int dim1,
int dim2);
124 int writeData(
const char* data_name,
const unsigned long* value,
int dim1,
int dim2) {
return writeData(data_name, (
const int*)value, dim1, dim2); }
125 int writeData(
const char* data_name,
const float* value,
int dim1,
int dim2);
126 int writeData(
const char* data_name,
const double* value,
int dim1,
int dim2);
127 int writeData(
const char* data_name,
const char* value);
128 int writeData(
const char* data_name,
const char* value,
int len);
129 int writeData(
const char* data_name,
const char* value,
int dim1,
int dim2);
130 int makeData(
const char* data_name,
int nxtype,
const int* dims_array,
int ndims);
131 int makeDataChunked(
const char* data_name,
int nxtype,
const int* dims_array,
const int* chunk_array,
int ndims);
132 int writeSlabList(
const char* data_name,
const unsigned long* value,
const int* dims_array,
int ndims,
const int* slab_start,
const int* slab_size,
const std::vector<int>& slab_list);
133 int addSlabList(
const char* data_name,
const unsigned long* value,
const int* dims_array,
int ndims,
int dest_start[],
const int* slab_start,
const int* slab_size,
const std::vector<int>& slab_list);
134 int makeDataSlab(
const char* data_name,
const unsigned long* value,
const int* dims_array,
int ndims);
135 int writeSlab(
const char* data_name,
const int* value,
const int* dims_array,
int ndims,
const int* slab_start,
const int* slab_size);
136 int writeSlab(
const char* data_name,
const unsigned long* value,
const int* dims_array,
int ndims,
const int* slab_start,
const int* slab_size) {
return writeSlab(data_name, (
const int*)value, dims_array, ndims, slab_start, slab_size); }
137 int addSlab(
const char* data_name,
const int* value,
const int* dims_array,
int ndims,
const int* slab_start,
const int* slab_size,
const int* dest_start);
138 int addSlab(
const char* data_name,
const unsigned long* value,
const int* dims_array,
int ndims,
const int* slab_start,
const int* slab_size,
const int* dest_start);
139 int addSlab(
const char* data_name,
const float* value,
const int* dims_array,
int ndims,
const int* slab_start,
const int* slab_size,
const int* dest_start);
140 int addSlab(
const int* value,
const int* dims_array,
int ndims,
const int* slab_start,
const int* slab_size,
const int* dest_start);
141 int addSlab(
const unsigned long* value,
const int* dims_array,
int ndims,
const int* slab_start,
const int* slab_size,
const int* dest_start);
142 int addSlab(
const float* value,
const int* dims_array,
int ndims,
const int* slab_start,
const int* slab_size,
const int* dest_start);
143 int addSlab(
const int* value,
const int64_t* dims_array,
int ndims,
const int64_t* slab_start,
const int64_t* slab_size,
const int64_t* dest_start);
144 int addSlab(
const float* value,
const int64_t* dims_array,
int ndims,
const int64_t* slab_start,
const int64_t* slab_size,
const int64_t* dest_start);
145 int writeAttribute(
const char* data_name,
const char* attr_name,
const int* value,
int len);
146 int writeAttribute(
const char* data_name,
const char* attr_name,
const float* value,
int len);
147 int writeAttribute(
const char* data_name,
const char* attr_name,
const double* value,
int len);
148 int writeAttribute(
const char* data_name,
const char* attr_name,
const char* value,
int len);
149 int writeAttribute(
const char* data_name,
const char* attr_name,
const char* value);
150 int addLog(
const char* nxname,
const char* filename,
151 const char* log_name,
const char* log_units, time_t ref_time);
153 int addLog(
const char* nxname,
const std::vector<T>& values,
const char* value_units,
154 const std::vector<float>& time,
const char* time_units, time_t ref_time);
157 int makeNewGroup(
const char* name,
const char* nxclass,
bool open_group =
true);
158 int makeNewGroup(
const std::string& name,
const std::string& nxclass,
bool open_group =
true) {
return makeNewGroup(name.c_str(), nxclass.c_str(), open_group); }
161 const char*
ISOtime(time_t time);
162 time_t
unixTime(
const char* isotime);
169 int readData(
const char* data_name, std::string& value);
170 int readData(
const char* data_name,
int& value);
171 int readData(
const char* data_name,
float& value);
172 int listEntries(std::list<std::string>& entries,
bool groups_only =
false);
173 int openGroup(
const char* group_name,
const char* group_class);
186 int writeISISNeXus(
const char* filename,
bool logs_only,
const ISISCRPT_STRUCT* crpt,
const isisU32_t* raw_data,
isisU32_t raw_data_size,
const ISISRAW* iraw,
const seblock_map_t& blocks,
const std::string& inst_xml_file,
const std::string& inst_parameter_map_file,
DAEstatus& dstatus,
bool update =
false);
187 int writeISISNeXus(
const char* filename,
bool logs_only,
const ISISCRPT_STRUCT* crpt,
const isisU32_t* raw_data,
isisU32_t raw_data_size,
const ISISRAW* iraw,
const seblock_map_t& blocks,
const std::string& events_nxfile,
const std::string& inst_xml_file,
const std::string& inst_parameter_map_file,
DAEstatus& dstatus);
188 int addMissingMuonLogs(
const char* filename,
const char* logs_path,
const char* new_comment,
const char* new_sample_name,
DAEstatus& dstatus);
190 static void readExternalFile(
const std::string& file_name, std::string& file_contents);
195 template <
typename T>
int writeData(const char *data_name, unsigned long value)
int openGroup(const char *group_name, const char *group_class)
void setErrorReporter(nx_error_t error_func, void *error_arg)
const char * ISOtime(time_t time)
int listEntries(std::list< std::string > &entries, bool groups_only=false)
int readData(const char *data_name, std::string &value)
NXlogWriter(const std::string &value_units, time_t offset)
int open(const char *filename, int mode, int type=IXNeXusFile::HDF5)
int makeNewGroup(const std::string &name, const std::string &nxclass, bool open_group=true)
int getLink(const char *name, NXlink &link)
int makeNewGroup(const char *name, const char *nxclass, bool open_group=true)
int makeData(const char *data_name, int nxtype, const int *dims_array, int ndims)
int writeSlabList(const char *data_name, const unsigned long *value, const int *dims_array, int ndims, const int *slab_start, const int *slab_size, const std::vector< int > &slab_list)
std::map< std::string, SEBLOCK > seblock_map_t
int writeData(const char *data_name, const std::vector< std::string > &value)
int addLog(const char *nxname, const char *filename, const char *log_name, const char *log_units, time_t ref_time)
void addValue(float time, T value)
time_t unixTime(const char *isotime)
const char * detector_format
int makeDataSlab(const char *data_name, const unsigned long *value, const int *dims_array, int ndims)
int makeDataChunked(const char *data_name, int nxtype, const int *dims_array, const int *chunk_array, int ndims)
std::vector< float > m_time
int addMissingMuonLogs(const char *filename, const char *logs_path, const char *new_comment, const char *new_sample_name, DAEstatus &dstatus)
static bool string_len_lt(const std::string &s1, const std::string &s2)
void disableCompression()
int writeSlab(const char *data_name, const int *value, const int *dims_array, int ndims, const int *slab_start, const int *slab_size)
int writeAttribute(const std::string &data_name, const std::string &attr_name, const std::string &value)
int writeData(const char *data_name, const unsigned long *value, int dim1, int dim2)
void setSpectraChunkSize(int nsp)
static void readExternalFile(const std::string &file_name, std::string &file_contents)
void(* nx_error_t)(void *arg, char *text)
void setRunNumberDigits(int digits)
int enableOptions(Options options)
void setOffset(time_t offset)
int writeMuonFile(const char *filename, const ISISCRPT_STRUCT *crpt, const isisU32_t *raw_data, isisU32_t raw_data_size, const seblock_map_t &blocks, const Poco::Path &inst_settings_dir, const std::string &inst_xml_file, const std::string &inst_parameter_map_file, DAEstatus &dstatus)
const char * detector_base
int getLink(const char *name, const char *nxclass, NXlink &link)
int writeISISNeXus(const char *filename, bool logs_only, const ISISCRPT_STRUCT *crpt, const isisU32_t *raw_data, isisU32_t raw_data_size, const ISISRAW *iraw, const seblock_map_t &blocks, const std::string &inst_xml_file, const std::string &inst_parameter_map_file, DAEstatus &dstatus, bool update=false)
int makeLink(const char *name, NXlink &link)
void write(IXNeXusFile *file, const std::string &name)
int writeSlab(const char *data_name, const unsigned long *value, const int *dims_array, int ndims, const int *slab_start, const int *slab_size)
Base(const std::string &logger_name="UNKNOWN")
NeXusWriter(const NeXusWriter &)
int openData(const char *name)
IXNeXusFile(nx_error_t error_func=NULL, void *error_arg=NULL)
bool testOptions(Options options)
int writeData(const std::string &data_name, const std::string &value)
void setLoggerName(const std::string &logger_name)
int writeData(const char *data_name, const std::vector< T > &value)
int addSlabList(const char *data_name, const unsigned long *value, const int *dims_array, int ndims, int dest_start[], const int *slab_start, const int *slab_size, const std::vector< int > &slab_list)
void enableCompression(int comp_level=NX_COMP_LZW)
int makeLink(const char *name, const char *nxclass, NXlink &link)
int addSlab(const char *data_name, const int *value, const int *dims_array, int ndims, const int *slab_start, const int *slab_size, const int *dest_start)
std::string m_value_units
int writeData(const char *data_name, unsigned value)
int writeData(const char *data_name, long value)