Пример #1
0
def make_plots(dirname, fnames):
    # get the highest-level directory, assume it is the target source ID
    obj = os.path.split(dirname)[-1]

    for fn in fnames:
        # each band gets listed...
        if 'band0' not in fn or '.sav' not in fn:
            continue
        # templates:
        # coadd_cleanband0in_clean_music_20130815_jk000.sav
        # 130820_ob1_band0i_clean_music_20130815_map.sav
        obs = "_".join(fn.split("_")[:2])
        #obs = fn[:11]

        print "Working on file ", os.path.join(dirname, obs)

        data = load_data(os.path.join(dirname, obs))
        sm, us = convolve_and_match(data, obj, writefits=False)
        flux, bg, err = sed_from_dict(sm)

        pl.clf()
        plot_sed(flux, bg, err, label='Smooth')
        flux, bg, err = sed_from_dict(us)
        plot_sed(flux, bg, err, label='Unsharp')

        pl.title(obj)
        pl.legend(loc='best')
        pl.savefig(os.path.join(dirname, obj + obs) + "_SED.png",
                   bbox_inches='tight')
Пример #2
0
def make_plots(dirname, fnames):
    # get the highest-level directory, assume it is the target source ID
    obj = os.path.split(dirname)[-1]

    for fn in fnames:
        # each band gets listed...
        if 'band0' not in fn or '.sav' not in fn:
            continue
        # templates:
        # coadd_cleanband0in_clean_music_20130815_jk000.sav
        # 130820_ob1_band0i_clean_music_20130815_map.sav
        obs = "_".join(fn.split("_")[:2])
        #obs = fn[:11]

        print "Working on file ",os.path.join(dirname,obs)

        data = load_data(os.path.join(dirname,obs))
        sm,us = convolve_and_match(data,obj,writefits=False)
        flux,bg,err = sed_from_dict(sm)

        pl.clf()
        plot_sed(flux,bg,err, label='Smooth')
        flux,bg,err = sed_from_dict(us)
        plot_sed(flux,bg,err, label='Unsharp')

        pl.title(obj)
        pl.legend(loc='best')
        pl.savefig(os.path.join(dirname,obj+obs)+"_SED.png",bbox_inches='tight')
Пример #3
0
def make_plots(dirname, fnames):
    obj = os.path.split(dirname)[-1]
    for fn in fnames:
        # each band gets listed...
        if 'band0' not in fn:
            continue
        obs = fn[:11]

        print "Working on file ", os.path.join(obj, obs)

        data = load_data(os.path.join(obj, obs))
        sm, us = convolve_and_match(data, 'W49', writefits=False)
        flux, bg, err = sed_from_dict(sm)

        pl.clf()
        plot_sed(flux, bg, err, label='Smooth')
        flux, bg, err = sed_from_dict(us)
        plot_sed(flux, bg, err, label='Unsharp')

        pl.title(obj)
        pl.legend(loc='best')
        pl.savefig(os.path.join(obj, obs) + "_SED.png", bbox_inches='tight')
Пример #4
0
def make_plots(dirname, fnames):
    obj = os.path.split(dirname)[-1]
    for fn in fnames:
        # each band gets listed...
        if 'band0' not in fn:
            continue
        obs = fn[:11]

        print "Working on file ",os.path.join(obj,obs)

        data = load_data(os.path.join(obj,obs))
        sm,us = convolve_and_match(data,'W49',writefits=False)
        flux,bg,err = sed_from_dict(sm)

        pl.clf()
        plot_sed(flux,bg,err, label='Smooth')
        flux,bg,err = sed_from_dict(us)
        plot_sed(flux,bg,err, label='Unsharp')

        pl.title(obj)
        pl.legend(loc='best')
        pl.savefig(os.path.join(obj,obs)+"_SED.png",bbox_inches='tight')
