NeXus HDF4/HDF5 IDF V1: read 'frames_good'
This commit is contained in:
35
src/external/nexus/PNeXus.cpp
vendored
35
src/external/nexus/PNeXus.cpp
vendored
@@ -504,6 +504,7 @@ void nxH4::PNeXus::HandleIdfV1(int32 sd_id)
|
||||
"/run/number",
|
||||
"/run/switching_states",
|
||||
"/run/instrument/detector/number",
|
||||
"/run/instrument/beam/frames_good",
|
||||
"/run/histogram_data_1/counts",
|
||||
"/run/histogram_data_1/resolution",
|
||||
"/run/histogram_data_1/grouping"
|
||||
@@ -1183,6 +1184,17 @@ void nxH4::PNeXus::Dump()
|
||||
}
|
||||
}
|
||||
std::cout << std::endl << "----";
|
||||
std::cout << std::endl << " beam";
|
||||
std::cout << std::endl << "----";
|
||||
if (fDataMap.find("/run/instrument/beam/frames_good") != fDataMap.end()) {
|
||||
try {
|
||||
auto fg = std::any_cast<PNXdata<int>>(fDataMap["/run/instrument/beam/frames_good"]);
|
||||
std::cout << std::endl << " good_frames : " << fg.GetData()[0];
|
||||
} catch (const std::bad_any_cast& e) {
|
||||
std::cerr << std::endl << "**ERROR**: Failed to cast good_frames data" << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << std::endl << "----";
|
||||
std::cout << std::endl << " collimator";
|
||||
std::cout << std::endl << "----";
|
||||
if (fDataMap.find("/run/instrument/collimator/type") != fDataMap.end()) {
|
||||
@@ -3125,7 +3137,7 @@ void nxH5::PNeXus::HandleIdfV1(H5::H5File &file)
|
||||
ReadStringDataset(file, "/run/lab");
|
||||
ReadStringDataset(file, "/run/beamline");
|
||||
ReadStringDataset(file, "/run/start_time");
|
||||
ReadStringDataset(file, "/run/end_time");
|
||||
ReadStringDataset(file, "/run/stop_time");
|
||||
ReadIntDataset(file, "/run/switching_states");
|
||||
ReadStringDataset(file, "/run/user/name");
|
||||
ReadStringDataset(file, "/run/user/experiment_number");
|
||||
@@ -3137,8 +3149,10 @@ void nxH5::PNeXus::HandleIdfV1(H5::H5File &file)
|
||||
ReadStringDataset(file, "/run/sample/environment");
|
||||
ReadStringDataset(file, "/run/instrument/name");
|
||||
ReadIntDataset(file, "/run/instrument/detector/number");
|
||||
ReadFloatDataset(file, "/run/instrument/detector/deadtimes");
|
||||
ReadStringDataset(file, "/run/instrument/collimator/type");
|
||||
ReadStringDataset(file, "/run/instrument/beam/beamline");
|
||||
ReadIntDataset(file, "/run/instrument/beam/frames_good");
|
||||
ReadIntDataset(file, "/run/histogram_data_1/counts");
|
||||
ReadIntDataset(file, "/run/histogram_data_1/resolution");
|
||||
ReadIntDataset(file, "/run/histogram_data_1/time_zero");
|
||||
@@ -3450,6 +3464,17 @@ void nxH5::PNeXus::Dump()
|
||||
std::cerr << std::endl << "Error: Failed to cast number data" << std::endl;
|
||||
}
|
||||
}
|
||||
if (fDataMap.find("/run/instrument/detector/deadtimes") != fDataMap.end()) {
|
||||
try {
|
||||
const auto& dead_times = std::any_cast<PNXdata<float>>("/run/instrument/detector/deadtimes").GetData();
|
||||
std::cout << std::endl << " deadtimes: ";
|
||||
for (unsigned int i=0; i<10; i++)
|
||||
std::cout << dead_times[i] << ", ";
|
||||
std::cout << "...";
|
||||
} catch (const std::bad_any_cast& e) {
|
||||
std::cerr << std::endl << "Error: Failed to cast dead time data" << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << std::endl << " collimator";
|
||||
std::cout << std::endl << "----";
|
||||
if (fDataMap.find("/run/instrument/collimator/type") != fDataMap.end()) {
|
||||
@@ -3470,6 +3495,14 @@ void nxH5::PNeXus::Dump()
|
||||
std::cerr << std::endl << "Error: Failed to cast beamline data" << std::endl;
|
||||
}
|
||||
}
|
||||
if (fDataMap.find("/run/instrument/beam/frames_good") != fDataMap.end()) {
|
||||
try {
|
||||
auto str_data = std::any_cast<PNXdata<std::string>>(fDataMap["/run/instrument/beam/frames_good"]);
|
||||
std::cout << std::endl << " frames_good : " << str_data.GetData()[0];
|
||||
} catch (const std::bad_any_cast& e) {
|
||||
std::cerr << std::endl << "Error: Failed to cast frames_good data" << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << std::endl << " histogram_data_1";
|
||||
std::cout << std::endl << "----";
|
||||
std::cout << std::endl << " counts:";
|
||||
|
||||
Reference in New Issue
Block a user