Astronomie · English version

How to create an image from FITS-files

Translated spanish version

If you want to create an image from telescope data, you might see data in the FITS format, which you cannot open without the right software. FITS-files end with .fits, .FITS, .fit, .FIT, .fts, .FTS …

First you have to download it from a service. For Infrared Images you should use IRSA (like 2MASS, Spitzer, WISE, Planck, Herschel).
For a wide selection of survey data you can use SkyView (not Hubble or Spitzer or Herschel) and very useful is that the FITS-file does rotate depending on the coordinate system you use!
If I want to use Hubble data, you can use the MAST portal, which has a lot of data, but you have to enter coordinates in RA and DEC. In MAST you can enter the search radius after the coordinates in degrees, for example select “All Virtual Observatory Collections” enter Alf Cen r=0.5, and it will search 0.5° around Alpha Centauri for images, catalogs and spectra.
For ESO data you can use the ESO archive, but you need an account, which is free for everyone. Only the DSS data is avaiable without a login, but you can also use SkyView for searching DSS images.
There are all kind of other image archives, like SuperCOSMOS H-alpha, IPHAS or Akari and sometimes you have to read a bit about the filters, before you can begin.

footer-si After you have downloaded the files, you need a software. I use SAO Image DS9, which can be used for a lot of cool things. SAO does stand for Smithsonian Astrophysical Observatory.

DS9 is a standalone application, so you can start it after the installation. It should look like this:


As you can see there is a top menu, below a info frame and two small image frames, a menu in the middle and finally on the bottom a large frame with a brightness scale.

You can download the FITS-files I used by entering 25.29 0.29 ga in the coordinate field of GLIMPSE, with 0.25 cutout-size.

You can open a FITS-file via File->Open…


I did open a Spitzer 3.6 μm (I1) file from IRSA and you should see that the scale on the bottom did change. Also the info frame does show something:

  • File – File name
  • Value – A value for the brightness
  • fk5 – The coordinates in a chosen coordinate system (WCS)
  • Image – Pixel Coordinates of the image

The both coordinates change if you move your curser. The small frame with coordinate axes show the entire image. The cyan box shows the area shown in the large main frame below, the green coordinate axes (x, y) is the image coordinate system and the yellow is the chosen coordinate system (North, East).

But you cannot see much in this image. Now you have to scale the image. For this you can either use the top menu, which is more detailed, or you can use the bottom menu, which is faster. The default is “linear” and “min max”, change this to “square root” and “ZScale”:


With the zoom-menu you can change the zoom, or you can use your mouse-wheel (does not work always). If you want to change the center of view, you can either click and drag the cyan box or you change Edit->pan, then the main frame will center to the position you click on.

Now we want to open other images. Before you open a new image, you should choose Frame->tile frame. This way you can look at both images at the same time. After choosing Frame->New Frame a new frame will appear and you can open a new image with File->Open…


You might find useful to select Frame->Lock->Frame->WCS, because if you pan or zoom one image, the other image will pan the same way.

Now we want to create a RGB image (image with colours). If you have photoshop you can crop the images and export them as PNG, but I want to show you how to do this without photoshop:

First reopen SAO ds9 and choose Frame->New Frame RGB. A small window will open:


For a RGB (Red-Green-Blue) image you should always choose the shortest wavelenght for blue and the longest wavelength for red. So first choose the 8.0 μm FITS and open it.


You should scale the image right for every colour: use again “square root” and “ZScale” and then scale it manually by coosing Scale->Scale Parameters, until every detail is visible, bright structures are bright and faint structures are black. You can do this by dragging the red and green line. Then you choose “green” for “current”, unselect “view” for “red” and do the same after opening the 4.5 μm image. At last you choose “blue” for “current”, unselect “view” for “green” and do the above after opening the 3.6 μm image.

If you are done, you can select “view” for all RGB and it should look like this:


Now you can choose File->Export->PNG and there is your coloured image!


This works just fine if every image has the exact same resolution, like GLIMPSE. But what happens if you use two different surveys, like GLIMPSE and MIPSGAL. Lets open the files for SNR G011.2-00.3, a supernova remnant. Those are visible at 24 μm and we want 8.0 μm and 4.5 μm as a background. You can just enter SNR G011.2-00.3 in the coordinate/object field and load the fits-files in a RGB-frame (as described above). If you try to export this image, you will always see a nasty error:


There is another way to save images: File>Save Image>png

But if you run DS9 on windows this might not work (maybe the new version has fixed this problem already?). If you try this you might get an image that is cut off and is almost entierly white. You need to find your copy (mine is at C:\ds9\ds9.exe) and open the preferences. There you have to check that DS9 runs with your version of windows, for example Windows 8 and not an old version, but this is not going to work with
Windows 10. There is DS9 Version 7.6b8 (October 31, 2017), but it has problems, see
notes in the end.
Sorry that this is in German, but I don’t want to change the language for this:

prevent fail

Now we can continue and you might save your image File>Save Image>png:


Saving an image can take a while. And there might be something you don’t want to see. DS9 saves everything in the large main frame, including the colorbar.


So you can remove the colorbar at View>Colorbar. The result is the image without the colorbar.


If you want to change the language of your DS9 copy, you can find this at Edit>Preferences>General>Languages. But you might need to restart DS9 after clicking on save. You might find it more comfortable to work with your local language.


If you want to know how to open a fits-file on Aladin Desktop Version, you might check this tutorial in galaxyzoo by Ghost_Sheep_SWR: Is it a supernova? Check transients with Aladin. There are also additional links to surveys.

Notes about DS9 7.6b8

DS9 Version 7.6b8 (October 31, 2017) corrects the compatibility problem between DS9
and whatever Windows version your computer is running. But, introduces two new

1. File -> Save Image -> PNG (or JPEG) don’t work, if you try to save you are to just get the following error due to this version still being in beta for Windows, this is going to stop us from saving the files,


2. If our image allow us to use the File -> Export -> GIF / TIFF / JPEG / PNG we are going to find a new bug. At first we are to think that everything is normal, we just put the name that we want for the file in the dialog box:


But when we go to the folder to check the result, we find this:


DS9 saved correctly, but without file extension, that is going to prevent us from opening the file like we normally do. To avoid this problem we are going to do the following, write the extension after the name of the file:


With this simple step, we correct the problem making DS9 to save the correct extension for the file, allowing us to open the file normally.



The executable file of DS9 7.68b is going to trigger false positive warnings in some antivirus like Avira or Avast, to avoid this problem the easiest way is to deactivate the antivirus while executing this file for the first time.


The next tutorial will be about fits-files that have multiple images saved in one file and how to open those files (sometimes ESO provides such files). And how to open DS9 with the command line.





2 thoughts on “How to create an image from FITS-files

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s