LSSTApplications  16.0-10-g0ee56ad+5,16.0-11-ga33d1f2+5,16.0-12-g3ef5c14+3,16.0-12-g71e5ef5+18,16.0-12-gbdf3636+3,16.0-13-g118c103+3,16.0-13-g8f68b0a+3,16.0-15-gbf5c1cb+4,16.0-16-gfd17674+3,16.0-17-g7c01f5c+3,16.0-18-g0a50484+1,16.0-20-ga20f992+8,16.0-21-g0e05fd4+6,16.0-21-g15e2d33+4,16.0-22-g62d8060+4,16.0-22-g847a80f+4,16.0-25-gf00d9b8+1,16.0-28-g3990c221+4,16.0-3-gf928089+3,16.0-32-g88a4f23+5,16.0-34-gd7987ad+3,16.0-37-gc7333cb+2,16.0-4-g10fc685+2,16.0-4-g18f3627+26,16.0-4-g5f3a788+26,16.0-5-gaf5c3d7+4,16.0-5-gcc1f4bb+1,16.0-6-g3b92700+4,16.0-6-g4412fcd+3,16.0-6-g7235603+4,16.0-69-g2562ce1b+2,16.0-8-g14ebd58+4,16.0-8-g2df868b+1,16.0-8-g4cec79c+6,16.0-8-gadf6c7a+1,16.0-8-gfc7ad86,16.0-82-g59ec2a54a+1,16.0-9-g5400cdc+2,16.0-9-ge6233d7+5,master-g2880f2d8cf+3,v17.0.rc1
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
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)
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
Interface for Persistable base class.
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
Basic LSST definitions.
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)