Skip to content

Commit

Permalink
Added fitting, fixed roi etc (#129)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrick <[email protected]>
Co-authored-by: JulianHeymes <[email protected]>
  • Loading branch information
3 people authored Feb 12, 2025
1 parent 7d6223d commit dadf5f4
Show file tree
Hide file tree
Showing 55 changed files with 2,924 additions and 686 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- developer

jobs:
build:
Expand Down Expand Up @@ -34,7 +33,6 @@ jobs:
run: conda install conda-build=24.9 conda-verify pytest anaconda-client

- name: Enable upload
if: github.ref == 'refs/heads/main'
run: conda config --set anaconda_upload yes

- name: Build
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/build_conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build pkgs and deploy if on main

on:
push:
branches:
- developer

jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, ] # macos-12, windows-2019]
python-version: ["3.12",]

runs-on: ${{ matrix.platform }}

# The setup-miniconda action needs this to activate miniconda
defaults:
run:
shell: "bash -l {0}"

steps:
- uses: actions/checkout@v4

- name: Get conda
uses: conda-incubator/[email protected]
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge

- name: Prepare
run: conda install conda-build=24.9 conda-verify pytest anaconda-client

- name: Disable upload
run: conda config --set anaconda_upload no

- name: Build
run: conda build conda-recipe

47 changes: 43 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ option(AARE_FETCH_PYBIND11 "Use FetchContent to download pybind11" ON)
option(AARE_FETCH_CATCH "Use FetchContent to download catch2" ON)
option(AARE_FETCH_JSON "Use FetchContent to download nlohmann::json" ON)
option(AARE_FETCH_ZMQ "Use FetchContent to download libzmq" ON)
option(AARE_FETCH_LMFIT "Use FetchContent to download lmfit" ON)


#Convenience option to use system libraries only (no FetchContent)
Expand Down Expand Up @@ -76,6 +77,34 @@ endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(AARE_FETCH_LMFIT)
set(lmfit_patch git apply ${CMAKE_CURRENT_SOURCE_DIR}/patches/lmfit.patch)
FetchContent_Declare(
lmfit
GIT_REPOSITORY https://jugit.fz-juelich.de/mlz/lmfit.git
GIT_TAG main
PATCH_COMMAND ${lmfit_patch}
UPDATE_DISCONNECTED 1
EXCLUDE_FROM_ALL
)
#Disable what we don't need from lmfit
set(BUILD_TESTING OFF CACHE BOOL "")
set(LMFIT_CPPTEST OFF CACHE BOOL "")
set(LIB_MAN OFF CACHE BOOL "")
set(LMFIT_CPPTEST OFF CACHE BOOL "")
set(BUILD_SHARED_LIBS OFF CACHE BOOL "")


FetchContent_MakeAvailable(lmfit)
set_property(TARGET lmfit PROPERTY POSITION_INDEPENDENT_CODE ON)

target_include_directories (lmfit PUBLIC "${libzmq_SOURCE_DIR}/lib")
message(STATUS "lmfit include dir: ${lmfit_SOURCE_DIR}/lib")
else()
find_package(lmfit REQUIRED)
endif()


