mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
Introduced pattern class
This commit is contained in:
@ -1272,8 +1272,7 @@ void init_det(py::module &m) {
|
||||
Detector::setPattern,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("setPattern",
|
||||
(void (Detector::*)(const defs::patternParameters *,
|
||||
sls::Positions)) &
|
||||
(void (Detector::*)(const sls::Pattern &, sls::Positions)) &
|
||||
Detector::setPattern,
|
||||
py::arg(), py::arg() = Positions{})
|
||||
.def("savePattern",
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "sls/Pattern.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
namespace py = pybind11;
|
||||
void init_enums(py::module &m) {
|
||||
@ -17,20 +18,6 @@ void init_enums(py::module &m) {
|
||||
xy.def_readwrite("x", &slsDetectorDefs::xy::x);
|
||||
xy.def_readwrite("y", &slsDetectorDefs::xy::y);
|
||||
|
||||
py::class_<slsDetectorDefs::patternParameters> patternParameters(
|
||||
m, "patternParameters");
|
||||
|
||||
using pat = slsDetectorDefs::patternParameters;
|
||||
PYBIND11_NUMPY_DTYPE(pat, word, ioctrl, limits, loop, nloop, wait,
|
||||
waittime);
|
||||
|
||||
patternParameters.def(py::init());
|
||||
patternParameters.def("numpy_view", [](py::object &obj) {
|
||||
pat &o = obj.cast<pat &>();
|
||||
return py::array_t<pat>(1, &o, obj);
|
||||
});
|
||||
patternParameters.def("load", &pat::load);
|
||||
|
||||
py::enum_<slsDetectorDefs::detectorType>(Defs, "detectorType")
|
||||
.value("GENERIC", slsDetectorDefs::detectorType::GENERIC)
|
||||
.value("EIGER", slsDetectorDefs::detectorType::EIGER)
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "sls/Pattern.h"
|
||||
namespace py = pybind11;
|
||||
void init_enums(py::module &m) {
|
||||
py::class_<slsDetectorDefs> Defs(m, "slsDetectorDefs");
|
||||
@ -14,18 +15,5 @@ void init_enums(py::module &m) {
|
||||
xy.def_readwrite("x", &slsDetectorDefs::xy::x);
|
||||
xy.def_readwrite("y", &slsDetectorDefs::xy::y);
|
||||
|
||||
py::class_<slsDetectorDefs::patternParameters> patternParameters(
|
||||
m, "patternParameters");
|
||||
|
||||
using pat = slsDetectorDefs::patternParameters;
|
||||
PYBIND11_NUMPY_DTYPE(pat, word, ioctrl, limits, loop, nloop,
|
||||
wait, waittime);
|
||||
|
||||
patternParameters.def(py::init());
|
||||
patternParameters.def("numpy_view", [](py::object &obj) {
|
||||
pat& o = obj.cast<pat&>();
|
||||
return py::array_t<pat>(1, &o, obj); });
|
||||
patternParameters.def("load", &pat::load);
|
||||
|
||||
[[ENUMS]]
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ void init_enums(py::module &);
|
||||
void init_experimental(py::module &);
|
||||
void init_det(py::module &);
|
||||
void init_network(py::module &);
|
||||
void init_pattern(py::module &);
|
||||
PYBIND11_MODULE(_slsdet, m) {
|
||||
m.doc() = R"pbdoc(
|
||||
C/C++ API
|
||||
@ -33,6 +34,7 @@ PYBIND11_MODULE(_slsdet, m) {
|
||||
init_enums(m);
|
||||
init_det(m);
|
||||
init_network(m);
|
||||
init_pattern(m);
|
||||
// init_experimental(m);
|
||||
|
||||
|
||||
|
42
python/src/pattern.cpp
Normal file
42
python/src/pattern.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include <pybind11/chrono.h>
|
||||
#include <pybind11/numpy.h>
|
||||
#include <pybind11/operators.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "sls/Pattern.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
namespace py = pybind11;
|
||||
void init_pattern(py::module &m) {
|
||||
|
||||
using pat = sls::patternParameters;
|
||||
py::class_<pat> patternParameters(m, "patternParameters");
|
||||
|
||||
PYBIND11_NUMPY_DTYPE(pat, word, ioctrl, limits, loop, nloop, wait,
|
||||
waittime);
|
||||
|
||||
patternParameters.def(py::init());
|
||||
patternParameters.def("numpy_view", [](py::object &obj) {
|
||||
pat &o = obj.cast<pat &>();
|
||||
return py::array_t<pat>(1, &o, obj);
|
||||
});
|
||||
|
||||
// m.def("get_memoryview1d", []() {
|
||||
// return py::memoryview::from_memory(
|
||||
// buffer, // buffer pointer
|
||||
// sizeof(uint8_t) * 8 // buffer size
|
||||
// );
|
||||
// })
|
||||
// patternParameters.def("load", &pat::load);
|
||||
|
||||
py::class_<sls::Pattern> Pattern(m, "Pattern");
|
||||
Pattern.def(py::init());
|
||||
Pattern.def("load", &sls::Pattern::load);
|
||||
Pattern.def("data", (pat * (sls::Pattern::*)()) & sls::Pattern::data, py::return_value_policy::reference);
|
||||
|
||||
// m.def("get_memoryview1d", []() {
|
||||
// return py::memoryview::from_memory(data(), // buffer pointer
|
||||
// sizeof(pat) // buffer size
|
||||
// );
|
||||
// });
|
||||
}
|
Reference in New Issue
Block a user