LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
Namespaces | Classes | Typedefs | Enumerations | Functions
lsst::jointcal Namespace Reference

Namespaces

 dataIds
 
 jointcal
 
 testUtils
 
 utils
 
 version
 

Classes

class  Associations
 The class that implements the relations between MeasuredStar and FittedStar. More...
 
class  AstrometryFit
 Class that handles the astrometric least squares problem. More...
 
class  AstrometryMapping
 virtual class needed in the abstraction of the distortion model More...
 
class  AstrometryModel
 Interface between AstrometryFit and the combinations of Mappings from pixels to some tangent plane (aka distortions). More...
 
class  AstrometryTransform
 a virtual (interface) class for geometric transformations. More...
 
class  AstrometryTransformComposition
 Private class to handle AstrometryTransform compositions (i.e. More...
 
class  AstrometryTransformIdentity
 A do-nothing transformation. It anyway has dummy routines to mimick a AstrometryTransform. More...
 
class  AstrometryTransformInverse
 
class  AstrometryTransformLinear
 implements the linear transformations (6 real coefficients). More...
 
class  AstrometryTransformLinearRot
 just here to provide a specialized constructor, and fit. More...
 
class  AstrometryTransformLinearScale
 just here to provide specialized constructors. AstrometryTransformLinear fit routine. More...
 
class  AstrometryTransformLinearShift
 just here to provide a specialized constructor, and fit. More...
 
class  AstrometryTransformPolynomial
 Polynomial transformation class. More...
 
class  AstrometryTransformSkyWcs
 A AstrometryTransform that holds a SkyWcs. More...
 
class  BaseStar
 The base class for handling stars. Used by all matching routines. More...
 
class  BaseTanWcs
 
class  CcdImage
 Handler of an actual image from a single CCD. More...
 
struct  CcdImageKey
 For hashing a ccdImage: the pair of (visit, ccd) IDs should be unique to each ccdImage. More...
 
class  Chi2Accumulator
 Base class for Chi2Statistic and Chi2List, to allow addEntry inside Fitter for either class. More...
 
class  Chi2List
 Structure to accumulate the chi2 contributions per each star (to help find outliers). More...
 
struct  Chi2Star
 
class  Chi2Statistic
 Simple structure to accumulate chi2 and ndof. More...
 
class  ChipVisitAstrometryMapping
 The mapping with two transforms in a row. More...
 
class  ChipVisitFluxMapping
 
class  ChipVisitMagnitudeMapping
 
class  ChipVisitPhotometryMapping
 A two-level photometric transform: one for the ccd and one for the visit. More...
 
class  ConstrainedAstrometryModel
 A multi-component model, fitting mappings for sensors and visits simultaneously. More...
 
class  ConstrainedFluxModel
 
class  ConstrainedMagnitudeModel
 
class  ConstrainedPhotometryModel
 Photometry model with constraints, \(M(x,y) = M_CCD(x,y)*M_visit(u,v)\). More...
 
class  FastFinder
 This is an auxillary class for matching objects from starlists. More...
 
class  FatPoint
 A Point with uncertainties. More...
 
class  FittedStar
 The objects which have been measured several times. More...
 
class  FittedStarList
 A list of FittedStar s. Such a list is typically constructed by Associations. More...
 
class  FitterBase
 Base class for fitters. More...
 
class  FluxTransformChebyshev
 nth-order 2d Chebyshev photometry transform, times the input flux. More...
 
class  FluxTransformSpatiallyInvariant
 Photometric offset independent of position, defined as (fluxMag0)^-1. More...
 
class  Frame
 rectangle with sides parallel to axes. More...
 
class  Histo2d
 
class  IdentityProjectionHandler
 The simplest implementation of ProjectionHandler. More...
 
struct  JointcalControl
 
class  MagnitudeTransformChebyshev
 nth-order 2d Chebyshev photometry transform, plus the input flux. More...
 
class  MagnitudeTransformSpatiallyInvariant
 Photometric offset independent of position, defined as -2.5 * log(flux / fluxMag0). More...
 
struct  MatchConditions
 Parameters to be provided to combinatorial searches. More...
 
class  MeasuredStar
 objects measured on actual images. More...
 
class  MeasuredStarList
 A list of MeasuredStar. They are usually filled in Associations::createCcdImage. More...
 
class  OneTPPerVisitHandler
 A projection handler in which all CCDs from the same visit have the same tangent point. More...
 
class  PhotometryFit
 Class that handles the photometric least squares problem. More...
 
class  PhotometryMapping
 A mapping containing a single photometryTransform. More...
 
class  PhotometryMappingBase
 Relates transform(s) to their position in the fitting matrix and allows interaction with the transform(s). More...
 
class  PhotometryModel
 
class  PhotometryTransform
 A photometric transform, defined in terms of the input flux or magnitude. More...
 
class  PhotometryTransformChebyshev
 nth-order 2d Chebyshev photometry transform. More...
 
class  PhotometryTransformSpatiallyInvariant
 Photometry offset independent of position. More...
 
struct  PmBlock
 objects whose position is going to be fitted. Coordinates in Common Tangent Plane. More...
 
class  Point
 A point in a plane. More...
 
class  PolyXY
 
struct  ProjectionHandler
 This is a virtual class that allows a lot of freedom in the choice of the projection from "Sky" (where coodinates are reported) to tangent plane (where they are compared to transformed measurements) More...
 
class  RefStar
 Objects used as position anchors, typically USNO stars. More...
 
class  RefStarList
 
struct  Segment
 
class  SegmentList
 
struct  SegmentPair
 
class  SimpleAstrometryMapping
 
class  SimpleAstrometryModel
 A model where there is one independent transform per CcdImage. More...
 
class  SimpleFluxModel
 
class  SimpleMagnitudeModel
 
class  SimplePhotometryModel
 Photometric response model which has a single photometric factor per CcdImage. More...
 
class  SimplePolyMapping
 Mapping implementation for a polynomial transformation. More...
 
class  SparseHisto4d
 A class to histogram in 4 dimensions. More...
 
class  StarList
 std::lists of Stars. More...
 
class  StarMatch
 A hanger for star associations. More...
 
class  StarMatchList
 
class  TanPixelToRaDec
 The transformation that handles pixels to sideral transformations (Gnomonic, possibly with polynomial distortions). More...
 
class  TanRaDecToPixel
 This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane) More...
 
