101static void wcsCheckHeaders(
const wcsprm *wcs,
const char *headers_str,
int number_of_records) {
106 if (wcs->lin.dispre) {
107 bool sip_used =
false, sip_specified =
false;
108 for (
int i = 0; i < wcs->naxis; ++i) {
109 sip_used |= (
strncmp(wcs->lin.dispre->dtype[i],
"SIP", 3) == 0);
110 size_t ctype_len =
strlen(wcs->ctype[i]);
111 sip_specified |= (
strncmp(wcs->ctype[i] + ctype_len - 4,
"-SIP", 4) == 0);
113 if (sip_used && !sip_specified) {
114 logger.warn() <<
"SIP coefficients present, but CTYPE has not the '-SIP' suffix";
115 logger.warn() <<
"SIP distortion will be applied, but this may not be desired";
116 logger.warn() <<
"To suppress this warning, explicitly add the '-SIP' suffix to the CTYPE,";
117 logger.warn() <<
"or remove the SIP distortion coefficients";
167 int number_of_records;
170 if (wcshdo(WCSHDO_none, original.
m_wcs.
get(), &number_of_records, &raw_header) != 0) {
171 throw Elements::Exception() <<
"Failed to get the FITS headers for the WCS coordinate system when copying WCS";
174 init(raw_header, number_of_records);
183 int nreject = 0, nwcs = 0, nreject_strict = 0;
187 wcsprintf_set(
nullptr);
191 int ret = wcspih(headers, number_of_records, WCSHDR_strict, 2, &nreject_strict, &nwcs, &wcs);
196 ret = wcspih(headers, number_of_records, WCSHDR_all, 0, &nreject, &nwcs, &wcs);
203 m_wcs =
decltype(
m_wcs)(wcs, [nwcs](wcsprm* ptr) {
204 int nwcs_copy = nwcs;
206 wcsvfree(&nwcs_copy, &ptr);
210 wcslib_version(wcsver);
211 if (wcsver[0] < 5 || (wcsver[0] == 5 && wcsver[1] < 18)) {
212 logger.info() <<
"wcslib " << wcsver[0] <<
"." << wcsver[1]
213 <<
" is not fully thread safe, using wrapped lincpy call!";
229 double pc_array[2] {image_coordinate.
m_x + 1, image_coordinate.
m_y + 1};
231 double ic_array[2] {0, 0};
232 double wc_array[2] {0, 0};
236 int ret_val = wcsp2s(&wcs_copy, 1, 1, pc_array, ic_array, &phi, &theta, wc_array, &status);
249 double pc_array[2] {0, 0};
250 double ic_array[2] {0, 0};
251 double wc_array[2] {world_coordinate.
m_alpha, world_coordinate.
m_delta};
255 int ret_val = wcss2p(&wcs_copy, 1, 1, wc_array, &phi, &theta, ic_array, pc_array, &status);
256 if (ret_val != WCSERR_SUCCESS) {
257 logger.warn() <<
"Bad worldToImage from RA/Dec: " << wc_array[0] <<
"/" << wc_array[1];