From 5b2809d6b0ed368c66ee52f7140ac561136a0574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=B6jdh?= Date: Wed, 6 Nov 2024 10:13:56 +0100 Subject: [PATCH] working Moench03 detector type --- python/examples/play.py | 10 ++++------ src/RawMasterFile.cpp | 22 +++++++++++++++++++--- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/python/examples/play.py b/python/examples/play.py index 5e39774..0d43d5c 100644 --- a/python/examples/play.py +++ b/python/examples/play.py @@ -18,16 +18,14 @@ from pathlib import Path # im = ax.imshow(frame, cmap='viridis') -# fpath = Path('/Users/erik/data/Moench03old/test_034_irradiated_noise_g4_hg_exptime_2000us_master_0.json') -fpath = Path('/Users/erik/data/Moench05/moench05_multifile_master_0.json') +fpath = Path('/Users/erik/data/Moench03old/test_034_irradiated_noise_g4_hg_exptime_2000us_master_0.json') +# fpath = Path('/Users/erik/data/Moench05/moench05_multifile_master_0.json') # f = aare.CtbRawFile(fpath, transform = transform.moench05) - - - # with CtbRawFile(fpath, transform = transform.moench05) as f: # for header, image in f: # print(f'Frame number: {header["frameNumber"]}') -f = aare.RawMasterFile(fpath) \ No newline at end of file +m = aare.RawMasterFile(fpath) +f = aare.File(fpath) \ No newline at end of file diff --git a/src/RawMasterFile.cpp b/src/RawMasterFile.cpp index 3399e0d..ba55ae2 100644 --- a/src/RawMasterFile.cpp +++ b/src/RawMasterFile.cpp @@ -147,15 +147,27 @@ void RawMasterFile::parse_json(const std::filesystem::path &fpath) { // keep the optional empty } - try { - int analog_flag = j.at("Analog Flag"); - if (analog_flag) { + + // ---------------------------------------------------------------- + // Special treatment of analog flag because of Moench03 + try{ + m_analog_flag = j.at("Analog Flag"); + }catch (const json::out_of_range &e) { + // if it doesn't work still set it to one + // to try to decode analog samples (Old Moench03) + m_analog_flag = 1; + } + try { + if (m_analog_flag) { m_analog_samples = j.at("Analog Samples"); } } catch (const json::out_of_range &e) { // keep the optional empty + // and set analog flag to 0 + m_analog_flag = 0; } + //----------------------------------------------------------------- try { m_quad = j.at("Quad"); @@ -180,6 +192,10 @@ void RawMasterFile::parse_json(const std::filesystem::path &fpath) { // Update detector type for Moench // TODO! How does this work with old .raw master files? + #ifdef AARE_VERBOSE + fmt::print("Detecting Moench03: m_pixels_y: {}, m_analog_samples: {}\n", + m_pixels_y, m_analog_samples.value_or(0)); + #endif if (m_type == DetectorType::Moench && !m_analog_samples && m_pixels_y == 400) { m_type = DetectorType::Moench03;