# south galaxy west region se_blue = np.genfromtxt(taffy_extdir + 'rawspectra_for_paperplot/se_blue.dat', dtype=None, names=['wav','flux']) se_red = np.genfromtxt(taffy_extdir + 'rawspectra_for_paperplot/se_red.dat', dtype=None, names=['wav','flux']) # bridge west region bw_blue = np.genfromtxt(taffy_extdir + 'rawspectra_for_paperplot/bw_new_blue.dat', dtype=None, names=['wav','flux']) bw_red = np.genfromtxt(taffy_extdir + 'rawspectra_for_paperplot/bw_new_red.dat', dtype=None, names=['wav','flux']) # bridge east region be_blue = np.genfromtxt(taffy_extdir + 'rawspectra_for_paperplot/be_new_blue.dat', dtype=None, names=['wav','flux']) be_red = np.genfromtxt(taffy_extdir + 'rawspectra_for_paperplot/be_new_red.dat', dtype=None, names=['wav','flux']) # Make figure # read in i band SDSS image sdss_i, wcs_sdss = vcm.get_sdss('i') # read in lzifu output file lzifu_hdulist, wcs_lzifu = vcm.get_lzifu_products() # create figure and plot # the sdss image is plotted according the the function in the # vel_channel_map code it is slightly modified here to work with gridspec. fig = plt.figure(figsize=(9,9)) # figsize=(width, height) # modify rc Params mpl.rcParams["font.family"] = "serif" mpl.rcParams["font.sans-serif"] = ["Computer Modern Sans"] #mpl.rcParams["text.usetex"] = True # I've kept this above commented out line here as a reminder. # This line will stop any bold text from appearing anywhere
def main(): """ The purpose of this code is to compare the Vs+V1+V1n map (this is currently the top middle panel in Fig 7) with the Vs+V2+V1n map. This is one of the plots the referee wanted to see. I think they think that this will display the rotation better. I'm not entirely sure. This code is completely based on the codes -- 1. stitche_vel_vdisp_cube.py and 2. contours_from_linefits.py. """ # Generate the Vs + V2 + V1n map #genmap() # Read in the new map and make contours map_vel_comp2_hdu = fits.open(gaussfits_dir + 'vel_cube_comp2.fits') map_vel_comp2_new_hdu = fits.open(gaussfits_dir + 'vel_cube_vs_v2_v1n.fits') map_vel_comp2 = map_vel_comp2_hdu[0].data map_vel_comp2_new = map_vel_comp2_new_hdu[0].data # Diagnostic figures # Do not delete this code block. Useful for checking. """ fig = plt.figure() ax1 = fig.add_subplot(121) ax2 = fig.add_subplot(122) ax1.imshow(map_vel_comp2, origin='lower', vmin=-350, vmax=350) ax2.imshow(map_vel_comp2_new, origin='lower', vmin=-350, vmax=350) plt.show() """ # ------- Contours --------- # # Plotting # Change MPL RC params first to stop using TeX for all text # becasue I can't use bold text with TeX. mpl.rcParams['text.usetex'] = False # Bold text f = FontProperties() f.set_weight('bold') # read in i band SDSS image sdss_i, wcs_sdss = vcm.get_sdss('i') # read in lzifu output file lzifu_hdulist, wcs_lzifu = vcm.get_lzifu_products() # plot sdss image fig, ax = vcm.plot_sdss_image(sdss_i, wcs_sdss) # draw contours x = np.arange(58) y = np.arange(58) X, Y = np.meshgrid(x,y) # get colormap colorbrewer_cm = vcm.get_colorbrewer_cm('blue2yellow') # select contour map to plot and set the variables # set the variables, levels, and limits below con_map = map_vel_comp2_new # apply min and max limits minlim = -500 maxlim = 500 minidx = np.where(con_map < minlim) maxidx = np.where(con_map > maxlim) con_map[minidx] = np.nan con_map[maxidx] = np.nan levels = np.array([-350, -250, -200, -150, -100, 0, 100, 150, 200, 250, 350]) # vel both comp # try smoothing the map to get smoother contours # define kernel kernel = Gaussian2DKernel(stddev=0.9) con_map = convolve(con_map, kernel, boundary='extend') c = ax.contour(X, Y, con_map, transform=ax.get_transform(wcs_lzifu),\ levels=levels, cmap=colorbrewer_cm, linewidths=2.0, interpolation='None') # add colorbar inside figure cbaxes = inset_axes(ax, width='30%', height='3%', loc=8, bbox_to_anchor=[0.02, 0.08, 1, 1], bbox_transform=ax.transAxes) cb = plt.colorbar(c, cax=cbaxes, ticks=[min(levels), max(levels)], orientation='horizontal') cb.ax.get_children()[0].set_linewidths(16.0) cb.ax.set_xlabel(r'$\mathrm{Radial\ Velocity\ [km\, s^{-1}]}$', fontsize=15) plt.show() return None
def make_diff_map(): # read in indices file h = fits.open(savedir + 'all_cases_indices.fits') comp1_inv_idx = h['COMP1_INV'].data comp2_inv_idx = h['COMP2_INV'].data single_idx = h['SINGLE_IDX'].data diffmean_idx = h['DIFFMEAN_IDX'].data diffstd_idx = h['DIFFSTD_IDX'].data diffboth_idx = h['DIFFBOTH_IDX'].data intg_flux_comp1_hdu = fits.open(savedir + 'intg_flux_cube_comp1.fits') intg_flux_comp2_hdu = fits.open(savedir + 'intg_flux_cube_comp2.fits') intg_flux_comp1 = intg_flux_comp1_hdu[0].data intg_flux_comp2 = intg_flux_comp2_hdu[0].data diffmap = intg_flux_comp2 - intg_flux_comp1 # NaN out some spaxels that don't seem right # ds9 coords [x,y] nan_list = [[20, 47], [20, 48], [20, 49]] for coord_to_nan in nan_list: i = coord_to_nan[1] - 1 j = coord_to_nan[0] - 1 print "DS9 coords:", coord_to_nan, " Array coords:", i, j diffmap[i, j] = np.nan # Plotting # read in i band SDSS image sdss_i, wcs_sdss = vcm.get_sdss('i') # read in lzifu output file lzifu_hdulist, wcs_lzifu = vcm.get_lzifu_products() # Save as fits file hdr = lzifu_hdulist['B_LINE'].header # Create file hdu = fits.PrimaryHDU(diffmap, header=hdr) # write hdu.writeto(taffy_extdir + 'intg_flux_diff_map.fits', overwrite=True) # ------------ also save indices file with proper header ------------ # indices_hdu = fits.PrimaryHDU() indices_hdul = fits.HDUList(indices_hdu) hdr['EXTNAME'] = 'COMP1_INV' indices_hdul.append(fits.ImageHDU(data=comp1_inv_idx, header=hdr)) hdr['EXTNAME'] = 'COMP2_INV' indices_hdul.append(fits.ImageHDU(data=comp2_inv_idx, header=hdr)) hdr['EXTNAME'] = 'SINGLE_IDX' indices_hdul.append(fits.ImageHDU(data=single_idx, header=hdr)) hdr['EXTNAME'] = 'DIFFMEAN_IDX' indices_hdul.append(fits.ImageHDU(data=diffmean_idx, header=hdr)) hdr['EXTNAME'] = 'DIFFSTD_IDX' indices_hdul.append(fits.ImageHDU(data=diffstd_idx, header=hdr)) hdr['EXTNAME'] = 'DIFFBOTH_IDX' indices_hdul.append(fits.ImageHDU(data=diffboth_idx, header=hdr)) indices_hdul.writeto(taffy_extdir + 'all_cases_indices_with_wcs.fits', overwrite=True) sys.exit(0) # plot sdss image fig, ax = vcm.plot_sdss_image(sdss_i, wcs_sdss) # draw contours x = np.arange(58) y = np.arange(58) X, Y = np.meshgrid(x, y) # get colormap colorbrewer_cm = vcm.get_colorbrewer_cm('coolwarm') kernel = Gaussian2DKernel(stddev=0.9) diffmap = convolve(diffmap, kernel, boundary='extend') c = ax.contour(X, Y, diffmap, transform=ax.get_transform(wcs_lzifu),\ cmap=colorbrewer_cm, linewidths=2.0, interpolation='None') ax.clabel(c, inline=True, inline_spacing=2, fontsize=8, fmt='%1.1f', lw=4, ls='-') # add colorbar inside figure cbaxes = inset_axes(ax, width='30%', height='3%', loc=8, bbox_to_anchor=[0.02, 0.08, 1, 1], bbox_transform=ax.transAxes) #cb = plt.colorbar(c, cax=cbaxes, ticks=[min(levels), max(levels)], orientation='horizontal') #cb.ax.get_children()[0].set_linewidths(10.0) #cb.ax.set_xlabel(r'$\mathrm{Integrated\ flux [erg\, s^{-1}\, cm^{-2}\, \AA^{-1} * km\, s^{-1}]}$', fontsize=12) plt.show() return None
def main(): # ------------------------- Read in data ------------------------- # # Read in HI data from Condon et al. 1993 hi_cube_hdu = fits.open(home + '/Dropbox/Taffy/HI_Condon_et_al/taffy_HIcube.fits') hi_cube = hi_cube_hdu[0].data # Now read in optical IFU data # Only need red channel for Halpha obs_r_hdu = fits.open(taffy_data + 'Taffy_R.fits') obs_r = obs_r_hdu[0].data # Using my own line fits instead of lzifu r_line_total = np.load(taffy_extdir + 'halpha_profile_mylinefits.npy') # ------------------------- Other preliminaries ------------------------- # # create wavelength array # I read these data from the corresponding headers # red wav arr delt_r = 0.3 # i.e. the wav axis is sampled at 0.3A red_wav_start = 6165.0 total_red_res_elem = 2350 red_wav_arr = [ red_wav_start + delt_r * i for i in range(total_red_res_elem) ] red_wav_arr = np.asarray(red_wav_arr) # get mask of all possible not NaN pixels all_mask = vcm.get_region_mask('all_possibly_notnan_pixels_new') # Make sure that rest wavelength is Halpha wavelength in air!! the IFU data was taken on the ground # find line index in wavelength array redshift = 0.0145 # average z sys_vel = redshift * speed_of_light # avg systemic velocity is z*c = 4350 km/s halpha_air_wav = 6562.80 halpha_wav = halpha_air_wav * (1 + redshift) halpha_idx = np.argmin(abs(red_wav_arr - halpha_wav)) # ------------------------- Plotting ------------------------- # # read in i band SDSS image sdss_i, wcs_sdss = vcm.get_sdss('i') # read in lzifu output file lzifu_hdulist, wcs_lzifu = vcm.get_lzifu_products() # plot sdss image fig, ax = vcm.plot_sdss_image(sdss_i, wcs_sdss) # Now read in regions file and convert to polygons #with fl as open(): regstr = 'polygon(52.75971,52.679517,55.559628,52.679492,55.559611,55.479493,52.759775,55.479517) # color=red width=2' regstr = regstr.split('(')[1].split(')')[0] regstr = regstr.split(',') reglist = list( regstr) # this is now a list of floats represented as strings reg_pn_list = [] for k in range(0, 8, 2): reg_pn_list.append([float(reglist[k]), float(reglist[k + 1])]) reg_pn = pg.Polygon(reg_pn_list) extract_spec(reg_pn, hi_cube) #extract_spec(reg_pn, obs_r) #plt.show() return None