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();
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);