当前位置: 首页>>代码示例>>Python>>正文


Python FITSFigure.add_colorbar方法代码示例

本文整理汇总了Python中aplpy.FITSFigure.add_colorbar方法的典型用法代码示例。如果您正苦于以下问题:Python FITSFigure.add_colorbar方法的具体用法?Python FITSFigure.add_colorbar怎么用?Python FITSFigure.add_colorbar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aplpy.FITSFigure的用法示例。


在下文中一共展示了FITSFigure.add_colorbar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: part_8

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
def part_8():

	object_list = ['ROXs12','ROXs42B','ROXs42B']
	filename_list = ['ROXs12','ROXs42Bb','ROXs42Bc']

	for i in range(len(filename_list)):
		outfile = open('position_'+filename_list[i]+'.dat','w')
		outfile.write('# '+'%25s'%'file name\t'\
							  +'%12s'%'x planet\t'\
							  +'%12s'%'y planet\t'\
							  +'%12s'%'position angle\t'\
							  +'%12s'%'projected separation (pixels)\n')


		if filename_list[i] == 'ROXs12': int_x,int_y = 562,685
		elif filename_list[i] == 'ROXs42Bb': int_x,int_y = 629,495
		elif filename_list[i] == 'ROXs42Bc': int_x,int_y = 546,465
		parts = ['','_CMsub','_ADIsub','_bPSFsub']
		for j in parts:

			filename = object_list[i]+j+'_aligned_median.fits'
			fit_radius = 16

			f = fits.open(filename)
			scidata = f[0].data

			x_data = scidata[int_y,int_x-fit_radius:int_x+fit_radius+1]
			x_data -= min(x_data)
			fit_x = np.linspace(-fit_radius,fit_radius,1+2*fit_radius)
			xfitParam, xfitCovar = curve_fit(gaussian_pdf,fit_x,x_data)
			
			y_data = scidata[int_y-fit_radius:int_y+fit_radius+1,int_x]
			y_data -= min(y_data)
			fit_y = np.linspace(-fit_radius,fit_radius,1+2*fit_radius)
			yfitParam, yfitCovar = curve_fit(gaussian_pdf,fit_y,y_data)

			thisPARANG   = f[0].header['PARANG']
			thisROTPPOSN = f[0].header['ROTPPOSN']
			thisEL       = f[0].header['EL']
			thisINSTANGL = f[0].header['INSTANGL']
			PA_yaxis     = thisPARANG +thisROTPPOSN -thisEL -thisINSTANGL

			PA_planet    = PA_yaxis -rad_to_deg(arctan2(float(xfitParam[0]+int_x-512),float(yfitParam[0]+int_y-512)))
			if PA_planet < 0: PA_planet += 360

			outfile.write('%25s'%str(object_list[i]+j+'_aligned_median.fits')+'\t'\
					+'%8s'%'%.3f'%(float(xfitParam[0]+int_x))+'\t'\
					+'%8s'%'%.3f'%(float(yfitParam[0]+int_y))+'\t'\
					+'%8s'%'%.3f'%(float(PA_planet))+'\t'\
					+'%8s'%'%.3f'%(float(sqrt((xfitParam[0]+int_x-512)**2+(yfitParam[0]+int_y-512)**2)))+'\n')

			tf = FITSFigure(filename)
			tf.show_colorscale(cmap='gray')
			tf.add_colorbar()
			tf.colorbar.show(location='top',box_orientation='horizontal')
			plt.savefig(object_list[i]+j+'_aligned_median.pdf',dpi=200)
			plt.close()

		outfile.close()
开发者ID:aleung12,项目名称:ast381,代码行数:61,代码来源:hw2.py

示例2: test_colorbar_font

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
def test_colorbar_font():
    data = np.zeros((16, 16))
    f = FITSFigure(data)
    f.show_grayscale()
    f.add_colorbar()
    f.colorbar.set_font(size='small', weight='bold', stretch='normal',
                        family='serif', style='normal', variant='normal')
    f.close()
