# 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 = [] all_vals_co = [] edge_masks = [] skeletons = [] hi_beam = average_beams(hi_cube.beams) # Estimate the noise level in an equivalent slab hi_mom0 = hi_cube.spectral_slab(-180 * u.km / u.s, -183 * u.km / u.s).moment0() sigma = sig_clip(hi_mom0.value, nsig=10) * \ hi_beam.jtok(hi_freq).value
from analysis.galaxy_params import gal cube = SpectralCube.read(fourteenB_HI_data_path(cube_name)) mask = fits.open(fourteenB_HI_data_path(mask_name))[0] # Apply the source mask cube = cube.with_mask((mask.data > 0)) # Now cut to the elliptical region to remove all bkg regions # region = pyregion.open(c_hi_analysispath("rotation_curves/mom1_rotcurve_mask.reg")) # subcube = cube.subcube_from_ds9region(region) # Since the parameters of M33 are already well constrained, use a radius # cut-off based on previous values. The fitting is done out to 10 kpc. A # small bit is added here to account for small changes in the fit parameters. radius = gal.radius(header=cube.header) max_radius = 10.25 * u.kpc subcube = cube.with_mask(radius < max_radius).minimal_subcube() # Now create the moment 1 and save it. Make a linewidth one too. # DISKFIT has issues with float64, so convert to float32 then save moment0_name = "M33_14B-088_HI.clean.image.pbcov_gt_{}.ellip_mask.mom0.fits".format(pb_lim) moment0 = subcube.moment0() moment0.write(fourteenB_HI_data_path(moment0_name, no_check=True), overwrite=True) moment1_name = "M33_14B-088_HI.clean.image.pbcov_gt_{}.ellip_mask.mom1.fits".format(pb_lim) moment1 = subcube.moment1().astype(np.float32) moment1.header["BITPIX"] = -32 moment1.write(fourteenB_HI_data_path(moment1_name, no_check=True),
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) nbins = np.int(np.floor(max_radius / dr)) inneredge = np.linspace(0, max_radius - dr, nbins) outeredge = np.linspace(dr, max_radius, nbins) total_spectrum_hi_radial = np.zeros((inneredge.size, hi_cube.shape[0])) total_spectrum_co_radial = np.zeros((inneredge.size, co_cube.shape[0]))