In [ ]:
# %load /Users/jdecock/git/pub/jdhp/snippets/science/wavelet_transform/read_mrtransform.py

In [ ]:
%matplotlib inline
from astropy.io import fits
import numpy as np
import matplotlib.pyplot as plt

Tool functions


In [ ]:
def read_mr_file(file_path):
    hdu_list = fits.open(file_path) # Open the FITS file
    data = hdu_list[0].data
    hdu_list.close()                # Close the FITS file
    return data

In [ ]:
def plot(data, title=""):
    fig = plt.figure()
    ax = fig.add_subplot(111)

    im = ax.imshow(data, interpolation='nearest', origin='lower', cmap="gnuplot2")   # cmap=cm.inferno and cmap="inferno" are both valid
    ax.set_title(title)
    
    plt.colorbar(im) # draw the colorbar
    plt.show()

Apply mr_transform


In [ ]:
file_path = "/Users/jdecock/git/pub/jdhp/snippets/science/wavelet_transform/test.fits"

Apply mr_filter


In [ ]:
file_path = "/Users/jdecock/git/pub/jdhp/snippets/science/wavelet_transform/test.fits"

Read and plot an .mr file


In [ ]:
file_path = "/Users/jdecock/git/pub/jdhp/snippets/science/wavelet_transform/test.out.fits.mr"
data = read_mr_file(file_path)

for scale_index, scale in enumerate(data):
    print(scale_index, scale.shape)
    plot(scale, "Scale {}".format(scale_index))