LSSTApplications  17.0+103,17.0+11,17.0+61,18.0.0+13,18.0.0+25,18.0.0+5,18.0.0+52,18.0.0-4-g68ffd23,18.1.0-1-g0001055+8,18.1.0-1-g03d53ef+1,18.1.0-1-g1349e88+28,18.1.0-1-g2505f39+22,18.1.0-1-g380d4d4+27,18.1.0-1-g5315e5e+1,18.1.0-1-g5e4b7ea+10,18.1.0-1-g7e8fceb+1,18.1.0-1-g85f8cd4+23,18.1.0-1-g9a6769a+13,18.1.0-1-ga1a4c1a+22,18.1.0-1-gd55f500+17,18.1.0-12-g42eabe8e+10,18.1.0-14-gd04256d+15,18.1.0-16-g430f6a53+1,18.1.0-17-gd2166b6e4,18.1.0-18-gb5d19ff+1,18.1.0-2-gfbf3545+7,18.1.0-2-gfefb8b5+16,18.1.0-3-g52aa583+13,18.1.0-3-g62b5e86+14,18.1.0-3-g8f4a2b1+17,18.1.0-3-g9bc06b8+7,18.1.0-3-gb69f684+9,18.1.0-4-g1ee41a7+1,18.1.0-5-g6dbcb01+13,18.1.0-5-gc286bb7+3,18.1.0-6-g48bdcd3+2,18.1.0-6-gd05e160+9,18.1.0-7-gc4d902b+2,18.1.0-7-gebc0338+8,18.1.0-9-gae7190a+10,w.2019.38
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 #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
double dec
Definition: Match.cc:41
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
Interface for Persistable base class.
MultiIndex(std::string const &filepath)
Construct a MultiIndex from an astrometry.net multi-index file.
int getLength() const
Get the number of indices.
A class representing an angle.
Definition: Angle.h:127
STL class.
LSST DM logging module built on log4cxx.
lsst::geom::Angle healpixDistance(int hp, int nside, lsst::geom::SpherePoint const &coord)
Calculate the distance from coordinates to a healpix.
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.
def run(self, skyInfo, tempExpRefList, imageScalerList, weightList, altMaskList=None, mask=None, supplementaryData=None)
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?
Basic LSST definitions.
void setPixelScaleRange(double low, double high)