# 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) shifts = np.zeros(model.shape) posns = np.where(np.isfinite(model))
from astropy.io import fits # Import from above. # parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # os.sys.path.insert(0, parentdir) from paths import (iram_co21_data_path, fourteenB_HI_data_path, 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)
Create the surface density profile in CO(2-1), assuming a factor to convert to the H2 mass. ''' 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]