[fitsbits] reading a single value
William Pence
pence at tetra.gsfc.nasa.gov
Mon Jul 28 14:14:02 EDT 2003
Nico Vermaas wrote:
>
> Would this be the right way to read a single value from a fits file?
> (I add [x:x,y:y,z:z] to the filename and then read one float).
>
> --
> sprintf(filter,"%s[%d:%d,%d:%d,%d:%d]",this->filename,point[X],point[X],point[Y],point[Y],point[Z],point[Z]);
> if (!fits_open_file(&fptr, filter, READONLY, &status)) {
> fits_read_img(fptr,TFLOAT,1,1,0,buffer,0,&status);
> } // if
Note that it would be better to send questions that are specific to CFITSIO
directly to me at the HEASARC, rather than posting them to this newsgroup.
To answer your question though, the above method of reading a single pixel
in an image will work, but it is rather unorthodox. (Also, the 7th parameter
in the fits_read_img call must be a pointer to an int, not 0). The more
direct way would be to first open the image (without any image section
filters) then:
long fpixel[3];
fpixel[0]=point[X];
fpixel[1]=point[Y];
fpixel[2]=point[Z];
fits_read_pix(fptr,TFLOAT,fpixel,1,0,buffer,&anynul,&status);
-Bill Pence
--
____________________________________________________________________
Dr. William Pence William.D.Pence @ nasa.gov
NASA/GSFC Code 662 HEASARC +1-301-286-4599 (voice)
Greenbelt MD 20771 +1-301-286-1684 (fax)
More information about the fitsbits
mailing list