Esempio n. 1
0
                   paper1_figures_path)
from constants import lwidth_name
from galaxy_params import gal

from HI_veldisp_profile import radial_profile

# Load data in
cube = SpectralCube.read(iram_co21_data_path("m33.co21_iram.fits"))
del cube._header[""]
# cube = cube.with_mask(cube > 0.1 * u.K)
mask = fits.getdata(iram_co21_data_path("m33.co21_new_assign_clfind.fits"))
cube = cube.with_mask(mask.astype(bool))

lwidth_co = cube.linewidth_sigma()

lwidth_hi = fits.open(fourteenB_HI_data_path(lwidth_name))[0]
lwidth_hi = Projection(lwidth_hi.data, wcs=WCS(lwidth_hi.header),
                       unit=u.m / u.s)

dr = 250 * u.pc

rs, sd, sd_sigma = radial_profile(gal, lwidth_co, max_rad=6 * u.kpc,
                                  dr=dr)

sd = sd.to(u.km / u.s)
sd_sigma = sd_sigma.to(u.km / u.s)

p.errorbar(rs.value, sd.value,
           yerr=sd_sigma.value, fmt="-", color="b",
           drawstyle='steps-mid')
p.xlabel("R (kpc)")
Esempio n. 2
0
from galaxies import Galaxy
from astropy.table import Table
import astropy.units as u

from cube_analysis.rotation_curves import update_galaxy_params

from paths import fourteenB_HI_data_path, fourteenB_HI_data_wGBT_path

# The models from the peak velocity aren't as biased, based on comparing
# the VLA and VLA+GBT velocity curves. Using these as the defaults

folder_name = "diskfit_peakvels_noasymm_noradial_nowarp_output"

param_name = \
    fourteenB_HI_data_path("{}/rad.out.params.csv".format(folder_name))

param_table = Table.read(param_name)

gal = Galaxy("M33")

update_galaxy_params(gal, param_table)

# Load in the model from the feathered data as well.
folder_name = "diskfit_peakvels_noasymm_noradial_nowarp_output"

param_name = \
    fourteenB_HI_data_wGBT_path("{}/rad.out.params.csv".format(folder_name))

param_table = Table.read(param_name)
Esempio n. 3
0
    sdprof_sigma = sdprof_sigma * moment.unit

    return radprof, sdprof, sdprof_sigma


if __name__ == "__main__":
    import matplotlib.pyplot as p

    from paths import (fourteenB_HI_data_path, arecibo_HI_data_path,
                       c_hi_analysispath, paper1_figures_path,
                       data_path)

    from constants import moment0_name, lwidth_name
    from galaxy_params import gal

    lwidth_hdu = fits.open(fourteenB_HI_data_path(lwidth_name))[0]
    lwidth = Projection(lwidth_hdu.data, wcs=WCS(lwidth_hdu.header),
                        unit=u.m / u.s)
    lwidth.meta["beam"] = Beam.from_fits_header(lwidth_hdu.header)

    # Create a radial profile of the HI vel disp out to 8 kpc.
    # Beyond 8 kpc, noise is dominant. It may be some reflection of the
    # warp, but I don't trust it right now.
    rs, sd, sd_sigma = radial_profile(gal, lwidth, max_rad=8 * u.kpc)

    sd = sd.to(u.km / u.s)
    sd_sigma = sd_sigma.to(u.km / u.s)

    p.errorbar(rs.value, sd.value,
               yerr=sd_sigma.value, fmt="-", color="b",
               drawstyle='steps-mid')
Esempio n. 4
0
Make figures of the zeroth and first moments.
'''

import numpy as np
from astropy.io import fits
from astropy.wcs import WCS
import matplotlib.pyplot as plt
from astropy.visualization import AsinhStretch
from astropy.visualization.mpl_normalize import ImageNormalize
from radio_beam import Beam

from paths import fourteenB_HI_data_path, paper1_figures_path
from constants import moment0_name, moment1_name, hi_freq


moment0 = fits.open(fourteenB_HI_data_path(moment0_name))[0]

beam = Beam.from_fits_header(moment0.header)

moment0_Kkm_s = beam.jtok(hi_freq).value * moment0.data / 1000.

ax = plt.subplot(111, projection=WCS(moment0.header))
im = ax.imshow(moment0_Kkm_s,
          origin='lower',
          interpolation='nearest',
          norm=ImageNormalize(vmin=-0.001,
                              vmax=np.nanmax(moment0_Kkm_s),
                              stretch=AsinhStretch()))
ax.set_ylabel("DEC (J2000)")
ax.set_xlabel("RA (J2000)")
Esempio n. 5
0
    from astropy.table import Table
    from spectral_cube.lower_dimensional_structures import Projection
    from astropy.wcs import WCS
    from radio_beam import Beam
    from astropy.io import fits

    import os

    from paths import (fourteenB_HI_data_path, arecibo_HI_data_path,
                       c_hi_analysispath, paper1_figures_path,
                       data_path)

    from constants import hi_freq, moment0_name
    from galaxy_params import gal

    mom0_hdu = fits.open(fourteenB_HI_data_path(moment0_name))[0]
    mom0 = Projection(mom0_hdu.data, wcs=WCS(mom0_hdu.header),
                      unit=u.Jy * u.m / u.s)
    mom0.meta["beam"] = Beam.from_fits_header(mom0_hdu.header)

    # Bin size in pc
    dr = 100 * u.pc

    # Create a radial profile of HI
    rs, sd, sd_sigma = surfdens_radial_profile(gal, mom0=mom0, dr=dr,
                                               restfreq=hi_freq)
    rs_n, sd_n, sd_sigma_n = \
        surfdens_radial_profile(gal, mom0=mom0,
                                pa_bounds=Angle([0.5 * np.pi * u.rad,
                                                -0.5 * np.pi * u.rad]),
                                dr=dr, restfreq=hi_freq)
Esempio n. 6
0
Subtract a rotation model from the CO cube.
'''

