From 3e5b8840b467149b9d0af45a12daac151f5bfe9a Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 17 Mar 2022 12:21:29 +0100 Subject: [PATCH] wip --- RELEASE.txt | 2 +- slsReceiverSoftware/src/HDF5VirtualFile.cpp | 170 +------------------- 2 files changed, 2 insertions(+), 170 deletions(-) diff --git a/RELEASE.txt b/RELEASE.txt index 2b46be795..c72a50339 100755 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -50,7 +50,7 @@ This document describes the differences between v7.0.0 and v6.x.x - added geometry to metadata - 10g eiger nextframenumber get fixed. - stop, able to set nextframenumber to a consistent (max + 1) for all modules if different (eiger/ctb/jungfrau/moench) - +- gotthard 25 um image reconstructed in gui and virtual hdf5 (firmware updated for slave to reverse channels) 2. Resolved Issues ================== diff --git a/slsReceiverSoftware/src/HDF5VirtualFile.cpp b/slsReceiverSoftware/src/HDF5VirtualFile.cpp index b52925fa1..6c5f3202c 100644 --- a/slsReceiverSoftware/src/HDF5VirtualFile.cpp +++ b/slsReceiverSoftware/src/HDF5VirtualFile.cpp @@ -28,7 +28,7 @@ void HDF5VirtualFile::CloseFile() { error.printErrorStack(); } } -/* + void HDF5VirtualFile::CreateVirtualFile( const std::string filePath, const std::string fileNamePrefix, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, @@ -213,171 +213,3 @@ void HDF5VirtualFile::CreateVirtualFile( LOG(logINFO) << "Virtual File: " << fileName_; } } -*/ - -void HDF5VirtualFile::CreateVirtualFile( - const std::string filePath, const std::string fileNamePrefix, - const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, - const int modulePos, const int numUnitsPerReadout, - const uint32_t maxFramesPerFile, const uint64_t numImages, - const uint32_t nPixelsX, const uint32_t nPixelsY, - const uint32_t dynamicRange, const uint64_t numImagesCaught, - const int numModX, const int numModY, const DataType dataType, - const std::vector parameterNames, - const std::vector parameterDataTypes) { - // virtual file name - std::ostringstream osfn; - osfn << filePath << "/" << fileNamePrefix << "_virtual" - << "_" << fileIndex << ".h5"; - fileName_ = osfn.str(); - - uint64_t numModZ = numModX; - uint32_t nDimy = nPixelsY; - uint32_t nDimz = ((dynamicRange == 4) ? (nPixelsX / 2) : nPixelsX); - - std::lock_guard lock(*hdf5Lib_); - - try { - Exception::dontPrint(); // to handle errors - - // file - FileAccPropList fapl; - fapl.setFcloseDegree(H5F_CLOSE_STRONG); - fd_ = nullptr; - if (!overWriteEnable) - fd_ = new H5File(fileName_.c_str(), H5F_ACC_EXCL, - FileCreatPropList::DEFAULT, fapl); - else - fd_ = new H5File(fileName_.c_str(), H5F_ACC_TRUNC, - FileCreatPropList::DEFAULT, fapl); - - // attributes - version - double dValue = HDF5_WRITER_VERSION; - DataSpace dataspace_attr = DataSpace(H5S_SCALAR); - Attribute attribute = fd_->createAttribute( - "version", PredType::NATIVE_DOUBLE, dataspace_attr); - attribute.write(PredType::NATIVE_DOUBLE, &dValue); - - // virtual data dataspace - hsize_t vdsDims[3] = {numImagesCaught, numModY * nDimy, - numModZ * nDimz}; - DataSpace vdsDataSpace(3, vdsDims, nullptr); - - // property list (fill value and datatype) - int fill_value = -1; - DSetCreatPropList plist; - plist.setFillValue(dataType, &fill_value); - - // hyperslab - int numFiles = numImagesCaught / maxFramesPerFile; - if (numImagesCaught % maxFramesPerFile) - ++numFiles; - uint64_t framesSaved = 0; - // loop through files - for (int file = 0; file < numFiles; ++file) { - - uint64_t nDimx = - ((numImagesCaught - framesSaved) > maxFramesPerFile) - ? maxFramesPerFile - : (numImagesCaught - framesSaved); - - // static const int nImages = 1280 * nDimx; - // hsize_t coord[nImages][3]; - - // loop through readouts (image) - for (unsigned int iReadout = 0; iReadout < numModY * numModZ; - ++iReadout) { - - // memset(&coord, 0, sizeof(coord)); - /*for (int x = 0; x != (int)nDimx; ++x) { - for (int z = 0; z != 1280; ++z) { - coord[1280 * x + z][0] = x + iReadout * nDimx; - coord[1280 * x + z][2] = z; - } - }*/ - hsize_t coord[1280][3]; - memset(coord, 0, sizeof(coord)); - for (int z = 0; z != 1280; ++z) { - coord[z][0] = iReadout; - coord[z][2] = z; - } - /*for (int x = 0; x != nImages; ++x) { - for (int y = 0; y != 3; ++y) { - LOG(logDEBUG) << "coord[" << x << "][" << y << "]:\t" - << coord[x][y] << '\n'; - } - }*/ - - LOG(logINFO) << iReadout << " before selecting"; - vdsDataSpace.selectElements(H5S_SELECT_SET, 1280, - (const hsize_t *)coord); - LOG(logINFO) << iReadout << " after selecting"; - - LOG(logINFO) << "vds valid:" << vdsDataSpace.selectValid(); - - // source file name - std::ostringstream os; - os << filePath << "/" << fileNamePrefix << "_d" - << (modulePos * numUnitsPerReadout + iReadout) << "_f" - << file << '_' << fileIndex << ".h5"; - std::string srcFileName = os.str(); - LOG(logDEBUG1) << srcFileName; - - // find relative path - std::string relative_srcFileName = srcFileName; - { - size_t p = srcFileName.rfind('/', srcFileName.length()); - if (p != std::string::npos) - relative_srcFileName = (srcFileName.substr( - p + 1, srcFileName.length() - p)); - } - - // source dataset name - std::ostringstream osfn; - osfn << "/data"; - if (numImages > 1) - osfn << "_f" << std::setfill('0') << std::setw(12) << file; - std::string srcDatasetName = osfn.str(); - - // source data dataspace - hsize_t srcDims[3] = {nDimx, nDimy, nDimz}; - // hsize_t srcDimsMax[3] = {H5S_UNLIMITED, nDimy, nDimz}; - DataSpace srcDataSpace(3, srcDims); //, srcDimsMax); - /* - LOG(logINFO) << iReadout << " before selecting - src"; srcDataSpace.selectElements(H5S_SELECT_SET, 1280, - (const hsize_t - *)coord); LOG(logINFO) << iReadout << " after selecting src"; - LOG(logINFO) << "src valid:" << - srcDataSpace.selectValid(); - */ - // mapping of data property list - // int values[] = {53, 59, 61, 67}; /* New values to be written - // */ vdsDataSet->write(values, dataType, srcDataSpace, - // vdsDataSpace); - - LOG(logINFORED) << iReadout << " before vritual"; - plist.setVirtual(vdsDataSpace, relative_srcFileName.c_str(), - srcDatasetName.c_str(), srcDataSpace); - LOG(logINFORED) << iReadout << " before virtual"; - - // H5Sclose(srcDataspace); - } - framesSaved += nDimx; - } - // data dataset - dataSetName_ = "data"; - DataSet vdsDataSet(fd_->createDataSet(dataSetName_.c_str(), dataType, - vdsDataSpace, plist)); - - fd_->close(); - } catch (const Exception &error) { - error.printErrorStack(); - CloseFile(); - throw sls::RuntimeError( - "Could not create/overwrite virtual HDF5 handles"); - } - if (!silentMode) { - LOG(logINFO) << "Virtual File: " << fileName_; - } -} \ No newline at end of file