Subject: FITS-support for Mathematica

From: dwells at nrao.edu (Don Wells)
Date: Fri, 16 Sep 1994 02:34:04 GMT

I thank Fred Schwab <fschwab at nrao.edu> for alerting me to the
existence of this thread in newsgroup sci.math.symbolic. -Don Wells
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Newsgroups: sci.math.symbolic
From: abraham at haida (Bob Abraham)
Subject: MMA and FITS format images
Nntp-Posting-Host: haida.dao.nrc.ca
Organization: University of Victoria
Date: Wed, 14 Sep 94 00:49:18 GMT

Hi,

Has anybody written a routine to let Mathematica read images in FITS
format? If so, I'd be very grateful if you would get get in touch with
me.

Cheers,

Bob

PS. in case anybody is curious: FITS (Flexible Image Transport Format)
images are mixed text/binary format files that are becoming a de-facto
standard for use in astronomy.
--
-----------------------------------------------------------------------------
Dr. R. G. Abraham                    |  Internet: abraham at dao.nrc.ca
Dominion Astrophysical Observatory   |  Bitnet:   abraham at nrcdao.nrc.ca
Herzberg Institute of Astrophysics   |  phone:  (604) 363-0028
National Research Council of Canada  |  fax:    (604) 363-0045
5071 W. Saanich Rd.                  |  telex:  049-7295 
Victoria, B.C., V8X 4M6              |
CANADA                               |
-----------------------------------------------------------------------------
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
From: elsner at avalon.msfc.nasa.gov (Ron Elsner)
Newsgroups: sci.math.symbolic
Subject: Reading FITS files in Mma
Date: 14 Sep 1994 18:29:54 GMT
Organization: NASA/MSFC

I do not have a package to read all FITS files with one cammand, but I can  
read them treating each case separately.

To read even modest sized binary files in Mathematica you MUST obtain the 
FastBinaryFiles MathLink Package from MathSource.  You can do this via 
anonymous ftp to ftp.wri.com.  You will have peruse their index to find  
it, or ask Wolfram Research Inc.  After compiling the source code you can  
read FITS files as follows (simple example):

Link to the package:  
 SetDirectory[ "~/AXAF93Math/MathSource" ] ; 
 link = Install[ "binary" ] 

Open the input file:  
 infile = OpenReadBinary[ "image.fit" ] 

Read the 36 (or whatever) record, 80 columns per record, ascii header:  
 TableForm[ hdr = 
 Table[ FromCharacterCode[ ReadListBinary[ infile, Byte, 80 ] ], {36} ] ] 

Read the binary image using information from the header:
     image = Partition[ ReadListBinary[ infile, Int16 ], 512 ] ; 

In the above case, the header tells us that this is a 512 (1st axis) by  
480 (2nd axis) image with 16 bits per data pixel.  The array image will  
have dimensions 480 by 512, which you can Transpose if you like.

Hope this helps.
--------------------------------------------------------------------------
Ron Elsner/ES84                                 205-544-7741
NASA Marshall Space Flight Center               205-544-7754 (Fax)
Huntsville, AL 35812                            elsner at ssl.msfc.nasa.gov

--
  Donald C. Wells         Associate Scientist         dwells at nrao.edu
                    http://fits.cv.nrao.edu/~dwells
  National Radio Astronomy Observatory                +1-804-296-0277
  520 Edgemont Road,   Charlottesville, Virginia       22903-2475 USA