1
package Astro::FITS::CFITSIO;
6
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD);
12
@ISA = qw(Exporter DynaLoader);
14
my @__names_no_short = qw(
15
fits_get_compression_type
16
fits_set_compression_type
24
# perl -nle "next unless /^\s*#define\s+fits_/; (undef,\$l,\$s) = split ' '; print \"\$s => '\$l',\"" /usr/local/cfitsio/longnam.h
27
ffiurl => 'fits_parse_input_url',
28
ffrtnm => 'fits_parse_rootname',
29
ffrwrg => 'fits_parse_range',
30
ffourl => 'fits_parse_output_url',
31
ffexts => 'fits_parse_extspec',
32
ffextn => 'fits_parse_extnum',
33
ffbins => 'fits_parse_binspec',
34
ffbinr => 'fits_parse_binrange',
35
ffdopn => 'fits_open_data',
36
fftopn => 'fits_open_table',
37
ffiopn => 'fits_open_image',
38
ffomem => 'fits_open_memfile',
39
ffopen => 'fits_open_file',
40
ffreopen => 'fits_reopen_file',
41
ffinit => 'fits_create_file',
42
ffimem => 'fits_create_memfile',
43
fftplt => 'fits_create_template',
44
ffflus => 'fits_flush_file',
45
ffflsh => 'fits_flush_buffer',
46
ffclos => 'fits_close_file',
47
ffdelt => 'fits_delete_file',
48
ffflnm => 'fits_file_name',
49
ffflmd => 'fits_file_mode',
50
ffurlt => 'fits_url_type',
51
ffvers => 'fits_get_version',
52
ffupch => 'fits_uppercase',
53
ffgerr => 'fits_get_errstatus',
54
ffpmsg => 'fits_write_errmsg',
55
ffgmsg => 'fits_read_errmsg',
56
ffcmsg => 'fits_clear_errmsg',
57
ffrprt => 'fits_report_error',
58
ffpmrk => 'fits_write_errmark',
59
ffcmrk => 'fits_clear_errmark',
60
ffcmsg => 'fits_clear_errmsg',
61
ffcmps => 'fits_compare_str',
62
fftkey => 'fits_test_keyword',
63
fftrec => 'fits_test_record',
64
ffnchk => 'fits_null_check',
65
ffkeyn => 'fits_make_keyn',
66
ffnkey => 'fits_make_nkey',
67
ffgkcl => 'fits_get_keyclass',
68
ffdtyp => 'fits_get_keytype',
69
ffpsvc => 'fits_parse_value',
70
ffgknm => 'fits_get_keyname',
71
ffgthd => 'fits_parse_template',
72
ffasfm => 'fits_ascii_tform',
73
ffbnfm => 'fits_binary_tform',
74
ffgabc => 'fits_get_tbcol',
75
ffgrsz => 'fits_get_rowsize',
76
ffgcdw => 'fits_get_col_display_width',
77
ffprec => 'fits_write_record',
78
ffpky => 'fits_write_key',
79
ffpunt => 'fits_write_key_unit',
80
ffpcom => 'fits_write_comment',
81
ffphis => 'fits_write_history',
82
ffpdat => 'fits_write_date',
83
ffgstm => 'fits_get_system_time',
84
ffgsdt => 'fits_get_system_date',
85
ffdt2s => 'fits_date2str',
86
fftm2s => 'fits_time2str',
87
ffs2dt => 'fits_str2date',
88
ffs2tm => 'fits_str2time',
89
ffpkls => 'fits_write_key_longstr',
90
ffplsw => 'fits_write_key_longwarn',
91
ffpkyu => 'fits_write_key_null',
92
ffpkys => 'fits_write_key_str',
93
ffpkyl => 'fits_write_key_log',
94
ffpkyj => 'fits_write_key_lng',
95
ffpkyf => 'fits_write_key_fixflt',
96
ffpkye => 'fits_write_key_flt',
97
ffpkyg => 'fits_write_key_fixdbl',
98
ffpkyd => 'fits_write_key_dbl',
99
ffpkfc => 'fits_write_key_fixcmp',
100
ffpkyc => 'fits_write_key_cmp',
101
ffpkfm => 'fits_write_key_fixdblcmp',
102
ffpkym => 'fits_write_key_dblcmp',
103
ffpkyt => 'fits_write_key_triple',
104
ffptdm => 'fits_write_tdim',
105
ffpkns => 'fits_write_keys_str',
106
ffpknl => 'fits_write_keys_log',
107
ffpknj => 'fits_write_keys_lng',
108
ffpknf => 'fits_write_keys_fixflt',
109
ffpkne => 'fits_write_keys_flt',
110
ffpkng => 'fits_write_keys_fixdbl',
111
ffpknd => 'fits_write_keys_dbl',
112
ffcpky => 'fits_copy_key',
113
ffphps => 'fits_write_imghdr',
114
ffphpr => 'fits_write_grphdr',
115
ffphtb => 'fits_write_atblhdr',
116
ffphbn => 'fits_write_btblhdr',
117
ffpktp => 'fits_write_key_template',
118
ffghsp => 'fits_get_hdrspace',
119
ffghps => 'fits_get_hdrpos',
120
ffmaky => 'fits_movabs_key',
121
ffmrky => 'fits_movrel_key',
122
ffgnxk => 'fits_find_nextkey',
123
ffgrec => 'fits_read_record',
124
ffgcrd => 'fits_read_card',
125
ffgunt => 'fits_read_key_unit',
126
ffgkyn => 'fits_read_keyn',
127
ffgky => 'fits_read_key',
128
ffgkey => 'fits_read_keyword',
129
ffgkys => 'fits_read_key_str',
130
ffgkyl => 'fits_read_key_log',
131
ffgkyj => 'fits_read_key_lng',
132
ffgkye => 'fits_read_key_flt',
133
ffgkyd => 'fits_read_key_dbl',
134
ffgkyc => 'fits_read_key_cmp',
135
ffgkym => 'fits_read_key_dblcmp',
136
ffgkyt => 'fits_read_key_triple',
137
ffgkls => 'fits_read_key_longstr',
138
ffgtdm => 'fits_read_tdim',
139
ffdtdm => 'fits_decode_tdim',
140
ffgkns => 'fits_read_keys_str',
141
ffgknl => 'fits_read_keys_log',
142
ffgknj => 'fits_read_keys_lng',
143
ffgkne => 'fits_read_keys_flt',
144
ffgknd => 'fits_read_keys_dbl',
145
ffghpr => 'fits_read_imghdr',
146
ffghtb => 'fits_read_atblhdr',
147
ffghbn => 'fits_read_btblhdr',
148
ffh2st => 'fits_header2str',
149
ffucrd => 'fits_update_card',
150
ffuky => 'fits_update_key',
151
ffukyu => 'fits_update_key_null',
152
ffukys => 'fits_update_key_str',
153
ffukls => 'fits_update_key_longstr',
154
ffukyl => 'fits_update_key_log',
155
ffukyj => 'fits_update_key_lng',
156
ffukyf => 'fits_update_key_fixflt',
157
ffukye => 'fits_update_key_flt',
158
ffukyg => 'fits_update_key_fixdbl',
159
ffukyd => 'fits_update_key_dbl',
160
ffukfc => 'fits_update_key_fixcmp',
161
ffukyc => 'fits_update_key_cmp',
162
ffukfm => 'fits_update_key_fixdblcmp',
163
ffukym => 'fits_update_key_dblcmp',
164
ffmrec => 'fits_modify_record',
165
ffmcrd => 'fits_modify_card',
166
ffmnam => 'fits_modify_name',
167
ffmcom => 'fits_modify_comment',
168
ffmkyu => 'fits_modify_key_null',
169
ffmkys => 'fits_modify_key_str',
170
ffmkls => 'fits_modify_key_longstr',
171
ffmkyl => 'fits_modify_key_log',
172
ffmkyj => 'fits_modify_key_lng',
173
ffmkyf => 'fits_modify_key_fixflt',
174
ffmkye => 'fits_modify_key_flt',
175
ffmkyg => 'fits_modify_key_fixdbl',
176
ffmkyd => 'fits_modify_key_dbl',
177
ffmkfc => 'fits_modify_key_fixcmp',
178
ffmkyc => 'fits_modify_key_cmp',
179
ffmkfm => 'fits_modify_key_fixdblcmp',
180
ffmkym => 'fits_modify_key_dblcmp',
181
ffikey => 'fits_insert_card',
182
ffirec => 'fits_insert_record',
183
ffikyu => 'fits_insert_key_null',
184
ffikys => 'fits_insert_key_str',
185
ffikls => 'fits_insert_key_longstr',
186
ffikyl => 'fits_insert_key_log',
187
ffikyj => 'fits_insert_key_lng',
188
ffikyf => 'fits_insert_key_fixflt',
189
ffikye => 'fits_insert_key_flt',
190
ffikyg => 'fits_insert_key_fixdbl',
191
ffikyd => 'fits_insert_key_dbl',
192
ffikfc => 'fits_insert_key_fixcmp',
193
ffikyc => 'fits_insert_key_cmp',
194
ffikfm => 'fits_insert_key_fixdblcmp',
195
ffikym => 'fits_insert_key_dblcmp',
196
ffdkey => 'fits_delete_key',
197
ffdrec => 'fits_delete_record',
198
ffghdn => 'fits_get_hdu_num',
199
ffghdt => 'fits_get_hdu_type',
200
ffghad => 'fits_get_hduaddr',
201
ffghof => 'fits_get_hduoff',
202
ffgipr => 'fits_get_img_param',
203
ffgidt => 'fits_get_img_type',
204
ffgiet => 'fits_get_img_equivtype',
205
ffgidm => 'fits_get_img_dim',
206
ffgisz => 'fits_get_img_size',
207
ffmahd => 'fits_movabs_hdu',
208
ffmrhd => 'fits_movrel_hdu',
209
ffmnhd => 'fits_movnam_hdu',
210
ffthdu => 'fits_get_num_hdus',
211
ffcrim => 'fits_create_img',
212
ffcrtb => 'fits_create_tbl',
213
ffcrhd => 'fits_create_hdu',
214
ffiimg => 'fits_insert_img',
215
ffitab => 'fits_insert_atbl',
216
ffibin => 'fits_insert_btbl',
217
ffrsim => 'fits_resize_img',
218
ffdhdu => 'fits_delete_hdu',
219
ffcpfl => 'fits_copy_file',
220
ffcopy => 'fits_copy_hdu',
221
ffcphd => 'fits_copy_header',
222
ffcpdt => 'fits_copy_data',
223
ffrdef => 'fits_set_hdustruc',
224
ffhdef => 'fits_set_hdrsize',
225
ffpthp => 'fits_write_theap',
226
ffesum => 'fits_encode_chksum',
227
ffdsum => 'fits_decode_chksum',
228
ffpcks => 'fits_write_chksum',
229
ffupck => 'fits_update_chksum',
230
ffvcks => 'fits_verify_chksum',
231
ffgcks => 'fits_get_chksum',
232
ffpscl => 'fits_set_bscale',
233
fftscl => 'fits_set_tscale',
234
ffpnul => 'fits_set_imgnull',
235
fftnul => 'fits_set_btblnull',
236
ffsnul => 'fits_set_atblnull',
237
ffgcno => 'fits_get_colnum',
238
ffgcnn => 'fits_get_colname',
239
ffgtcl => 'fits_get_coltype',
240
ffeqty => 'fits_get_eqcoltype',
241
ffgnrw => 'fits_get_num_rows',
242
ffgncl => 'fits_get_num_cols',
243
ffgacl => 'fits_get_acolparms',
244
ffgbcl => 'fits_get_bcolparms',
245
ffiter => 'fits_iterate_data',
246
ffggpb => 'fits_read_grppar_byt',
247
ffggpui => 'fits_read_grppar_usht',
248
ffggpuj => 'fits_read_grppar_ulng',
249
ffggpi => 'fits_read_grppar_sht',
250
ffggpj => 'fits_read_grppar_lng',
251
ffggpk => 'fits_read_grppar_int',
252
ffggpuk => 'fits_read_grppar_uint',
253
ffggpe => 'fits_read_grppar_flt',
254
ffggpd => 'fits_read_grppar_dbl',
255
ffgpxv => 'fits_read_pix',
256
ffgpxf => 'fits_read_pixnull',
257
ffgpv => 'fits_read_img',
258
ffgpf => 'fits_read_imgnull',
259
ffgpvb => 'fits_read_img_byt',
260
ffgpvui => 'fits_read_img_usht',
261
ffgpvuj => 'fits_read_img_ulng',
262
ffgpvi => 'fits_read_img_sht',
263
ffgpvj => 'fits_read_img_lng',
264
ffgpvuk => 'fits_read_img_uint',
265
ffgpvk => 'fits_read_img_int',
266
ffgpve => 'fits_read_img_flt',
267
ffgpvd => 'fits_read_img_dbl',
268
ffgpfb => 'fits_read_imgnull_byt',
269
ffgpfui => 'fits_read_imgnull_usht',
270
ffgpfuj => 'fits_read_imgnull_ulng',
271
ffgpfi => 'fits_read_imgnull_sht',
272
ffgpfj => 'fits_read_imgnull_lng',
273
ffgpfuk => 'fits_read_imgnull_uint',
274
ffgpfk => 'fits_read_imgnull_int',
275
ffgpfe => 'fits_read_imgnull_flt',
276
ffgpfd => 'fits_read_imgnull_dbl',
277
ffg2db => 'fits_read_2d_byt',
278
ffg2dui => 'fits_read_2d_usht',
279
ffg2duj => 'fits_read_2d_ulng',
280
ffg2di => 'fits_read_2d_sht',
281
ffg2dj => 'fits_read_2d_lng',
282
ffg2duk => 'fits_read_2d_uint',
283
ffg2dk => 'fits_read_2d_int',
284
ffg2de => 'fits_read_2d_flt',
285
ffg2dd => 'fits_read_2d_dbl',
286
ffg3db => 'fits_read_3d_byt',
287
ffg3dui => 'fits_read_3d_usht',
288
ffg3duj => 'fits_read_3d_ulng',
289
ffg3di => 'fits_read_3d_sht',
290
ffg3dj => 'fits_read_3d_lng',
291
ffg3duk => 'fits_read_3d_uint',
292
ffg3dk => 'fits_read_3d_int',
293
ffg3de => 'fits_read_3d_flt',
294
ffg3dd => 'fits_read_3d_dbl',
295
ffgsv => 'fits_read_subset',
296
ffgsvb => 'fits_read_subset_byt',
297
ffgsvui => 'fits_read_subset_usht',
298
ffgsvuj => 'fits_read_subset_ulng',
299
ffgsvi => 'fits_read_subset_sht',
300
ffgsvj => 'fits_read_subset_lng',
301
ffgsvuk => 'fits_read_subset_uint',
302
ffgsvk => 'fits_read_subset_int',
303
ffgsve => 'fits_read_subset_flt',
304
ffgsvd => 'fits_read_subset_dbl',
305
ffgsfb => 'fits_read_subsetnull_byt',
306
ffgsfui => 'fits_read_subsetnull_usht',
307
ffgsfuj => 'fits_read_subsetnull_ulng',
308
ffgsfi => 'fits_read_subsetnull_sht',
309
ffgsfj => 'fits_read_subsetnull_lng',
310
ffgsfuk => 'fits_read_subsetnull_uint',
311
ffgsfk => 'fits_read_subsetnull_int',
312
ffgsfe => 'fits_read_subsetnull_flt',
313
ffgsfd => 'fits_read_subsetnull_dbl',
314
fits_comp_img => 'fits_compress_img',
315
fits_decomp_img => 'fits_decompress_img',
316
ffgcv => 'fits_read_col',
317
ffgcf => 'fits_read_colnull',
318
ffgcvs => 'fits_read_col_str',
319
ffgcvl => 'fits_read_col_log',
320
ffgcvb => 'fits_read_col_byt',
321
ffgcvui => 'fits_read_col_usht',
322
ffgcvuj => 'fits_read_col_ulng',
323
ffgcvi => 'fits_read_col_sht',
324
ffgcvj => 'fits_read_col_lng',
325
ffgcvuk => 'fits_read_col_uint',
326
ffgcvk => 'fits_read_col_int',
327
ffgcve => 'fits_read_col_flt',
328
ffgcvd => 'fits_read_col_dbl',
329
ffgcvc => 'fits_read_col_cmp',
330
ffgcvm => 'fits_read_col_dblcmp',
331
ffgcx => 'fits_read_col_bit',
332
ffgcxui => 'fits_read_col_bit_usht',
333
ffgcxuk => 'fits_read_col_bit_uint',
334
ffgcfs => 'fits_read_colnull_str',
335
ffgcfl => 'fits_read_colnull_log',
336
ffgcfb => 'fits_read_colnull_byt',
337
ffgcfui => 'fits_read_colnull_usht',
338
ffgcfuj => 'fits_read_colnull_ulng',
339
ffgcfi => 'fits_read_colnull_sht',
340
ffgcfj => 'fits_read_colnull_lng',
341
ffgcfuk => 'fits_read_colnull_uint',
342
ffgcfk => 'fits_read_colnull_int',
343
ffgcfe => 'fits_read_colnull_flt',
344
ffgcfd => 'fits_read_colnull_dbl',
345
ffgcfc => 'fits_read_colnull_cmp',
346
ffgcfm => 'fits_read_colnull_dblcmp',
347
ffgdes => 'fits_read_descript',
348
ffgdess => 'fits_read_descripts',
349
ffgtbb => 'fits_read_tblbytes',
350
ffpgpb => 'fits_write_grppar_byt',
351
ffpgpui => 'fits_write_grppar_usht',
352
ffpgpuj => 'fits_write_grppar_ulng',
353
ffpgpi => 'fits_write_grppar_sht',
354
ffpgpj => 'fits_write_grppar_lng',
355
ffpgpuk => 'fits_write_grppar_uint',
356
ffpgpk => 'fits_write_grppar_int',
357
ffpgpe => 'fits_write_grppar_flt',
358
ffpgpd => 'fits_write_grppar_dbl',
359
ffppx => 'fits_write_pix',
360
ffppxn => 'fits_write_pixnull',
361
ffppr => 'fits_write_img',
362
ffpprb => 'fits_write_img_byt',
363
ffpprui => 'fits_write_img_usht',
364
ffppruj => 'fits_write_img_ulng',
365
ffppri => 'fits_write_img_sht',
366
ffpprj => 'fits_write_img_lng',
367
ffppruk => 'fits_write_img_uint',
368
ffpprk => 'fits_write_img_int',
369
ffppre => 'fits_write_img_flt',
370
ffpprd => 'fits_write_img_dbl',
371
ffppn => 'fits_write_imgnull',
372
ffppnb => 'fits_write_imgnull_byt',
373
ffppnui => 'fits_write_imgnull_usht',
374
ffppnuj => 'fits_write_imgnull_ulng',
375
ffppni => 'fits_write_imgnull_sht',
376
ffppnj => 'fits_write_imgnull_lng',
377
ffppnuk => 'fits_write_imgnull_uint',
378
ffppnk => 'fits_write_imgnull_int',
379
ffppne => 'fits_write_imgnull_flt',
380
ffppnd => 'fits_write_imgnull_dbl',
381
ffppru => 'fits_write_img_null',
382
ffpprn => 'fits_write_null_img',
383
ffp2db => 'fits_write_2d_byt',
384
ffp2dui => 'fits_write_2d_usht',
385
ffp2duj => 'fits_write_2d_ulng',
386
ffp2di => 'fits_write_2d_sht',
387
ffp2dj => 'fits_write_2d_lng',
388
ffp2duk => 'fits_write_2d_uint',
389
ffp2dk => 'fits_write_2d_int',
390
ffp2de => 'fits_write_2d_flt',
391
ffp2dd => 'fits_write_2d_dbl',
392
ffp3db => 'fits_write_3d_byt',
393
ffp3dui => 'fits_write_3d_usht',
394
ffp3duj => 'fits_write_3d_ulng',
395
ffp3di => 'fits_write_3d_sht',
396
ffp3dj => 'fits_write_3d_lng',
397
ffp3duk => 'fits_write_3d_uint',
398
ffp3dk => 'fits_write_3d_int',
399
ffp3de => 'fits_write_3d_flt',
400
ffp3dd => 'fits_write_3d_dbl',
401
ffpss => 'fits_write_subset',
402
ffpssb => 'fits_write_subset_byt',
403
ffpssui => 'fits_write_subset_usht',
404
ffpssuj => 'fits_write_subset_ulng',
405
ffpssi => 'fits_write_subset_sht',
406
ffpssj => 'fits_write_subset_lng',
407
ffpssuk => 'fits_write_subset_uint',
408
ffpssk => 'fits_write_subset_int',
409
ffpsse => 'fits_write_subset_flt',
410
ffpssd => 'fits_write_subset_dbl',
411
ffpcl => 'fits_write_col',
412
ffpcls => 'fits_write_col_str',
413
ffpcll => 'fits_write_col_log',
414
ffpclb => 'fits_write_col_byt',
415
ffpclui => 'fits_write_col_usht',
416
ffpcluj => 'fits_write_col_ulng',
417
ffpcli => 'fits_write_col_sht',
418
ffpclj => 'fits_write_col_lng',
419
ffpcluk => 'fits_write_col_uint',
420
ffpclk => 'fits_write_col_int',
421
ffpcle => 'fits_write_col_flt',
422
ffpcld => 'fits_write_col_dbl',
423
ffpclc => 'fits_write_col_cmp',
424
ffpclm => 'fits_write_col_dblcmp',
425
ffpclu => 'fits_write_col_null',
426
ffpclx => 'fits_write_col_bit',
427
ffpcn => 'fits_write_colnull',
428
ffpcns => 'fits_write_colnull_str',
429
ffpcnl => 'fits_write_colnull_log',
430
ffpcnb => 'fits_write_colnull_byt',
431
ffpcnui => 'fits_write_colnull_usht',
432
ffpcnuj => 'fits_write_colnull_ulng',
433
ffpcni => 'fits_write_colnull_sht',
434
ffpcnj => 'fits_write_colnull_lng',
435
ffpcnuk => 'fits_write_colnull_uint',
436
ffpcnk => 'fits_write_colnull_int',
437
ffpcne => 'fits_write_colnull_flt',
438
ffpcnd => 'fits_write_colnull_dbl',
439
ffpdes => 'fits_write_descript',
440
ffcmph => 'fits_compress_heap',
441
fftheap => 'fits_test_heap',
442
ffptbb => 'fits_write_tblbytes',
443
ffirow => 'fits_insert_rows',
444
ffdrrg => 'fits_delete_rowrange',
445
ffdrow => 'fits_delete_rows',
446
ffdrws => 'fits_delete_rowlist',
447
fficol => 'fits_insert_col',
448
fficls => 'fits_insert_cols',
449
ffdcol => 'fits_delete_col',
450
ffcpcl => 'fits_copy_col',
451
ffmvec => 'fits_modify_vector_len',
452
ffgics => 'fits_read_img_coord',
453
ffgtcs => 'fits_read_tbl_coord',
454
ffwldp => 'fits_pix_to_world',
455
ffxypx => 'fits_world_to_pix',
456
ffgiwcs => 'fits_get_image_wcs_keys',
457
ffgtwcs => 'fits_get_table_wcs_keys',
458
fffrow => 'fits_find_rows',
459
ffffrw => 'fits_find_first_row',
460
fffrwc => 'fits_find_rows_cmp',
461
ffsrow => 'fits_select_rows',
462
ffcrow => 'fits_calc_rows',
463
ffcalc => 'fits_calculator',
464
ffcalc_rng => 'fits_calculator_rng',
465
fftexp => 'fits_test_expr',
466
ffgtcr => 'fits_create_group',
467
ffgtis => 'fits_insert_group',
468
ffgtch => 'fits_change_group',
469
ffgtrm => 'fits_remove_group',
470
ffgtcp => 'fits_copy_group',
471
ffgtmg => 'fits_merge_groups',
472
ffgtcm => 'fits_compact_group',
473
ffgtvf => 'fits_verify_group',
474
ffgtop => 'fits_open_group',
475
ffgtam => 'fits_add_group_member',
476
ffgtnm => 'fits_get_num_members',
477
ffgmng => 'fits_get_num_groups',
478
ffgmop => 'fits_open_member',
479
ffgmcp => 'fits_copy_member',
480
ffgmtf => 'fits_transfer_member',
481
ffgmrm => 'fits_remove_member',
484
my @__shortnames = keys %__names;
485
my @__longnames = (values(%__names), @__names_no_short);
486
my @__constants = qw(
655
TOO_MANY_HDUS_TRACKED
693
'shortnames' => \@__shortnames,
694
'longnames' => \@__longnames,
695
'constants' => \@__constants,
708
# This AUTOLOAD is used to 'autoload' constants from the constant()
709
# XS function. If a constant is not found then control is passed
710
# to the AUTOLOAD in AutoLoader.
713
($constname = $AUTOLOAD) =~ s/.*:://;
714
croak "& not defined" if $constname eq 'constant';
715
my $val = constant($constname, @_ ? $_[0] : 0);
717
if ($! =~ /Invalid/) {
718
$AutoLoader::AUTOLOAD = $AUTOLOAD;
719
goto &AutoLoader::AUTOLOAD;
722
croak "Your vendor has not defined Astro::FITS::CFITSIO macro $constname";
725
*$AUTOLOAD = sub { $val };
726
#eval "sub $AUTOLOAD { $val }";
730
bootstrap Astro::FITS::CFITSIO $VERSION;
732
# Preloaded methods go here.
734
# Compound routines -- useful routines that combine lower level
735
# Astro::FITS::CFITSIO commands
736
# This routine takes an argument (either a fitsfilePtr object
737
# or a string containing a FITS file name) and returns the header
738
# into a hash along with the exit status of the routine.
739
# If it is called in a scalar context then only the hash reference
742
# $hashref = fits_read_header("test.fits");
743
# ($hashref, $status) = $fitsfile->read_header;
745
# The comments are stored in a hash in $hashref->{COMMENTS}.
747
sub fits_read_header {
749
croak 'Usage: fits_read_header(file|fitsfilePtr)'
752
my ($fitsfile, $status);
753
my ($n, $left, %header, $key, $value, $comment);
758
my $obj_passed = 0; # were we passed a fitsfilePtr?
761
if (UNIVERSAL::isa($file,'fitsfilePtr')) {
766
fits_open_file($fitsfile, $file, READONLY(), $status);
769
# Now we have an open file -- check that status is good before
773
# Get the number of fits keywords in primary header
774
$fitsfile->get_hdrspace($n, $left, $status);
778
last unless $status == 0;
780
$fitsfile->read_keyn($i, $key, $value, $comment, $status);
782
# Store the key/value in a hash
783
$header{$key} = $value;
785
# Store the comments.
786
if (! exists $header{COMMENTS}{$key}) {
787
$header{COMMENTS}{$key} = $comment;
789
# HISTORY keywords, for instance, can be numerous
791
if (! ref $header{COMMENTS}{$key}) {
792
$header{COMMENTS}{$key} = [ $header{COMMENTS}{$key} ];
794
push @{$header{COMMENTS}{$key}}, $comment;
799
# Close the file if we opened it
800
$fitsfile->close_file($status) unless $obj_passed;
803
# Report an error - may not always want to write to STDERR...
804
fits_report_error(*STDERR, $status);
807
return (\%header, $status) if wantarray;
812
# This section provides perl aliases for the OO interface
813
# This is a bit of a kluge since the actual command is in the
814
# Astro::FITS::CFITSIO namespace. Did not open a new namespace with the package
815
# command since AUTOSPLIT gets confused
817
sub fitsfilePtr::read_header {
819
my ($href, $status) = Astro::FITS::CFITSIO::fits_read_header($self);
820
return ($href, $status) if wantarray;
826
# Autoload methods go after =cut, and are processed by the autosplit program.
834
Astro::FITS::CFITSIO - Perl extension for using the cfitsio library
838
use Astro::FITS::CFITSIO;
839
use Astro::FITS::CFITSIO qw( :longnames );
840
use Astro::FITS::CFITSIO qw( :shortnames );
841
use Astro::FITS::CFITSIO qw( :constants );
845
Perl interface to William Pence's cfitsio subroutine library. For more
846
information on cfitsio, see
847
http://heasarc.gsfc.nasa.gov/fitsio.
849
This module attempts to provide a wrapper for nearly every cfitsio routine,
850
while retaining as much cfitsio behavior as possible. As such, one should
851
be aware that it is still somewhat low-level, in the sense that handing an
852
array which is not the correct size to a routine like C<fits_write_img()>
855
My goal is to eventually use these routines to build a more Perl-like
856
interface to many common tasks such as reading and writing of images and
857
ASCII and binary tables.
859
=head1 cfitsio API MAPPING
861
Astro::FITS::CFITSIO allows one to use either the long or short name forms of the
862
cfitsio routines. These work by using the exact same form of arguments
863
as one would find in an equivalent C program.
865
There is also an object-oriented API which uses the same function names
866
as the long-name API, but with the leading "fits_" stripped. To get
867
a Astro::FITS::CFITSIO "object" one would call C<open_file()>, C<create_file()> or
868
C<create_template()>:
871
my $fptr = Astro::FITS::CFITSIO::open_file($filename,
872
Astro::FITS::CFITSIO::READONLY(),$status);
874
$fptr->read_key_str('NAXIS1',$naxis1,undef,$status);
876
Note that the object-oriented forms of function names are only available for
877
those cfitsio routines which accept a C<fitsfile*> data-type as the first
880
As an added benefit, whenever a filehandle goes out of scope, B<ffclos()>
881
is automatically closed:
884
my $fptr = Astro::FITS::CFITSIO::open_file($filename,
885
Astro::FITS::CFITSIO::READWRITE(),$status);
888
# neither of the following are needed
889
# ffclos($fptr,$status);
890
# $fptr->close_file($status);
893
It there is an error, it will B<croak()>.
898
All cfitsio routines, with the exception of C<fits_iterate_data()> and
899
C<fits_open_memfile()>, are available in both long and short name
900
forms (e.g., C<fits_read_key> E<lt>=E<gt> C<ffgky>), as well as all
901
constants defined in the F<fitsio.h> header file. This raises the
902
possibility of your name space being invaded by nearly 1000 function
905
To deal with this situation, Astro::FITS::CFITSIO makes use of the Exporter
906
package support for C<%EXPORT_TAGS>. You can import the long-named functions
909
use Astro::FITS::CFITSIO qw( :longnames );
911
and the short-named routines with
913
use Astro::FITS::CFITSIO qw( :shortnames );
915
Constants are actually implemented as AUTOLOADed functions, so C<TSTRING>, for
916
instance, would be accessed via C<Astro::FITS::CFITSIO::TSTRING()>. Alternatively
919
use Astro::FITS::CFITSIO qw( :constants );
921
which would allow you to simply say C<TSTRING>.
923
=head1 DATA STORAGE DETAILS
925
=head2 Input Variables
927
If a routine expects an N-dimensional array as input, and you hand it a
928
reference to a scalar, then Astro::FITS::CFITSIO simply uses the data in the scalar
929
which the argument is referencing.
930
Otherwise it expects the argument to be a Perl array reference whose total
931
number of elements satisfies the input demands of the corresponding
932
C routine. Astro::FITS::CFITSIO then unpacks the array reference into a format that
933
the C routine can understand. If your input array does not hold enough
934
data for the C routine then a segfault is likely to occur.
936
cfitsio functions which take an optional NULL pointer - indicating no output
937
in that place is desired - can instead be given an C<undef>. In other words,
938
the following C and Perl statements which read a keyword but ignore the
939
comment would be roughly equivalent:
941
fits_read_key_lng(fptr,key,&value,NULL,&status);
943
fits_read_key_lng($fptr,$key,$value,undef,$status);
945
=head2 Output Variables
947
Calling cfitsio routines which read data from FITS files causes the
948
output variable to be transformed into a Perl array of the appropriate
949
dimensions. The exception to this is if one wants the output to be in
950
the machine-native format (e.g., for use with PDL).
951
Then all output variables will become scalars containing the
952
appropriate data. The exception here is with routines which read
953
arrays of strings (e.g., C<fits_read_col_str()>). In this case the
954
output is again a Perl array reference.
956
There are two ways to specify how data are retrieved. The behavior
957
can be specified either globally or on a per filehandle basis. The
958
global selection is done by calling the B<PerlyUnpacking> function.
959
This sets the behavior for I<all> file handles which do not
960
I<explicitly> choose not to follow it.
962
# turn ON unpacking into Perl arrays. This is the default
965
# turn OFF unpacking into Perl arrays, i.e. put in machine-native
969
# retrieve the current state:
970
$state = PerlyUnpacking();
972
To change the behavior for a particular file handle, use the
973
B<perlyunpacking> method. The default behavior for a file handle
974
is to track what is done with B<PerlyUnpacking()>
976
# track PerlyUnpacking(). This is the default
977
$fptr->perlyunpacking(-1);
979
# turn ON unpacking into Perl arrays
980
$fptr->perlyunpacking(1);
982
# turn OFF unpacking into Perl arrays
983
$fptr->perlyunpacking(0);
985
# retrieve the current state:
986
$state = $fptr->perlyunpacking;
991
Take a look at F<testprog/testprog.pl> under the distribution directory. It
993
produce output identical to F<testprog.c> which comes with the cfitsio
994
library. Additionally, the
995
versions named F<testprog_longnames.pl>, F<testprog_OO.pl> and
996
F<testprog_pdl.pl> test the long-name and object-oriented APIs,
997
and machine-native unpacking with PDL.
999
There is also an F<examples/> directory with scripts which do
1004
=item F<image_read.pl>
1006
reads a FITS primary image and displays it using PGPLOT
1008
=item F<image_read_pdl.pl>
1010
same as above, but uses machine-native unpacking with PDL
1012
=item F<bintable_read_pdl.pl>
1014
reads binary table column into PDL object, makes histogram and plots it
1018
=head1 CONSIDERATIONS
1022
=item Ensure your input arrays contain enough data
1024
The caller is responsible for ensuring that the input arrays given
1025
to Astro::FITS::CFITSIO routines are large enough to satisfy the access demands
1026
of said routines. For example, if you tell C<fits_write_col()> to write
1027
a data column containing 100 elements, your Perl array should contain
1028
at least 100 elements. Segfaults abound, so beware!
1030
=item maxdim semantics
1032
Some cfitsio routines take a parameter named something like 'C<maxdim>',
1033
indicating that no more than that many elements should be placed into
1034
the output data area. An example of this would be C<fits_read_tdim()>.
1035
In these cases Astro::FITS::CFITSIO will automatically determine how much storage
1036
space is needed for the full amount of output possible. As a result,
1037
the arguments expected in Astro::FITS::CFITSIO are slightly different than
1038
one would use in a C program, in that the 'C<maxdim>' argument
1041
Currently the routines
1042
for which this is the case are C<fits_read_atblhdr()>, C<fits_read_btblhdr()>,
1043
C<fits_read_imghdr()>, C<fits_decode_tdim()>, C<fits_read_tdim()>
1044
C<fits_test_expr()>, C<fits_get_img_parm()> and C<fits_get_img_size()>.
1046
=item Output arrays remain as undisturbed as possible
1048
For routines like C<fits_read_col()>, Astro::FITS::CFITSIO unpacks the output into
1049
a Perl array reference (unless C<PerlyUnpacking(0)> has been called, of
1050
course). Prior to doing this, it ensures the scalar passed is a reference
1051
to an array large enough to hold the data. If the argument is an
1052
array reference which is too small, it expands the array pointed to
1053
appropriately. B<But>, if the array is large enough already, the data
1054
are just unpacked into the array. The upshot: If you call
1055
C<fits_read_col()>, telling it to read 100 data elements, and the array
1056
you are placing the data into already has 200 elements, then after
1057
C<fits_read_col()> returns your array will still have 200 elements, only
1058
the first 100 of which actually correspond to the data read by the routine.
1060
In more succinct language:
1063
fits_read_col_lng($fptr,2,1,1,100,0,\@output,$anynul,$status);
1065
# @output still has 200 elements, only first 100 are from FITS
1070
=head1 EXTRA COMMANDS
1072
Some extra commands that use sets of cfitsio routines are supplied to
1073
simplify some standard tasks:
1077
=item fits_read_header(filename)
1079
This command reads in a primary fits header (unless one is using the extended
1080
filename sytax to move to a different HDU on open) from the specified filename
1081
and returns the header as a hash reference and a status (when called
1082
in an array context) or simply a hash reference (when called in a scalar
1085
($hash_ref, $status) = fits_read_header ($file);
1086
$hash_ref = fits_read_header($file);
1088
An object-oriented interface is also provided for reading headers from
1089
FITS files that have already been opened. In this case, the header
1090
read is from the current HDU.
1092
$fitsfile = Astro::FITS::CFITSIO::open_file($file);
1093
$hash_ref = $fitsfile->read_header;
1094
($hash_ref, $status) = $fitsfile->read_header;
1096
=item sizeof_datatype(datatype)
1098
Returns the size of the given Astro::FITS::CFITSIO datatype constant (e.g., C<Astro::FITS::CFITSIO::TSHORT()>).
1108
Pete Ratzlaff <pratzlaff@cfa.harvard.edu>, with a great deal of code taken
1109
from Karl Glazebrook's PGPLOT module.
1111
Contributors include:
1115
=item Tim Jenness <t.jenness@jach.hawaii.edu>
1117
convenience routines
1119
=item Tim Conrow <tim@ipac.caltech.edu>
1121
function implementations, bug fixes