Пример #1
0
def histogram_crossover_point(file):
    """ Histogram on what durations OML dominate the transversal losses """
    fills = fills_from_file(file, "OML")
    durations = []
    outliers = []
    for nbr in fills:
        fill = Fill(nbr)

        crossover = fill.crossover_point()
        if crossover['t'] > 40:
            outliers.append(nbr)
        else:
            durations.append(crossover["t"])

    draw_histogram("Duration OML > transversal losses from '{}'".format(file),
                   durations, 1, 'Duration (s) after spike with OML > TM',
                   'Count')
    return outliers
Пример #2
0
def bar_graph_crossover_point(file):
    """ Bar graph displaying the 'time till max spike' + 'time where OML > TM' for all fills in file """
    fills = fills_from_file(file, "OML")
    oml_dom_duration = []
    time_till_spike = []
    total_duration = []

    odd = []
    for nbr in fills:
        fill = Fill(nbr)

        crossover = fill.crossover_point()
        oml = fill.blm_ir3()
        ispike = np.argmax(oml.y)
        tspike = oml.x[ispike]
        time_till_spike.append(tspike)

        oml_dom_duration.append(crossover["t"] - tspike)

        total_duration.append(crossover['t'])

        if crossover['t'] > 40 or tspike > 12:  # why am I using this?
            odd.append(nbr)

    print("odd looking fills: ", odd)
    fig, ax = plt.subplots()
    ax.bar(range(len(oml_dom_duration)),
           time_till_spike,
           label='Time to max peak (s)')
    ax.bar(range(len(oml_dom_duration)),
           oml_dom_duration,
           bottom=time_till_spike,
           label='Crossover point (s)')
    ax.legend(loc="upper right")
    ax.set_xlabel("Fill nbr")
    ax.set_ylabel("Duration (s)")
    plt.show()
Пример #3
0
def comp_blm_ir3_vs_abort_gap(file):
    fills = fills_from_file(file, "OML")
    abort_gap = []
    average_loss = []
    max_loss = []
    for nbr in fills:
        fill = Fill(nbr, False)
        fill.fetch()
        smin, smax = fill.OML_period()

        # Only looking until t_co instead -- will not affect max
        smax = fill.crossover_point()['i']

        tmax = fill.blm_ir3().x[smax]
        tmin = fill.blm_ir3().x[smin]

        # tmax = find_crossover_point(fill)['t']

        ag_average = moving_average(fill.abort_gap().y, 5)
        agmin = fill.abort_gap().index_for_time(tmin)
        agmax = fill.abort_gap().index_for_time(tmax)

        ssubset = fill.blm_ir3().y[smin:smax]

        average_loss.append(np.average(ssubset))
        max_loss.append(max(ssubset))
        abort_gap.append(ag_average[agmin] - ag_average[agmax])

    fig = plt.figure()
    ax1 = fig.add_subplot(121)
    ax2 = fig.add_subplot(122, sharey=ax1)

    # fig1, ax1 = plt.subplots()
    ax1.set_xlabel("Average BLM")
    ax1.set_ylabel("∆ abort gap intensity")
    ax1.scatter(average_loss, abort_gap, color='b', label='average')
    ax1.set_xlim([0, 1.1 * max(average_loss)])
    ax1.set_ylim([0, 1.1 * max(abort_gap)])

    xval = [0, 1]
    slope, intercept, r_value, p_value, std_err = stats.linregress(
        average_loss, abort_gap)
    print("Average fit")
    print(
        "\tk  ={:>10.3E}\n\tm  ={:>10.3E}\n\tr  ={:>10.7f}\n\tp  ={:>10.3E}\n\te^2={:>10.3E}"
        .format(slope, intercept, r_value, p_value, std_err))
    yfit = [slope * x + intercept for x in xval]
    ax1.plot(xval, yfit, color='gray')

    ax1.legend(loc="lower right")

    # fig2, ax2 = plt.subplots()
    ax2.set_xlabel("Max BLM")
    ax2.scatter(max_loss, abort_gap, color='r', label='max')
    ax2.set_xlim([0, 1.1 * max(max_loss)])
    ax2.legend(loc="lower right")

    slope, intercept, r_value, p_value, std_err = stats.linregress(
        max_loss, abort_gap)
    print("Max fit")
    print(
        "\tk  ={:>10.3E}\n\tm  ={:>10.3E}\n\tr  ={:>10.7f}\n\tp  ={:>10.3E}\n\te^2={:>10.3E}"
        .format(slope, intercept, r_value, p_value, std_err))
    yfit = [slope * x + intercept for x in xval]
    ax2.plot(xval, yfit, color='gray')

    fig.suptitle(
        "Correlation between abort gap intensity and BLM signal for TCP in IR3"
    )
    plt.show()