def main(fname):
    collision_data = CollisionData.data_from_file(fname)

    t1 = collision_data.type1s
    t2 = collision_data.type2s
    deltaVs = collision_data.deltaVs
    distances = collision_data.distances

    low  = np.min(deltaVs)
    high = np.max(deltaVs)

    #diff_indices = np.where(t1 != t2)
    #diff_deltaVs = deltaVs[diff_indices]
    #diff_hist = gaussian_kde(diff_deltaVs)
    #diff_xs   = np.linspace(low, high, 200)

    #he_indices = np.where(np.logical_and(t1 == 0, t2 == 0))
    #he_deltaVs = deltaVs[he_indices]
    #he_hist = gaussian_kde(he_deltaVs)
    #he_xs   = np.linspace(low, high, 200)
    #he_dist = distances[he_indices]

    xe_indices = np.where(np.logical_and(t1 == 7, t2 == 7))
    xe_deltaVs = deltaVs[xe_indices]

    xe_xs   = np.linspace(low, high, 200)
    xe_dist = distances[xe_indices]
    #print np.mean(xe_dist), np.median(xe_dist), np.mean(distances), np.median(distances)
    print mquantiles(distances, prob=[0.8, 0.85, 0.9, 0.95, 0.975, 0.99])

    if len(xe_deltaVs) <= 1:
        return

    xe_hist = gaussian_kde(xe_deltaVs)

    fig = plt.figure()
    ax  = fig.add_subplot(1, 1, 1)

    # print np.mean(xe_dist)

    # update the view limits
    #ax.plot(diff_xs, diff_hist(diff_xs), c='r', marker='.', label='He-Xe')
    #ax.plot(he_xs, he_hist(he_xs), c='g', marker='.', label='He-He')
    ax.plot(xe_xs, xe_hist(xe_xs), c='b', marker='.', label='Xe-Xe')
    ax.set_xlim(0, high)
    ax.set_title("Collision Radius vs Difference in Velocity")
    ax.set_xlabel("Delta V (m/s)")
    ax.set_ylabel("Relative Density")
    ax.legend()

    fig.savefig(os.path.splitext(fname)[0] + ".png", dpi=250)
    plt.close()
    fig = None
    ax = None
def main(fname):
    collision_data = CollisionData.data_from_file(fname)

    t1 = collision_data.type1s
    t2 = collision_data.type2s
    deltaVs = collision_data.deltaVs
    distances = collision_data.distances

    low = np.min(deltaVs)
    high = np.max(deltaVs)

    #diff_indices = np.where(t1 != t2)
    #diff_deltaVs = deltaVs[diff_indices]
    #diff_hist = gaussian_kde(diff_deltaVs)
    #diff_xs   = np.linspace(low, high, 200)

    #he_indices = np.where(np.logical_and(t1 == 0, t2 == 0))
    #he_deltaVs = deltaVs[he_indices]
    #he_hist = gaussian_kde(he_deltaVs)
    #he_xs   = np.linspace(low, high, 200)
    #he_dist = distances[he_indices]

    xe_indices = np.where(np.logical_and(t1 == 7, t2 == 7))
    xe_deltaVs = deltaVs[xe_indices]

    xe_xs = np.linspace(low, high, 200)
    xe_dist = distances[xe_indices]
    #print np.mean(xe_dist), np.median(xe_dist), np.mean(distances), np.median(distances)
    print mquantiles(distances, prob=[0.8, 0.85, 0.9, 0.95, 0.975, 0.99])

    if len(xe_deltaVs) <= 1:
        return

    xe_hist = gaussian_kde(xe_deltaVs)

    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)

    # print np.mean(xe_dist)

    # update the view limits
    #ax.plot(diff_xs, diff_hist(diff_xs), c='r', marker='.', label='He-Xe')
    #ax.plot(he_xs, he_hist(he_xs), c='g', marker='.', label='He-He')
    ax.plot(xe_xs, xe_hist(xe_xs), c='b', marker='.', label='Xe-Xe')
    ax.set_xlim(0, high)
    ax.set_title("Collision Radius vs Difference in Velocity")
    ax.set_xlabel("Delta V (m/s)")
    ax.set_ylabel("Relative Density")
    ax.legend()

    fig.savefig(os.path.splitext(fname)[0] + ".png", dpi=250)
    plt.close()
    fig = None
    ax = None
