Skip to content

Commit

Permalink
Merge branch 'tickets/DM-32010'
Browse files Browse the repository at this point in the history
  • Loading branch information
morriscb committed Nov 24, 2021
2 parents 21ef37a + 041cc4a commit 44dc1dc
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 316 deletions.
63 changes: 54 additions & 9 deletions include/lsst/meas/astrom/pessimisticPatternMatcherUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,53 @@
namespace lsst {
namespace meas {
namespace astrom {
/**
* Find the range of reference spokes within a spoke distance tolerance of our
* source spoke.
*
* Returns an the min and max index spanning src_dist +/- max_dist_rad.
*
* @param[in] src_dist float value of the distance we would like to search for
* in the reference array in radians.
* @param[in] ref_dist_array sorted array of distances in radians.
* @param[in] max_dist_rad maximum plus/minus search to find in the reference
* array in radians.
* @return pair of indices for the min and max range of indices to search.
*/
std::pair<size_t, size_t> find_candidate_reference_pair_range(
float src_dist, ndarray::Array<float, 1, 1> const& ref_dist_array, float max_dist_rad);
/**
* Create the individual spokes that make up the pattern now that the
* shift and rotation are within tolerance.
*
* If we can't create a valid pattern we exit early with a partial result.
*
* @param[in] src_ctr 3 vector of the source pinwheel center
* @param[in] src_delta_array Array of 3 vector deltas between the source
* center and the pairs that make up the remaining spokes of the pinwheel.
* @param[in] src_dist_array Array of the distances of each src_delta in the
* pinwheel.
* @param[in] ref_ctr 3 vector of the candidate reference center.
* @param[in] proj_ref_ctr_delta Plane projected 3 vector formed from the
* center point of the candidate pin-wheel and the second point in the
* pattern to create the first spoke pair. This is the candidate pair that
* was matched in the main _construct_pattern_and_shift_rot_matrix loop.
* @param[in] ref_dist_array Array of vector distances for each of the
* reference pairs
* @param[in] ref_id_array Array of id lookups into the master reference array
* that our center id object is paired with.
* @param[in] reference_array Full 3 vector data for the reference catalog.
* @param[in] max_dist_rad Maximum search radius for distances.
* @param[in] n_match Number of source deltas that must be matched into the
* reference deltas in order to consider this a successful pattern match.
* @return Return pairs of reference ids and their matched src ids.
*/
std::vector<std::pair<size_t, size_t>> create_pattern_spokes(
ndarray::Array<double, 1, 1> const& src_ctr, ndarray::Array<double, 2, 1> const& src_delta_array,
ndarray::Array<double, 1, 1> const& src_dist_array, ndarray::Array<double, 1, 1> const& ref_ctr,
ndarray::Array<double, 1, 1> const& proj_ref_ctr_delta,
ndarray::Array<float, 1, 1> const& ref_dist_array, ndarray::Array<uint16_t, 1, 1> const& ref_id_array,
ndarray::Array<double, 2, 1> const& reference_array, double max_dist_rad, size_t n_match);

/**
* Check the opening angle between the first spoke of our pattern for the
Expand All @@ -41,18 +88,16 @@ namespace astrom {
* @param[in] sin_theta_src Sine of the angle between the current candidate
* source spoke and the first spoke.
* @param[in] ref_ctr 3 vector of the candidate reference center
* @param[in] ref_ctr_id id lookup of the ref_ctr into the master reference
* array. uint16 type is to limit the amount of memory used and is set
* in the pessimistic_pattern_matcher_3d python class with reference
* catalogs trimmed by the matchPessimisticB runner class.
* @param[in] proj_ref_ctr_delta Plane projected first spoke in the reference
* pattern using the pattern center as normal.
* @param[in] proj_ref_ctr_dist_sq Squared length of the projected vector.
* @param[in] ref_dist_idx_array Indices sorted by the delta distance between
* the source spoke we are trying to test and the candidate reference
* spokes.
* @param[in] candidate_range Min and max index locations in ref_id_array that
* have pair lengths within the tolerance range.
* @param[in] ref_id_array Array of id lookups into the master reference array
* that our center id object is paired with.
* that our center id object is paired with. uint16 type is to limit the
* amount of memory used and is set in the pessimistic_pattern_matcher_3d
* python class with reference catalogs trimmed by the matchPessimisticB
* runner class.
* @param[in] reference_array Array of three vectors representing the locations
* of all reference objects.
* @param[in] src_sin_tol Sine of tolerance allowed between source and
Expand All @@ -62,7 +107,7 @@ namespace astrom {
*/
int check_spoke(double cos_theta_src, double sin_theta_src, ndarray::Array<double, 1, 1> const& ref_ctr,
ndarray::Array<double, 1, 1> const& proj_ref_ctr_delta, double proj_ref_ctr_dist_sq,
ndarray::Array<long int, 1, 1> const& ref_dist_idx_array,
std::pair<size_t, size_t> const& candidate_range,
ndarray::Array<uint16_t, 1, 1> const& ref_id_array,
ndarray::Array<double, 2, 1> const& reference_array, double src_sin_tol);

Expand Down
11 changes: 9 additions & 2 deletions python/lsst/meas/astrom/pessimisticPatternMatcherUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@
#include "lsst/meas/astrom/pessimisticPatternMatcherUtils.h"

namespace py = pybind11;
using namespace pybind11::literals;

namespace lsst {
namespace meas {
namespace astrom {

PYBIND11_MODULE(pessimisticPatternMatcherUtils, mod) {
mod.def("check_spoke", &check_spoke,
"Test the opening angle between the spokes of our source pattern against the reference.");
mod.def("find_candidate_reference_pair_range", &find_candidate_reference_pair_range, "src_dist"_a,
"ref_dist_array"_a, "max_dist_rad"_a);
mod.def("create_pattern_spokes", &create_pattern_spokes, "src_ctr"_a, "src_delta_array"_a,
"src_dist_array"_a, "ref_ctr"_a, "proj_ref_ctr_delta"_a, "ref_dist_array"_a, "ref_id_array"_a,
"reference_array"_a, "max_dist_rad"_a, "n_match"_a);
mod.def("check_spoke", &check_spoke, "cos_theta_src"_a, "sin_theta_src"_a, "ref_ctr"_a,
"proj_ref_ctr_delta"_a, "proj_ref_ctr_dist_sq"_a, "candidate_range"_a, "ref_id_array"_a,
"reference_array"_a, "src_sin_tol"_a);
}

} // namespace astrom
Expand Down

0 comments on commit 44dc1dc

Please sign in to comment.