LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
lsst::jointcal::StarMatchList Class Reference

#include <StarMatch.h>

Inheritance diagram for lsst::jointcal::StarMatchList:
std::list< StarMatch >

Public Member Functions

void refineTransform (double nSigmas)
 removes pairs beyond nSigmas in distance (where the sigma scale is set by the fit) and iterates until stabilization of the number of pairs.
 
void applyTransform (StarMatchList &transformed, const AstrometryTransform *priorTransform, const AstrometryTransform *posteriorTransform=nullptr) const
 enables to get a transformed StarMatchList.
 
 StarMatchList ()
 
std::shared_ptr< const AstrometryTransformgetTransform () const
 carries out a fit with outlier rejection
 
double getDist2 () const
 access to the sum of squared residuals of the last call to refineTransform.
 
double getChi2 () const
 access to the chi2 of the last call to refineTransform.
 
int getTransformOrder () const
 returns the order of the used transform
 
void swap ()
 swaps elements 1 and 2 of each starmatch in std::list.
 
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 setTransform (const AstrometryTransform *transform)
 sets a transform between the 2 std::lists and deletes the previous or default one. No fit.
 
void setTransform (const AstrometryTransform &transform)
 
void setTransform (std::shared_ptr< AstrometryTransform > transform)
 
void setTransformOrder (int order)
 set transform according to the given order.
 
std::unique_ptr< AstrometryTransforminverseTransform ()
 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 cutTail (int nKeep)
 deletes the tail of the match std::list
 
int recoveredNumber (double mindist) const
 count the number of elements for which distance is < mindist
 
void printTransform (std::ostream &stream=std::cout) const
 print the matching transformation quality (transform, chi2, residual)
 
 ~StarMatchList ()=default
 
 StarMatchList (const StarMatchList &)=delete
 
void operator= (const StarMatchList &)=delete
 
StarMatch pop_front (StarMatch ... args)
 
StarMatch push_back (StarMatch ... args)
 
StarMatch splice (StarMatch ... args)
 
StarMatch crbegin (StarMatch ... args)
 
StarMatch erase (StarMatch ... args)
 
StarMatch emplace_front (StarMatch ... args)
 
StarMatch insert (StarMatch ... args)
 
StarMatch reverse (StarMatch ... args)
 
StarMatch back (StarMatch ... args)
 
StarMatch end (StarMatch ... args)
 
StarMatch remove (StarMatch ... args)
 
StarMatch emplace_back (StarMatch ... args)
 
StarMatch pop_back (StarMatch ... args)
 
StarMatch cbegin (StarMatch ... args)
 
StarMatch front (StarMatch ... args)
 
StarMatch unique (StarMatch ... args)
 
StarMatch size (StarMatch ... args)
 
StarMatch resize (StarMatch ... args)
 
StarMatch push_front (StarMatch ... args)
 
StarMatch rbegin (StarMatch ... args)
 
StarMatch crend (StarMatch ... args)
 
StarMatch assign (StarMatch ... args)
 
StarMatch sort (StarMatch ... args)
 
StarMatch merge (StarMatch ... args)
 
StarMatch empty (StarMatch ... args)
 
StarMatch remove_if (StarMatch ... args)
 
StarMatch cend (StarMatch ... args)
 
StarMatch swap (StarMatch ... args)
 
StarMatch max_size (StarMatch ... args)
 
StarMatch rend (StarMatch ... args)
 
StarMatch get_allocator (StarMatch ... args)
 
StarMatch clear (StarMatch ... args)
 
StarMatch emplace (StarMatch ... args)
 
StarMatch begin (StarMatch ... args)
 

Public Attributes

StarMatch elements
 STL member.
 

Detailed Description

Definition at line 150 of file StarMatch.h.

Constructor & Destructor Documentation

◆ StarMatchList() [1/2]

lsst::jointcal::StarMatchList::StarMatchList ( )
inline

Definition at line 160 of file StarMatch.h.

160: _order(0), _chi2(0){};

◆ ~StarMatchList()

lsst::jointcal::StarMatchList::~StarMatchList ( )
default

◆ StarMatchList() [2/2]

lsst::jointcal::StarMatchList::StarMatchList ( const StarMatchList & )
delete

Member Function Documentation

◆ applyTransform()

void lsst::jointcal::StarMatchList::applyTransform ( StarMatchList & transformed,
const AstrometryTransform * priorTransform,
const AstrometryTransform * posteriorTransform = nullptr ) const

enables to get a transformed StarMatchList.

Only positions are transformed, not attached stars. const routine: "this" remains unchanged.

Definition at line 212 of file StarMatch.cc.

213 {
214 transformed.clear();
215 AstrometryTransformIdentity id;
216 const AstrometryTransform &T1 = (priorTransform) ? *priorTransform : id;
217 const AstrometryTransform &T2 = (posteriorTransform) ? *posteriorTransform : id;
218
219 for (auto const &starMatch : *this) {
220 FatPoint p1;
221 T1.transformPosAndErrors(starMatch.point1, p1);
222 FatPoint p2;
223 T2.transformPosAndErrors(starMatch.point2, p2);
224 transformed.push_back(StarMatch(p1, p2, starMatch.s1, starMatch.s2));
225 }
226}
table::Key< int > id
Definition Detector.cc:162

