Skip to content

Commit

Permalink
NEGGIA ERROR
Browse files Browse the repository at this point in the history
  • Loading branch information
pilipp committed Apr 21, 2017
1 parent b9b793a commit a52ec03
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

enable_testing()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(VERSION 1.0.0)
set(VERSION 1.0.1)
add_definitions(-DVERSION=\"${VERSION}\")

add_subdirectory(src)
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Neggia
===========

XDS plugin that reads hdf5 files written by Dectris Eiger Detectors
XDS plugin that reads hdf5 files written by Dectris Eiger Detectors.
Please obtain XDS from ftp://turn5.biologie.uni-konstanz.de/xds/2016-dec05/, which is the version that was released in December 2016.
Other versions may not work.

## Build

Expand Down
30 changes: 15 additions & 15 deletions src/dectris/neggia/plugin/H5ToXds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void printVersionInfo() {
}

template<class T> void applyMaskAndTransformToInt32(const T * indata, int outdata[], const uint32_t * maskData, size_t size) {
constexpr size_t maxSigned = (size_t)std::numeric_limits<int>::max();
constexpr size_t maxSigned = (size_t)std::numeric_limits<int32_t>::max();
for(size_t j=0; j<size; ++j) {
if(maskData[j] & 0x1) {
outdata[j] = -1;
Expand Down Expand Up @@ -88,7 +88,7 @@ size_t readSizeTypeFromDataset(const Dataset &d) {
case sizeof(uint64_t):
return readFromDataset<uint64_t>(d);
default:
throw H5Error(-4, "UNSUPPORTED DATATYPE");
throw H5Error(-4, "NEGGIA ERROR: UNSUPPORTED DATATYPE");
}
}

Expand All @@ -100,21 +100,21 @@ double readFloatFromDataset(const Dataset & d) {
case sizeof(double):
return readFromDataset<double>(d);
default:
throw H5Error(-4, "UNSUPPORTED DATATYPE");
throw H5Error(-4, "NEGGIA ERROR: UNSUPPORTED DATATYPE");
}
}

H5DataCache * getPreopenedDataCache () {
H5DataCache * dataCache = GLOBAL_HANDLE.get();
if (!dataCache) {
throw H5Error(-2, "ERROR: NO FILE HAS BEEN OPENED YET");
throw H5Error(-2, "NEGGIA ERROR: NO FILE HAS BEEN OPENED YET");
}
return dataCache;
}

size_t correctFrameNumberOffset(int frameNumberStartingFromOne) {
if(frameNumberStartingFromOne < 1) {
throw H5Error(-2, "ERROR: Framenumbers start from 1");
throw H5Error(-2, "NEGGIA ERROR: Framenumbers start from 1");
}
return (size_t) frameNumberStartingFromOne - 1;
}
Expand Down Expand Up @@ -164,7 +164,7 @@ void setPixelMask(H5DataCache* dataCache) {
dataCache->pixelMask.reset(new uint32_t[s]);
pixelMask.read(dataCache->pixelMask.get());
} catch (const std::out_of_range &) {
throw H5Error(-4, "ERROR: CANNOT READ PIXEL MASK FROM ", dataCache->filename);
throw H5Error(-4, "NEGGIA ERROR: CANNOT READ PIXEL MASK FROM ", dataCache->filename);
}
}

Expand All @@ -173,9 +173,9 @@ size_t getNumberOfImages(const H5DataCache * dataCache) {
Dataset d(dataCache->h5File, "/entry/instrument/detector/detectorSpecific/nimages");
return readSizeTypeFromDataset(d);
} catch (const std::out_of_range&) {
throw H5Error(-4, "ERROR: CANNOT READ N_IMAGES FROM ", dataCache->filename);
throw H5Error(-4, "NEGGIA ERROR: CANNOT READ N_IMAGES FROM ", dataCache->filename);
} catch (const H5Error &) {
throw H5Error(-4, "ERROR: UNSUPPORTED DATATYPE FOR N_IMAGES");
throw H5Error(-4, "NEGGIA ERROR: UNSUPPORTED DATATYPE FOR N_IMAGES");
}
}

