#--Ploting a fits image with astropy. # ipython3 <-- start IPython (more functionality than python3) import astropy import matplotlib.pyplot as plt from astropy.visualization import astropy_mpl_style plt.style.use(astropy_mpl_style) from astropy.utils.data import get_pkg_data_filename from astropy.io import fits image_file = get_pkg_data_filename('tutorials/FITS-images/HorseHead.fits') # image_file is the whole fits file: header, image data, etc. image_data = fits.getdata(image_file, ext=0) # image_data is the image part of the fits file print(image_data.shape) plt.figure() plt.imshow(image_data, cmap='rainbow') plt.colorbar() # This is the path to a fits file on my laptop -- put in the path # to a fits file you have on your computer. BD_file = '/home/tages/CLASS/A288C/BD30.dat/bd30_H-alpha.fits' im = fits.getdata(BD_file, ext=1) print(im.shape) # see what size the image is plt.figure() plt.imshow(im,cmap='rainbow') plt.colorbar() # to do any computations on the whole image, we need NumPy import numpy as np z=np.log(im+1.0) # use the numpy log: np.log() plt.imshow(z,cmap='rainbow_r') # play with different transformations of your image data z=np.arctan(np.sqrt(im)) # this brings out faint halo features plt.imshow(z,cmap='rainbow')