lsst.meas.extensions.astrometryNet  14.0+12
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 
19 #undef logdebug
20 #undef debug
21 }
22 
23 #include <memory>
24 #include <string>
25 #include <utility>
26 #include <vector>
27 
28 #include "boost/format.hpp"
29 
30 #include "lsst/utils/python.h"
32 #include "lsst/base.h"
33 #include "lsst/log/Log.h"
34 #include "lsst/daf/persistence.h"
37 #include "lsst/afw/table.h"
38 #include "lsst/afw/image/Wcs.h"
39 #include "lsst/afw/image/TanWcs.h"
40 #include "lsst/afw/geom.h"
41 #include "lsst/afw/coord.h"
42 
43 namespace lsst {
44 namespace meas {
45 namespace extensions {
46 namespace astrometryNet {
47 
48 /*
49  * A thin C++ wrapper around astrometry_net's multiindex_t struct.
50  *
51  * This provide memory management and a few methods used by LSST.
52  */
53 class MultiIndex {
54 
55 public:
56 
60  MultiIndex(std::string const & filepath);
61 
63 
67  index_t * operator[](int i) const {
68  return multiindex_get(_multiindex.get(), i);
69  }
70 
74  void addIndex(std::string const & filepath, bool metadataOnly);
75 
79  int isWithinRange(double ra, double dec, double radius_deg);
80 
84  void unload() {
85  multiindex_unload(_multiindex.get());
86  }
87 
88  std::string getName() const {
89  return _multiindex->fits->filename;
90  }
91 
95  int getLength() const {
96  return multiindex_n(_multiindex.get());
97  }
98 
102  void reload();
103 
104 private:
105 
106  struct _Deleter {
107  void operator()(multiindex_t* m) {
108  multiindex_free(m);
109  }
110  };
111 
113 };
114 
115 
121 class Solver {
122 
123 public:
124 
125  explicit Solver();
126 
127  ~Solver();
128 
158  lsst::afw::coord::Coord const &ctrCoord,
159  lsst::afw::geom::Angle const &radius,
160  const char* idCol,
161  std::vector<std::string> const& filterNameList,
162  std::vector<std::string> const& magColList,
163  std::vector<std::string> const& magErrColList,
164  const char* starGalCol,
165  const char* varCol,
166  bool uniqueIds=true);
167 
169 
171 
172  bool didSolve() const {
173  return solver_did_solve(_solver.get());
174  }
175 
176  void run(double cpulimit);
177 
179  double qlo,qhi;
180  solver_get_quad_size_range_arcsec(_solver.get(), &qlo, &qhi);
181  return std::make_pair(qlo, qhi);
182  }
183 
190  void addIndices(std::vector<index_t*> inds);
191 
195  void setParity(bool flipped) {
196  _solver->parity = flipped ? PARITY_FLIP : PARITY_NORMAL;
197  }
198 
199  void setMatchThreshold(double threshold) {
200  solver_set_keep_logodds(_solver.get(), threshold);
201  }
202 
203  void setPixelScaleRange(double low, double high) {
204  _solver->funits_lower = low;
205  _solver->funits_upper = high;
206  }
207 
208  void setRaDecRadius(double ra, double dec, double radius_deg) {
209  solver_set_radec(_solver.get(), ra, dec, radius_deg);
210  }
211 
212  void setImageSize(int width, int height);
213 
214  void setMaxStars(int maxStars) {
215  _solver->endobj = maxStars;
216  }
217 
218  void setStars(lsst::afw::table::SourceCatalog const & srcs, int x0, int y0);
219 
220 private:
221 
222  struct _Deleter {
223  void operator()(solver_t* m) {
224  solver_free(m);
225  }
226  };
227 
229 };
230 
236 lsst::afw::geom::Angle healpixDistance(int hp, int nside, lsst::afw::coord::Coord const& coord);
237 
238 }}}} // namespace lsst::meas::extensions::astrometryNet
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.
std::pair< double, double > getQuadSizeRangeArcsec() const
T make_pair(T... args)
index_t * operator[](int i) const
Get the specified index.
def run(suite, exit=True)
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)
m
lsst::afw::geom::Angle healpixDistance(int hp, int nside, lsst::afw::coord::Coord const &coord)
Calculate the distance from coordinates to a healpix.
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)