开发者ID:d80b2t,项目名称:python,代码行数:10,代码来源:test_colorbar.py

示例3: test_colorbar_showhide

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
def test_colorbar_showhide():
    data = np.zeros((16, 16))
    f = FITSFigure(data)
    f.show_grayscale()
    f.add_colorbar()
    f.colorbar.hide()
    f.colorbar.show()
    f.close()
开发者ID:d80b2t,项目名称:python,代码行数:10,代码来源:test_colorbar.py

示例4: test_colorbar_addremove

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
def test_colorbar_addremove():
    data = np.zeros((16, 16))
    f = FITSFigure(data)
    f.show_grayscale()
    f.add_colorbar()
    f.remove_colorbar()
    f.add_colorbar()
    f.close()
开发者ID:d80b2t,项目名称:python,代码行数:10,代码来源:test_colorbar.py

示例5: test_colorbar_pad

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
def test_colorbar_pad():
    data = np.zeros((16, 16))
    f = FITSFigure(data)
    f.show_grayscale()
    f.add_colorbar()
    f.colorbar.set_pad(0.1)
    f.colorbar.set_pad(0.2)
    f.colorbar.set_pad(0.5)
    f.close()
开发者ID:d80b2t,项目名称:python,代码行数:11,代码来源:test_colorbar.py

示例6: test_colorbar_location

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
def test_colorbar_location():
    data = np.zeros((16, 16))
    f = FITSFigure(data)
    f.show_grayscale()
    f.add_colorbar()
    f.colorbar.set_location('top')
    f.colorbar.set_location('bottom')
    f.colorbar.set_location('left')
    f.colorbar.set_location('right')
    f.close()
开发者ID:d80b2t,项目名称:python,代码行数:12,代码来源:test_colorbar.py

示例7: plot_exposure_image

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
def plot_exposure_image(filename):
    """Plot FOV image of exposure for one given energy slice"""
    from astropy.io import fits
    from aplpy import FITSFigure
    fig = FITSFigure(filename, dimensions=(0, 1), slices=[10], figsize=(5, 5))
    header = fits.getheader(filename)
    fig.show_grayscale()
    fig.add_colorbar()
    ra, dec = header['CRVAL1'], header['CRVAL2']
    
    # Bug: Marker doesn't show up at the center of the run
    # Bug: aplpy show_circles doesn't show a circle in degress.
    fig.show_markers(ra, dec)
    fig.show_circles(ra, dec, 1.)
    
    fig.tick_labels.set_xformat('dd')
    fig.tick_labels.set_yformat('dd')
    fig.ticks.set_xspacing(1)
    fig.ticks.set_yspacing(1)
    fig.colorbar.set_axis_label_text('Effective Area (cm^2)')
    
    fig.save('exposure_image.png')
开发者ID:Cadair,项目名称:gammapy,代码行数:24,代码来源:plot_irfs.py

示例8: FITSFigure

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
# Gammapy significance
significance = np.nan_to_num(significance(correlated_counts, correlated_model,
                                          method='lima'))

titles = ['Gammapy Significance', 'Fermi Tools Significance']

# Plot

fig = plt.figure(figsize=(10, 5))
hdu1 = fits.ImageHDU(significance, header)
f1 = FITSFigure(hdu1, figure=fig, convention='wells', subplot=(1, 2, 1))
f1.set_tick_labels_font(size='x-small')
f1.tick_labels.set_xformat('ddd')
f1.tick_labels.set_yformat('ddd')
f1.show_colorscale(vmin=0, vmax=10, cmap='afmhot')
f1.add_colorbar(axis_label_text='Significance')
f1.colorbar.set_width(0.1)
f1.colorbar.set_location('right')

