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


Python GraphArtist.add_pin方法代码示例

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


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

示例1: plot_detection_efficiency_vs_R_for_angles

# 需要导入模块: from artist import GraphArtist [as 别名]
# 或者: from artist.GraphArtist import add_pin [as 别名]
def plot_detection_efficiency_vs_R_for_angles(N):
    figure()
    graph = GraphArtist()
    locations = iter(['right', 'left', 'below left'])
    positions = iter([.18, .14, .15])

    bin_edges = linspace(0, 100, 20)
    x = (bin_edges[:-1] + bin_edges[1:]) / 2.

    for angle in [0, 22.5, 35]:
        angle_str = str(angle).replace('.', '_')
        shower_group = '/simulations/E_1PeV/zenith_%s' % angle_str

        efficiencies = []
        for low, high in zip(bin_edges[:-1], bin_edges[1:]):
            shower_results = []
            for shower in data.list_nodes(shower_group):
                sel_query = '(low <= r) & (r < high)'
                coinc_sel = shower.coincidences.read_where(sel_query)
                ids = coinc_sel['id']
                obs_sel = shower.observables.read_coordinates(ids)
                assert (obs_sel['id'] == ids).all()

                o = obs_sel
                sel = obs_sel.compress((o['n1'] >= N) & (o['n3'] >= N) &
                                       (o['n4'] >= N))
                shower_results.append(len(sel) / len(obs_sel))
            efficiencies.append(mean(shower_results))

        plot(x, efficiencies, label=r'$\theta = %s^\circ$' % angle)
        graph.plot(x, efficiencies, mark=None)
        graph.add_pin(r'\SI{%s}{\degree}' % angle,
                      location=locations.next(), use_arrow=True,
                      relative_position=positions.next())

    xlabel("Core distance [m]")
    graph.set_xlabel(r"Core distance [\si{\meter}]")
    ylabel("Detection efficiency")
    graph.set_ylabel("Detection efficiency")
    #title(r"$N_{MIP} \geq %d$" % N)
    legend()
    graph.set_xlimits(0, 100)
    graph.set_ylimits(0, 1)

    utils.saveplot(N)
    artist.utils.save_graph(graph, suffix=N, dirname='plots')
开发者ID:OpenCosmics,项目名称:sapphire,代码行数:48,代码来源:direction_reconstruction.py

示例2: artistplot_reconstruction_efficiency_vs_R_for_angles

# 需要导入模块: from artist import GraphArtist [as 别名]
# 或者: from artist.GraphArtist import add_pin [as 别名]
def artistplot_reconstruction_efficiency_vs_R_for_angles(N):
    filename = 'DIR-plot_reconstruction_efficiency_vs_R_for_angles-%d.txt' % N
    all_data = loadtxt(os.path.join('plots/', filename))

    graph = GraphArtist()
    locations = iter(['above right', 'below left', 'below left'])
    positions = iter([.9, .2, .2])

    x = all_data[:, 0]

    for angle, efficiencies in zip([0, 22.5, 35], all_data[:, 1:].T):
        graph.plot(x, efficiencies, mark=None)
        graph.add_pin(r'\SI{%s}{\degree}' % angle, use_arrow=True,
                      location=locations.next(),
                      relative_position=positions.next())

    graph.set_xlabel("Core distance [\si{\meter}]")
    graph.set_ylabel("Reconstruction efficiency")
    graph.set_xlimits(0, 100)
    graph.set_ylimits(max=1)
    artist.utils.save_graph(graph, suffix=N, dirname='plots')
开发者ID:OpenCosmics,项目名称:sapphire,代码行数:23,代码来源:direction_reconstruction.py

示例3: plot_pulseheight_histogram

# 需要导入模块: from artist import GraphArtist [as 别名]
# 或者: from artist.GraphArtist import add_pin [as 别名]
def plot_pulseheight_histogram(data):
    events = data.root.hisparc.cluster_kascade.station_601.events
    ph = events.col("pulseheights")

    s = landau.Scintillator()
    mev_scale = 3.38 / 340
    count_scale = 6e3 / 0.32

    clf()
    n, bins, patches = hist(ph[:, 0], bins=arange(0, 1501, 10), histtype="step")
    x = linspace(0, 1500, 1500)
    plot(x, s.conv_landau_for_x(x, mev_scale=mev_scale, count_scale=count_scale))
    plot(x, count_scale * s.landau_pdf(x * mev_scale))
    ylim(ymax=25000)
    xlim(xmax=1500)

    # Remove one statistical fluctuation from data.  It is not important
    # for the graph, but it detracts from the main message
    index = bins.searchsorted(370)
    n[index] = mean([n[index - 1], n[index + 1]])

    graph = GraphArtist()
    n_trunc = where(n <= 100000, n, 100000)
    graph.histogram(n_trunc, bins, linestyle="gray")
    graph.add_pin("data", x=800, location="above right", use_arrow=True)
    graph.add_pin("$\gamma$", x=90, location="above right", use_arrow=True)
    graph.plot(x, s.conv_landau_for_x(x, mev_scale=mev_scale, count_scale=count_scale), mark=None)
    graph.add_pin("convolved Landau", x=450, location="above right", use_arrow=True)
    graph.plot(x, count_scale * s.landau_pdf(x * mev_scale), mark=None, linestyle="black")
    graph.add_pin("Landau", x=380, location="above right", use_arrow=True)

    graph.set_xlabel(r"Pulseheight [\adc{}]")
    graph.set_ylabel(r"Number of events")
    graph.set_xlimits(0, 1400)
    graph.set_ylimits(0, 21000)
    graph.save("plots/plot_pulseheight_histogram")
开发者ID:HiSPARC,项目名称:sapphire,代码行数:38,代码来源:plot_pulseheight_histogram.py


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