22 LOG_LOGGER _log =
LOG_GET(
"jointcal.CcdImage");
29 out <<
"(visit: " << key.
visit <<
", ccd: " << key.
ccd <<
")";
42 auto fluxErrKey = catalog.
getSchema().
find<
double>(fluxField +
"_fluxSigma").
key;
44 auto transform = _detector->getTransform(afw::cameraGeom::PIXELS, afw::cameraGeom::FOCAL_PLANE);
46 _wholeCatalog.clear();
47 for (
auto const &record : catalog) {
48 auto ms = std::make_shared<MeasuredStar>();
49 ms->setId(record.getId());
50 ms->x = record.get(xKey);
51 ms->y = record.get(yKey);
52 ms->vx =
std::pow(record.get(xsKey), 2);
53 ms->vy =
std::pow(record.get(ysKey), 2);
54 auto pointFocal = transform->applyForward(record.getCentroid());
55 ms->setXFocal(pointFocal.getX());
56 ms->setYFocal(pointFocal.getY());
60 double mxx = record.get(mxxKey);
61 double myy = record.get(myyKey);
62 double mxy = record.get(mxyKey);
63 ms->vxy = mxy * (ms->vx + ms->vy) / (mxx + myy);
64 if (
std::isnan(ms->vxy) || ms->vx < 0 || ms->vy < 0 || (ms->vxy * ms->vxy) > (ms->vx * ms->vy)) {
65 LOGLS_WARN(_log,
"Bad source detected during loadCatalog id: " 66 << ms->getId() <<
" with vx,vy: " << ms->vx <<
"," << ms->vy
67 <<
" vxy^2: " << ms->vxy * ms->vxy <<
" vx*vy: " << ms->vx * ms->vy);
70 ms->setInstFlux(record.get(fluxKey));
71 ms->setInstFluxErr(record.get(fluxErrKey));
74 afw::geom::Point<double, 2> point(ms->x, ms->y);
75 auto flux = _photoCalib->instFluxToMaggies(ms->getInstFlux(), ms->getInstFluxErr(), point);
76 ms->setFlux(flux.value);
77 ms->setFluxErr(flux.err);
78 ms->mag = _photoCalib->instFluxToMagnitude(ms->getInstFlux(), point);
79 ms->setCcdImage(
this);
82 _wholeCatalog.setCcdImage(
this);
90 : _ccdId(ccdId), _visit(visit), _photoCalib(photoCalib), _detector(detector), _filter(filter) {
91 loadCatalog(catalog, fluxField);
93 Point lowerLeft(bbox.getMinX(), bbox.getMinY());
94 Point upperRight(bbox.getMaxX(), bbox.getMaxY());
95 _imageFrame =
Frame(lowerLeft, upperRight);
97 _readWcs = std::make_shared<GtransfoSkyWcs>(wcs);
100 out << visit <<
"_" << ccdId;
103 _boresightRaDec = visitInfo->getBoresightRaDec();
104 _airMass = visitInfo->getBoresightAirmass();
106 double latitude = visitInfo->getObservatory().getLatitude();
107 _lstObs = visitInfo->getEra();
108 _hourAngle = visitInfo->getBoresightHourAngle();
117 _sineta = _coseta = _tgz = 0;
119 double cosz = 1. / _airMass;
120 double sinz =
sqrt(1 - cosz * cosz);
123 double dec = _boresightRaDec.getLatitude();
125 double yEta =
sin(_hourAngle);
126 double xEta =
cos(dec) *
tan(latitude) -
sin(dec) *
cos(_hourAngle);
127 double eta =
atan2(yEta, xEta);
134 int measuredStars = 0;
136 for (
auto const &measuredStar : _catalogForFit) {
137 if (measuredStar->isValid()) {
140 if ((measuredStar->getFittedStar() !=
nullptr) &&
141 (measuredStar->getFittedStar()->getRefStar() !=
nullptr)) {
149 _commonTangentPoint = commonTangentPoint;
151 auto const crval = _readWcs->getSkyWcs()->getSkyOrigin();
167 _sky2TP.reset(
new TanRaDec2Pix(identity, tangentPoint));
implements the linear transformations (6 real coefficients).
std::ostream & operator<<(std::ostream &out, CcdImageKey const &key)
the transformation that handles pix to sideral transfos (Gnomonic, possibly with polynomial distortio...
For hashing a ccdImage: the pair of (visit, ccd) IDs should be unique to each ccdImage.
table::PointKey< double > crval
table::Key< lsst::geom::Angle > latitude
rectangle with sides parallel to axes.
SchemaItem< T > find(std::string const &name) const
Class for a simple mapping implementing a generic Gtransfo.
This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane) ...
table::Key< int > transform
void setCommonTangentPoint(Point const &commonTangentPoint)
Sets the common tangent point and computes necessary transforms.
#define LOGLS_WARN(logger, message)
std::pair< int, int > countStars() const
Count the number of valid measured and reference stars that fall within this ccdImage.
std::unique_ptr< Gtransfo > gtransfoCompose(Gtransfo const &left, Gtransfo const &right)
Returns a pointer to a composition of gtransfos, representing left(right()).