5
/*--------------------------------------------------------------------------*/
6
int ffgiwcs(fitsfile *fptr, /* I - FITS file pointer */
7
char **header, /* O - pointer to the WCS related keywords */
8
int *status) /* IO - error status */
10
int fits_get_image_wcs_keys
11
return a string containing all the image WCS header keywords.
12
This string is then used as input to the wcsinit WCSlib routine.
20
fits_get_hdu_type(fptr, &hdutype, status);
21
if (hdutype != IMAGE_HDU)
24
"Error in ffgiwcs. This HDU is not an image. Can't read WCS keywords");
25
return(*status = NOT_IMAGE);
28
/* read header keywords into a long string of chars */
29
if (ffh2st(fptr, header, status) > 0)
31
ffpmsg("error creating string of image WCS keywords (ffgiwcs)");
37
/*--------------------------------------------------------------------------*/
38
int ffgtwcs(fitsfile *fptr, /* I - FITS file pointer */
39
int xcol, /* I - column number for the X column */
40
int ycol, /* I - column number for the Y column */
41
char **header, /* O - string of all the WCS keywords */
42
int *status) /* IO - error status */
44
int fits_get_table_wcs_keys
45
Return string containing all the WCS keywords appropriate for the
46
pair of X and Y columns containing the coordinate
47
of each event in an event list table. This string may then be passed
48
to Doug Mink's WCS library wcsinit routine, to create and initialize the
49
WCS structure. The calling routine must free the header character string
50
when it is no longer needed.
53
int hdutype, ncols, tstatus, length;
54
int naxis1 = 1, naxis2 = 1;
56
char keyname[FLEN_KEYWORD];
57
char valstring[FLEN_VALUE];
60
/* construct a string of 80 blanks, for adding fill to the keywords */
61
/* 12345678901234567890123456789012345678901234567890123456789012345678901234567890 */
67
fits_get_hdu_type(fptr, &hdutype, status);
68
if (hdutype == IMAGE_HDU)
70
ffpmsg("Can't read table WSC keywords. This HDU is not a table");
71
return(*status = NOT_TABLE);
74
fits_get_num_cols(fptr, &ncols, status);
76
if (xcol < 1 || xcol > ncols)
78
ffpmsg("illegal X axis column number in fftwcs");
79
return(*status = BAD_COL_NUM);
82
if (ycol < 1 || ycol > ncols)
84
ffpmsg("illegal Y axis column number in fftwcs");
85
return(*status = BAD_COL_NUM);
88
/* allocate character string for all the WCS keywords */
89
*header = calloc(1, 2401); /* room for up to 30 keywords */
92
ffpmsg("error allocating memory for WCS header keywords (fftwcs)");
93
return(*status = MEMORY_ALLOCATION);
100
ffkeyn("TLMIN",xcol,keyname,status);
101
ffgkyj(fptr,keyname, &tlmin,NULL,&tstatus);
105
ffkeyn("TLMAX",xcol,keyname,status);
106
ffgkyj(fptr,keyname, &tlmax,NULL,&tstatus);
111
naxis1 = tlmax - tlmin + 1;
115
ffkeyn("TLMIN",ycol,keyname,status);
116
ffgkyj(fptr,keyname, &tlmin,NULL,&tstatus);
120
ffkeyn("TLMAX",ycol,keyname,status);
121
ffgkyj(fptr,keyname, &tlmax,NULL,&tstatus);
126
naxis2 = tlmax - tlmin + 1;
129
/* 123456789012345678901234567890 */
130
strcat(cptr, "NAXIS = 2");
131
strncat(cptr, blanks, 50);
134
ffi2c(naxis1, valstring, status); /* convert to formatted string */
135
ffmkky("NAXIS1", valstring, comm, cptr, status); /* construct the keyword*/
136
strncat(cptr, blanks, 50); /* pad with blanks */
139
strcpy(keyname, "NAXIS2");
140
ffi2c(naxis2, valstring, status); /* convert to formatted string */
141
ffmkky(keyname, valstring, comm, cptr, status); /* construct the keyword*/
142
strncat(cptr, blanks, 50); /* pad with blanks */
145
/* read the required header keywords (use defaults if not found) */
149
ffkeyn("TCTYP",xcol,keyname,status);
150
if (ffgkey(fptr, keyname, valstring, NULL, &tstatus) )
152
ffmkky("CTYPE1", valstring, comm, cptr, status); /* construct the keyword*/
153
length = strlen(cptr);
154
strncat(cptr, blanks, 80 - length); /* pad with blanks */
159
ffkeyn("TCTYP",ycol,keyname,status);
160
if (ffgkey(fptr, keyname, valstring, NULL, &tstatus) )
162
ffmkky("CTYPE2", valstring, comm, cptr, status); /* construct the keyword*/
163
length = strlen(cptr);
164
strncat(cptr, blanks, 80 - length); /* pad with blanks */
169
ffkeyn("TCRPX",xcol,keyname,status);
170
if (ffgkey(fptr, keyname, valstring, NULL, &tstatus) )
171
strcpy(valstring, "1");
172
ffmkky("CRPIX1", valstring, comm, cptr, status); /* construct the keyword*/
173
strncat(cptr, blanks, 50); /* pad with blanks */
178
ffkeyn("TCRPX",ycol,keyname,status);
179
if (ffgkey(fptr, keyname, valstring, NULL, &tstatus) )
180
strcpy(valstring, "1");
181
ffmkky("CRPIX2", valstring, comm, cptr, status); /* construct the keyword*/
182
strncat(cptr, blanks, 50); /* pad with blanks */
187
ffkeyn("TCRVL",xcol,keyname,status);
188
if (ffgkey(fptr, keyname, valstring, NULL, &tstatus) )
189
strcpy(valstring, "1");
190
ffmkky("CRVAL1", valstring, comm, cptr, status); /* construct the keyword*/
191
strncat(cptr, blanks, 50); /* pad with blanks */
196
ffkeyn("TCRVL",ycol,keyname,status);
197
if (ffgkey(fptr, keyname, valstring, NULL, &tstatus) )
198
strcpy(valstring, "1");
199
ffmkky("CRVAL2", valstring, comm, cptr, status); /* construct the keyword*/
200
strncat(cptr, blanks, 50); /* pad with blanks */
205
ffkeyn("TCDLT",xcol,keyname,status);
206
if (ffgkey(fptr, keyname, valstring, NULL, &tstatus) )
207
strcpy(valstring, "1");
208
ffmkky("CDELT1", valstring, comm, cptr, status); /* construct the keyword*/
209
strncat(cptr, blanks, 50); /* pad with blanks */
214
ffkeyn("TCDLT",ycol,keyname,status);
215
if (ffgkey(fptr, keyname, valstring, NULL, &tstatus) )
216
strcpy(valstring, "1");
217
ffmkky("CDELT2", valstring, comm, cptr, status); /* construct the keyword*/
218
strncat(cptr, blanks, 50); /* pad with blanks */
221
/* the following keywords may not exist */
225
ffkeyn("TCROT",ycol,keyname,status);
226
if (ffgkey(fptr, keyname, valstring, NULL, &tstatus) == 0 )
228
ffmkky("CROTA2", valstring, comm, cptr, status); /* construct keyword*/
229
strncat(cptr, blanks, 50); /* pad with blanks */
235
if (ffgkey(fptr, "EPOCH", valstring, NULL, &tstatus) == 0 )
237
ffmkky("EPOCH", valstring, comm, cptr, status); /* construct keyword*/
238
length = strlen(cptr);
239
strncat(cptr, blanks, 80 - length); /* pad with blanks */
243
/* EQUINOX keyword */
245
if (ffgkey(fptr, "EQUINOX", valstring, NULL, &tstatus) == 0 )
247
ffmkky("EQUINOX", valstring, comm, cptr, status); /* construct keyword*/
248
length = strlen(cptr);
249
strncat(cptr, blanks, 80 - length); /* pad with blanks */
253
/* RADECSYS keyword */
255
if (ffgkey(fptr, "RADECSYS", valstring, NULL, &tstatus) == 0 )
257
ffmkky("RADECSYS", valstring, comm, cptr, status); /*construct keyword*/
258
length = strlen(cptr);
259
strncat(cptr, blanks, 80 - length); /* pad with blanks */
263
/* TELESCOPE keyword */
265
if (ffgkey(fptr, "TELESCOP", valstring, NULL, &tstatus) == 0 )
267
ffmkky("TELESCOP", valstring, comm, cptr, status);
268
length = strlen(cptr);
269
strncat(cptr, blanks, 80 - length); /* pad with blanks */
273
/* INSTRUME keyword */
275
if (ffgkey(fptr, "INSTRUME", valstring, NULL, &tstatus) == 0 )
277
ffmkky("INSTRUME", valstring, comm, cptr, status);
278
length = strlen(cptr);
279
strncat(cptr, blanks, 80 - length); /* pad with blanks */
283
/* DETECTOR keyword */
285
if (ffgkey(fptr, "DETECTOR", valstring, NULL, &tstatus) == 0 )
287
ffmkky("DETECTOR", valstring, comm, cptr, status);
288
length = strlen(cptr);
289
strncat(cptr, blanks, 80 - length); /* pad with blanks */
293
/* MJD-OBS keyword */
295
if (ffgkey(fptr, "MJD-OBS", valstring, NULL, &tstatus) == 0 )
297
ffmkky("MJD-OBS", valstring, comm, cptr, status);
298
length = strlen(cptr);
299
strncat(cptr, blanks, 80 - length); /* pad with blanks */
303
/* DATE-OBS keyword */
305
if (ffgkey(fptr, "DATE-OBS", valstring, NULL, &tstatus) == 0 )
307
ffmkky("DATE-OBS", valstring, comm, cptr, status);
308
length = strlen(cptr);
309
strncat(cptr, blanks, 80 - length); /* pad with blanks */
315
if (ffgkey(fptr, "DATE", valstring, NULL, &tstatus) == 0 )
317
ffmkky("DATE", valstring, comm, cptr, status);
318
length = strlen(cptr);
319
strncat(cptr, blanks, 80 - length); /* pad with blanks */
324
strncat(cptr, blanks, 77);