예제 #1
0
for thisfile in fl:
    fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2, constrained_layout=True)
    fig.set_size_inches(6.5, 6.5)
    cube = SpectralCube.read(thisfile)
    gal = os.path.split(thisfile)[-1].split('_')[0]
    shortfile = os.path.split(thisfile)[-1]

    try:
        mask = SpectralCube.read(degas_data +
                                 '/masks/{0}_mask.fits'.format(gal))
        mask = mask.with_spectral_unit(u.km / u.s, velocity_convention='radio')
        hdr = mask.header
        hdr['CTYPE3'] = 'VRAD'
        mask = SpectralCube(mask.filled_data[:], wcs.WCS(hdr), header=hdr)
        mask = mask.with_mask(mask.filled_data[:] > 0)
        mask = mask.spectral_interpolate(cube.spectral_axis)
        mask = mask.reproject(cube.header)

    except FileNotFoundError:
        print('No mask for ' + thisfile)
        mask = SpectralCube(np.ones(cube.shape),
                            wcs=cube.wcs,
                            header=cube.header)

    rmsamplitude = scm.noise_cube(cube.filled_data[:].value,
                                  box=5,
                                  spec_box=5,
                                  iterations=5,
                                  bandpass_smooth_window=21)
    s2n = cube.filled_data[:].value / rmsamplitude
예제 #2
0
    for gal, ax in zip(subtable['NAME'], axlist.flatten()):
        eta_mb = eta_mb_dict[molecule]
        degas_cube_name = 'IR5/{0}_{1}_rebase3_smooth1.3_hanning1.fits'.format(gal, molecule)
        if not os.path.exists(degas_data + degas_cube_name):
            ax.set_title(gal)
            ax.text(0.5, 0.5, 'No data',ha='center')
            continue
        cube_degas = SpectralCube.read(degas_data + degas_cube_name)
        cube_degas = cube_degas / eta_mb
        mask = SpectralCube.read(degas_data + '/masks/{0}_mask.fits'.format(gal))
        mask = mask.with_spectral_unit(u.km/u.s, velocity_convention='radio')
        hdr = mask.header
        hdr['CTYPE3'] = 'VRAD'
        mask = SpectralCube(mask.filled_data[:], wcs.WCS(hdr), header=hdr)
        mask = mask.with_mask(mask.filled_data[:] > 0)
        mask = mask.spectral_interpolate(cube_degas.spectral_axis)
        mask = mask.reproject(cube_degas.header)

        fl = glob.glob(empire_data + 'EMPIRE_{0}_{1}_*.fits'.format(gal.lower(),molecule.lower()))
        hdulist = fits.open(fl[0])
        hdu = sanitize(hdulist[0])
        cube_empire = SpectralCube(data=hdu.data, header=hdu.header, wcs=wcs.WCS(hdu.header))
        empire_mask = np.isfinite(hdu.data)
        cube_empire = cube_empire.with_mask(empire_mask)

        channel_ratio = ((cube_degas.spectral_axis[1]
                          - cube_degas.spectral_axis[0]) / 
                         (cube_empire.spectral_axis[1]
                          - cube_empire.spectral_axis[0])).to(u.dimensionless_unscaled).value
        
        kernel = Box1DKernel(channel_ratio)