mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
Merge pull request #373 from slsdetectorgroup/ghdf5
Gotthard25um: virtual hdf5 image
This commit is contained in:
commit
de5c298d99
@ -54,6 +54,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
|
||||
==================
|
||||
|
@ -200,7 +200,10 @@ void DataProcessor::CreateVirtualFile(
|
||||
if (virtualFile_) {
|
||||
delete virtualFile_;
|
||||
}
|
||||
virtualFile_ = new HDF5VirtualFile(hdf5Lib);
|
||||
bool gotthard25um =
|
||||
((detectorType_ == GOTTHARD || detectorType_ == GOTTHARD2) &&
|
||||
(numModX * numModY) == 2);
|
||||
virtualFile_ = new HDF5VirtualFile(hdf5Lib, gotthard25um);
|
||||
|
||||
// maxframesperfile = 0 for infinite files
|
||||
uint32_t framesPerFile =
|
||||
@ -214,7 +217,7 @@ void DataProcessor::CreateVirtualFile(
|
||||
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
|
||||
modulePos, numUnitsPerReadout, framesPerFile, numImages,
|
||||
generalData_->nPixelsX, generalData_->nPixelsY, dynamicRange,
|
||||
numImagesProcessed, numModX, numModY, dataFile_->GetPDataType(),
|
||||
numFramesCaught_, numModX, numModY, dataFile_->GetPDataType(),
|
||||
dataFile_->GetParameterNames(), dataFile_->GetParameterDataTypes());
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
HDF5VirtualFile::HDF5VirtualFile(std::mutex *hdf5Lib)
|
||||
: File(HDF5), hdf5Lib_(hdf5Lib) {}
|
||||
HDF5VirtualFile::HDF5VirtualFile(std::mutex *hdf5Lib, bool g25)
|
||||
: File(HDF5), hdf5Lib_(hdf5Lib), gotthard25um(g25) {}
|
||||
|
||||
HDF5VirtualFile::~HDF5VirtualFile() { CloseFile(); }
|
||||
|
||||
@ -73,12 +73,10 @@ void HDF5VirtualFile::CreateVirtualFile(
|
||||
"version", PredType::NATIVE_DOUBLE, dataspace_attr);
|
||||
attribute.write(PredType::NATIVE_DOUBLE, &dValue);
|
||||
|
||||
// virtual data dataspace
|
||||
// virtual dataspace
|
||||
hsize_t vdsDims[3] = {numImagesCaught, numModY * nDimy,
|
||||
numModZ * nDimz};
|
||||
DataSpace vdsDataSpace(3, vdsDims, nullptr);
|
||||
|
||||
// virtual parameter dataspace
|
||||
hsize_t vdsDimsPara[2] = {numImagesCaught,
|
||||
(unsigned int)numModY * numModZ};
|
||||
DataSpace vdsDataSpacePara(2, vdsDimsPara, nullptr);
|
||||
@ -91,37 +89,54 @@ void HDF5VirtualFile::CreateVirtualFile(
|
||||
// property list for parameters (datatype)
|
||||
std::vector<DSetCreatPropList> plistPara(paraSize);
|
||||
|
||||
// hyperslab
|
||||
int numMajorHyperslab = numImagesCaught / maxFramesPerFile;
|
||||
// hyperslab (files)
|
||||
int numFiles = numImagesCaught / maxFramesPerFile;
|
||||
if (numImagesCaught % maxFramesPerFile)
|
||||
++numMajorHyperslab;
|
||||
++numFiles;
|
||||
uint64_t framesSaved = 0;
|
||||
// loop through files
|
||||
for (int hyperSlab = 0; hyperSlab < numMajorHyperslab; ++hyperSlab) {
|
||||
for (int iFile = 0; iFile < numFiles; ++iFile) {
|
||||
|
||||
uint64_t nDimx =
|
||||
((numImagesCaught - framesSaved) > maxFramesPerFile)
|
||||
? maxFramesPerFile
|
||||
: (numImagesCaught - framesSaved);
|
||||
hsize_t start[3] = {framesSaved, 0, 0};
|
||||
hsize_t count[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t startPara[2] = {framesSaved, 0};
|
||||
hsize_t countPara[2] = {nDimx, 1};
|
||||
// loop through readouts
|
||||
for (unsigned int i = 0; i < numModY * numModZ; ++i) {
|
||||
|
||||
// setect data hyperslabs
|
||||
vdsDataSpace.selectHyperslab(H5S_SELECT_SET, count, start);
|
||||
hsize_t startLocation[3] = {framesSaved, 0, 0};
|
||||
hsize_t strideBetweenBlocks[3] = {1, 1, 1};
|
||||
hsize_t numBlocks[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t blockSize[3] = {1, 1, 1};
|
||||
|
||||
// select parameter hyperslabs
|
||||
vdsDataSpacePara.selectHyperslab(H5S_SELECT_SET, countPara,
|
||||
startPara);
|
||||
hsize_t startLocationPara[2] = {framesSaved, 0};
|
||||
hsize_t strideBetweenBlocksPara[3] = {1, 1};
|
||||
hsize_t numBlocksPara[2] = {1, 1};
|
||||
hsize_t blockSizePara[3] = {nDimx, 1};
|
||||
|
||||
// interleaving for g2
|
||||
if (gotthard25um) {
|
||||
strideBetweenBlocks[2] = 2;
|
||||
}
|
||||
|
||||
for (unsigned int iReadout = 0; iReadout < numModY * numModZ;
|
||||
++iReadout) {
|
||||
|
||||
// interleaving for g2 (startLocation is 0 and 1)
|
||||
if (gotthard25um) {
|
||||
startLocation[2] = iReadout;
|
||||
}
|
||||
|
||||
vdsDataSpace.selectHyperslab(H5S_SELECT_SET, numBlocks,
|
||||
startLocation, strideBetweenBlocks,
|
||||
blockSize);
|
||||
|
||||
vdsDataSpacePara.selectHyperslab(
|
||||
H5S_SELECT_SET, numBlocksPara, startLocationPara,
|
||||
strideBetweenBlocksPara, blockSizePara);
|
||||
|
||||
// source file name
|
||||
std::ostringstream os;
|
||||
os << filePath << "/" << fileNamePrefix << "_d"
|
||||
<< (modulePos * numUnitsPerReadout + i) << "_f" << hyperSlab
|
||||
<< '_' << fileIndex << ".h5";
|
||||
<< (modulePos * numUnitsPerReadout + iReadout) << "_f"
|
||||
<< iFile << '_' << fileIndex << ".h5";
|
||||
std::string srcFileName = os.str();
|
||||
LOG(logDEBUG1) << srcFileName;
|
||||
|
||||
@ -138,25 +153,20 @@ void HDF5VirtualFile::CreateVirtualFile(
|
||||
std::ostringstream osfn;
|
||||
osfn << "/data";
|
||||
if (numImages > 1)
|
||||
osfn << "_f" << std::setfill('0') << std::setw(12)
|
||||
<< hyperSlab;
|
||||
osfn << "_f" << std::setfill('0') << std::setw(12) << iFile;
|
||||
std::string srcDatasetName = osfn.str();
|
||||
|
||||
// source data dataspace
|
||||
// source dataspace
|
||||
hsize_t srcDims[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t srcDimsMax[3] = {H5S_UNLIMITED, nDimy, nDimz};
|
||||
DataSpace srcDataSpace(3, srcDims, srcDimsMax);
|
||||
|
||||
// source parameter dataspace
|
||||
hsize_t srcDimsPara[1] = {nDimx};
|
||||
hsize_t srcDimsMaxPara[1] = {H5S_UNLIMITED};
|
||||
DataSpace srcDataSpacePara(1, srcDimsPara, srcDimsMaxPara);
|
||||
|
||||
// mapping of data property list
|
||||
// mapping of property list
|
||||
plist.setVirtual(vdsDataSpace, relative_srcFileName.c_str(),
|
||||
srcDatasetName.c_str(), srcDataSpace);
|
||||
|
||||
// mapping of parameter property list
|
||||
for (unsigned int p = 0; p < paraSize; ++p) {
|
||||
plistPara[p].setVirtual(
|
||||
vdsDataSpacePara, relative_srcFileName.c_str(),
|
||||
@ -165,21 +175,23 @@ void HDF5VirtualFile::CreateVirtualFile(
|
||||
|
||||
// H5Sclose(srcDataspace);
|
||||
// H5Sclose(srcDataspace_para);
|
||||
start[2] += nDimz;
|
||||
if (start[2] >= (numModZ * nDimz)) {
|
||||
start[2] = 0;
|
||||
start[1] += nDimy;
|
||||
|
||||
if (!gotthard25um) {
|
||||
startLocation[2] += nDimz;
|
||||
if (startLocation[2] >= (numModZ * nDimz)) {
|
||||
startLocation[2] = 0;
|
||||
startLocation[1] += nDimy;
|
||||
}
|
||||
}
|
||||
startPara[1]++;
|
||||
startLocationPara[1]++;
|
||||
}
|
||||
framesSaved += nDimx;
|
||||
}
|
||||
// data dataset
|
||||
// datasets
|
||||
dataSetName_ = "data";
|
||||
DataSet vdsDataSet(fd_->createDataSet(dataSetName_.c_str(), dataType,
|
||||
vdsDataSpace, plist));
|
||||
|
||||
// parameter dataset
|
||||
for (unsigned int p = 0; p < paraSize; ++p) {
|
||||
DataSet vdsDataSetPara(fd_->createDataSet(
|
||||
parameterNames[p].c_str(), parameterDataTypes[p],
|
||||
@ -196,4 +208,4 @@ void HDF5VirtualFile::CreateVirtualFile(
|
||||
if (!silentMode) {
|
||||
LOG(logINFO) << "Virtual File: " << fileName_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
class HDF5VirtualFile : private virtual slsDetectorDefs, public File {
|
||||
|
||||
public:
|
||||
HDF5VirtualFile(std::mutex *hdf5Lib);
|
||||
HDF5VirtualFile(std::mutex *hdf5Lib, bool g25);
|
||||
~HDF5VirtualFile();
|
||||
|
||||
std::array<std::string, 2> GetFileAndDatasetName() const override;
|
||||
@ -30,4 +30,5 @@ class HDF5VirtualFile : private virtual slsDetectorDefs, public File {
|
||||
H5File *fd_{nullptr};
|
||||
std::string fileName_;
|
||||
std::string dataSetName_;
|
||||
bool gotthard25um;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user