3 #include "lsst/meas/extensions/psfex/Field.hh" 4 #include "wcslib/wcs.h" 12 namespace lsst {
namespace meas {
namespace extensions {
namespace psfex {
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) {
63 Field::_finalize(
bool force)
65 if (force || !_isInitialized) {
66 field_init_finalize(impl);
67 _isInitialized =
true;
74 Field::getPsfs()
const 78 for (
int i = 0; i != impl->next; ++i) {
79 _psfs.push_back(
Psf(impl->psf[i]));
93 const struct wcsprm* getWcsInfo() {
return _wcsInfo; }
99 int const naxis1,
int const naxis2,
102 QREALLOC(impl->psf, psfstruct *, impl->next + 1);
103 impl->psf[impl->next] = 0;
104 QREALLOC(impl->wcs, wcsstruct *, impl->next + 1);
105 impl->wcs[impl->next] = 0;
109 PsfUnpack wcsUnpacked(wcs_);
110 struct wcsprm const* wcsPrm = wcsUnpacked.getWcsInfo();
111 QMALLOC(impl->wcs[impl->next], wcsstruct, 1);
112 wcsstruct *
wcs = impl->wcs[impl->next];
114 wcs->naxis = wcsPrm->naxis;
115 wcs->naxisn[0] = naxis1;
116 wcs->naxisn[1] = naxis2;
118 for (
int i = 0; i != wcs->naxis; ++i) {
119 strncpy(wcs->ctype[i], wcsPrm->ctype[i],
sizeof(wcs->ctype[i]) - 1);
120 strncpy(wcs->cunit[i], wcsPrm->cunit[i],
sizeof(wcs->cunit[i]) - 1);
121 wcs->crval[i] = wcsPrm->crval[i];
123 wcs->cdelt[i] = wcsPrm->cdelt[i];
124 wcs->crpix[i] = wcsPrm->crpix[i];
125 wcs->crder[i] = wcsPrm->crder[i];
126 wcs->csyer[i] = wcsPrm->csyer[i];
127 wcs->crval[i] = wcsPrm->crval[i];
129 for (
int i = 0; i != wcs->naxis*wcs->naxis; ++i) {
130 wcs->cd[i] = wcsPrm->cd[i];
132 wcs->longpole = wcsPrm->lonpole;
133 wcs->latpole = wcsPrm->latpole;
134 wcs->lat = wcsPrm->lat;
135 wcs->lng = wcsPrm->lng;
136 wcs->equinox = wcsPrm->equinox;
139 wcs->wcsscalepos[0] = center->getLongitude().asDegrees();
140 wcs->wcsscalepos[1] = center->getLatitude().asDegrees();
142 double maxradius = 0.0;
143 for (
int x = 0;
x <= 1; ++
x) {
144 for (
int y = 0; y <= 1; ++y) {
146 double const radius = center->angularSeparation(*wcs_.
pixelToSky(point)).asDegrees();
147 if (radius > maxradius) {
152 wcs->wcsmaxradius = maxradius;
std::shared_ptr< coord::Coord > pixelToSky(double pix1, double pix2) const
Point< double, 2 > Point2D