WCSLIB  7.6
wcslib.h
Go to the documentation of this file.
1 /*============================================================================
2  WCSLIB 7.6 - an implementation of the FITS WCS standard.
3  Copyright (C) 1995-2021, Mark Calabretta
4 
5  This file is part of WCSLIB.
6 
7  WCSLIB is free software: you can redistribute it and/or modify it under the
8  terms of the GNU Lesser General Public License as published by the Free
9  Software Foundation, either version 3 of the License, or (at your option)
10  any later version.
11 
12  WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
13  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15  more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with WCSLIB. If not, see http://www.gnu.org/licenses.
19 
20  Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
21  http://www.atnf.csiro.au/people/Mark.Calabretta
22  $Id: wcslib.h,v 7.6 2021/04/13 12:57:01 mcalabre Exp $
23 *=============================================================================
24 *
25 * WCSLIB 7.6 - C routines that implement the FITS World Coordinate System
26 * (WCS) standard. Refer to the README file provided with WCSLIB for an
27 * overview of the library.
28 *
29 * Summary of wcslib.h
30 * -------------------
31 * This header file is provided purely for convenience. Use it to include all
32 * of the separate WCSLIB headers.
33 *
34 *===========================================================================*/
35 
36 #ifndef WCSLIB_WCSLIB
37 #define WCSLIB_WCSLIB
38 
39 #include "cel.h"
40 #include "dis.h"
41 #include "fitshdr.h"
42 #include "lin.h"
43 #include "log.h"
44 #include "prj.h"
45 #include "spc.h"
46 #include "sph.h"
47 #include "spx.h"
48 #include "tab.h"
49 #include "wcs.h"
50 #include "wcserr.h"
51 #include "wcsfix.h"
52 #include "wcshdr.h"
53 #include "wcsmath.h"
54 #include "wcsprintf.h"
55 #include "wcstrig.h"
56 #include "wcsunits.h"
57 #include "wcsutil.h"
58 #include "wtbarr.h"
59 
60 #endif // WCSLIB_WCSLIB
3580  wcserr_enable(1);
3581  wcsprintf_set(stderr);
3582 
3583  ...
3584 
3585  if (wcsset(&wcs) {
3586  wcsperr(&wcs);
3587  return wcs.err->status;
3588  }
3589 @endverbatim
3590 In this example, if an error was generated in one of the prjset() functions,
3591 wcsperr() would print an error traceback starting with wcsset(), then
3592 celset(), and finally the particular projection-setting function that
3593 generated the error. For each of them it would print the status return value,
3594 function name, source file, line number, and an error message which may be
3595 more specific and informative than the general error messages reported in the
3596 first example. For example, in response to a deliberately generated error,
3597 the @c twcs test program, which tests wcserr among other things, produces a
3598 traceback similar to this:
3599 @verbatim
3600 ERROR 5 in wcsset() at line 1564 of file wcs.c:
3601  Invalid parameter value.
3602 ERROR 2 in celset() at line 196 of file cel.c:
3603  Invalid projection parameters.
3604 ERROR 2 in bonset() at line 5727 of file prj.c:
3605  Invalid parameters for Bonne's projection.
3606 @endverbatim
3607 
3608 Each of the @ref structs "structs" in @ref overview "WCSLIB" includes a
3609 pointer, called @a err, to a wcserr struct. When an error occurs, a struct is
3610 allocated and error information stored in it. The wcserr pointers and the
3611 @ref memory "memory" allocated for them are managed by the routines that
3612 manage the various structs such as wcsinit() and wcsfree().
3613 
3614 wcserr messaging is an opt-in system enabled via wcserr_enable(), as in the
3615 example above. If enabled, when an error occurs it is the user's
3616 responsibility to free the memory allocated for the error message using
3617 wcsfree(), celfree(), prjfree(), etc. Failure to do so before the struct goes
3618 out of scope will result in memory leaks (if execution continues beyond the
3619 error).
3620 */
3621 
3622 
int celfree(struct celprm *cel)
Destructor for the celprm struct.
int celset(struct celprm *cel)
Setup routine for the celprm struct.
int prjfree(struct prjprm *prj)
Destructor for the prjprm struct.
int bonset(struct prjprm *prj)
Set up a prjprm struct for Bonne's (BON) projection.
int prjset(struct prjprm *prj)
Generic setup routine for the prjprm struct.
Error message handling.
Definition: wcserr.h:243
int wcsfree(struct wcsprm *wcs)
Destructor for the wcsprm struct.
int wcsperr(const struct wcsprm *wcs, const char *prefix)
Print error messages from a wcsprm struct.
int wcsinit(int alloc, int naxis, struct wcsprm *wcs, int npvmax, int npsmax, int ndpmax)
Default constructor for the wcsprm struct.
int wcsset(struct wcsprm *wcs)
Setup routine for the wcsprm struct.
int wcserr_enable(int enable)
Enable/disable error messaging.
int wcsprintf_set(FILE *wcsout)
Set output disposition for wcsprintf() and wcsfprintf().