lsst.meas.extensions.astrometryNet  18.1.0-3-g9bc06b8+2
astrometry_net.h
Go to the documentation of this file.
1 // -*- lsst-C++ -*-
2 
3 // Astrometry.net include files...
4 extern "C" {
5 #include "astrometry/solver.h"
6 #include "astrometry/index.h"
7 #include "astrometry/multiindex.h"
8 #include "astrometry/starkd.h"
9 #include "astrometry/fitsioutils.h"
10 #include "astrometry/fitstable.h"
11 #include "astrometry/log.h"
12 #include "astrometry/tic.h"
13 #include "astrometry/healpix.h"
14 
15 #undef ATTRIB_FORMAT
16 #undef FALSE
17 #undef TRUE
18 #undef DEG_PER_RAD
19 #undef RAD_PER_DEG
20 #undef logdebug
21 #undef debug
22 }
23 
24 #include <memory>
25 #include <string>
26 #include <utility>
27 #include <vector>
28 
29 #include "boost/format.hpp"
30 
31 #include "lsst/utils/python.h"
33 #include "lsst/base.h"
34 #include "lsst/log/Log.h"
35 #include "lsst/daf/persistence.h"
38 #include "lsst/afw/table.h"
39 #include "lsst/afw/geom.h"
40 #include "lsst/geom.h"
41 
42 namespace lsst {
43 namespace meas {
44 namespace extensions {
45 namespace astrometryNet {
46 
47 /*
48  * A thin C++ wrapper around astrometry_net's multiindex_t struct.
49  *
50  * This provide memory management and a few methods used by LSST.
51  */
52 class MultiIndex {
53 
54 public:
55 
59  MultiIndex(std::string const & filepath);
60 
62 
66  index_t * operator[](int i) const {
67  return multiindex_get(_multiindex.get(), i);
68  }
69 
73  void addIndex(std::string const & filepath, bool metadataOnly);
74 
78  int isWithinRange(double ra, double dec, double radius_deg);
79 
83  void unload() {
84  multiindex_unload(_multiindex.get());
85  }
86 
87  std::string getName() const {
88  return _multiindex->fits->filename;
89  }
90 
94  int getLength() const {
95  return multiindex_n(_multiindex.get());
96  }
97 
101  void reload();
102 
103 private:
104 
105  struct _Deleter {
106  void operator()(multiindex_t* m) {
107  multiindex_free(m);
108  }
109  };
110 
112 };
113 
114 
120 class Solver {
121 
122 public:
123 
124  explicit Solver();
125 
126  ~Solver();
127 
157  lsst::geom::SpherePoint const &ctrCoord,
158  lsst::geom::Angle const &radius,
159  const char* idCol,
160  std::vector<std::string> const& filterNameList,
161  std::vector<std::string> const& magColList,
162  std::vector<std::string> const& magErrColList,
163  const char* starGalCol,
164  const char* varCol,
165  bool uniqueIds=true);
166 
168 
170 
171  bool didSolve() const {
172  return solver_did_solve(_solver.get());
173  }
174 
175  void run(double cpulimit);
176 
178  double qlo,qhi;
179  solver_get_quad_size_range_arcsec(_solver.get(), &qlo, &qhi);
180  return std::make_pair(qlo, qhi);
181  }
182 
189  void addIndices(std::vector<index_t*> inds);
190 
194  void setParity(bool flipped) {
195  _solver->parity = flipped ? PARITY_FLIP : PARITY_NORMAL;
196  }
197 
198  void setMatchThreshold(double threshold) {
199  solver_set_keep_logodds(_solver.get(), threshold);
200  }
201 
202  void setPixelScaleRange(double low, double high) {
203  _solver->funits_lower = low;
204  _solver->funits_upper = high;
205  }
206 
207  void setRaDecRadius(double ra, double dec, double radius_deg) {
208  solver_set_radec(_solver.get(), ra, dec, radius_deg);
209  }
210 
211  void setImageSize(int width, int height);
212 
213  void setMaxStars(int maxStars) {
214  _solver->endobj = maxStars;
215  }
216 
217  void setStars(lsst::afw::table::SourceCatalog const & srcs, int x0, int y0);
218 
219 private:
220 
221  struct _Deleter {
222  void operator()(solver_t* m) {
223  solver_free(m);
224  }
225  };
226 
228 };
229 
235 lsst::geom::Angle healpixDistance(int hp, int nside, lsst::geom::SpherePoint const& coord);
236 
237 }}}} // namespace lsst::meas::extensions::astrometryNet
int m
double dec
A thin C++ wrapper around astrometry.net&#39;s solver_t struct.
void setParity(bool flipped)
Set parity to flipped (if true) or normal (if false)
MultiIndex(std::string const &filepath)
Construct a MultiIndex from an astrometry.net multi-index file.
int getLength() const
Get the number of indices.
STL class.
lsst::geom::Angle healpixDistance(int hp, int nside, lsst::geom::SpherePoint const &coord)
Calculate the distance from coordinates to a healpix.
std::pair< double, double > getQuadSizeRangeArcsec() const
T make_pair(T... args)
index_t * operator[](int i) const
Get the specified index.
T get(T... args)
STL class.
void addIndex(std::string const &filepath, bool metadataOnly)
Add an index read from a file.
void setRaDecRadius(double ra, double dec, double radius_deg)
int isWithinRange(double ra, double dec, double radius_deg)
Is this multi-index in range of the specified cone?
void setPixelScaleRange(double low, double high)