3#include "lsst/meas/extensions/psfex/Field.hh"
14Field::Field(std::string
const& ident) :
15 impl(NULL), _isInitialized(false)
17 QCALLOC(impl, fieldstruct, 1);
21 impl->rcatname = impl->catname;
23 strncpy(impl->rtcatname, impl->rcatname,
sizeof(impl->rtcatname) - 1);
24 strncpy(impl->ident,
"??",
sizeof(impl->ident) - 1);
26 if (!(impl->rcatname =
strrchr(impl->catname,
'/'))) {
27 impl->rcatname = impl->catname;
32 strncpy(impl->rtcatname, impl->rcatname,
sizeof(impl->rtcatname) - 1);
34 char *pstr=
strrchr(impl->rtcatname,
'.');
40 strncpy(impl->ident,
"??",
sizeof(impl->ident) - 1);
52 for (
int i = 0; i != impl->next; ++i) {
63Field::_finalize(
bool force)
65 if (force || !_isInitialized) {
66 field_init_finalize(impl);
67 _isInitialized =
true;
77 _psfs.reserve(impl->next);
78 for (
int i = 0; i != impl->next; ++i) {
79 _psfs.push_back(Psf(impl->psf[i]));
88 int const naxis1,
int const naxis2,
91 QREALLOC(impl->psf, psfstruct *, impl->next + 1);
92 impl->psf[impl->next] = 0;
93 QREALLOC(impl->wcs, wcsstruct *, impl->next + 1);
94 impl->wcs[impl->next] = 0;
98 QMALLOC(impl->wcs[impl->next], wcsstruct, 1);
99 wcsstruct *wcs = impl->wcs[impl->next];
102 wcs->naxisn[0] = naxis1;
103 wcs->naxisn[1] = naxis2;
113 }
catch (pex::exceptions::RuntimeError &) {
116 for (
int i = 0; i != wcs->naxis; ++i) {
118 auto ctype = metadata->getAsString(
"CTYPE" +
std::to_string(ifits));
119 strncpy(wcs->ctype[i], ctype.c_str(), ctype.size() + 1);
120 strncpy(wcs->cunit[i], cunit.c_str(), cunit.size() + 1);
121 wcs->crpix[i] = crpix[i];
122 wcs->crval[i] = crval[i].asDegrees();
127 for (
int i = 0, k = 0; i < 2; ++i) {
128 for (
int j = 0; j < 2; ++j, ++k) {
129 wcs->cd[k] = cdMatrix(i, j);
136 auto center = wcs_.
pixelToSky(geom::Point2D(0.5*naxis1, 0.5*naxis2));
138 wcs->wcsscalepos[1] = center.getLatitude().asDegrees();
140 double maxradius = 0.0;
141 for (
int x = 0; x <= 1; ++x) {
142 for (
int y = 0; y <= 1; ++y) {
143 geom::Point2D point(x*naxis1, y*naxis2);
144 double const radius = center.separation(wcs_.
pixelToSky(point)).asDegrees();
145 if (radius > maxradius) {
150 wcs->wcsmaxradius = maxradius;
Eigen::Matrix2d getCdMatrix(lsst::geom::Point2D const &pixel) const
lsst::geom::SpherePoint pixelToSky(lsst::geom::Point2D const &pixel) const
std::shared_ptr< SkyWcs > getTanWcs(lsst::geom::Point2D const &pixel) const
lsst::geom::SpherePoint getSkyOrigin() const
lsst::geom::Point2D getPixelOrigin() const
std::shared_ptr< daf::base::PropertyList > getFitsMetadata(bool precise=false, lsst::geom::Box2I const &bbox=lsst::geom::Box2I(lsst::geom::Point2I(0, 0), lsst::geom::Extent2I(100, 100))) const
constexpr double asDegrees() const noexcept
Angle getLongitude() const noexcept