Skip to content

FITS basics

PK0207 edited this page Aug 15, 2021 · 6 revisions

*** AN UNDERSTANDING OF PYTHON IS ASSUMED IN THIS INTRODUCTION ***

A FITS file is a complicated image file that, along with the image itself, contains information about the conditions in which an image was taken, along with any other information that one may desire to put in it. It is a versatile tool that astronomers use for observational data.

SAO DS9 - a program designed to view and work with FITS files

HEADER DATA

When someone references Header data, what they are usually referring to is the data that comes with the fits file that contains all of the details about the observing conditions in which the image was taken. Such information can include the time and location at which the images were taken, the CCD specifications and much more. Different telescope sites process the image in different ways, and will therefore have some different values in their header data, but some core information is always there.

How to access the header from python:

from astropy.io import fits

file_path = "/path/to/fits/file/"

hdul = fits.open(file_path)

When you print the hdul, you will see that it is a list of file objects i.e., there are multiple files contained in the .fits file. The header data is located in the image often called the "Science" image. This can be called with either the indices ['SCI'] or [0], depending on what site the images are from (LCO uses ['SCI']).

header = hdul["SCI"].header

This output is your image header. For the other files contained in the HDUL, visit the respective telescope site's website.

Pipeline Outputs

subtract - a PRIMARY hdu which refers to the residual image. The residual should look like a gray, uniform background with black dots where there are variable stars.

extract - a FITSRec table that comes from source extractor python (sep). Each index of the table contains all of the data sep finds regarding a single star in the image. By default, the table is named XRT. This name can be changed using:
extract -w NAME 1 where the 1 refers to the position in the list of hduls

ref - a FITSRec table that contains data from querying the external Gaia database. The purpose of the query is to find additional information about the stars in our images, such that we can extrapolate new information from them. Similar to CAT, each index in the table refers to all of the information about one object. It is important to note that each index of the tables CAT and REF refers to the same object, and that the table should be of the same size.

collate - a TableHDU where each entry references an index in an existing FITSRec table produced by extract. The command runs a clustering algorithm, either DBSCAN or OPTICS, on sep source data and attempts to match sources between images that belong to the same sky object by modeling matching sources as clusters, using normalized flux and ra/dec or xy as coordinates and pulling out these clusters using any of the clustering algorithms. The TableHDU returned is named OBJ by default and the ith entry of each image’s table will refer to the same object. Each entry will be either a non-negative integer corresponding to an index for an sep table pointing to a source, or will be -1 indicating that no appropriate matching source was found for a particular object in a particular image.

Writing to a FITS file