24 LOG_LOGGER _log =
LOG_GET(
"jointcal.CcdImage");
31 out <<
"(visit: " << key.first <<
", ccd: " << key.second <<
")";
36 auto xKey = catalog.
getSchema().
find<
double>(
"slot_Centroid_x").key;
37 auto yKey = catalog.
getSchema().
find<
double>(
"slot_Centroid_y").key;
38 auto xsKey = catalog.
getSchema().
find<
float>(
"slot_Centroid_xSigma").key;
39 auto ysKey = catalog.
getSchema().
find<
float>(
"slot_Centroid_ySigma").key;
40 auto mxxKey = catalog.
getSchema().
find<
double>(
"slot_Shape_xx").key;
41 auto myyKey = catalog.
getSchema().
find<
double>(
"slot_Shape_yy").key;
42 auto mxyKey = catalog.
getSchema().
find<
double>(
"slot_Shape_xy").key;
43 auto fluxKey = catalog.
getSchema().
find<
double>(fluxField +
"_flux").key;
44 auto fluxErrKey = catalog.
getSchema().
find<
double>(fluxField +
"_fluxSigma").key;
46 auto transform = _detector->getTransform(afw::cameraGeom::PIXELS, afw::cameraGeom::FOCAL_PLANE);
48 _wholeCatalog.clear();
49 for (
auto const &record : catalog) {
50 auto ms = std::make_shared<MeasuredStar>();
51 ms->x = record.get(xKey);
52 ms->y = record.get(yKey);
53 ms->vx =
std::pow(record.get(xsKey), 2);
54 ms->vy =
std::pow(record.get(ysKey), 2);
55 auto pointFocal = transform->applyForward(record.getCentroid());
56 ms->setXFocal(pointFocal.getX());
57 ms->setYFocal(pointFocal.getY());
61 double mxx = record.get(mxxKey);
62 double myy = record.get(myyKey);
63 double mxy = record.get(mxyKey);
64 ms->vxy = mxy * (ms->vx + ms->vy) / (mxx + myy);
65 if (ms->vx < 0 || ms->vy < 0 || (ms->vxy * ms->vxy) > (ms->vx * ms->vy)) {
66 LOGLS_WARN(_log,
"Bad source detected in loadCatalog : " << ms->vx <<
" " << ms->vy <<
" " 67 << ms->vxy * ms->vxy <<
" " 71 ms->setId(record.getId());
72 ms->setInstFlux(record.get(fluxKey));
73 ms->setInstFluxErr(record.get(fluxErrKey));
77 auto flux = _photoCalib->instFluxToMaggies(ms->getInstFlux(), ms->getInstFluxErr(), point);
78 ms->setFlux(flux.value);
79 ms->setFluxErr(flux.err);
80 ms->mag = _photoCalib->instFluxToMagnitude(ms->getInstFlux(), point);
81 ms->setCcdImage(
this);
84 _wholeCatalog.setCcdImage(
this);
92 : _ccdId(ccdId), _visit(visit), _photoCalib(photoCalib), _detector(detector), _filter(filter) {
93 loadCatalog(catalog, fluxField);
97 _imageFrame =
Frame(lowerLeft, upperRight);
99 _readWcs = std::make_shared<GtransfoSkyWcs>(wcs);
102 out << visit <<
"_" << ccdId;
105 _boresightRaDec = visitInfo->getBoresightRaDec();
106 _airMass = visitInfo->getBoresightAirmass();
108 double latitude = visitInfo->getObservatory().getLatitude();
109 _lstObs = visitInfo->getEra();
110 _hourAngle = visitInfo->getBoresightHourAngle();
119 _sineta = _coseta = _tgz = 0;
121 double cosz = 1. / _airMass;
122 double sinz =
sqrt(1 - cosz * cosz);
127 double yEta =
sin(_hourAngle);
128 double xEta =
cos(dec) *
tan(latitude) -
sin(dec) *
cos(_hourAngle);
129 double eta =
atan2(yEta, xEta);
136 _commonTangentPoint = commonTangentPoint;
140 auto const crval = _readWcs->getSkyWcs()->getSkyOrigin();
141 Point tangentPoint(crval[0].asDegrees(), crval[1].asDegrees());
156 _sky2TP.reset(
new TanRaDec2Pix(identity, tangentPoint));
implements the linear transformations (6 real coefficients).
std::unique_ptr< Gtransfo > gtransfoCompose(const Gtransfo *left, const Gtransfo *right)
Returns a pointer to a composition.
std::ostream & operator<<(std::ostream &out, CcdImageKey const &key)
the transformation that handles pix to sideral transfos (Gnomonic, possibly with polynomial distortio...
SchemaItem< T > find(std::string const &name) const
table::Key< geom::Angle > latitude
lsst::afw::geom::Angle getLatitude() const
rectangle with sides parallel to axes.
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)