◆ computeResidual()

double lsst::jointcal::StarMatchList::computeResidual ( ) const

returns the average 1d Residual (last call to refineTransform)

Definition at line 134 of file StarMatch.cc.

134 {
135 int deno = (2. * size() - _transform->getNpar());
136 return (deno > 0) ? sqrt(_dist2 / deno) : -1; // is -1 a good idea?
137}
StarMatch size(StarMatch ... args)
T sqrt(T... args)

◆ cutTail()

void lsst::jointcal::StarMatchList::cutTail ( int nKeep)

deletes the tail of the match std::list

Definition at line 189 of file StarMatch.cc.

189 {
190 iterator si;
191 int count = 0;
192 for (si = begin(); si != end() && count < nKeep; ++count, ++si)
193 ;
194 erase(si, end());
195}
int end
StarMatch begin(StarMatch ... args)
T count(T... args)
StarMatch erase(StarMatch ... args)

◆ getChi2()

double lsst::jointcal::StarMatchList::getChi2 ( ) const
inline

access to the chi2 of the last call to refineTransform.

Definition at line 171 of file StarMatch.h.

171{ return _chi2; }

◆ getDist2()

double lsst::jointcal::StarMatchList::getDist2 ( ) const
inline

access to the sum of squared residuals of the last call to refineTransform.

Definition at line 168 of file StarMatch.h.

168{ return _dist2; }

◆ getTransform()

std::shared_ptr< const AstrometryTransform > lsst::jointcal::StarMatchList::getTransform ( ) const
inline

carries out a fit with outlier rejection

enables to access the fitted transformation.

Definition at line 165 of file StarMatch.h.

165{ return _transform; }

◆ getTransformOrder()

int lsst::jointcal::StarMatchList::getTransformOrder ( ) const
inline

returns the order of the used transform

Definition at line 174 of file StarMatch.h.

174{ return _order; }

◆ inverseTransform()

std::unique_ptr< AstrometryTransform > lsst::jointcal::StarMatchList::inverseTransform ( )

returns the inverse transform (swap, fit(refineTransform) , and swap).

The caller should delete the returned pointer.

Definition at line 172 of file StarMatch.cc.

172 {
173 if (!_transform) return nullptr;
174
175 auto old_transform = _transform->clone();
176 double old_chi2 = _chi2;
177
178 swap();
179 setTransformOrder(_order);
180 refineTransform(3.); // keep same order
181 auto inverted_transform = _transform->clone();
182 setTransform(old_transform.get());
183 swap();
184 _chi2 = old_chi2;
185
186 return inverted_transform;
187}
void swap()
swaps elements 1 and 2 of each starmatch in std::list.
Definition StarMatch.cc:197
void setTransform(const AstrometryTransform *transform)
sets a transform between the 2 std::lists and deletes the previous or default one....
Definition StarMatch.h:188
void setTransformOrder(int order)
set transform according to the given order.
Definition StarMatch.cc:158
void refineTransform(double nSigmas)
removes pairs beyond nSigmas in distance (where the sigma scale is set by the fit) and iterates until...
Definition StarMatch.cc:92

◆ operator=()

void lsst::jointcal::StarMatchList::operator= ( const StarMatchList & )
delete

◆ printTransform()

void lsst::jointcal::StarMatchList::printTransform ( std::ostream & stream = std::cout) const

print the matching transformation quality (transform, chi2, residual)

Definition at line 228 of file StarMatch.cc.

228 {
229 stream << " ================================================================" << std::endl
230 << " Transformation between lists of order " << getTransformOrder() << std::endl
231 << *_transform //<< endl
232 << " Chi2 = " << getChi2() << " Residual = " << computeResidual() << std::endl
233 << " Number in the list = " << size() << std::endl
234 << " ================================================================" << std::endl;
235}
double getChi2() const
access to the chi2 of the last call to refineTransform.
Definition StarMatch.h:171
int getTransformOrder() const
returns the order of the used transform
Definition StarMatch.h:174
double computeResidual() const
returns the average 1d Residual (last call to refineTransform)
Definition StarMatch.cc:134
T endl(T... args)

◆ recoveredNumber()

int lsst::jointcal::StarMatchList::recoveredNumber ( double mindist) const

count the number of elements for which distance is < mindist

Definition at line 203 of file StarMatch.cc.

203 {
204 int n = 0;
205 AstrometryTransformIdentity identity;
206 for (auto const &starMatch : *this) {
207 if (starMatch.computeDistance(identity) < mindist) n++;
208 }
209 return (n);
210}

◆ refineTransform()

void lsst::jointcal::StarMatchList::refineTransform ( double nSigmas)

removes pairs beyond nSigmas in distance (where the sigma scale is set by the fit) and iterates until stabilization of the number of pairs.

If the transform is not assigned, it will be set to a AstrometryTransformLinearear. User can set an other type/order using setTransform() before call.

Definition at line 92 of file StarMatch.cc.

