53 out <<
"(visit: " << key.
visit <<
", detector: " << key.
ccd <<
")";
58 auto xKey = catalog.getSchema().find<
double>(
"slot_Centroid_x").key;
59 auto yKey = catalog.getSchema().find<
double>(
"slot_Centroid_y").key;
60 auto xsKey = catalog.getSchema().find<
float>(
"slot_Centroid_xErr").key;
61 auto ysKey = catalog.getSchema().find<
float>(
"slot_Centroid_yErr").key;
62 auto mxxKey = catalog.getSchema().find<
double>(
"slot_Shape_xx").key;
63 auto myyKey = catalog.getSchema().find<
double>(
"slot_Shape_yy").key;
64 auto mxyKey = catalog.getSchema().find<
double>(
"slot_Shape_xy").key;
65 auto instFluxKey = catalog.getSchema().find<
double>(fluxField +
"_instFlux").key;
66 auto instFluxErrKey = catalog.getSchema().find<
double>(fluxField +
"_instFluxErr").key;
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));
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);
117 loadCatalog(catalog, fluxField);
121 _imageFrame =
Frame(lowerLeft, upperRight);
123 _readWcs = std::make_shared<AstrometryTransformSkyWcs>(
wcs);
126 out <<
visit <<
"_" << ccdId;
129 _boresightRaDec =
visitInfo->getBoresightRaDec();
130 _airMass =
visitInfo->getBoresightAirmass();
133 _hourAngle =
visitInfo->getBoresightHourAngle();
142 _sinEta = _cosEta = _tanZ = 0;
144 double cosz = 1. / _airMass;
145 double sinz =
std::sqrt(1 - cosz * cosz);
154 int measuredStars = 0;
156 for (
auto const &measuredStar : _catalogForFit) {
157 if (measuredStar->isValid()) {
160 if ((measuredStar->getFittedStar() !=
nullptr) &&
161 (measuredStar->getFittedStar()->getRefStar() !=
nullptr)) {
169 _commonTangentPoint = commonTangentPoint;
171 auto const crval = _readWcs->getSkyWcs()->getSkyOrigin();
179 _pixelToTangentPlane =
compose(raDecToTangentPlane, *_readWcs);
180 TanPixelToRaDec CommonTangentPlane2RaDec(identity, commonTangentPoint);
181 _commonTangentPlaneToTangentPlane =
compose(raDecToTangentPlane, CommonTangentPlane2RaDec);
184 TanRaDecToPixel raDecToCommonTangentPlane(identity, commonTangentPoint);
186 _tangentPlaneToCommonTangentPlane =
compose(raDecToCommonTangentPlane, TangentPlaneToRaDec);
190 _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.
void setCommonTangentPoint(Point const &commonTangentPoint)
Sets the common tangent point and computes necessary transforms.
CcdImage(afw::table::SourceCatalog &record, 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, std::string const &fluxField)
std::pair< int, int > countStars() const
Count the number of valid measured and reference stars that fall within this ccdImage.
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)
CameraSys const FOCAL_PLANE
Focal plane coordinates: Position on a 2-d planar approximation to the focal plane (x,...
CameraSysPrefix const PIXELS
Pixel coordinates: Nominal position on the entry surface of a given detector (x, y unbinned pixels).
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
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)
A base class for image defects.
For hashing a ccdImage: the pair of (visit, ccd) IDs should be unique to each ccdImage.