WCSLIB 4.20
wcshdr.h
Go to the documentation of this file.
1 /*============================================================================
2 
3  WCSLIB 4.20 - an implementation of the FITS WCS standard.
4  Copyright (C) 1995-2013, Mark Calabretta
5 
6  This file is part of WCSLIB.
7 
8  WCSLIB is free software: you can redistribute it and/or modify it under the
9  terms of the GNU Lesser General Public License as published by the Free
10  Software Foundation, either version 3 of the License, or (at your option)
11  any later version.
12 
13  WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16  more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with WCSLIB. If not, see http://www.gnu.org/licenses.
20 
21  Direct correspondence concerning WCSLIB to mark@calabretta.id.au
22 
23  Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
24  http://www.atnf.csiro.au/people/Mark.Calabretta
25  $Id: wcshdr_8h_source.html,v 1.1 2014/02/12 21:11:37 irby Exp $
26 *=============================================================================
27 *
28 * WCSLIB 4.20 - C routines that implement the FITS World Coordinate System
29 * (WCS) standard. Refer to
30 *
31 * "Representations of world coordinates in FITS",
32 * Greisen, E.W., & Calabretta, M.R. 2002, A&A, 395, 1061 (Paper I)
33 *
34 * "Representations of celestial coordinates in FITS",
35 * Calabretta, M.R., & Greisen, E.W. 2002, A&A, 395, 1077 (Paper II)
36 *
37 * "Representations of spectral coordinates in FITS",
38 * Greisen, E.W., Calabretta, M.R., Valdes, F.G., & Allen, S.L.
39 * 2006, A&A, 446, 747 (Paper III)
40 *
41 * Refer to the README file provided with WCSLIB for an overview of the
42 * library.
43 *
44 *
45 * Summary of the wcshdr routines
46 * ------------------------------
47 * Routines in this suite are aimed at extracting WCS information from a FITS
48 * file. They provide the high-level interface between the FITS file and the
49 * WCS coordinate transformation routines.
50 *
51 * Additionally, function wcshdo() is provided to write out the contents of a
52 * wcsprm struct as a FITS header.
53 *
54 * Briefly, the anticipated sequence of operations is as follows:
55 *
56 * - 1: Open the FITS file and read the image or binary table header, e.g.
57 * using CFITSIO routine fits_hdr2str().
58 *
59 * - 2: Parse the header using wcspih() or wcsbth(); they will automatically
60 * interpret 'TAB' header keywords using wcstab().
61 *
62 * - 3: Allocate memory for, and read 'TAB' arrays from the binary table
63 * extension, e.g. using CFITSIO routine fits_read_wcstab() - refer to
64 * the prologue of getwcstab.h. wcsset() will automatically take
65 * control of this allocated memory, in particular causing it to be
66 * free'd by wcsfree().
67 *
68 * - 4: Translate non-standard WCS usage using wcsfix(), see wcsfix.h.
69 *
70 * - 5: Initialize wcsprm struct(s) using wcsset() and calculate coordinates
71 * using wcsp2s() and/or wcss2p(). Refer to the prologue of wcs.h for a
72 * description of these and other high-level WCS coordinate
73 * transformation routines.
74 *
75 * - 6: Clean up by freeing memory with wcsvfree().
76 *
77 * In detail:
78 *
79 * - wcspih() is a high-level FITS WCS routine that parses an image header. It
80 * returns an array of up to 27 wcsprm structs on each of which it invokes
81 * wcstab().
82 *
83 * - wcsbth() is the analogue of wcspih() for use with binary tables; it
84 * handles image array and pixel list keywords. As an extension of the FITS
85 * WCS standard, it also recognizes image header keywords which may be used
86 * to provide default values via an inheritance mechanism.
87 *
88 * - wcstab() assists in filling in members of the wcsprm struct associated
89 * with coordinate lookup tables ('TAB'). These are based on arrays stored
90 * in a FITS binary table extension (BINTABLE) that are located by PVi_ma
91 * keywords in the image header.
92 *
93 * - wcsidx() and wcsbdx() are utility routines that return the index for a
94 * specified alternate coordinate descriptor in the array of wcsprm structs
95 * returned by wcspih() or wcsbth().
96 *
97 * - wcsvfree() deallocates memory for an array of wcsprm structs, such as
98 * returned by wcspih() or wcsbth().
99 *
100 * - wcshdo() writes out a wcsprm struct as a FITS header.
101 *
102 *
103 * wcspih() - FITS WCS parser routine for image headers
104 * ----------------------------------------------------
105 * wcspih() is a high-level FITS WCS routine that parses an image header,
106 * either that of a primary HDU or of an image extension. All WCS keywords
107 * defined in Papers I, II, and III are recognized, and also those used by the
108 * AIPS convention and certain other keywords that existed in early drafts of
109 * the WCS papers as explained in wcsbth() note 5.
110 *
111 * Given a character array containing a FITS image header, wcspih() identifies
112 * and reads all WCS keywords for the primary coordinate representation and up
113 * to 26 alternate representations. It returns this information as an array of
114 * wcsprm structs.
115 *
116 * wcspih() invokes wcstab() on each of the wcsprm structs that it returns.
117 *
118 * Use wcsbth() in preference to wcspih() for FITS headers of unknown type;
119 * wcsbth() can parse image headers as well as binary table and pixel list
120 * headers.
121 *
122 * Given and returned:
123 * header char[] Character array containing the (entire) FITS image
124 * header from which to identify and construct the
125 * coordinate representations, for example, as might be
126 * obtained conveniently via the CFITSIO routine
127 * fits_hdr2str().
128 *
129 * Each header "keyrecord" (formerly "card image")
130 * consists of exactly 80 7-bit ASCII printing characters
131 * in the range 0x20 to 0x7e (which excludes NUL, BS,
132 * TAB, LF, FF and CR) especially noting that the
133 * keyrecords are NOT null-terminated.
134 *
135 * For negative values of ctrl (see below), header[] is
136 * modified so that WCS keyrecords processed by wcspih()
137 * are removed from it.
138 *
139 * Given:
140 * nkeyrec int Number of keyrecords in header[].
141 *
142 * relax int Degree of permissiveness:
143 * 0: Recognize only FITS keywords defined by the
144 * published WCS standard.
145 * WCSHDR_all: Admit all recognized informal
146 * extensions of the WCS standard.
147 * Fine-grained control of the degree of permissiveness
148 * is also possible as explained in wcsbth() note 5.
149 *
150 * ctrl int Error reporting and other control options for invalid
151 * WCS and other header keyrecords:
152 * 0: Do not report any rejected header keyrecords.
153 * 1: Produce a one-line message stating the number
154 * of WCS keyrecords rejected (nreject).
155 * 2: Report each rejected keyrecord and the reason
156 * why it was rejected.
157 * 3: As above, but also report all non-WCS
158 * keyrecords that were discarded, and the number
159 * of coordinate representations (nwcs) found.
160 * The report is written to stderr by default, or the
161 * stream set by wcsprintf_set().
162 *
163 * For ctrl < 0, WCS keyrecords processed by wcspih()
164 * are removed from header[]:
165 * -1: Remove only valid WCS keyrecords whose values
166 * were successfully extracted, nothing is
167 * reported.
168 * -2: Also remove WCS keyrecords that were rejected,
169 * reporting each one and the reason that it was
170 * rejected.
171 * -3: As above, and also report the number of
172 * coordinate representations (nwcs) found.
173 * -11: Same as -1 but preserving the basic keywords
174 * '{DATE,MJD}-{OBS,AVG}' and 'OBSGEO-{X,Y,Z}'.
175 * If any keyrecords are removed from header[] it will
176 * be null-terminated (NUL not being a legal FITS header
177 * character), otherwise it will contain its original
178 * complement of nkeyrec keyrecords and possibly not be
179 * null-terminated.
180 *
181 * Returned:
182 * nreject int* Number of WCS keywords rejected for syntax errors,
183 * illegal values, etc. Keywords not recognized as WCS
184 * keywords are simply ignored. Refer also to wcsbth()
185 * note 5.
186 *
187 * nwcs int* Number of coordinate representations found.
188 *
189 * wcs struct wcsprm**
190 * Pointer to an array of wcsprm structs containing up to
191 * 27 coordinate representations.
192 *
193 * Memory for the array is allocated by wcspih() which
194 * also invokes wcsini() for each struct to allocate
195 * memory for internal arrays and initialize their
196 * members to default values. Refer also to wcsbth()
197 * note 8. Note that wcsset() is not invoked on these
198 * structs.
199 *
200 * This allocated memory must be freed by the user, first
201 * by invoking wcsfree() for each struct, and then by
202 * freeing the array itself. A routine, wcsvfree(), is
203 * provided to do this (see below).
204 *
205 * Function return value:
206 * int Status return value:
207 * 0: Success.
208 * 1: Null wcsprm pointer passed.
209 * 2: Memory allocation failed.
210 * 4: Fatal error returned by Flex parser.
211 *
212 * Notes:
213 * Refer to wcsbth() notes 1, 2, 3, 5, 7, and 8.
214 *
215 *
216 * wcsbth() - FITS WCS parser routine for binary table and image headers
217 * ---------------------------------------------------------------------
218 * wcsbth() is a high-level FITS WCS routine that parses a binary table header.
219 * It handles image array and pixel list WCS keywords which may be present
220 * together in one header.
221 *
222 * As an extension of the FITS WCS standard, wcsbth() also recognizes image
223 * header keywords in a binary table header. These may be used to provide
224 * default values via an inheritance mechanism discussed in note 5 (c.f.
225 * WCSHDR_AUXIMG and WCSHDR_ALLIMG), or may instead result in wcsprm structs
226 * that are not associated with any particular column. Thus wcsbth() can
227 * handle primary image and image extension headers in addition to binary table
228 * headers (it ignores NAXIS and does not rely on the presence of the TFIELDS
229 * keyword).
230 *
231 * All WCS keywords defined in Papers I, II, and III are recognized, and also
232 * those used by the AIPS convention and certain other keywords that existed in
233 * early drafts of the WCS papers as explained in note 5 below.
234 *
235 * wcsbth() sets the colnum or colax[] members of the wcsprm structs that it
236 * returns with the column number of an image array or the column numbers
237 * associated with each pixel coordinate element in a pixel list. wcsprm
238 * structs that are not associated with any particular column, as may be
239 * derived from image header keywords, have colnum == 0.
240 *
241 * Note 6 below discusses the number of wcsprm structs returned by wcsbth(),
242 * and the circumstances in which image header keywords cause a struct to be
243 * created. See also note 9 concerning the number of separate images that may
244 * be stored in a pixel list.
245 *
246 * The API to wcsbth() is similar to that of wcspih() except for the addition
247 * of extra arguments that may be used to restrict its operation. Like
248 * wcspih(), wcsbth() invokes wcstab() on each of the wcsprm structs that it
249 * returns.
250 *
251 * Given and returned:
252 * header char[] Character array containing the (entire) FITS binary
253 * table, primary image, or image extension header from
254 * which to identify and construct the coordinate
255 * representations, for example, as might be obtained
256 * conveniently via the CFITSIO routine fits_hdr2str().
257 *
258 * Each header "keyrecord" (formerly "card image")
259 * consists of exactly 80 7-bit ASCII printing
260 * characters in the range 0x20 to 0x7e (which excludes
261 * NUL, BS, TAB, LF, FF and CR) especially noting that
262 * the keyrecords are NOT null-terminated.
263 *
264 * For negative values of ctrl (see below), header[] is
265 * modified so that WCS keyrecords processed by wcsbth()
266 * are removed from it.
267 *
268 * Given:
269 * nkeyrec int Number of keyrecords in header[].
270 *
271 * relax int Degree of permissiveness:
272 * 0: Recognize only FITS keywords defined by the
273 * published WCS standard.
274 * WCSHDR_all: Admit all recognized informal
275 * extensions of the WCS standard.
276 * Fine-grained control of the degree of permissiveness
277 * is also possible, as explained in note 5 below.
278 *
279 * ctrl int Error reporting and other control options for invalid
280 * WCS and other header keyrecords:
281 * 0: Do not report any rejected header keyrecords.
282 * 1: Produce a one-line message stating the number
283 * of WCS keyrecords rejected (nreject).
284 * 2: Report each rejected keyrecord and the reason
285 * why it was rejected.
286 * 3: As above, but also report all non-WCS
287 * keyrecords that were discarded, and the number
288 * of coordinate representations (nwcs) found.
289 * The report is written to stderr by default, or the
290 * stream set by wcsprintf_set().
291 *
292 * For ctrl < 0, WCS keyrecords processed by wcsbth()
293 * are removed from header[]:
294 * -1: Remove only valid WCS keyrecords whose values
295 * were successfully extracted, nothing is
296 * reported.
297 * -2: Also remove WCS keyrecords that were rejected,
298 * reporting each one and the reason that it was
299 * rejected.
300 * -3: As above, and also report the number of
301 * coordinate representations (nwcs) found.
302 * -11: Same as -1 but preserving the basic keywords
303 * '{DATE,MJD}-{OBS,AVG}' and 'OBSGEO-{X,Y,Z}'.
304 * If any keyrecords are removed from header[] it will
305 * be null-terminated (NUL not being a legal FITS header
306 * character), otherwise it will contain its original
307 * complement of nkeyrec keyrecords and possibly not be
308 * null-terminated.
309 *
310 * keysel int Vector of flag bits that may be used to restrict the
311 * keyword types considered:
312 * WCSHDR_IMGHEAD: Image header keywords.
313 * WCSHDR_BIMGARR: Binary table image array.
314 * WCSHDR_PIXLIST: Pixel list keywords.
315 * If zero, there is no restriction.
316 *
317 * Keywords such as EQUIna or RFRQna that are common to
318 * binary table image arrays and pixel lists (including
319 * WCSNna and TWCSna, as explained in note 4 below) are
320 * selected by both WCSHDR_BIMGARR and WCSHDR_PIXLIST.
321 * Thus if inheritance via WCSHDR_ALLIMG is enabled as
322 * discussed in note 5 and one of these shared keywords
323 * is present, then WCSHDR_IMGHEAD and WCSHDR_PIXLIST
324 * alone may be sufficient to cause the construction of
325 * coordinate descriptions for binary table image arrays.
326 *
327 * colsel int* Pointer to an array of table column numbers used to
328 * restrict the keywords considered by wcsbth().
329 *
330 * A null pointer may be specified to indicate that there
331 * is no restriction. Otherwise, the magnitude of
332 * cols[0] specifies the length of the array:
333 * cols[0] > 0: the columns are included,
334 * cols[0] < 0: the columns are excluded.
335 *
336 * For the pixel list keywords TPn_ka and TCn_ka (and
337 * TPCn_ka and TCDn_ka if WCSHDR_LONGKEY is enabled), it
338 * is an error for one column to be selected but not the
339 * other. This is unlike the situation with invalid
340 * keyrecords, which are simply rejected, because the
341 * error is not intrinsic to the header itself but
342 * arises in the way that it is processed.
343 *
344 * Returned:
345 * nreject int* Number of WCS keywords rejected for syntax errors,
346 * illegal values, etc. Keywords not recognized as WCS
347 * keywords are simply ignored, refer also to note 5
348 * below.
349 *
350 * nwcs int* Number of coordinate representations found.
351 *
352 * wcs struct wcsprm**
353 * Pointer to an array of wcsprm structs containing up
354 * to 27027 coordinate representations, refer to note 6
355 * below.
356 *
357 * Memory for the array is allocated by wcsbth() which
358 * also invokes wcsini() for each struct to allocate
359 * memory for internal arrays and initialize their
360 * members to default values. Refer also to note 8
361 * below. Note that wcsset() is not invoked on these
362 * structs.
363 *
364 * This allocated memory must be freed by the user, first
365 * by invoking wcsfree() for each struct, and then by
366 * freeing the array itself. A routine, wcsvfree(), is
367 * provided to do this (see below).
368 *
369 * Function return value:
370 * int Status return value:
371 * 0: Success.
372 * 1: Null wcsprm pointer passed.
373 * 2: Memory allocation failed.
374 * 3: Invalid column selection.
375 * 4: Fatal error returned by Flex parser.
376 *
377 * Notes:
378 * 1: wcspih() determines the number of coordinate axes independently for
379 * each alternate coordinate representation (denoted by the "a" value in
380 * keywords like CTYPEia) from the higher of
381 *
382 * a: NAXIS,
383 * b: WCSAXESa,
384 * c: The highest axis number in any parameterized WCS keyword. The
385 * keyvalue, as well as the keyword, must be syntactically valid
386 * otherwise it will not be considered.
387 *
388 * If none of these keyword types is present, i.e. if the header only
389 * contains auxiliary WCS keywords for a particular coordinate
390 * representation, then no coordinate description is constructed for it.
391 *
392 * wcsbth() is similar except that it ignores the NAXIS keyword if given
393 * an image header to process.
394 *
395 * The number of axes, which is returned as a member of the wcsprm
396 * struct, may differ for different coordinate representations of the
397 * same image.
398 *
399 * 2: wcspih() and wcsbth() enforce correct FITS "keyword = value" syntax
400 * with regard to "= " occurring in columns 9 and 10.
401 *
402 * However, they do recognize free-format character (NOST 100-2.0,
403 * Sect. 5.2.1), integer (Sect. 5.2.3), and floating-point values
404 * (Sect. 5.2.4) for all keywords.
405 *
406 * 3: Where CROTAn, CDi_ja, and PCi_ja occur together in one header wcspih()
407 * and wcsbth() treat them as described in the prologue to wcs.h.
408 *
409 * 4: WCS Paper I mistakenly defined the pixel list form of WCSNAMEa as
410 * TWCSna instead of WCSNna; the 'T' is meant to substitute for the axis
411 * number in the binary table form of the keyword - note that keywords
412 * defined in WCS Papers II and III that are not parameterised by axis
413 * number have identical forms for binary tables and pixel lists.
414 * Consequently wcsbth() always treats WCSNna and TWCSna as equivalent.
415 *
416 * 5: wcspih() and wcsbth() interpret the "relax" argument as a vector of
417 * flag bits to provide fine-grained control over what non-standard WCS
418 * keywords to accept. The flag bits are subject to change in future and
419 * should be set by using the preprocessor macros (see below) for the
420 * purpose.
421 *
422 * - WCSHDR_none: Don't accept any extensions (not even those in the
423 * errata). Treat non-conformant keywords in the same way as
424 * non-WCS keywords in the header, i.e. simply ignore them.
425 *
426 * - WCSHDR_all: Accept all extensions recognized by the parser.
427 *
428 * - WCSHDR_reject: Reject non-standard keywords (that are not otherwise
429 * accepted). A message will optionally be printed on stderr by
430 * default, or the stream set by wcsprintf_set(), as determined by
431 * the ctrl argument, and nreject will be incremented.
432 *
433 * This flag may be used to signal the presence of non-standard
434 * keywords, otherwise they are simply passed over as though they
435 * did not exist in the header.
436 *
437 * Useful for testing conformance of a FITS header to the WCS
438 * standard.
439 *
440 * - WCSHDR_CROTAia: Accept CROTAia (wcspih()),
441 * iCROTna (wcsbth()),
442 * TCROTna (wcsbth()).
443 * - WCSHDR_EPOCHa: Accept EPOCHa.
444 * - WCSHDR_VELREFa: Accept VELREFa.
445 * wcspih() always recognizes the AIPS-convention keywords,
446 * CROTAn, EPOCH, and VELREF for the primary representation
447 * (a = ' ') but alternates are non-standard.
448 *
449 * wcsbth() accepts EPOCHa and VELREFa only if WCSHDR_AUXIMG is
450 * also enabled.
451 *
452 * - WCSHDR_CD00i00j: Accept CD00i00j (wcspih()).
453 * - WCSHDR_PC00i00j: Accept PC00i00j (wcspih()).
454 * - WCSHDR_PROJPn: Accept PROJPn (wcspih()).
455 * These appeared in early drafts of WCS Paper I+II (before they
456 * were split) and are equivalent to CDi_ja, PCi_ja, and PVi_ma
457 * for the primary representation (a = ' '). PROJPn is
458 * equivalent to PVi_ma with m = n <= 9, and is associated
459 * exclusively with the latitude axis.
460 *
461 * - WCSHDR_RADECSYS: Accept RADECSYS. This appeared in early drafts of
462 * WCS Paper I+II and was subsequently replaced by RADESYSa.
463 *
464 * wcsbth() accepts RADECSYS only if WCSHDR_AUXIMG is also
465 * enabled.
466 *
467 * - WCSHDR_VSOURCE: Accept VSOURCEa or VSOUna (wcsbth()). This appeared
468 * in early drafts of WCS Paper III and was subsequently dropped
469 * in favour of ZSOURCEa and ZSOUna.
470 *
471 * wcsbth() accepts VSOURCEa only if WCSHDR_AUXIMG is also
472 * enabled.
473 *
474 * - WCSHDR_DOBSn (wcsbth() only): Allow DOBSn, the column-specific analogue
475 * of DATE-OBS. By an oversight this was never formally defined
476 * in the standard.
477 *
478 * - WCSHDR_LONGKEY (wcsbth() only): Accept long forms of the alternate
479 * binary table and pixel list WCS keywords, i.e. with "a" non-
480 * blank. Specifically
481 *
482 # jCRPXna TCRPXna : jCRPXn jCRPna TCRPXn TCRPna CRPIXja
483 # - TPCn_ka : - ijPCna - TPn_ka PCi_ja
484 # - TCDn_ka : - ijCDna - TCn_ka CDi_ja
485 # iCDLTna TCDLTna : iCDLTn iCDEna TCDLTn TCDEna CDELTia
486 # iCUNIna TCUNIna : iCUNIn iCUNna TCUNIn TCUNna CUNITia
487 # iCTYPna TCTYPna : iCTYPn iCTYna TCTYPn TCTYna CTYPEia
488 # iCRVLna TCRVLna : iCRVLn iCRVna TCRVLn TCRVna CRVALia
489 # iPVn_ma TPVn_ma : - iVn_ma - TVn_ma PVi_ma
490 # iPSn_ma TPSn_ma : - iSn_ma - TSn_ma PSi_ma
491 *
492 * where the primary and standard alternate forms together with
493 * the image-header equivalent are shown rightwards of the colon.
494 *
495 * The long form of these keywords could be described as quasi-
496 * standard. TPCn_ka, iPVn_ma, and TPVn_ma appeared by mistake
497 * in the examples in WCS Paper II and subsequently these and
498 * also TCDn_ka, iPSn_ma and TPSn_ma were legitimized by the
499 * errata to the WCS papers.
500 *
501 * Strictly speaking, the other long forms are non-standard and
502 * in fact have never appeared in any draft of the WCS papers nor
503 * in the errata. However, as natural extensions of the primary
504 * form they are unlikely to be written with any other intention.
505 * Thus it should be safe to accept them provided, of course,
506 * that the resulting keyword does not exceed the 8-character
507 * limit.
508 *
509 * If WCSHDR_CNAMn is enabled then also accept
510 *
511 # iCNAMna TCNAMna : --- iCNAna --- TCNAna CNAMEia
512 # iCRDEna TCRDEna : --- iCRDna --- TCRDna CRDERia
513 # iCSYEna TCSYEna : --- iCSYna --- TCSYna CSYERia
514 *
515 * Note that CNAMEia, CRDERia, CSYERia, and their variants are
516 * not used by WCSLIB but are stored in the wcsprm struct as
517 * auxiliary information.
518 *
519 * - WCSHDR_CNAMn (wcsbth() only): Accept iCNAMn, iCRDEn, iCSYEn, TCNAMn,
520 * TCRDEn, and TCSYEn, i.e. with "a" blank. While non-standard,
521 * these are the obvious analogues of iCTYPn, TCTYPn, etc.
522 *
523 * - WCSHDR_AUXIMG (wcsbth() only): Allow the image-header form of an
524 * auxiliary WCS keyword with representation-wide scope to
525 * provide a default value for all images. This default may be
526 * overridden by the column-specific form of the keyword.
527 *
528 * For example, a keyword like EQUINOXa would apply to all image
529 * arrays in a binary table, or all pixel list columns with
530 * alternate representation "a" unless overridden by EQUIna.
531 *
532 * Specifically the keywords are:
533 *
534 # LATPOLEa for LATPna
535 # LONPOLEa for LONPna
536 # RESTFREQ for RFRQna
537 # RESTFRQa for RFRQna
538 # RESTWAVa for RWAVna
539 *
540 * whose keyvalues are actually used by WCSLIB, and also keywords
541 * that provide auxiliary information that is simply stored in
542 * the wcsprm struct:
543 *
544 # EPOCH - ... (No column-specific form.)
545 # EPOCHa - ... Only if WCSHDR_EPOCHa is set.
546 # EQUINOXa for EQUIna
547 # RADESYSa for RADEna
548 # RADECSYS for RADEna ... Only if WCSHDR_RADECSYS is set.
549 # SPECSYSa for SPECna
550 # SSYSOBSa for SOBSna
551 # SSYSSRCa for SSRCna
552 # VELOSYSa for VSYSna
553 # VELANGLa for VANGna
554 # VELREF - ... (No column-specific form.)
555 # VELREFa - ... Only if WCSHDR_VELREFa is set.
556 # VSOURCEa for VSOUna ... Only if WCSHDR_VSOURCE is set.
557 # WCSNAMEa for WCSNna ... Or TWCSna (see below).
558 # ZSOURCEa for ZSOUna
559 *
560 # DATE-AVG for DAVGn
561 # DATE-OBS for DOBSn
562 # MJD-AVG for MJDAn
563 # MJD-OBS for MJDOBn
564 # OBSGEO-X for OBSGXn
565 # OBSGEO-Y for OBSGYn
566 # OBSGEO-Z for OBSGZn
567 *
568 * where the image-header keywords on the left provide default
569 * values for the column specific keywords on the right.
570 *
571 * Keywords in the last group, such as MJD-OBS, apply to all
572 * alternate representations, so MJD-OBS would provide a default
573 * value for all images in the header.
574 *
575 * This auxiliary inheritance mechanism applies to binary table
576 * image arrays and pixel lists alike. Most of these keywords
577 * have no default value, the exceptions being LONPOLEa and
578 * LATPOLEa, and also RADESYSa and EQUINOXa which provide
579 * defaults for each other. Thus the only potential difficulty
580 * in using WCSHDR_AUXIMG is that of erroneously inheriting one
581 * of these four keywords.
582 *
583 * Unlike WCSHDR_ALLIMG, the existence of one (or all) of these
584 * auxiliary WCS image header keywords will not by itself cause a
585 * wcsprm struct to be created for alternate representation "a".
586 * This is because they do not provide sufficient information to
587 * create a non-trivial coordinate representation when used in
588 * conjunction with the default values of those keywords, such as
589 * CTYPEia, that are parameterized by axis number.
590 *
591 * - WCSHDR_ALLIMG (wcsbth() only): Allow the image-header form of *all*
592 * image header WCS keywords to provide a default value for all
593 * image arrays in a binary table (n.b. not pixel list). This
594 * default may be overridden by the column-specific form of the
595 * keyword.
596 *
597 * For example, a keyword like CRPIXja would apply to all image
598 * arrays in a binary table with alternate representation "a"
599 * unless overridden by jCRPna.
600 *
601 * Specifically the keywords are those listed above for
602 * WCSHDR_AUXIMG plus
603 *
604 # WCSAXESa for WCAXna
605 *
606 * which defines the coordinate dimensionality, and the following
607 * keywords which are parameterized by axis number:
608 *
609 # CRPIXja for jCRPna
610 # PCi_ja for ijPCna
611 # CDi_ja for ijCDna
612 # CDELTia for iCDEna
613 # CROTAi for iCROTn
614 # CROTAia - ... Only if WCSHDR_CROTAia is set.
615 # CUNITia for iCUNna
616 # CTYPEia for iCTYna
617 # CRVALia for iCRVna
618 # PVi_ma for iVn_ma
619 # PSi_ma for iSn_ma
620 *
621 # CNAMEia for iCNAna
622 # CRDERia for iCRDna
623 # CSYERia for iCSYna
624 *
625 * where the image-header keywords on the left provide default
626 * values for the column specific keywords on the right.
627 *
628 * This full inheritance mechanism only applies to binary table
629 * image arrays, not pixel lists, because in the latter case
630 * there is no well-defined association between coordinate axis
631 * number and column number.
632 *
633 * Note that CNAMEia, CRDERia, CSYERia, and their variants are
634 * not used by WCSLIB but are stored in the wcsprm struct as
635 * auxiliary information.
636 *
637 * Note especially that at least one wcsprm struct will be
638 * returned for each "a" found in one of the image header
639 * keywords listed above:
640 *
641 * - If the image header keywords for "a" ARE NOT inherited by a
642 * binary table, then the struct will not be associated with
643 * any particular table column number and it is up to the user
644 * to provide an association.
645 *
646 * - If the image header keywords for "a" ARE inherited by a
647 * binary table image array, then those keywords are considered
648 * to be "exhausted" and do not result in a separate wcsprm
649 * struct.
650 *
651 * For example, to accept CD00i00j and PC00i00j and reject all other
652 * extensions, use
653 *
654 = relax = WCSHDR_reject | WCSHDR_CD00i00j | WCSHDR_PC00i00j;
655 *
656 * The parser always treats EPOCH as subordinate to EQUINOXa if both are
657 * present, and VSOURCEa is always subordinate to ZSOURCEa.
658 *
659 * Likewise, VELREF is subordinate to the formalism of WCS Paper III, see
660 * spcaips().
661 *
662 * Neither wcspih() nor wcsbth() currently recognize the AIPS-convention
663 * keywords ALTRPIX or ALTRVAL which effectively define an alternative
664 * representation for a spectral axis.
665 *
666 * 6: Depending on what flags have been set in its "relax" argument,
667 * wcsbth() could return as many as 27027 wcsprm structs:
668 *
669 * - Up to 27 unattached representations derived from image header
670 * keywords.
671 *
672 * - Up to 27 structs for each of up to 999 columns containing an image
673 * arrays.
674 *
675 * - Up to 27 structs for a pixel list.
676 *
677 * Note that it is considered legitimate for a column to contain an image
678 * array and also form part of a pixel list, and in particular that
679 * wcsbth() does not check the TFORM keyword for a pixel list column to
680 * check that it is scalar.
681 *
682 * In practice, of course, a realistic binary table header is unlikely to
683 * contain more than a handful of images.
684 *
685 * In order for wcsbth() to create a wcsprm struct for a particular
686 * coordinate representation, at least one WCS keyword that defines an
687 * axis number must be present, either directly or by inheritance if
688 * WCSHDR_ALLIMG is set.
689 *
690 * When the image header keywords for an alternate representation are
691 * inherited by a binary table image array via WCSHDR_ALLIMG, those
692 * keywords are considered to be "exhausted" and do not result in a
693 * separate wcsprm struct. Otherwise they do.
694 *
695 * 7: Neither wcspih() nor wcsbth() check for duplicated keywords, in most
696 * cases they accept the last encountered.
697 *
698 * 8: wcspih() and wcsbth() use wcsnpv() and wcsnps() (refer to the prologue
699 * of wcs.h) to match the size of the pv[] and ps[] arrays in the wcsprm
700 * structs to the number in the header. Consequently there are no unused
701 * elements in the pv[] and ps[] arrays, indeed they will often be of
702 * zero length.
703 *
704 * 9: The FITS WCS standard for pixel lists assumes that a pixel list
705 * defines one and only one image, i.e. that each row of the binary table
706 * refers to just one event, e.g. the detection of a single photon or
707 * neutrino.
708 *
709 * In the absence of a formal mechanism for identifying the columns
710 * containing pixel coordinates (as opposed to pixel values or ancillary
711 * data recorded at the time the photon or neutrino was detected),
712 * Paper I discusses how the WCS keywords themselves may be used to
713 * identify them.
714 *
715 * In practice, however, pixel lists have been used to store multiple
716 * images. Besides not specifying how to identify columns, the pixel
717 * list convention is also silent on the method to be used to associate
718 * table columns with image axes.
719 *
720 * wcsbth() simply collects all WCS keywords for a particular coordinate
721 * representation (i.e. the "a" value in TCTYna) into one wcsprm struct.
722 * However, these alternates need not be associated with the same table
723 * columns and this allows a pixel list to contain up to 27 separate
724 * images. As usual, if one of these representations happened to contain
725 * more than two celestial axes, for example, then an error would result
726 * when wcsset() is invoked on it. In this case the "colsel" argument
727 * could be used to restrict the columns used to construct the
728 * representation so that it only contained one pair of celestial axes.
729 *
730 *
731 * wcstab() - Tabular construction routine
732 * ---------------------------------------
733 * wcstab() assists in filling in the information in the wcsprm struct relating
734 * to coordinate lookup tables.
735 *
736 * Tabular coordinates ('TAB') present certain difficulties in that the main
737 * components of the lookup table - the multidimensional coordinate array plus
738 * an index vector for each dimension - are stored in a FITS binary table
739 * extension (BINTABLE). Information required to locate these arrays is stored
740 * in PVi_ma and PSi_ma keywords in the image header.
741 *
742 * wcstab() parses the PVi_ma and PSi_ma keywords associated with each 'TAB'
743 * axis and allocates memory in the wcsprm struct for the required number of
744 * tabprm structs. It sets as much of the tabprm struct as can be gleaned from
745 * the image header, and also sets up an array of wtbarr structs (described in
746 * the prologue of wcs.h) to assist in extracting the required arrays from the
747 * BINTABLE extension(s).
748 *
749 * It is then up to the user to allocate memory for, and copy arrays from the
750 * BINTABLE extension(s) into the tabprm structs. A CFITSIO routine,
751 * fits_read_wcstab(), has been provided for this purpose, see getwcstab.h.
752 * wcsset() will automatically take control of this allocated memory, in
753 * particular causing it to be free'd by wcsfree(); the user must not attempt
754 * to free it after wcsset() has been called.
755 *
756 * Note that wcspih() and wcsbth() automatically invoke wcstab() on each of the
757 * wcsprm structs that they return.
758 *
759 * Given and returned:
760 * wcs struct wcsprm*
761 * Coordinate transformation parameters (see below).
762 *
763 * wcstab() sets ntab, tab, nwtb and wtb, allocating
764 * memory for the tab and wtb arrays. This allocated
765 * memory will be free'd automatically by wcsfree().
766 *
767 * Function return value:
768 * int Status return value:
769 * 0: Success.
770 * 1: Null wcsprm pointer passed.
771 * 2: Memory allocation failed.
772 * 3: Invalid tabular parameters.
773 *
774 * For returns > 1, a detailed error message is set in
775 * wcsprm::err if enabled, see wcserr_enable().
776 *
777 *
778 * wcsidx() - Index alternate coordinate representations
779 * -----------------------------------------------------
780 * wcsidx() returns an array of 27 indices for the alternate coordinate
781 * representations in the array of wcsprm structs returned by wcspih(). For
782 * the array returned by wcsbth() it returns indices for the unattached
783 * (colnum == 0) representations derived from image header keywords - use
784 * wcsbdx() for those derived from binary table image arrays or pixel lists
785 * keywords.
786 *
787 * Given:
788 * nwcs int Number of coordinate representations in the array.
789 *
790 * wcs const struct wcsprm**
791 * Pointer to an array of wcsprm structs returned by
792 * wcspih() or wcsbth().
793 *
794 * Returned:
795 * alts int[27] Index of each alternate coordinate representation in
796 * the array: alts[0] for the primary, alts[1] for 'A',
797 * etc., set to -1 if not present.
798 *
799 * For example, if there was no 'P' representation then
800 *
801 = alts['P'-'A'+1] == -1;
802 *
803 * Otherwise, the address of its wcsprm struct would be
804 *
805 = wcs + alts['P'-'A'+1];
806 *
807 * Function return value:
808 * int Status return value:
809 * 0: Success.
810 * 1: Null wcsprm pointer passed.
811 *
812 *
813 * wcsbdx() - Index alternate coordinate representions
814 * ---------------------------------------------------
815 * wcsbdx() returns an array of 999 x 27 indices for the alternate coordinate
816 * representions for binary table image arrays xor pixel lists in the array of
817 * wcsprm structs returned by wcsbth(). Use wcsidx() for the unattached
818 * representations derived from image header keywords.
819 *
820 * Given:
821 * nwcs int Number of coordinate representations in the array.
822 *
823 * wcs const struct wcsprm**
824 * Pointer to an array of wcsprm structs returned by
825 * wcsbth().
826 *
827 * type int Select the type of coordinate representation:
828 * 0: binary table image arrays,
829 * 1: pixel lists.
830 *
831 * Returned:
832 * alts short[1000][28]
833 * Index of each alternate coordinate represention in the
834 * array: alts[col][0] for the primary, alts[col][1] for
835 * 'A', to alts[col][26] for 'Z', where col is the
836 * 1-relative column number, and col == 0 is used for
837 * unattached image headers. Set to -1 if not present.
838 *
839 * alts[col][27] counts the number of coordinate
840 * representations of the chosen type for each column.
841 *
842 * For example, if there was no 'P' represention for
843 * column 13 then
844 *
845 = alts[13]['P'-'A'+1] == -1;
846 *
847 * Otherwise, the address of its wcsprm struct would be
848 *
849 = wcs + alts[13]['P'-'A'+1];
850 *
851 * Function return value:
852 * int Status return value:
853 * 0: Success.
854 * 1: Null wcsprm pointer passed.
855 *
856 *
857 * wcsvfree() - Free the array of wcsprm structs
858 * ---------------------------------------------
859 * wcsvfree() frees the memory allocated by wcspih() or wcsbth() for the array
860 * of wcsprm structs, first invoking wcsfree() on each of the array members.
861 *
862 * Given and returned:
863 * nwcs int* Number of coordinate representations found; set to 0
864 * on return.
865 *
866 * wcs struct wcsprm**
867 * Pointer to the array of wcsprm structs; set to 0 on
868 * return.
869 *
870 * Function return value:
871 * int Status return value:
872 * 0: Success.
873 * 1: Null wcsprm pointer passed.
874 *
875 *
876 * wcshdo() - Write out a wcsprm struct as a FITS header
877 * -----------------------------------------------------
878 * wcshdo() translates a wcsprm struct into a FITS header. If the colnum
879 * member of the struct is non-zero then a binary table image array header will
880 * be produced. Otherwise, if the colax[] member of the struct is set non-zero
881 * then a pixel list header will be produced. Otherwise, a primary image or
882 * image extension header will be produced.
883 *
884 * If the struct was originally constructed from a header, e.g. by wcspih(),
885 * the output header will almost certainly differ in a number of respects:
886 *
887 * - The output header only contains WCS-related keywords. In particular, it
888 * does not contain syntactically-required keywords such as SIMPLE, NAXIS,
889 * BITPIX, or END.
890 *
891 * - Deprecated (e.g. CROTAn) or non-standard usage will be translated to
892 * standard (this is partially dependent on whether wcsfix() was applied).
893 *
894 * - Quantities will be converted to the units used internally, basically SI
895 * with the addition of degrees.
896 *
897 * - Floating-point quantities may be given to a different decimal precision.
898 *
899 * - Elements of the PCi_ja matrix will be written if and only if they differ
900 * from the unit matrix. Thus, if the matrix is unity then no elements
901 * will be written.
902 *
903 * - Additional keywords such as WCSAXESa, CUNITia, LONPOLEa and LATPOLEa may
904 * appear.
905 *
906 * - The original keycomments will be lost, although wcshdo() tries hard to
907 * write meaningful comments.
908 *
909 * - Keyword order may be changed.
910 *
911 * Keywords can be translated between the image array, binary table, and pixel
912 * lists forms by manipulating the colnum or colax[] members of the wcsprm
913 * struct.
914 *
915 * Given:
916 * relax int Degree of permissiveness:
917 * 0: Recognize only FITS keywords defined by the
918 * published WCS standard.
919 * -1: Admit all informal extensions of the WCS
920 * standard.
921 * Fine-grained control of the degree of permissiveness
922 * is also possible as explained in the notes below.
923 *
924 * Given and returned:
925 * wcs struct wcsprm*
926 * Pointer to a wcsprm struct containing coordinate
927 * transformation parameters. Will be initialized if
928 * necessary.
929 *
930 * Returned:
931 * nkeyrec int* Number of FITS header keyrecords returned in the
932 * "header" array.
933 *
934 * header char** Pointer to an array of char holding the header.
935 * Storage for the array is allocated by wcshdo() in
936 * blocks of 2880 bytes (32 x 80-character keyrecords)
937 * and must be free'd by the user to avoid memory leaks.
938 *
939 * Each keyrecord is 80 characters long and is *NOT*
940 * null-terminated, so the first keyrecord starts at
941 * (*header)[0], the second at (*header)[80], etc.
942 *
943 * Function return value:
944 * int Status return value (associated with wcs_errmsg[]):
945 * 0: Success.
946 * 1: Null wcsprm pointer passed.
947 * 2: Memory allocation failed.
948 * 3: Linear transformation matrix is singular.
949 * 4: Inconsistent or unrecognized coordinate axis
950 * types.
951 * 5: Invalid parameter value.
952 * 6: Invalid coordinate transformation parameters.
953 * 7: Ill-conditioned coordinate transformation
954 * parameters.
955 *
956 * For returns > 1, a detailed error message is set in
957 * wcsprm::err if enabled, see wcserr_enable().
958 *
959 * Notes:
960 * wcshdo() interprets the "relax" argument as a vector of flag bits to
961 * provide fine-grained control over what non-standard WCS keywords to write.
962 * The flag bits are subject to change in future and should be set by using
963 * the preprocessor macros (see below) for the purpose.
964 *
965 * - WCSHDO_none: Don't use any extensions.
966 *
967 * - WCSHDO_all: Write all recognized extensions, equivalent to setting each
968 * flag bit.
969 *
970 * - WCSHDO_safe: Write all extensions that are considered to be safe and
971 * recommended.
972 *
973 * - WCSHDO_DOBSn: Write DOBSn, the column-specific analogue of DATE-OBS for
974 * use in binary tables and pixel lists. WCS Paper III introduced
975 * DATE-AVG and DAVGn but by an oversight DOBSn (the obvious analogy)
976 * was never formally defined by the standard. The alternative to
977 * using DOBSn is to write DATE-OBS which applies to the whole table.
978 * This usage is considered to be safe and is recommended.
979 *
980 * - WCSHDO_TPCn_ka: WCS Paper I defined
981 *
982 * - TPn_ka and TCn_ka for pixel lists
983 *
984 * but WCS Paper II uses TPCn_ka in one example and subsequently the
985 * errata for the WCS papers legitimized the use of
986 *
987 * - TPCn_ka and TCDn_ka for pixel lists
988 *
989 * provided that the keyword does not exceed eight characters. This
990 * usage is considered to be safe and is recommended because of the
991 * non-mnemonic terseness of the shorter forms.
992 *
993 * - WCSHDO_PVn_ma: WCS Paper I defined
994 *
995 * - iVn_ma and iSn_ma for bintables and
996 * - TVn_ma and TSn_ma for pixel lists
997 *
998 * but WCS Paper II uses iPVn_ma and TPVn_ma in the examples and
999 * subsequently the errata for the WCS papers legitimized the use of
1000 *
1001 * - iPVn_ma and iPSn_ma for bintables and
1002 * - TPVn_ma and TPSn_ma for pixel lists
1003 *
1004 * provided that the keyword does not exceed eight characters. This
1005 * usage is considered to be safe and is recommended because of the
1006 * non-mnemonic terseness of the shorter forms.
1007 *
1008 * - WCSHDO_CRPXna: For historical reasons WCS Paper I defined
1009 *
1010 * - jCRPXn, iCDLTn, iCUNIn, iCTYPn, and iCRVLn for bintables and
1011 * - TCRPXn, TCDLTn, TCUNIn, TCTYPn, and TCRVLn for pixel lists
1012 *
1013 * for use without an alternate version specifier. However, because
1014 * of the eight-character keyword constraint, in order to accommodate
1015 * column numbers greater than 99 WCS Paper I also defined
1016 *
1017 * - jCRPna, iCDEna, iCUNna, iCTYna and iCRVna for bintables and
1018 * - TCRPna, TCDEna, TCUNna, TCTYna and TCRVna for pixel lists
1019 *
1020 * for use with an alternate version specifier (the "a"). Like the
1021 * PC, CD, PV, and PS keywords there is an obvious tendency to
1022 * confuse these two forms for column numbers up to 99. It is very
1023 * unlikely that any parser would reject keywords in the first set
1024 * with a non-blank alternate version specifier so this usage is
1025 * considered to be safe and is recommended.
1026 *
1027 * - WCSHDO_CNAMna: WCS Papers I and III defined
1028 *
1029 * - iCNAna, iCRDna, and iCSYna for bintables and
1030 * - TCNAna, TCRDna, and TCSYna for pixel lists
1031 *
1032 * By analogy with the above, the long forms would be
1033 *
1034 * - iCNAMna, iCRDEna, and iCSYEna for bintables and
1035 * - TCNAMna, TCRDEna, and TCSYEna for pixel lists
1036 *
1037 * Note that these keywords provide auxiliary information only, none
1038 * of them are needed to compute world coordinates. This usage is
1039 * potentially unsafe and is not recommended at this time.
1040 *
1041 * - WCSHDO_WCSNna: In light of wcsbth() note 4, write WCSNna instead of
1042 * TWCSna for pixel lists. While wcsbth() treats WCSNna and TWCSna
1043 * as equivalent, other parsers may not. Consequently, this usage
1044 * is potentially unsafe and is not recommended at this time.
1045 *
1046 *
1047 * Global variable: const char *wcshdr_errmsg[] - Status return messages
1048 * ---------------------------------------------------------------------
1049 * Error messages to match the status value returned from each function.
1050 * Use wcs_errmsg[] for status returns from wcshdo().
1051 *
1052 *===========================================================================*/
1053 
1054 #ifndef WCSLIB_WCSHDR
1055 #define WCSLIB_WCSHDR
1056 
1057 #include "wcs.h"
1058 
1059 #ifdef __cplusplus
1060 extern "C" {
1061 #endif
1062 
1063 #define WCSHDR_none 0x00000000
1064 #define WCSHDR_all 0x000FFFFF
1065 #define WCSHDR_reject 0x10000000
1066 
1067 #define WCSHDR_CROTAia 0x00000001
1068 #define WCSHDR_EPOCHa 0x00000002
1069 #define WCSHDR_VELREFa 0x00000004
1070 #define WCSHDR_CD00i00j 0x00000008
1071 #define WCSHDR_PC00i00j 0x00000010
1072 #define WCSHDR_PROJPn 0x00000020
1073 #define WCSHDR_RADECSYS 0x00000040
1074 #define WCSHDR_VSOURCE 0x00000080
1075 #define WCSHDR_DOBSn 0x00000100
1076 #define WCSHDR_LONGKEY 0x00000200
1077 #define WCSHDR_CNAMn 0x00000400
1078 #define WCSHDR_AUXIMG 0x00000800
1079 #define WCSHDR_ALLIMG 0x00001000
1080 
1081 #define WCSHDR_IMGHEAD 0x00010000
1082 #define WCSHDR_BIMGARR 0x00020000
1083 #define WCSHDR_PIXLIST 0x00040000
1084 
1085 #define WCSHDO_none 0x00
1086 #define WCSHDO_all 0xFF
1087 #define WCSHDO_safe 0x0F
1088 #define WCSHDO_DOBSn 0x01
1089 #define WCSHDO_TPCn_ka 0x02
1090 #define WCSHDO_PVn_ma 0x04
1091 #define WCSHDO_CRPXna 0x08
1092 #define WCSHDO_CNAMna 0x10
1093 #define WCSHDO_WCSNna 0x20
1094 
1095 
1096 extern const char *wcshdr_errmsg[];
1097 
1099  WCSHDRERR_SUCCESS = 0, /* Success. */
1100  WCSHDRERR_NULL_POINTER = 1, /* Null wcsprm pointer passed. */
1101  WCSHDRERR_MEMORY = 2, /* Memory allocation failed. */
1102  WCSHDRERR_BAD_COLUMN = 3, /* Invalid column selection. */
1103  WCSHDRERR_PARSER = 4, /* Fatal error returned by Flex
1104  parser. */
1105  WCSHDRERR_BAD_TABULAR_PARAMS = 5 /* Invalid tabular parameters. */
1106 };
1107 
1108 int wcspih(char *header, int nkeyrec, int relax, int ctrl, int *nreject,
1109  int *nwcs, struct wcsprm **wcs);
1110 
1111 int wcsbth(char *header, int nkeyrec, int relax, int ctrl, int keysel,
1112  int *colsel, int *nreject, int *nwcs, struct wcsprm **wcs);
1113 
1114 int wcstab(struct wcsprm *wcs);
1115 
1116 int wcsidx(int nwcs, struct wcsprm **wcs, int alts[27]);
1117 
1118 int wcsbdx(int nwcs, struct wcsprm **wcs, int type, short alts[1000][28]);
1119 
1120 int wcsvfree(int *nwcs, struct wcsprm **wcs);
1121 
1122 int wcshdo(int relax, struct wcsprm *wcs, int *nkeyrec, char **header);
1123 
1124 
1125 #ifdef __cplusplus
1126 }
1127 #endif
1128 
1129 #endif /* WCSLIB_WCSHDR */