LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
Namespaces | Classes | Typedefs | Enumerations | Functions
lsst::jointcal Namespace Reference

Namespaces

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

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 class  MinimizeResult { Converged , Chi2Increased , Failed , NonFinite }
 Return value of minimize() More...
 

Functions

std::ostreamoperator<< (std::ostream &stream, AstrometryMapping const &mapping)
 
std::ostreamoperator<< (std::ostream &stream, AstrometryModel const &model)
 
std::ostreamoperator<< (std::ostream &stream, AstrometryTransform const &transform)
 
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)
 
std::ostreamoperator<< (std::ostream &stream, ProjectionHandler const &projectionHandler)
 
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 754 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 178 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 1811 of file AstrometryTransform.cc.

1811  {
1812  ifstream s(fileName.c_str());
1813  if (!s)
1814  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1815  " astrometryTransformRead : cannot open " + fileName);
1816  try {
1818  s.close();
1819  return res;
1820  } catch (pex::exceptions::InvalidParameterError &e) {
1821  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1822  std::string(e.what()) + " in file " + fileName);
1823  }
1824 }
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
T c_str(T... args)
std::unique_ptr< AstrometryTransform > astrometryTransformRead(const std::string &fileName)
The virtual constructor from a file.

◆ astrometryTransformRead() [2/2]

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

The virtual constructor from a file.

Definition at line 1826 of file AstrometryTransform.cc.

1826  {
1827  std::string type;
1828  s >> type;
1829  if (s.fail())
1830  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1831  "astrometryTransformRead : could not find a AstrometryTransformtype");
1832  if (type == "AstrometryTransformIdentity") {
1833  std::unique_ptr<AstrometryTransformIdentity> res(new AstrometryTransformIdentity());
1834  res->read(s);
1835  return std::move(res);
1836  } else if (type == "AstrometryTransformPolynomial") {
1837  std::unique_ptr<AstrometryTransformPolynomial> res(new AstrometryTransformPolynomial());
1838  res->read(s);
1839  return std::move(res);
1840  } else
1841  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
1842  " astrometryTransformRead : No reader for AstrometryTransform type " + type);
1843 }
table::Key< int > type
Definition: Detector.cc:163
T fail(T... args)
T move(T... args)

◆ 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 426 of file AstrometryTransform.cc.

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

◆ compose() [2/2]

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

Definition at line 421 of file AstrometryTransform.cc.

422  {
423  return left.clone();
424 }

◆ 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 }
table::Key< int > transform

◆ 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]

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() [2/4]

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

Definition at line 70 of file FittedStar.cc.

70 { return (BaseStarList *)This; }

◆ Fitted2Base() [3/4]

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

Definition at line 64 of file FittedStar.cc.

64 { return (BaseStarList &)This; }

◆ Fitted2Base() [4/4]

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

Definition at line 66 of file FittedStar.cc.

66 { return (BaseStarList *)This; }

◆ 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 1150 of file AstrometryTransform.cc.

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

◆ isIntegerShift()

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

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

Definition at line 56 of file AstrometryTransform.cc.

56  {
57  const AstrometryTransformPolynomial *shift =
58  dynamic_cast<const AstrometryTransformPolynomial *>(transform);
59  if (shift == nullptr) return false;
60 
61  static const double eps = 1e-5;
62 
63  double dx = shift->getCoefficient(0, 0, 0);
64  double dy = shift->getCoefficient(0, 0, 1);
65 
66  static Point dumb(4000, 4000);
67  if (fabs(dx - int(floor(dx + 0.5))) < eps && fabs(dy - int(floor(dy + 0.5))) < eps &&
68  fabs(dumb.x + dx - shift->apply(dumb).x) < eps && fabs(dumb.y + dy - shift->apply(dumb).y) < eps)
69  return true;
70 
71  return false;
72 }
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

◆ 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

◆ 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 }