92 {
93 double cut;
94 unsigned nremoved;
95 if (!_transform) _transform.reset(new AstrometryTransformLinear);
96 do {
97 int nused = size();
98 if (nused <= 2) {
99 _chi2 = -1;
100 break;
101 }
102 _chi2 = _transform->fit(*this);
103 /* convention of the fitted routines :
104 - chi2 = 0 means zero degrees of freedom
105 (this was not enforced in AstrometryTransform{Lin,Quad,Cub} ...)
106 - chi2 = -1 means ndof <0 (and hence no possible fit)
107 --> in either case, refinement is over
108 The fact that chi2 = 0 was not enforced when necessary means
109 that in this (rare) case, we were discarding matches at random....
110 With AstrometryTransformPolynomial::fit, this is no longer the case.
111 */
112 if (_chi2 <= 0) return;
113 unsigned npair = int(size());
114 if (npair == 0) break; // should never happen
115
116 // compute some chi2 statistics
117 std::vector<double> chi2_array(npair);
118 unsigned count = 0;
119 for (auto &starMatch : *this)
120 chi2_array[count++] = starMatch.chi2 = starMatch.computeChi2(*_transform);
121
122 std::sort(chi2_array.begin(), chi2_array.end());
123 double median = (npair & 1) ? chi2_array[npair / 2]
124 : (chi2_array[npair / 2 - 1] + chi2_array[npair / 2]) * 0.5;
125
126 // discard outliers : the cut is understood as a "distance" cut
127 cut = sq(nSigmas) * median;
128 nremoved = chi2_cleanup(*this, cut, *_transform);
129 } while (nremoved);
130 _dist2 = computeDist2(*this, *_transform);
131}
T end(T... args)
double computeDist2(const StarMatchList &S, const AstrometryTransform &transform)
sum of distance squared
Definition StarMatch.cc:237
double computeChi2(const StarMatchList &L, const AstrometryTransform &transform)
the actual chi2
Definition StarMatch.cc:244
T sort(T... args)

◆ removeAmbiguities()

unsigned lsst::jointcal::StarMatchList::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.

The distance is computed using transform. which = 1 (2) removes ambiguities on the first (second) term of the match. which=3 does both.

Definition at line 143 of file StarMatch.cc.

143 {
144 if (!which) return 0;
146 int initial_count = size();
147 if (which & 1) {
150 }
151 if (which & 2) {
154 }
155 return (initial_count - size());
156}
table::Key< int > transform
void setDistance(const AstrometryTransform &transform)
Sets the distance (residual) field of all std::list elements. Mandatory before sorting on distances.
Definition StarMatch.cc:139
bool compareStar1(const StarMatch &one, const StarMatch &two)
Definition StarMatch.h:116
bool sameStar2(const StarMatch &one, const StarMatch &two)
Definition StarMatch.h:126
bool sameStar1(const StarMatch &one, const StarMatch &two)
Definition StarMatch.h:120
bool compareStar2(const StarMatch &one, const StarMatch &two)
Definition StarMatch.h:122
StarMatch unique(StarMatch ... args)

◆ setDistance()

void lsst::jointcal::StarMatchList::setDistance ( const AstrometryTransform & transform)

Sets the distance (residual) field of all std::list elements. Mandatory before sorting on distances.

Definition at line 139 of file StarMatch.cc.

139 {
140 for (auto &smi : *this) smi.setDistance(transform); // c'est compact
141}

◆ setTransform() [1/3]

void lsst::jointcal::StarMatchList::setTransform ( const AstrometryTransform & transform)
inline

Definition at line 190 of file StarMatch.h.

190{ _transform = transform.clone(); }

◆ setTransform() [2/3]

void lsst::jointcal::StarMatchList::setTransform ( const AstrometryTransform * transform)
inline

sets a transform between the 2 std::lists and deletes the previous or default one. No fit.

Definition at line 188 of file StarMatch.h.

188{ _transform = transform->clone(); }

◆ setTransform() [3/3]

void lsst::jointcal::StarMatchList::setTransform ( std::shared_ptr< AstrometryTransform > transform)
inline

Definition at line 191 of file StarMatch.h.

191{ _transform = std::move(transform); }
T move(T... args)

◆ setTransformOrder()

void lsst::jointcal::StarMatchList::setTransformOrder ( int order)

set transform according to the given order.

Definition at line 158 of file StarMatch.cc.

158 {
159 if (order == 0)
160 setTransform(std::make_shared<AstrometryTransformLinearShift>());
161 else if (order == 1)
162 setTransform(std::make_shared<AstrometryTransformLinear>());
163 else
164 setTransform(AstrometryTransformPolynomial(order));
165 // might consider throwing if order does not make sense (e.g. >10)
166 _order = order;
167}
table::Key< int > order

◆ swap()

void lsst::jointcal::StarMatchList::swap ( )

swaps elements 1 and 2 of each starmatch in std::list.

Definition at line 197 of file StarMatch.cc.

197 {
198 for (auto &starMatch : *this) {
199 starMatch.swap();
200 }
201}

Member Data Documentation

◆ elements

StarMatch std::list< StarMatch >::elements
inherited

STL member.


The documentation for this class was generated from the following files: