summaryrefslogtreecommitdiffstats
path: root/ast/dssmap.h
blob: b7550de36166c17e048a9a0044e42a3998f6818d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#if !defined( DSSMAP_INCLUDED ) /* Include this file only once */
#define DSSMAP_INCLUDED
/*
*+
*  Name:
*     dssmap.h

*  Type:
*     C include file.

*  Purpose:
*     Define the interface to the DssMap class.

*  Invocation:
*     #include "dssmap.h"

*  Description:
*     This include file defines the interface to the DssMap class and
*     provides the type definitions, function prototypes and macros,
*     etc.  needed to use this class.
*
*     The DssMap class implements Mappings which use a Digitised Sky
*     Survey plate fit to transform between pixel coordinates and
*     Equatorial coordinates.

*  Inheritance:
*     The DssMap class inherits from the Mapping class.

*  Attributes Over-Ridden:
*     None.

*  New Attributes Defined:
*     None.

*  Methods Over-Ridden:
*     Public:
*        None.
*
*     Protected:
*        astTransform
*           Apply a DssMap to transform a set of points.

*  New Methods Defined:
*     Public:
*        astDssFits
*           Create a FitsChan holding a FITS description of the DSS plate fit.
*
*     Protected:
*        None.

*  Other Class Functions:
*     Public:
*        astIsADssMap
*           Test class membership.
*        astDssMap
*           Create a DssMap.
*
*     Protected:
*        astCheckDssMap
*           Validate class membership.
*        astInitDssMap
*           Initialise a DssMap.
*        astInitDssMapVtab
*           Initialise the virtual function table for the DssMap class.
*        astLoadDssMap
*           Load a DssMap.

*  Macros:
*     None.

*  Type Definitions:
*     Public:
*        AstDssMap
*           DssMap object type.
*
*     Protected:
*        AstDssMapVtab
*           DssMap virtual function table type.

*  Feature Test Macros:
*     astCLASS
*        If the astCLASS macro is undefined, only public symbols are
*        made available, otherwise protected symbols (for use in other
*        class implementations) are defined. This macro also affects
*        the reporting of error context information, which is only
*        provided for external calls to the AST library.

*  Copyright:
*     Copyright (C) 1997-2006 Council for the Central Laboratory of the
*     Research Councils

*  Licence:
*     This program is free software: you can redistribute it and/or
*     modify it under the terms of the GNU Lesser General Public
*     License as published by the Free Software Foundation, either
*     version 3 of the License, or (at your option) any later
*     version.
*     
*     This program is distributed in the hope that it will be useful,
*     but WITHOUT ANY WARRANTY; without even the implied warranty of
*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*     GNU Lesser General Public License for more details.
*     
*     You should have received a copy of the GNU Lesser General
*     License along with this program.  If not, see
*     <http://www.gnu.org/licenses/>.
*     (except for code supplied by Doug Mink, as noted in this file)

*  Authors:
*     DSB: D.S. Berry (Starlink)

*  History:
*     18-FEB-1997 (DSB):
*        Original version.
*     30-JUN-1997 (DSB):
*        All public functions made protected.
*     4-NOV-1997 (DSB):
*        Removed copy of supplied FitsChan from DssMap structure.
*     8-JAN-2003 (DSB):
*        Added protected astInitDssMapVtab method.
*     21-OCT-2004 (DSB):
*        Removed wcstools prototypes which clash with the MS Windows
*        runtime library.
*-
*/

/* Include files. */
/* ============== */
/* Interface definitions. */
/* ---------------------- */

#if defined(astCLASS)            /* Protected */

/* The code within this #if...#endif block is covered by the following
   statement of terms and conditions, which differ from the terms and
   conditions which apply elsewhere in this file.

***************************************************************************
*
* Copyright:   1988 Smithsonian Astrophysical Observatory
*              You may do anything you like with these files except remove
*              this copyright.  The Smithsonian Astrophysical Observatory
*              makes no representations about the suitability of this
*              software for any purpose.  It is provided "as is" without
*              express or implied warranty.
*
*****************************************************************************
*/

/* >>>>>>>>>>>>>>>>>> SAOimage wcs.h header file <<<<<<<<<<<<<<<<<< */

/* libwcs/wcs.h
   November 1, 1996
   By Doug Mink, Harvard-Smithsonian Center for Astrophysics */

struct WorldCoor {
  double	xref;		/* x reference coordinate value (deg) */
  double	yref;		/* y reference coordinate value (deg) */
  double	xrefpix;	/* x reference pixel */
  double	yrefpix;	/* y reference pixel */
  double	xinc;		/* x coordinate increment (deg) */
  double	yinc;		/* y coordinate increment (deg) */
  double	rot;		/* rotation (deg)  (from N through E) */
  double	crot,srot;	/* Cosine and sine of rotation angle */
  double	cd11,cd12,cd21,cd22;
				/* rotation matrix */
  double	dc11,dc12,dc21,dc22;
				/* inverse rotation matrix */
  double	equinox;	/* Equinox of coordinates default to 1950.0 */
  double	epoch;		/* Epoch of coordinates default to equinox */
  double	nxpix;		/* Number of pixels in X-dimension of image */
  double	nypix;		/* Number of pixels in Y-dimension of image */
  double	plate_ra;	/* Right ascension of plate center */
  double	plate_dec;	/* Declination of plate center */
  double	plate_scale;	/* Plate scale in arcsec/mm */
  double	x_pixel_offset;	/* X pixel offset of image lower right */
  double	y_pixel_offset;	/* Y pixel offset of image lower right */
  double	x_pixel_size;	/* X pixel_size */
  double	y_pixel_size;	/* Y pixel_size */
  double	ppo_coeff[6];
  double	amd_x_coeff[20]; /* X coefficients for plate model */
  double	amd_y_coeff[20]; /* Y coefficients for plate model */
  double	xpix;		/* x (RA) coordinate (pixels) */
  double	ypix;		/* y (dec) coordinate (pixels) */
  double	xpos;		/* x (RA) coordinate (deg) */
  double	ypos;		/* y (dec) coordinate (deg) */
  int		pcode;		/* projection code (1-8) */
  int		changesys;	/* 1 for FK4->FK5, 2 for FK5->FK4 */
  				/* 3 for FK4->galactic, 4 for FK5->galactic */
  int		printsys;	/* 1 to print coordinate system, else 0 */
  int		ndec;		/* Number of decimal places in PIX2WCST */
  int		degout;		/* 1 to always print degrees in PIX2WCST */
  int		tabsys;		/* 1 to put tab between RA & Dec, else 0 */
  int		rotmat;		/* 0 if CDELT, CROTA; 1 if CD */
  int		coorflip;	/* 0 if x=RA, y=Dec; 1 if x=Dec, y=RA */
  int		offscl;		/* 0 if OK, 1 if offscale */
  int		plate_fit;	/* 1 if plate fit, else 0 */
  int		wcson;		 /* 1 if WCS is set, else 0 */
  char		c1type[8];	/*  1st coordinate type code:
					RA--, GLON, ELON */
  char		c2type[8];	/*  2nd coordinate type code:
					DEC-, GLAT, ELAT */
  char		ptype[8];	/*  projection type code:
				    -SIN, -TAN, -ARC, -NCP, -GLS, -MER, -AIT */
  char		radecsys[16];	/* Reference frame: FK4, FK4-NO-E, FK5, GAPPT*/
  char		sysout[16];	/* Reference frame for output: FK4, FK5 */
  char		center[32];	/* Center coordinates (with frame) */
  char		search_format[120];	/* search command format */
				/* where %s is replaced by WCS coordinates */
};

#ifndef PI
#define PI		3.141592653589793
#endif

/* Conversions among hours of RA, degrees and radians. */
#define degrad(x)	((x)*PI/180.)
#define raddeg(x)	((x)*180./PI)
#define hrdeg(x)	((x)*15.)
#define deghr(x)	((x)/15.)
#define hrrad(x)	degrad(hrdeg(x))
#define radhr(x)	deghr(raddeg(x))


/* WCS subroutines in wcs.c */

/* >>>>> DSB: Prototypes for "subroutines in wcs.c" have been removed since
   they clash with prototypes defined by the MS windows runtime library and
   are not needed by AST. */

/* Oct 26 1994	New file
 * Dec 21 1994	Add rotation matrix
 * Dec 22 1994	Add flag for coordinate reversal

 * Mar  6 1995	Add parameters for Digital Sky Survey plate fit
 * Jun  8 1995	Add parameters for coordinate system change
 * Jun 21 1995	Add parameter for plate scale
 * Jul  6 1995	Add parameter to note whether WCS is set
 * Aug  8 1995	Add parameter to note whether to print coordinate system
 * Oct 16 1995	Add parameters to save image dimensions and center coordinates

 * Feb 15 1996	Add coordinate conversion functions
 * Feb 20 1996	Add flag for tab tables
 * Apr 26 1996	Add epoch of positions (actual date of image)
 * Jul  5 1996	Add subroutine declarations
 * Jul 19 1996	Add WCSFULL declaration
 * Aug  5 1996	Add WCSNINIT to initialize WCS for non-terminated header
 * Oct 31 1996	Add DCnn inverse rotation matrix
 * Nov  1 1996	Add NDEC number of decimal places in output
 */
/* >>>>>>>>>>>>>>>>>>>> End of SAOimage wcs.h header file <<<<<<<<<<<<<<<< */
#endif

