mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-02-19 11:48:39 +01:00
added ReadingMode member to RawMasterFile adapted error in Matterhorntransformer
This commit is contained in:
@@ -5,7 +5,7 @@ from . import _aare
|
||||
|
||||
from ._aare import File, RawMasterFile, RawSubFile, JungfrauDataFile
|
||||
from ._aare import Pedestal_d, Pedestal_f, ClusterFinder_Cluster3x3i, VarClusterFinder
|
||||
from ._aare import DetectorType
|
||||
from ._aare import DetectorType, ReadingMode
|
||||
from ._aare import hitmap
|
||||
from ._aare import ROI
|
||||
from ._aare import corner
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
import numpy as np
|
||||
from . import _aare
|
||||
|
||||
from aare import ReadingMode
|
||||
|
||||
class AdcSar04Transform64to16:
|
||||
def __call__(self, data):
|
||||
@@ -71,20 +71,16 @@ class Matterhorn10Transform:
|
||||
self.dynamic_range = dynamic_range
|
||||
self.num_counters = num_counters
|
||||
|
||||
def compatibility(self, num_digital_samples : int, num_analog_samples : int):
|
||||
def compatibility(self, readingmode : ReadingMode):
|
||||
"""
|
||||
checks if Matterhorn10Transform is compatible with given parameters
|
||||
|
||||
:param num_digital_samples: Number of digital samples set
|
||||
:type num_digital_samples: int
|
||||
:param num_analog_samples: Number of analog samples set
|
||||
:type num_analog_samples: int
|
||||
:param readingmode: Reading mode set
|
||||
:type readingmode: ReadingMode
|
||||
:raises ValueError: if not compatible
|
||||
"""
|
||||
if(num_digital_samples != 0 and num_digital_samples is not None):
|
||||
raise ValueError(f"Incompatible Transformation. Matterhorn10Transform does not support digital samples, but num_digital_samples is {num_digital_samples}.")
|
||||
if(num_analog_samples != 0 and num_analog_samples is not None):
|
||||
raise ValueError(f"Incompatible Transformation. Matterhorn10Transform does not support analog samples, but num_analog_samples is {num_analog_samples}.")
|
||||
if(readingmode != ReadingMode.Transceiver):
|
||||
raise ValueError(f"Incompatible Transformation. Matterhorn10Transform only requires transceiver samples. However reading mode is {readingmode}.")
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@@ -23,6 +23,16 @@ namespace py = pybind11;
|
||||
using namespace ::aare;
|
||||
|
||||
void define_raw_master_file_bindings(py::module &m) {
|
||||
|
||||
py::enum_<ReadingMode>(m, "ReadingMode")
|
||||
.value("Analog", ReadingMode::Analog)
|
||||
.value("Digital", ReadingMode::Digital)
|
||||
.value("AnalogAndDigital", ReadingMode::AnalogAndDigital)
|
||||
.value("Transceiver", ReadingMode::Transceiver)
|
||||
.value("DigitalAndTransceiver", ReadingMode::DigitalAndTransceiver)
|
||||
.value("Unknown", ReadingMode::Unknown)
|
||||
.export_values();
|
||||
|
||||
py::class_<RawMasterFile>(m, "RawMasterFile")
|
||||
.def(py::init<const std::filesystem::path &>())
|
||||
.def("data_fname", &RawMasterFile::data_fname, R"(
|
||||
@@ -81,6 +91,7 @@ void define_raw_master_file_bindings(py::module &m) {
|
||||
|
||||
.def_property_readonly("transceiver_samples",
|
||||
&RawMasterFile::transceiver_samples)
|
||||
.def_property_readonly("reading_mode", &RawMasterFile::get_reading_mode)
|
||||
.def_property_readonly("number_of_rows", &RawMasterFile::number_of_rows)
|
||||
.def_property_readonly("quad", &RawMasterFile::quad)
|
||||
.def_property_readonly("scan_parameters",
|
||||
|
||||
14
python/tests/test_RawMasterFile.py
Normal file
14
python/tests/test_RawMasterFile.py
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
import pytest
|
||||
from aare import RawMasterFile, ReadingMode, DetectorType
|
||||
|
||||
|
||||
@pytest.mark.withdata
|
||||
def test_read_rawfile_quad_eiger_and_compare_to_numpy(test_data_path):
|
||||
|
||||
file_name = test_data_path/'raw/jungfrau/jungfrau_single_master_0.json'
|
||||
|
||||
f = RawMasterFile(file_name)
|
||||
assert(f.reading_mode == ReadingMode.Unknown)
|
||||
assert(f.detector_type == DetectorType.Jungfrau)
|
||||
Reference in New Issue
Block a user