Skip to content

Commit ed2ffe7

Browse files
Pedro VicentePedro.vicente
Pedro Vicente
authored and
Pedro.vicente
committed
refs nexusformat#226 Save a NeXus file with chunking and no compression
git-svn-id: https://svn.nexusformat.org/code/trunk@1449 ff5d1e40-2be0-497f-93bd-dc18237bd3c7
1 parent eba5c71 commit ed2ffe7

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

bindings/cpp/NeXusFile.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ namespace NeXus {
7373
* \ingroup cpp_types
7474
*/
7575
enum NXcompression {
76+
CHUNK = NX_CHUNK,
7677
NONE = NX_COMP_NONE,
7778
LZW = NX_COMP_LZW,
7879
RLE = NX_COMP_RLE,

include/napi.h

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ typedef struct {
146146
#define NX_BINARY 21
147147

148148
/* Map NeXus compression methods to HDF compression methods */
149+
#define NX_CHUNK 0
149150
#define NX_COMP_NONE 100
150151
#define NX_COMP_LZW 200
151152
#define NX_COMP_RLE 300

src/napi5.c

+17-10
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,7 @@ static hid_t nxToHDF5Type(int datatype)
723723
return NX_ERROR;
724724
}
725725
H5Pset_deflate(cparms,compress_level);
726-
iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1,
727-
dataspace, cparms);
726+
iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, dataspace, cparms);
728727
}
729728
else if (compress_type == NX_COMP_NONE)
730729
{
@@ -734,25 +733,33 @@ static hid_t nxToHDF5Type(int datatype)
734733
iNew = H5Pset_chunk(cparms,rank,chunkdims);
735734
if (iNew < 0)
736735
{
737-
NXIReportError (NXpData,
738-
"ERROR: Size of chunks could not be set!");
736+
NXIReportError (NXpData, "ERROR: Size of chunks could not be set!");
739737
return NX_ERROR;
740738
}
741-
iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1,
742-
dataspace, cparms);
739+
iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, dataspace, cparms);
743740
}
744741
else
745742
{
746-
iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1,
747-
dataspace, H5P_DEFAULT);
743+
iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, dataspace, H5P_DEFAULT);
748744
}
749745
}
746+
else if (compress_type == NX_CHUNK)
747+
{
748+
cparms = H5Pcreate(H5P_DATASET_CREATE);
749+
iNew = H5Pset_chunk(cparms,rank,chunkdims);
750+
if (iNew < 0)
751+
{
752+
NXIReportError (NXpData, "ERROR: Size of chunks could not be set!");
753+
return NX_ERROR;
754+
}
755+
iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, dataspace, cparms);
756+
757+
}
750758
else
751759
{
752760
NXIReportError (NXpData,
753761
"HDF5 doesn't support selected compression method! Dataset was saved without compression");
754-
iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1,
755-
dataspace, H5P_DEFAULT);
762+
iRet = H5Dcreate (pFile->iCurrentG, (char*)name, datatype1, dataspace, H5P_DEFAULT);
756763
}
757764
if (iRet < 0)
758765
{

0 commit comments

Comments
 (0)