Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to read in the FITS file into Mathematica. My FITS file is very simple, it should be 2 columns of numbers.

What should be the correct Mathematica command to convert this fits file into a table of numbers?

share|improve this question

closed as off-topic by Oleksandr R., Verbeia Jun 26 '13 at 2:46

  • The question does not concern the technical computing software Mathematica by Wolfram Research. Please see the help center to find out about the topics that can be asked here.
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Did you have trouble with Import? If so, what happened? –  Oleksandr R. Jun 26 '13 at 1:32
    
Thanks for the answer! I do not have troubles when I import as rawdata = Import[file, "Data"], but when I ask Mathematica to display rawdata, it has all kinds of weird symbols. Those symbols should be some numbers, but I do not know how to convert them into a readable format. –  user6573 Jun 26 '13 at 1:53
    
FITS files are able to contain all sorts of things. If "weird symbols" show up, perhaps your file doesn't contain what you think it does. To get a more specific answer you will certainly have to upload your file (or an appropriate substitute) somewhere so that we can see it. –  Oleksandr R. Jun 26 '13 at 1:58
    
Sorry, I am pretty new in this website, but where can I attachment my file? Thanks! –  user6573 Jun 26 '13 at 2:02
1  
Question should be closed as off-topic since the difficulty is due to the file not containing what it was thought to contain, not because of any problem with Mathematica. –  Oleksandr R. Jun 26 '13 at 2:22

1 Answer 1

According to the documentation, importing a FITS file returns an image by default, corresponding to the "Image" element:

Import["file.fits"] (* equivalent to Import["file.fits", {"FITS", "Image"}] *)

You can use the ImageData function to convert this result into numbers, of course, but it's usually preferable not to have to do this, especially if the file didn't contain image data in the first place, in order to avoid normalization and conversion to floating point values.

Alternatively, one may import either the "Data" or the "RawData" element.

The former produces an array of floating-point values, normalized between 0 and 1, and is presumably what the image would have been built from, if one had asked for that instead:

Import["file.fits", {"FITS", "Data"}]

The latter, however, returns whatever is in the file as unscaled values, of either integer or floating-point type as appropriate. This is what I suppose one will prefer in most cases for FITS files containing non-image data:

Import["file.fits", {"FITS", "RawData"}]
share|improve this answer
    
My fits file only contains data, it should be a table, and I want to write those data into a human readable file. –  user6573 Jun 26 '13 at 1:54
    
I just uploaded my file to the following link: user.iter.org/filesharing/… Could you please help me to take a look? Thanks a lot! –  user6573 Jun 26 '13 at 2:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.