LSST Applications  21.0.0+04719a4bac,21.0.0-1-ga51b5d4+f5e6047307,21.0.0-11-g2b59f77+a9c1acf22d,21.0.0-11-ga42c5b2+86977b0b17,21.0.0-12-gf4ce030+76814010d2,21.0.0-13-g1721dae+760e7a6536,21.0.0-13-g3a573fe+768d78a30a,21.0.0-15-g5a7caf0+f21cbc5713,21.0.0-16-g0fb55c1+b60e2d390c,21.0.0-19-g4cded4ca+71a93a33c0,21.0.0-2-g103fe59+bb20972958,21.0.0-2-g45278ab+04719a4bac,21.0.0-2-g5242d73+3ad5d60fb1,21.0.0-2-g7f82c8f+8babb168e8,21.0.0-2-g8f08a60+06509c8b61,21.0.0-2-g8faa9b5+616205b9df,21.0.0-2-ga326454+8babb168e8,21.0.0-2-gde069b7+5e4aea9c2f,21.0.0-2-gecfae73+1d3a86e577,21.0.0-2-gfc62afb+3ad5d60fb1,21.0.0-25-g1d57be3cd+e73869a214,21.0.0-3-g357aad2+ed88757d29,21.0.0-3-g4a4ce7f+3ad5d60fb1,21.0.0-3-g4be5c26+3ad5d60fb1,21.0.0-3-g65f322c+e0b24896a3,21.0.0-3-g7d9da8d+616205b9df,21.0.0-3-ge02ed75+a9c1acf22d,21.0.0-4-g591bb35+a9c1acf22d,21.0.0-4-g65b4814+b60e2d390c,21.0.0-4-gccdca77+0de219a2bc,21.0.0-4-ge8a399c+6c55c39e83,21.0.0-5-gd00fb1e+05fce91b99,21.0.0-6-gc675373+3ad5d60fb1,21.0.0-64-g1122c245+4fb2b8f86e,21.0.0-7-g04766d7+cd19d05db2,21.0.0-7-gdf92d54+04719a4bac,21.0.0-8-g5674e7b+d1bd76f71f,master-gac4afde19b+a9c1acf22d,w.2021.13
LSST Data Management Base Package
Associations.cc
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 /*
3  * This file is part of jointcal.
4  *
5  * Developed for the LSST Data Management System.
6  * This product includes software developed by the LSST Project
7  * (https://www.lsst.org).
8  * See the COPYRIGHT file at the top-level directory of this distribution
9  * for details of code ownership.
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <https://www.gnu.org/licenses/>.
23  */
24 
25 #include <cmath>
26 #include <iostream>
27 #include <limits>
28 #include <sstream>
29 
30 #include "lsst/log/Log.h"
32 #include "lsst/jointcal/CcdImage.h"
35 #include "lsst/jointcal/Frame.h"
36 #include "lsst/jointcal/FatPoint.h"
39 
40 #include "lsst/afw/image/Image.h"
43 
44 #include "lsst/pex/exceptions.h"
45 #include "lsst/geom/Box.h"
46 #include "lsst/geom/Point.h"
47 #include "lsst/afw/image/Calib.h"
48 
49 #include "lsst/sphgeom/LonLat.h"
50 #include "lsst/sphgeom/Circle.h"
52 
53 namespace jointcal = lsst::jointcal;
54 
55 namespace {
56 LOG_LOGGER _log = LOG_GET("jointcal.Associations");
57 }
58 
59 namespace lsst {
60 namespace jointcal {
61 
68  lsst::jointcal::JointcalControl const &control) {
69  auto ccdImage = std::make_shared<CcdImage>(catalog, wcs, visitInfo, bbox, filter, photoCalib, detector,
70  visit, ccd, control.sourceFluxField);
71  ccdImageList.push_back(ccdImage);
72 }
73 
76  centers.reserve(ccdImageList.size());
77  for (auto const &ccdImage : ccdImageList) {
78  centers.push_back(ccdImage->getBoresightRaDec());
79  }
80  auto commonTangentPoint = geom::averageSpherePoint(centers);
81  LOGLS_DEBUG(_log, "Using common tangent point: " << commonTangentPoint.getPosition(geom::degrees));
82  setCommonTangentPoint(commonTangentPoint.getPosition(geom::degrees));
83 }
84 
86  _commonTangentPoint = Point(commonTangentPoint.getX(), commonTangentPoint.getY()); // a jointcal::Point
87  for (auto &ccdImage : ccdImageList) ccdImage->setCommonTangentPoint(_commonTangentPoint);
88 }
89 
91  // Compute the frame on the common tangent plane that contains all input images.
92  Frame tangentPlaneFrame;
93 
94  for (auto const &ccdImage : ccdImageList) {
95  Frame CTPFrame = ccdImage->getPixelToCommonTangentPlane()->apply(ccdImage->getImageFrame(), false);
96  if (tangentPlaneFrame.getArea() == 0)
97  tangentPlaneFrame = CTPFrame;
98  else
99  tangentPlaneFrame += CTPFrame;
100  }
101 
102  // Convert tangent plane coordinates to RaDec.
103  AstrometryTransformLinear identity;
104  TanPixelToRaDec commonTangentPlaneToRaDec(identity, _commonTangentPoint);
105  Frame raDecFrame = commonTangentPlaneToRaDec.apply(tangentPlaneFrame, false);
106 
108  points.reserve(4);
109  // raDecFrame is in on-sky (RA,Dec) degrees stored as an x/y box:
110  // the on-sky bounding box it represents is given by the corners of that box.
111  points.emplace_back(sphgeom::LonLat::fromDegrees(raDecFrame.xMin, raDecFrame.yMin));
112  points.emplace_back(sphgeom::LonLat::fromDegrees(raDecFrame.xMax, raDecFrame.yMin));
113  points.emplace_back(sphgeom::LonLat::fromDegrees(raDecFrame.xMin, raDecFrame.yMax));
114  points.emplace_back(sphgeom::LonLat::fromDegrees(raDecFrame.xMax, raDecFrame.yMax));
115 
117 }
118 
119 void Associations::associateCatalogs(const double matchCutInArcSec, const bool useFittedList,
120  const bool enlargeFittedList) {
121  // clear reference stars
122  refStarList.clear();
123 
124  // clear measurement counts and associations to refstars, but keep fittedStars themselves.
125  for (auto &item : fittedStarList) {
126  item->clearBeforeAssoc();
127  }
128  // clear fitted stars
129  if (!useFittedList) fittedStarList.clear();
130 
131  for (auto &ccdImage : ccdImageList) {
132  std::shared_ptr<AstrometryTransform> toCommonTangentPlane = ccdImage->getPixelToCommonTangentPlane();
133 
134  // Clear the catalog to fit and copy the whole catalog into it.
135  // This allows reassociating from scratch after a fit.
136  ccdImage->resetCatalogForFit();
137  MeasuredStarList &catalog = ccdImage->getCatalogForFit();
138 
139  // Associate with previous lists.
140  /* To speed up the match (more precisely the contruction of the FastFinder), select in the
141  fittedStarList the objects that are within reach of the current ccdImage */
142  Frame ccdImageFrameCPT = toCommonTangentPlane->apply(ccdImage->getImageFrame(), false);
143  ccdImageFrameCPT = ccdImageFrameCPT.rescale(1.10); // add 10 % margin.
144  // We cannot use FittedStarList::ExtractInFrame, because it does an actual copy, which we don't want
145  // here: we want the pointers in the StarMatch to refer to fittedStarList elements.
146  FittedStarList toMatch;
147 
148  for (auto const &fittedStar : fittedStarList) {
149  if (ccdImageFrameCPT.inFrame(*fittedStar)) {
150  toMatch.push_back(fittedStar);
151  }
152  }
153 
154  // divide by 3600 because coordinates in CTP are in degrees.
155  auto starMatchList = listMatchCollect(Measured2Base(catalog), Fitted2Base(toMatch),
156  toCommonTangentPlane.get(), matchCutInArcSec / 3600.);
157 
158  /* should check what this removeAmbiguities does... */
159  LOGLS_DEBUG(_log, "Measured-to-Fitted matches before removing ambiguities " << starMatchList->size());
160  starMatchList->removeAmbiguities(*toCommonTangentPlane);
161  LOGLS_DEBUG(_log, "Measured-to-Fitted matches after removing ambiguities " << starMatchList->size());
162 
163  // Associate MeasuredStar -> FittedStar using the surviving matches.
164 
165  int matchedCount = 0;
166  for (auto const &starMatch : *starMatchList) {
167  auto bs = starMatch.s1;
168  auto ms_const = std::dynamic_pointer_cast<const MeasuredStar>(bs);
169  auto ms = std::const_pointer_cast<MeasuredStar>(ms_const);
170  auto bs2 = starMatch.s2;
171  auto fs_const = std::dynamic_pointer_cast<const FittedStar>(bs2);
172  auto fs = std::const_pointer_cast<FittedStar>(fs_const);
173  ms->setFittedStar(fs);
174  matchedCount++;
175  }
176  LOGLS_INFO(_log, "Matched " << matchedCount << " objects in " << ccdImage->getName());
177 
178  // add unmatched objets to FittedStarList
179  int unMatchedCount = 0;
180  for (auto const &mstar : catalog) {
181  // to check if it was matched, just check if it has a fittedStar Pointer assigned
182  if (mstar->getFittedStar()) continue;
183  if (enlargeFittedList) {
184  auto fs = std::make_shared<FittedStar>(*mstar);
185  // transform coordinates to CommonTangentPlane
186  toCommonTangentPlane->transformPosAndErrors(*fs, *fs);
188  mstar->setFittedStar(fs);
189  }
190  unMatchedCount++;
191  }
192  LOGLS_INFO(_log, "Unmatched objects: " << unMatchedCount);
193  } // end of loop on CcdImages
194 
195  // !!!!!!!!!!!!!!!!!
196  // TODO: DO WE REALLY NEED THIS???
197  // Why do we need to do this, instead of directly computing them in normalizeFittedStars?
198  // What makes the magnitudes special here?
199  // !!!!!!!!!!!!!!!!!
200  // assignMags();
201 }
202 
204  std::string const &fluxField, float refCoordinateErr,
205  bool rejectBadFluxes) {
206  if (refCat.size() == 0) {
208  " reference catalog is empty : stop here "));
209  }
210 
211  afw::table::CoordKey coordKey = refCat.getSchema()["coord"];
212  // Handle reference catalogs that don't have position errors.
213  afw::table::Key<float> raErrKey;
214  afw::table::Key<float> decErrKey;
215  if (std::isnan(refCoordinateErr)) {
216  raErrKey = refCat.getSchema()["coord_raErr"];
217  decErrKey = refCat.getSchema()["coord_decErr"];
218  }
219 
220  auto fluxKey = refCat.getSchema().find<double>(fluxField).key;
221  // Handle reference catalogs that don't have flux errors.
222  afw::table::Key<double> fluxErrKey;
223  try {
224  fluxErrKey = refCat.getSchema().find<double>(fluxField + "Err").key;
225  } catch (pex::exceptions::NotFoundError &) {
226  LOGLS_WARN(_log, "Flux error field ("
227  << fluxField << "Err"
228  << ") not found in reference catalog. Not using ref flux errors.");
229  }
230 
231  refStarList.clear();
232  for (size_t i = 0; i < refCat.size(); i++) {
233  auto const &record = refCat.get(i);
234 
235  auto coord = record->get(coordKey);
236  double flux = record->get(fluxKey);
237  double fluxErr;
238  if (fluxErrKey.isValid()) {
239  fluxErr = record->get(fluxErrKey);
240  } else {
242  }
243  double ra = lsst::geom::radToDeg(coord.getLongitude());
244  double dec = lsst::geom::radToDeg(coord.getLatitude());
245  auto star = std::make_shared<RefStar>(ra, dec, flux, fluxErr);
246 
247  if (std::isnan(refCoordinateErr)) {
248  // refcat errors are unitless but stored as radians: convert to deg**2
249  star->vx = std::pow(lsst::geom::radToDeg(record->get(raErrKey)), 2);
250  star->vy = std::pow(lsst::geom::radToDeg(record->get(decErrKey)), 2);
251  } else {
252  // Convert the fake errors from mas to deg**2
253  star->vx = std::pow(refCoordinateErr / 1000. / 3600. / std::cos(coord.getLatitude()), 2);
254  star->vy = std::pow(refCoordinateErr / 1000. / 3600., 2);
255  }
256  // TODO: cook up a covariance as none of our current refcats have it
257  star->vxy = 0.;
258 
259  // Reject sources with non-finite fluxes and flux errors, and fluxErr=0 (which gives chi2=inf).
260  if (rejectBadFluxes && (!std::isfinite(flux) || !std::isfinite(fluxErr) || fluxErr <= 0)) continue;
261  refStarList.push_back(star);
262  }
263 
264  // project on CTP (i.e. RaDec2CTP), in degrees
265  AstrometryTransformLinear identity;
266  TanRaDecToPixel raDecToCommonTangentPlane(identity, _commonTangentPoint);
267 
268  associateRefStars(matchCut.asArcseconds(), &raDecToCommonTangentPlane);
269 }
270 
271 void Associations::associateRefStars(double matchCutInArcSec, const AstrometryTransform *transform) {
272  // associate with FittedStars
273  // 3600 because coordinates are in degrees (in CTP).
275  matchCutInArcSec / 3600.);
276 
277  LOGLS_DEBUG(_log, "Refcat matches before removing ambiguities " << starMatchList->size());
278  starMatchList->removeAmbiguities(*transform);
279  LOGLS_DEBUG(_log, "Refcat matches after removing ambiguities " << starMatchList->size());
280 
281  // actually associate things
282  for (auto const &starMatch : *starMatchList) {
283  const BaseStar &bs = *starMatch.s1;
284  const RefStar &rs_const = dynamic_cast<const RefStar &>(bs);
285  RefStar &rs = const_cast<RefStar &>(rs_const);
286  const BaseStar &bs2 = *starMatch.s2;
287  const FittedStar &fs_const = dynamic_cast<const FittedStar &>(bs2);
288  FittedStar &fs = const_cast<FittedStar &>(fs_const);
289  // rs->setFittedStar(*fs);
290  fs.setRefStar(&rs);
291  }
292 
293  LOGLS_INFO(_log,
294  "Associated " << starMatchList->size() << " reference stars among " << refStarList.size());
295 }
296 
297 void Associations::prepareFittedStars(int minMeasurements) {
298  selectFittedStars(minMeasurements);
299  normalizeFittedStars();
300 }
301 
302 void Associations::selectFittedStars(int minMeasurements) {
303  LOGLS_INFO(_log, "Fitted stars before measurement # cut: " << fittedStarList.size());
304 
305  int totalMeasured = 0, validMeasured = 0;
306 
307  // first pass: remove objects that have less than a certain number of measurements.
308  for (auto const &ccdImage : ccdImageList) {
309  MeasuredStarList &catalog = ccdImage->getCatalogForFit();
310  // Iteration happens internal to the loop, as we may delete measuredStars from catalog.
311  for (MeasuredStarIterator mi = catalog.begin(); mi != catalog.end();) {
312  MeasuredStar &mstar = **mi;
313  ++totalMeasured;
314 
315  auto fittedStar = mstar.getFittedStar();
316  // measuredStar has no fittedStar: move on.
317  if (fittedStar == nullptr) {
318  ++mi;
319  continue;
320  }
321 
322  // keep FittedStars which either have a minimum number of
323  // measurements, or are matched to a RefStar
324  if (!fittedStar->getRefStar() && fittedStar->getMeasurementCount() < minMeasurements) {
325  fittedStar->getMeasurementCount()--;
326  mi = catalog.erase(mi); // mi now points to the next measuredStar.
327  } else {
328  ++validMeasured;
329  ++mi;
330  }
331  } // end loop on objects in catalog
332  } // end loop on catalogs
333 
334  // now FittedStars with less than minMeasurements should have zero measurementCount.
335  for (FittedStarIterator fi = fittedStarList.begin(); fi != fittedStarList.end();) {
336  if ((*fi)->getMeasurementCount() == 0) {
337  fi = fittedStarList.erase(fi);
338  } else {
339  ++fi;
340  }
341  }
342 
343  LOGLS_INFO(_log, "Fitted stars after measurement # cut: " << fittedStarList.size());
344  LOGLS_INFO(_log, "Total, valid number of Measured stars: " << totalMeasured << ", " << validMeasured);
345 }
346 
347 void Associations::normalizeFittedStars() const {
348  // Clear positions in order to take the average of the measuredStars.
349  for (auto &fittedStar : fittedStarList) {
350  fittedStar->x = 0.0;
351  fittedStar->y = 0.0;
352  fittedStar->setFlux(0.0);
353  fittedStar->getMag() = 0.0;
354  }
355 
356  // Iterate over measuredStars to add their values into their fittedStars
357  for (auto const &ccdImage : ccdImageList) {
358  std::shared_ptr<AstrometryTransform> toCommonTangentPlane = ccdImage->getPixelToCommonTangentPlane();
359  MeasuredStarList &catalog = ccdImage->getCatalogForFit();
360  for (auto &mi : catalog) {
361  auto fittedStar = mi->getFittedStar();
362  if (fittedStar == nullptr)
363  throw(LSST_EXCEPT(
364  pex::exceptions::RuntimeError,
365  "All measuredStars must have a fittedStar: did you call selectFittedStars()?"));
366  auto point = toCommonTangentPlane->apply(*mi);
367  fittedStar->x += point.x;
368  fittedStar->y += point.y;
369  fittedStar->getFlux() += mi->getFlux();
370  }
371  }
372 
373  for (auto &fi : fittedStarList) {
374  auto measurementCount = fi->getMeasurementCount();
375  fi->x /= measurementCount;
376  fi->y /= measurementCount;
377  fi->getFlux() /= measurementCount;
378  fi->getMag() = utils::nanojanskyToABMagnitude(fi->getFlux());
379  }
380 }
381 
382 void Associations::assignMags() {
383  for (auto const &ccdImage : ccdImageList) {
384  MeasuredStarList &catalog = ccdImage->getCatalogForFit();
385  for (auto const &mstar : catalog) {
386  auto fstar = mstar->getFittedStar();
387  if (!fstar) continue;
388  fstar->addMagMeasurement(mstar->getMag(), mstar->getMagWeight());
389  }
390  }
391 }
392 
394  // By default, Associations::fittedStarList is expressed on the Associations::commonTangentPlane.
395  // For AstrometryFit, we need it on the sky.
397  LOGLS_WARN(_log,
398  "DeprojectFittedStars: Fitted stars are already in sidereal coordinates, nothing done ");
399  return;
400  }
401 
405 }
406 
409  return item->getCatalogForFit().size() > 0;
410  });
411 }
412 
414  size_t count = 0;
415  for (auto const &fittedStar : fittedStarList) {
416  if ((fittedStar != nullptr) & (fittedStar->getRefStar() != nullptr)) count++;
417  }
418  return count;
419 }
420 
421 #ifdef TODO
422 void Associations::collectMCStars(int realization) {
423  CcdImageIterator I;
424  StarMatchIterator smI;
425 
426  for (I = ccdImageList.begin(); I != ccdImageList.end(); I++) {
427  CcdImage &ccdImage = **I;
428  string dbimdir = ccdImage.Dir();
429  string mctruth = dbimdir + "/mc/mctruth.list";
430 
431  if (realization >= 0) {
432  stringstream sstrm;
433  sstrm << dbimdir << "/mc/mctruth_" << realization << ".list";
434  mctruth = sstrm.str();
435  }
436 
437  AstrometryTransformIdentity gti;
438  MeasuredStarList &catalog = ccdImage.getCatalogForFit();
439 
440  // BaseStarWithErrorList mctruthlist(mctruth);
441  DicStarList mctruthlist(mctruth);
442  auto starMatchList =
443  listMatchCollect(Measured2Base(catalog), Dic2Base(mctruthlist), &gti, 1. /* pixel ? */);
444  if (starMatchList)
445  for (smI = starMatchList->begin(); smI != starMatchList->end(); smI++) {
446  StarMatch &sm = *smI;
447  BaseStar *bs = sm.s1;
448  MeasuredStar *mstar = dynamic_cast<MeasuredStar *>(bs);
449  bs = sm.s2;
450  DicStar *dstar = dynamic_cast<DicStar *>(bs);
451  std::unique_ptr<BaseStarWithError> mcstar(new BaseStarWithError(*bs));
452  mcstar->GetMCInfo().iflux = dstar->getval("iflux");
453  mcstar->GetMCInfo().tflux = dstar->getval("sflux");
454  /*
455  mstar->SetMCTruth(mcstar);
456  mstar->SetMCMeas(mcstar);
457  */
458  }
459  else
460  LOGLS_FATAL(_log, "CollectMCStars Unable to match MCTruth w/ catalog!");
461  }
462 }
463 
464 void Associations::setFittedStarColors(std::string dicStarListName, std::string color,
465  double matchCutArcSec) {
466  // decode color string in case it is x-y
467  size_t pos_minus = color.find('-');
468  bool compute_diff = (pos_minus != string::npos);
469  std::string c1, c2;
470  c1 = color.substr(0, pos_minus); // if pos_minus == npos, means "up to the end"
471  if (compute_diff) c2 = color.substr(pos_minus + 1, string::npos);
472  DicStarList cList(dicStarListName);
473  if (!cList.HasKey(c1))
474  throw(GastroException("Associations::SetFittedstarColors : " + dicStarListName +
475  " misses a key named \"" + c1 + "\""));
476  if (compute_diff && !cList.HasKey(c2))
477  throw(GastroException("Associations::SetFittedstarColors : " + dicStarListName +
478  " misses a key named \"" + c2 + "\""));
479  // we associate in some tangent plane. The reference catalog is expressed on the sky,
480  // but FittedStar's may be still in this tangent plane.
482  AstrometryTransformIdentity id;
483  TanRaDecToPixel proj(AstrometryTransformLinear(), getCommonTangentPoint());
484  // project or not ?
485  AstrometryTransform *id_or_proj = &proj;
486  if (fittedStarList.inTangentPlaneCoordinates) id_or_proj = &id;
487  // The color List is to be projected:
488  TStarList projected_cList((BaseStarList &)cList, proj);
489  // Associate
490  auto starMatchList = listMatchCollect(Fitted2Base(fittedStarList), (const BaseStarList &)projected_cList,
491  id_or_proj, matchCutArcSec / 3600);
492 
493  LOGLS_INFO(_log, "Matched " << starMatchList->size() << '/' << fittedStarList.size()
494  << " FittedStars to color catalog");
495  // Evaluate and assign colors.
496  for (auto i = starMatchList->begin(); i != starMatchList->end(); ++i) {
497  BaseStar *s1 = i->s1;
498  FittedStar *fs = dynamic_cast<FittedStar *>(s1);
499  BaseStar *s2 = i->s2;
500  const TStar *ts = dynamic_cast<const TStar *>(s2);
501  const DicStar *ds = dynamic_cast<const DicStar *>(ts->get_original());
502  fs->color = ds->getval(c1);
503  if (compute_diff) fs->color -= ds->getval(c2);
504  }
505 }
506 
507 #endif /* TODO */
508 } // namespace jointcal
509 } // namespace lsst
AmpInfoBoxKey bbox
Definition: Amplifier.cc:117
This file declares a class for representing circular regions on the unit sphere.
This file declares a class for representing convex polygons with great circle edges on the unit spher...
table::Key< int > id
Definition: Detector.cc:162
table::Key< int > detector
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
Combinatorial searches for linear transformations to go from list1 to list2.
LSST DM logging module built on log4cxx.
#define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
Definition: Log.h:648
#define LOGLS_FATAL(logger, message)
Log a fatal-level message using an iostream-based interface.
Definition: Log.h:688
#define LOG_GET(logger)
Returns a Log object associated with logger.
Definition: Log.h:75
#define LOGLS_INFO(logger, message)
Log a info-level message using an iostream-based interface.
Definition: Log.h:628
#define LOG_LOGGER
Definition: Log.h:703
#define LOGLS_DEBUG(logger, message)
Log a debug-level message using an iostream-based interface.
Definition: Log.h:608
This file contains a class representing spherical coordinates.
double dec
Definition: Match.cc:41
Key< U > key
Definition: Schema.cc:281
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
pairs of points
table::Key< int > transform
T begin(T... args)
size_type size() const
Return the number of elements in the catalog.
Definition: Catalog.h:408
Schema getSchema() const
Return the schema associated with the catalog's table.
Definition: Catalog.h:117
std::shared_ptr< RecordT > const get(size_type i) const
Return a pointer to the record at index i.
Definition: Catalog.h:459
A FunctorKey used to get or set celestial coordinates from a pair of lsst::geom::Angle keys.
Definition: aggregates.h:210
SchemaItem< T > find(std::string const &name) const
Find a SchemaItem in the Schema by name.
Definition: Schema.cc:656
Custom catalog class for record/table subclasses that are guaranteed to have an ID,...
Definition: SortedCatalog.h:42
A class representing an angle.
Definition: Angle.h:127
constexpr double asArcseconds() const noexcept
Return an Angle's value in arcseconds.
Definition: Angle.h:178
An integer coordinate rectangle.
Definition: Box.h:55
size_t nFittedStarsWithAssociatedRefStar() const
Return the number of fittedStars that have an associated refStar.
void computeCommonTangentPoint()
Sets a shared tangent point for all ccdImages, using the mean of the centers of all ccdImages.
Definition: Associations.cc:74
lsst::sphgeom::Circle computeBoundingCircle() const
Return the bounding circle in on-sky (RA, Dec) coordinates containing all CcdImages.
Definition: Associations.cc:90
int nCcdImagesValidForFit() const
return the number of CcdImages with non-empty catalogs to-be-fit.
void createCcdImage(afw::table::SourceCatalog &catalog, std::shared_ptr< lsst::afw::geom::SkyWcs > wcs, std::shared_ptr< lsst::afw::image::VisitInfo > visitInfo, lsst::geom::Box2I const &bbox, std::string const &filter, std::shared_ptr< afw::image::PhotoCalib > photoCalib, std::shared_ptr< afw::cameraGeom::Detector > detector, int visit, int ccd, lsst::jointcal::JointcalControl const &control)
Create a ccdImage from an exposure catalog and metadata, and add it to the list.
Definition: Associations.cc:62
void setCommonTangentPoint(lsst::geom::Point2D const &commonTangentPoint)
Sets a shared tangent point for all ccdImages.
Definition: Associations.cc:85
void associateCatalogs(const double matchCutInArcsec=0, const bool useFittedList=false, const bool enlargeFittedList=true)
incrementaly builds a merged catalog of all image catalogs
Point getCommonTangentPoint() const
can be used to project sidereal coordinates related to the image set on a plane.
Definition: Associations.h:105
void collectRefStars(afw::table::SimpleCatalog &refCat, geom::Angle matchCut, std::string const &fluxField, float refCoordinateErr, bool rejectBadFluxes=false)
Collect stars from an external reference catalog and associate them with fittedStars.
FittedStarList fittedStarList
Definition: Associations.h:58
void prepareFittedStars(int minMeasurements)
Set the color field of FittedStar 's from a colored catalog.
void deprojectFittedStars()
Sends back the fitted stars coordinates on the sky FittedStarsList::inTangentPlaneCoordinates keeps t...
a virtual (interface) class for geometric transformations.
implements the linear transformations (6 real coefficients).
The base class for handling stars. Used by all matching routines.
Definition: BaseStar.h:50
double getMag() const
Definition: BaseStar.h:103
Handler of an actual image from a single CCD.
Definition: CcdImage.h:64
MeasuredStarList const & getCatalogForFit() const
Gets the catalog to be used for fitting, which may have been cleaned-up.
Definition: CcdImage.h:94
The objects which have been measured several times.
Definition: FittedStar.h:61
void setRefStar(const RefStar *_refStar)
Set the astrometric reference star associated with this star.
Definition: FittedStar.cc:46
A list of FittedStar s. Such a list is typically constructed by Associations.
Definition: FittedStar.h:123
rectangle with sides parallel to axes.
Definition: Frame.h:38
Frame rescale(const double factor) const
rescale it. The center does not move.
Definition: Frame.cc:110
bool inFrame(double x, double y) const
inside?
Definition: Frame.cc:120
double xMin
coordinate of boundary.
Definition: Frame.h:41
double getArea() const
Definition: Frame.cc:118
objects measured on actual images.
Definition: MeasuredStar.h:46
std::shared_ptr< FittedStar > getFittedStar() const
Definition: MeasuredStar.h:113
double getMagWeight() const
the inverse of the mag variance
Definition: MeasuredStar.h:106
A list of MeasuredStar. They are usually filled in Associations::createCcdImage.
Definition: MeasuredStar.h:146
A point in a plane.
Definition: Point.h:36
Objects used as position anchors, typically USNO stars.
Definition: RefStar.h:39
void applyTransform(const Operator &op)
enables to apply a geometrical transform if Star is Basestar or derives from it.
Definition: StarList.h:98
The transformation that handles pixels to sideral transformations (Gnomonic, possibly with polynomial...
virtual void apply(const double xIn, const double yIn, double &xOut, double &yOut) const=0
This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane)
Reports invalid arguments.
Definition: Runtime.h:66
Reports attempts to access elements using an invalid key.
Definition: Runtime.h:151
Circle is a circular region on the unit sphere that contains its boundary.
Definition: Circle.h:46
static ConvexPolygon convexHull(std::vector< UnitVector3d > const &points)
convexHull returns the convex hull of the given set of points if it exists and throws an exception ot...
Definition: ConvexPolygon.h:65
Circle getBoundingCircle() const override
getBoundingCircle returns a bounding-circle for this region.
static LonLat fromDegrees(double lon, double lat)
Definition: LonLat.h:50
T clear(T... args)
T cos(T... args)
T count_if(T... args)
T emplace_back(T... args)
T end(T... args)
T erase(T... args)
T find(T... args)
T get(T... args)
T isfinite(T... args)
T isnan(T... args)
SpherePoint averageSpherePoint(std::vector< SpherePoint > const &coords)
Return the average of a list of coordinates.
Definition: SpherePoint.cc:235
constexpr AngleUnit degrees
constant with units of degrees
Definition: Angle.h:109
constexpr double radToDeg(double x) noexcept
Definition: Angle.h:52
StarList< BaseStar > BaseStarList
Definition: BaseStar.h:119
BaseStarList & Measured2Base(MeasuredStarList &This)
Definition: MeasuredStar.cc:58
std::unique_ptr< StarMatchList > listMatchCollect(const BaseStarList &list1, const BaseStarList &list2, const AstrometryTransform *guess, const double maxDist)
assembles star matches.
Definition: ListMatch.cc:569
BaseStarList & Fitted2Base(FittedStarList &This)
Definition: FittedStar.cc:64
MeasuredStarList::iterator MeasuredStarIterator
Definition: MeasuredStar.h:154
::std::list< StarMatch >::iterator StarMatchIterator
Definition: StarMatch.h:133
BaseStarList & Ref2Base(RefStarList &This)
Definition: RefStar.cc:34
FittedStarList::iterator FittedStarIterator
Definition: FittedStar.h:132
double nanojanskyToABMagnitude(double flux)
Convert a flux in nanojansky to AB magnitude.
Definition: Magnitude.cc:30
A base class for image defects.
T pow(T... args)
T push_back(T... args)
T quiet_NaN(T... args)
T reserve(T... args)
T size(T... args)
T str(T... args)
std::string sourceFluxField
"name of flux field in source catalog" ;
T substr(T... args)
Key< int > visitInfo
Definition: Exposure.cc:70
Key< int > photoCalib
Definition: Exposure.cc:67