from analysis.paths import fourteenB_HI_data_path, iram_co21_data_path from analysis.constants import moment0_name ''' Reproject the CO to match the HI. Not taking the beam difference into account here since they are quite close. Once this is merged https://github.com/astrofrog/reproject/pull/115/files, make a full regrid of the whole cube. ''' hi_header = fits.getheader(fourteenB_HI_data_path(moment0_name)) co_ico = fits.open(iram_co21_data_path("m33.ico.fits"))[0] proj = Projection(co_ico.data.squeeze(), wcs=WCS(co_ico.header).dropaxis(3).dropaxis(2)) rep_array, footprint = reproject_interp(proj.hdu, hi_header) new_header = hi_header.copy() # Need to change some of the properties before saving keys = ["BMAJ", "BMIN", "BPA", "BUNIT"] for key in keys: new_header[key] = co_ico.header[key] new_hdu = fits.PrimaryHDU(rep_array, header=new_header) new_hdu.writeto(iram_co21_data_path("m33.ico.hireprojection.fits",
import matplotlib.pyplot as p from pandas import DataFrame from astropy.modeling import models, fitting from astropy.io import fits from analysis.paths import (fourteenB_HI_data_path, iram_co21_data_path, paper1_figures_path, paper1_tables_path) from analysis.constants import (rotsub_cube_name, rotsub_mask_name, co21_mass_conversion, hi_freq) from analysis.galaxy_params import gal ''' Create profiles of HI and CO after rotation subtraction. ''' co_cube = SpectralCube.read(iram_co21_data_path("m33.co21_iram.rotsub.fits")) # mask = fits.getdata(iram_co21_data_path("m33.co21_new_assign_clfind.fits")) # co_cube = co_cube.with_mask(mask.astype(bool)) hi_cube = SpectralCube.read(fourteenB_HI_data_path(rotsub_cube_name)) hi_mask = fits.open(fourteenB_HI_data_path(rotsub_mask_name))[0] hi_cube = hi_cube.with_mask(hi_mask.data > 0) hi_radius = gal.radius(header=hi_cube.header) co_radius = gal.radius(header=co_cube.header) # Perform the same analysis split up into radial bins dr = 500 * u.pc max_radius = (6.0 * u.kpc).to(u.pc)
To avoid a whole cube regrid, I use the rotation subtracted cubes and extract zeroth moments from spectral slabs. ''' np.random.seed(34678953) # Plot a bunch verbose = False # slicer = (slice(825, 1033), slice(360, 692)) slicer = (slice(None), slice(None)) # Load in the rotation subtracted cubes hi_cube = SpectralCube.read(fourteenB_HI_data_path(rotsub_cube_name)) co_cube = SpectralCube.read(iram_co21_data_path("m33.co21_iram.rotsub.fits")) start_vel = - 30 * u.km / u.s end_vel = 30 * u.km / u.s del_vel = 3. * u.km / u.s vels = np.arange(start_vel.value, end_vel.value + del_vel.value, del_vel.value) * u.km / u.s # Get the radius array so we can cut to where the CO data is valid radii = gal.radius(header=hi_cube[0].header) max_radius = 6.0 * u.kpc all_dists = [] all_radii = [] all_vals_hi = []
p.savefig(paper1_figures_path("filfinder_radial_profile_hi.png")) fraction_in_peak = np.sqrt(2 * np.pi) * (fit[0] - fit[2]) * \ (fit[1] / pixscale) * skeleton.sum() / np.nansum(mom0.value) print("Fraction of emission above the background level: {}" .format(fraction_in_peak)) # 0.543 # raw_input("Next plot?") p.clf() # Now use the regridded integrated CO map with the same skeleton # Created with co_comparison/co_reproject.py mom0_co_fits = \ fits.open(iram_co21_data_path("m33.ico.hireprojection.fits"))[0] # Correction for beam efficiency added in. mom0_co = \ Projection(mom0_co_fits.data / 0.75, wcs=WCS(mom0_co_fits.header)) mom0_co.meta['beam'] = Beam.from_fits_header(mom0_co_fits.header) # On the same grid, so pixscales are the same beam_width_co = \ mom0_co.meta['beam'].major.to(u.deg).value * (np.pi / 180.) * \ gal.distance.to(u.pc).value fit_co, err_co, model_co, profile_co = \ fit_skeleton_width(skeleton, mom0_co.value, pixscale, beam_width_co) # p.errorbar(profile_co[0], profile_co[1], yerr=profile_co[2], fmt="D", # color="b")