# Load in my huge FITS creator
execfile(os.path.expanduser("~/Dropbox/code_development/ewky_scripts/write_huge_fits.py"))


def find_nearest(array, value):
    '''
    http://stackoverflow.com/questions/2566412/find-nearest-value-in-numpy-array
    '''
    idx = (np.abs(array - value)).argmin()
    return idx

# Set vsys. Using the fit value from DISKFIT
table_name = fourteenB_HI_data_path("diskfit_noasymm_noradial_nowarp_output/rad.out.csv")
tab = Table.read(table_name)

cube = SpectralCube.read(iram_co21_data_path("m33.co21_iram.fits"))
# Somehow blank keywords are generated when reading the cube in... something
# to do with dropping the Stokes axis is my guess.
del cube._header[""]

# Where's the center?
# center_pixel = find_nearest(cube.spectral_axis, vsys)
# In this case, the remaining difference is a minuscule 3 m/s.

model = return_smooth_model(tab, cube.header, gal)

# Now calculate the spectral shifts needed for each pixel
# Assuming that the array shapes for the same (which they are here)
Esempio n. 7
0
co21_mass_conversion = 6.7 * (u.M_sun / u.pc ** 2) / (u.K * u.km / u.s)

# IRAM beam efficiency
beam_eff = 0.75

# Set the radial disk widths to bin over
# dr = 500 * u.pc
dr = 100 * u.pc
# dr = 300 * u.pc

# Load the moment 0
cube = SpectralCube.read(iram_co21_data_path("m33.co21_iram.fits"))
del cube._header[""]
cube = cube.with_mask(cube > 0.1 * u.K)

mom0_hi = fits.open(fourteenB_HI_data_path(moment0_name))[0]
hi_cube = SpectralCube.read(fourteenB_HI_data_path(cube_name))
mask = fits.open(fourteenB_HI_data_path(mask_name))[0]
hi_cube = hi_cube.with_mask(mask.data > 0)

radii = gal.radius(header=cube.header)
# Edge effects are really awful in this map. Ignore the edges by masking
# beyond 6 kpc. This is really close to the edge of the data anyways, and
# honestly results beyond this point shouldn't be trusted...
cube = cube.with_mask(radii < 6. * u.kpc)

# mom0 = fits.open(os.path.join(direc, "m33.ico.fits"))[0]

# mom0_data = mom0.data.squeeze() * (mom0.data.squeeze() > 1.0) * u.K
mom0 = cube.moment0()
Esempio n. 8
0
                   paper1_figures_path, paper1_tables_path)
from constants import cube_name, mask_name
from galaxy_params import gal

'''
Sum over all spectra above 3 sigma. Overplot with single-dish Arecibo.
And produce the summed spectra of the rotation subtracted cube.
'''

# You know what's great? Making an install script!
execfile(os.path.expanduser("~/Dropbox/code_development/BaSiCs/basics/utils.py"))
# Needed sig_clip.


cube = \
    SpectralCube.read(fourteenB_HI_data_path(cube_name))
mask = fits.open(fourteenB_HI_data_path(mask_name))[0]
cube = cube.with_mask(mask.data > 0)

arecibo = SpectralCube.read(arecibo_HI_data_path("14B-088_items/M33_14B-088_HI_model.fits"))
arecibo = arecibo.spectral_slab(*cube.spectral_extrema)
arecibo = arecibo.subcube(ylo=cube.latitude_extrema[1],
                          yhi=cube.latitude_extrema[0],
                          xlo=cube.longitude_extrema[0],
                          xhi=cube.longitude_extrema[1])

# noise_sigma = sig_clip(cube[-1].value, nsig=10) * u.Jy

# cube = cube.with_mask(cube > 3 * noise_sigma)

# Using sum on two axes of a cube is super slow (and wrong? All NaNs?).
import astropy.units as u
import pandas as pd
import numpy as np

from paths import fourteenB_HI_data_path, paper1_figures_path
from constants import pb_lim
from galaxy_params import gal


# Requires that diskfit has already been run on these 3 surfaces!
# By default, the analysis pipeline should run each.
cent_name = "diskfit_noasymm_noradial_nowarp_output/rad.out.csv"
peak_name = "diskfit_peakvels_noasymm_noradial_nowarp_output/rad.out.csv"
gh_name = "diskfit_ghfit_noasymm_noradial_nowarp_output/rad.out.csv"

cent_tab = pd.read_csv(fourteenB_HI_data_path(cent_name))
peak_tab = pd.read_csv(fourteenB_HI_data_path(peak_name))
peak_tab["Vt"] = np.abs(peak_tab["Vt"])
gh_tab = pd.read_csv(fourteenB_HI_data_path(gh_name))

# Read in WCS info to convert to distances
mom1_name = fourteenB_HI_data_path("M33_14B-088_HI.clean.image.pbcov_gt_{}.ellip_mask.mom1.fits".format(pb_lim))
mom1 = fits.open(mom1_name)
mom1_wcs = wcs.WCS(mom1[0].header)

scale = wcs.utils.proj_plane_pixel_scales(mom1_wcs)[0]
# Distance scaling (1" ~ 4 pc). Conversion is deg to kpc
dist_scale = (np.pi / 180.) * gal.distance.to(u.kpc).value


# Plot the rotation curves