hdu2 = fits.ImageHDU(fermi_significance, header)
f2 = FITSFigure(hdu2, figure=fig, convention='wells', subplot=(1, 2, 2))
f2.set_tick_labels_font(size='x-small')
f2.tick_labels.set_xformat('ddd')
f2.hide_ytick_labels()
f2.hide_yaxis_label()
f2.show_colorscale(vmin=0, vmax=10, cmap='afmhot')
f2.add_colorbar(axis_label_text='Significance')
f2.colorbar.set_width(0.1)
f2.colorbar.set_location('right')
fig.text(0.15, 0.92, "Gammapy Significance")
fig.text(0.63, 0.92, "Fermi Tools Significance")
开发者ID:OlgaVorokh,项目名称:gammapy,代码行数:33,代码来源:npred_convolved_significance.py

示例9: FITSFigure

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
fermi_significance = np.nan_to_num(significance(correlated_counts, correlated_gtmodel, method="lima"))
# Gammapy significance
significance = np.nan_to_num(significance(correlated_counts, correlated_model, method="lima"))

titles = ["Gammapy Significance", "Fermi Tools Significance"]

# Plot

fig = plt.figure(figsize=(10, 5))
hdu1 = fits.ImageHDU(significance, header)
f1 = FITSFigure(hdu1, figure=fig, convention="wells", subplot=(1, 2, 1))
f1.set_tick_labels_font(size="x-small")
f1.tick_labels.set_xformat("ddd")
f1.tick_labels.set_yformat("ddd")
f1.show_colorscale(vmin=0, vmax=20, cmap="afmhot", stretch="sqrt")
f1.add_colorbar(axis_label_text="Significance")
f1.colorbar.set_width(0.1)
f1.colorbar.set_location("right")

hdu2 = fits.ImageHDU(fermi_significance, header)
f2 = FITSFigure(hdu2, figure=fig, convention="wells", subplot=(1, 2, 2))
f2.set_tick_labels_font(size="x-small")
f2.tick_labels.set_xformat("ddd")
f2.hide_ytick_labels()
f2.hide_yaxis_label()
f2.show_colorscale(vmin=0, vmax=20, cmap="afmhot", stretch="sqrt")
f2.add_colorbar(axis_label_text="Significance")
f2.colorbar.set_width(0.1)
f2.colorbar.set_location("right")
fig.text(0.15, 0.92, "Gammapy Significance")
fig.text(0.63, 0.92, "Fermi Tools Significance")
开发者ID:dlennarz,项目名称:gammapy,代码行数:33,代码来源:npred_convolved_significance.py

示例10: catalog_image

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
"""Produces an image from 1FHL catalog point sources.
"""
import numpy as np
import matplotlib.pyplot as plt
from aplpy import FITSFigure
from gammapy.datasets import FermiGalacticCenter
from gammapy.image import catalog_image, SkyImage
from gammapy.irf import EnergyDependentTablePSF

# Create image of defined size
reference = SkyImage.empty(nxpix=300, nypix=100, binsz=1).to_image_hdu()
psf_file = FermiGalacticCenter.filenames()['psf']
psf = EnergyDependentTablePSF.read(psf_file)

# Create image
image = catalog_image(reference, psf, catalog='1FHL', source_type='point',
                      total_flux='True')

# Plot
fig = FITSFigure(image.to_fits()[0], figsize=(15, 5))
fig.show_colorscale(interpolation='bicubic', cmap='afmhot', stretch='log', vmin=1E-12, vmax=1E-8)
fig.tick_labels.set_xformat('ddd')
fig.tick_labels.set_yformat('dd')
ticks = np.logspace(-12, -8, 5)
fig.add_colorbar(ticks=ticks, axis_label_text='Flux (ph s^-1 cm^-2 TeV^-1)')
fig.colorbar._colorbar_axes.set_yticklabels(['{:.0e}'.format(_) for _ in ticks])
plt.tight_layout()
plt.show()
开发者ID:OlgaVorokh,项目名称:gammapy,代码行数:30,代码来源:source_image_demo.py