Пример #5
0
def make_plots(dirname, fnames):
    # get the highest-level directory, assume it is the target source ID
    obj = os.path.split(dirname)[-1]

    for fn in fnames:
        # each band gets listed...
        if 'band0' not in fn or '.sav' not in fn:
            continue
        # templates:
        # coadd_cleanband0in_clean_music_20130815_jk000.sav
        # 130820_ob1_band0i_clean_music_20130815_map.sav
        obs = "_".join(fn.split("_")[:2])
        #obs = fn[:11]

        print "Working on file ",os.path.join(dirname,obs)

        data = load_data(os.path.join(dirname,obs))
        headers = {k: load_header(data[k].mapstruct) for k in data}
        sm,us = convolve_and_match(data,obj,headers=headers,writefits=True,savepath=dirname)
        vmin = -1000 #max([sm[2].min(),-1000])
        vmax = max([sm[2].max(),5000])
        print obj, obs, vmin, vmax

        prefix = os.path.join(dirname,obj+obs)

        pl.clf()
        viewer(data, vmin=vmin, vmax=vmax, cb=True)
        pl.suptitle(obj)
        pl.savefig(prefix+"_quicklook.png",bbox_inches='tight')

        pl.clf()
        dictviewer(sm, vmin=vmin, vmax=vmax, cb=True)
        pl.suptitle(obj)
        pl.savefig(prefix+"_quicklook_smooth.png",bbox_inches='tight')

        pl.clf()
        dictviewer(us, vmin=vmin, vmax=vmax, cb=True)
        pl.suptitle(obj)
        pl.savefig(prefix+"_quicklook_unsharp.png",bbox_inches='tight')
from astropy.io import fits
import idlsave
import itertools
import scipy.ndimage
from astropy.nddata.convolution import make_kernel,convolve
import numpy as np
import sys
import os
sys.path.append(os.path.split(os.getcwd())[0])
from convolve_match_makefits import convolve_and_match

data_g010_1 = {k:idlsave.read('gal_010.47+00.03/130820_ob3_band%ii_clean_music_20130815_map.sav' % k) for k in xrange(4)}
data_g010_2 = {k:idlsave.read('gal_010.47+00.03/130820_ob4_band%ii_clean_music_20130815_map.sav' % k) for k in xrange(4)}
data_g000_1 = {k:idlsave.read('gal_0.253+0.016/130820_ob1_band%ii_clean_music_20130815_map.sav' % k) for k in xrange(4)}
data_g000_2 = {k:idlsave.read('gal_0.253+0.016/130820_ob2_band%ii_clean_music_20130815_map.sav' % k) for k in xrange(4)}
data_g012_1 = {k:idlsave.read('gal_012.21-00.10/130820_ob5_band%ii_clean_music_20130815_map.sav' % k) for k in xrange(4)}
data_g012_2 = {k:idlsave.read('gal_012.21-00.10/130820_ob6_band%ii_clean_music_20130815_map.sav' % k) for k in xrange(4)}

datasets = dict(zip(['G010_1','G010_2','G000_1','G000_2','G012_1','G012_2'],
                    [data_g010_1, data_g010_2, data_g000_1, data_g000_2, data_g012_1, data_g012_2]))

for jj,(k,data) in enumerate(datasets.iteritems()):
    print(jj)
    convolve_and_match(data,k)
data_g000_1 = {
    k: idlsave.read(
        'gal_0.253+0.016/130820_ob1_band%ii_clean_music_20130815_map.sav' % k)
    for k in xrange(4)
}
data_g000_2 = {
    k: idlsave.read(
        'gal_0.253+0.016/130820_ob2_band%ii_clean_music_20130815_map.sav' % k)
    for k in xrange(4)
}
data_g012_1 = {
    k: idlsave.read(
        'gal_012.21-00.10/130820_ob5_band%ii_clean_music_20130815_map.sav' % k)
    for k in xrange(4)
}
data_g012_2 = {
    k: idlsave.read(
        'gal_012.21-00.10/130820_ob6_band%ii_clean_music_20130815_map.sav' % k)
    for k in xrange(4)
}

datasets = dict(
    zip(['G010_1', 'G010_2', 'G000_1', 'G000_2', 'G012_1', 'G012_2'], [
        data_g010_1, data_g010_2, data_g000_1, data_g000_2, data_g012_1,
        data_g012_2
    ]))

for jj, (k, data) in enumerate(datasets.iteritems()):
    print(jj)
    convolve_and_match(data, k)