int wcsfix(int ctrl, const int naxis[], struct wcsprm *wcs, int stat[]) { int status = 0; if ((stat[CDFIX] = cdfix(wcs)) > 0) { status = 1; } if ((stat[DATFIX] = datfix(wcs)) > 0) { status = 1; } if ((stat[UNITFIX] = unitfix(ctrl, wcs)) > 0) { status = 1; } if ((stat[SPCFIX] = spcfix(wcs)) > 0) { status = 1; } if ((stat[CELFIX] = celfix(wcs)) > 0) { status = 1; } if ((stat[CYLFIX] = cylfix(naxis, wcs)) > 0) { status = 1; } return status; }
int wcsfixi(int ctrl, const int naxis[], struct wcsprm *wcs, int stat[], struct wcserr info[]) { int ifix, status = 0; struct wcserr err; /* Handling the status values returned from the sub-fixers is trickier than it might seem, especially considering that wcs->err may contain an error status on input which should be preserved if no translation errors occur. The simplest way seems to be to save a copy of wcs->err and clear it before each sub-fixer. The last real error to occur, excluding informative messages, is the one returned. To get informative messages from spcfix() it must precede celfix() and cylfix(). The latter call wcsset() which also translates AIPS-convention spectral axes. */ wcserr_copy(wcs->err, &err); for (ifix = CDFIX; ifix < NWCSFIX; ifix++) { /* Clear (delete) wcs->err. */ wcserr_clear(&(wcs->err)); switch (ifix) { case CDFIX: stat[ifix] = cdfix(wcs); break; case DATFIX: stat[ifix] = datfix(wcs); break; case UNITFIX: stat[ifix] = unitfix(ctrl, wcs); break; case SPCFIX: stat[ifix] = spcfix(wcs); break; case CELFIX: stat[ifix] = celfix(wcs); break; case CYLFIX: stat[ifix] = cylfix(naxis, wcs); break; default: continue; } if (stat[ifix] == FIXERR_NO_CHANGE) { /* No change => no message. */ wcserr_copy(0x0, info+ifix); } else if (stat[ifix] == FIXERR_SUCCESS) { /* Successful translation, but there may be an informative message. */ if (wcs->err && wcs->err->status < 0) { wcserr_copy(wcs->err, info+ifix); } else { wcserr_copy(0x0, info+ifix); } } else { /* An informative message or error message. */ wcserr_copy(wcs->err, info+ifix); if ((status = (stat[ifix] > 0))) { /* It was an error, replace the previous one. */ wcserr_copy(wcs->err, &err); } } } /* Restore the last error to occur. */ if (err.status) { wcserr_copy(&err, wcs->err); } else { wcserr_clear(&(wcs->err)); } return status; }
int wcsfixi(int ctrl, const int naxis[], struct wcsprm *wcs, int stat[], struct wcserr info[]) { int status = 0; struct wcserr *err; err = info + CDFIX; if ((stat[CDFIX] = cdfix(wcs)) > 0) { wcserr_copy(wcs->err, err); status = 1; } else { wcserr_copy(0x0, err); } err = info + DATFIX; if ((stat[DATFIX] = datfix(wcs)) > 0) { wcserr_copy(wcs->err, err); status = 1; } else { wcserr_copy(0x0, err); } err = info + UNITFIX; if ((stat[UNITFIX] = unitfix(ctrl, wcs)) > 0) { wcserr_copy(wcs->err, err); status = 1; } else { wcserr_copy(0x0, err); } err = info + CELFIX; if ((stat[CELFIX] = celfix(wcs)) > 0) { wcserr_copy(wcs->err, err); status = 1; } else { wcserr_copy(0x0, err); } err = info + SPCFIX; if ((stat[SPCFIX] = spcfix(wcs)) > 0) { wcserr_copy(wcs->err, err); status = 1; } else { wcserr_copy(0x0, err); } err = info + CYLFIX; wcserr_copy(0x0, err); if (naxis) { if ((stat[CYLFIX] = cylfix(naxis, wcs)) > 0) { err = info + CYLFIX; wcserr_copy(wcs->err, err); status = 1; } } else { stat[CYLFIX] = -2; } if (wcs->err) free(wcs->err); wcs->err = 0x0; return status; }