LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
LSSTDataManagementBasePackage
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 
41 namespace lsst {
42 namespace meas {
43 namespace extensions {
44 namespace astrometryNet {
45 
46 /*
47  * A thin C++ wrapper around astrometry_net's multiindex_t struct.
48  *
49  * This provide memory management and a few methods used by LSST.
50  */
51 class MultiIndex {
52 
53 public:
54 
58  MultiIndex(std::string const & filepath);
59 
61 
65  index_t * operator[](int i) const {
66  return multiindex_get(_multiindex.get(), i);
67  }
68 
72  void addIndex(std::string const & filepath, bool metadataOnly);
73 
77  int isWithinRange(double ra, double dec, double radius_deg);
78 
82  void unload() {
83  multiindex_unload(_multiindex.get());
84  }
85 
86  std::string getName() const {
87  return _multiindex->fits->filename;
88  }
89 
93  int getLength() const {
94  return multiindex_n(_multiindex.get());
95  }
96 
100  void reload();
101 
102 private:
103 
104  struct _Deleter {
105  void operator()(multiindex_t* m) {
106  multiindex_free(m);
107  }
108  };
109 
111 };
112 
113 
119 class Solver {
120 
121 public:
122 
123  explicit Solver();
124 
125  ~Solver();
126 
156  lsst::afw::geom::SpherePoint const &ctrCoord,
157  lsst::afw::geom::Angle const &radius,
158  const char* idCol,
159  std::vector<std::string> const& filterNameList,
160  std::vector<std::string> const& magColList,
161  std::vector<std::string> const& magErrColList,
162  const char* starGalCol,
163  const char* varCol,
164  bool uniqueIds=true);
165 
167 
169 
170  bool didSolve() const {
171  return solver_did_solve(_solver.get());
172  }
173 
174  void run(double cpulimit);
175 
177  double qlo,qhi;
178  solver_get_quad_size_range_arcsec(_solver.get(), &qlo, &qhi);
179  return std::make_pair(qlo, qhi);
180  }
181 
188  void addIndices(std::vector<index_t*> inds);
189 
193  void setParity(bool flipped) {
194  _solver->parity = flipped ? PARITY_FLIP : PARITY_NORMAL;
195  }
196 
198  solver_set_keep_logodds(_solver.get(), threshold);
199  }
200 
201  void setPixelScaleRange(double low, double high) {
202  _solver->funits_lower = low;
203  _solver->funits_upper = high;
204  }
205 
206  void setRaDecRadius(double ra, double dec, double radius_deg) {
207  solver_set_radec(_solver.get(), ra, dec, radius_deg);
208  }
209 
210  void setImageSize(int width, int height);
211 
212  void setMaxStars(int maxStars) {
213  _solver->endobj = maxStars;
214  }
215 
216  void setStars(lsst::afw::table::SourceCatalog const & srcs, int x0, int y0);
217 
218 private:
219 
220  struct _Deleter {
221  void operator()(solver_t* m) {
222  solver_free(m);
223  }
224  };
225 
227 };
228 
235 
236 }}}} // namespace lsst::meas::extensions::astrometryNet
Interface for Persistable base class.
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)
Basic LSST definitions.
daf_persistence package header file
MultiIndex(std::string const &filepath)
Construct a MultiIndex from an astrometry.net multi-index file.
int getLength() const
Get the number of indices.
double dec
Definition: Match.cc:41
A class representing an angle.
Definition: Angle.h:127
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.
LSST DM logging module built on log4cxx.
A base class for image defects.
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
Definition: fwd.h:63
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.
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
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 m
Definition: SpanSet.cc:49
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)