Projects
domecam:swift
domecam
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 24
View file
domecam.changes
Changed
@@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Fri Sep 30 11:33:28 UTC 2022 - Matwey V. Kornilov <matwey@sai.msu.ru> + +- Version 0.1.9 + +------------------------------------------------------------------- Tue Sep 20 10:32:56 UTC 2022 - Matwey V. Kornilov <matwey@sai.msu.ru> - Version 0.1.8
View file
domecam.spec
Changed
@@ -36,6 +36,7 @@ BuildRequires: pkgconfig(aravis-0.8) BuildRequires: pkgconfig(cfitsio) BuildRequires: pkgconfig(cppunit) +BuildRequires: pkgconfig(fftw3f) BuildRequires: pkgconfig(libcurl) BuildRoot: %{_tmppath}/%{name}-%{version}-build
View file
_service
Changed
@@ -3,7 +3,7 @@ <param name="url">http://curl.sai.msu.ru/hg/home/matwey/domecam/</param> <param name="scm">hg</param> <param name="versionformat">{latesttag}</param> - <param name="revision">0.1.8</param> + <param name="revision">0.1.9</param> </service> <service name="tar" mode="buildtime" /> <service name="recompress" mode="buildtime">
View file
domecam-0.1.8.obscpio/include/clean.h
Deleted
@@ -1,77 +0,0 @@ -/* - * SPDX-License-Identifier: GPL-3.0-or-later - * - * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> - */ - -#ifndef _CLEAN_H -#define _CLEAN_H - -#include <buffer.h> -#include <buffer_view.h> - -#include <memory> - - -template<class T, std::size_t Align, class Allocator = std::allocator<T>> -class clean: - private Allocator { -public: - using value_type = T; - using result_type = value_type; - using allocator_type = Allocator; - using buffer_type = buffer<result_type, Align, allocator_type>; - using mask_type = std::uint16_t; - -private: - std::size_t width_; - std::size_t height_; - -public: - clean(std::size_t width, std::size_t height, const allocator_type& alloc = allocator_type()): - Allocator(alloc), - width_(width), - height_(height) { - - assert(width_ >= 1); - assert(height_ >= 1); - } - - const std::size_t& width() const { return width_; } - const std::size_t& height() const { return height_; } - - inline buffer_type operator() (buffer_view<value_type, Align> b, buffer_view<value_type> bias, buffer_view<mask_type> mask) const; -}; - -template<class T, std::size_t Align, class Allocator> -typename clean<T, Align, Allocator>::buffer_type -clean<T, Align, Allocator>::operator() (buffer_view<T, Align> b, buffer_view<T> bias, buffer_view<mask_type> mask) const { - constexpr std::size_t mask_capacity = sizeof(mask_type) * 8; - - buffer_type ret{width_ * height_, *this}; - - assert(ret.size() == b.size()); - - auto bias_it = bias.cbegin(); - auto dest_it = ret.begin(); - auto mask_it = mask.cbegin(); - for (auto it = b.cbegin(); it != b.cend(); ++mask_it) { - for (std::size_t bit = 0; - bit < mask_capacity && it != b.cend(); - ++bit, ++it, ++dest_it) { - - *dest_it = (*mask_it & (1 << bit) ? - *it - *bias_it++ : - static_cast<value_type>(0)); - } - } - - assert(bias_it == bias.cend()); - assert(dest_it == ret.end()); - assert(mask_it == mask.cend()); - - return ret; -} - -#endif // _CLEAN_H -
View file
domecam-0.1.8.obscpio/.hgtags -> domecam-0.1.9.obscpio/.hgtags
Changed
@@ -6,3 +6,4 @@ 8e510d8d9774e21cdbf83dd82d7b029285889ae4 0.1.5 3f19208b6ac21b2b2776f064440fb20d5f99170b 0.1.6 41a20f4ebd5e57689dc34e2b7f56e18609dadf14 0.1.7 +efa87880dd80510c7274207a1df55793364749f3 0.1.8
View file
domecam-0.1.8.obscpio/CMakeLists.txt -> domecam-0.1.9.obscpio/CMakeLists.txt
Changed
@@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.5) -project(domecam LANGUAGES C CXX VERSION 0.1.8) +project(domecam LANGUAGES C CXX VERSION 0.1.9) set(CMAKE_CXX_STANDARD 17) @@ -30,12 +30,14 @@ pkg_check_modules(CFITSIO REQUIRED IMPORTED_TARGET cfitsio) pkg_check_modules(CPPUNIT REQUIRED IMPORTED_TARGET cppunit) pkg_check_modules(LIBCURL REQUIRED IMPORTED_TARGET libcurl) +# float version of FFTW3 +pkg_check_modules(FFTW3F REQUIRED IMPORTED_TARGET fftw3f) include_directories("${PROJECT_SOURCE_DIR}/include") file(GLOB_RECURSE SOURCES src/*.cpp) add_library(domecam STATIC ${SOURCES}) -target_link_libraries(domecam Threads::Threads Boost::boost Boost::system Boost::program_options PkgConfig::ARAVIS PkgConfig::CFITSIO PkgConfig::LIBCURL) +target_link_libraries(domecam Threads::Threads Boost::boost Boost::system Boost::program_options PkgConfig::ARAVIS PkgConfig::CFITSIO PkgConfig::LIBCURL PkgConfig::FFTW3F) target_compile_definitions(domecam PRIVATE PROJECT_VERSION="${PROJECT_VERSION}") if(HAS_LTO_SUPPORT) set_property(TARGET domecam PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
View file
domecam-0.1.8.obscpio/exe/domecam-replay.cpp -> domecam-0.1.9.obscpio/exe/domecam-replay.cpp
Changed
@@ -28,12 +28,16 @@ static constexpr const char mean_pupil_mask_filename_opt[] = "mean_pupil_mask_filename"; static constexpr const char clean_filename_opt[] = "clean_filename"; static constexpr const char normalized_clean_filename_opt[] = "normalized_clean_filename"; + static constexpr const char relative_clean_filename_opt[] = "relative_clean_filename"; + static constexpr const char acf_filename_opt[] = "acf_filename"; static constexpr const char pupil_opt[] = "pupil"; static constexpr const char pupil_samples_opt[] = "samples"; static constexpr const char force_initial_opt[] = "force_initial"; static constexpr const char edge_opt[] = "edge"; static constexpr const char edge_loss_factor_opt[] = "loss_factor"; + static constexpr const char grid_size_opt[] = "grid_size"; static constexpr const char bias_filename_opt[] = "bias_filename"; + static constexpr const char pupil_filename_opt[] = "pupil_filename"; static constexpr const char mask_filename_opt[] = "mask_filename"; }; @@ -45,12 +49,16 @@ constexpr const char application::mean_pupil_mask_filename_opt[]; constexpr const char application::clean_filename_opt[]; constexpr const char application::normalized_clean_filename_opt[]; +constexpr const char application::relative_clean_filename_opt[]; +constexpr const char application::acf_filename_opt[]; constexpr const char application::pupil_opt[]; constexpr const char application::pupil_samples_opt[]; constexpr const char application::force_initial_opt[]; constexpr const char application::edge_opt[]; constexpr const char application::edge_loss_factor_opt[]; +constexpr const char application::grid_size_opt[]; constexpr const char application::bias_filename_opt[]; +constexpr const char application::pupil_filename_opt[]; constexpr const char application::mask_filename_opt[]; application::application(): abstract_application() { @@ -65,12 +73,16 @@ (mean_pupil_mask_filename_opt, po::value<std::string>(), "Mean pupil mask output filename") (clean_filename_opt, po::value<std::string>(), "Clean output filename") (normalized_clean_filename_opt, po::value<std::string>(), "Normalized clean output filename") + (relative_clean_filename_opt, po::value<std::string>(), "Relative clean output filename") + (acf_filename_opt, po::value<std::string>(), "Spatial cross-correlation output filename") (pupil_opt, "Do entrance pupil image processing") (pupil_samples_opt, po::value<std::size_t>()->default_value(60), "Number of pupil edge sampling points") (force_initial_opt, "Force initial geometry reestimation for each frame") (edge_opt, "Do entrance pupil edge processing") (edge_loss_factor_opt, po::value<float>(), "Step range for the focus position estimation") + (grid_size_opt, po::value<std::size_t>(), "Time grid size for spatial cross-correlations") (bias_filename_opt, po::value<std::string>(), "CCD Bias filename") + (pupil_filename_opt, po::value<std::string>(), "Normalized pupil image filename") (mask_filename_opt, po::value<std::string>(), "Pupil binary mask filename") ; @@ -117,7 +129,7 @@ const auto& loss_factor = va[edge_loss_factor_opt].as<float>(); edge_replay_executor e(va[pupil_samples_opt].as<std::size_t>(), va.count(force_initial_opt) > 0, loss_factor); std::cerr << e.run(vi); - } else if (va.count(clean_filename_opt) || va.count(normalized_clean_filename_opt)) { + } else if (va.count(clean_filename_opt) || va.count(normalized_clean_filename_opt) || va.count(relative_clean_filename_opt) || va.count(acf_filename_opt)) { const auto& bias_filename = va[bias_filename_opt].as<std::string>(); const auto& mask_filename = va[mask_filename_opt].as<std::string>(); @@ -129,6 +141,21 @@ const auto& output_filename = va[normalized_clean_filename_opt].as<std::string>(); normalized_clean_replay_executor e(output_filename, bias_filename, mask_filename); std::cerr << e.run(vi); + } else if (va.count(relative_clean_filename_opt) || va.count(acf_filename_opt)) { + const auto& pupil_filename = va[pupil_filename_opt].as<std::string>(); + + if (va.count(relative_clean_filename_opt)) { + const auto& output_filename = va[relative_clean_filename_opt].as<std::string>(); + + relative_clean_replay_executor e(output_filename, bias_filename, pupil_filename, mask_filename); + std::cerr << e.run(vi); + } else if (va.count(acf_filename_opt)) { + const auto& output_filename = va[acf_filename_opt].as<std::string>(); + const auto grid_size = va[grid_size_opt].as<std::size_t>(); + + acf_replay_executor e(output_filename, bias_filename, pupil_filename, mask_filename, grid_size); + std::cerr << e.run(vi); + } } } const auto time_end = std::chrono::steady_clock::now();
View file
domecam-0.1.8.obscpio/include/buffer.h -> domecam-0.1.9.obscpio/include/buffer.h
Changed
@@ -113,7 +113,7 @@ } buffer(const buffer& other): - buffer(other.size(), allocator_type()) { + buffer(other.size(), other.get_allocator()) { do_unsafe_copy_from(other); } @@ -183,8 +183,10 @@ inline const_iterator end() const noexcept { return data() + size(); } inline iterator end() noexcept { return data() + size(); } - buffer_view<T, Align> as_view() const noexcept { return {data(), size()}; } - operator buffer_view<T, Align> () const noexcept { return {data(), size()}; } + template<std::size_t Align2 = Align, class V = typename std::enable_if<detail::is_align_compatible<Align, Align2>::value>::type> + buffer_view<T, Align2> as_view() const noexcept { return {data(), size()}; } + template<std::size_t Align2, class V = typename std::enable_if<detail::is_align_compatible<Align, Align2>::value>::type> + operator buffer_view<T, Align2> () const noexcept { return {data(), size()}; } }; #endif // _BUFFER_H
View file
domecam-0.1.8.obscpio/include/element_wise.h -> domecam-0.1.9.obscpio/include/element_wise.h
Changed
@@ -13,10 +13,11 @@ #include <buffer.h> #include <buffer_view.h> +#include <masked.h> template<class Op, std::size_t Align> -class element_wise: +class element_wise_base: private Op { public: using op_type = Op; @@ -26,40 +27,194 @@ using value_type = first_argument_type; public: template<class... Args> - element_wise(Args&&... args): - Op(std::forward<Args>(args)...) {} + element_wise_base(Args&&... args): + Op(std::forward<Args>(args)...) {} template<class Allocator> - inline buffer<result_type, Align, Allocator>& operator() (buffer<first_argument_type, Align, Allocator>& lhs, buffer_view<second_argument_type, Align> rhs) const { - static_assert(std::is_same<result_type, first_argument_type>::value, "Only in-place operations are allowed"); + inline void operator() (buffer<result_type, Align, Allocator>& dest, buffer_view<first_argument_type, Align> first, buffer_view<second_argument_type, Align> second) const { + std::transform(first.cbegin(), first.cend(), second.cbegin(), dest.begin(), static_cast<const Op&>(*this)); + } + + template<class Allocator> + inline void operator() (buffer<result_type, Align, Allocator>& dest, buffer_view<first_argument_type, Align> first, second_argument_type second) const { + using std::placeholders::_1; + + std::transform(first.cbegin(), first.cend(), dest.begin(), std::bind(static_cast<const Op&>(*this), _1, second)); + } +}; + +template<class Op, std::size_t Align, class Allocator = std::allocator<typename element_wise_base<Op, Align>::result_type>> +class element_wise: + private Allocator, + public element_wise_base<Op, Align> { +public: + using typename element_wise_base<Op, Align>::op_type; + using typename element_wise_base<Op, Align>::first_argument_type; + using typename element_wise_base<Op, Align>::second_argument_type; + using typename element_wise_base<Op, Align>::result_type; + using typename element_wise_base<Op, Align>::value_type; + using allocator_type = Allocator; + using buffer_type = buffer<result_type, Align, Allocator>; +private: + std::size_t width_; + std::size_t height_; +public: + template<class... Args> + element_wise(std::size_t width, std::size_t height, const allocator_type& alloc = allocator_type(), const op_type& op = op_type()): + Allocator(alloc), + element_wise_base<Op, Align>(op), + width_{width}, + height_{height} { + + assert(width_ >= 1); + assert(height_ >= 1); + } + + inline buffer_type operator() (buffer_view<first_argument_type, Align> first, buffer_view<second_argument_type, Align> second) const { + buffer_type ret{width_ * height_, *this}; + + element_wise_base<Op, Align>::operator() (ret, first, second); + + return ret; + } + + inline buffer_type operator() (buffer_view<first_argument_type, Align> first, second_argument_type second) const { + buffer_type ret{width_ * height_, *this}; + + element_wise_base<Op, Align>::operator() (ret, first, second); - std::transform(lhs.cbegin(), lhs.cend(), rhs.cbegin(), lhs.begin(), static_cast<const Op&>(*this)); + return ret; + } +}; + +template<class Op, std::size_t Align> +class element_wise_assign: + public element_wise_base<Op, Align> { +public: + using typename element_wise_base<Op, Align>::first_argument_type; + using typename element_wise_base<Op, Align>::second_argument_type; + using typename element_wise_base<Op, Align>::result_type; + using typename element_wise_base<Op, Align>::value_type; +public: + template<class... Args> + element_wise_assign(Args&&... args): + element_wise_base<Op, Align>(std::forward<Args>(args)...) {} - return lhs; + template<class Allocator> + inline void operator() (buffer<first_argument_type, Align, Allocator>& lhs, buffer_view<second_argument_type, Align> rhs) const { + element_wise_base<Op, Align>::operator() (lhs, lhs, rhs); } template<class Allocator> - inline buffer<result_type, Align, Allocator>& operator() (buffer<first_argument_type, Align, Allocator>& lhs, second_argument_type rhs) const { - static_assert(std::is_same<result_type, first_argument_type>::value, "Only in-place operations are allowed"); + inline void operator() (buffer<first_argument_type, Align, Allocator>& lhs, second_argument_type rhs) const { + element_wise_base<Op, Align>::operator() (lhs, lhs, rhs); + } +}; - using std::placeholders::_1; +template<class T, std::size_t Align = alignof(T), class Allocator = std::allocator<T>> +using element_plus = element_wise<std::plus<T>, Align, Allocator>; + +template<class T, std::size_t Align = alignof(T), class Allocator = std::allocator<T>> +using element_minus = element_wise<std::minus<T>, Align, Allocator>; + +template<class T, std::size_t Align = alignof(T), class Allocator = std::allocator<T>> +using element_multiplies = element_wise<std::multiplies<T>, Align, Allocator>; + +template<class T, std::size_t Align = alignof(T), class Allocator = std::allocator<T>> +using element_divides = element_wise<std::divides<T>, Align, Allocator>; + +template<class T, std::size_t Align = alignof(T)> +using element_plus_assign = element_wise_assign<std::plus<T>, Align>; - std::transform(lhs.cbegin(), lhs.cend(), lhs.begin(), std::bind(static_cast<const Op&>(*this), _1, rhs)); +template<class T, std::size_t Align = alignof(T)> +using element_minus_assign = element_wise_assign<std::minus<T>, Align>; - return lhs; +template<class T, std::size_t Align = alignof(T)> +using element_multiplies_assign = element_wise_assign<std::multiplies<T>, Align>; + +template<class T, std::size_t Align = alignof(T)> +using element_divides_assign = element_wise_assign<std::divides<T>, Align>; + + +template<class Op, std::size_t Align, class Allocator = std::allocator<typename Op::result_type>> +class element_wise_masked: + private Allocator, + private Op { +public: + using op_type = Op; + using first_argument_type = typename op_type::first_argument_type; + using second_argument_type = typename op_type::second_argument_type; + using result_type = typename op_type::result_type; + using value_type = first_argument_type; + using allocator_type = Allocator; + using buffer_type = buffer<result_type, Align, Allocator>; + using mask_type = std::uint16_t; +private: + std::size_t width_; + std::size_t height_; +public: + element_wise_masked(std::size_t width, std::size_t height, const allocator_type& alloc = allocator_type(), const op_type& op = op_type()): + Allocator(alloc), + Op(op), + width_{width}, + height_{height} { + + assert(width_ >= 1); + assert(height_ >= 1); + } + + inline buffer_type operator() (buffer_view<first_argument_type, Align> first, buffer_view<second_argument_type, Align> second, buffer_view<mask_type, Align> mask) const { + buffer_type ret{width_ * height_, *this}; + + transform_masked_or(first.cbegin(), first.cend(), mask.cbegin(), second.cbegin(), ret.begin(), static_cast<const Op&>(*this), static_cast<result_type>(0)); + + return ret; } }; -template<class T, std::size_t Align> -using element_plus = element_wise<std::plus<T>, Align>; +template<class Op, std::size_t Align> +class element_wise_masked_assign: + private Op { +public: + using op_type = Op; + using first_argument_type = typename op_type::first_argument_type; + using second_argument_type = typename op_type::second_argument_type; + using result_type = typename op_type::result_type; + using value_type = first_argument_type; + using mask_type = std::uint16_t; +public: + template<class... Args> + element_wise_masked_assign(Args&&... args): + Op(std::forward<Args>(args)...) {} + + template<class Allocator> + inline void operator() (buffer<first_argument_type, Align, Allocator>& lhs, buffer_view<second_argument_type, Align> rhs, buffer_view<mask_type, Align> mask) const { + transform_masked(lhs.cbegin(), lhs.cend(), mask.cbegin(), rhs.cbegin(), lhs.begin(), static_cast<const Op&>(*this)); + } +}; + +template<class T, std::size_t Align = alignof(T), class Allocator = std::allocator<T>> +using element_plus_masked = element_wise_masked<std::plus<T>, Align, Allocator>; + +template<class T, std::size_t Align = alignof(T), class Allocator = std::allocator<T>>
View file
domecam-0.1.8.obscpio/include/executor.h -> domecam-0.1.9.obscpio/include/executor.h
Changed
@@ -7,6 +7,7 @@ #ifndef _EXECUTOR_H #define _EXECUTOR_H +#include <executor/acf.h> #include <executor/binary.h> #include <executor/carriage.h> #include <executor/clean.h> @@ -19,5 +20,6 @@ #include <executor/pupil.h> #include <executor/pupil_mask.h> #include <executor/raw.h> +#include <executor/relative_clean.h> #endif // _EXECUTOR_H
View file
domecam-0.1.9.obscpio/include/executor/acf.h
Added
@@ -0,0 +1,174 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_ACF_H +#define _EXECUTOR_ACF_H + +#include <algorithm> +#include <cmath> +#include <random> + +#include <boost/circular_buffer.hpp> + +#include <executorfwd.h> +#include <executor/fits_sink_mixin.h> +#include <executor/pipeline_mixin.h> +#include <executor/relative_clean.h> +#include <pipeline.h> + + +class acf_executor_base: + public relative_clean_executor_base { +protected: + template<class SourceMixin> class runner; +public: + acf_executor_base(const std::string& target_uri, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri, std::size_t grid_size); + + std::size_t grid_size() const { return grid_size_; } + std::size_t history_size() const { return grid_size_ ? 1 << (grid_size() - 1) : 0; } + +private: + std::size_t grid_size_; +}; + +template<class SourceMixin> +class acf_executor_base::runner: + public SourceMixin, + protected pipeline_mixin::runner_mixin< + relative_clean_sp_pipeline<typename SourceMixin::source_type::value_type>>, + protected pipeline_mixin::runner_mixin<mean_acf_pipeline>, + protected fits_sink_mixin::runner_mixin< + typename mean_acf_pipeline::result_type::value_type, + mean_acf_pipeline::result_type::align>, + protected relative_clean_executor_base::runner_base { +private: + using source_mixin = SourceMixin; + using source_type = typename source_mixin::source_type; + using relative_clean_sp_pipeline_type = relative_clean_sp_pipeline<typename SourceMixin::source_type::value_type>; + using mean_acf_pipeline_type = mean_acf_pipeline; + + struct history_elem_type { + std::size_t position; + typename relative_clean_sp_pipeline_type::result_type frame; + }; + + struct accum_elem_type { + std::size_t count; + typename relative_clean_sp_pipeline_type::result_type frame; + }; +public: + template<class Executor, class... Args> + runner(const Executor& e, Args&&... args): + source_mixin(e, std::forward<Args>(args)...), + pipeline_mixin::runner_mixin<relative_clean_sp_pipeline_type>( + this->source().width(), + this->source().height(), e.history_size() + e.grid_size()), + pipeline_mixin::runner_mixin<mean_acf_pipeline_type>( + pipeline_mixin::runner_mixin<relative_clean_sp_pipeline_type>::pipeline_.width(), + pipeline_mixin::runner_mixin<relative_clean_sp_pipeline_type>::pipeline_.height()), + fits_sink_mixin::runner_mixin< + typename mean_acf_pipeline_type::result_type::value_type, + mean_acf_pipeline_type::result_type::align>(e, + pipeline_mixin::runner_mixin<mean_acf_pipeline_type>::pipeline_.width(), + pipeline_mixin::runner_mixin<mean_acf_pipeline_type>::pipeline_.height(), + e.grid_size(), this->source()), + runner_base(e, + {this->source().xoffset(), this->source().yoffset()}, + {this->source().width(), this->source().height()}), + frame_num_{0}, + history_{e.history_size()}, + accum_{} { + + auto& p = pipeline_mixin::runner_mixin<relative_clean_sp_pipeline_type>::pipeline_; + const auto accum_width = p.width(); + const auto accum_height = p.height(); + + accum_.reserve(e.grid_size()); + std::generate_n(std::back_inserter(accum_), e.grid_size(), [&] () { + accum_elem_type e{0, {accum_width * accum_height, p.make_allocator()}}; + + e.frame.clear(); + + return e; + }); + } + + void run(); + + template<class T, class V = typename std::enable_if<!buffer_traits<T>::has_position>::type> + static inline std::size_t frame_num(const T&, std::size_t n) noexcept { + return n; + } + + template<class T, class V = typename std::enable_if<buffer_traits<T>::has_position>::type> + static inline auto frame_num(const T& b, std::size_t) noexcept -> + decltype(buffer_traits<T>::position(b)) { + return buffer_traits<T>::position(b); + } + +private: + std::size_t frame_num_; + boost::circular_buffer<history_elem_type, std::allocator<history_elem_type>> history_; + std::vector<accum_elem_type> accum_; +}; + +template<class SourceMixin> +void acf_executor_base::runner<SourceMixin>::run() { + this->for_each([this] (const typename source_type::result_type& b) { + history_elem_type c{ + frame_num(b, frame_num_++), + pipeline_mixin::runner_mixin<relative_clean_sp_pipeline_type>::apply(b, bias(), pupil(), mask())}; + const auto& pos = c.position; + const auto& sp = c.frame; + + std::for_each(history_.begin(), history_.end(), [&] (const history_elem_type& h) { + const auto pos_diff = pos - h.position; + + /* pos_diff is not power of two */ + if ((pos_diff & (pos_diff - 1)) != 0) + return; + + const auto accum_idx = __builtin_ctzl(pos_diff); + auto& a = accum_[accum_idx]; + + pipeline_mixin::runner_mixin<mean_acf_pipeline_type>::apply(a.frame, h.frame, sp); + a.count++; + }); + + history_.push_back(std::move(c)); + }); + + std::for_each(accum_.begin(), accum_.end(), [&] (accum_elem_type& a) { + const auto& r = pipeline_mixin::runner_mixin<mean_acf_pipeline_type>::apply(std::move(a.frame), a.count); + this->append_frame(r); + }); + + this->commit(); +} + + +class acf_executor: + public camera_executor, + public acf_executor_base { +public: + acf_executor(const std::string& target_uri, std::size_t frames_number, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri, std::size_t grid_size); + + virtual executor_result run(camera& c) const override; +}; + +class acf_replay_executor: + public replay_executor, + public acf_executor_base { +private: + template<class T> + using runner_type = runner<source_mixin<T>>; +public: + acf_replay_executor(const std::string& target_uri, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri, std::size_t grid_size); + + virtual executor_result run(const fits::variant_image& vi) const override; +}; + +#endif // _EXECUTOR_ACF_H
View file
domecam-0.1.8.obscpio/include/executor/clean.h -> domecam-0.1.9.obscpio/include/executor/clean.h
Changed
@@ -7,6 +7,8 @@ #ifndef _EXECUTOR_CLEAN_H #define _EXECUTOR_CLEAN_H +#include <boost/align/aligned_allocator.hpp> + #include <executorfwd.h> #include <executor/fits_sink_mixin.h> #include <executor/pipeline_mixin.h> @@ -17,9 +19,8 @@ protected fits_sink_mixin, protected pipeline_mixin { protected: - template<class SourceMixin> class runner; -private: class runner_base; + template<class SourceMixin> class runner; public: clean_executor_base(const std::string& target_uri, const std::string& bias_source_uri, const std::string& mask_source_uri); private: @@ -28,13 +29,18 @@ }; class clean_executor_base::runner_base { +private: + template<class T> + using buffer_type_t = buffer<T, 32, boost::alignment::aligned_allocator<T, 32>>; public: - using mask_buffer_type = buffer<std::uint16_t>; - using bias_buffer_type = buffer<float>; + using buffer_type = buffer_type_t<float>; + using mask_buffer_type = buffer_type_t<std::uint16_t>; private: static std::pair<mask_buffer_type, std::size_t> load_mask_image(const std::string& mask_source_uri, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size); - static bias_buffer_type load_bias_image(const std::string& bias_source_uri, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size, const mask_buffer_type& mask, std::size_t active_count); + +protected: + buffer_type load_aux_image(const std::string& source_uri, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size); private: runner_base(std::pair<mask_buffer_type, std::size_t>&& mask, const std::string& bias_source_uri, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size); @@ -43,12 +49,14 @@ runner_base(const std::string& bias_source_uri, const std::string& mask_source_uri, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size); runner_base(const clean_executor_base& e, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size); + const std::size_t& active_count() const { return active_count_; } const mask_buffer_type& mask() const { return mask_; } - const bias_buffer_type& bias() const { return bias_; } + const buffer_type& bias() const { return bias_; } private: + std::size_t active_count_; mask_buffer_type mask_; - bias_buffer_type bias_; + buffer_type bias_; }; template<class SourceMixin>
View file
domecam-0.1.8.obscpio/include/executor/normalized_clean.h -> domecam-0.1.9.obscpio/include/executor/normalized_clean.h
Changed
@@ -83,4 +83,3 @@ }; #endif // _EXECUTOR_NORMALIZED_CLEAN_H -
View file
domecam-0.1.9.obscpio/include/executor/relative_clean.h
Added
@@ -0,0 +1,101 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _EXECUTOR_RELATIVE_CLEAN_H +#define _EXECUTOR_RELATIVE_CLEAN_H + +#include <executorfwd.h> +#include <executor/fits_sink_mixin.h> +#include <executor/pipeline_mixin.h> +#include <executor/clean.h> +#include <pipeline.h> + + +struct relative_clean_executor_base: + public clean_executor_base { +protected: + class runner_base; + template<class SourceMixin> class runner; +public: + relative_clean_executor_base(const std::string& target_uri, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri); +private: + std::string pupil_source_uri_; +}; + +class relative_clean_executor_base::runner_base: + public clean_executor_base::runner_base { +private: + buffer_type load_pupil_image(const std::string& source_uri, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size); + +public: + runner_base(const relative_clean_executor_base& e, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size); + + const buffer_type& pupil() const { return pupil_; } +private: + buffer_type pupil_; +}; + +template<class SourceMixin> +class relative_clean_executor_base::runner: + public SourceMixin, + protected pipeline_mixin::runner_mixin< + relative_clean_pipeline<typename SourceMixin::source_type::value_type>>, + protected fits_sink_mixin::runner_mixin< + typename relative_clean_pipeline<typename SourceMixin::source_type::value_type>::result_type::value_type, + relative_clean_pipeline<typename SourceMixin::source_type::value_type>::result_type::align>, + protected relative_clean_executor_base::runner_base { +private: + using source_mixin = SourceMixin; + using source_type = typename source_mixin::source_type; + using pipeline_type = relative_clean_pipeline<typename source_type::value_type>; + +public: + template<class Executor, class... Args> + runner(const Executor& e, Args&&... args): + source_mixin(e, std::forward<Args>(args)...), + pipeline_mixin::runner_mixin<pipeline_type>( + this->source().width(), + this->source().height()), + fits_sink_mixin::runner_mixin< + typename pipeline_type::result_type::value_type, + pipeline_type::result_type::align>(e, this->source()), + runner_base(e, + {this->source().xoffset(), this->source().yoffset()}, + {this->source().width(), this->source().height()}) {} + + void run(); +}; + +template<class SourceMixin> +void relative_clean_executor_base::runner<SourceMixin>::run() { + this->for_each([this] (const typename source_type::result_type& b) { + this->append_frame(this->apply(b, bias(), pupil(), mask())); + }); + + this->commit(); +} + +class relative_clean_executor: + public camera_executor, + public relative_clean_executor_base { +public: + relative_clean_executor(const std::string& target_uri, std::size_t frames_number, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri); + + virtual executor_result run(camera& c) const override; +}; + +class relative_clean_replay_executor: + public replay_executor, + public relative_clean_executor_base { +private: + template<class T> using runner_type = runner<source_mixin<T>>; +public: + relative_clean_replay_executor(const std::string& target_uri, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri); + + virtual executor_result run(const fits::variant_image& vi) const override; +}; + +#endif // _EXECUTOR_RELATIVE_CLEAN_H
View file
domecam-0.1.9.obscpio/include/fft.h
Added
@@ -0,0 +1,111 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _FFT_H +#define _FFT_H + +#include <cassert> +#include <complex> +#include <memory> + +#include <fftw3.h> + +class fft_base { +private: + std::size_t width_; + std::size_t height_; + std::unique_ptr<fftwf_plan_s, void(*)(fftwf_plan_s*)> plan_; + +protected: + fftwf_plan plan() const noexcept { return plan_.get(); } + +public: + fft_base(std::size_t width, std::size_t height, fftwf_plan plan): + width_{width}, + height_{height}, + plan_{plan, &fftwf_destroy_plan} { + + assert(plan != nullptr); + } + + const std::size_t width() const { return width_; } + const std::size_t height() const { return height_; } +}; + +template<std::size_t Align, class Allocator = std::allocator<float>> +class fft_forward: + public fft_base, + private std::allocator_traits<Allocator>::template rebind_alloc<std::complex<float>> { +public: + /* Only float is supported, since fftwf_* are used */ + using value_type = float; + using result_type = std::complex<value_type>; + using allocator_type = typename std::allocator_traits<Allocator>::template rebind_alloc<result_type>; + using buffer_type = buffer<result_type, Align, allocator_type>; + +public: + fft_forward(std::size_t width, std::size_t height, const allocator_type& alloc = allocator_type()): + fft_base(width/2 + 1, height, + fftwf_plan_dft_r2c_2d(height, width, + reinterpret_cast<value_type*>(Align), + reinterpret_cast<fftwf_complex*>(3*Align), // 3 is a prime number + FFTW_ESTIMATE | FFTW_DESTROY_INPUT)), + allocator_type(alloc) {} + + template<class AllocatorIn> + inline buffer_type operator() (buffer<value_type, Align, AllocatorIn> b) const; +}; + +template<std::size_t Align, class Allocator> +template<class AllocatorIn> +typename fft_forward<Align, Allocator>::buffer_type +fft_forward<Align, Allocator>::operator() (buffer<value_type, Align, AllocatorIn> b) const { + buffer_type ret{width() * height(), *this}; + + fftwf_execute_dft_r2c(plan(), + b.data(), reinterpret_cast<fftwf_complex*>(ret.data())); + + return ret; +} + +template<std::size_t Align, class Allocator = std::allocator<float>> +class fft_backward: + public fft_base, + private std::allocator_traits<Allocator>::template rebind_alloc<float> { +public: + /* Only float is supported, since fftwf_* are used */ + using value_type = std::complex<float>; + using result_type = typename value_type::value_type; + using allocator_type = typename std::allocator_traits<Allocator>::template rebind_alloc<result_type>; + using buffer_type = buffer<result_type, Align, allocator_type>; + +public: + /* There is no FFTW_PRESERVE_INPUT for _c2r */ + fft_backward(std::size_t width, std::size_t height, const allocator_type& alloc = allocator_type()): + fft_base(2*(width-1), height, + fftwf_plan_dft_c2r_2d(height, 2*(width-1), + reinterpret_cast<fftwf_complex*>(Align), + reinterpret_cast<result_type*>(3*Align), // 3 is a prime number + FFTW_ESTIMATE | FFTW_DESTROY_INPUT)), + allocator_type(alloc) {} + + template<class AllocatorIn> + inline buffer_type operator() (buffer<value_type, Align, AllocatorIn> b) const; +}; + +template<std::size_t Align, class Allocator> +template<class AllocatorIn> +typename fft_backward<Align, Allocator>::buffer_type +fft_backward<Align, Allocator>::operator() (buffer<value_type, Align, AllocatorIn> b) const { + buffer_type ret{width() * height(), *this}; + + fftwf_execute_dft_c2r(plan(), + reinterpret_cast<fftwf_complex*>(b.data()), ret.data()); + + return ret; +} + +#endif // _FFT_H
View file
domecam-0.1.8.obscpio/include/io.h -> domecam-0.1.9.obscpio/include/io.h
Changed
@@ -183,7 +183,7 @@ } else if (type == "carriage_home") { return std::unique_ptr<executor>{new carriage_home_executor( pt.get<std::uint16_t>("axis"))}; - } else if (type == "clean" || type == "normalized_clean") { + } else if (type == "clean" || type == "normalized_clean" || type == "relative_clean" || type == "acf") { const auto& filename = pt.get<std::string>("filename"); const auto& frames_number = pt.get<std::size_t>("frames_number"); const auto& bias_filename = pt.get<std::string>("bias_filename"); @@ -193,6 +193,16 @@ return std::unique_ptr<executor>{new clean_executor(filename, frames_number, bias_filename, mask_filename)}; } else if (type == "normalized_clean") { return std::unique_ptr<executor>{new normalized_clean_executor(filename, frames_number, bias_filename, mask_filename)}; + } else if (type == "relative_clean" || type == "acf") { + const auto& pupil_filename = pt.get<std::string>("pupil_filename"); + + if (type == "relative_clean") { + return std::unique_ptr<executor>{new relative_clean_executor(filename, frames_number, bias_filename, pupil_filename, mask_filename)}; + } else if (type == "acf") { + const auto grid_size = pt.get<std::size_t>("grid_size"); + + return std::unique_ptr<executor>{new acf_executor(filename, frames_number, bias_filename, pupil_filename, mask_filename, grid_size)}; + } } }
View file
domecam-0.1.9.obscpio/include/masked.h
Added
@@ -0,0 +1,65 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _MASKED_H +#define _MASKED_H + +#include <iterator> + + +template<class InputIt1, class MaskIt, class InputIt2, class OutputIt, class BinaryOperation, class T> +OutputIt transform_masked_or(InputIt1 first1, InputIt1 last1, MaskIt firstm, InputIt2 first2, OutputIt d_first, BinaryOperation binary_op, T or_value) { + constexpr std::size_t mask_capacity = sizeof(typename std::iterator_traits<MaskIt>::value_type) * 8; + + for (; first1 != last1; ++firstm) { + for (std::size_t bit = 0; + bit < mask_capacity && first1 != last1; + ++bit, ++first1, ++d_first) { + + *d_first = (*firstm & (1 << bit) ? + binary_op(*first1, *first2++) : + or_value); + } + } + + return d_first; +} + +template<class InputIt1, class MaskIt, class InputIt2, class OutputIt, class BinaryOperation> +OutputIt transform_masked(InputIt1 first1, InputIt1 last1, MaskIt firstm, InputIt2 first2, OutputIt d_first, BinaryOperation binary_op) { + constexpr std::size_t mask_capacity = sizeof(typename std::iterator_traits<MaskIt>::value_type) * 8; + + for (; first1 != last1; ++firstm) { + for (std::size_t bit = 0; + bit < mask_capacity && first1 != last1; + ++bit, ++first1, ++d_first) { + + if (*firstm & (1 << bit)) + *d_first = binary_op(*first1, *first2++); + } + } + + return d_first; +} + +template<class InputIt, class MaskIt, class OutputIt> +OutputIt copy_masked(InputIt first, InputIt last, MaskIt firstm, OutputIt d_first) { + constexpr std::size_t mask_capacity = sizeof(typename std::iterator_traits<MaskIt>::value_type) * 8; + + for (; first != last; ++firstm) { + for (std::size_t bit = 0; + bit < mask_capacity && first != last; + ++bit, ++first) { + + if (*firstm & (1 << bit)) + *d_first++ = *first; + } + } + + return d_first; +} + +#endif // _MASKED_H
View file
domecam-0.1.9.obscpio/include/multiplies_conj.h
Added
@@ -0,0 +1,20 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _MULTIPLIES_CONJ_H +#define _MULTIPLIES_CONJ_H + +#include <complex> +#include <functional> + +template<class T> +struct multiplies_conj: public std::multiplies<T> { + constexpr T operator()(const T& lhs, const T& rhs) const { + return lhs * std::conj(rhs); + } +}; + +#endif // _MULTIPLIES_CONJ_H
View file
domecam-0.1.8.obscpio/include/pipeline.h -> domecam-0.1.9.obscpio/include/pipeline.h
Changed
@@ -14,16 +14,18 @@ #include <binary.h> #include <buffer.h> #include <buffer_view.h> -#include <clean.h> #include <convert.h> #include <edge_entropy.h> #include <edge_select.h> #include <element_wise.h> #include <error.h> +#include <fft.h> #include <foldl.h> #include <grad.h> #include <mempool.h> +#include <multiplies_conj.h> #include <pupil_geom.h> +#include <relative.h> template<class InpT, class T> class pipeline_base { @@ -293,8 +295,8 @@ using typename pipeline_base<InpT, float>::mempool_type; using typename pipeline_base<InpT, float>::allocator_type; private: - using plus_op_type = element_plus<value_type, mempool_type::align>; - using divides_op_type = element_divides<value_type, mempool_type::align>; + using plus_op_type = element_plus_assign<value_type, mempool_type::align>; + using divides_op_type = element_divides_assign<value_type, mempool_type::align>; protected: using pipeline_base<InpT, float>::convert_; public: @@ -314,14 +316,17 @@ template<class InpT> typename mean_pipeline<InpT>::result_type& mean_pipeline<InpT>::operator() (buffer_type& accum, buffer_view<InpT, mempool_type::align> b) const { - const auto& c = convert_(b); - return plus_op_(accum, c); + plus_op_(accum, convert_(b)); + + return accum; } template<class InpT> typename mean_pipeline<InpT>::result_type& mean_pipeline<InpT>::operator() (buffer_type& accum, value_type count) const { - return divides_op_(accum, count); + divides_op_(accum, count); + + return accum; } template<class InpT> @@ -332,7 +337,7 @@ using typename pipeline_base<InpT, float>::mempool_type; using typename pipeline_base<InpT, float>::allocator_type; private: - using clean_type = clean<value_type, mempool_type::align, allocator_type>; + using clean_type = element_minus_masked<value_type, mempool_type::align, allocator_type>; protected: using pipeline_base<InpT, float>::pool_; using pipeline_base<InpT, float>::convert_; @@ -343,11 +348,12 @@ clean_type clean_; public: clean_pipeline(std::size_t width, std::size_t height): - pipeline_base<InpT, float>(mempool_type(width * height * sizeof(float), 2)), - clean_{width, height, typename clean_type::allocator_type(pool_)} { - } + clean_pipeline(width, height, mempool_type(width * height * sizeof(float), 2)) {} + clean_pipeline(std::size_t width, std::size_t height, mempool_type&& pool): + pipeline_base<InpT, float>(std::move(pool)), + clean_{width, height, typename clean_type::allocator_type(pool_)} {} - inline result_type operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float> bias, buffer_view<mask_type> mask) const; + inline result_type operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float, mempool_type::align> bias, buffer_view<mask_type, mempool_type::align> mask) const; inline std::size_t width() const { return clean_.width(); } inline std::size_t height() const { return clean_.height(); } @@ -355,7 +361,7 @@ template<class InpT> typename clean_pipeline<InpT>::result_type -clean_pipeline<InpT>::operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float> bias, buffer_view<mask_type> mask) const { +clean_pipeline<InpT>::operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float, mempool_type::align> bias, buffer_view<mask_type, mempool_type::align> mask) const { const auto& c = convert_(b); return clean_(c, bias, mask); } @@ -370,7 +376,7 @@ using typename clean_pipeline<InpT>::mask_type; private: using sum_op_type = sum<value_type, mempool_type::align>; - using divides_op_type = element_divides<value_type, mempool_type::align>; + using divides_op_type = element_divides_assign<value_type, mempool_type::align>; protected: using clean_pipeline<InpT>::clean_; public: @@ -382,16 +388,147 @@ public: normalized_clean_pipeline(std::size_t width, std::size_t height): clean_pipeline<InpT>(width, height) {} + normalized_clean_pipeline(std::size_t width, std::size_t height, mempool_type&& pool): + clean_pipeline<InpT>(width, height, std::move(pool)) {} - inline result_type operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float> bias, buffer_view<mask_type> mask) const; + inline result_type operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float, mempool_type::align> bias, buffer_view<mask_type, mempool_type::align> mask) const; }; template<class InpT> typename normalized_clean_pipeline<InpT>::result_type -normalized_clean_pipeline<InpT>::operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float> bias, buffer_view<mask_type> mask) const { +normalized_clean_pipeline<InpT>::operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float, mempool_type::align> bias, buffer_view<mask_type, mempool_type::align> mask) const { auto c = clean_pipeline<InpT>::operator()(b, bias, mask); + divides_op_(c, sum_op_(c)); + return c; } +template<class InpT> +class relative_clean_pipeline: + public normalized_clean_pipeline<InpT> { +public: + using typename pipeline_base<InpT, float>::value_type; + using typename pipeline_base<InpT, float>::mempool_type; + using typename pipeline_base<InpT, float>::allocator_type; + using typename clean_pipeline<InpT>::mask_type; +private: + using relative_type = relative_masked<value_type, mempool_type::align>; +public: + using buffer_type = buffer<value_type, mempool_type::align, allocator_type>; + using result_type = buffer_type; +private: + relative_type relative_; +public: + relative_clean_pipeline(std::size_t width, std::size_t height): + normalized_clean_pipeline<InpT>(width, height) {} + relative_clean_pipeline(std::size_t width, std::size_t height, mempool_type&& pool): + normalized_clean_pipeline<InpT>(width, height, std::move(pool)) {} + + inline result_type operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float, mempool_type::align> bias, buffer_view<float, mempool_type::align> pupil, buffer_view<mask_type, mempool_type::align> mask) const; +}; + +template<class InpT> +typename relative_clean_pipeline<InpT>::result_type +relative_clean_pipeline<InpT>::operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float, mempool_type::align> bias, buffer_view<float, mempool_type::align> pupil, buffer_view<mask_type, mempool_type::align> mask) const { + auto c = normalized_clean_pipeline<InpT>::operator()(b, bias, mask); + + relative_(c, pupil, mask); + + return c; +} + +template<class InpT> +class relative_clean_sp_pipeline: + public relative_clean_pipeline<InpT> { +public: + using typename pipeline_base<InpT, float>::value_type; + using typename pipeline_base<InpT, float>::mempool_type; + using typename pipeline_base<InpT, float>::allocator_type; + using typename clean_pipeline<InpT>::mask_type; +private: + using fft_forward_type = fft_forward<mempool_type::align, allocator_type>; +public: + using buffer_type = typename fft_forward_type::buffer_type; + using result_type = buffer_type; +protected: + using pipeline_base<InpT, float>::pool_; +private: + fft_forward_type fft_forward_; +public: + relative_clean_sp_pipeline(std::size_t width, std::size_t height, std::size_t history): + relative_clean_pipeline<InpT>(width, height, + mempool_type(height * (width/2 + 1) * sizeof(std::complex<float>), 2 + history)), + fft_forward_(width, height, typename fft_forward_type::allocator_type(pool_)) {} + + inline result_type operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float, mempool_type::align> bias, buffer_view<float, mempool_type::align> pupil, buffer_view<mask_type, mempool_type::align> mask) const; + + inline std::size_t width() const { return fft_forward_.width(); } + inline std::size_t height() const { return fft_forward_.height(); } +}; + +template<class InpT> +typename relative_clean_sp_pipeline<InpT>::result_type +relative_clean_sp_pipeline<InpT>::operator() (buffer_view<InpT, mempool_type::align> b, buffer_view<float, mempool_type::align> bias, buffer_view<float, mempool_type::align> pupil, buffer_view<mask_type, mempool_type::align> mask) const { + return fft_forward_(relative_clean_pipeline<InpT>::operator()(b, bias, pupil, mask)); +} + +class mean_acf_pipeline { +public: + using value_type = std::complex<float>; + using mempool_type = mempool<32>; + using allocator_type = mempool_type::allocator<value_type>; + +private: + using multiplies_conj_op_type = element_wise<multiplies_conj<value_type>, mempool_type::align, allocator_type>; + using plus_op_type = element_plus_assign<value_type, mempool_type::align>; + using divides_op_type = element_divides_assign<value_type, mempool_type::align>; + using fft_backward_type = fft_backward<mempool_type::align, allocator_type>; + +public:
View file
domecam-0.1.9.obscpio/include/relative.h
Added
@@ -0,0 +1,30 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#ifndef _RELATIVE_H +#define _RELATIVE_H + +#include <functional> + +#include <element_wise.h> + +namespace detail { + template<class T> + struct fmsu { + using result_type = T; + using first_argument_type = T; + using second_argument_type = T; + + T operator() (T a, T b) const { + return a * b - static_cast<T>(1); + } + }; +} // detail + +template<class T, std::size_t Align = alignof(T)> +using relative_masked = element_wise_masked_assign<detail::fmsu<T>, Align>; + +#endif // _RELATIVE_H
View file
domecam-0.1.8.obscpio/src/error.cpp -> domecam-0.1.9.obscpio/src/error.cpp
Changed
@@ -4,6 +4,7 @@ * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> */ +#include <array> #include <sstream> #include <error.h>
View file
domecam-0.1.9.obscpio/src/executor/acf.cpp
Added
@@ -0,0 +1,36 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <executor/acf.h> + + +acf_executor_base::acf_executor_base(const std::string& target_uri, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri, std::size_t grid_size): + relative_clean_executor_base(target_uri, bias_source_uri, pupil_source_uri, mask_source_uri), + grid_size_{grid_size} {} + + +acf_executor::acf_executor(const std::string& target_uri, std::size_t frames_number, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri, std::size_t grid_size): + camera_executor(frames_number), + acf_executor_base(target_uri, bias_source_uri, pupil_source_uri, mask_source_uri, grid_size) {} + +executor_result acf_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + r.run(); + + return {}; +} + + +acf_replay_executor::acf_replay_executor(const std::string& target_uri, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri, std::size_t grid_size): + replay_executor(), + acf_executor_base(target_uri, bias_source_uri, pupil_source_uri, mask_source_uri, grid_size) {} + +executor_result acf_replay_executor::run(const fits::variant_image& vi) const { + vi.apply(runner_visitor<runner_type, acf_replay_executor>{*this}); + + return {}; +}
View file
domecam-0.1.8.obscpio/src/executor/clean.cpp -> domecam-0.1.9.obscpio/src/executor/clean.cpp
Changed
@@ -5,6 +5,7 @@ */ #include <executor/clean.h> +#include <masked.h> namespace { std::pair<std::array<std::size_t, 2>, std::array<std::size_t, 2>> unpack_image_region(const fits& f) { @@ -84,44 +85,31 @@ return ret; } -clean_executor_base::runner_base::bias_buffer_type -clean_executor_base::runner_base::load_bias_image(const std::string& bias_source_uri, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size, const mask_buffer_type& mask, std::size_t active_count) { - constexpr std::size_t mask_capacity = sizeof(mask_buffer_type::value_type) * 8; - - bias_buffer_type ret{active_count}; - auto bias_it = ret.begin(); - auto mask_it = mask.cbegin(); +clean_executor_base::runner_base::buffer_type +clean_executor_base::runner_base::load_aux_image(const std::string& source_uri, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size) { + buffer_type ret{active_count()}; - fits bias_fits{bias_source_uri}; - const auto [image_offset, image_size] = unpack_image_region(bias_fits); + fits aux_fits{source_uri}; + const auto [image_offset, image_size] = unpack_image_region(aux_fits); const auto rel_offset = relative_region(offset, size, image_offset, image_size); if (!rel_offset) - throw aux_image_incorrect_position{bias_source_uri, offset, size}; + throw aux_image_incorrect_position{source_uri, offset, size}; - bias_fits.load_image().apply([&] (const auto& image) { + [[maybe_unused]] const auto last = aux_fits.load_image().apply([&] (const auto& image) { const auto frame = image.read_frame_range(0, *rel_offset, size); - for (auto it = frame.cbegin(); it != frame.cend(); ++mask_it) { - for (std::size_t bit = 0; - bit < mask_capacity && it != frame.cend(); - ++bit, ++it) { - - if (*mask_it & (1 << bit)) { - *bias_it++ = *it; - } - } - } + return copy_masked(frame.cbegin(), frame.cend(), mask().cbegin(), ret.begin()); }); - assert(bias_it == ret.end()); - assert(mask_it == mask.cend()); + assert(last == ret.cend()); return ret; } clean_executor_base::runner_base::runner_base(std::pair<mask_buffer_type, std::size_t>&& mask, const std::string& bias_source_uri, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size): + active_count_{mask.second}, mask_{std::move(mask.first)}, - bias_{load_bias_image(bias_source_uri, offset, size, mask_, mask.second)} {} + bias_{load_aux_image(bias_source_uri, offset, size)} {} clean_executor_base::runner_base::runner_base(const std::string& bias_source_uri, const std::string& mask_source_uri, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size): runner_base(load_mask_image(mask_source_uri, offset, size), bias_source_uri, offset, size) {}
View file
domecam-0.1.9.obscpio/src/executor/relative_clean.cpp
Added
@@ -0,0 +1,51 @@ +/* + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Copyright (C) 2017-2022 Matwey V. Kornilov <matwey.kornilov@gmail.com> + */ + +#include <algorithm> + +#include <executor/relative_clean.h> + +relative_clean_executor_base::relative_clean_executor_base(const std::string& target_uri, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri): + clean_executor_base(target_uri, bias_source_uri, mask_source_uri), + pupil_source_uri_{pupil_source_uri} {} + +relative_clean_executor_base::runner_base::buffer_type +relative_clean_executor_base::runner_base::load_pupil_image(const std::string& source_uri, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size) { + auto ret = load_aux_image(source_uri, offset, size); + + std::transform(ret.cbegin(), ret.cend(), ret.begin(), [] (const auto& x) { + return static_cast<decltype(x)>(1) / x; + }); + + return ret; +} + +relative_clean_executor_base::runner_base::runner_base(const relative_clean_executor_base& e, const std::array<std::size_t, 2>& offset, const std::array<std::size_t, 2>& size): + clean_executor_base::runner_base(e, offset, size), + pupil_{load_pupil_image(e.pupil_source_uri_, offset, size)} {} + +relative_clean_executor::relative_clean_executor(const std::string& target_uri, std::size_t frames_number, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri): + camera_executor(frames_number), + relative_clean_executor_base(target_uri, bias_source_uri, pupil_source_uri, mask_source_uri) {} + +executor_result relative_clean_executor::run(camera& c) const { + runner<source_mixin> r{*this, c}; + + r.run(); + + return {}; +} + + +relative_clean_replay_executor::relative_clean_replay_executor(const std::string& target_uri, const std::string& bias_source_uri, const std::string& pupil_source_uri, const std::string& mask_source_uri): + replay_executor(), + relative_clean_executor_base(target_uri, bias_source_uri, pupil_source_uri, mask_source_uri) {} + +executor_result relative_clean_replay_executor::run(const fits::variant_image& vi) const { + vi.apply(runner_visitor<runner_type, relative_clean_replay_executor>{*this}); + + return {}; +}
View file
domecam-0.1.8.obscpio/test/buffer.cpp -> domecam-0.1.9.obscpio/test/buffer.cpp
Changed
@@ -256,6 +256,13 @@ CPPUNIT_ASSERT_EQUAL(bv2.size(), bv.size()); } +void test_create5() { + const buffer<float, 32, std::allocator<float>> b(64, std::allocator<float>()); + buffer_view<float, 16> bv(b); + CPPUNIT_ASSERT_EQUAL(b.data(), bv.data()); + CPPUNIT_ASSERT_EQUAL(b.size(), bv.size()); +} + void test_copy1() { const std::array<float, 4> arr{0.0f, 0.0f, 0.0f, 0.0f}; buffer_view<float> bv(arr.data(), arr.size());
View file
domecam.obsinfo
Changed
@@ -1,3 +1,3 @@ name: domecam -version: 0.1.8 -mtime: 1663669895 +version: 0.1.9 +mtime: 1664537478
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.