24 LOG_LOGGER _log =
LOG_GET(
"jointcal.CcdImage");
30 void CcdImage::loadCatalog(afw::table::SourceCatalog
const &catalog,
std::string const &fluxField) {
31 auto xKey = catalog.getSchema().find<
double>(
"slot_Centroid_x").key;
32 auto yKey = catalog.getSchema().find<
double>(
"slot_Centroid_y").key;
33 auto xsKey = catalog.getSchema().find<
float>(
"slot_Centroid_xSigma").key;
34 auto ysKey = catalog.getSchema().find<
float>(
"slot_Centroid_ySigma").key;
35 auto mxxKey = catalog.getSchema().find<
double>(
"slot_Shape_xx").key;
36 auto myyKey = catalog.getSchema().find<
double>(
"slot_Shape_yy").key;
37 auto mxyKey = catalog.getSchema().find<
double>(
"slot_Shape_xy").key;
38 auto fluxKey = catalog.getSchema().find<
double>(fluxField +
"_flux").key;
39 auto fluxErrKey = catalog.getSchema().find<
double>(fluxField +
"_fluxSigma").key;
41 auto transform = _detector->getTransform(afw::cameraGeom::PIXELS, afw::cameraGeom::FOCAL_PLANE);
43 _wholeCatalog.clear();
44 for (
auto const &record : catalog) {
45 auto ms = std::make_shared<MeasuredStar>();
46 ms->x = record.get(xKey);
47 ms->y = record.get(yKey);
48 ms->vx =
std::pow(record.get(xsKey), 2);
49 ms->vy =
std::pow(record.get(ysKey), 2);
50 auto pointFocal = transform->applyForward(record.getCentroid());
51 ms->setXFocal(pointFocal.getX());
52 ms->setYFocal(pointFocal.getY());
56 double mxx = record.get(mxxKey);
57 double myy = record.get(myyKey);
58 double mxy = record.get(mxyKey);
59 ms->vxy = mxy * (ms->vx + ms->vy) / (mxx + myy);
60 if (ms->vx < 0 || ms->vy < 0 || (ms->vxy * ms->vxy) > (ms->vx * ms->vy)) {
61 LOGLS_WARN(_log,
"Bad source detected in loadCatalog : " << ms->vx <<
" " << ms->vy <<
" " 62 << ms->vxy * ms->vxy <<
" " 66 ms->setId(record.getId());
67 ms->setInstFlux(record.get(fluxKey));
68 ms->setInstFluxErr(record.get(fluxErrKey));
71 afw::geom::Point<double, 2> point(ms->x, ms->y);
72 auto flux = _photoCalib->instFluxToMaggies(ms->getInstFlux(), ms->getInstFluxErr(), point);
73 ms->setFlux(flux.value);
74 ms->setFluxErr(flux.err);
75 ms->mag = _photoCalib->instFluxToMagnitude(ms->getInstFlux(), point);
76 ms->setCcdImage(
this);
79 _wholeCatalog.setCcdImage(
this);
87 : _ccdId(ccdId), _visit(visit), _photoCalib(photoCalib), _detector(detector), _filter(filter) {
88 loadCatalog(catalog, fluxField);
92 _imageFrame =
Frame(lowerLeft, upperRight);
95 _inverseReadWcs = _readWcs->inverseTransfo(0.01, _imageFrame);
98 out << visit <<
"_" << ccdId;
101 _boresightRaDec = visitInfo->getBoresightRaDec();
102 _airMass = visitInfo->getBoresightAirmass();
104 double latitude = visitInfo->getObservatory().getLatitude();
105 _lstObs = visitInfo->getEra();
106 _hourAngle = visitInfo->getBoresightHourAngle();
115 _sineta = _coseta = _tgz = 0;
117 double cosz = 1. / _airMass;
118 double sinz =
sqrt(1 - cosz * cosz);
123 double yEta =
sin(_hourAngle);
124 double xEta =
cos(dec) *
tan(latitude) -
sin(dec) *
cos(_hourAngle);
125 double eta =
atan2(yEta, xEta);
132 _commonTangentPoint = commonTangentPoint;
#define LOGLS_WARN(logger, message)
Implements the (forward) SIP distorsion scheme.
implements the linear transformations (6 real coefficients).
std::unique_ptr< Gtransfo > gtransfoCompose(const Gtransfo *left, const Gtransfo *right)
Returns a pointer to a composition.
the transformation that handles pix to sideral transfos (Gnomonic, possibly with polynomial distortio...
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) ...
Point getTangentPoint() const
The tangent point (in degrees)
TanSipPix2RaDec convertTanWcs(const std::shared_ptr< lsst::afw::image::TanWcs > wcs)
Transform an afw TanWcs into a Gtransfo.
void setCommonTangentPoint(Point const &commonTangentPoint)
Sets the common tangent point and computes necessary transforms.