示例11: FITSFigure

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
hdu1 = fits.ImageHDU(model, header)
f1 = FITSFigure(hdu1, figure=fig, convention='wells', subplot=[0.18, 0.264, 0.18, 0.234])
f1.tick_labels.set_font(size='x-small')
f1.tick_labels.set_xformat('ddd')
f1.tick_labels.set_yformat('ddd')
f1.axis_labels.hide_x()
f1.show_colorscale(vmin=0, vmax=0.3)

hdu2 = fits.ImageHDU(gtmodel, header)
f2 = FITSFigure(hdu2, figure=fig, convention='wells', subplot=[0.38, 0.25, 0.2, 0.26])
f2.tick_labels.set_font(size='x-small')
f2.tick_labels.set_xformat('ddd')
f2.tick_labels.hide_y()
f2.axis_labels.hide_y()
f2.show_colorscale(vmin=0, vmax=0.3)
f2.add_colorbar()
f2.colorbar.set_width(0.1)
f2.colorbar.set_location('right')

hdu3 = fits.ImageHDU(ratio, header)
f3 = FITSFigure(hdu3, figure=fig, convention='wells', subplot=[0.67, 0.25, 0.2, 0.26])
f3.tick_labels.set_font(size='x-small')
f3.tick_labels.set_xformat('ddd')
f3.tick_labels.hide_y()
f3.axis_labels.hide()
f3.show_colorscale(vmin=0.9, vmax=1.1)
f3.add_colorbar()
f3.colorbar.set_width(0.1)
f3.colorbar.set_location('right')

fig.text(0.19, 0.53, "Gammapy Background", color='black', size='9')
开发者ID:JonathanDHarris,项目名称:gammapy,代码行数:33,代码来源:npred_convolved.py

示例12: make_empty_image

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
"""Produces an image from 1FHL catalog point sources.
"""
from aplpy import FITSFigure
from gammapy.datasets import FermiGalacticCenter
from gammapy.image import make_empty_image, catalog_image
from gammapy.irf import EnergyDependentTablePSF

# Create image of defined size
reference = make_empty_image(nxpix=300, nypix=100, binsz=1)
psf_file = FermiGalacticCenter.filenames()['psf']
psf = EnergyDependentTablePSF.read(psf_file)

# Create image
image = catalog_image(reference, psf, catalog='1FHL', source_type='point',
                      total_flux='True')

# Plot
fig = FITSFigure(image.to_fits()[0])
fig.show_grayscale(stretch='linear', interpolation='none')
fig.add_colorbar()
开发者ID:JonathanDHarris,项目名称:gammapy,代码行数:22,代码来源:source_image_demo.py

示例13: prepare_images

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
model, gtmodel, ratio, counts, header = prepare_images()

# Plotting
fig = plt.figure(figsize=(15, 5))

image1 = fits.ImageHDU(data=model, header=header)
f1 = FITSFigure(image1, figure=fig, subplot=(1, 3, 1), convention='wells')
f1.show_colorscale(vmin=0, vmax=0.3, cmap='afmhot')
f1.tick_labels.set_xformat('ddd')
f1.tick_labels.set_yformat('dd')

image2 = fits.ImageHDU(data=gtmodel, header=header)
f2 = FITSFigure(image2, figure=fig, subplot=(1, 3, 2), convention='wells')
f2.show_colorscale(vmin=0, vmax=0.3, cmap='afmhot')
f2.tick_labels.set_xformat('ddd')
f2.tick_labels.set_yformat('dd')

image3 = fits.ImageHDU(data=ratio, header=header)
f3 = FITSFigure(image3, figure=fig, subplot=(1, 3, 3), convention='wells')
f3.show_colorscale(vmin=0.95, vmax=1.05, cmap='RdBu')
f3.tick_labels.set_xformat('ddd')
f3.tick_labels.set_yformat('dd')
f3.add_colorbar(ticks=[0.95, 0.975, 1, 1.025, 1.05])

