46 LOG_LOGGER _log =
LOG_GET(
"jointcal.CcdImage");
53 out <<
"(visit: " << key.
visit <<
", ccd: " << key.
ccd <<
")";
65 auto instFluxKey = catalog.
getSchema().
find<
double>(fluxField +
"_instFlux").
key;
66 auto instFluxErrKey = catalog.
getSchema().
find<
double>(fluxField +
"_instFluxErr").
key;
68 auto transform = _detector->getTransform(afw::cameraGeom::PIXELS, afw::cameraGeom::FOCAL_PLANE);
70 _wholeCatalog.clear();
71 for (
auto const &record : catalog) {
72 auto ms = std::make_shared<MeasuredStar>();
73 ms->setId(record.getId());
74 ms->x = record.get(xKey);
75 ms->y = record.get(yKey);
76 ms->vx =
std::pow(record.get(xsKey), 2);
77 ms->vy =
std::pow(record.get(ysKey), 2);
78 auto pointFocal = transform->applyForward(record.getCentroid());
79 ms->setXFocal(pointFocal.getX());
80 ms->setYFocal(pointFocal.getY());
84 double mxx = record.get(mxxKey);
85 double myy = record.get(myyKey);
86 double mxy = record.get(mxyKey);
87 ms->vxy = mxy * (ms->vx + ms->vy) / (mxx + myy);
88 if (
std::isnan(ms->vxy) || ms->vx < 0 || ms->vy < 0 || (ms->vxy * ms->vxy) > (ms->vx * ms->vy)) {
89 LOGLS_WARN(_log,
"Bad source detected during loadCatalog id: " 90 << ms->getId() <<
" with vx,vy: " << ms->vx <<
"," << ms->vy
91 <<
" vxy^2: " << ms->vxy * ms->vxy <<
" vx*vy: " << ms->vx * ms->vy);
94 ms->setInstFluxAndErr(record.get(instFluxKey), record.get(instFluxErrKey));
98 afw::geom::Point<double, 2> point(ms->x, ms->y);
99 auto flux = _photoCalib->instFluxToNanojansky(ms->getInstFlux(), ms->getInstFluxErr(), point);
100 ms->setFlux(flux.value);
101 ms->setFluxErr(flux.error);
102 auto mag = _photoCalib->instFluxToMagnitude(ms->getInstFlux(), ms->getInstFluxErr(), point);
103 ms->getMag() = mag.value;
104 ms->setMagErr(mag.error);
105 ms->setCcdImage(
this);
108 _wholeCatalog.setCcdImage(
this);
116 : _ccdId(ccdId), _visit(visit), _photoCalib(photoCalib), _detector(detector), _filter(filter) {
117 loadCatalog(catalog, fluxField);
119 Point lowerLeft(bbox.getMinX(), bbox.getMinY());
120 Point upperRight(bbox.getMaxX(), bbox.getMaxY());
121 _imageFrame =
Frame(lowerLeft, upperRight);
123 _readWcs = std::make_shared<AstrometryTransformSkyWcs>(wcs);
126 out << visit <<
"_" << ccdId;
129 _boresightRaDec = visitInfo->getBoresightRaDec();
130 _airMass = visitInfo->getBoresightAirmass();
132 double latitude = visitInfo->getObservatory().getLatitude();
133 _lstObs = visitInfo->getEra();
134 _hourAngle = visitInfo->getBoresightHourAngle();
143 _sinEta = _cosEta = _tanZ = 0;
145 double cosz = 1. / _airMass;
146 double sinz =
std::sqrt(1 - cosz * cosz);
149 double dec = _boresightRaDec.getLatitude();
160 int measuredStars = 0;
162 for (
auto const &measuredStar : _catalogForFit) {
163 if (measuredStar->isValid()) {
166 if ((measuredStar->getFittedStar() !=
nullptr) &&
167 (measuredStar->getFittedStar()->getRefStar() !=
nullptr)) {
175 _commonTangentPoint = commonTangentPoint;
177 auto const crval = _readWcs->getSkyWcs()->getSkyOrigin();
185 _pixelToTangentPlane =
compose(raDecToTangentPlane, *_readWcs);
186 TanPixelToRaDec CommonTangentPlane2RaDec(identity, commonTangentPoint);
187 _commonTangentPlaneToTangentPlane =
compose(raDecToTangentPlane, CommonTangentPlane2RaDec);
190 TanRaDecToPixel raDecToCommonTangentPlane(identity, commonTangentPoint);
192 _tangentPlaneToCommonTangentPlane =
compose(raDecToCommonTangentPlane, TangentPlaneToRaDec);
196 _pixelToCommonTangentPlane =
compose(raDecToCommonTangentPlane, *_readWcs);
The transformation that handles pixels to sideral transformations (Gnomonic, possibly with polynomial...
std::ostream & operator<<(std::ostream &stream, AstrometryTransform const &transform)
Delegates to transform.dump()
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 AstrometryTransform.
std::unique_ptr< AstrometryTransform > compose(AstrometryTransform const &left, AstrometryTransform const &right)
Returns a pointer to a composition of transforms, representing left(right()).
This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane) ...
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.