本文整理汇总了Python中atpy.Table.field方法的典型用法代码示例。如果您正苦于以下问题:Python Table.field方法的具体用法?Python Table.field怎么用?Python Table.field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atpy.Table
的用法示例。
在下文中一共展示了Table.field方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SED
# 需要导入模块: from atpy import Table [as 别名]
# 或者: from atpy.Table import field [as 别名]
#.........这里部分代码省略.........
component.plot()
plt.xlim(xlim)
plt.ylim(ylim)
plt.legend()
logging.info('Writing {0}'.format(filename))
plt.savefig(filename)
def add_component(self, catalog_format, catalog_name,
object_name, plot_pivot=False, **ecpl_params):
""" Read necessary parameters from FITS file and plot butterfly
Parameters:
catalog_format = 'hess', 'fermi'
catalog_name = FITS file name
object_name = object name string in 'name' column
Note: Since every catalog has columns with different
names and units, a general SED plotting is not possible.
Instead for each catalog type a handler function that
deals converts to a standard format is called.
@todo: Possibly pass plotting parameters along here by
appending them to the ecpl_params dictionary
-> I don't think this works at the moment!!!"""
from atpy import Table
# Get the catalog from file and initialize some things
self.catalog_format = catalog_format
self.catalog_name = catalog_name
self.object_name = object_name
self.catalog = Table(catalog_name).data
# Build a dictionary of parameters needed for the plot
self.ecpl_params = ecpl_params
self.get_ecpl_params()
# Plot curve
self.plot_ecpl(plot_pivot=plot_pivot, **ecpl_params)
# Plot points if present
if self.plot_points is not None:
# Get the values needed for plotting
e = self.plot_points[0]
f = self.plot_points[1]
f_err = self.plot_points[2]
e_err = self.plot_points[3]
is_ul = self.plot_points[4]
for ii in range(e.size):
self.plot_point(e[ii], f[ii],
f_err=f_err[ii],
e_err=[[e_err[0][ii]], [e_err[1][ii]]],
ul=is_ul[ii])
# Remove so that it doesn't get plotted again.
self.plot_points = None
def get_ecpl_params(self):
"""Build self.ecpl_params dictionary
by parsing one of the supported catalogs"""
if self.catalog_format == 'hess':
self.get_ecpl_params_hess_cat()
elif self.catalog_format == 'fermi':
self.get_ecpl_params_fermi_cat()
# Change numpy types to regular types
# and replace nan values with 0
for key, value in self.ecpl_params.items():
if isinstance(value, np.float32):
value = float(value)
if isinstance(value, np.int16):
value = int(value)
def get_ecpl_params_fermi_cat(self):
""" Build self.ecpl_params dictionary from Fermi catalog fields """
i = self.find_object_index('source_name')
# Set all plot parameters:
self.ecpl_params['e_pivot'] = self.catalog.field('Pivot_Energy')[i]
self.ecpl_params['e_min'] = 1e2
self.ecpl_params['e_max'] = 1e5
self.ecpl_params['e_cut'] = 0.0
self.ecpl_params['e_cut_err'] = 0.0
self.ecpl_params['e_scale'] = 1
self.ecpl_params['norm'] = self.catalog.field('Flux_Density')[i]
self.ecpl_params['norm_err'] = self.catalog.field('Unc_Flux_Density')[i]
self.ecpl_params['norm_scale'] = 1
self.ecpl_params['index'] = self.catalog.field('Spectral_Index')[i]
self.ecpl_params['index_err'] = self.catalog.field('Unc_Spectral_Index')[i]
self.ecpl_params['color'] = 'green'
self.ecpl_params['butterfly'] = True
# Set flux point data
self.plot_points = self.get_flux_points_fermi(i)
# Add text label
fmt = '%s\n%s, %s\n' + \
r'S = %3.1f, C = %3.1f, $\Gamma = %1.2f \pm %1.2f$'
values = (self.object_name,
self.catalog.field('class1')[i],
self.catalog.field('assoc1')[i],
self.catalog.field('signif_avg')[i],
self.catalog.field('curvature_index')[i],
self.catalog.field('spectral_index')[i],
self.catalog.field('unc_spectral_index')[i]
)
self.ax.text(0.05, 0.95, fmt % values,
horizontalalignment='left',
verticalalignment='top',
transform=self.ax.transAxes)