Example #3
0
def main(fname):
    collision_data = CollisionData.data_from_file(fname)

    if collision_data is None:
        return

    energies  = collision_data.energies * 6.24150934e15
    distances = collision_data.distances

    if len(energies) < 100:
        return

    for d, e in zip(distances, energies):
        print d, ',', e

    #energies.sort()

    low  = np.min(energies)
    high = np.max(energies)

    print fname, np.max(energies)

    hist = gaussian_kde(energies)
    n, bins = np.histogram(energies, bins=100)

    fig = plt.figure()
    ax  = fig.add_subplot(1, 1, 1)

    # print np.mean(xe_dist)

    # update the view limits
    #ax.plot(diff_xs, diff_hist(diff_xs), c='r', marker='.', label='He-Xe')
    #ax.plot(he_xs, he_hist(he_xs), c='g', marker='.', label='He-He')
    #ax.plot(bins[:-1], n, c='b', marker='.')
    ax.scatter(energies, distances)
    ax.set_xlim(low, high)
    ax.set_ylim(0.0, np.max(distances))
    ax.set_title("Collision Energy Histogram")
    ax.set_xlabel("Collision Energy (keV)")
    ax.set_ylabel("Relative Density")
    ax.legend()

    fig.savefig(os.path.splitext(fname)[0] + ".png", dpi=250)
    plt.close()
    fig = None
    ax = None
Example #4
0
def main(fname):
    collision_data = CollisionData.data_from_file(fname)
    time = collision_data.times
    pos = collision_data.positions
    ene = collision_data.energies

    ene_min = np.min(ene)
    ene_max = np.max(ene)

    jet = plt.get_cmap('jet')
    cNorm = colo.Normalize(vmin=0, vmax=ene_max)
    scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=jet)

    ep = np.zeros((len(ene), 3))
    for i in range(len(ene)):
        ep[i, :] = scalarMap.to_rgba(ene[i])[0:3]

    x_min = np.min(pos[:, 0])
    x_max = np.max(pos[:, 0])
    z_min = np.min(pos[:, 2])
    z_max = np.max(pos[:, 2])

    x_range = x_max - x_min
    z_range = z_max - z_min

    X = np.zeros((GRID_WIDTH, GRID_HEIGHT, 3))

    grid_x = ((pos[:, 0] - x_min) / x_range * GRID_WIDTH).astype(int) - 1
    grid_y = ((pos[:, 2] - z_min) / z_range * GRID_HEIGHT).astype(int) - 1

    X[grid_y, grid_x] = ep

    xs = np.arange(0, GRID_WIDTH) * x_range / GRID_WIDTH + x_min
    ys = np.arange(0, GRID_HEIGHT) * z_range / GRID_HEIGHT + z_min
    extents = (x_min, x_max, z_min, z_max)

    plt.imshow(X, origin='lower', cmap=cmx.jet, aspect='auto', extent=extents)
    plt.savefig(fname + ".png", dpi=150)
    plt.clf()
