53 out <<
"(visit: " << key.
visit <<
", ccd: " << 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);
108 _wholeCatalog.setCcdImage(
this);
116 : _ccdId(ccdId), _visit(visit), _photoCalib(photoCalib), _detector(detector), _filter(filter) {
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();
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);
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);
#define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
The transformation that handles pixels to sideral transformations (Gnomonic, possibly with polynomial...
table::Key< lsst::geom::Angle > latitude
CameraSysPrefix const PIXELS
Pixel coordinates: Nominal position on the entry surface of a given detector (x, y unbinned pixels)...
For hashing a ccdImage: the pair of (visit, ccd) IDs should be unique to each ccdImage.
table::PointKey< double > crval
table::Key< table::Array< std::uint8_t > > wcs
std::ostream & operator<<(std::ostream &os, CameraSysPrefix const &detSysPrefix)
LSST DM logging module built on log4cxx.
rectangle with sides parallel to axes.
A base class for image defects.
int getMaxY() const noexcept
std::unique_ptr< AstrometryTransform > compose(AstrometryTransform const &left, AstrometryTransform const &right)
Returns a pointer to a composition of transforms, representing left(right()).
Angle getLatitude() const noexcept
The latitude of this point.
This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane) ...
table::Key< int > detector
int getMaxX() const noexcept
int getMinX() const noexcept
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
#define LOG_GET(logger)
Returns a Log object associated with logger.
An integer coordinate rectangle.
CameraSys const FOCAL_PLANE
Focal plane coordinates: Position on a 2-d planar approximation to the focal plane (x...
Implementation of the Photometric Calibration class.
int getMinY() const noexcept
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.