◆ 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 }
#define LOGL_INFO(logger, message...)
Log a info-level message using a varargs/printf style interface.
Definition: Log.h:520
#define LOGLS_INFO(logger, message)
Log a info-level message using an iostream-based interface.
Definition: Log.h:628
#define LOGL_ERROR(logger, message...)
Log a error-level message using a varargs/printf style interface.
Definition: Log.h:552
#define LOGLS_DEBUG(logger, message)
Log a debug-level message using an iostream-based interface.
Definition: Log.h:608
#define LOGL_DEBUG(logger, message...)
Log a debug-level message using a varargs/printf style interface.
Definition: Log.h:504
#define LOGL_FATAL(logger, message...)
Log a fatal-level message using a varargs/printf style interface.
Definition: Log.h:568
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
T pow(T... args)

◆ 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 }
std::unique_ptr< StarMatchList > listMatchCollect(const BaseStarList &list1, const BaseStarList &list2, const AstrometryTransform *guess, const double maxDist)
assembles star matches.
Definition: ListMatch.cc:569
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 }
T count(T... args)
std::list< std::unique_ptr< StarMatchList > > SolList
Definition: ListMatch.cc:157
FastFinder::Iterator Iterator
Definition: FastFinder.cc:178
T sqrt(T... args)

◆ 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 }

◆ Measured2Base() [1/4]

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

Definition at line 62 of file MeasuredStar.cc.

62 { return (const BaseStarList &)This; }

◆ Measured2Base() [2/4]

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

Definition at line 64 of file MeasuredStar.cc.

64 { return (BaseStarList *)This; }

◆ Measured2Base() [3/4]

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

Definition at line 58 of file MeasuredStar.cc.

58 { return (BaseStarList &)This; }

◆ Measured2Base() [4/4]

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

Definition at line 60 of file MeasuredStar.cc.

60 { return (BaseStarList *)This; }

◆ 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 833 of file AstrometryTransform.cc.

833  {
834  Point center = frame.getCenter();
835  return AstrometryTransformLinearScale(2. / frame.getWidth(), 2. / frame.getHeight()) *
836  AstrometryTransformLinearShift(-center.x, -center.y);
837 }

◆ operator<<() [1/10]

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 << ", detector: " << key.ccd << ")";
54  return out;
55 }
Key< U > key
Definition: Schema.cc:281

◆ operator<<() [2/10]

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<<() [3/10]

std::ostream& lsst::jointcal::operator<< ( std::ostream stream,
AstrometryMapping const &  mapping 
)
inline

Definition at line 78 of file AstrometryMapping.h.

78  {
79  mapping.print(stream);
80  return stream;
81 }

◆ operator<<() [4/10]

std::ostream & lsst::jointcal::operator<< ( std::ostream stream,
AstrometryModel const &  model 
)

Definition at line 42 of file AstrometryModel.cc.

42  {
43  model.print(stream);
44  return stream;
45 }

◆ operator<<() [5/10]

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

Definition at line 241 of file AstrometryTransform.cc.

241  {
242  transform.print(stream);
243  return stream;
244 }

◆ operator<<() [6/10]

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

Definition at line 69 of file Point.h.

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

◆ operator<<() [7/10]

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.print(stream);
107  return stream;
108 }
daf::base::PropertyList * list
Definition: fits.cc:913

◆ operator<<() [8/10]

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 }

◆ operator<<() [9/10]

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)

◆ operator<<() [10/10]

std::ostream & lsst::jointcal::operator<< ( std::ostream stream,
ProjectionHandler const &  projectionHandler 
)

Definition at line 34 of file Projectionhandler.cc.

34  {
35  projectionHandler.print(stream);
36  return stream;
37 }

◆ Ref2Base() [1/4]

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

Definition at line 38 of file RefStar.cc.

38 { return (const BaseStarList &)This; }

◆ Ref2Base() [2/4]

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

Definition at line 40 of file RefStar.cc.

40 { return (BaseStarList *)This; }

◆ Ref2Base() [3/4]

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

Definition at line 34 of file RefStar.cc.

34 { return (BaseStarList &)This; }

◆ Ref2Base() [4/4]

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

Definition at line 36 of file RefStar.cc.

36 { return (BaseStarList *)This; }

◆ 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); }