Quick look to the catalogue

  • I've just created a small notebook to have a very quick look into the contents of fits files. The contents are same in HDF5 as well.
In [ ]:
# Importing important modules

import numpy as np
from astropy.io import fits
from astropy.table import Table

import matplotlib.pyplot as plt
  • Download the fits files (if you've not done already):

    Mg II

    Fe II

In [ ]:
hdu_list = fits.open(path_to_file, memmap=True) ## Replace path_to_file by the location of the fits file
In [ ]:
hdu_list.info() ## To see the contents of fits header
In [ ]:
cat_data = Table(hdu_list[1].data) # Save the data in Table format
In [ ]:
cat_data ## To see the content of the Table

Plotting histograms of quantitites from the catalogue (1D)

  • 1D histograms:
In [ ]:
keyname = 'Z_QSO' # type keyname (e.g. 'Z_ABS', 'Z_QSO', 'REST_EW_MGII_2796', ...)
hist_data = cat_data[keyname]
In [ ]:
# histogram plotter

def plot_hist(hist_data, bins, ylog, xlabel, ylabel, fig_file=None):
    
    fig = plt.figure(figsize=(6.5, 5.5))
    ax = fig.add_subplot(111)
    
    ax.hist(hist_data, bins=bins, alpha=0.5)
    if ylog:
        ax.set_yscale('log')
    ax.set_xlabel(xlabel, fontsize=16)
    ax.set_ylabel(ylabel, fontsize=16)
    fig.tight_layout()
    
    if fig_file is not None:
        plt.savefig(fig_file)
    else:
        plt.show()
    
    return None
    
In [ ]:
plot_hist(hist_data, bins=50, ylog=True, xlabel='Redshifts', ylabel='Number of Absorbers', fig_file=None)

Plotting 2D scatter plots of quantitites from the catalogue

  • Use the function below to plot scatter plot
In [ ]:
def plot_scatter_plot(xvals, yvals, xlog, ylog, xlabel, ylabel, fig_file):
    
    fig = plt.figure(figsize=(6.5, 5.5))
    ax = fig.add_subplot(111)
    
    ax.scatter(xvals, yvals, color='g', s=2, marker='o', alpha=0.5, rasterized=True)
    
    if ylog:
        ax.set_yscale('log')
    if xlog:
        ax.set_xscale('log')
        
    ax.set_xlabel(xlabel, fontsize=16)
    ax.set_ylabel(ylabel, fontsize=16)
    fig.tight_layout()
    
    if fig_file is not None:
        plt.savefig(fig_file)
    else:
        plt.show()
    
    return None
In [ ]:
x_key = 'Z_QSO' # type keyname (e.g. 'Z_ABS', 'Z_QSO', 'REST_EW_MGII_2796', ...)
y_key = 'Z_ABS' # type keyname (e.g. 'Z_ABS', 'Z_QSO', 'REST_EW_MGII_2796', ...)

xvals = cat_data[x_key]
yvals = cat_data[y_key]
In [ ]:
plot_scatter_plot(xvals, yvals, xlog=False, ylog=False, xlabel='z_QSO', ylabel='z_MgII', fig_file=None)