hubble_separation.py 1.35 KB
Newer Older
Jakob Knollmueller's avatar
Jakob Knollmueller committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
from point_separation import build_problem, problem_iteration, load_data
from nifty2go import *
import numpy as np
from matplotlib import rc
rc('font',**{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)
from matplotlib import pyplot as plt
from matplotlib.colors import LogNorm


np.random.seed(42)
if __name__ == '__main__':
    path = 'hst_05195_01_wfpc2_f702w_pc_sci.fits'
    data = load_data(path)
    alpha = 1.3



    myEnergy = build_problem(data, alpha=alpha)
    for i in range(10):
        myEnergy = problem_iteration(myEnergy)

    size = 15
    vmin = data.min()+0.01
    vmax = 0.1*data.max()
    plt.figure()
    plt.imshow(np.exp(myEnergy.s.val),norm=LogNorm(vmin=vmin, vmax=vmax))
    cbar = plt.colorbar()
    cbar.set_label('flux', size=size)
    plt.title('diffuse emission', size=size)
    plt.axis('off')
    plt.savefig('hubble_diffuse.pdf')

    plt.figure()
    plt.imshow(np.exp(myEnergy.u.val), norm=LogNorm(vmin=vmin, vmax=vmax))
    cbar = plt.colorbar()
    cbar.set_label('flux', size=size)
    plt.title('point-like emission', size=size)
    plt.axis('off')
    plt.savefig('hubble_point.pdf')

    plt.figure()
    plt.imshow(data, norm=LogNorm(vmin=vmin, vmax=vmax))
    cbar = plt.colorbar()
    cbar.set_label('flux', size=size)
    plt.title('data', size=size)
    plt.axis('off')
    plt.savefig('hubble_data.pdf')
    plt.close()