if(AARE_FETCH_ZMQ)
# Fetchcontent_Declare is deprecated need to find a way to update this
# for now setting the policy to old is enough
Expand Down Expand Up @@ -127,8 +156,8 @@ if (AARE_FETCH_FMT)
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
else()
find_package(fmt 6 REQUIRED)
endif()
Expand All @@ -146,7 +175,6 @@ if (AARE_FETCH_JSON)
install(
TARGETS nlohmann_json
EXPORT "${TARGETS_EXPORT_NAME}"

)
message(STATUS "target: ${NLOHMANN_JSON_TARGET_NAME}")
else()
Expand Down Expand Up @@ -283,11 +311,14 @@ set(PUBLICHEADERS
include/aare/ClusterFile.hpp
include/aare/CtbRawFile.hpp
include/aare/ClusterVector.hpp
include/aare/decode.hpp
include/aare/defs.hpp
include/aare/Dtype.hpp
include/aare/File.hpp
include/aare/Fit.hpp
include/aare/FileInterface.hpp
include/aare/Frame.hpp
include/aare/geo_helpers.hpp
include/aare/NDArray.hpp
include/aare/NDView.hpp
include/aare/NumpyFile.hpp
Expand All @@ -298,6 +329,7 @@ set(PUBLICHEADERS
include/aare/RawMasterFile.hpp
include/aare/RawSubFile.hpp
include/aare/VarClusterFinder.hpp
include/aare/utils/task.hpp

)

Expand All @@ -307,14 +339,18 @@ set(SourceFiles
${CMAKE_CURRENT_SOURCE_DIR}/src/ClusterFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/defs.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Dtype.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/decode.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Frame.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/File.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Fit.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/geo_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/NumpyFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/NumpyHelpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/PixelMap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/RawFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/RawSubFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/RawMasterFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/utils/task.cpp
)


Expand All @@ -334,6 +370,7 @@ target_link_libraries(
${STD_FS_LIB} # from helpers.cmake
PRIVATE
aare_compiler_flags
lmfit
)

set_target_properties(aare_core PROPERTIES
Expand All @@ -350,6 +387,7 @@ if(AARE_TESTS)
${CMAKE_CURRENT_SOURCE_DIR}/src/defs.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Dtype.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Frame.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/geo_helpers.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/RawMasterFile.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/NDArray.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/NDView.test.cpp
Expand All @@ -359,6 +397,7 @@ if(AARE_TESTS)
${CMAKE_CURRENT_SOURCE_DIR}/src/NumpyFile.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/NumpyHelpers.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/RawFile.test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/utils/task.test.cpp

)
target_sources(tests PRIVATE ${TestSources} )
Expand Down Expand Up @@ -436,4 +475,4 @@ if(AARE_MASTER_PROJECT)
set(CMAKE_INSTALL_DIR "share/cmake/${PROJECT_NAME}")
set(PROJECT_LIBRARIES aare-core aare-compiler-flags )
include(cmake/package_config.cmake)
endif()
endif()
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package:
name: aare
version: 2024.12.16.dev0 #TODO! how to not duplicate this?
version: 2025.2.12 #TODO! how to not duplicate this?


source:
Expand Down
23 changes: 1 addition & 22 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,7 @@ set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR})


file(GLOB SPHINX_SOURCE_FILES CONFIGURE_DEPENDS "src/*.rst")
# set(SPHINX_SOURCE_FILES
# src/index.rst
# src/Installation.rst
# src/Requirements.rst
# src/NDArray.rst
# src/NDView.rst
# src/File.rst
# src/Frame.rst
# src/Dtype.rst
# src/ClusterFinder.rst
# src/ClusterFile.rst
# src/Pedestal.rst
# src/RawFile.rst
# src/RawSubFile.rst
# src/RawMasterFile.rst
# src/VarClusterFinder.rst
# src/pyVarClusterFinder.rst
# src/pyFile.rst
# src/pyCtbRawFile.rst
# src/pyRawFile.rst
# src/pyRawMasterFile.rst
# )



foreach(filename ${SPHINX_SOURCE_FILES})
Expand Down
7 changes: 7 additions & 0 deletions docs/src/ClusterFinderMT.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ClusterFinderMT
==================


.. doxygenclass:: aare::ClusterFinderMT
:members:
:undoc-members:
4 changes: 4 additions & 0 deletions docs/src/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ AARE
pyFile
pyCtbRawFile
pyClusterFile
pyClusterVector
pyRawFile
pyRawMasterFile
pyVarClusterFinder

pyFit


.. toctree::
:caption: C++ API
Expand All @@ -45,6 +48,7 @@ AARE
File
Dtype
ClusterFinder
ClusterFinderMT
ClusterFile
ClusterVector
Pedestal
Expand Down
33 changes: 33 additions & 0 deletions docs/src/pyClusterVector.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
ClusterVector
================

The ClusterVector, holds clusters from the ClusterFinder. Since it is templated
in C++ we use a suffix indicating the data type in python. The suffix is
``_i`` for integer, ``_f`` for float, and ``_d`` for double.

At the moment the functionality from python is limited and it is not supported
to push_back clusters to the vector. The intended use case is to pass it to
C++ functions that support the ClusterVector or to view it as a numpy array.

**View ClusterVector as numpy array**

.. code:: python
from aare import ClusterFile
with ClusterFile("path/to/file") as f:
cluster_vector = f.read_frame()
# Create a copy of the cluster data in a numpy array
clusters = np.array(cluster_vector)
# Avoid copying the data by passing copy=False
clusters = np.array(cluster_vector, copy = False)
.. py:currentmodule:: aare
.. autoclass:: ClusterVector_i
:members:
:undoc-members:
:show-inheritance:
:inherited-members:
19 changes: 19 additions & 0 deletions docs/src/pyFit.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

Fit
========

.. py:currentmodule:: aare
**Functions**

.. autofunction:: gaus

.. autofunction:: pol1


**Fitting**

.. autofunction:: fit_gaus

.. autofunction:: fit_pol1
Loading

0 comments on commit dadf5f4

Please sign in to comment.