LSST Applications 24.1.5,g02d81e74bb+fa3a7a026e,g180d380827+a53a32eff8,g2079a07aa2+86d27d4dc4,g2305ad1205+c0501b3732,g295015adf3+7d3e92f0ec,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+5dd1654d75,g48712c4677+3bf1020dcb,g487adcacf7+065c13d9cf,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+d7ac436cfb,g5a732f18d5+53520f316c,g64a986408d+fa3a7a026e,g858d7b2824+fa3a7a026e,g8a8a8dda67+585e252eca,g99cad8db69+a5a909b84f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+4cf350ccb2,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+f991a0b59f,gc120e1dc64+9ccbfdb8be,gc28159a63d+0e5473021a,gcf0d15dbbd+5dd1654d75,gd96a1ce819+42fd0ee607,gdaeeff99f8+f9a426f77a,ge6526c86ff+0d71447b4b,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+fa3a7a026e
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;
145 setDistance(transform);
146 int initial_count = size();
147 if (which & 1) {
150 }
151 if (which & 2) {
154 }
155 return (initial_count - size());
156}
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: