python works

This commit is contained in:
2024-12-04 15:02:57 +01:00
parent b23e697e26
commit 09de69c090
6 changed files with 28 additions and 80 deletions

View File

@ -34,30 +34,22 @@ set( PYTHON_FILES
aare/utils.py
)
# Conditionally add HDF5-related Python files
# HDF5
# if (AARE_HDF5)
# find_package(h5py REQUIRED)
# find_package(HDF5 1.10 COMPONENTS CXX REQUIRED)
# add_definitions(
# ${HDF5_DEFINITIONS}
# )
# list(APPEND PYTHON_FILES
# aare/Hdf5File.py
# )
# if(HDF5_FOUND)
# target_sources(_aare PRIVATE
# ${CMAKE_CURRENT_SOURCE_DIR}/src/Hdf5File.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/src/Hdf5MasterFile.cpp
# )
# target_link_libraries(_aare PUBLIC ${HDF5_LIBRARIES})
# target_include_directories(_aare PUBLIC ${HDF5_INCLUDE_DIRS})
# endif()
# if(H5PY_FOUND)
# set(H5PY_INCLUDE_DIRS ${H5PY_INCLUDE_DIR})
# set(H5PY_LIBRARIES ${PYTHON_LIBRARIES})
# endif()
#HDF5
if (AARE_HDF5)
find_package(HDF5 1.10 COMPONENTS CXX REQUIRED)
add_definitions(
${HDF5_DEFINITIONS}
)
list(APPEND PYTHON_FILES
aare/Hdf5File.py
)
if(HDF5_FOUND)
add_definitions(-DHDF5_FOUND)
target_link_libraries(_aare PUBLIC ${HDF5_LIBRARIES})
target_include_directories(_aare PUBLIC ${HDF5_INCLUDE_DIRS})
endif()
endif()
# Copy the python files to the build directory
foreach(FILE ${PYTHON_FILES})

View File

@ -2,31 +2,15 @@
from . import _aare
from ._aare import File, RawMasterFile, RawSubFile
from ._aare import File, RawMasterFile, RawSubFile, Hdf5MasterFile
from ._aare import Pedestal, ClusterFinder, VarClusterFinder
from ._aare import DetectorType
from ._aare import ClusterFile
from .CtbRawFile import CtbRawFile
from .RawFile import RawFile
from .Hdf5File import Hdf5File
from .ScanParameters import ScanParameters
from .utils import random_pixels, random_pixel
try:
import h5py
HDF5_FOUND = True
except ImportError:
HDF5_FOUND = False
if HDF5_FOUND:
from ._aare import Hdf5MasterFile
from .Hdf5File import Hdf5File
else:
class Hdf5MasterFile:
def __init__(self, *args, **kwargs):
raise ImportError("h5py library not found. HDF5 Master File is not available.")
class Hdf5File:
def __init__(self, *args, **kwargs):
raise ImportError("h5py library not found. HDF5 File is not available.")

View File

@ -1,3 +1,4 @@
#include "H5Cpp.h"
#include "aare/File.hpp"
#include "aare/Frame.hpp"
#include "aare/Hdf5File.hpp"

View File

@ -79,8 +79,8 @@ void define_hdf5_master_file_bindings(py::module &m) {
&Hdf5MasterFile::transceiver_samples)
.def_property_readonly("number_of_rows",
&Hdf5MasterFile::number_of_rows)
.def_property_readonly("quad", &Hdf5MasterFile::quad)
.def_property_readonly("scan_parameters",
&Hdf5MasterFile::scan_parameters)
.def_property_readonly("roi", &Hdf5MasterFile::roi);
.def_property_readonly("quad", &Hdf5MasterFile::quad);
//.def_property_readonly("scan_parameters",
// &Hdf5MasterFile::scan_parameters)
//.def_property_readonly("roi", &Hdf5MasterFile::roi);
}