class  TanSipPixelToRaDec
 Implements the (forward) SIP distorsion scheme. More...
 
class  TripletList
 
class  UserTransform
 A run-time transform that allows users to define a AstrometryTransform with minimal coding (just the apply routine). More...
 

Typedefs

using RefFluxMapType = std::map< std::string, std::vector< double > >
 
typedef void() AstrometryTransformFun(const double, const double, double &, double &, const void *)
 signature of the user-provided routine that actually does the coordinate transform for UserTransform. More...
 
typedef StarList< BaseStarBaseStarList
 
typedef BaseStarList::const_iterator BaseStarCIterator
 
typedef BaseStarList::iterator BaseStarIterator
 
typedef std::list< std::shared_ptr< CcdImage > > CcdImageList
 
typedef int VisitIdType
 
typedef int CcdIdType
 
typedef FittedStarList::const_iterator FittedStarCIterator
 
typedef FittedStarList::iterator FittedStarIterator
 
typedef MeasuredStarList::const_iterator MeasuredStarCIterator
 
typedef MeasuredStarList::iterator MeasuredStarIterator
 
typedef RefStarList::const_iterator RefStarCIterator
 
typedef RefStarList::iterator RefStarIterator
 
typedef ::std::list< StarMatch >::iterator StarMatchIterator
 
typedef ::std::list< StarMatch >::const_iterator StarMatchCIterator
 
typedef Eigen::Triplet< double > Trip
 
using Iterator = FastFinder::Iterator
 
typedef std::list< Segment >::iterator SegmentIterator
 
typedef std::list< Segment >::const_iterator SegmentCIterator
 
typedef std::list< SegmentPairSegmentPairList
 
typedef SegmentPairList::iterator SegmentPairListIterator
 
typedef SegmentPairList::const_iterator SegmentPairListCIterator
 
using SolList = std::list< std::unique_ptr< StarMatchList > >
 

Enumerations

enum  MinimizeResult { MinimizeResult::Converged, MinimizeResult::Chi2Increased, MinimizeResult::Failed, MinimizeResult::NonFinite }
 Return value of minimize() More...
 

Functions

std::ostreamoperator<< (std::ostream &stream, AstrometryTransform const &transform)
 Delegates to transform.dump() More...
 
std::unique_ptr< AstrometryTransformcompose (AstrometryTransform const &left, AstrometryTransform const &right)
 Returns a pointer to a composition of transforms, representing left(right()). More...
 
std::unique_ptr< AstrometryTransformcompose (AstrometryTransform const &left, AstrometryTransformIdentity const &right)
 
bool isIntegerShift (const AstrometryTransform *transform)
 Shorthand test to tell if a transform is a simple integer shift. More...
 
std::shared_ptr< AstrometryTransformPolynomialinversePolyTransform (AstrometryTransform const &forward, Frame const &domain, double const precision, std::size_t maxOrder=9, std::size_t nSteps=50)
 Approximate the inverse by a polynomial, to some precision. More...
 
AstrometryTransformLinear normalizeCoordinatesTransform (const Frame &frame)
 Returns the transformation that maps the input frame along both axes to [-1,1]. More...
 
std::unique_ptr< AstrometryTransformastrometryTransformRead (const std::string &fileName)
 The virtual constructor from a file. More...
 
std::unique_ptr< AstrometryTransformastrometryTransformRead (std::istream &s)
 The virtual constructor from a file. More...
 
std::ostreamoperator<< (std::ostream &out, CcdImageKey const &key)
 
BaseStarListFitted2Base (FittedStarList &This)
 
BaseStarListFitted2Base (FittedStarList *This)
 
const BaseStarListFitted2Base (const FittedStarList &This)
 
const BaseStarListFitted2Base (const FittedStarList *This)
 
std::unique_ptr< StarMatchListmatchSearchRotShift (BaseStarList &list1, BaseStarList &list2, const MatchConditions &conditions)
 searches a geometrical transformation that goes from list1 to list2. More...
 
std::unique_ptr< StarMatchListmatchSearchRotShiftFlip (BaseStarList &list1, BaseStarList &list2, const MatchConditions &conditions)
 same as above but searches also a flipped solution. More...
 
std::unique_ptr< StarMatchListlistMatchCollect (const BaseStarList &list1, const BaseStarList &list2, const AstrometryTransform *guess, const double maxDist)
 assembles star matches. More...
 
std::unique_ptr< StarMatchListlistMatchCollect (const BaseStarList &list1, const BaseStarList &list2, const double maxDist)
 same as before except that the transform is the identity More...
 
std::unique_ptr< AstrometryTransformLinearlistMatchupShift (const BaseStarList &list1, const BaseStarList &list2, const AstrometryTransform &transform, double maxShift, double binSize=0)
 searches for a 2 dimensional shift using a very crude histogram method. More...
 
std::unique_ptr< AstrometryTransformlistMatchCombinatorial (const BaseStarList &list1, const BaseStarList &list2, const MatchConditions &conditions=MatchConditions())
 
std::unique_ptr< AstrometryTransformlistMatchRefine (const BaseStarList &list1, const BaseStarList &list2, std::unique_ptr< AstrometryTransform > transform, const int maxOrder=3)
 
BaseStarListMeasured2Base (MeasuredStarList &This)
 
BaseStarListMeasured2Base (MeasuredStarList *This)
 
const BaseStarListMeasured2Base (const MeasuredStarList &This)
 
const BaseStarListMeasured2Base (const MeasuredStarList *This)
 