def main(fname):
    collision_data = CollisionData.data_from_file(fname)

    fig, ax = plt.subplots()

    t1 = collision_data.type1s
    t2 = collision_data.type2s
    deltaVs = collision_data.deltaVs
    distances = collision_data.distances

    del collision_data

    diff_indices = np.where(t1 != t2)[::10]
    diff_deltaVs = deltaVs[diff_indices]
    diff_distances = distances[diff_indices]

    he_indices = np.where(np.logical_and(t1 == 0, t2 == 0))[::10]
    he_deltaVs = deltaVs[he_indices]
    he_distances = distances[he_indices]

    xe_indices = np.where(np.logical_and(t1 == 7, t2 == 7))[::10]
    xe_deltaVs = deltaVs[xe_indices]
    xe_distances = distances[xe_indices]

    print np.mean(xe_distances)

    ax.scatter(diff_deltaVs, diff_distances, c='r', marker='.', label='He-Xe')
    ax.scatter(he_deltaVs, he_distances, c='g', marker='.', label='He-He')
    ax.scatter(xe_deltaVs, xe_distances, c='b', marker='.', label='Xe-Xe')
    ax.set_xlim(0, np.max(deltaVs))
    ax.set_ylim(np.min(distances), np.max(distances))
    ax.set_title("Collision Radius vs Difference in Velocity")
    ax.set_xlabel("Delta V (m/s)")
    ax.set_ylabel("Collision Radius (m)")
    ax.legend()
    fig.savefig(fname + ".png", dpi=250)
    plt.clf()
def main(fname):
    collision_data = CollisionData.data_from_file(fname)

    fig, ax = plt.subplots()

    t1 = collision_data.type1s
    t2 = collision_data.type2s
    deltaVs = collision_data.deltaVs
    distances = collision_data.distances

    del collision_data

    diff_indices = np.where(t1 != t2)[::10]
    diff_deltaVs = deltaVs[diff_indices]
    diff_distances = distances[diff_indices]

    he_indices = np.where(np.logical_and(t1 == 0, t2 == 0))[::10]
    he_deltaVs = deltaVs[he_indices]
    he_distances = distances[he_indices]

    xe_indices = np.where(np.logical_and(t1 == 7, t2 == 7))[::10]
    xe_deltaVs = deltaVs[xe_indices]
    xe_distances = distances[xe_indices]

    print np.mean(xe_distances)

    ax.scatter(diff_deltaVs, diff_distances, c="r", marker=".", label="He-Xe")
    ax.scatter(he_deltaVs, he_distances, c="g", marker=".", label="He-He")
    ax.scatter(xe_deltaVs, xe_distances, c="b", marker=".", label="Xe-Xe")
    ax.set_xlim(0, np.max(deltaVs))
    ax.set_ylim(np.min(distances), np.max(distances))
    ax.set_title("Collision Radius vs Difference in Velocity")
    ax.set_xlabel("Delta V (m/s)")
    ax.set_ylabel("Collision Radius (m)")
    ax.legend()
    fig.savefig(fname + ".png", dpi=250)
    plt.clf()
Example #7
0
    middle = 0.5 * (right + left)

    return (middle, ene / n)


def make_histogram(data, fname):

    middle, ene = histogram_from_data(data)

    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)

    # update the view limits
    ax.set_xlim(middle[0], middle[-1])
    #ax.set_ylim(0.0, 10.0)
    ax.set_xlabel("Radius")
    ax.set_ylabel("Density")

    ax.plot(middle, ene, c='r')

    fig.savefig(os.path.splitext(fname)[0] + ".png", dpi=150)
    plt.close()
    fig = None
    ax = None


for fname in sys.argv[1:]:
    print fname
    data = CollisionData.data_from_file(fname)
    make_histogram(data, fname)
    middle = 0.5 * (right + left)

    return (middle, ene / n)

def make_histogram(data, fname):

    middle, ene = histogram_from_data(data)

    fig = plt.figure()
    ax  = fig.add_subplot(1, 1, 1)

    # update the view limits
    ax.set_xlim(middle[0], middle[-1])
    #ax.set_ylim(0.0, 10.0)
    ax.set_xlabel("Radius")
    ax.set_ylabel("Density")

    ax.plot(middle, ene, c='r')

    fig.savefig(os.path.splitext(fname)[0] + ".png", dpi=150)
    plt.close()
    fig = None
    ax = None

for fname in sys.argv[1:]:
    print fname
    data = CollisionData.data_from_file(fname)
    make_histogram(data, fname)