#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Documentation: http://docs.astropy.org/en/stable/io/fits/index.html

import argparse
from astropy.io import fits

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm


# PARSE OPTIONS ###############################################################

parser = argparse.ArgumentParser(description="An astropy snippet")

parser.add_argument("filearg", nargs=1, metavar="FILE", help="the FITS file to process")

args = parser.parse_args()

file_path = args.filearg[0]


# INIT MATPLOTLIB #############################################################

fig = plt.figure(figsize=(8.0, 8.0))
ax = fig.add_subplot(111)


# READ DATA ###################################################################

# Open the FITS file
hdu_list = fits.open(file_path)

# Print the content of the FITS file (HDU headers)
hdu_list.info()

for hdu in hdu_list:
    data = hdu.data   # "hdu.data" is a Numpy Array
    ax.imshow(data, interpolation='nearest', cmap=cm.gray)
    plt.show()

# Close the FITS file
hdu_list.close()


@@ -886,27 +886,59 @@
 ()%0A%0A
-for hdu in 
+print(%22---%22)%0A%0Afor hdu_id, hdu in enumerate(
 hdu_list
 :%0A  
@@ -937,10 +937,159 @@
 list
+)
 :%0A
+    print(%22HDU %7B%7D%22.format(hdu_id))%0A%0A    header = hdu.header%0A    for key, value in header.items():%0A        print(key, %22:%22, value)%0A%0A    print(%22---%22)%0A%0A
     
@@ -1136,16 +1136,17 @@
 y Array%0A
+%0A
     ax.i
@@ -1196,16 +1196,59 @@
 m.gray)%0A
+    ax.set_title(%22HDU %7B%7D%22.format(hdu_id))%0A%0A
     plt.

Improve a snippet.