std::ostreamoperator<< (std::ostream &stream, const Point &point)
 
BaseStarListRef2Base (RefStarList &This)
 
BaseStarListRef2Base (RefStarList *This)
 
const BaseStarListRef2Base (const RefStarList &This)
 
const BaseStarListRef2Base (const RefStarList *This)
 
template<class Star >
std::ostreamoperator<< (std::ostream &stream, const StarList< Star > &list)
 enables More...
 
bool compareStar1 (const StarMatch &one, const StarMatch &two)
 
bool sameStar1 (const StarMatch &one, const StarMatch &two)
 
bool compareStar2 (const StarMatch &one, const StarMatch &two)
 
bool sameStar2 (const StarMatch &one, const StarMatch &two)
 
std::ostreamoperator<< (std::ostream &stream, const StarMatch &match)
 
std::ostreamoperator<< (std::ostream &stream, const StarMatchList &starMatchList)
 A std::list of star matches,. More...
 
double computeDist2 (const StarMatchList &S, const AstrometryTransform &transform)
 sum of distance squared More...
 
double computeChi2 (const StarMatchList &L, const AstrometryTransform &transform)
 the actual chi2 More...
 
std::ostreamoperator<< (std::ostream &s, Chi2List const &chi2List)
 

Typedef Documentation

◆ AstrometryTransformFun

typedef void() lsst::jointcal::AstrometryTransformFun(const double, const double, double &, double &, const void *)

signature of the user-provided routine that actually does the coordinate transform for UserTransform.

Definition at line 750 of file AstrometryTransform.h.

◆ BaseStarCIterator

typedef BaseStarList::const_iterator lsst::jointcal::BaseStarCIterator

Definition at line 121 of file BaseStar.h.

◆ BaseStarIterator

typedef BaseStarList::iterator lsst::jointcal::BaseStarIterator

Definition at line 122 of file BaseStar.h.

◆ BaseStarList

Definition at line 119 of file BaseStar.h.

◆ CcdIdType

Definition at line 49 of file CcdImage.h.

◆ CcdImageList

Definition at line 46 of file CcdImage.h.

◆ FittedStarCIterator

typedef FittedStarList::const_iterator lsst::jointcal::FittedStarCIterator

Definition at line 131 of file FittedStar.h.

◆ FittedStarIterator

typedef FittedStarList::iterator lsst::jointcal::FittedStarIterator

Definition at line 132 of file FittedStar.h.

◆ Iterator

Definition at line 179 of file FastFinder.cc.

◆ MeasuredStarCIterator

typedef MeasuredStarList::const_iterator lsst::jointcal::MeasuredStarCIterator

Definition at line 153 of file MeasuredStar.h.

◆ MeasuredStarIterator

typedef MeasuredStarList::iterator lsst::jointcal::MeasuredStarIterator

Definition at line 154 of file MeasuredStar.h.

◆ RefFluxMapType

Definition at line 51 of file Associations.h.

◆ RefStarCIterator

typedef RefStarList::const_iterator lsst::jointcal::RefStarCIterator

Definition at line 57 of file RefStar.h.

◆ RefStarIterator

typedef RefStarList::iterator lsst::jointcal::RefStarIterator

Definition at line 58 of file RefStar.h.

◆ SegmentCIterator

Definition at line 92 of file ListMatch.cc.

◆ SegmentIterator

Definition at line 91 of file ListMatch.cc.

◆ SegmentPairList

Definition at line 119 of file ListMatch.cc.

◆ SegmentPairListCIterator

typedef SegmentPairList::const_iterator lsst::jointcal::SegmentPairListCIterator

Definition at line 121 of file ListMatch.cc.

◆ SegmentPairListIterator

typedef SegmentPairList::iterator lsst::jointcal::SegmentPairListIterator

Definition at line 120 of file ListMatch.cc.

◆ SolList

Definition at line 157 of file ListMatch.cc.

◆ StarMatchCIterator

Definition at line 134 of file StarMatch.h.

◆ StarMatchIterator

Definition at line 133 of file StarMatch.h.

◆ Trip

typedef Eigen::Triplet<double> lsst::jointcal::Trip

Definition at line 35 of file Tripletlist.h.

◆ VisitIdType

Definition at line 48 of file CcdImage.h.

Enumeration Type Documentation

◆ MinimizeResult

Return value of minimize()

Enumerator
Converged 
Chi2Increased 
Failed 
NonFinite 

Definition at line 40 of file FitterBase.h.

40  {
41  Converged, // fit has converged - no more outliers
42  Chi2Increased, // still some ouliers but chi2 increases
43  Failed, // factorization failed
44  NonFinite // non-finite chi2 statistic
45 };

Function Documentation

◆ astrometryTransformRead() [1/2]

std::unique_ptr< AstrometryTransform > lsst::jointcal::astrometryTransformRead ( const std::string fileName)

The virtual constructor from a file.

Definition at line 1781 of file AstrometryTransform.cc.

1781  {
1782  ifstream s(fileName.c_str());
1783  if (!s)
1784  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1785  " astrometryTransformRead : cannot open " + fileName);
1786  try {
1788  s.close();
1789  return res;
1790  } catch (pex::exceptions::InvalidParameterError &e) {
1791  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1792  std::string(e.what()) + " in file " + fileName);
1793  }
1794 }
STL class.
std::unique_ptr< AstrometryTransform > astrometryTransformRead(const std::string &fileName)
The virtual constructor from a file.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
STL class.
T c_str(T... args)
STL class.

◆ astrometryTransformRead() [2/2]

std::unique_ptr< AstrometryTransform > lsst::jointcal::astrometryTransformRead ( std::istream s)

The virtual constructor from a file.

Definition at line 1796 of file AstrometryTransform.cc.

