Beispiel #1
0
def histogram_intensity(file):
    fills = fills_from_file(file, "OML")
    intensities = []
    for nbr in fills:
        fill = Fill(nbr, fetch=False)
        fill.fetch()
        intensities.append(max(fill.intensity().y))

    draw_histogram('Intensity for {}'.format(file), intensities, 1e13,
                   "Intensity", "Count")
Beispiel #2
0
def comp_blm_ir3_vs_intensity(file):
    fills = fills_from_file(file, "OML")
    intensity = []
    mean_loss = []
    max_loss = []
    discarded = 0
    for nbr in fills:
        fill = Fill(nbr, False)
        fill.fetch()
        smin, smax = fill.OML_period()
        ssubset = fill.blm_ir3().y[smin:smax]

        maxint = max(fill.intensity().y)
        if maxint < 1.8e14:
            discarded += 1
            continue

        mean_loss.append(np.mean(ssubset))
        max_loss.append(max(ssubset))
        intensity.append(maxint)

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

    ax1.set_xlabel("Mean momentum (IR3) TCP")
    ax1.set_ylabel("Intensity")
    ax1.scatter(mean_loss, intensity, color='b', label='mean')
    ax1.set_xlim([0, 1.1 * max(mean_loss)])
    ax1.set_ylim([1.5e14, 1.1 * max(intensity)])
    ax1.legend(loc="lower right")

    ax2.set_xlabel("Max momentum (IR3) TCP")
    ax2.set_ylabel("Intensity")
    ax2.scatter(max_loss, intensity, color='r', label='max')
    ax2.set_xlim([0, 1.1 * max(max_loss)])
    ax2.legend(loc="lower right")

    percent_used = int(
        round(float(len(intensity)) / (len(intensity) + discarded) * 100))
    fig.suptitle(
        "Intensity vs OML for {} (only intenities > 1.8e14, {}% of total)\n".
        format(file, percent_used))

    plt.show()
Beispiel #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()