41static double sq(
double x) {
return x *
x; }
56 stream <<
match.point1.x <<
' ' <<
match.point1.y <<
' ' <<
match.point2.x <<
' ' <<
match.point2.y <<
' '
68 const AstrometryTransform &transform) {
75static unsigned chi2_cleanup(StarMatchList &starMatchList,
const double chi2Cut,
76 const AstrometryTransform &transform) {
77 unsigned erased = starMatchList.removeAmbiguities(transform);
78 for (
auto smi = starMatchList.begin(); smi != starMatchList.end();) {
79 if (smi->chi2 > chi2Cut) {
80 smi = starMatchList.erase(smi);
102 _chi2 = _transform->fit(*
this);
112 if (_chi2 <= 0)
return;
114 if (
npair == 0)
break;
122 std::sort(chi2_array.begin(), chi2_array.end());
124 : (chi2_array[
npair / 2 - 1] + chi2_array[
npair / 2]) * 0.5;
135 int deno = (2. *
size() - _transform->getNpar());
144 if (!
which)
return 0;
173 if (!_transform)
return nullptr;
229 stream <<
" ================================================================" <<
std::endl
234 <<
" ================================================================" <<
std::endl;
247 for (
auto const &
c :
chi2s) chi2 +=
c;
StarMatch begin(StarMatch ... args)
A Point with uncertainties.
A hanger for star associations.
double computeChi2(const AstrometryTransform &transform) const
returns the chi2 (using errors in the FatPoint's)
std::unique_ptr< AstrometryTransform > inverseTransform()
returns the inverse transform (swap, fit(refineTransform) , and swap).
void setDistance(const AstrometryTransform &transform)
Sets the distance (residual) field of all std::list elements. Mandatory before sorting on distances.
void printTransform(std::ostream &stream=std::cout) const
print the matching transformation quality (transform, chi2, residual)
void swap()
swaps elements 1 and 2 of each starmatch in std::list.
double getChi2() const
access to the chi2 of the last call to refineTransform.
int getTransformOrder() const
returns the order of the used transform
void setTransform(const AstrometryTransform *transform)
sets a transform between the 2 std::lists and deletes the previous or default one....
int recoveredNumber(double mindist) const
count the number of elements for which distance is < mindist
void setTransformOrder(int order)
set transform according to the given order.
double computeResidual() const
returns the average 1d Residual (last call to refineTransform)
unsigned removeAmbiguities(const AstrometryTransform &transform, int which=3)
cleans up the std::list of pairs for pairs that share one of their stars, keeping the closest one.
void cutTail(int nKeep)
deletes the tail of the match std::list
void applyTransform(StarMatchList &transformed, const AstrometryTransform *priorTransform, const AstrometryTransform *posteriorTransform=nullptr) const
enables to get a transformed StarMatchList.
void refineTransform(double nSigmas)
removes pairs beyond nSigmas in distance (where the sigma scale is set by the fit) and iterates until...
StarMatch end(StarMatch ... args)
StarMatch erase(StarMatch ... args)
bool compareStar1(const StarMatch &one, const StarMatch &two)
bool sameStar2(const StarMatch &one, const StarMatch &two)
bool sameStar1(const StarMatch &one, const StarMatch &two)
bool compareStar2(const StarMatch &one, const StarMatch &two)
double computeDist2(const StarMatchList &S, const AstrometryTransform &transform)
sum of distance squared
double computeChi2(const StarMatchList &L, const AstrometryTransform &transform)
the actual chi2
std::ostream & operator<<(std::ostream &stream, AstrometryMapping const &mapping)
StarMatch size(StarMatch ... args)
StarMatch unique(StarMatch ... args)