1796  {
1797  std::string type;
1798  s >> type;
1799  if (s.fail())
1800  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1801  "astrometryTransformRead : could not find a AstrometryTransformtype");
1802  if (type == "AstrometryTransformIdentity") {
1803  std::unique_ptr<AstrometryTransformIdentity> res(new AstrometryTransformIdentity());
1804  res->read(s);
1805  return std::move(res);
1806  } else if (type == "AstrometryTransformPolynomial") {
1807  std::unique_ptr<AstrometryTransformPolynomial> res(new AstrometryTransformPolynomial());
1808  res->read(s);
1809  return std::move(res);
1810  } else
1811  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1812  " astrometryTransformRead : No reader for AstrometryTransform type " + type);
1813 }
T fail(T... args)
STL class.
table::Key< int > type
Definition: Detector.cc:163
T move(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
STL class.

◆ compareStar1()

bool lsst::jointcal::compareStar1 ( const StarMatch one,
const StarMatch two 
)
inline

Definition at line 115 of file StarMatch.h.

115  {
116  return ((one.s1 == two.s1) ? (one.distance < two.distance) : (&(*one.s1) > &(*two.s1)));
117 }

◆ compareStar2()

bool lsst::jointcal::compareStar2 ( const StarMatch one,
const StarMatch two 
)
inline

Definition at line 121 of file StarMatch.h.

121  {
122  return ((one.s2 == two.s2) ? (one.distance < two.distance) : (&(*one.s2) > &(*two.s2)));
123 }

◆ compose() [1/2]

std::unique_ptr< AstrometryTransform > lsst::jointcal::compose ( AstrometryTransform const &  left,
AstrometryTransform const &  right 
)

Returns a pointer to a composition of transforms, representing left(right()).

Deletion of returned value to be done by caller.

If left->composeAndReduce(right) returns NULL, build a AstrometryTransformComposition and return it. This routine implements "run-time" compositions. When there is a possible "reduction" (e.g. compositions of polynomials), compose detects it and returns a genuine AstrometryTransform.

Returns
The composed transform.

Definition at line 424 of file AstrometryTransform.cc.

425  {
426  // Try to use the composeAndReduce method from left. If absent, AstrometryTransform::composeAndReduce
427  // returns NULL. composeAndReduce is non trivial for polynomials.
428  std::unique_ptr<AstrometryTransform> composition(left.composeAndReduce(right));
429  // composition == NULL means no reduction: just build a Composition that pipelines "left" and "right".
430  if (composition == nullptr)
431  return std::make_unique<AstrometryTransformComposition>(left, right);
432  else
433  return composition;
434 }
T left(T... args)
STL class.

◆ compose() [2/2]

std::unique_ptr< AstrometryTransform > lsst::jointcal::compose ( AstrometryTransform const &  left,
AstrometryTransformIdentity const &  right 
)

Definition at line 419 of file AstrometryTransform.cc.

420  {
421  return left.clone();
422 }
T left(T... args)

◆ computeChi2()

double lsst::jointcal::computeChi2 ( const StarMatchList L,
const AstrometryTransform transform 
)

the actual chi2

Definition at line 246 of file StarMatch.cc.

246  {
247  unsigned s = starMatchList.size();
248  std::unique_ptr<double[]> chi2s(chi2_array(starMatchList, transform));
249  double chi2 = 0;
250  for (unsigned k = 0; k < s; ++k) chi2 += chi2s[k];
251  return chi2;
252 }
STL class.

◆ computeDist2()

double lsst::jointcal::computeDist2 ( const StarMatchList S,
const AstrometryTransform transform 
)

sum of distance squared

Definition at line 239 of file StarMatch.cc.

239  {
240  double dist2 = 0;
241  for (auto const &starMatch : starMatchList)
242  dist2 += transform.apply(starMatch.point1).computeDist2(starMatch.point2);
243  return dist2;
244 }

◆ Fitted2Base() [1/4]

BaseStarList & lsst::jointcal::Fitted2Base ( FittedStarList This)

Definition at line 64 of file FittedStar.cc.

64 { return (BaseStarList &)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ Fitted2Base() [2/4]

BaseStarList * lsst::jointcal::Fitted2Base ( FittedStarList This)

Definition at line 66 of file FittedStar.cc.

66 { return (BaseStarList *)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ Fitted2Base() [3/4]

const BaseStarList & lsst::jointcal::Fitted2Base ( const FittedStarList This)

Definition at line 68 of file FittedStar.cc.

68 { return (const BaseStarList &)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ Fitted2Base() [4/4]

const BaseStarList * lsst::jointcal::Fitted2Base ( const FittedStarList This)

Definition at line 70 of file FittedStar.cc.

70 { return (BaseStarList *)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ inversePolyTransform()

std::shared_ptr< AstrometryTransformPolynomial > lsst::jointcal::inversePolyTransform ( AstrometryTransform const &  forward,
Frame const &  domain,
double const  precision,
std::size_t  maxOrder = 9,
std::size_t  nSteps = 50 
)

Approximate the inverse by a polynomial, to some precision.

Parameters
forwardTransform to be inverted.
[in]domainThe domain of forward.
[in]precisionRequire that \(chi2 / (nsteps^2) < precision^2\).
[in]maxOrderThe maximum order allowed of the inverse polynomial.
[in]nStepsThe number of sample points per axis (nSteps^2 total points).
Returns
A polynomial that best approximates forward.

Definition at line 1132 of file AstrometryTransform.cc.

1136  {
1137  StarMatchList sm;
1138  double xStart = domain.xMin;
1139  double yStart = domain.yMin;
1140  double xStep = domain.getWidth() / (nSteps - 1);
1141  double yStep = domain.getHeight() / (nSteps - 1);
1142  for (std::size_t i = 0; i < nSteps; ++i) {
1143  for (std::size_t j = 0; j < nSteps; ++j) {
1144  Point in(xStart + i * xStep, yStart + j * yStep);
1145  Point out(forward.apply(in));
1146  sm.push_back(StarMatch(out, in, nullptr, nullptr));
1147  }
1148  }
1149  std::size_t npairs = sm.size();
1150  std::size_t order;
1153  double chi2 = 0;
1154  double oldChi2 = std::numeric_limits<double>::infinity();
1155  for (order = 1; order <= maxOrder; ++order) {
1156  poly.reset(new AstrometryTransformPolynomial(order));
1157  auto success = poly->fit(sm);
1158  if (success == -1) {
1159  std::stringstream errMsg;
1160  errMsg << "Cannot fit a polynomial of order " << order << " with " << nSteps << "^2 points";
1161  throw pexExcept::RuntimeError(errMsg.str());
1162  }
1163  // compute the chi2 ignoring errors:
1164  chi2 = 0;
1165  for (auto const &i : sm) chi2 += i.point2.computeDist2(poly->apply((i.point1)));
1166  LOGLS_TRACE(_log, "inversePoly order " << order << ": " << chi2 << " / " << npairs << " = "
1167  << chi2 / npairs << " < " << precision * precision);
1168 
1169  if (chi2 / npairs < precision * precision) break;
1170 
1171  // If this triggers, we know we did not reach the required precision.
1172  if (chi2 > oldChi2) {
1173  LOGLS_WARN(_log, "inversePolyTransform: chi2 increases ("
1174  << chi2 << " > " << oldChi2 << "); ending fit with order: " << order);
1175  LOGLS_WARN(_log, "inversePolyTransform: requested precision not reached: "
1176  << chi2 << " / " << npairs << " = " << chi2 / npairs << " < "
1177  << precision * precision);
1178  poly = std::move(oldPoly);
1179  order--;
1180  break;
1181  } else {
1182  oldChi2 = chi2;
1183  // Clone it so we don't lose it in the next iteration.
1184  oldPoly = dynamic_pointer_cast<AstrometryTransformPolynomial>(
1185  std::shared_ptr<AstrometryTransform>(poly->clone()));
1186  }
1187  }
1188  if (order > maxOrder)
1189  LOGLS_WARN(_log, "inversePolyTransform: Reached max order without reaching requested precision: "
1190  << chi2 << " / " << npairs << " = " << chi2 / npairs << " < "
1191  << precision * precision);
1192  return poly;
1193 }
#define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
Definition: Log.h:648
Low-level polynomials (including special polynomials) in C++.
Definition: Basis1d.h:26
#define LOGLS_TRACE(logger, message)
Log a trace-level message using an iostream-based interface.
Definition: Log.h:588
T str(T... args)
T reset(T... args)
T dynamic_pointer_cast(T... args)
T infinity(T... args)
T move(T... args)
T forward(T... args)
Reports errors that are due to events beyond the control of the program.
Definition: Runtime.h:104

◆ isIntegerShift()

bool lsst::jointcal::isIntegerShift ( const AstrometryTransform transform)

Shorthand test to tell if a transform is a simple integer shift.

Definition at line 55 of file AstrometryTransform.cc.

55  {
56  const AstrometryTransformPolynomial *shift =
57  dynamic_cast<const AstrometryTransformPolynomial *>(transform);
58  if (shift == nullptr) return false;
59 
60  static const double eps = 1e-5;
61 
62  double dx = shift->coeff(0, 0, 0);
63  double dy = shift->coeff(0, 0, 1);
64 
65  static Point dumb(4000, 4000);
66  if (fabs(dx - int(floor(dx + 0.5))) < eps && fabs(dy - int(floor(dy + 0.5))) < eps &&
67  fabs(dumb.x + dx - shift->apply(dumb).x) < eps && fabs(dumb.y + dy - shift->apply(dumb).y) < eps)
68  return true;
69 
70  return false;
71 }
T fabs(T... args)
Extent< int, N > floor(Extent< double, N > const &input) noexcept
Return the component-wise floor (round towards more negative).
Definition: Extent.cc:109
table::Key< int > transform

◆ listMatchCollect() [1/2]

std::unique_ptr< StarMatchList > lsst::jointcal::listMatchCollect ( const BaseStarList list1,
const BaseStarList list2,
const AstrometryTransform guess,
const double  maxDist 
)

assembles star matches.

It picks stars in list1, transforms them through guess, and collects closest star in list2, and builds a match if closer than maxDist).

Definition at line 569 of file ListMatch.cc.

570  {
571  std::unique_ptr<StarMatchList> matches(new StarMatchList);
572  /****** Collect ***********/
573  FastFinder finder(list2);
574  for (BaseStarCIterator si = list1.begin(); si != list1.end(); ++si) {
575  auto p1 = (*si);
576  Point p2 = guess->apply(*p1);
577  auto neighbour = finder.findClosest(p2, maxDist);
578  if (!neighbour) continue;
579  double distance = p2.Distance(*neighbour);
580  if (distance < maxDist) {
581  matches->push_back(StarMatch(*p1, *neighbour, p1, neighbour));
582  // assign the distance, since we have it in hand:
583  matches->back().distance = distance;
584  }
585  }
586  matches->setTransform(guess);
587 
588  return matches;
589 }
BaseStarList::const_iterator BaseStarCIterator
Definition: BaseStar.h:121
STL class.

◆ listMatchCollect() [2/2]

std::unique_ptr< StarMatchList > lsst::jointcal::listMatchCollect ( const BaseStarList list1,
const BaseStarList list2,
const double  maxDist 
)

same as before except that the transform is the identity

Definition at line 615 of file ListMatch.cc.

616  {
617  std::unique_ptr<StarMatchList> matches(new StarMatchList);
618  FastFinder finder(list2);
619  for (BaseStarCIterator si = list1.begin(); si != list1.end(); ++si) {
620  auto p1 = (*si);
621  auto neighbour = finder.findClosest(*p1, maxDist);
622  if (!neighbour) continue;
623  double distance = p1->Distance(*neighbour);
624  if (distance < maxDist) {
625  matches->push_back(StarMatch(*p1, *neighbour, p1, neighbour));
626  // assign the distance, since we have it in hand:
627  matches->back().distance = distance;
628  }
629  }
630 
631  matches->setTransform(std::make_shared<AstrometryTransformIdentity>());
632 
633  return matches;
634 }
BaseStarList::const_iterator BaseStarCIterator
Definition: BaseStar.h:121
STL class.

◆ listMatchCombinatorial()

std::unique_ptr< AstrometryTransform > lsst::jointcal::listMatchCombinatorial ( const BaseStarList list1,
const BaseStarList list2,
const MatchConditions conditions = MatchConditions() 
)

Definition at line 680 of file ListMatch.cc.

682  {
683  BaseStarList list1, list2;
684  List1.copyTo(list1);
685  list1.fluxSort();
686  List2.copyTo(list2);
687  list2.fluxSort();
688 
689  LOGLS_INFO(_log, "listMatchCombinatorial: find match between " << list1.size() << " and " << list2.size()
690  << " stars...");
691  auto match = matchSearchRotShiftFlip(list1, list2, conditions);
692  double pixSizeRatio2 = std::pow(conditions.sizeRatio, 2);
693  size_t nmin =
694  std::min(size_t(10), size_t(std::min(List1.size(), List2.size()) * conditions.minMatchRatio));
695 
697  if (is_transform_ok(match.get(), pixSizeRatio2, nmin))
698  transform = match->getTransform()->clone();
699  else {
700  LOGL_ERROR(_log, "listMatchCombinatorial: direct transform failed, trying reverse");
701  match = matchSearchRotShiftFlip(list2, list1, conditions);
702  if (is_transform_ok(match.get(), pixSizeRatio2, nmin))
703  transform = match->inverseTransform();
704  else {
705  LOGL_FATAL(_log, "FAILED");
706  }
707  }
708 
709  if (transform) {
710  LOGL_INFO(_log, "FOUND");
711  if (conditions.printLevel >= 1) {
712  LOGL_DEBUG(_log, " listMatchCombinatorial: found the following transform.");
713  LOGLS_DEBUG(_log, *transform);
714  }
715  } else
716  LOGL_ERROR(_log, "listMatchCombinatorial: failed to find a transform");
717  return transform;
718 }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119
#define LOGL_ERROR(logger, message...)
Log a error-level message using a varargs/printf style interface.
Definition: Log.h:552
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
Definition: Log.h:504
T min(T... args)
std::unique_ptr< StarMatchList > matchSearchRotShiftFlip(BaseStarList &list1, BaseStarList &list2, const MatchConditions &conditions)
same as above but searches also a flipped solution.
Definition: ListMatch.cc:433
#define LOGL_INFO(logger, message...)
Log a info-level message using a varargs/printf style interface.
Definition: Log.h:520
#define LOGL_FATAL(logger, message...)
Log a fatal-level message using a varargs/printf style interface.
Definition: Log.h:568
#define LOGLS_DEBUG(logger, message)
Log a debug-level message using an iostream-based interface.
Definition: Log.h:608
#define LOGLS_INFO(logger, message)
Log a info-level message using an iostream-based interface.
Definition: Log.h:628
STL class.
T pow(T... args)
table::Key< int > transform

◆ listMatchRefine()

std::unique_ptr< AstrometryTransform > lsst::jointcal::listMatchRefine ( const BaseStarList list1,
const BaseStarList list2,
std::unique_ptr< AstrometryTransform transform,
const int  maxOrder = 3 
)

Definition at line 720 of file ListMatch.cc.

722  {
723  if (!transform) {
724  return std::unique_ptr<AstrometryTransform>(nullptr);
725  }
726 
727  // some hard-coded constants that could go in a param file
728  const double brightDist = 2.; // distance in pixels in a match
729  const double fullDist = 4.; // distance in pixels in a match between entire lists
730  const double nSigmas = 3.; // k-sigma clipping on residuals
731  const size_t nStars = 500; // max number of bright stars to fit
732 
733  int order = 1;
734  size_t nstarmin = 3;
735 
736  BaseStarList list1, list2;
737  List1.copyTo(list1);
738  list1.fluxSort();
739  list1.cutTail(nStars);
740  List2.copyTo(list2);
741  list2.fluxSort();
742  list2.cutTail(nStars);
743 
744  auto fullMatch = listMatchCollect(List1, List2, transform.get(), fullDist);
745  auto brightMatch = listMatchCollect(list1, list2, transform.get(), brightDist);
746  double curChi2 = computeChi2(*brightMatch, *transform) / brightMatch->size();
747 
748  LOGLS_INFO(_log, "listMatchRefine: start: med.resid " << median_distance(fullMatch.get(), transform.get())
749  << " #match " << fullMatch->size());
750 
751  do { // loop on transform order on full list of stars
752  auto curTransform = brightMatch->getTransform()->clone();
753  unsigned iter = 0;
754  double transDiff;
755  do { // loop on transform diff only on bright stars
756  brightMatch->setTransformOrder(order);
757  brightMatch->refineTransform(nSigmas);
758  transDiff = transform_diff(list1, brightMatch->getTransform().get(), curTransform.get());
759  curTransform = brightMatch->getTransform()->clone();
760  brightMatch = listMatchCollect(list1, list2, curTransform.get(), brightDist);
761  } while (brightMatch->size() > nstarmin && transDiff > 0.05 && ++iter < 5);
762 
763  double prevChi2 = curChi2;
764  curChi2 = computeChi2(*brightMatch, *curTransform) / brightMatch->size();
765 
766  fullMatch = listMatchCollect(List1, List2, curTransform.get(), fullDist);
767  LOGLS_INFO(_log, "listMatchRefine: order " << order << " med.resid "
768  << median_distance(fullMatch.get(), curTransform.get())
769  << " #match " << fullMatch->size());
770  if (((prevChi2 - curChi2) > 0.01 * curChi2) && curChi2 > 0) {
771  LOGLS_INFO(_log, " listMatchRefine: order " << order << " was a better guess.");
772  transform = brightMatch->getTransform()->clone();
773  }
774  nstarmin = brightMatch->getTransform()->getNpar();
775  } while (++order <= maxOrder);
776 
777  return transform;
778 }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119
std::unique_ptr< StarMatchList > listMatchCollect(const BaseStarList &list1, const BaseStarList &list2, const AstrometryTransform *guess, const double maxDist)
assembles star matches.
Definition: ListMatch.cc:569
#define LOGLS_INFO(logger, message)
Log a info-level message using an iostream-based interface.
Definition: Log.h:628
T get(T... args)
STL class.
table::Key< int > transform
double computeChi2(const StarMatchList &L, const AstrometryTransform &transform)
the actual chi2
Definition: StarMatch.cc:246

◆ listMatchupShift()

std::unique_ptr< AstrometryTransformLinear > lsst::jointcal::listMatchupShift ( const BaseStarList list1,
const BaseStarList list2,
const AstrometryTransform transform,
double  maxShift,
double  binSize = 0 
)

searches for a 2 dimensional shift using a very crude histogram method.

Definition at line 491 of file ListMatch.cc.

494  {
495  int nx;
496  if (binSize == 0) {
497  int ncomb = list1.size() * list2.size();
498  if (ncomb > 10000)
499  nx = 100;
500  else
501  nx = (int)sqrt(double(ncomb));
502  if (!ncomb) return std::unique_ptr<AstrometryTransformLinear>(nullptr);
503  } else
504  nx = int(2 * maxShift / binSize + 0.5);
505 
506  Histo2d histo(nx, -maxShift, maxShift, nx, -maxShift, maxShift);
507  double binSizeNew = 2 * maxShift / nx;
508 
510  FastFinder finder(list2);
511  double x1, y1;
512  for (s1 = list1.begin(); s1 != list1.end(); ++s1) {
513  transform.apply((*s1)->x, (*s1)->y, x1, y1);
514  FastFinder::Iterator it = finder.beginScan(Point(x1, y1), maxShift);
515  while (*it) {
516  auto s2 = *it;
517  histo.fill(s2->x - x1, s2->y - y1);
518  ++it;
519  }
520  }
521  SolList Solutions;
522  for (int i = 0; i < 4; ++i) {
523  double dx = 0, dy = 0;
524  double count = histo.maxBin(dx, dy);
525  histo.fill(dx, dy, -count); // zero the maxbin
526  AstrometryTransformLinearShift shift(dx, dy);
527  auto newGuess = compose(shift, transform);
528  auto raw_matches = listMatchCollect(list1, list2, newGuess.get(), binSizeNew);
529  std::unique_ptr<StarMatchList> matches(new StarMatchList);
530  raw_matches->applyTransform(*matches, &transform);
531  matches->setTransformOrder(1);
532  matches->refineTransform(3.);
533  Solutions.push_back(std::move(matches));
534  }
535  Solutions.sort(DecreasingQuality);
537  new AstrometryTransformLinear(*std::const_pointer_cast<AstrometryTransformLinear>(
538  std::dynamic_pointer_cast<const AstrometryTransformLinear>(
539  Solutions.front()->getTransform()))));
540  return best;
541 }
BaseStarList::const_iterator BaseStarCIterator
Definition: BaseStar.h:121
std::unique_ptr< StarMatchList > listMatchCollect(const BaseStarList &list1, const BaseStarList &list2, const AstrometryTransform *guess, const double maxDist)
assembles star matches.
Definition: ListMatch.cc:569
FastFinder::Iterator Iterator
Definition: FastFinder.cc:179
T move(T... args)
T count(T... args)
STL class.
T sqrt(T... args)
std::list< std::unique_ptr< StarMatchList > > SolList
Definition: ListMatch.cc:157

◆ matchSearchRotShift()

std::unique_ptr< StarMatchList > lsst::jointcal::matchSearchRotShift ( BaseStarList list1,
BaseStarList list2,
const MatchConditions conditions 
)

searches a geometrical transformation that goes from list1 to list2.

The found transformation is a field of the returned object, as well as the star pairs (the matches) that were constructed. (see StarMatchList class definition for more details). The various cuts are contained in conditions (see listmatch.h) for its contents. This routine searches a transformation that involves a shift and a rotation.

Definition at line 425 of file ListMatch.cc.

426  {
427  list1.fluxSort();
428  list2.fluxSort();
429 
430  return ListMatchupRotShift(list1, list2, AstrometryTransformIdentity(), conditions);
431 }

◆ matchSearchRotShiftFlip()

std::unique_ptr< StarMatchList > lsst::jointcal::matchSearchRotShiftFlip ( BaseStarList list1,
BaseStarList list2,
const MatchConditions conditions 
)

same as above but searches also a flipped solution.

Definition at line 433 of file ListMatch.cc.

434  {
435  list1.fluxSort();
436  list2.fluxSort();
437 
438  AstrometryTransformLinear flip(0, 0, 1, 0, 0, -1);
439  std::unique_ptr<StarMatchList> flipped(ListMatchupRotShift(list1, list2, flip, conditions));
441  ListMatchupRotShift(list1, list2, AstrometryTransformIdentity(), conditions));
442  if (!flipped || !unflipped) return std::unique_ptr<StarMatchList>(nullptr);
443  if (conditions.printLevel >= 1) {
444  LOGLS_DEBUG(_log,
445  "unflipped Residual " << unflipped->computeResidual() << " nused " << unflipped->size());
446  LOGLS_DEBUG(_log, "flipped Residual " << flipped->computeResidual() << " nused " << flipped->size());
447  }
448  if (DecreasingQuality(flipped, unflipped)) {
449  if (conditions.printLevel >= 1) LOGL_DEBUG(_log, "Keeping flipped solution.");
450  // One should NOT apply the flip to the result because the matchlist
451  // (even the flipped one) contains the actual coordinates of stars.
452  // MatchListExtract is always called with AstrometryTransformIdentity() as last parameter
453  return flipped;
454  } else {
455  if (conditions.printLevel >= 1) LOGL_DEBUG(_log, "Keeping unflipped solution.");
456  return unflipped;
457  }
458 }
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
Definition: Log.h:504
#define LOGLS_DEBUG(logger, message)
Log a debug-level message using an iostream-based interface.
Definition: Log.h:608
STL class.

◆ Measured2Base() [1/4]

BaseStarList & lsst::jointcal::Measured2Base ( MeasuredStarList This)

Definition at line 58 of file MeasuredStar.cc.

58 { return (BaseStarList &)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ Measured2Base() [2/4]

BaseStarList * lsst::jointcal::Measured2Base ( MeasuredStarList This)

Definition at line 60 of file MeasuredStar.cc.

60 { return (BaseStarList *)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ Measured2Base() [3/4]

const BaseStarList & lsst::jointcal::Measured2Base ( const MeasuredStarList This)

Definition at line 62 of file MeasuredStar.cc.

62 { return (const BaseStarList &)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ Measured2Base() [4/4]

const BaseStarList * lsst::jointcal::Measured2Base ( const MeasuredStarList This)

Definition at line 64 of file MeasuredStar.cc.

64 { return (BaseStarList *)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ normalizeCoordinatesTransform()

AstrometryTransformLinear lsst::jointcal::normalizeCoordinatesTransform ( const Frame frame)

Returns the transformation that maps the input frame along both axes to [-1,1].

Definition at line 818 of file AstrometryTransform.cc.

818  {
819  Point center = frame.getCenter();
820  return AstrometryTransformLinearScale(2. / frame.getWidth(), 2. / frame.getHeight()) *
821  AstrometryTransformLinearShift(-center.x, -center.y);
822 }

◆ operator<<() [1/7]

std::ostream& lsst::jointcal::operator<< ( std::ostream s,
Chi2List const &  chi2List 
)

Definition at line 45 of file Chi2.cc.

45  {
46  s << "chi2 per star : ";
47  for (auto chi2 : chi2List) {
48  s << *(chi2.star) << " chi2: " << chi2.chi2 << " ; ";
49  }
50  s << std::endl;
51  return s;
52 }
T endl(T... args)

◆ operator<<() [2/7]

std::ostream & lsst::jointcal::operator<< ( std::ostream out,
CcdImageKey const &  key 
)

Definition at line 52 of file CcdImage.cc.

52  {
53  out << "(visit: " << key.visit << ", ccd: " << key.ccd << ")";
54  return out;
55 }
Key< U > key
Definition: Schema.cc:281

◆ operator<<() [3/7]

std::ostream& lsst::jointcal::operator<< ( std::ostream stream,
const Point point 
)

Definition at line 69 of file Point.h.

69  {
70  point.dump(stream);
71  return stream;
72  }

◆ operator<<() [4/7]

template<class Star >
std::ostream& lsst::jointcal::operator<< ( std::ostream stream,
const StarList< Star > &  list 
)

enables

std::cout << my_list; 

Definition at line 105 of file StarList.h.

105  {
106  list.dump(stream);
107  return stream;
108 }
daf::base::PropertyList * list
Definition: fits.cc:903

◆ operator<<() [5/7]

std::ostream & lsst::jointcal::operator<< ( std::ostream stream,
const StarMatch match 
)

Definition at line 56 of file StarMatch.cc.

56  {
57  stream << match.point1.x << ' ' << match.point1.y << ' ' << match.point2.x << ' ' << match.point2.y << ' '
58  << match.distance << std::endl;
59  return stream;
60 }
T endl(T... args)

◆ operator<<() [6/7]

std::ostream & lsst::jointcal::operator<< ( std::ostream stream,
const StarMatchList starMatchList 
)

A std::list of star matches,.

To be used as the argument to AstrometryTransform::fit routines. There is as well a StarMatch::fit routine which fits a polynomial by default, although the transform may be user-provided. The StarMatchList::refineTransform is a convenient tool to reject outliers. Given two catalogs, one can assemble a StarMatchList using utilities such as listMatchCollect. StarMatchList's have write capabilities. NStarMatchList is a generalization of this 2-match to n-matches.

Definition at line 62 of file StarMatch.cc.

62  {
63  stream << " number of elements " << starMatchList.size() << std::endl;
64  copy(starMatchList.begin(), starMatchList.end(), std::ostream_iterator<StarMatch>(stream));
65  return stream;
66 }
T copy(T... args)
T endl(T... args)

◆ operator<<() [7/7]

ostream & lsst::jointcal::operator<< ( std::ostream stream,
AstrometryTransform const &  transform 
)

Delegates to transform.dump()

Definition at line 240 of file AstrometryTransform.cc.

240  {
241  transform.dump(stream);
242  return stream;
243 }

◆ Ref2Base() [1/4]

BaseStarList & lsst::jointcal::Ref2Base ( RefStarList This)

Definition at line 34 of file RefStar.cc.

34 { return (BaseStarList &)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ Ref2Base() [2/4]

BaseStarList * lsst::jointcal::Ref2Base ( RefStarList This)

Definition at line 36 of file RefStar.cc.

36 { return (BaseStarList *)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ Ref2Base() [3/4]

const BaseStarList & lsst::jointcal::Ref2Base ( const RefStarList This)

Definition at line 38 of file RefStar.cc.

38 { return (const BaseStarList &)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ Ref2Base() [4/4]

const BaseStarList * lsst::jointcal::Ref2Base ( const RefStarList This)

Definition at line 40 of file RefStar.cc.

40 { return (BaseStarList *)This; }
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119

◆ sameStar1()

bool lsst::jointcal::sameStar1 ( const StarMatch one,
const StarMatch two 
)
inline

Definition at line 119 of file StarMatch.h.

119 { return (one.s1 == two.s1); }

◆ sameStar2()

bool lsst::jointcal::sameStar2 ( const StarMatch one,
const StarMatch two 
)
inline

Definition at line 125 of file StarMatch.h.

125 { return (one.s2 == two.s2); }