13 namespace astrometryNet {
22 static time_t timer_callback(
void* baton) {
23 struct timer_baton* tt =
static_cast<struct timer_baton*
>(baton);
24 solver_t* solver = tt->s;
25 if (solver->timeused > tt->timelimit)
35 os <<
"Could not read multi-index star file " << filepath;
41 int const flags = metadataOnly ? INDEX_ONLY_LOAD_METADATA : 0;
44 os <<
"Failed to read multiindex from \"" << filepath <<
"\"" 45 <<
" with meatadaOnly=" << metadataOnly;
51 return index_is_within_range(multiindex_get(
_multiindex.get(), 0), ra, dec, radius_deg);
57 os <<
"Failed to reload multi-index star file " <<
getName();
80 const char* starGalCol,
84 if ((filterNameList.
size() != magColList.
size()) || (filterNameList.
size() != magErrColList.
size())) {
86 "Filter name, mag column, and mag error column vectors must be the same length.");
89 for (
size_t i=0; i<filterNameList.
size(); ++i) {
97 idCol, magColInfoList, starGalCol, varCol, uniqueIds);
102 auto qa = std::make_shared<daf::base::PropertyList>();
104 qa->set(
"meas_astrom*an*n_tried",
_solver->numtries);
105 qa->set(
"meas_astrom*an*n_matched",
_solver->nummatches);
106 qa->set(
"meas_astrom*an*n_scaleok",
_solver->numscaleok);
107 qa->set(
"meas_astrom*an*n_cxdxcut",
_solver->num_cxdx_skipped);
108 qa->set(
"meas_astrom*an*n_meanxcut",
_solver->num_meanx_skipped);
109 qa->set(
"meas_astrom*an*n_radeccut",
_solver->num_radec_skipped);
110 qa->set(
"meas_astrom*an*n_scalecut",
_solver->num_abscale_skipped);
111 qa->set(
"meas_astrom*an*n_verified",
_solver->num_verified);
112 qa->set(
"meas_astrom*an*time_used",
_solver->timeused);
113 qa->set(
"meas_astrom*an*best_logodds",
_solver->best_logodds);
115 index_t* ind =
_solver->best_index;
116 qa->set(
"meas_astrom*an*best_index*id", ind->indexid);
117 qa->set(
"meas_astrom*an*best_index*hp", ind->healpix);
118 qa->set(
"meas_astrom*an*best_index*nside", ind->hpnside);
119 qa->set(
"meas_astrom*an*best_index*name",
std::string(ind->indexname));
121 if (
_solver->have_best_match) {
122 MatchObj* mo = &(
_solver->best_match);
124 for (
int i=1; i<mo->dimquads; i++)
126 qa->set(
"meas_astrom*an*best_match*starinds", s);
127 qa->set(
"meas_astrom*an*best_match*coderr",
std::sqrt(mo->code_err));
128 qa->set(
"meas_astrom*an*best_match*nmatch", mo->nmatch);
129 qa->set(
"meas_astrom*an*best_match*ndistract", mo->ndistractor);
130 qa->set(
"meas_astrom*an*best_match*nconflict", mo->nconflict);
131 qa->set(
"meas_astrom*an*best_match*nfield", mo->nfield);
132 qa->set(
"meas_astrom*an*best_match*nindex", mo->nindex);
133 qa->set(
"meas_astrom*an*best_match*nbest", mo->nbest);
134 qa->set(
"meas_astrom*an*best_match*logodds", mo->logodds);
135 qa->set(
"meas_astrom*an*best_match*parity", mo->parity ? 0 : 1);
136 qa->set(
"meas_astrom*an*best_match*nobjs", mo->objs_tried);
142 MatchObj* match = solver_get_best_match(
_solver.get());
145 tan_t*
wcs = &(match->wcstan);
150 Eigen::Matrix2d cdMatrix;
151 for (
int i = 0; i < 2; ++i) {
152 for (
int j = 0; j < 2; ++j) {
153 cdMatrix(i, j) = wcs->cd[i][j];
160 solver_log_params(
_solver.get());
161 struct timer_baton tt;
164 tt.timelimit = cpulimit;
166 _solver->timer_callback = timer_callback;
170 _solver->timer_callback = NULL;
183 pind != inds.
end(); ++pind) {
187 double ra,dec,radius;
188 xyzarr2radecdeg(
_solver->centerxyz, &ra, &dec);
189 radius = distsq2deg(
_solver->r2);
190 if (!index_is_within_range(man.
index, ra, dec, radius)) {
197 solver_get_quad_size_range_arcsec(
_solver.get(), &qlo, &qhi);
198 if (!index_overlaps_scale_range(man.
index, qlo, qhi)) {
203 if (index_reload(man.
index)) {
205 "Failed to index_reload() an astrometry_net_data index file -- out of file descriptors?");
213 solver_set_field_bounds(
_solver.get(), 0, width, 0, height);
214 double hi = hypot(width, height);
215 double lo = 0.1 *
std::min(width, height);
216 solver_set_quad_size_range(
_solver.get(), lo, hi);
222 const size_t N = srcs.size();
223 starxy_t *starxy = starxy_new(N,
true,
false);
224 for (
size_t i=0; i<N; ++i) {
225 double const x = srcs[i].getX();
226 double const y = srcs[i].getY();
227 double const flux = srcs[i].getPsfFlux();
228 starxy_set(starxy, i, x - x0, y - y0);
229 starxy_set_flux(starxy, i, flux);
232 starxy_sort_by_flux(starxy);
234 starxy_free(solver_get_field(
_solver.get()));
235 solver_free_field(
_solver.get());
236 solver_set_field(
_solver.get(), starxy);
237 solver_reset_field_size(
_solver.get());
239 solver_preprocess_field(
_solver.get());
std::string magCol
name of magnitude column
lsst::afw::table::SimpleCatalog getCatalogImpl(std::vector< index_t *> inds, lsst::afw::coord::Coord const &ctrCoord, lsst::afw::geom::Angle const &radius, const char *idCol, std::vector< MagColInfo > const &magColInfoList, const char *starGalCol, const char *varCol, bool uniqueIds=true)
Implementation for index_t::getCatalog method.
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
lsst::afw::geom::Angle Angle
std::string magErrCol
name of magnitude sigma column
std::unique_ptr< multiindex_t, _Deleter > _multiindex
AngleUnit constexpr degrees
constant with units of degrees
MultiIndex(std::string const &filepath)
Construct a MultiIndex from an astrometry.net multi-index file.
virtual IcrsCoord toIcrs() const
Convert ourself to ICRS: RA, Dec (basically J2000)
void run(double cpulimit)
std::shared_ptr< lsst::afw::geom::SkyWcs > getWcs()
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
std::unique_ptr< solver_t, _Deleter > _solver
Include files required for standard LSST Exception handling.
A class representing an angle.
A base class for image defects.
void setImageSize(int width, int height)
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
RAII manager for astrometry.net indices.
lsst::afw::coord::IcrsCoord IcrsCoord
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
std::string getName() const
std::shared_ptr< lsst::daf::base::PropertyList > getSolveStats() const
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
void addIndex(std::string const &filepath, bool metadataOnly)
Add an index read from a file.
std::string filterName
name of filter
lsst::afw::geom::Angle healpixDistance(int hp, int nside, lsst::afw::coord::Coord const &coord)
Calculate the distance from coordinates to a healpix.
constexpr double asDegrees() const noexcept
Return an Angle's value in degrees.
This is the base class for spherical coordinates.
A class to handle Icrs coordinates (inherits from Coord)
void setStars(lsst::afw::table::SourceCatalog const &srcs, int x0, int y0)
lsst::afw::table::SimpleCatalog getCatalog(std::vector< index_t *> inds, lsst::afw::coord::Coord const &ctrCoord, lsst::afw::geom::Angle const &radius, const char *idCol, std::vector< std::string > const &filterNameList, std::vector< std::string > const &magColList, std::vector< std::string > const &magErrColList, const char *starGalCol, const char *varCol, bool uniqueIds=true)
Load reference objects in a region of the sky described by a center coordinate and a radius...
void reload()
Reload the indices.
int isWithinRange(double ra, double dec, double radius_deg)
Is this multi-index in range of the specified cone?
void addIndices(std::vector< index_t *> inds)
Add indices to the solver.