In [1]:
# %load /Users/jdecock/git/pub/jdhp/snippets/science/wavelet_transform/read_mrtransform.py
In [2]:
%matplotlib inline
from astropy.io import fits
import numpy as np
import matplotlib.pyplot as plt

Tool functions

In [3]:
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 [4]:
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 [5]:
file_path = "/Users/jdecock/git/pub/jdhp/snippets/science/wavelet_transform/test.fits"

Apply mr_filter

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

Read and plot an .mr file

In [7]:
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))
0 (40, 40)
1 (40, 40)
2 (40, 40)
3 (40, 40)