r'$\sigma_{\rm CO} = \sigma_{\rm HI}$'),
    frameon=True,
    loc=(0.56, 0.6),
)

# plt.tight_layout()
plt.subplots_adjust(hspace=0.03, wspace=0.03)

plt.savefig(osjoin(fig_path, "sigma_HI_vs_H2_w_fit_cornerplot.png"))
plt.savefig(osjoin(fig_path, "sigma_HI_vs_H2_w_fit_cornerplot.pdf"))
plt.close()

# What does this relation look like for line widths from the second moment
co_lwidth = Projection.from_hdu(
    fits.open(
        iram_co21_14B088_data_path("m33.co21_iram.14B-088_HI.lwidth.fits"))[0])
hi_lwidth = Projection.from_hdu(
    fits.open(fourteenB_wGBT_HI_file_dict['LWidth'])[0])

co_lwidth_vals = co_lwidth.value[tab['ypts'][good_pts],
                                 tab['xpts'][good_pts]] / 1000.
hi_lwidth_vals = hi_lwidth.value[tab['ypts'][good_pts],
                                 tab['xpts'][good_pts]] / 1000.

# How bad is the relation between the 2nd moment line widths

hist2d(hi_lwidth_vals, co_lwidth_vals, bins=13, data_kwargs={"alpha": 0.5})
plt.plot([4, 16], [4. * slope_ratio, 16. * slope_ratio],
         '--',
         color=sb.color_palette()[1],
         linewidth=3,
示例#2
0
moment0 = fits.open(fourteenB_wGBT_HI_file_dict["Moment0"])[0]
moment0_wcs = WCS(moment0.header)

mom0_proj = Projection.from_hdu(moment0)

beam = Beam.from_fits_header(moment0.header)

# Convert to K km s and correct for disk inclination.
moment0_Kkm_s = beam.jtok(hi_freq).value * (moment0.data / 1000.) * cosinc
moment0_coldens = moment0_Kkm_s * hi_coldens_Kkms.value

pixscale = np.sqrt(proj_plane_pixel_area(moment0_wcs))

# Use the reprojected version
co_moment0 = fits.open(
    iram_co21_14B088_data_path("m33.co21_iram.14B-088_HI.mom0.fits"))[0]

co_noise_map = fits.open(
    iram_co21_14B088_data_path("m33.rms.14B-088_HI.fits"))[0]

onecolumn_Npanel_figure(N=1.5)

img_slice = (slice(902, 1084), slice(400, 650))
offset = [902, 400]

fig = plt.figure(figsize=(4.4, 5.84))

ax = fig.add_axes((0.15, 0.5, 0.8, 0.45), projection=mom0_proj[img_slice].wcs)
im = ax.imshow(moment0_coldens[img_slice],
               origin='lower',
               interpolation='nearest',
                       beam_eff_30m_druard)

default_figure()

tab = Table.read(
    fourteenB_HI_data_wGBT_path(
        "tables/hi_co_gaussfit_column_densities_perpix.fits"))

good_pts = np.logical_and(~tab['multicomp_flag_HI'], ~tab['multicomp_flag_CO'])
good_pts = np.logical_and(good_pts, tab["sigma_HI"] > 3800)
# Minimum CO line width of one channel.
good_pts = np.logical_and(good_pts, tab["sigma_CO"] >= 2600)

cube = SpectralCube.read(fourteenB_wGBT_HI_file_dict['Cube'])
co_cube = SpectralCube.read(
    iram_co21_14B088_data_path("m33.co21_iram.14B-088_HI.fits"))

co_mask = fits.open(
    iram_co21_14B088_data_path(
        "m33.co21_iram.14B-088_HI_source_mask.fits"))[0].data

# Require there be 3 pixels in the mask
co_mask_spatial = co_mask.sum(0) > 3
yposns, xposns = np.where(co_mask_spatial)

hi_specaxis = cube.spectral_axis
co_specaxis = co_cube.spectral_axis

hi_chanwidth = np.abs(np.diff(hi_specaxis[:2])[0].value)
co_chanwidth = np.abs(np.diff(co_specaxis[:2])[0].value)
from paths import (fourteenB_wGBT_HI_file_dict, iram_co21_14B088_data_path,
                   fourteenB_HI_data_wGBT_path, allfigs_path)
from plotting_styles import (default_figure, onecolumn_figure,
                             onecolumn_twopanel_figure)
from galaxy_params import gal_feath as gal
from constants import (co21_mass_conversion, hi_mass_conversion, hi_freq,
                       beam_eff_30m_druard)

default_figure()
cpal = sb.color_palette()

# cube = SpectralCube.read(fourteenB_wGBT_HI_file_dict['PeakSub_Cube'])
cube = SpectralCube.read(fourteenB_wGBT_HI_file_dict['Cube'])
co_cube = SpectralCube.read(
    iram_co21_14B088_data_path("m33.co21_iram.14B-088_HI.fits"))
co_rms = fits.open(iram_co21_14B088_data_path('m33.rms.14B-088_HI.fits'))[0]

co_mask = fits.open(
    iram_co21_14B088_data_path(
        "m33.co21_iram.14B-088_HI_source_mask.fits"))[0].data

# Require there be 3 pixels in the mask
co_mask_spatial = co_mask.sum(0) > 3
yposns, xposns = np.where(co_mask_spatial)

hi_specaxis = cube.spectral_axis
co_specaxis = co_cube.spectral_axis

hi_chanwidth = np.abs(np.diff(hi_specaxis[:2])[0].value)
co_chanwidth = np.abs(np.diff(co_specaxis[:2])[0].value)
nbins = np.int(np.floor(max_radius / dr))
inneredge = np.linspace(0, max_radius - dr, nbins)
outeredge = np.linspace(dr, max_radius, nbins)

# Avg rms noise in smoothed cube is 16 mK
sigma = 2.7 * u.K

hi_cube_peakvel = \
    SpectralCube.read(fourteenB_wGBT_HI_file_dict['PeakSub_Cube'])
hi_mask = fits.open(fourteenB_wGBT_HI_file_dict['PeakSub_Mask'])[0].data > 0
hi_cube_peakvel = hi_cube_peakvel.with_mask(hi_mask)

del hi_mask

co_mask = fits.open(
    iram_co21_14B088_data_path(
        "m33.co21_iram.14B-088_HI_source_mask.fits"))[0].data

# Require there be 3 pixels in the mask
no_co_mask_spatial = co_mask.sum(0) < 1

# Apply this mask to the HI

hi_cube_peakvel = hi_cube_peakvel.with_mask(no_co_mask_spatial)

bin_centers, total_spectrum_hi_radial_peakvel, num_pixels = \
    radial_stacking(gal, hi_cube_peakvel, dr=dr,
                    max_radius=max_radius,
                    pa_bounds=None,
                    verbose=True,
                    how='slice')
示例#6
0
Model and compare the stacked profiles from total_stacked_profiles_lowres.py
'''

figure_folder = allfigs_path("stacked_profiles")
if not os.path.exists(figure_folder):
    os.mkdir(figure_folder)


dr = 500 * u.pc
max_radius = (7.0 * u.kpc).to(u.pc)
wstring = "{0}{1}".format(int(dr.value), dr.unit)
maxrad_string = "{0}{1}".format(int(max_radius.value), max_radius.unit)

# Load the CO stacks

co_stackpath = lambda x: osjoin(iram_co21_14B088_data_path("smooth_2beam/stacked_spectra"), x)

total_spectrum_co_cent = OneDSpectrum.from_hdu(fits.open(co_stackpath("centroid_stacked_{}.fits".format(maxrad_string))))
total_spectrum_co_peakvel = OneDSpectrum.from_hdu(fits.open(co_stackpath("peakvel_stacked_{}.fits".format(maxrad_string))))

# Load the total HI profiles in
hi_stackpath = lambda x: osjoin(fourteenB_HI_data_wGBT_path("smooth_2beam/stacked_spectra"), x)

total_spectrum_hi_cent = OneDSpectrum.from_hdu(fits.open(hi_stackpath("centroid_stacked_{}.fits".format(maxrad_string))))
total_spectrum_hi_peakvel = OneDSpectrum.from_hdu(fits.open(hi_stackpath("peakvel_stacked_{}.fits".format(maxrad_string))))

spectra = [total_spectrum_co_cent,
           total_spectrum_co_peakvel]
hi_spectra = [total_spectrum_hi_cent,
              total_spectrum_hi_peakvel]
co_fit_vals = {}
示例#7
0
# Load the radial-stacked tables in
hi_tab = Table.read(
    fourteenB_HI_data_wGBT_path(
        "tables/hi_hwhm_totalprof_fits_radial_500pc.csv"))
hi_tab_2beam = Table.read(
    fourteenB_HI_data_wGBT_path(
        "smooth_2beam/tables/hi_hwhm_totalprof_fits_38arcsec_radial_500pc.csv")
)
hi_tab_5beam = Table.read(
    fourteenB_HI_data_wGBT_path(
        "smooth_5beam/tables/hi_hwhm_totalprof_fits_95arcsec_radial_500pc.csv")
)

co_tab = Table.read(
    iram_co21_14B088_data_path(
        "tables/co_hwhm_totalprof_fits_radial_500pc.csv"))
co_tab_2beam = Table.read(
    iram_co21_14B088_data_path(
        "smooth_2beam/tables/co_hwhm_totalprof_fits_38arcsec_radial_500pc.csv")
)
co_tab_5beam = Table.read(
    iram_co21_14B088_data_path(
        "smooth_5beam/tables/co_hwhm_totalprof_fits_95arcsec_radial_500pc.csv")
)

bin_centers = np.arange(0., 6.6, 0.5) + 0.25

onecolumn_Npanel_figure(N=2)

fig, ax = plt.subplots(2, 1, sharex=True, sharey=True)
示例#8
0
import numpy as np
from astropy.io import fits
from os.path import join as osjoin
import os
from astropy import log

from cube_analysis.spectral_stacking import radial_stacking

from paths import (iram_co21_14B088_data_path, fourteenB_HI_data_wGBT_path)
from constants import hi_freq
from galaxy_params import gal_feath as gal

smooth_2beam_hi_path = lambda x: osjoin(
    fourteenB_HI_data_wGBT_path("smooth_2beam"), x)
smooth_2beam_co_path = lambda x: osjoin(
    iram_co21_14B088_data_path("smooth_2beam"), x)

co_stackpath = lambda x: osjoin(smooth_2beam_co_path("stacked_spectra"), x)
if not os.path.exists(co_stackpath("")):
    os.mkdir(co_stackpath(""))

verbose = False
dr = 500 * u.pc
max_radius = (7.0 * u.kpc).to(u.pc)
wstring = "{0}{1}".format(int(dr.value), dr.unit)
maxrad_string = "{0}{1}".format(int(max_radius.value), max_radius.unit)

# CO stacking first
co_cube = SpectralCube.read(smooth_2beam_co_path(
    "m33.co21_iram.14B-088_HI.38arcsec.centroid_corrected.fits"),
                            memmap=False)
示例#9
0
from paths import (iram_co21_14B088_data_path, fourteenB_HI_data_wGBT_path)
from plotting_styles import (default_figure, onecolumn_figure,
                             onecolumn_twopanel_figure)
from galaxy_params import gal_feath as gal
from constants import (co21_mass_conversion, hi_mass_conversion, hi_freq,
                       beam_eff_30m_druard)

default_figure()
cpal = sb.color_palette()

log.info("Running 38'' analysis.")
# Get the original CO mask. We'll only use the same pixel positions with the
# low res data.
co_mask = fits.open(
    iram_co21_14B088_data_path(
        "m33.co21_iram.14B-088_HI_source_mask.fits"))[0].data

hi_cube_38 = SpectralCube.read(
    fourteenB_HI_data_wGBT_path(
        "smooth_2beam/M33_14B-088_HI.clean.image.GBT_feathered.38arcsec.fits"))
co_cube_38 = SpectralCube.read(
    iram_co21_14B088_data_path(
        "smooth_2beam/m33.co21_iram.14B-088_HI.38arcsec.fits"))
co_rms_38 = fits.open(
    iram_co21_14B088_data_path(
        "smooth_2beam/m33.rms.14B-088_HI.38arcsec.fits"))[0]
co_mask_38 = fits.open(
    iram_co21_14B088_data_path(
        "smooth_2beam/m33.co21_iram.14B-088_HI.38arcsec_source_mask.fits")
)[0].data
from cube_analysis.spectral_stacking import radial_stacking
from cube_analysis.spectral_stacking_models import fit_hwhm

from paths import (fourteenB_wGBT_HI_file_dict, iram_co21_14B088_data_path,
                   fourteenB_HI_data_wGBT_path, allfigs_path)
from constants import hi_freq
from galaxy_params import gal_feath as gal
from plotting_styles import default_figure, twocolumn_twopanel_figure

default_figure()

figure_folder = allfigs_path("stacked_profiles")
if not os.path.exists(figure_folder):
    os.mkdir(figure_folder)

co_stackpath = lambda x: osjoin(iram_co21_14B088_data_path("", no_check=True),
                                "stacked_spectra", x)
if not os.path.exists(co_stackpath("")):
    os.mkdir(co_stackpath(""))

dr = 500 * u.pc
max_radius = (7.0 * u.kpc).to(u.pc)
wstring = "{0}{1}".format(int(dr.value), dr.unit)
maxrad_string = "{0}{1}".format(int(max_radius.value), max_radius.unit)

pa_bounds_n = Angle([0.5 * np.pi * u.rad, -0.5 * np.pi * u.rad])

pa_bounds_s = Angle([-0.5 * np.pi * u.rad, 0.5 * np.pi * u.rad])

# Avg rms noise in smoothed cube is 16 mK
sigma = 16. * u.mK
示例#11
0
import os
from astropy.coordinates import Angle

from cube_analysis.spectral_stacking import radial_stacking

from paths import (fourteenB_wGBT_HI_file_dict,
                   iram_co21_14B088_data_path,
                   fourteenB_HI_data_wGBT_path)
from constants import hi_freq
from galaxy_params import gal_feath as gal

'''
Create profiles of HI and CO after subtracting velocity surfaces
'''

co_stackpath = lambda x: osjoin(iram_co21_14B088_data_path("", no_check=True), "stacked_spectra", x)
if not os.path.exists(co_stackpath("")):
    os.mkdir(co_stackpath(""))

dr = 500 * u.pc
max_radius = (7.0 * u.kpc).to(u.pc)
wstring = "{0}{1}".format(int(dr.value), dr.unit)
maxrad_string = "{0}{1}".format(int(max_radius.value), max_radius.unit)

pa_bounds_n = Angle([0.5 * np.pi * u.rad, -0.5 * np.pi * u.rad])

pa_bounds_s = Angle([-0.5 * np.pi * u.rad, 0.5 * np.pi * u.rad])

# CO stacking first
co_cube = SpectralCube.read(iram_co21_14B088_data_path("m33.co21_iram.14B-088_HI_feather.rotation_corrected.fits"))
示例#12
0
'''

fig_path = join(allfigs_path(""), "co_vs_hi")
if not exists(fig_path):
    os.mkdir(fig_path)

cpal = sb.color_palette()

hi_mom1 = fits.open(fourteenB_wGBT_HI_file_dict['Moment1'])[0].data / 1000.
hi_peakvels = fits.open(
    fourteenB_wGBT_HI_file_dict['PeakVels'])[0].data / 1000.
hi_peaktemp = fits.open(fourteenB_wGBT_HI_file_dict['PeakTemp'])[0].data

co_mom1 = fits.open(
    iram_co21_14B088_data_path(
        "m33.co21_iram.14B-088_HI.mom1.fits"))[0].data / 1000.
co_peakvels = fits.open(
    iram_co21_14B088_data_path(
        "m33.co21_iram.14B-088_HI.peakvels.fits"))[0].data / 1000.
co_peaktemp = fits.open(
    iram_co21_14B088_data_path(
        "m33.co21_iram.14B-088_HI.peaktemps.fits"))[0].data

co_mask = fits.open(
    iram_co21_14B088_data_path("m33.co21_iram.14B-088_HI_source_mask.fits"))[0]

good_co_pts = co_mask.data.sum(0) >= 2

good_pts = np.logical_and(np.isfinite(hi_mom1), good_co_pts)
# Impose 3 sigma cut on the CO peaks
good_pts = np.logical_and(good_pts, co_peaktemp > 0.06)