54 out <<
"(visit: " << key.
visit <<
", detector: " << key.
ccd <<
")";
59 auto xKey = catalog.getSchema().find<
double>(
"slot_Centroid_x").key;
60 auto yKey = catalog.getSchema().find<
double>(
"slot_Centroid_y").key;
61 auto xsKey = catalog.getSchema().find<
float>(
"slot_Centroid_xErr").key;
62 auto ysKey = catalog.getSchema().find<
float>(
"slot_Centroid_yErr").key;
63 auto mxxKey = catalog.getSchema().find<
double>(
"slot_Shape_xx").key;
64 auto myyKey = catalog.getSchema().find<
double>(
"slot_Shape_yy").key;
65 auto mxyKey = catalog.getSchema().find<
double>(
"slot_Shape_xy").key;
66 auto instFluxKey = catalog.getSchema().find<
double>(fluxField +
"_instFlux").key;
67 auto instFluxErrKey = catalog.getSchema().find<
double>(fluxField +
"_instFluxErr").key;
69 auto transform = _detector->getTransform(afw::cameraGeom::PIXELS, afw::cameraGeom::FOCAL_PLANE);
71 _wholeCatalog.
clear();
72 for (
auto const &record : catalog) {
73 auto ms = std::make_shared<MeasuredStar>();
74 ms->setId(record.getId());
75 ms->x = record.get(xKey);
76 ms->y = record.get(yKey);
77 ms->vx =
std::pow(record.get(xsKey), 2);
78 ms->vy =
std::pow(record.get(ysKey), 2);
79 auto pointFocal =
transform->applyForward(record.getCentroid());
80 ms->setXFocal(pointFocal.getX());
81 ms->setYFocal(pointFocal.getY());
85 double mxx = record.get(mxxKey);
86 double myy = record.get(myyKey);
87 double mxy = record.get(mxyKey);
88 ms->vxy = mxy * (ms->vx + ms->vy) / (mxx + myy);
89 if (
std::isnan(ms->vxy) || ms->vx < 0 || ms->vy < 0 || (ms->vxy * ms->vxy) > (ms->vx * ms->vy)) {
90 LOGLS_WARN(_log,
"Bad source detected during loadCatalog, "
91 <<
"detector=" << _ccdId <<
", visit=" << _visit
92 <<
" id: " << ms->getId() <<
" with vx,vy: " << ms->vx <<
"," << ms->vy
93 <<
" vxy^2: " << ms->vxy * ms->vxy <<
" vx*vy: " << ms->vx * ms->vy);
96 ms->setInstFluxAndErr(record.get(instFluxKey), record.get(instFluxErrKey));
101 auto flux = _photoCalib->instFluxToNanojansky(ms->getInstFlux(), ms->getInstFluxErr(), point);
102 ms->setFlux(flux.value);
103 ms->setFluxErr(flux.error);
104 auto mag = _photoCalib->instFluxToMagnitude(ms->getInstFlux(), ms->getInstFluxErr(), point);
105 ms->getMag() = mag.value;
106 ms->setMagErr(mag.error);
107 ms->setCcdImage(
this);
119 loadCatalog(catalog, fluxField);
123 _imageFrame =
Frame(lowerLeft, upperRight);
125 _readWcs = std::make_shared<AstrometryTransformSkyWcs>(
wcs);
128 out << visit <<
"_" << ccdId;
131 _boresightRaDec =
visitInfo->getBoresightRaDec();
132 _airMass =
visitInfo->getBoresightAirmass();
135 _hourAngle =
visitInfo->getBoresightHourAngle();
144 _sinEta = _cosEta = _tanZ = 0;
146 double cosz = 1. / _airMass;
147 double sinz =
std::sqrt(1 - cosz * cosz);
156 int measuredStars = 0;
158 for (
auto const &measuredStar : _catalogForFit) {
159 if (measuredStar->isValid()) {
162 if ((measuredStar->getFittedStar() !=
nullptr) &&
163 (measuredStar->getFittedStar()->getRefStar() !=
nullptr)) {
171 _commonTangentPoint = commonTangentPoint;
173 auto const crval = _readWcs->getSkyWcs()->getSkyOrigin();
181 _pixelToTangentPlane =
compose(raDecToTangentPlane, *_readWcs);
182 TanPixelToRaDec CommonTangentPlane2RaDec(identity, commonTangentPoint);
183 _commonTangentPlaneToTangentPlane =
compose(raDecToTangentPlane, CommonTangentPlane2RaDec);
186 TanRaDecToPixel raDecToCommonTangentPlane(identity, commonTangentPoint);
188 _tangentPlaneToCommonTangentPlane =
compose(raDecToCommonTangentPlane, TangentPlaneToRaDec);
192 _pixelToCommonTangentPlane =
compose(raDecToCommonTangentPlane, *_readWcs);
table::Key< int > detector
LSST DM logging module built on log4cxx.
#define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
#define LOG_GET(logger)
Returns a Log object associated with logger.
table::PointKey< double > crval
Implementation of the Photometric Calibration class.
table::Key< table::Array< std::uint8_t > > wcs
A class representing an angle.
constexpr double asRadians() const noexcept
Return an Angle's value in radians.
An integer coordinate rectangle.
A coordinate class intended to represent absolute positions.
void setCommonTangentPoint(Point const &commonTangentPoint)
Sets the common tangent point and computes necessary transforms.
std::pair< int, int > countStars() const
Count the number of valid measured and reference stars that fall within this ccdImage.
CcdImage(afw::table::SourceCatalog &record, const std::shared_ptr< lsst::afw::geom::SkyWcs > &wcs, const std::shared_ptr< lsst::afw::image::VisitInfo > &visitInfo, lsst::geom::Box2I const &bbox, std::string filter, std::shared_ptr< afw::image::PhotoCalib > photoCalib, std::shared_ptr< afw::cameraGeom::Detector > detector, int visit, int ccd, std::string const &fluxField)
rectangle with sides parallel to axes.
void setCcdImage(const CcdImage *_ccdImage)
The transformation that handles pixels to sideral transformations (Gnomonic, possibly with polynomial...
This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane)
std::unique_ptr< AstrometryTransform > compose(AstrometryTransform const &left, AstrometryTransform const &right)
Returns a pointer to a composition of transforms, representing left(right()).
std::ostream & operator<<(std::ostream &stream, AstrometryMapping const &mapping)
For hashing a ccdImage: the pair of (visit, ccd) IDs should be unique to each ccdImage.