fig.text(0.12, 0.95, "Gammapy Background")
fig.text(0.45, 0.95, "Fermi Tools Background")
fig.text(0.75, 0.95, "Ratio: Gammapy/Fermi Tools")
plt.tight_layout()
plt.show()
开发者ID:dlennarz,项目名称:gammapy,代码行数:31,代码来源:npred_convolved.py

示例14: luminosity

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
    n_sources=n_sources, rad_dis=rad_dis, vel_dis=vel_dis, max_age=1e6, spiralarms=spiralarms, random_state=0
)

# Minimum source luminosity (ph s^-1)
luminosity_min = 4e34
# Maximum source luminosity (ph s^-1)
luminosity_max = 4e37
# Luminosity function differential power-law index
luminosity_index = 1.5

# Assigns luminosities to sources
luminosity = sample_powerlaw(luminosity_min, luminosity_max, luminosity_index, n_sources, random_state=0)
table["luminosity"] = luminosity

# Adds parameters to table: distance, glon, glat, flux, angular_extension
table = population.add_observed_parameters(table)
table.meta["Energy Bins"] = np.array([10, 500]) * u.GeV
# Create image
image = catalog_image(reference, psf, catalog="simulation", source_type="point", total_flux=True, sim_table=table)

# Plot
fig = FITSFigure(image.to_fits(format="fermi-background")[0], figsize=(15, 5))
fig.show_colorscale(interpolation="bicubic", cmap="afmhot", stretch="log", vmin=1e30, vmax=1e35)
fig.tick_labels.set_xformat("ddd")
fig.tick_labels.set_yformat("dd")
ticks = np.logspace(30, 35, 6)
fig.add_colorbar(ticks=ticks, axis_label_text="Flux (ph s^-1)")
fig.colorbar._colorbar_axes.set_yticklabels(["{:.0e}".format(_) for _ in ticks])
plt.tight_layout()
plt.show()
开发者ID:dlennarz,项目名称:gammapy,代码行数:32,代码来源:simulated_image_demo.py

示例15: prepare_images

# 需要导入模块: from aplpy import FITSFigure [as 别名]
# 或者: from aplpy.FITSFigure import add_colorbar [as 别名]
model, gtmodel, ratio, counts, header = prepare_images()

# Plotting
fig = plt.figure(figsize=(15, 5))

image1 = fits.ImageHDU(data=model, header=header)
f1 = FITSFigure(image1, figure=fig, subplot=(1, 3, 1), convention='wells')
f1.show_colorscale(vmin=0, vmax=0.3, cmap='afmhot')
f1.tick_labels.set_xformat('ddd')
f1.tick_labels.set_yformat('dd')

image2 = fits.ImageHDU(data=gtmodel, header=header)
f2 = FITSFigure(image2, figure=fig, subplot=(1, 3, 2), convention='wells')
f2.show_colorscale(vmin=0, vmax=0.3, cmap='afmhot')
f2.tick_labels.set_xformat('ddd')
f2.tick_labels.set_yformat('dd')

image3 = fits.ImageHDU(data=ratio, header=header)
f3 = FITSFigure(image3, figure=fig, subplot=(1, 3, 3), convention='wells')
f3.show_colorscale(vmin=0.9, vmax=1.1, cmap='RdBu')
f3.tick_labels.set_xformat('ddd')
f3.tick_labels.set_yformat('dd')
f3.add_colorbar(ticks=[0.9, 0.95, 1, 1.05, 1.1])

fig.text(0.12, 0.95, "Gammapy Background")
fig.text(0.45, 0.95, "Fermi Tools Background")
fig.text(0.75, 0.95, "Ratio: Gammapy/Fermi Tools")
plt.tight_layout()
plt.show()
开发者ID:astrofrog,项目名称:gammapy,代码行数:31,代码来源:npred_convolved.py


注:本文中的aplpy.FITSFigure.add_colorbar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。