LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
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. More...
 
void applyTransform (StarMatchList &transformed, const AstrometryTransform *priorTransform, const AstrometryTransform *posteriorTransform=nullptr) const
 enables to get a transformed StarMatchList. More...
 
 StarMatchList ()
 
std::shared_ptr< const AstrometryTransformgetTransform () const
 carries out a fit with outlier rejection More...
 
double getDist2 () const
 access to the sum of squared residuals of the last call to refineTransform. More...
 
double getChi2 () const
 access to the chi2 of the last call to refineTransform. More...
 
int getTransformOrder () const
 returns the order of the used transform More...
 
void swap ()
 swaps elements 1 and 2 of each starmatch in std::list. More...
 
double computeResidual () const
 returns the average 1d Residual (last call to refineTransform) More...
 
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. More...
 
void setTransform (const AstrometryTransform *transform)
 sets a transform between the 2 std::lists and deletes the previous or default one. No fit. More...
 
void setTransform (const AstrometryTransform &transform)
 
void setTransform (std::shared_ptr< AstrometryTransform > transform)
 
void setTransformOrder (int order)
 set transform according to the given order. More...
 
std::unique_ptr< AstrometryTransforminverseTransform ()
 returns the inverse transform (swap, fit(refineTransform) , and swap). More...
 
void setDistance (const AstrometryTransform &transform)
 Sets the distance (residual) field of all std::list elements. Mandatory before sorting on distances. More...
 
void cutTail (int nKeep)
 deletes the tail of the match std::list More...
 
int recoveredNumber (double mindist) const
 count the number of elements for which distance is < mindist More...
 
void printTransform (std::ostream &stream=std::cout) const
 print the matching transformation quality (transform, chi2, residual) More...
 
 ~StarMatchList ()
 
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. More...
 

Detailed Description

Definition at line 149 of file StarMatch.h.

Constructor & Destructor Documentation

◆ StarMatchList()

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

Definition at line 159 of file StarMatch.h.

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

◆ ~StarMatchList()

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

Definition at line 211 of file StarMatch.h.

211 {/* should delete the transform.... or use counted refs*/};

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 214 of file StarMatch.cc.

215  {
216  transformed.clear();
217  AstrometryTransformIdentity id;
218  const AstrometryTransform &T1 = (priorTransform) ? *priorTransform : id;
219  const AstrometryTransform &T2 = (posteriorTransform) ? *posteriorTransform : id;
220 
221  for (auto const &starMatch : *this) {
222  FatPoint p1;
223  T1.transformPosAndErrors(starMatch.point1, p1);
224  FatPoint p2;
225  T2.transformPosAndErrors(starMatch.point2, p2);
226  transformed.push_back(StarMatch(p1, p2, starMatch.s1, starMatch.s2));
227  }
228 }
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 136 of file StarMatch.cc.

136  {
137  int deno = (2. * size() - _transform->getNpar());
138  return (deno > 0) ? sqrt(_dist2 / deno) : -1; // is -1 a good idea?
139 }
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 191 of file StarMatch.cc.

191  {
192  iterator si;
193  int count = 0;
194  for (si = begin(); si != end() && count < nKeep; ++count, ++si)
195  ;
196  erase(si, end());
197 }
StarMatch begin(StarMatch ... args)
T count(T... args)
StarMatch end(StarMatch ... 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 170 of file StarMatch.h.

170 { 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 167 of file StarMatch.h.

167 { 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 164 of file StarMatch.h.

164 { return _transform; }

◆ getTransformOrder()

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

returns the order of the used transform

Definition at line 173 of file StarMatch.h.

173 { 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 174 of file StarMatch.cc.

174  {
175  if (!_transform) return nullptr;
176 
177  auto old_transform = _transform->clone();
178  double old_chi2 = _chi2;
179 
180  swap();
181  setTransformOrder(_order);
182  refineTransform(3.); // keep same order
183  auto inverted_transform = _transform->clone();
184  setTransform(old_transform.get());
185  swap();
186  _chi2 = old_chi2;
187 
188  return inverted_transform;
189 }
void swap()
swaps elements 1 and 2 of each starmatch in std::list.
Definition: StarMatch.cc:199
void setTransform(const AstrometryTransform *transform)
sets a transform between the 2 std::lists and deletes the previous or default one....
Definition: StarMatch.h:187
void setTransformOrder(int order)
set transform according to the given order.
Definition: StarMatch.cc:160
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:94

◆ printTransform()

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

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

Definition at line 230 of file StarMatch.cc.

230  {
231  stream << " ================================================================" << std::endl
232  << " Transformation between lists of order " << getTransformOrder() << std::endl
233  << *_transform //<< endl
234  << " Chi2 = " << getChi2() << " Residual = " << computeResidual() << std::endl
235  << " Number in the list = " << size() << std::endl
236  << " ================================================================" << std::endl;
237 }
double getChi2() const
access to the chi2 of the last call to refineTransform.
Definition: StarMatch.h:170
int getTransformOrder() const
returns the order of the used transform
Definition: StarMatch.h:173
double computeResidual() const
returns the average 1d Residual (last call to refineTransform)
Definition: StarMatch.cc:136
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 205 of file StarMatch.cc.

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

◆ 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 94 of file StarMatch.cc.

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

145  {
146  if (!which) return 0;
148  int initial_count = size();
149  if (which & 1) {
151  unique(sameStar1);
152  }
153  if (which & 2) {
155  unique(sameStar2);
156  }
157  return (initial_count - size());
158 }
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:141
bool compareStar1(const StarMatch &one, const StarMatch &two)
Definition: StarMatch.h:115
bool sameStar2(const StarMatch &one, const StarMatch &two)
Definition: StarMatch.h:125
bool sameStar1(const StarMatch &one, const StarMatch &two)
Definition: StarMatch.h:119
bool compareStar2(const StarMatch &one, const StarMatch &two)
Definition: StarMatch.h:121
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 141 of file StarMatch.cc.

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

◆ setTransform() [1/3]

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

Definition at line 189 of file StarMatch.h.

189 { _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 187 of file StarMatch.h.

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

◆ setTransform() [3/3]

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

Definition at line 190 of file StarMatch.h.

190 { _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 160 of file StarMatch.cc.

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

◆ swap()

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

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

Definition at line 199 of file StarMatch.cc.

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

Member Data Documentation

◆ elements

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

STL member.


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