lsst.meas.extensions.astrometryNet  14.0-3-gc45031d+7
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/geom.h"
39 
40 namespace lsst {
41 namespace meas {
42 namespace extensions {
43 namespace astrometryNet {
44 
45 /*
46  * A thin C++ wrapper around astrometry_net's multiindex_t struct.
47  *
48  * This provide memory management and a few methods used by LSST.
49  */
50 class MultiIndex {
51 
52 public:
53 
57  MultiIndex(std::string const & filepath);
58 
60 
64  index_t * operator[](int i) const {
65  return multiindex_get(_multiindex.get(), i);
66  }
67 
71  void addIndex(std::string const & filepath, bool metadataOnly);
72 
76  int isWithinRange(double ra, double dec, double radius_deg);
77 
81  void unload() {
82  multiindex_unload(_multiindex.get());
83  }
84 
85  std::string getName() const {
86  return _multiindex->fits->filename;
87  }
88 
92  int getLength() const {
93  return multiindex_n(_multiindex.get());
94  }
95 
99  void reload();
100 
101 private:
102 
103  struct _Deleter {
104  void operator()(multiindex_t* m) {
105  multiindex_free(m);
106  }
107  };
108 
110 };
111 
112 
118 class Solver {
119 
120 public:
121 
122  explicit Solver();
123 
124  ~Solver();
125 
155  lsst::afw::geom::SpherePoint const &ctrCoord,
156  lsst::afw::geom::Angle const &radius,
157  const char* idCol,
158  std::vector<std::string> const& filterNameList,
159  std::vector<std::string> const& magColList,
160  std::vector<std::string> const& magErrColList,
161  const char* starGalCol,
162  const char* varCol,
163  bool uniqueIds=true);
164 
166 
168 
169  bool didSolve() const {
170  return solver_did_solve(_solver.get());
171  }
172 
173  void run(double cpulimit);
174 
176  double qlo,qhi;
177  solver_get_quad_size_range_arcsec(_solver.get(), &qlo, &qhi);
178  return std::make_pair(qlo, qhi);
179  }
180 
187  void addIndices(std::vector<index_t*> inds);
188 
192  void setParity(bool flipped) {
193  _solver->parity = flipped ? PARITY_FLIP : PARITY_NORMAL;
194  }
195 
196  void setMatchThreshold(double threshold) {
197  solver_set_keep_logodds(_solver.get(), threshold);
198  }
199 
200  void setPixelScaleRange(double low, double high) {
201  _solver->funits_lower = low;
202  _solver->funits_upper = high;
203  }
204 
205  void setRaDecRadius(double ra, double dec, double radius_deg) {
206  solver_set_radec(_solver.get(), ra, dec, radius_deg);
207  }
208 
209  void setImageSize(int width, int height);
210 
211  void setMaxStars(int maxStars) {
212  _solver->endobj = maxStars;
213  }
214 
215  void setStars(lsst::afw::table::SourceCatalog const & srcs, int x0, int y0);
216 
217 private:
218 
219  struct _Deleter {
220  void operator()(solver_t* m) {
221  solver_free(m);
222  }
223  };
224 
226 };
227 
234 
235 }}}} // 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.
lsst::afw::geom::Angle healpixDistance(int hp, int nside, lsst::afw::geom::SpherePoint const &coord)
Calculate the distance from coordinates to a healpix.
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
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)