1
/* This file, getcole.c, contains routines that read data elements from */
2
/* a FITS image or table, with float datatype */
4
/* The FITSIO software was written by William Pence at the High Energy */
5
/* Astrophysic Science Archive Research Center (HEASARC) at the NASA */
6
/* Goddard Space Flight Center. */
14
/*--------------------------------------------------------------------------*/
15
int ffgpve( fitsfile *fptr, /* I - FITS file pointer */
16
long group, /* I - group to read (1 = 1st group) */
17
LONGLONG firstelem, /* I - first vector element to read (1 = 1st) */
18
LONGLONG nelem, /* I - number of values to read */
19
float nulval, /* I - value for undefined pixels */
20
float *array, /* O - array of values that are returned */
21
int *anynul, /* O - set to 1 if any values are null; else 0 */
22
int *status) /* IO - error status */
24
Read an array of values from the primary array. Data conversion
25
and scaling will be performed if necessary (e.g, if the datatype of
26
the FITS array is not the same as the array being read).
27
Undefined elements will be set equal to NULVAL, unless NULVAL=0
28
in which case no checking for undefined values will be performed.
29
ANYNUL is returned with a value of .true. if any pixels are undefined.
37
if (fits_is_compressed_image(fptr, status))
39
/* this is a compressed image in a binary table */
40
nullvalue = nulval; /* set local variable */
42
fits_read_compressed_pixels(fptr, TFLOAT, firstelem, nelem,
43
nullcheck, &nullvalue, array, NULL, anynul, status);
48
the primary array is represented as a binary table:
49
each group of the primary array is a row in the table,
50
where the first column contains the group parameters
51
and the second column contains the image itself.
54
row=maxvalue(1,group);
56
ffgcle(fptr, 2, row, firstelem, nelem, 1, 1, nulval,
57
array, &cdummy, anynul, status);
60
/*--------------------------------------------------------------------------*/
61
int ffgpfe( fitsfile *fptr, /* I - FITS file pointer */
62
long group, /* I - group to read (1 = 1st group) */
63
LONGLONG firstelem, /* I - first vector element to read (1 = 1st) */
64
LONGLONG nelem, /* I - number of values to read */
65
float *array, /* O - array of values that are returned */
66
char *nularray, /* O - array of null pixel flags */
67
int *anynul, /* O - set to 1 if any values are null; else 0 */
68
int *status) /* IO - error status */
70
Read an array of values from the primary array. Data conversion
71
and scaling will be performed if necessary (e.g, if the datatype of
72
the FITS array is not the same as the array being read).
73
Any undefined pixels in the returned array will be set = 0 and the
74
corresponding nularray value will be set = 1.
75
ANYNUL is returned with a value of .true. if any pixels are undefined.
81
if (fits_is_compressed_image(fptr, status))
83
/* this is a compressed image in a binary table */
85
fits_read_compressed_pixels(fptr, TFLOAT, firstelem, nelem,
86
nullcheck, NULL, array, nularray, anynul, status);
91
the primary array is represented as a binary table:
92
each group of the primary array is a row in the table,
93
where the first column contains the group parameters
94
and the second column contains the image itself.
97
row=maxvalue(1,group);
99
ffgcle(fptr, 2, row, firstelem, nelem, 1, 2, 0.F,
100
array, nularray, anynul, status);
103
/*--------------------------------------------------------------------------*/
104
int ffg2de(fitsfile *fptr, /* I - FITS file pointer */
105
long group, /* I - group to read (1 = 1st group) */
106
float nulval, /* set undefined pixels equal to this */
107
LONGLONG ncols, /* I - number of pixels in each row of array */
108
LONGLONG naxis1, /* I - FITS image NAXIS1 value */
109
LONGLONG naxis2, /* I - FITS image NAXIS2 value */
110
float *array, /* O - array to be filled and returned */
111
int *anynul, /* O - set to 1 if any values are null; else 0 */
112
int *status) /* IO - error status */
114
Read an entire 2-D array of values to the primary array. Data conversion
115
and scaling will be performed if necessary (e.g, if the datatype of the
116
FITS array is not the same as the array being read). Any null
117
values in the array will be set equal to the value of nulval, unless
118
nulval = 0 in which case no null checking will be performed.
121
/* call the 3D reading routine, with the 3rd dimension = 1 */
123
ffg3de(fptr, group, nulval, ncols, naxis2, naxis1, naxis2, 1, array,
128
/*--------------------------------------------------------------------------*/
129
int ffg3de(fitsfile *fptr, /* I - FITS file pointer */
130
long group, /* I - group to read (1 = 1st group) */
131
float nulval, /* set undefined pixels equal to this */
132
LONGLONG ncols, /* I - number of pixels in each row of array */
133
LONGLONG nrows, /* I - number of rows in each plane of array */
134
LONGLONG naxis1, /* I - FITS image NAXIS1 value */
135
LONGLONG naxis2, /* I - FITS image NAXIS2 value */
136
LONGLONG naxis3, /* I - FITS image NAXIS3 value */
137
float *array, /* O - array to be filled and returned */
138
int *anynul, /* O - set to 1 if any values are null; else 0 */
139
int *status) /* IO - error status */
141
Read an entire 3-D array of values to the primary array. Data conversion
142
and scaling will be performed if necessary (e.g, if the datatype of the
143
FITS array is not the same as the array being read). Any null
144
values in the array will be set equal to the value of nulval, unless
145
nulval = 0 in which case no null checking will be performed.
148
long tablerow, ii, jj;
149
LONGLONG narray, nfits;
152
long inc[] = {1,1,1};
153
LONGLONG fpixel[] = {1,1,1};
157
if (fits_is_compressed_image(fptr, status))
159
/* this is a compressed image in a binary table */
164
nullvalue = nulval; /* set local variable */
166
fits_read_compressed_img(fptr, TFLOAT, fpixel, lpixel, inc,
167
nullcheck, &nullvalue, array, NULL, anynul, status);
172
the primary array is represented as a binary table:
173
each group of the primary array is a row in the table,
174
where the first column contains the group parameters
175
and the second column contains the image itself.
177
tablerow=maxvalue(1,group);
179
if (ncols == naxis1 && nrows == naxis2) /* arrays have same size? */
181
/* all the image pixels are contiguous, so read all at once */
182
ffgcle(fptr, 2, tablerow, 1, naxis1 * naxis2 * naxis3, 1, 1, nulval,
183
array, &cdummy, anynul, status);
187
if (ncols < naxis1 || nrows < naxis2)
188
return(*status = BAD_DIMEN);
190
nfits = 1; /* next pixel in FITS image to read */
191
narray = 0; /* next pixel in output array to be filled */
193
/* loop over naxis3 planes in the data cube */
194
for (jj = 0; jj < naxis3; jj++)
196
/* loop over the naxis2 rows in the FITS image, */
197
/* reading naxis1 pixels to each row */
199
for (ii = 0; ii < naxis2; ii++)
201
if (ffgcle(fptr, 2, tablerow, nfits, naxis1, 1, 1, nulval,
202
&array[narray], &cdummy, anynul, status) > 0)
208
narray += (nrows - naxis2) * ncols;
213
/*--------------------------------------------------------------------------*/
214
int ffgsve(fitsfile *fptr, /* I - FITS file pointer */
215
int colnum, /* I - number of the column to read (1 = 1st) */
216
int naxis, /* I - number of dimensions in the FITS array */
217
long *naxes, /* I - size of each dimension */
218
long *blc, /* I - 'bottom left corner' of the subsection */
219
long *trc, /* I - 'top right corner' of the subsection */
220
long *inc, /* I - increment to be applied in each dimension */
221
float nulval, /* I - value to set undefined pixels */
222
float *array, /* O - array to be filled and returned */
223
int *anynul, /* O - set to 1 if any values are null; else 0 */
224
int *status) /* IO - error status */
226
Read a subsection of data values from an image or a table column.
227
This routine is set up to handle a maximum of nine dimensions.
230
long ii,i0, i1,i2,i3,i4,i5,i6,i7,i8,row,rstr,rstp,rinc;
231
long str[9],stp[9],incr[9],dir[9];
232
long nelem, nultyp, ninc, numcol;
233
LONGLONG felem, dsize[10], blcll[9], trcll[9];
235
char ldummy, msg[FLEN_ERRMSG];
239
if (naxis < 1 || naxis > 9)
241
sprintf(msg, "NAXIS = %d in call to ffgsve is out of range", naxis);
243
return(*status = BAD_DIMEN);
246
if (fits_is_compressed_image(fptr, status))
248
/* this is a compressed image in a binary table */
250
for (ii=0; ii < naxis; ii++) {
255
nullvalue = nulval; /* set local variable */
257
fits_read_compressed_img(fptr, TFLOAT, blcll, trcll, inc,
258
nullcheck, &nullvalue, array, NULL, anynul, status);
263
if this is a primary array, then the input COLNUM parameter should
264
be interpreted as the row number, and we will alway read the image
265
data from column 2 (any group parameters are in column 1).
267
if (ffghdt(fptr, &hdutype, status) > 0)
270
if (hdutype == IMAGE_HDU)
272
/* this is a primary array, or image extension */
288
/* this is a table, so the row info is in the (naxis+1) elements */
300
for (ii = 0; ii < 9; ii++)
309
for (ii = 0; ii < naxis; ii++)
311
if (trc[ii] < blc[ii])
313
if (hdutype == IMAGE_HDU)
319
sprintf(msg, "ffgsve: illegal range specified for axis %ld", ii + 1);
321
return(*status = BAD_PIX_NUM);
328
dsize[ii + 1] = dsize[ii] * naxes[ii];
329
dsize[ii] = dsize[ii] * dir[ii];
331
dsize[naxis] = dsize[naxis] * dir[naxis];
333
if (naxis == 1 && naxes[0] == 1)
335
/* This is not a vector column, so read all the rows at once */
336
nelem = (rstp - rstr) / rinc + 1;
342
/* have to read each row individually, in all dimensions */
343
nelem = (stp[0]*dir[0] - str[0]*dir[0]) / inc[0] + 1;
344
ninc = incr[0] * dir[0];
347
for (row = rstr; row <= rstp; row += rinc)
349
for (i8 = str[8]*dir[8]; i8 <= stp[8]*dir[8]; i8 += incr[8])
351
for (i7 = str[7]*dir[7]; i7 <= stp[7]*dir[7]; i7 += incr[7])
353
for (i6 = str[6]*dir[6]; i6 <= stp[6]*dir[6]; i6 += incr[6])
355
for (i5 = str[5]*dir[5]; i5 <= stp[5]*dir[5]; i5 += incr[5])
357
for (i4 = str[4]*dir[4]; i4 <= stp[4]*dir[4]; i4 += incr[4])
359
for (i3 = str[3]*dir[3]; i3 <= stp[3]*dir[3]; i3 += incr[3])
361
for (i2 = str[2]*dir[2]; i2 <= stp[2]*dir[2]; i2 += incr[2])
363
for (i1 = str[1]*dir[1]; i1 <= stp[1]*dir[1]; i1 += incr[1])
366
felem=str[0] + (i1 - dir[1]) * dsize[1] + (i2 - dir[2]) * dsize[2] +
367
(i3 - dir[3]) * dsize[3] + (i4 - dir[4]) * dsize[4] +
368
(i5 - dir[5]) * dsize[5] + (i6 - dir[6]) * dsize[6] +
369
(i7 - dir[7]) * dsize[7] + (i8 - dir[8]) * dsize[8];
371
if ( ffgcle(fptr, numcol, row, felem, nelem, ninc, nultyp,
372
nulval, &array[i0], &ldummy, &anyf, status) > 0)
390
/*--------------------------------------------------------------------------*/
391
int ffgsfe(fitsfile *fptr, /* I - FITS file pointer */
392
int colnum, /* I - number of the column to read (1 = 1st) */
393
int naxis, /* I - number of dimensions in the FITS array */
394
long *naxes, /* I - size of each dimension */
395
long *blc, /* I - 'bottom left corner' of the subsection */
396
long *trc, /* I - 'top right corner' of the subsection */
397
long *inc, /* I - increment to be applied in each dimension */
398
float *array, /* O - array to be filled and returned */
399
char *flagval, /* O - set to 1 if corresponding value is null */
400
int *anynul, /* O - set to 1 if any values are null; else 0 */
401
int *status) /* IO - error status */
403
Read a subsection of data values from an image or a table column.
404
This routine is set up to handle a maximum of nine dimensions.
407
long ii,i0, i1,i2,i3,i4,i5,i6,i7,i8,row,rstr,rstp,rinc;
408
long str[9],stp[9],incr[9],dsize[10];
409
LONGLONG blcll[9], trcll[9];
410
long felem, nelem, nultyp, ninc, numcol;
413
char msg[FLEN_ERRMSG];
416
if (naxis < 1 || naxis > 9)
418
sprintf(msg, "NAXIS = %d in call to ffgsve is out of range", naxis);
420
return(*status = BAD_DIMEN);
423
if (fits_is_compressed_image(fptr, status))
425
/* this is a compressed image in a binary table */
427
for (ii=0; ii < naxis; ii++) {
432
fits_read_compressed_img(fptr, TFLOAT, blcll, trcll, inc,
433
nullcheck, NULL, array, flagval, anynul, status);
438
if this is a primary array, then the input COLNUM parameter should
439
be interpreted as the row number, and we will alway read the image
440
data from column 2 (any group parameters are in column 1).
442
if (ffghdt(fptr, &hdutype, status) > 0)
445
if (hdutype == IMAGE_HDU)
447
/* this is a primary array, or image extension */
463
/* this is a table, so the row info is in the (naxis+1) elements */
475
for (ii = 0; ii < 9; ii++)
483
for (ii = 0; ii < naxis; ii++)
485
if (trc[ii] < blc[ii])
487
sprintf(msg, "ffgsve: illegal range specified for axis %ld", ii + 1);
489
return(*status = BAD_PIX_NUM);
495
dsize[ii + 1] = dsize[ii] * naxes[ii];
498
if (naxis == 1 && naxes[0] == 1)
500
/* This is not a vector column, so read all the rows at once */
501
nelem = (rstp - rstr) / rinc + 1;
507
/* have to read each row individually, in all dimensions */
508
nelem = (stp[0] - str[0]) / inc[0] + 1;
512
for (row = rstr; row <= rstp; row += rinc)
514
for (i8 = str[8]; i8 <= stp[8]; i8 += incr[8])
516
for (i7 = str[7]; i7 <= stp[7]; i7 += incr[7])
518
for (i6 = str[6]; i6 <= stp[6]; i6 += incr[6])
520
for (i5 = str[5]; i5 <= stp[5]; i5 += incr[5])
522
for (i4 = str[4]; i4 <= stp[4]; i4 += incr[4])
524
for (i3 = str[3]; i3 <= stp[3]; i3 += incr[3])
526
for (i2 = str[2]; i2 <= stp[2]; i2 += incr[2])
528
for (i1 = str[1]; i1 <= stp[1]; i1 += incr[1])
530
felem=str[0] + (i1 - 1) * dsize[1] + (i2 - 1) * dsize[2] +
531
(i3 - 1) * dsize[3] + (i4 - 1) * dsize[4] +
532
(i5 - 1) * dsize[5] + (i6 - 1) * dsize[6] +
533
(i7 - 1) * dsize[7] + (i8 - 1) * dsize[8];
535
if ( ffgcle(fptr, numcol, row, felem, nelem, ninc, nultyp,
536
nulval, &array[i0], &flagval[i0], &anyf, status) > 0)
554
/*--------------------------------------------------------------------------*/
555
int ffggpe( fitsfile *fptr, /* I - FITS file pointer */
556
long group, /* I - group to read (1 = 1st group) */
557
long firstelem, /* I - first vector element to read (1 = 1st) */
558
long nelem, /* I - number of values to read */
559
float *array, /* O - array of values that are returned */
560
int *status) /* IO - error status */
562
Read an array of group parameters from the primary array. Data conversion
563
and scaling will be performed if necessary (e.g, if the datatype of
564
the FITS array is not the same as the array being read).
571
the primary array is represented as a binary table:
572
each group of the primary array is a row in the table,
573
where the first column contains the group parameters
574
and the second column contains the image itself.
577
row=maxvalue(1,group);
579
ffgcle(fptr, 1, row, firstelem, nelem, 1, 1, 0.F,
580
array, &cdummy, &idummy, status);
583
/*--------------------------------------------------------------------------*/
584
int ffgcve(fitsfile *fptr, /* I - FITS file pointer */
585
int colnum, /* I - number of column to read (1 = 1st col) */
586
LONGLONG firstrow, /* I - first row to read (1 = 1st row) */
587
LONGLONG firstelem, /* I - first vector element to read (1 = 1st) */
588
LONGLONG nelem, /* I - number of values to read */
589
float nulval, /* I - value for null pixels */
590
float *array, /* O - array of values that are read */
591
int *anynul, /* O - set to 1 if any values are null; else 0 */
592
int *status) /* IO - error status */
594
Read an array of values from a column in the current FITS HDU. Automatic
595
datatype conversion will be performed if the datatype of the column does not
596
match the datatype of the array parameter. The output values will be scaled
597
by the FITS TSCALn and TZEROn values if these values have been defined.
598
Any undefined pixels will be set equal to the value of 'nulval' unless
599
nulval = 0 in which case no checks for undefined pixels will be made.
604
ffgcle(fptr, colnum, firstrow, firstelem, nelem, 1, 1, nulval,
605
array, &cdummy, anynul, status);
608
/*--------------------------------------------------------------------------*/
609
int ffgcvc(fitsfile *fptr, /* I - FITS file pointer */
610
int colnum, /* I - number of column to read (1 = 1st col) */
611
LONGLONG firstrow, /* I - first row to read (1 = 1st row) */
612
LONGLONG firstelem, /* I - first vector element to read (1 = 1st) */
613
LONGLONG nelem, /* I - number of values to read */
614
float nulval, /* I - value for null pixels */
615
float *array, /* O - array of values that are read */
616
int *anynul, /* O - set to 1 if any values are null; else 0 */
617
int *status) /* IO - error status */
619
Read an array of values from a column in the current FITS HDU. Automatic
620
datatype conversion will be performed if the datatype of the column does not
621
match the datatype of the array parameter. The output values will be scaled
622
by the FITS TSCALn and TZEROn values if these values have been defined.
623
Any undefined pixels will be set equal to the value of 'nulval' unless
624
nulval = 0 in which case no checks for undefined pixels will be made.
626
TSCAL and ZERO should not be used with complex values.
631
/* a complex value is interpreted as a pair of float values, thus */
632
/* need to multiply the first element and number of elements by 2 */
634
ffgcle(fptr, colnum, firstrow, (firstelem - 1) * 2 + 1, nelem *2,
635
1, 1, nulval, array, &cdummy, anynul, status);
638
/*--------------------------------------------------------------------------*/
639
int ffgcfe(fitsfile *fptr, /* I - FITS file pointer */
640
int colnum, /* I - number of column to read (1 = 1st col) */
641
LONGLONG firstrow, /* I - first row to read (1 = 1st row) */
642
LONGLONG firstelem, /* I - first vector element to read (1 = 1st) */
643
LONGLONG nelem, /* I - number of values to read */
644
float *array, /* O - array of values that are read */
645
char *nularray, /* O - array of flags: 1 if null pixel; else 0 */
646
int *anynul, /* O - set to 1 if any values are null; else 0 */
647
int *status) /* IO - error status */
649
Read an array of values from a column in the current FITS HDU. Automatic
650
datatype conversion will be performed if the datatype of the column does not
651
match the datatype of the array parameter. The output values will be scaled
652
by the FITS TSCALn and TZEROn values if these values have been defined.
653
Nularray will be set = 1 if the corresponding array pixel is undefined,
654
otherwise nularray will = 0.
659
ffgcle(fptr, colnum, firstrow, firstelem, nelem, 1, 2, dummy,
660
array, nularray, anynul, status);
663
/*--------------------------------------------------------------------------*/
664
int ffgcfc(fitsfile *fptr, /* I - FITS file pointer */
665
int colnum, /* I - number of column to read (1 = 1st col) */
666
LONGLONG firstrow, /* I - first row to read (1 = 1st row) */
667
LONGLONG firstelem, /* I - first vector element to read (1 = 1st) */
668
LONGLONG nelem, /* I - number of values to read */
669
float *array, /* O - array of values that are read */
670
char *nularray, /* O - array of flags: 1 if null pixel; else 0 */
671
int *anynul, /* O - set to 1 if any values are null; else 0 */
672
int *status) /* IO - error status */
674
Read an array of values from a column in the current FITS HDU. Automatic
675
datatype conversion will be performed if the datatype of the column does not
676
match the datatype of the array parameter. The output values will be scaled
677
by the FITS TSCALn and TZEROn values if these values have been defined.
678
Nularray will be set = 1 if the corresponding array pixel is undefined,
679
otherwise nularray will = 0.
681
TSCAL and ZERO should not be used with complex values.
688
/* a complex value is interpreted as a pair of float values, thus */
689
/* need to multiply the first element and number of elements by 2 */
691
/* allocate temporary array */
692
carray = (char *) calloc( (size_t) (nelem * 2), 1);
694
ffgcle(fptr, colnum, firstrow, (firstelem - 1) * 2 + 1, nelem * 2,
695
1, 2, dummy, array, carray, anynul, status);
697
for (ii = 0, jj = 0; jj < nelem; ii += 2, jj++)
699
if (carray[ii] || carray[ii + 1])
708
/*--------------------------------------------------------------------------*/
709
int ffgcle( fitsfile *fptr, /* I - FITS file pointer */
710
int colnum, /* I - number of column to read (1 = 1st col) */
711
LONGLONG firstrow, /* I - first row to read (1 = 1st row) */
712
LONGLONG firstelem, /* I - first vector element to read (1 = 1st) */
713
LONGLONG nelem, /* I - number of values to read */
714
long elemincre, /* I - pixel increment; e.g., 2 = every other */
715
int nultyp, /* I - null value handling code: */
716
/* 1: set undefined pixels = nulval */
717
/* 2: set nularray=1 for undefined pixels */
718
float nulval, /* I - value for null pixels if nultyp = 1 */
719
float *array, /* O - array of values that are read */
720
char *nularray, /* O - array of flags = 1 if nultyp = 2 */
721
int *anynul, /* O - set to 1 if any values are null; else 0 */
722
int *status) /* IO - error status */
724
Read an array of values from a column in the current FITS HDU.
725
The column number may refer to a real column in an ASCII or binary table,
726
or it may refer be a virtual column in a 1 or more grouped FITS primary
727
array or image extension. FITSIO treats a primary array as a binary table
728
with 2 vector columns: the first column contains the group parameters (often
729
with length = 0) and the second column contains the array of image pixels.
730
Each row of the table represents a group in the case of multigroup FITS
733
The output array of values will be converted from the datatype of the column
734
and will be scaled by the FITS TSCALn and TZEROn values if necessary.
737
double scale, zero, power = 1., dtemp;
738
int tcode, maxelem2, hdutype, xcode, decimals;
740
long ii, xwidth, ntodo;
741
int convert, nulcheck, readcheck = 0;
742
LONGLONG repeat, startpos, elemnum, readptr, tnull;
743
LONGLONG rowlen, rownum, remain, next, rowincre, maxelem;
746
char snull[20]; /* the FITS null value if reading from ASCII table */
748
double cbuff[DBUFFSIZE / sizeof(double)]; /* align cbuff on word boundary */
751
if (*status > 0 || nelem == 0) /* inherit input status value if > 0 */
760
memset(nularray, 0, (size_t) nelem); /* initialize nullarray */
762
/*---------------------------------------------------*/
763
/* Check input and get parameters about the column: */
764
/*---------------------------------------------------*/
766
readcheck = -1; /* don't do range checking in this case */
768
if ( ffgcprll( fptr, colnum, firstrow, firstelem, nelem, readcheck, &scale, &zero,
769
tform, &twidth, &tcode, &maxelem2, &startpos, &elemnum, &incre,
770
&repeat, &rowlen, &hdutype, &tnull, snull, status) > 0 )
774
incre *= elemincre; /* multiply incre to just get every nth pixel */
776
if (tcode == TSTRING) /* setup for ASCII tables */
778
/* get the number of implied decimal places if no explicit decmal point */
779
ffasfm(tform, &xcode, &xwidth, &decimals, status);
780
for(ii = 0; ii < decimals; ii++)
784
/*------------------------------------------------------------------*/
785
/* Decide whether to check for null values in the input FITS file: */
786
/*------------------------------------------------------------------*/
787
nulcheck = nultyp; /* by default check for null values in the FITS file */
789
if (nultyp == 1 && nulval == 0)
790
nulcheck = 0; /* calling routine does not want to check for nulls */
792
else if (tcode%10 == 1 && /* if reading an integer column, and */
793
tnull == NULL_UNDEFINED) /* if a null value is not defined, */
794
nulcheck = 0; /* then do not check for null values. */
796
else if (tcode == TSHORT && (tnull > SHRT_MAX || tnull < SHRT_MIN) )
797
nulcheck = 0; /* Impossible null value */
799
else if (tcode == TBYTE && (tnull > 255 || tnull < 0) )
800
nulcheck = 0; /* Impossible null value */
802
else if (tcode == TSTRING && snull[0] == ASCII_NULL_UNDEFINED)
805
/*----------------------------------------------------------------------*/
806
/* If FITS column and output data array have same datatype, then we do */
807
/* not need to use a temporary buffer to store intermediate datatype. */
808
/*----------------------------------------------------------------------*/
810
if (tcode == TFLOAT) /* Special Case: */
811
{ /* no type convertion required, so read */
812
maxelem = nelem; /* data directly into output buffer. */
814
if (nulcheck == 0 && scale == 1. && zero == 0.)
815
convert = 0; /* no need to scale data or find nulls */
818
/*---------------------------------------------------------------------*/
819
/* Now read the pixels from the FITS column. If the column does not */
820
/* have the same datatype as the output array, then we have to read */
821
/* the raw values into a temporary buffer (of limited size). In */
822
/* the case of a vector colum read only 1 vector of values at a time */
823
/* then skip to the next row if more values need to be read. */
824
/* After reading the raw values, then call the fffXXYY routine to (1) */
825
/* test for undefined values, (2) convert the datatype if necessary, */
826
/* and (3) scale the values by the FITS TSCALn and TZEROn linear */
827
/* scaling parameters. */
828
/*---------------------------------------------------------------------*/
829
remain = nelem; /* remaining number of values to read */
830
next = 0; /* next element in array to be read */
831
rownum = 0; /* row number, relative to firstrow */
835
/* limit the number of pixels to read at one time to the number that
836
will fit in the buffer or to the number of pixels that remain in
837
the current vector, which ever is smaller.
839
ntodo = (long) minvalue(remain, maxelem);
842
ntodo = (long) minvalue(ntodo, ((repeat - elemnum - 1)/elemincre +1));
846
ntodo = (long) minvalue(ntodo, (elemnum/(-elemincre) +1));
849
readptr = startpos + ((LONGLONG)rownum * rowlen) + (elemnum * (incre / elemincre));
854
ffgr4b(fptr, readptr, ntodo, incre, &array[next], status);
856
fffr4r4(&array[next], ntodo, scale, zero, nulcheck,
857
nulval, &nularray[next], anynul,
858
&array[next], status);
861
ffgi1b(fptr, readptr, ntodo, incre, (unsigned char *) buffer,
863
fffi1r4((unsigned char *) buffer, ntodo, scale, zero, nulcheck,
864
(unsigned char) tnull, nulval, &nularray[next], anynul,
865
&array[next], status);
868
ffgi2b(fptr, readptr, ntodo, incre, (short *) buffer, status);
869
fffi2r4((short *) buffer, ntodo, scale, zero, nulcheck,
870
(short) tnull, nulval, &nularray[next], anynul,
871
&array[next], status);
874
ffgi4b(fptr, readptr, ntodo, incre, (INT32BIT *) buffer,
876
fffi4r4((INT32BIT *) buffer, ntodo, scale, zero, nulcheck,
877
(INT32BIT) tnull, nulval, &nularray[next], anynul,
878
&array[next], status);
882
ffgi8b(fptr, readptr, ntodo, incre, (long *) buffer, status);
883
fffi8r4( (LONGLONG *) buffer, ntodo, scale, zero,
884
nulcheck, tnull, nulval, &nularray[next],
885
anynul, &array[next], status);
888
ffgr8b(fptr, readptr, ntodo, incre, (double *) buffer, status);
889
fffr8r4((double *) buffer, ntodo, scale, zero, nulcheck,
890
nulval, &nularray[next], anynul,
891
&array[next], status);
894
ffmbyt(fptr, readptr, REPORT_EOF, status);
896
if (incre == twidth) /* contiguous bytes */
897
ffgbyt(fptr, ntodo * twidth, buffer, status);
899
ffgbytoff(fptr, twidth, ntodo, incre - twidth, buffer,
902
fffstrr4((char *) buffer, ntodo, scale, zero, twidth, power,
903
nulcheck, snull, nulval, &nularray[next], anynul,
904
&array[next], status);
908
default: /* error trap for invalid column format */
910
"Cannot read numbers from column %d which has format %s",
913
if (hdutype == ASCII_TBL)
914
return(*status = BAD_ATABLE_FORMAT);
916
return(*status = BAD_BTABLE_FORMAT);
918
} /* End of switch block */
920
/*-------------------------*/
921
/* Check for fatal error */
922
/*-------------------------*/
923
if (*status > 0) /* test for error during previous read operation */
925
dtemp = (double) next;
928
"Error reading elements %.0f thru %.0f from column %d (ffgcle).",
929
dtemp+1., dtemp+ntodo, colnum);
932
"Error reading elements %.0f thru %.0f from image (ffgcle).",
933
dtemp+1., dtemp+ntodo);
939
/*--------------------------------------------*/
940
/* increment the counters for the next loop */
941
/*--------------------------------------------*/
946
elemnum = elemnum + (ntodo * elemincre);
948
if (elemnum >= repeat) /* completed a row; start on later row */
950
rowincre = elemnum / repeat;
952
elemnum = elemnum - (rowincre * repeat);
954
else if (elemnum < 0) /* completed a row; start on a previous row */
956
rowincre = (-elemnum - 1) / repeat + 1;
958
elemnum = (rowincre * repeat) + elemnum;
961
} /* End of main while Loop */
964
/*--------------------------------*/
965
/* check for numerical overflow */
966
/*--------------------------------*/
967
if (*status == OVERFLOW_ERR)
970
"Numerical overflow during type conversion while reading FITS data.");
971
*status = NUM_OVERFLOW;
976
/*--------------------------------------------------------------------------*/
977
int fffi1r4(unsigned char *input, /* I - array of values to be converted */
978
long ntodo, /* I - number of elements in the array */
979
double scale, /* I - FITS TSCALn or BSCALE value */
980
double zero, /* I - FITS TZEROn or BZERO value */
981
int nullcheck, /* I - null checking code; 0 = don't check */
982
/* 1:set null pixels = nullval */
983
/* 2: if null pixel, set nullarray = 1 */
984
unsigned char tnull, /* I - value of FITS TNULLn keyword if any */
985
float nullval, /* I - set null pixels, if nullcheck = 1 */
986
char *nullarray, /* I - bad pixel array, if nullcheck = 2 */
987
int *anynull, /* O - set to 1 if any pixels are null */
988
float *output, /* O - array of converted pixels */
989
int *status) /* IO - error status */
991
Copy input to output following reading of the input from a FITS file.
992
Check for null values and do datatype conversion and scaling if required.
993
The nullcheck code value determines how any null values in the input array
994
are treated. A null value is an input pixel that is equal to tnull. If
995
nullcheck = 0, then no checking for nulls is performed and any null values
996
will be transformed just like any other pixel. If nullcheck = 1, then the
997
output pixel will be set = nullval if the corresponding input pixel is null.
998
If nullcheck = 2, then if the pixel is null then the corresponding value of
999
nullarray will be set to 1; the value of nullarray for non-null pixels
1000
will = 0. The anynull parameter will be set = 1 if any of the returned
1001
pixels are null, otherwise anynull will be returned with a value = 0;
1006
if (nullcheck == 0) /* no null checking required */
1008
if (scale == 1. && zero == 0.) /* no scaling */
1010
for (ii = 0; ii < ntodo; ii++)
1011
output[ii] = (float) input[ii]; /* copy input to output */
1013
else /* must scale the data */
1015
for (ii = 0; ii < ntodo; ii++)
1017
output[ii] = (float) (( (double) input[ii] ) * scale + zero);
1021
else /* must check for null values */
1023
if (scale == 1. && zero == 0.) /* no scaling */
1025
for (ii = 0; ii < ntodo; ii++)
1027
if (input[ii] == tnull)
1031
output[ii] = nullval;
1036
output[ii] = (float) input[ii];
1039
else /* must scale the data */
1041
for (ii = 0; ii < ntodo; ii++)
1043
if (input[ii] == tnull)
1047
output[ii] = nullval;
1053
output[ii] = (float) (( (double) input[ii] ) * scale + zero);
1060
/*--------------------------------------------------------------------------*/
1061
int fffi2r4(short *input, /* I - array of values to be converted */
1062
long ntodo, /* I - number of elements in the array */
1063
double scale, /* I - FITS TSCALn or BSCALE value */
1064
double zero, /* I - FITS TZEROn or BZERO value */
1065
int nullcheck, /* I - null checking code; 0 = don't check */
1066
/* 1:set null pixels = nullval */
1067
/* 2: if null pixel, set nullarray = 1 */
1068
short tnull, /* I - value of FITS TNULLn keyword if any */
1069
float nullval, /* I - set null pixels, if nullcheck = 1 */
1070
char *nullarray, /* I - bad pixel array, if nullcheck = 2 */
1071
int *anynull, /* O - set to 1 if any pixels are null */
1072
float *output, /* O - array of converted pixels */
1073
int *status) /* IO - error status */
1075
Copy input to output following reading of the input from a FITS file.
1076
Check for null values and do datatype conversion and scaling if required.
1077
The nullcheck code value determines how any null values in the input array
1078
are treated. A null value is an input pixel that is equal to tnull. If
1079
nullcheck = 0, then no checking for nulls is performed and any null values
1080
will be transformed just like any other pixel. If nullcheck = 1, then the
1081
output pixel will be set = nullval if the corresponding input pixel is null.
1082
If nullcheck = 2, then if the pixel is null then the corresponding value of
1083
nullarray will be set to 1; the value of nullarray for non-null pixels
1084
will = 0. The anynull parameter will be set = 1 if any of the returned
1085
pixels are null, otherwise anynull will be returned with a value = 0;
1090
if (nullcheck == 0) /* no null checking required */
1092
if (scale == 1. && zero == 0.) /* no scaling */
1094
for (ii = 0; ii < ntodo; ii++)
1095
output[ii] = (float) input[ii]; /* copy input to output */
1097
else /* must scale the data */
1099
for (ii = 0; ii < ntodo; ii++)
1101
output[ii] = (float) (input[ii] * scale + zero);
1105
else /* must check for null values */
1107
if (scale == 1. && zero == 0.) /* no scaling */
1109
for (ii = 0; ii < ntodo; ii++)
1111
if (input[ii] == tnull)
1115
output[ii] = nullval;
1120
output[ii] = (float) input[ii];
1123
else /* must scale the data */
1125
for (ii = 0; ii < ntodo; ii++)
1127
if (input[ii] == tnull)
1131
output[ii] = nullval;
1137
output[ii] = (float) (input[ii] * scale + zero);
1144
/*--------------------------------------------------------------------------*/
1145
int fffi4r4(INT32BIT *input, /* I - array of values to be converted */
1146
long ntodo, /* I - number of elements in the array */
1147
double scale, /* I - FITS TSCALn or BSCALE value */
1148
double zero, /* I - FITS TZEROn or BZERO value */
1149
int nullcheck, /* I - null checking code; 0 = don't check */
1150
/* 1:set null pixels = nullval */
1151
/* 2: if null pixel, set nullarray = 1 */
1152
INT32BIT tnull, /* I - value of FITS TNULLn keyword if any */
1153
float nullval, /* I - set null pixels, if nullcheck = 1 */
1154
char *nullarray, /* I - bad pixel array, if nullcheck = 2 */
1155
int *anynull, /* O - set to 1 if any pixels are null */
1156
float *output, /* O - array of converted pixels */
1157
int *status) /* IO - error status */
1159
Copy input to output following reading of the input from a FITS file.
1160
Check for null values and do datatype conversion and scaling if required.
1161
The nullcheck code value determines how any null values in the input array
1162
are treated. A null value is an input pixel that is equal to tnull. If
1163
nullcheck = 0, then no checking for nulls is performed and any null values
1164
will be transformed just like any other pixel. If nullcheck = 1, then the
1165
output pixel will be set = nullval if the corresponding input pixel is null.
1166
If nullcheck = 2, then if the pixel is null then the corresponding value of
1167
nullarray will be set to 1; the value of nullarray for non-null pixels
1168
will = 0. The anynull parameter will be set = 1 if any of the returned
1169
pixels are null, otherwise anynull will be returned with a value = 0;
1174
if (nullcheck == 0) /* no null checking required */
1176
if (scale == 1. && zero == 0.) /* no scaling */
1178
for (ii = 0; ii < ntodo; ii++)
1179
output[ii] = (float) input[ii]; /* copy input to output */
1181
else /* must scale the data */
1183
for (ii = 0; ii < ntodo; ii++)
1185
output[ii] = (float) (input[ii] * scale + zero);
1189
else /* must check for null values */
1191
if (scale == 1. && zero == 0.) /* no scaling */
1193
for (ii = 0; ii < ntodo; ii++)
1195
if (input[ii] == tnull)
1199
output[ii] = nullval;
1204
output[ii] = (float) input[ii];
1207
else /* must scale the data */
1209
for (ii = 0; ii < ntodo; ii++)
1211
if (input[ii] == tnull)
1215
output[ii] = nullval;
1221
output[ii] = (float) (input[ii] * scale + zero);
1228
/*--------------------------------------------------------------------------*/
1229
int fffi8r4(LONGLONG *input, /* I - array of values to be converted */
1230
long ntodo, /* I - number of elements in the array */
1231
double scale, /* I - FITS TSCALn or BSCALE value */
1232
double zero, /* I - FITS TZEROn or BZERO value */
1233
int nullcheck, /* I - null checking code; 0 = don't check */
1234
/* 1:set null pixels = nullval */
1235
/* 2: if null pixel, set nullarray = 1 */
1236
LONGLONG tnull, /* I - value of FITS TNULLn keyword if any */
1237
float nullval, /* I - set null pixels, if nullcheck = 1 */
1238
char *nullarray, /* I - bad pixel array, if nullcheck = 2 */
1239
int *anynull, /* O - set to 1 if any pixels are null */
1240
float *output, /* O - array of converted pixels */
1241
int *status) /* IO - error status */
1243
Copy input to output following reading of the input from a FITS file.
1244
Check for null values and do datatype conversion and scaling if required.
1245
The nullcheck code value determines how any null values in the input array
1246
are treated. A null value is an input pixel that is equal to tnull. If
1247
nullcheck = 0, then no checking for nulls is performed and any null values
1248
will be transformed just like any other pixel. If nullcheck = 1, then the
1249
output pixel will be set = nullval if the corresponding input pixel is null.
1250
If nullcheck = 2, then if the pixel is null then the corresponding value of
1251
nullarray will be set to 1; the value of nullarray for non-null pixels
1252
will = 0. The anynull parameter will be set = 1 if any of the returned
1253
pixels are null, otherwise anynull will be returned with a value = 0;
1258
if (nullcheck == 0) /* no null checking required */
1260
if (scale == 1. && zero == 0.) /* no scaling */
1262
for (ii = 0; ii < ntodo; ii++)
1263
output[ii] = (float) input[ii]; /* copy input to output */
1265
else /* must scale the data */
1267
for (ii = 0; ii < ntodo; ii++)
1269
output[ii] = (float) (input[ii] * scale + zero);
1273
else /* must check for null values */
1275
if (scale == 1. && zero == 0.) /* no scaling */
1277
for (ii = 0; ii < ntodo; ii++)
1279
if (input[ii] == tnull)
1283
output[ii] = nullval;
1288
output[ii] = (float) input[ii];
1291
else /* must scale the data */
1293
for (ii = 0; ii < ntodo; ii++)
1295
if (input[ii] == tnull)
1299
output[ii] = nullval;
1305
output[ii] = (float) (input[ii] * scale + zero);
1312
/*--------------------------------------------------------------------------*/
1313
int fffr4r4(float *input, /* I - array of values to be converted */
1314
long ntodo, /* I - number of elements in the array */
1315
double scale, /* I - FITS TSCALn or BSCALE value */
1316
double zero, /* I - FITS TZEROn or BZERO value */
1317
int nullcheck, /* I - null checking code; 0 = don't check */
1318
/* 1:set null pixels = nullval */
1319
/* 2: if null pixel, set nullarray = 1 */
1320
float nullval, /* I - set null pixels, if nullcheck = 1 */
1321
char *nullarray, /* I - bad pixel array, if nullcheck = 2 */
1322
int *anynull, /* O - set to 1 if any pixels are null */
1323
float *output, /* O - array of converted pixels */
1324
int *status) /* IO - error status */
1326
Copy input to output following reading of the input from a FITS file.
1327
Check for null values and do datatype conversion and scaling if required.
1328
The nullcheck code value determines how any null values in the input array
1329
are treated. A null value is an input pixel that is equal to NaN. If
1330
nullcheck = 0, then no checking for nulls is performed and any null values
1331
will be transformed just like any other pixel. If nullcheck = 1, then the
1332
output pixel will be set = nullval if the corresponding input pixel is null.
1333
If nullcheck = 2, then if the pixel is null then the corresponding value of
1334
nullarray will be set to 1; the value of nullarray for non-null pixels
1335
will = 0. The anynull parameter will be set = 1 if any of the returned
1336
pixels are null, otherwise anynull will be returned with a value = 0;
1342
if (nullcheck == 0) /* no null checking required */
1344
if (scale == 1. && zero == 0.) /* no scaling */
1346
memcpy(output, input, ntodo * sizeof(float) );
1348
else /* must scale the data */
1350
for (ii = 0; ii < ntodo; ii++)
1352
output[ii] = (float) (input[ii] * scale + zero);
1356
else /* must check for null values */
1358
sptr = (short *) input;
1360
#if BYTESWAPPED && MACHINE != VAXVMS && MACHINE != ALPHAVMS
1361
sptr++; /* point to MSBs */
1364
if (scale == 1. && zero == 0.) /* no scaling */
1366
for (ii = 0; ii < ntodo; ii++, sptr += 2)
1368
if (0 != (iret = fnan(*sptr) ) ) /* test for NaN or underflow */
1370
if (iret == 1) /* is it a NaN? */
1374
output[ii] = nullval;
1378
/* explicitly set value in case output contains a NaN */
1379
output[ii] = FLOATNULLVALUE;
1382
else /* it's an underflow */
1386
output[ii] = input[ii];
1389
else /* must scale the data */
1391
for (ii = 0; ii < ntodo; ii++, sptr += 2)
1393
if (0 != (iret = fnan(*sptr) ) ) /* test for NaN or underflow */
1395
if (iret == 1) /* is it a NaN? */
1399
output[ii] = nullval;
1403
/* explicitly set value in case output contains a NaN */
1404
output[ii] = FLOATNULLVALUE;
1407
else /* it's an underflow */
1408
output[ii] = (float) zero;
1411
output[ii] = (float) (input[ii] * scale + zero);
1417
/*--------------------------------------------------------------------------*/
1418
int fffr8r4(double *input, /* I - array of values to be converted */
1419
long ntodo, /* I - number of elements in the array */
1420
double scale, /* I - FITS TSCALn or BSCALE value */
1421
double zero, /* I - FITS TZEROn or BZERO value */
1422
int nullcheck, /* I - null checking code; 0 = don't check */
1423
/* 1:set null pixels = nullval */
1424
/* 2: if null pixel, set nullarray = 1 */
1425
float nullval, /* I - set null pixels, if nullcheck = 1 */
1426
char *nullarray, /* I - bad pixel array, if nullcheck = 2 */
1427
int *anynull, /* O - set to 1 if any pixels are null */
1428
float *output, /* O - array of converted pixels */
1429
int *status) /* IO - error status */
1431
Copy input to output following reading of the input from a FITS file.
1432
Check for null values and do datatype conversion and scaling if required.
1433
The nullcheck code value determines how any null values in the input array
1434
are treated. A null value is an input pixel that is equal to NaN. If
1435
nullcheck = 0, then no checking for nulls is performed and any null values
1436
will be transformed just like any other pixel. If nullcheck = 1, then the
1437
output pixel will be set = nullval if the corresponding input pixel is null.
1438
If nullcheck = 2, then if the pixel is null then the corresponding value of
1439
nullarray will be set to 1; the value of nullarray for non-null pixels
1440
will = 0. The anynull parameter will be set = 1 if any of the returned
1441
pixels are null, otherwise anynull will be returned with a value = 0;
1447
if (nullcheck == 0) /* no null checking required */
1449
if (scale == 1. && zero == 0.) /* no scaling */
1451
for (ii = 0; ii < ntodo; ii++)
1452
output[ii] = (float) input[ii]; /* copy input to output */
1454
else /* must scale the data */
1456
for (ii = 0; ii < ntodo; ii++)
1458
output[ii] = (float) (input[ii] * scale + zero);
1462
else /* must check for null values */
1464
sptr = (short *) input;
1466
#if BYTESWAPPED && MACHINE != VAXVMS && MACHINE != ALPHAVMS
1467
sptr += 3; /* point to MSBs */
1469
if (scale == 1. && zero == 0.) /* no scaling */
1471
for (ii = 0; ii < ntodo; ii++, sptr += 4)
1473
if (0 != (iret = dnan(*sptr)) ) /* test for NaN or underflow */
1475
if (iret == 1) /* is it a NaN? */
1479
output[ii] = nullval;
1483
else /* it's an underflow */
1487
output[ii] = (float) input[ii];
1490
else /* must scale the data */
1492
for (ii = 0; ii < ntodo; ii++, sptr += 4)
1494
if (0 != (iret = dnan(*sptr)) ) /* test for NaN or underflow */
1496
if (iret == 1) /* is it a NaN? */
1500
output[ii] = nullval;
1504
else /* it's an underflow */
1505
output[ii] = (float) zero;
1508
output[ii] = (float) (input[ii] * scale + zero);
1514
/*--------------------------------------------------------------------------*/
1515
int fffstrr4(char *input, /* I - array of values to be converted */
1516
long ntodo, /* I - number of elements in the array */
1517
double scale, /* I - FITS TSCALn or BSCALE value */
1518
double zero, /* I - FITS TZEROn or BZERO value */
1519
long twidth, /* I - width of each substring of chars */
1520
double implipower, /* I - power of 10 of implied decimal */
1521
int nullcheck, /* I - null checking code; 0 = don't check */
1522
/* 1:set null pixels = nullval */
1523
/* 2: if null pixel, set nullarray = 1 */
1524
char *snull, /* I - value of FITS null string, if any */
1525
float nullval, /* I - set null pixels, if nullcheck = 1 */
1526
char *nullarray, /* I - bad pixel array, if nullcheck = 2 */
1527
int *anynull, /* O - set to 1 if any pixels are null */
1528
float *output, /* O - array of converted pixels */
1529
int *status) /* IO - error status */
1531
Copy input to output following reading of the input from a FITS file. Check
1532
for null values and do scaling if required. The nullcheck code value
1533
determines how any null values in the input array are treated. A null
1534
value is an input pixel that is equal to snull. If nullcheck= 0, then
1535
no special checking for nulls is performed. If nullcheck = 1, then the
1536
output pixel will be set = nullval if the corresponding input pixel is null.
1537
If nullcheck = 2, then if the pixel is null then the corresponding value of
1538
nullarray will be set to 1; the value of nullarray for non-null pixels
1539
will = 0. The anynull parameter will be set = 1 if any of the returned
1540
pixels are null, otherwise anynull will be returned with a value = 0;
1546
char *cstring, message[81];
1548
char tempstore, chrzero = '0';
1550
int exponent, sign, esign, decpt;
1552
nullen = strlen(snull);
1553
cptr = input; /* pointer to start of input string */
1554
for (ii = 0; ii < ntodo; ii++)
1557
/* temporarily insert a null terminator at end of the string */
1558
tpos = cptr + twidth;
1562
/* check if null value is defined, and if the */
1563
/* column string is identical to the null string */
1564
if (snull[0] != ASCII_NULL_UNDEFINED &&
1565
!strncmp(snull, cptr, nullen) )
1571
output[ii] = nullval;
1579
/* value is not the null value, so decode it */
1580
/* remove any embedded blank characters from the string */
1589
while (*cptr == ' ') /* skip leading blanks */
1592
if (*cptr == '-' || *cptr == '+') /* check for leading sign */
1599
while (*cptr == ' ') /* skip blanks between sign and value */
1603
while (*cptr >= '0' && *cptr <= '9')
1605
val = val * 10. + *cptr - chrzero; /* accumulate the value */
1608
while (*cptr == ' ') /* skip embedded blanks in the value */
1612
if (*cptr == '.' || *cptr == ',') /* check for decimal point */
1614
decpt = 1; /* set flag to show there was a decimal point */
1616
while (*cptr == ' ') /* skip any blanks */
1619
while (*cptr >= '0' && *cptr <= '9')
1621
val = val * 10. + *cptr - chrzero; /* accumulate the value */
1622
power = power * 10.;
1625
while (*cptr == ' ') /* skip embedded blanks in the value */
1630
if (*cptr == 'E' || *cptr == 'D') /* check for exponent */
1633
while (*cptr == ' ') /* skip blanks */
1636
if (*cptr == '-' || *cptr == '+') /* check for exponent sign */
1643
while (*cptr == ' ') /* skip blanks between sign and exp */
1647
while (*cptr >= '0' && *cptr <= '9')
1649
exponent = exponent * 10 + *cptr - chrzero; /* accumulate exp */
1652
while (*cptr == ' ') /* skip embedded blanks */
1657
if (*cptr != 0) /* should end up at the null terminator */
1659
sprintf(message, "Cannot read number from ASCII table");
1661
sprintf(message, "Column field = %s.", cstring);
1663
/* restore the char that was overwritten by the null */
1665
return(*status = BAD_C2D);
1668
if (!decpt) /* if no explicit decimal, use implied */
1671
dvalue = (sign * val / power) * pow(10., (double) (esign * exponent));
1673
output[ii] = (float) (dvalue * scale + zero); /* apply the scaling */
1676
/* restore the char that was overwritten by the null */