2
/* This file, getcol.c, contains routines that read data elements from */
3
/* a FITS image or table. There are generic datatype routines. */
5
/* The FITSIO software was written by William Pence at the High Energy */
6
/* Astrophysic Science Archive Research Center (HEASARC) at the NASA */
7
/* Goddard Space Flight Center. */
12
/*--------------------------------------------------------------------------*/
13
int ffgpxv( fitsfile *fptr, /* I - FITS file pointer */
14
int datatype, /* I - datatype of the value */
15
long *firstpix, /* I - coord of first pixel to read (1s based) */
16
LONGLONG nelem, /* I - number of values to read */
17
void *nulval, /* I - value for undefined pixels */
18
void *array, /* O - array of values that are returned */
19
int *anynul, /* O - set to 1 if any values are null; else 0 */
20
int *status) /* IO - error status */
22
Read an array of values from the primary array. The datatype of the
23
input array is defined by the 2nd argument. Data conversion
24
and scaling will be performed if necessary (e.g, if the datatype of
25
the FITS array is not the same as the array being read).
26
Undefined elements will be set equal to NULVAL, unless NULVAL=0
27
in which case no checking for undefined values will be performed.
28
ANYNUL is returned with a value of .true. if any pixels are undefined.
31
LONGLONG tfirstpix[99];
34
if (*status > 0 || nelem == 0) /* inherit input status value if > 0 */
37
/* get the size of the image */
38
ffgidm(fptr, &naxis, status);
40
for (ii=0; ii < naxis; ii++)
41
tfirstpix[ii] = firstpix[ii];
43
ffgpxvll(fptr, datatype, tfirstpix, nelem, nulval, array, anynul, status);
47
/*--------------------------------------------------------------------------*/
48
int ffgpxvll( fitsfile *fptr, /* I - FITS file pointer */
49
int datatype, /* I - datatype of the value */
50
LONGLONG *firstpix, /* I - coord of first pixel to read (1s based) */
51
LONGLONG nelem, /* I - number of values to read */
52
void *nulval, /* I - value for undefined pixels */
53
void *array, /* O - array of values that are returned */
54
int *anynul, /* O - set to 1 if any values are null; else 0 */
55
int *status) /* IO - error status */
57
Read an array of values from the primary array. The datatype of the
58
input array is defined by the 2nd argument. Data conversion
59
and scaling will be performed if necessary (e.g, if the datatype of
60
the FITS array is not the same as the array being read).
61
Undefined elements will be set equal to NULVAL, unless NULVAL=0
62
in which case no checking for undefined values will be performed.
63
ANYNUL is returned with a value of .true. if any pixels are undefined.
69
LONGLONG naxes[9], trc[9]= {1,1,1,1,1,1,1,1,1};
70
long inc[9]= {1,1,1,1,1,1,1,1,1};
71
LONGLONG dimsize = 1, firstelem;
73
if (*status > 0 || nelem == 0) /* inherit input status value if > 0 */
76
/* get the size of the image */
77
ffgidm(fptr, &naxis, status);
79
ffgiszll(fptr, 9, naxes, status);
81
if (naxis == 0 || naxes[0] == 0) {
86
/* calculate the position of the first element in the array */
88
for (ii=0; ii < naxis; ii++)
90
firstelem += ((firstpix[ii] - 1) * dimsize);
92
trc[ii] = firstpix[ii];
96
if (fits_is_compressed_image(fptr, status))
98
/* this is a compressed image in a binary table */
100
/* test for special case of reading an integral number of */
101
/* rows in a 2D or 3D image (which includes reading the whole image */
103
if (naxis > 1 && naxis < 4 && firstpix[0] == 1 &&
104
(nelem / naxes[0]) * naxes[0] == nelem) {
106
/* calculate coordinate of last pixel */
107
trc[0] = naxes[0]; /* reading whole rows */
108
trc[1] = firstpix[1] + (nelem / naxes[0] - 1);
109
while (trc[1] > naxes[1]) {
110
trc[1] = trc[1] - naxes[1];
111
trc[2] = trc[2] + 1; /* increment to next plane of cube */
114
fits_read_compressed_img(fptr, datatype, firstpix, trc, inc,
115
1, nulval, array, NULL, anynul, status);
119
fits_read_compressed_pixels(fptr, datatype, firstelem,
120
nelem, nullcheck, nulval, array, NULL, anynul, status);
127
the primary array is represented as a binary table:
128
each group of the primary array is a row in the table,
129
where the first column contains the group parameters
130
and the second column contains the image itself.
133
if (datatype == TBYTE)
136
ffgclb(fptr, 2, 1, firstelem, nelem, 1, 1, 0,
137
(unsigned char *) array, &cdummy, anynul, status);
139
ffgclb(fptr, 2, 1, firstelem, nelem, 1, 1, *(unsigned char *) nulval,
140
(unsigned char *) array, &cdummy, anynul, status);
142
else if (datatype == TSBYTE)
145
ffgclsb(fptr, 2, 1, firstelem, nelem, 1, 1, 0,
146
(signed char *) array, &cdummy, anynul, status);
148
ffgclsb(fptr, 2, 1, firstelem, nelem, 1, 1, *(signed char *) nulval,
149
(signed char *) array, &cdummy, anynul, status);
151
else if (datatype == TUSHORT)
154
ffgclui(fptr, 2, 1, firstelem, nelem, 1, 1, 0,
155
(unsigned short *) array, &cdummy, anynul, status);
157
ffgclui(fptr, 2, 1, firstelem, nelem, 1, 1, *(unsigned short *) nulval,
158
(unsigned short *) array, &cdummy, anynul, status);
160
else if (datatype == TSHORT)
163
ffgcli(fptr, 2, 1, firstelem, nelem, 1, 1, 0,
164
(short *) array, &cdummy, anynul, status);
166
ffgcli(fptr, 2, 1, firstelem, nelem, 1, 1, *(short *) nulval,
167
(short *) array, &cdummy, anynul, status);
169
else if (datatype == TUINT)
172
ffgcluk(fptr, 2, 1, firstelem, nelem, 1, 1, 0,
173
(unsigned int *) array, &cdummy, anynul, status);
175
ffgcluk(fptr, 2, 1, firstelem, nelem, 1, 1, *(unsigned int *) nulval,
176
(unsigned int *) array, &cdummy, anynul, status);
178
else if (datatype == TINT)
181
ffgclk(fptr, 2, 1, firstelem, nelem, 1, 1, 0,
182
(int *) array, &cdummy, anynul, status);
184
ffgclk(fptr, 2, 1, firstelem, nelem, 1, 1, *(int *) nulval,
185
(int *) array, &cdummy, anynul, status);
187
else if (datatype == TULONG)
190
ffgcluj(fptr, 2, 1, firstelem, nelem, 1, 1, 0,
191
(unsigned long *) array, &cdummy, anynul, status);
193
ffgcluj(fptr, 2, 1, firstelem, nelem, 1, 1, *(unsigned long *) nulval,
194
(unsigned long *) array, &cdummy, anynul, status);
196
else if (datatype == TLONG)
199
ffgclj(fptr, 2, 1, firstelem, nelem, 1, 1, 0,
200
(long *) array, &cdummy, anynul, status);
202
ffgclj(fptr, 2, 1, firstelem, nelem, 1, 1, *(long *) nulval,
203
(long *) array, &cdummy, anynul, status);
205
else if (datatype == TLONGLONG)
208
ffgcljj(fptr, 2, 1, firstelem, nelem, 1, 1, 0,
209
(LONGLONG *) array, &cdummy, anynul, status);
211
ffgcljj(fptr, 2, 1, firstelem, nelem, 1, 1, *(LONGLONG *) nulval,
212
(LONGLONG *) array, &cdummy, anynul, status);
214
else if (datatype == TFLOAT)
217
ffgcle(fptr, 2, 1, firstelem, nelem, 1, 1, 0,
218
(float *) array, &cdummy, anynul, status);
220
ffgcle(fptr, 2, 1, firstelem, nelem, 1, 1, *(float *) nulval,
221
(float *) array, &cdummy, anynul, status);
223
else if (datatype == TDOUBLE)
226
ffgcld(fptr, 2, 1, firstelem, nelem, 1, 1, 0,
227
(double *) array, &cdummy, anynul, status);
229
ffgcld(fptr, 2, 1, firstelem, nelem, 1, 1, *(double *) nulval,
230
(double *) array, &cdummy, anynul, status);
233
*status = BAD_DATATYPE;
237
/*--------------------------------------------------------------------------*/
238
int ffgpxf( fitsfile *fptr, /* I - FITS file pointer */
239
int datatype, /* I - datatype of the value */
240
long *firstpix, /* I - coord of first pixel to read (1s based) */
241
LONGLONG nelem, /* I - number of values to read */
242
void *array, /* O - array of values that are returned */
243
char *nullarray, /* O - returned array of null value flags */
244
int *anynul, /* O - set to 1 if any values are null; else 0 */
245
int *status) /* IO - error status */
247
Read an array of values from the primary array. The datatype of the
248
input array is defined by the 2nd argument. Data conversion
249
and scaling will be performed if necessary (e.g, if the datatype of
250
the FITS array is not the same as the array being read).
251
The nullarray values will = 1 if the corresponding array value is null.
252
ANYNUL is returned with a value of .true. if any pixels are undefined.
255
LONGLONG tfirstpix[99];
258
if (*status > 0 || nelem == 0) /* inherit input status value if > 0 */
261
/* get the size of the image */
262
ffgidm(fptr, &naxis, status);
264
for (ii=0; ii < naxis; ii++)
265
tfirstpix[ii] = firstpix[ii];
267
ffgpxfll(fptr, datatype, tfirstpix, nelem, array, nullarray, anynul, status);
271
/*--------------------------------------------------------------------------*/
272
int ffgpxfll( fitsfile *fptr, /* I - FITS file pointer */
273
int datatype, /* I - datatype of the value */
274
LONGLONG *firstpix, /* I - coord of first pixel to read (1s based) */
275
LONGLONG nelem, /* I - number of values to read */
276
void *array, /* O - array of values that are returned */
277
char *nullarray, /* O - returned array of null value flags */
278
int *anynul, /* O - set to 1 if any values are null; else 0 */
279
int *status) /* IO - error status */
281
Read an array of values from the primary array. The datatype of the
282
input array is defined by the 2nd argument. Data conversion
283
and scaling will be performed if necessary (e.g, if the datatype of
284
the FITS array is not the same as the array being read).
285
The nullarray values will = 1 if the corresponding array value is null.
286
ANYNUL is returned with a value of .true. if any pixels are undefined.
292
LONGLONG dimsize = 1, firstelem;
294
if (*status > 0 || nelem == 0) /* inherit input status value if > 0 */
297
/* get the size of the image */
298
ffgidm(fptr, &naxis, status);
299
ffgiszll(fptr, 9, naxes, status);
301
/* calculate the position of the first element in the array */
303
for (ii=0; ii < naxis; ii++)
305
firstelem += ((firstpix[ii] - 1) * dimsize);
306
dimsize *= naxes[ii];
310
if (fits_is_compressed_image(fptr, status))
312
/* this is a compressed image in a binary table */
314
fits_read_compressed_pixels(fptr, datatype, firstelem, nelem,
315
nullcheck, NULL, array, nullarray, anynul, status);
320
the primary array is represented as a binary table:
321
each group of the primary array is a row in the table,
322
where the first column contains the group parameters
323
and the second column contains the image itself.
326
if (datatype == TBYTE)
328
ffgclb(fptr, 2, 1, firstelem, nelem, 1, 2, 0,
329
(unsigned char *) array, nullarray, anynul, status);
331
else if (datatype == TSBYTE)
333
ffgclsb(fptr, 2, 1, firstelem, nelem, 1, 2, 0,
334
(signed char *) array, nullarray, anynul, status);
336
else if (datatype == TUSHORT)
338
ffgclui(fptr, 2, 1, firstelem, nelem, 1, 2, 0,
339
(unsigned short *) array, nullarray, anynul, status);
341
else if (datatype == TSHORT)
343
ffgcli(fptr, 2, 1, firstelem, nelem, 1, 2, 0,
344
(short *) array, nullarray, anynul, status);
346
else if (datatype == TUINT)
348
ffgcluk(fptr, 2, 1, firstelem, nelem, 1, 2, 0,
349
(unsigned int *) array, nullarray, anynul, status);
351
else if (datatype == TINT)
353
ffgclk(fptr, 2, 1, firstelem, nelem, 1, 2, 0,
354
(int *) array, nullarray, anynul, status);
356
else if (datatype == TULONG)
358
ffgcluj(fptr, 2, 1, firstelem, nelem, 1, 2, 0,
359
(unsigned long *) array, nullarray, anynul, status);
361
else if (datatype == TLONG)
363
ffgclj(fptr, 2, 1, firstelem, nelem, 1, 2, 0,
364
(long *) array, nullarray, anynul, status);
366
else if (datatype == TLONGLONG)
368
ffgcljj(fptr, 2, 1, firstelem, nelem, 1, 2, 0,
369
(LONGLONG *) array, nullarray, anynul, status);
371
else if (datatype == TFLOAT)
373
ffgcle(fptr, 2, 1, firstelem, nelem, 1, 2, 0,
374
(float *) array, nullarray, anynul, status);
376
else if (datatype == TDOUBLE)
378
ffgcld(fptr, 2, 1, firstelem, nelem, 1, 2, 0,
379
(double *) array, nullarray, anynul, status);
382
*status = BAD_DATATYPE;
386
/*--------------------------------------------------------------------------*/
387
int ffgsv( fitsfile *fptr, /* I - FITS file pointer */
388
int datatype, /* I - datatype of the value */
389
long *blc, /* I - 'bottom left corner' of the subsection */
390
long *trc , /* I - 'top right corner' of the subsection */
391
long *inc, /* I - increment to be applied in each dim. */
392
void *nulval, /* I - value for undefined pixels */
393
void *array, /* O - array of values that are returned */
394
int *anynul, /* O - set to 1 if any values are null; else 0 */
395
int *status) /* IO - error status */
397
Read an section of values from the primary array. The datatype of the
398
input array is defined by the 2nd argument. Data conversion
399
and scaling will be performed if necessary (e.g, if the datatype of
400
the FITS array is not the same as the array being read).
401
Undefined elements will be set equal to NULVAL, unless NULVAL=0
402
in which case no checking for undefined values will be performed.
403
ANYNUL is returned with a value of .true. if any pixels are undefined.
410
if (*status > 0) /* inherit input status value if > 0 */
413
/* get the size of the image */
414
ffgidm(fptr, &naxis, status);
415
ffgisz(fptr, 9, naxes, status);
417
/* test for the important special case where we are reading the whole image */
418
/* this is only useful for images that are not tile-compressed */
419
if (!fits_is_compressed_image(fptr, status)) {
420
for (ii = 0; ii < naxis; ii++) {
421
if (inc[ii] != 1 || blc[ii] !=1 || trc[ii] != naxes[ii])
424
nelem = nelem * naxes[ii];
428
/* read the whole image more efficiently */
429
ffgpxv(fptr, datatype, blc, nelem, nulval, array, anynul, status);
434
if (datatype == TBYTE)
437
ffgsvb(fptr, 1, naxis, naxes, blc, trc, inc, 0,
438
(unsigned char *) array, anynul, status);
440
ffgsvb(fptr, 1, naxis, naxes, blc, trc, inc, *(unsigned char *) nulval,
441
(unsigned char *) array, anynul, status);
443
else if (datatype == TSBYTE)
446
ffgsvsb(fptr, 1, naxis, naxes, blc, trc, inc, 0,
447
(signed char *) array, anynul, status);
449
ffgsvsb(fptr, 1, naxis, naxes, blc, trc, inc, *(signed char *) nulval,
450
(signed char *) array, anynul, status);
452
else if (datatype == TUSHORT)
455
ffgsvui(fptr, 1, naxis, naxes, blc, trc, inc, 0,
456
(unsigned short *) array, anynul, status);
458
ffgsvui(fptr, 1, naxis, naxes,blc, trc, inc, *(unsigned short *) nulval,
459
(unsigned short *) array, anynul, status);
461
else if (datatype == TSHORT)
464
ffgsvi(fptr, 1, naxis, naxes, blc, trc, inc, 0,
465
(short *) array, anynul, status);
467
ffgsvi(fptr, 1, naxis, naxes, blc, trc, inc, *(short *) nulval,
468
(short *) array, anynul, status);
470
else if (datatype == TUINT)
473
ffgsvuk(fptr, 1, naxis, naxes, blc, trc, inc, 0,
474
(unsigned int *) array, anynul, status);
476
ffgsvuk(fptr, 1, naxis, naxes, blc, trc, inc, *(unsigned int *) nulval,
477
(unsigned int *) array, anynul, status);
479
else if (datatype == TINT)
482
ffgsvk(fptr, 1, naxis, naxes, blc, trc, inc, 0,
483
(int *) array, anynul, status);
485
ffgsvk(fptr, 1, naxis, naxes, blc, trc, inc, *(int *) nulval,
486
(int *) array, anynul, status);
488
else if (datatype == TULONG)
491
ffgsvuj(fptr, 1, naxis, naxes, blc, trc, inc, 0,
492
(unsigned long *) array, anynul, status);
494
ffgsvuj(fptr, 1, naxis, naxes, blc, trc, inc, *(unsigned long *) nulval,
495
(unsigned long *) array, anynul, status);
497
else if (datatype == TLONG)
500
ffgsvj(fptr, 1, naxis, naxes, blc, trc, inc, 0,
501
(long *) array, anynul, status);
503
ffgsvj(fptr, 1, naxis, naxes, blc, trc, inc, *(long *) nulval,
504
(long *) array, anynul, status);
506
else if (datatype == TLONGLONG)
509
ffgsvjj(fptr, 1, naxis, naxes, blc, trc, inc, 0,
510
(LONGLONG *) array, anynul, status);
512
ffgsvjj(fptr, 1, naxis, naxes, blc, trc, inc, *(LONGLONG *) nulval,
513
(LONGLONG *) array, anynul, status);
515
else if (datatype == TFLOAT)
518
ffgsve(fptr, 1, naxis, naxes, blc, trc, inc, 0,
519
(float *) array, anynul, status);
521
ffgsve(fptr, 1, naxis, naxes, blc, trc, inc, *(float *) nulval,
522
(float *) array, anynul, status);
524
else if (datatype == TDOUBLE)
527
ffgsvd(fptr, 1, naxis, naxes, blc, trc, inc, 0,
528
(double *) array, anynul, status);
530
ffgsvd(fptr, 1, naxis, naxes, blc, trc, inc, *(double *) nulval,
531
(double *) array, anynul, status);
534
*status = BAD_DATATYPE;
538
/*--------------------------------------------------------------------------*/
539
int ffgpv( fitsfile *fptr, /* I - FITS file pointer */
540
int datatype, /* I - datatype of the value */
541
LONGLONG firstelem, /* I - first vector element to read (1 = 1st) */
542
LONGLONG nelem, /* I - number of values to read */
543
void *nulval, /* I - value for undefined pixels */
544
void *array, /* O - array of values that are returned */
545
int *anynul, /* O - set to 1 if any values are null; else 0 */
546
int *status) /* IO - error status */
548
Read an array of values from the primary array. The datatype of the
549
input array is defined by the 2nd argument. Data conversion
550
and scaling will be performed if necessary (e.g, if the datatype of
551
the FITS array is not the same as the array being read).
552
Undefined elements will be set equal to NULVAL, unless NULVAL=0
553
in which case no checking for undefined values will be performed.
554
ANYNUL is returned with a value of .true. if any pixels are undefined.
558
if (*status > 0 || nelem == 0) /* inherit input status value if > 0 */
562
the primary array is represented as a binary table:
563
each group of the primary array is a row in the table,
564
where the first column contains the group parameters
565
and the second column contains the image itself.
568
if (datatype == TBYTE)
571
ffgpvb(fptr, 1, firstelem, nelem, 0,
572
(unsigned char *) array, anynul, status);
574
ffgpvb(fptr, 1, firstelem, nelem, *(unsigned char *) nulval,
575
(unsigned char *) array, anynul, status);
577
else if (datatype == TSBYTE)
580
ffgpvsb(fptr, 1, firstelem, nelem, 0,
581
(signed char *) array, anynul, status);
583
ffgpvsb(fptr, 1, firstelem, nelem, *(signed char *) nulval,
584
(signed char *) array, anynul, status);
586
else if (datatype == TUSHORT)
589
ffgpvui(fptr, 1, firstelem, nelem, 0,
590
(unsigned short *) array, anynul, status);
592
ffgpvui(fptr, 1, firstelem, nelem, *(unsigned short *) nulval,
593
(unsigned short *) array, anynul, status);
595
else if (datatype == TSHORT)
598
ffgpvi(fptr, 1, firstelem, nelem, 0,
599
(short *) array, anynul, status);
601
ffgpvi(fptr, 1, firstelem, nelem, *(short *) nulval,
602
(short *) array, anynul, status);
604
else if (datatype == TUINT)
607
ffgpvuk(fptr, 1, firstelem, nelem, 0,
608
(unsigned int *) array, anynul, status);
610
ffgpvuk(fptr, 1, firstelem, nelem, *(unsigned int *) nulval,
611
(unsigned int *) array, anynul, status);
613
else if (datatype == TINT)
616
ffgpvk(fptr, 1, firstelem, nelem, 0,
617
(int *) array, anynul, status);
619
ffgpvk(fptr, 1, firstelem, nelem, *(int *) nulval,
620
(int *) array, anynul, status);
622
else if (datatype == TULONG)
625
ffgpvuj(fptr, 1, firstelem, nelem, 0,
626
(unsigned long *) array, anynul, status);
628
ffgpvuj(fptr, 1, firstelem, nelem, *(unsigned long *) nulval,
629
(unsigned long *) array, anynul, status);
631
else if (datatype == TLONG)
634
ffgpvj(fptr, 1, firstelem, nelem, 0,
635
(long *) array, anynul, status);
637
ffgpvj(fptr, 1, firstelem, nelem, *(long *) nulval,
638
(long *) array, anynul, status);
640
else if (datatype == TLONGLONG)
643
ffgpvjj(fptr, 1, firstelem, nelem, 0,
644
(LONGLONG *) array, anynul, status);
646
ffgpvjj(fptr, 1, firstelem, nelem, *(LONGLONG *) nulval,
647
(LONGLONG *) array, anynul, status);
649
else if (datatype == TFLOAT)
652
ffgpve(fptr, 1, firstelem, nelem, 0,
653
(float *) array, anynul, status);
655
ffgpve(fptr, 1, firstelem, nelem, *(float *) nulval,
656
(float *) array, anynul, status);
658
else if (datatype == TDOUBLE)
661
ffgpvd(fptr, 1, firstelem, nelem, 0,
662
(double *) array, anynul, status);
665
ffgpvd(fptr, 1, firstelem, nelem, *(double *) nulval,
666
(double *) array, anynul, status);
670
*status = BAD_DATATYPE;
674
/*--------------------------------------------------------------------------*/
675
int ffgpf( fitsfile *fptr, /* I - FITS file pointer */
676
int datatype, /* I - datatype of the value */
677
LONGLONG firstelem, /* I - first vector element to read (1 = 1st) */
678
LONGLONG nelem, /* I - number of values to read */
679
void *array, /* O - array of values that are returned */
680
char *nullarray, /* O - array of null value flags */
681
int *anynul, /* O - set to 1 if any values are null; else 0 */
682
int *status) /* IO - error status */
684
Read an array of values from the primary array. The datatype of the
685
input array is defined by the 2nd argument. Data conversion
686
and scaling will be performed if necessary (e.g, if the datatype of
687
the FITS array is not the same as the array being read).
688
The nullarray values will = 1 if the corresponding array value is null.
689
ANYNUL is returned with a value of .true. if any pixels are undefined.
693
if (*status > 0 || nelem == 0) /* inherit input status value if > 0 */
697
the primary array is represented as a binary table:
698
each group of the primary array is a row in the table,
699
where the first column contains the group parameters
700
and the second column contains the image itself.
703
if (datatype == TBYTE)
705
ffgpfb(fptr, 1, firstelem, nelem,
706
(unsigned char *) array, nullarray, anynul, status);
708
else if (datatype == TSBYTE)
710
ffgpfsb(fptr, 1, firstelem, nelem,
711
(signed char *) array, nullarray, anynul, status);
713
else if (datatype == TUSHORT)
715
ffgpfui(fptr, 1, firstelem, nelem,
716
(unsigned short *) array, nullarray, anynul, status);
718
else if (datatype == TSHORT)
720
ffgpfi(fptr, 1, firstelem, nelem,
721
(short *) array, nullarray, anynul, status);
723
else if (datatype == TUINT)
725
ffgpfuk(fptr, 1, firstelem, nelem,
726
(unsigned int *) array, nullarray, anynul, status);
728
else if (datatype == TINT)
730
ffgpfk(fptr, 1, firstelem, nelem,
731
(int *) array, nullarray, anynul, status);
733
else if (datatype == TULONG)
735
ffgpfuj(fptr, 1, firstelem, nelem,
736
(unsigned long *) array, nullarray, anynul, status);
738
else if (datatype == TLONG)
740
ffgpfj(fptr, 1, firstelem, nelem,
741
(long *) array, nullarray, anynul, status);
743
else if (datatype == TLONGLONG)
745
ffgpfjj(fptr, 1, firstelem, nelem,
746
(LONGLONG *) array, nullarray, anynul, status);
748
else if (datatype == TFLOAT)
750
ffgpfe(fptr, 1, firstelem, nelem,
751
(float *) array, nullarray, anynul, status);
753
else if (datatype == TDOUBLE)
755
ffgpfd(fptr, 1, firstelem, nelem,
756
(double *) array, nullarray, anynul, status);
759
*status = BAD_DATATYPE;
763
/*--------------------------------------------------------------------------*/
764
int ffgcv( fitsfile *fptr, /* I - FITS file pointer */
765
int datatype, /* I - datatype of the value */
766
int colnum, /* I - number of column to write (1 = 1st col) */
767
LONGLONG firstrow, /* I - first row to write (1 = 1st row) */
768
LONGLONG firstelem, /* I - first vector element to read (1 = 1st) */
769
LONGLONG nelem, /* I - number of values to read */
770
void *nulval, /* I - value for undefined pixels */
771
void *array, /* O - array of values that are returned */
772
int *anynul, /* O - set to 1 if any values are null; else 0 */
773
int *status) /* IO - error status */
775
Read an array of values from a table column. The datatype of the
776
input array is defined by the 2nd argument. Data conversion
777
and scaling will be performed if necessary (e.g, if the datatype of
778
the FITS array is not the same as the array being read).
779
Undefined elements will be set equal to NULVAL, unless NULVAL=0
780
in which case no checking for undefined values will be performed.
781
ANYNUL is returned with a value of true if any pixels are undefined.
786
if (*status > 0) /* inherit input status value if > 0 */
789
if (datatype == TBIT)
791
ffgcx(fptr, colnum, firstrow, firstelem, nelem, (char *) array, status);
793
else if (datatype == TBYTE)
796
ffgclb(fptr, colnum, firstrow, firstelem, nelem, 1, 1, 0,
797
(unsigned char *) array, cdummy, anynul, status);
799
ffgclb(fptr, colnum, firstrow, firstelem, nelem, 1, 1, *(unsigned char *)
800
nulval, (unsigned char *) array, cdummy, anynul, status);
802
else if (datatype == TSBYTE)
805
ffgclsb(fptr, colnum, firstrow, firstelem, nelem, 1, 1, 0,
806
(signed char *) array, cdummy, anynul, status);
808
ffgclsb(fptr, colnum, firstrow, firstelem, nelem, 1, 1, *(signed char *)
809
nulval, (signed char *) array, cdummy, anynul, status);
811
else if (datatype == TUSHORT)
814
ffgclui(fptr, colnum, firstrow, firstelem, nelem, 1, 1, 0,
815
(unsigned short *) array, cdummy, anynul, status);
817
ffgclui(fptr, colnum, firstrow, firstelem, nelem, 1, 1,
818
*(unsigned short *) nulval,
819
(unsigned short *) array, cdummy, anynul, status);
821
else if (datatype == TSHORT)
824
ffgcli(fptr, colnum, firstrow, firstelem, nelem, 1, 1, 0,
825
(short *) array, cdummy, anynul, status);
827
ffgcli(fptr, colnum, firstrow, firstelem, nelem, 1, 1, *(short *)
828
nulval, (short *) array, cdummy, anynul, status);
830
else if (datatype == TUINT)
833
ffgcluk(fptr, colnum, firstrow, firstelem, nelem, 1, 1, 0,
834
(unsigned int *) array, cdummy, anynul, status);
836
ffgcluk(fptr, colnum, firstrow, firstelem, nelem, 1, 1,
837
*(unsigned int *) nulval, (unsigned int *) array, cdummy, anynul,
840
else if (datatype == TINT)
843
ffgclk(fptr, colnum, firstrow, firstelem, nelem, 1, 1, 0,
844
(int *) array, cdummy, anynul, status);
846
ffgclk(fptr, colnum, firstrow, firstelem, nelem, 1, 1, *(int *)
847
nulval, (int *) array, cdummy, anynul, status);
849
else if (datatype == TULONG)
852
ffgcluj(fptr, colnum, firstrow, firstelem, nelem, 1, 1, 0,
853
(unsigned long *) array, cdummy, anynul, status);
855
ffgcluj(fptr, colnum, firstrow, firstelem, nelem, 1, 1,
856
*(unsigned long *) nulval,
857
(unsigned long *) array, cdummy, anynul, status);
859
else if (datatype == TLONG)
862
ffgclj(fptr, colnum, firstrow, firstelem, nelem, 1, 1, 0,
863
(long *) array, cdummy, anynul, status);
865
ffgclj(fptr, colnum, firstrow, firstelem, nelem, 1, 1, *(long *)
866
nulval, (long *) array, cdummy, anynul, status);
868
else if (datatype == TLONGLONG)
871
ffgcljj(fptr, colnum, firstrow, firstelem, nelem, 1, 1, 0,
872
(LONGLONG *) array, cdummy, anynul, status);
874
ffgcljj(fptr, colnum, firstrow, firstelem, nelem, 1, 1, *(LONGLONG *)
875
nulval, (LONGLONG *) array, cdummy, anynul, status);
877
else if (datatype == TFLOAT)
880
ffgcle(fptr, colnum, firstrow, firstelem, nelem, 1, 1, 0.,
881
(float *) array, cdummy, anynul, status);
883
ffgcle(fptr, colnum, firstrow, firstelem, nelem, 1, 1, *(float *)
884
nulval,(float *) array, cdummy, anynul, status);
886
else if (datatype == TDOUBLE)
889
ffgcld(fptr, colnum, firstrow, firstelem, nelem, 1, 1, 0.,
890
(double *) array, cdummy, anynul, status);
892
ffgcld(fptr, colnum, firstrow, firstelem, nelem, 1, 1, *(double *)
893
nulval, (double *) array, cdummy, anynul, status);
895
else if (datatype == TCOMPLEX)
898
ffgcle(fptr, colnum, firstrow, (firstelem - 1) * 2 + 1, nelem * 2,
899
1, 1, 0., (float *) array, cdummy, anynul, status);
901
ffgcle(fptr, colnum, firstrow, (firstelem - 1) * 2 + 1, nelem * 2,
902
1, 1, *(float *) nulval, (float *) array, cdummy, anynul, status);
904
else if (datatype == TDBLCOMPLEX)
907
ffgcld(fptr, colnum, firstrow, (firstelem - 1) * 2 + 1, nelem * 2,
908
1, 1, 0., (double *) array, cdummy, anynul, status);
910
ffgcld(fptr, colnum, firstrow, (firstelem - 1) * 2 + 1, nelem * 2,
911
1, 1, *(double *) nulval, (double *) array, cdummy, anynul, status);
914
else if (datatype == TLOGICAL)
917
ffgcll(fptr, colnum, firstrow, firstelem, nelem, 1, 0,
918
(char *) array, cdummy, anynul, status);
920
ffgcll(fptr, colnum, firstrow, firstelem, nelem, 1, *(char *) nulval,
921
(char *) array, cdummy, anynul, status);
923
else if (datatype == TSTRING)
928
ffgcls(fptr, colnum, firstrow, firstelem, nelem, 1,
929
cdummy, (char **) array, cdummy, anynul, status);
932
ffgcls(fptr, colnum, firstrow, firstelem, nelem, 1, (char *)
933
nulval, (char **) array, cdummy, anynul, status);
936
*status = BAD_DATATYPE;
940
/*--------------------------------------------------------------------------*/
941
int ffgcf( fitsfile *fptr, /* I - FITS file pointer */
942
int datatype, /* I - datatype of the value */
943
int colnum, /* I - number of column to write (1 = 1st col) */
944
LONGLONG firstrow, /* I - first row to write (1 = 1st row) */
945
LONGLONG firstelem, /* I - first vector element to read (1 = 1st) */
946
LONGLONG nelem, /* I - number of values to read */
947
void *array, /* O - array of values that are returned */
948
char *nullarray, /* O - array of null value flags */
949
int *anynul, /* O - set to 1 if any values are null; else 0 */
950
int *status) /* IO - error status */
952
Read an array of values from a table column. The datatype of the
953
input array is defined by the 2nd argument. Data conversion
954
and scaling will be performed if necessary (e.g, if the datatype of
955
the FITS array is not the same as the array being read).
956
ANYNUL is returned with a value of true if any pixels are undefined.
959
void *nulval; /* dummy argument */
962
if (*status > 0) /* inherit input status value if > 0 */
965
nulval = &dnulval; /* set to a harmless value; this is never used */
967
if (datatype == TBIT)
969
ffgcx(fptr, colnum, firstrow, firstelem, nelem, (char *) array, status);
971
else if (datatype == TBYTE)
973
ffgclb(fptr, colnum, firstrow, firstelem, nelem, 1, 2, *(unsigned char *)
974
nulval, (unsigned char *) array, nullarray, anynul, status);
976
else if (datatype == TSBYTE)
978
ffgclsb(fptr, colnum, firstrow, firstelem, nelem, 1, 2, *(signed char *)
979
nulval, (signed char *) array, nullarray, anynul, status);
981
else if (datatype == TUSHORT)
983
ffgclui(fptr, colnum, firstrow, firstelem, nelem, 1, 2,
984
*(unsigned short *) nulval,
985
(unsigned short *) array, nullarray, anynul, status);
987
else if (datatype == TSHORT)
989
ffgcli(fptr, colnum, firstrow, firstelem, nelem, 1, 2, *(short *)
990
nulval, (short *) array, nullarray, anynul, status);
992
else if (datatype == TUINT)
994
ffgcluk(fptr, colnum, firstrow, firstelem, nelem, 1, 2,
995
*(unsigned int *) nulval, (unsigned int *) array, nullarray, anynul,
998
else if (datatype == TINT)
1000
ffgclk(fptr, colnum, firstrow, firstelem, nelem, 1, 2, *(int *)
1001
nulval, (int *) array, nullarray, anynul, status);
1003
else if (datatype == TULONG)
1005
ffgcluj(fptr, colnum, firstrow, firstelem, nelem, 1, 2,
1006
*(unsigned long *) nulval,
1007
(unsigned long *) array, nullarray, anynul, status);
1009
else if (datatype == TLONG)
1011
ffgclj(fptr, colnum, firstrow, firstelem, nelem, 1, 2, *(long *)
1012
nulval, (long *) array, nullarray, anynul, status);
1014
else if (datatype == TLONGLONG)
1016
ffgcljj(fptr, colnum, firstrow, firstelem, nelem, 1, 2, *(LONGLONG *)
1017
nulval, (LONGLONG *) array, nullarray, anynul, status);
1019
else if (datatype == TFLOAT)
1021
ffgcle(fptr, colnum, firstrow, firstelem, nelem, 1, 2, *(float *)
1022
nulval,(float *) array, nullarray, anynul, status);
1024
else if (datatype == TDOUBLE)
1026
ffgcld(fptr, colnum, firstrow, firstelem, nelem, 1, 2, *(double *)
1027
nulval, (double *) array, nullarray, anynul, status);
1029
else if (datatype == TCOMPLEX)
1031
ffgcfc(fptr, colnum, firstrow, firstelem, nelem,
1032
(float *) array, nullarray, anynul, status);
1034
else if (datatype == TDBLCOMPLEX)
1036
ffgcfm(fptr, colnum, firstrow, firstelem, nelem,
1037
(double *) array, nullarray, anynul, status);
1040
else if (datatype == TLOGICAL)
1042
ffgcll(fptr, colnum, firstrow, firstelem, nelem, 2, *(char *) nulval,
1043
(char *) array, nullarray, anynul, status);
1045
else if (datatype == TSTRING)
1047
ffgcls(fptr, colnum, firstrow, firstelem, nelem, 2, (char *)
1048
nulval, (char **) array, nullarray, anynul, status);
1051
*status = BAD_DATATYPE;