#include "mapping.h"             /* Coordinate mappings (parent class) */
#include "fitschan.h"            /* Storage for FITS header cards */

/* C header files. */
/* --------------- */
#if defined(astCLASS)            /* Protected */
#include <stddef.h>
#endif

/* Type Definitions. */
/* ================= */
/* DssMap structure. */
/* ------------------ */
/* This structure contains all information that is unique to each object in
   the class (e.g. its instance variables). */
typedef struct AstDssMap {

/* Attributes inherited from the parent class. */
   AstMapping mapping;           /* Parent class structure */

/* Attributes specific to objects in this class. */
   void *wcs;                    /* Pointer to structure holding plate fit info */

} AstDssMap;

/* Virtual function table. */
/* ----------------------- */
/* This table contains all information that is the same for all
   objects in the class (e.g. pointers to its virtual functions). */
#if defined(astCLASS)            /* Protected */
typedef struct AstDssMapVtab {

/* Properties (e.g. methods) inherited from the parent class. */
   AstMappingVtab mapping_vtab;  /* Parent class virtual function table */

/* A Unique identifier to determine class membership. */
   AstClassIdentifier id;

/* Properties (e.g. methods) specific to this class. */
   AstFitsChan *(* DssFits)( AstDssMap *, int * );

} AstDssMapVtab;

#if defined(THREAD_SAFE)

/* Define a structure holding all data items that are global within the
   object.c file. */

typedef struct AstDssMapGlobals {
   AstDssMapVtab Class_Vtab;
   int Class_Init;
} AstDssMapGlobals;


/* Thread-safe initialiser for all global data used by this module. */
void astInitDssMapGlobals_( AstDssMapGlobals * );

#endif


#endif

/* Function prototypes. */
/* ==================== */
/* Prototypes for standard class functions. */
/* ---------------------------------------- */
astPROTO_CHECK(DssMap)          /* Check class membership */
astPROTO_ISA(DssMap)            /* Test class membership */

/* Constructor. */
#if defined(astCLASS)            /* Protected. */
AstDssMap *astDssMap_( void *, const char *, int *, ...);
#endif

#if defined(astCLASS)            /* Protected */

/* Initialiser. */
AstDssMap *astInitDssMap_( void *, size_t, int, AstDssMapVtab *,
                             const char *, AstFitsChan *, int * );

/* Vtab initialiser. */
void astInitDssMapVtab_( AstDssMapVtab *, const char *, int * );

/* Loader. */
AstDssMap *astLoadDssMap_( void *, size_t, AstDssMapVtab *,
                             const char *, AstChannel *, int * );
#endif

/* Prototypes for member functions. */
/* -------------------------------- */
# if defined(astCLASS)           /* Protected */
AstFitsChan *astDssFits_( AstDssMap *, int * );

#endif

/* Function interfaces. */
/* ==================== */
/* These macros are wrap-ups for the functions defined by this class
   to make them easier to invoke (e.g. to avoid type mis-matches when
   passing pointers to objects from derived classes). */

/* Interfaces to standard class functions. */
/* --------------------------------------- */
/* Some of these functions provide validation, so we cannot use them
   to validate their own arguments. We must use a cast when passing
   object pointers (so that they can accept objects from derived
   classes). */

/* Check class membership. */
#define astCheckDssMap(this) astINVOKE_CHECK(DssMap,this,0)
#define astVerifyDssMap(this) astINVOKE_CHECK(DssMap,this,1)

/* Test class membership. */
#define astIsADssMap(this) astINVOKE_ISA(DssMap,this)

/* Constructor. */
#if defined(astCLASS)            /* Protected. */
#define astDssMap astINVOKE(F,astDssMap_)
#endif

#if defined(astCLASS)            /* Protected */

/* Initialiser. */
#define astInitDssMap(mem,size,init,vtab,name,fits) \
astINVOKE(O,astInitDssMap_(mem,size,init,vtab,name,astCheckFitsChan(fits),STATUS_PTR))

/* Vtab Initialiser. */
#define astInitDssMapVtab(vtab,name) astINVOKE(V,astInitDssMapVtab_(vtab,name,STATUS_PTR))
/* Loader. */
#define astLoadDssMap(mem,size,vtab,name,channel) \
astINVOKE(O,astLoadDssMap_(mem,size,vtab,name,astCheckChannel(channel),STATUS_PTR))
#endif

/* Interfaces to public member functions. */
/* -------------------------------------- */
/* Here we make use of astCheckDssMap to validate DssMap pointers
   before use.  This provides a contextual error report if a pointer
   to the wrong sort of Object is supplied. */

#if defined(astCLASS)            /* Protected */
#define astDssFits(this) astINVOKE(O,astDssFits_(astCheckDssMap(this),STATUS_PTR))
#endif
#endif