0.04, #0.05, 0.06, #0.08, 0.10, #0.15, 0.20, #0.30, 0.40, ], colors=['w'] * 12, layer='alma_cont_hires') F.save(paths.fpath("NACO_green_outflows_aplpy_CONTours_hires.png")) F.save(paths.fpath("NACO_green_outflows_aplpy_CONTours_hires.pdf")) h77a = SpectralCube.read(paths.vpath('data/W51north_H77_Outflow_cutout.fits')) h77a_outflow = h77a.spectral_slab(-16 * u.km / u.s, -60 * u.km / u.s).sum(axis=0) h77a_green = paths.dpath('W51_H77a_LacyJetOutflow_Sum.fits') h77a_outflow.hdu.writeto(h77a_green, clobber=True) F.show_contour(h77a_green, levels=[0.0075, 0.015, 0.030], colors=['b'] * 6, layer='h77a_outflow') F.save(paths.fpath("NACO_green_outflows_aplpy_CONTours_hires_h77acontour.png")) F.save(paths.fpath("NACO_green_outflows_aplpy_CONTours_hires_h77acontour.pdf")) F.hide_layer('h77a_outflow') F.hide_layer('alma_cont_hires')
fig1 = pl.figure(1) fig1.clf() F = aplpy.FITSFigure(rgb_cube_png, figure=fig1) F.show_rgb(rgb_cube_png) #F.recenter(290.93315, 14.509584, radius=0.0075) F.add_scalebar((0.5*u.pc / (5400*u.pc)).to(u.deg,u.dimensionless_angles())) F.scalebar.set_label('0.5 pc') F.scalebar.set_color('w') #F.set_tick_xspacing(0.0005) F.add_label(0.05, 0.95, rlabel, relative=True, color='r', horizontalalignment='left') F.add_label(0.05, 0.91, glabel, relative=True, color='g', horizontalalignment='left') F.add_label(0.05, 0.87, blabel, relative=True, color='b', horizontalalignment='left') F.save(paths.fpath("W51e2_{0}_aplpy.png".format(name))) F.save(paths.fpath("W51e2_{0}_aplpy.pdf".format(name))) cmcontsrc = Table.read(paths.vpath('tables/EVLA_VLA_PointSourcePhotometry.ipac'), format='ascii.ipac') cmok = (cmcontsrc['Frequency']==5.9) & (cmcontsrc['Epoch']=='3') cmcoords = coordinates.SkyCoord(cmcontsrc['gracen'][cmok], cmcontsrc['gdeccen'][cmok], frame='fk5') core_phot_tbl = Table.read(paths.tpath("continuum_photometry.ipac"), format='ascii.ipac') cores = coordinates.SkyCoord(core_phot_tbl['RA'], core_phot_tbl['Dec'], frame='fk5') F.show_markers(cmcoords.ra, cmcoords.dec, edgecolor=star_color, marker='*', alpha=0.75, zorder=1, facecolor=star_color, layer='hiiregions') #F.hide_layer('hiiregions_text') F.save(paths.fpath("W51e2_{0}_aplpy_hiiregions.png".format(name))) F.save(paths.fpath("W51e2_{0}_aplpy_hiiregions.pdf".format(name)))
F.tick_labels.set_xformat('hh:mm:ss.ss') F.ticks.set_xspacing(0.001) F.ticks.set_yspacing(0.001) #F.tick_labels.set_x_full_label_side('left') #aplpy.make_rgb_cube( ('W51-CBAND-feathered.fits','W51-X-ABCD-S1.VTESS.VTC.DAVID-MEH.fits','W51Ku_BDarray_continuum_2048_both_uniform.hires.clean.image.fits'), 'W51_CXU_rgb' ) pl.close(1) figure = pl.figure(1) figure.clf() # clean the header of junk axes hdu = fits.open( paths.vpath( 'data/W51Ku_BDarray_continuum_2048_both_uniform.hires.clean.image.fits' )) hdu[0].data = hdu[0].data.squeeze() hdu[0].header = wcs.WCS(hdu[0].header).sub([wcs.WCSSUB_CELESTIAL]).to_header() F = aplpy.FITSFigure(hdu, convention='calabretta', figure=figure) #F = aplpy.FITSFigure(dpath+'W51Ku_BDarray_continuum_2048_both_uniform.hires.clean.image.rot45.fits',convention='calabretta',figure=figure) F.tick_labels.set_xformat('dd.dd') F.tick_labels.set_yformat('dd.dd') F.tick_labels.set_font(size=20) F.axis_labels.set_font(size=20) F.show_grayscale(stretch='arcsinh', vmin=-5e-4, vmax=0.05, invert=True) #e1 = coordinates.ICRS(290.93263,14.50745,unit=('deg','deg')) #F.recenter(e1.ra.value,e1.dec.value,width=1/60.,height=1/60.) #F.recenter(290.92633,14.514769,radius=1.4/60.) # IRS2:
import copy from astropy.table import Table from astropy import units as u from astropy import coordinates import pylab as pl from astropy.io import fits from astropy import wcs from wcsaxes import WCS as WCSaxes from astropy.convolution import convolve, Gaussian2DKernel core_phot_tbl = Table.read(paths.tpath("continuum_photometry.ipac"), format='ascii.ipac') cores = coordinates.SkyCoord(core_phot_tbl['RA'], core_phot_tbl['Dec'], frame='fk5') w51moxc = Table.read(paths.tpath('w51_moxc.ipac'), format='ascii.ipac') cmcontsrc = Table.read(paths.vpath('tables/EVLA_VLA_PointSourcePhotometry.ipac'), format='ascii.ipac') cmok = (cmcontsrc['Frequency']==5.9) & (cmcontsrc['Epoch']=='3') cmcoords = coordinates.SkyCoord(cmcontsrc['gracen'][cmok], cmcontsrc['gdeccen'][cmok], frame='fk5') hdu = fits.open(paths.vpath("data/W51C_ACarray_continuum_4096_both_uniform_contsplit.clean.image.fits"))[0] mywcs = wcs.WCS(hdu.header).sub([wcs.WCSSUB_CELESTIAL]) wcsaxes = WCSaxes(mywcs.to_header()) fig = pl.figure(1) fig.clf() ax = fig.add_axes([0.15, 0.1, 0.8, 0.8], projection=wcsaxes)
def set_tight_ticks(F): F.tick_labels.set_yformat('dd:mm:ss.ss') F.tick_labels.set_xformat('hh:mm:ss.ss') F.ticks.set_xspacing(0.001) F.ticks.set_yspacing(0.001) #F.tick_labels.set_x_full_label_side('left') #aplpy.make_rgb_cube( ('W51-CBAND-feathered.fits','W51-X-ABCD-S1.VTESS.VTC.DAVID-MEH.fits','W51Ku_BDarray_continuum_2048_both_uniform.hires.clean.image.fits'), 'W51_CXU_rgb' ) pl.close(1) figure = pl.figure(1) figure.clf() # clean the header of junk axes hdu = fits.open(paths.vpath('data/W51Ku_BDarray_continuum_2048_both_uniform.hires.clean.image.fits')) hdu[0].data = hdu[0].data.squeeze() hdu[0].header = wcs.WCS(hdu[0].header).sub([wcs.WCSSUB_CELESTIAL]).to_header() F = aplpy.FITSFigure(hdu,convention='calabretta',figure=figure) #F = aplpy.FITSFigure(dpath+'W51Ku_BDarray_continuum_2048_both_uniform.hires.clean.image.rot45.fits',convention='calabretta',figure=figure) F.tick_labels.set_xformat('dd.dd') F.tick_labels.set_yformat('dd.dd') F.tick_labels.set_font(size=20) F.axis_labels.set_font(size=20) F.show_grayscale(stretch='arcsinh',vmin=-5e-4,vmax=0.05,invert=True) #e1 = coordinates.ICRS(290.93263,14.50745,unit=('deg','deg')) #F.recenter(e1.ra.value,e1.dec.value,width=1/60.,height=1/60.) #F.recenter(290.92633,14.514769,radius=1.4/60.) # IRS2: F.recenter(290.91644,14.518939,radius=0.3/60.)
from astropy import coordinates import pylab as pl from astropy.io import fits from astropy import wcs from wcsaxes import WCS as WCSaxes from astropy.convolution import convolve, Gaussian2DKernel core_phot_tbl = Table.read(paths.tpath("continuum_photometry.ipac"), format='ascii.ipac') cores = coordinates.SkyCoord(core_phot_tbl['RA'], core_phot_tbl['Dec'], frame='fk5') w51moxc = Table.read(paths.tpath('w51_moxc.ipac'), format='ascii.ipac') cmcontsrc = Table.read( paths.vpath('tables/EVLA_VLA_PointSourcePhotometry.ipac'), format='ascii.ipac') cmok = (cmcontsrc['Frequency'] == 5.9) & (cmcontsrc['Epoch'] == '3') cmcoords = coordinates.SkyCoord(cmcontsrc['gracen'][cmok], cmcontsrc['gdeccen'][cmok], frame='fk5') hdu = fits.open( paths.vpath( "data/W51C_ACarray_continuum_4096_both_uniform_contsplit.clean.image.fits" ))[0] mywcs = wcs.WCS(hdu.header).sub([wcs.WCSSUB_CELESTIAL]) wcsaxes = WCSaxes(mywcs.to_header()) fig = pl.figure(1)
def zoomfigure(target=e2e, targetname='e2e', radius=7.5*u.arcsec, cutout='e2e8', zoom_radius=3*u.arcsec, tick_spacing=1.8*u.arcsec): fn = paths.dpath('merge/cutouts/W51_b6_7M_12M.HNCO10010-909.image.pbcor_{0}cutout.fits'.format(cutout)) m0hnco = get_mom0(fn, iterate=False) cutout_cont = Cutout2D(cont_fits[0].data, target, radius, wcs=wcs.WCS(cont_fits[0].header)) cutout_ch3oh = Cutout2D(m0ch3oh.value, target, radius, wcs=wcs.WCS(m0ch3oh.header)) cutout_hnco = Cutout2D(m0hnco.value, target, radius, wcs=wcs.WCS(m0hnco.header)) cont_fits_cutout = fits.PrimaryHDU(data=cutout_cont.data, header=cutout_cont.wcs.to_header()) ch3oh_fits_cutout = fits.PrimaryHDU(data=cutout_ch3oh.data, header=cutout_ch3oh.wcs.to_header()) hnco_fits_cutout = fits.PrimaryHDU(data=cutout_hnco.data, header=cutout_hnco.wcs.to_header()) cont_fits_fn = "rgb/continuum_{0}_cutout.fits".format(targetname) hnco_fits_fn = "rgb/hnco_{0}_cutout.fits".format(targetname) ch3oh_fits_fn = "rgb/ch3oh_{0}_cutout.fits".format(targetname) cont_fits_cutout.writeto(cont_fits_fn, clobber=True) ch3oh_fits_cutout.writeto(ch3oh_fits_fn, clobber=True) hnco_fits_cutout.writeto(hnco_fits_fn, clobber=True) rgb_cube_fits = '{0}_ch3oh_hnco_cont.fits'.format(targetname) if not os.path.exists(rgb_cube_fits): # does not return anything aplpy.make_rgb_cube([ch3oh_fits_fn, hnco_fits_fn, cont_fits_fn,], rgb_cube_fits) rgb_cube_png = rgb_cube_fits[:-5]+"_auto.png" rgb_im = aplpy.make_rgb_image(data=rgb_cube_fits, output=rgb_cube_png, embed_avm_tags=True) rgb_cube_png = rgb_cube_fits[:-5]+"_logcont.png" rgb_im = aplpy.make_rgb_image(data=rgb_cube_fits, output=rgb_cube_png, #vmin_b=0.005, #vmax_b=0.15, stretch_b='log', embed_avm_tags=True) #rgb_cube_png = rgb_cube_fits[:-5]+"_asinhgreen.png" #rgb_im = aplpy.make_rgb_image(data=rgb_cube_fits, output=rgb_cube_png, # vmax_g=0.017, # vmax_b=6.5, # vmax_r=7.0, # vmin_g=0.0001, # stretch_g='arcsinh', embed_avm_tags=True) # # pl.rcParams['font.size'] = 18 fig1 = pl.figure(1) fig1.clf() F = aplpy.FITSFigure(rgb_cube_png, figure=fig1) F.show_rgb(rgb_cube_png) #F.recenter(290.93315, 14.509584, radius=0.00075) F.recenter(target.ra.deg, target.dec.deg, radius=zoom_radius.to(u.deg).value) F.add_scalebar((0.025*u.pc / (5400*u.pc)).to(u.deg,u.dimensionless_angles())) F.scalebar.set_label('5000 au / 0.025 pc') F.scalebar.set_color('w') F.set_tick_xspacing(tick_spacing.to(u.deg).value) F.add_label(0.05, 0.95, "CH$_3$OH", relative=True, color='r', horizontalalignment='left') F.add_label(0.05, 0.91, "HNCO", relative=True, color='g', horizontalalignment='left') F.add_label(0.05, 0.87, "Continuum", relative=True, color='b', horizontalalignment='left') F.save(paths.fpath("W51{0}_ch3oh_hnco_continuum_aplpy.png".format(targetname))) F.save(paths.fpath("W51{0}_ch3oh_hnco_continuum_aplpy.pdf".format(targetname))) F.show_contour(paths.vpath('data/W51Ku_BDarray_continuum_2048_both_uniform.hires.clean.image.fits'), levels=np.array([0.0015,0.0045,0.0135,0.0270,0.054,0.108])*1.25, colors=['w']*7, layer='evla_cont') F.save(paths.fpath("W51{0}_ch3oh_hnco_continuum_aplpy_kucontours.png".format(targetname))) F.save(paths.fpath("W51{0}_ch3oh_hnco_continuum_aplpy_kucontours.pdf".format(targetname)))
def zoomfigure( target=e2e, targetname="e2e", radius=7.5 * u.arcsec, cutout="e2e8", zoom_radius=3 * u.arcsec, tick_spacing=1.8 * u.arcsec, ): fn = paths.dpath("merge/cutouts/W51_b6_7M_12M.HNCO10010-909.image.pbcor_{0}cutout.fits".format(cutout)) m0hnco = get_mom0(fn, iterate=False) cutout_cont = Cutout2D(cont_fits[0].data, target, radius, wcs=wcs.WCS(cont_fits[0].header)) cutout_ch3oh = Cutout2D(m0ch3oh.value, target, radius, wcs=wcs.WCS(m0ch3oh.header)) cutout_hnco = Cutout2D(m0hnco.value, target, radius, wcs=wcs.WCS(m0hnco.header)) cont_fits_cutout = fits.PrimaryHDU(data=cutout_cont.data, header=cutout_cont.wcs.to_header()) ch3oh_fits_cutout = fits.PrimaryHDU(data=cutout_ch3oh.data, header=cutout_ch3oh.wcs.to_header()) hnco_fits_cutout = fits.PrimaryHDU(data=cutout_hnco.data, header=cutout_hnco.wcs.to_header()) cont_fits_fn = "rgb/continuum_{0}_cutout.fits".format(targetname) hnco_fits_fn = "rgb/hnco_{0}_cutout.fits".format(targetname) ch3oh_fits_fn = "rgb/ch3oh_{0}_cutout.fits".format(targetname) cont_fits_cutout.writeto(cont_fits_fn, clobber=True) ch3oh_fits_cutout.writeto(ch3oh_fits_fn, clobber=True) hnco_fits_cutout.writeto(hnco_fits_fn, clobber=True) rgb_cube_fits = "{0}_ch3oh_hnco_cont.fits".format(targetname) if not os.path.exists(rgb_cube_fits): # does not return anything aplpy.make_rgb_cube([ch3oh_fits_fn, hnco_fits_fn, cont_fits_fn], rgb_cube_fits) rgb_cube_png = rgb_cube_fits[:-5] + "_auto.png" rgb_im = aplpy.make_rgb_image(data=rgb_cube_fits, output=rgb_cube_png, embed_avm_tags=True) rgb_cube_png = rgb_cube_fits[:-5] + "_logcont.png" rgb_im = aplpy.make_rgb_image( data=rgb_cube_fits, output=rgb_cube_png, # vmin_b=0.005, # vmax_b=0.15, stretch_b="log", embed_avm_tags=True, ) # rgb_cube_png = rgb_cube_fits[:-5]+"_asinhgreen.png" # rgb_im = aplpy.make_rgb_image(data=rgb_cube_fits, output=rgb_cube_png, # vmax_g=0.017, # vmax_b=6.5, # vmax_r=7.0, # vmin_g=0.0001, # stretch_g='arcsinh', embed_avm_tags=True) # # pl.rcParams["font.size"] = 18 fig1 = pl.figure(1) fig1.clf() F = aplpy.FITSFigure(rgb_cube_png, figure=fig1) F.show_rgb(rgb_cube_png) # F.recenter(290.93315, 14.509584, radius=0.00075) F.recenter(target.ra.deg, target.dec.deg, radius=zoom_radius.to(u.deg).value) F.add_scalebar((0.025 * u.pc / (5400 * u.pc)).to(u.deg, u.dimensionless_angles())) F.scalebar.set_label("5000 au / 0.025 pc") F.scalebar.set_color("w") F.set_tick_xspacing(tick_spacing.to(u.deg).value) F.add_label(0.05, 0.95, "CH$_3$OH", relative=True, color="r", horizontalalignment="left") F.add_label(0.05, 0.91, "HNCO", relative=True, color="g", horizontalalignment="left") F.add_label(0.05, 0.87, "Continuum", relative=True, color="b", horizontalalignment="left") F.save(paths.fpath("rgb_zooms/W51{0}_ch3oh_hnco_continuum_aplpy.png".format(targetname))) F.save(paths.fpath("rgb_zooms/W51{0}_ch3oh_hnco_continuum_aplpy.pdf".format(targetname))) F.show_contour( paths.vpath("data/W51Ku_BDarray_continuum_2048_both_uniform.hires.clean.image.fits"), levels=np.array([0.0015, 0.0045, 0.0135, 0.0270, 0.054, 0.108]) * 1.25, colors=["w"] * 7, layer="evla_cont", ) F.save(paths.fpath("rgb_zooms/W51{0}_ch3oh_hnco_continuum_aplpy_kucontours.png".format(targetname))) F.save(paths.fpath("rgb_zooms/W51{0}_ch3oh_hnco_continuum_aplpy_kucontours.pdf".format(targetname)))
#F.scalebar.set_length((0.05*u.pc / (5400*u.pc)).to(u.deg,u.dimensionless_angles())) F.scalebar.set_label('0.05 pc') F.scalebar.set_color('w') #F.set_tick_xspacing(0.0005) #F.add_label(0.05, 0.95, rlabel, relative=True, color='r', horizontalalignment='left') #F.add_label(0.05, 0.91, glabel, relative=True, color='g', horizontalalignment='left') #F.add_label(0.05, 0.87, blabel, relative=True, color='b', horizontalalignment='left') F.save(paths.fpath("rgb_zooms/W51e2_{0}_aplpy.png".format(name))) F.save(paths.fpath("rgb_zooms/W51e2_{0}_aplpy.pdf".format(name))) # zoom on "e1 cluster" F.recenter(e1.ra.deg, e1.dec.deg, radius=11./3600.) F.set_tick_xspacing(6./3600) cmcontsrc = Table.read(paths.vpath('tables/EVLA_VLA_PointSourcePhotometry.ipac'), format='ascii.ipac') cmok = (cmcontsrc['Frequency']==5.9) & (cmcontsrc['Epoch']=='3') cmcoords = coordinates.SkyCoord(cmcontsrc['gracen'][cmok], cmcontsrc['gdeccen'][cmok], frame='fk5') core_phot_tbl = Table.read(paths.tpath("continuum_photometry.ipac"), format='ascii.ipac') cores = coordinates.SkyCoord(core_phot_tbl['RA'], core_phot_tbl['Dec'], frame='fk5') F.scalebar.set_label('0.05 pc') F.scalebar.set_color('w') F.show_markers(cmcoords.ra, cmcoords.dec, edgecolor=star_color, marker='*', alpha=0.75,
#0.15, 0.20, #0.30, 0.40, ], colors=['w'] * 12, layer='alma_cont_hires') F.save( paths.fpath("NACO_green_{0}_outflows_aplpy_CONTours_hires.png".format( species))) F.save( paths.fpath("NACO_green_{0}_outflows_aplpy_CONTours_hires.pdf".format( species))) h77a = SpectralCube.read( paths.vpath('data/W51north_H77_Outflow_cutout.fits')) h77a_outflow = h77a.spectral_slab(-16 * u.km / u.s, -60 * u.km / u.s).sum(axis=0) h77a_green = paths.dpath('W51_H77a_LacyJetOutflow_Sum.fits') h77a_outflow.hdu.writeto(h77a_green, clobber=True) F.show_contour(h77a_green, levels=[0.0075, 0.015, 0.030], colors=['b'] * 6, layer='h77a_outflow') F.save( paths.fpath( "NACO_green_{0}_outflows_aplpy_CONTours_hires_h77acontour.png". format(species))) F.save( paths.fpath(
F.scalebar.set_label('0.05 pc') F.scalebar.set_color('w') #F.set_tick_xspacing(0.0005) #F.add_label(0.05, 0.95, rlabel, relative=True, color='r', horizontalalignment='left') #F.add_label(0.05, 0.91, glabel, relative=True, color='g', horizontalalignment='left') #F.add_label(0.05, 0.87, blabel, relative=True, color='b', horizontalalignment='left') F.save(paths.fpath("rgb_zooms/W51e2_{0}_aplpy.png".format(name))) F.save(paths.fpath("rgb_zooms/W51e2_{0}_aplpy.pdf".format(name))) # zoom on "e1 cluster" F.recenter(e1.ra.deg, e1.dec.deg, radius=11. / 3600.) F.set_tick_xspacing(6. / 3600) cmcontsrc = Table.read( paths.vpath('tables/EVLA_VLA_PointSourcePhotometry.ipac'), format='ascii.ipac') cmok = (cmcontsrc['Frequency'] == 5.9) & (cmcontsrc['Epoch'] == '3') cmcoords = coordinates.SkyCoord(cmcontsrc['gracen'][cmok], cmcontsrc['gdeccen'][cmok], frame='fk5') core_phot_tbl = Table.read(paths.tpath("continuum_photometry.ipac"), format='ascii.ipac') cores = coordinates.SkyCoord(core_phot_tbl['RA'], core_phot_tbl['Dec'], frame='fk5') F.scalebar.set_label('0.05 pc') F.scalebar.set_color('w')
levels=[0.04, #0.05, 0.06, #0.08, 0.10, #0.15, 0.20, #0.30, 0.40,], colors=['w']*12, layer='alma_cont_hires') F.save(paths.fpath("NACO_green_{0}_outflows_aplpy_CONTours_hires.png".format(species))) F.save(paths.fpath("NACO_green_{0}_outflows_aplpy_CONTours_hires.pdf".format(species))) h77a = SpectralCube.read(paths.vpath('data/W51north_H77_Outflow_cutout.fits')) h77a_outflow = h77a.spectral_slab(-16*u.km/u.s, -60*u.km/u.s).sum(axis=0) h77a_green = paths.dpath('W51_H77a_LacyJetOutflow_Sum.fits') h77a_outflow.hdu.writeto(h77a_green, clobber=True) F.show_contour(h77a_green, levels=[0.0075, 0.015, 0.030], colors=['b']*6, layer='h77a_outflow') F.save(paths.fpath("NACO_green_{0}_outflows_aplpy_CONTours_hires_h77acontour.png".format(species))) F.save(paths.fpath("NACO_green_{0}_outflows_aplpy_CONTours_hires_h77acontour.pdf".format(species))) F.hide_layer('h77a_outflow') F.hide_layer('alma_cont_hires') F.show_contour(paths.dpath('longbaseline/W51ncax.cont.image.pbcor.fits'),