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