Skip to content

Commit

Permalink
Merge branch '123-hdf5-on-every-new-file-creation-add-nxroot-attribut…
Browse files Browse the repository at this point in the history
…es-file_name-and-file_time' into 'master'

Resolve "[HDF5] On every new file creation add NXroot attributes file_name and file_time"

Closes esrf-bliss#123

See merge request limagroup/lima!172
  • Loading branch information
alejandrohomsp committed Jul 15, 2020
2 parents ee03937 + 53dc0d7 commit 979e3b3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions control/src/CtSaving_Hdf5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,24 @@ void* SaveContainerHdf5::_open(const std::string &filename, std::ios_base::openm
write_h5_attribute(file->m_file, "NX_class", nxroot);
string nxcreator = "LIMA-"+ m_ct_parameters.lima_version;
write_h5_attribute(file->m_file, "creator", nxcreator);
// to know where the file comes from, add the filename (path) and creation date
string nxfilename = filename;
write_h5_attribute(file->m_file, "file_name", nxfilename);
// ISO 8601 Time format

time_t now;
time(&now);
char buf[sizeof("2011-10-08T07:07:09Z")];
#ifdef WIN32
struct tm gmtime_now;
gmtime_s(&gmtime_now, &now);
strftime(buf, sizeof(buf), "%FT%TZ", &gmtime_now);
#else
strftime(buf, sizeof(buf), "%FT%TZ", gmtime(&now));
#endif
string stime = string(buf);
write_h5_attribute(file->m_file,"file_time",stime);

// could be the beamline/instrument name instead
Group instrument(file->m_entry.createGroup(m_ct_parameters.instrument_name));
string nxinstrument = "NXinstrument";
Expand Down

0 comments on commit 979e3b3

Please sign in to comment.