Expand All @@ -184,9 +184,9 @@ size_t getNumberOfTriggers(const H5DataCache * dataCache) {
Dataset d(dataCache->h5File, "/entry/instrument/detector/detectorSpecific/ntrigger");
return readSizeTypeFromDataset(d);
} catch (const std::out_of_range&) {
throw H5Error(-4, "ERROR: CANNOT READ N_TRIGGER FROM ", dataCache->filename);
throw H5Error(-4, "NEGGIA ERROR: CANNOT READ N_TRIGGER FROM ", dataCache->filename);
} catch (const H5Error &) {
throw H5Error(-4, "ERROR: UNSUPPORTED DATATYPE FOR N_TRIGGER");
throw H5Error(-4, "NEGGIA ERROR: UNSUPPORTED DATATYPE FOR N_TRIGGER");
}
}

Expand All @@ -204,7 +204,7 @@ void setNFramesPerDataset(H5DataCache* dataCache)
assert(dataset.isChunked());
assert(dataset.chunkSize() == std::vector<size_t>({1,(unsigned int)dataCache->dimy,(unsigned int)dataCache->dimx}));
} catch (const std::out_of_range &) {
throw H5Error(-4, "ERROR: CANNOT OPEN /entry/data/data_000001 FROM ", dataCache->filename);
throw H5Error(-4, "NEGGIA ERROR: CANNOT OPEN /entry/data/data_000001 FROM ", dataCache->filename);
}
}

Expand All @@ -221,7 +221,7 @@ void applyMaskAndTransformToInt32(const H5DataCache* dataCache, const void * ind
applyMaskAndTransformToInt32((const uint32_t*)indata, outdata, dataCache->pixelMask.get(), dataCache->dimx*dataCache->dimy);
break;
default: {
throw H5Error(-3, "ERROR: DATATYPE NOT SUPPORTED");
throw H5Error(-3, "NEGGIA ERROR: DATATYPE NOT SUPPORTED");
}
}
}
Expand All @@ -239,7 +239,7 @@ void readDataset(int *frame_number, int data_array[], const H5DataCache* dataCac
dataset.read(buffer.get(), std::vector<size_t>({datasetFrameNumber, 0, 0}));
applyMaskAndTransformToInt32(dataCache, buffer.get(), data_array);
} catch(const std::out_of_range &) {
throw H5Error(-2, "ERROR: CANNOT OPEN FRAME ", *frame_number);
throw H5Error(-2, "NEGGIA ERROR: CANNOT OPEN FRAME ", *frame_number);
}
}

Expand Down Expand Up @@ -271,12 +271,12 @@ void plugin_open(const char * filename,
dataCache->filename = filename;
dataCache->h5File = H5File(filename);
} catch (const std::out_of_range &) {
std::cerr << "ERROR: CANNOT OPEN " << filename << std::endl;
std::cerr << "NEGGIA ERROR: CANNOT OPEN " << filename << std::endl;
*error_flag = -4;
return;
}
if(GLOBAL_HANDLE) {
std::cerr << "ERROR: CAN ONLY OPEN ONE FILE AT A TIME " << std::endl;
std::cerr << "NEGGIA ERROR: CAN ONLY OPEN ONE FILE AT A TIME " << std::endl;
*error_flag = -4;
return;
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/dectris/neggia/user/H5File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ std::shared_ptr<char> mapFile(const std::string & fileName)
{
int fd = open(fileName.c_str(), O_RDONLY);
if(fd < 0) {
std::cerr << "ERRNO: " << errno << std::endl;
throw std::out_of_range("Cannot map file");
std::cerr << "NEGGIA ERROR: OPENING FILE RETURNED ERROR CODE: " << errno << std::endl;
throw std::out_of_range("Cannot open file");
}
off_t fsize = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
char * filePointer = (char*) mmap(NULL, fsize, PROT_READ, MAP_SHARED, fd, 0);
if(filePointer == MAP_FAILED) {
close(fd);
std::cerr << "ERRNO: " << errno << std::endl;
std::cerr << "NEGGIA ERROR: MAPPING FILE RETURNED ERROR CODE: " << errno << std::endl;
throw std::out_of_range("Cannot map file");
}
close(fd);
Expand Down

0 comments on commit a52ec03

Please sign in to comment.