mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-29 17:40:01 +02:00
creating new datasets every 10,000 images in same file
This commit is contained in:
parent
d847a289a4
commit
abb5bfb6e4
@ -646,6 +646,7 @@ private:
|
|||||||
DataSet *hdf5_datasetId[MAX_NUMBER_OF_WRITER_THREADS];
|
DataSet *hdf5_datasetId[MAX_NUMBER_OF_WRITER_THREADS];
|
||||||
H5File *hdf5_fileId[MAX_NUMBER_OF_WRITER_THREADS];
|
H5File *hdf5_fileId[MAX_NUMBER_OF_WRITER_THREADS];
|
||||||
DataType hdf5_datatype;
|
DataType hdf5_datatype;
|
||||||
|
const static int MAX_IMAGES_IN_DATASET = 10000;
|
||||||
#endif
|
#endif
|
||||||
//***acquisition indices/count parameters***
|
//***acquisition indices/count parameters***
|
||||||
/** Frame Number of First Frame of an entire Acquisition (including all scans) */
|
/** Frame Number of First Frame of an entire Acquisition (including all scans) */
|
||||||
|
@ -1856,19 +1856,21 @@ int UDPStandardImplementation::createNewFile(int ithread){
|
|||||||
|
|
||||||
//data
|
//data
|
||||||
//create property list for a dataset and set up fill values
|
//create property list for a dataset and set up fill values
|
||||||
int fillvalue = -1;
|
|
||||||
|
/*int fillvalue = -1; //Aldo suggested its time consuming
|
||||||
DSetCreatPropList plist;
|
DSetCreatPropList plist;
|
||||||
plist.setFillValue(hdf5_datatype, &fillvalue);
|
plist.setFillValue(hdf5_datatype, &fillvalue);*/
|
||||||
//create dataspace for the dataset in the file
|
//create dataspace for the dataset in the file
|
||||||
hsize_t srcdims[3] = {NY,NX,numberOfFrames};
|
int numimagesindataset = ((numberOfFrames < MAX_IMAGES_IN_DATASET)? numberOfFrames:MAX_IMAGES_IN_DATASET);
|
||||||
|
hsize_t srcdims[3] = {NY,NX,numimagesindataset};
|
||||||
if(dynamicRange == 4)
|
if(dynamicRange == 4)
|
||||||
srcdims[1] = NX/2;
|
srcdims[1] = NX/2;
|
||||||
hdf5_dataspaceId[ithread] = new DataSpace (3,srcdims);
|
hdf5_dataspaceId[ithread] = new DataSpace (3,srcdims);
|
||||||
char dsetname[100];
|
char dsetname[100];
|
||||||
sprintf(dsetname, "/entry/data/data_%06lld", (long long int)currentFrameNumber[ithread]+1);
|
sprintf(dsetname, "/entry/data/data_%06lld", 0);//(long long int)currentFrameNumber[ithread]+1)
|
||||||
//Create dataset and write it into the file
|
//Create dataset and write it into the file
|
||||||
hdf5_datasetId[ithread] = new DataSet (hdf5_fileId[ithread]->createDataSet(
|
hdf5_datasetId[ithread] = new DataSet (hdf5_fileId[ithread]->createDataSet(
|
||||||
dsetname, hdf5_datatype, *hdf5_dataspaceId[ithread], plist));
|
dsetname, hdf5_datatype, *hdf5_dataspaceId[ithread]));/*, plist));*/
|
||||||
}
|
}
|
||||||
catch(Exception error){
|
catch(Exception error){
|
||||||
cprintf(RED,"Error in creating HDF5 handles in thread %d\n",ithread);
|
cprintf(RED,"Error in creating HDF5 handles in thread %d\n",ithread);
|
||||||
@ -3138,9 +3140,32 @@ void UDPStandardImplementation::handleCompleteFramesOnly(int ithread, char* wbuf
|
|||||||
else if (fileFormatType == HDF5){
|
else if (fileFormatType == HDF5){
|
||||||
pthread_mutex_lock(&writeMutex);
|
pthread_mutex_lock(&writeMutex);
|
||||||
|
|
||||||
|
if(tempframenumber && (tempframenumber%MAX_IMAGES_IN_DATASET) == 0){
|
||||||
|
try{
|
||||||
|
Exception::dontPrint(); //to handle errors
|
||||||
|
if(hdf5_datasetId[ithread]) {delete hdf5_datasetId[ithread]; hdf5_datasetId[ithread] = 0;}
|
||||||
|
char dsetname[100];
|
||||||
|
sprintf(dsetname, "/entry/data/data_%06lld", (long long int)currentFrameNumber[ithread]+1);
|
||||||
|
//create new dataspace if fewer than max images/dataset
|
||||||
|
int numimagesindataset = (((numberOfFrames-tempframenumber) < MAX_IMAGES_IN_DATASET)? (numberOfFrames-tempframenumber):MAX_IMAGES_IN_DATASET);
|
||||||
|
if(numimagesindataset<MAX_IMAGES_IN_DATASET){
|
||||||
|
hsize_t srcdims[3] = {NY,NX,numimagesindataset};
|
||||||
|
if(dynamicRange == 4)
|
||||||
|
srcdims[1] = NX/2;
|
||||||
|
hdf5_dataspaceId[ithread] = new DataSpace (3,srcdims);
|
||||||
|
}
|
||||||
|
hdf5_datasetId[ithread] = new DataSet (hdf5_fileId[ithread]->createDataSet(
|
||||||
|
dsetname, hdf5_datatype, *hdf5_dataspaceId[ithread]));
|
||||||
|
}
|
||||||
|
catch(Exception error){
|
||||||
|
cprintf(RED,"Error in closing HDF5 dataset to create a new one in thread %d\n",ithread);
|
||||||
|
error.printError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//wite to file
|
//wite to file
|
||||||
hsize_t count[3] = {NY,NX,1};
|
hsize_t count[3] = {NY,NX,1};
|
||||||
hsize_t start[3] = {0, 0, tempframenumber};
|
hsize_t start[3] = {0, 0, tempframenumber%MAX_IMAGES_IN_DATASET};
|
||||||
hsize_t dims2[2]={NY,NX};
|
hsize_t dims2[2]={NY,NX};
|
||||||
if(dynamicRange == 4){
|
if(dynamicRange == 4){
|
||||||
dims2[1] = NX/2;
|
dims2[1] = NX/2;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user