示例#1
0
def run(peak_str, peak_centre, source_name, timestep):

    import units as un

    print "Plotting each individual peak in kx, ky, and kz..."

    directions = ["kx", "ky", "kz"]

    constant_axes = [[1, 2], [0, 2], [0, 1]]

    variable_axes = [0, 1, 2]

    for i, current_peak_str in enumerate(peak_str):

        data_filename = un.determine_accurate_soh_output_file_location(
            current_peak_str, source_name, timestep)

        soh_output = un.read_from_soh_output(data_filename)

        centre_point = peak_centre[i]

        for j, direction in enumerate(directions):

            k, intensity = un.find_line_data_from_3DFT(constant_axes[j],
                                                       variable_axes[j],
                                                       centre_point,
                                                       soh_output)

            plot_data_filename = "./data/" + current_peak_str + "/" + direction + ".dat"
            plot_filename = "./data/" + current_peak_str + "/" + direction + ".png"

            un.plot_pygnuplot(k, intensity, plot_filename, plot_data_filename)

    return
示例#2
0
def run(peak_str, peak_centre, source_name, timestep):

    import units as un
    import numpy as np

    print "Plotting each peak in kx, ky, kz, and |G^2|..."

    directions = ["kx", "ky", "kz"]

    constant_axes = [[1, 2], [0, 2], [0, 1]]

    variable_axes = [0, 1, 2]

    for i, current_peak_str in enumerate(peak_str):

        data_filename = un.determine_accurate_soh_output_file_location(
            current_peak_str, source_name, timestep)

        soh_output = un.read_from_soh_output(data_filename)

        centre_point = peak_centre[i]

        # This for loop plots the peak through kx, ky, and kz.

        for j, direction in enumerate(directions):

            k, intensity = un.find_line_data_from_3DFT(constant_axes[j],
                                                       variable_axes[j],
                                                       centre_point,
                                                       soh_output)

            plot_data_filename = "./data/" + current_peak_str + "/" + direction + ".dat"

            plot_filename = "./data/" + current_peak_str + "/" + direction + ".png"

            un.plot_pygnuplot(k, intensity, plot_filename, plot_data_filename)

        # This section plots every point in the 3DFT as intensity vs. G^2.

        gsqr = list((np.array(soh_output[0])**2) +
                    (np.array(soh_output[1])**2) +
                    (np.array(soh_output[2])**2))

        intensity = soh_output[3]

        plot_data_filename = "./data/" + current_peak_str + "/I_vs_gsqr.dat"

        plot_filename = "./data/" + current_peak_str + "/I_vs_gsqr_" + current_peak_str + ".png"

        un.plot_pygnuplot(gsqr, intensity, plot_filename, plot_data_filename)

    return
示例#3
0
def run(pos, source_name, timestep):

    import units as un
    import logging as log

    log.debug("Brick %s started.\n", __name__)

    print "Calculating peak intensities..."

    peak_centre = []

    integrated_intensity = []

    for i in pos:

        peak_str = un.make_peak_str(i)

        soh_output_file_location = un.determine_accurate_soh_output_file_location(
            peak_str, source_name, timestep)

        soh_output = un.read_from_soh_output(soh_output_file_location)

        point_of_max_height = un.find_point_of_max_height(soh_output)

        peak_centre.append(point_of_max_height)

        dvol = un.calc_dvol(soh_output)

        current_integrated_intensity = un.calc_integrated_intensity(
            soh_output, dvol)

        integrated_intensity.append(current_integrated_intensity)

    log.debug("Brick %s finished.\n", __name__)

    return peak_centre, integrated_intensity
示例#4
0
def run(run_soh, lineout_directions, undershoot, overshoot, source, mass,
        a_lattice, lineout_k_steps, timestep, soh_command):

    import units as un
    import os

    print "Finding compression ratios..."

    compression_ratio = [1.0, 1.0, 1.0]

    direction_str = ["kx", "ky", "kz"]

    if os.path.exists("./data/lineouts/"):

        pass

    else:

        un.make_lineout_directory()

    for i, direction in enumerate(lineout_directions):

        k_start, k_stop = un.calc_lineout_k_start_stop(direction, undershoot,
                                                       overshoot)

        soh_location = un.determine_soh_compression_finding_input_file_location(
            direction_str[i])

        un.write_soh_input_1DFT(source, soh_location,
                                "lineout_" + direction_str[i], mass, a_lattice,
                                k_start, k_stop, lineout_k_steps)

    if run_soh is True:

        for i, direction in enumerate(lineout_directions):

            soh_location = un.determine_soh_compression_finding_input_file_location(
                direction_str[i])

            un.run_soh(soh_location, soh_command)

            un.move_soh_output_to_lineout_folder(direction_str[i], source,
                                                 timestep)

    for i, direction in enumerate(lineout_directions):

        soh_location = un.determine_soh_1DFT_output_file_location(
            direction_str[i], source, timestep)

        soh_output = un.read_from_soh_output(soh_location)

        un.plot_pygnuplot(
            soh_output[i], soh_output[3],
            os.getcwd() + "/data/lineouts/" + direction_str[i] +
            "_lineout.png",
            os.getcwd() + "/data/lineouts/" + direction_str[i] +
            "_lineout.dat")

        k_of_max_height = un.find_point_of_max_height(soh_output)

        compression_ratio[i] = un.calc_compression_ratio(
            k_of_max_height[i], lineout_directions[i][i])

    return compression_ratio
示例#5
0
def run(run_soh, raw_pos_est, pos_est, gsqr_est, compression_ratio, source_name, N_atoms, mass, a_lattice,
        k_steps_find_centre_1D, k_steps_find_centre_3D, timestep, soh_command, plot):

    import units as un
    import copy

    print "Fitting to peak centres..."

    centre_guess_3DFT = copy.deepcopy(pos_est)  # This list will contain the first guesses of peak centres gained from
    # the three 1DFTs performed below. It is used as a first guess of the centre for the final 3DFT.

    fitted_pos_est = copy.deepcopy(pos_est)  # This list contains the final peak centres, determined from the final
    # 3DFT. These are used as the input for peak centres when calculating the intensity of a full peak.

    compressed_pos_est, compressed_gsqr_est = un.apply_compression_ratio_to_pos_est(pos_est, gsqr_est, compression_ratio)

    offset = un.calc_k_offset_with_N_atoms(N_atoms)

    for i, pos in enumerate(compressed_pos_est):

        k_start = un.find_simple_k_start(pos, offset)

        k_stop = un.find_simple_k_stop(pos, offset)

        kx_start, kx_stop, ky_start, ky_stop, kz_start, kz_stop = un.calc_lineout_k_start_stop_along_xyz(k_start,
                                                                                                         k_stop,
                                                                                                         pos)
        peak_str = un.make_peak_str(raw_pos_est[i])

        input_file_location = un.determine_rough_soh_input_file_location(peak_str, "find_centre_kx_1DFT.in")

        un.write_soh_input_1DFT(source_name, input_file_location, "find_centre_kx_" + peak_str, mass, a_lattice, kx_start, kx_stop, k_steps_find_centre_1D)

        input_file_location = un.determine_rough_soh_input_file_location(peak_str, "find_centre_ky_1DFT.in")

        un.write_soh_input_1DFT(source_name, input_file_location, "find_centre_ky_" + peak_str, mass, a_lattice, ky_start, ky_stop, k_steps_find_centre_1D)

        input_file_location = un.determine_rough_soh_input_file_location(peak_str, "find_centre_kz_1DFT.in")

        un.write_soh_input_1DFT(source_name, input_file_location, "find_centre_kz_" + peak_str, mass, a_lattice, kz_start, kz_stop, k_steps_find_centre_1D)

    if run_soh is True:

        for i, pos in enumerate(compressed_pos_est):

            peak_str = un.make_peak_str(raw_pos_est[i])

            input_file_location = un.determine_rough_soh_input_file_location(peak_str, "find_centre_kx_1DFT.in")

            un.run_soh(input_file_location, soh_command)

            un.move_soh_rough_output_to_peak_folder(peak_str, "find_centre_kx_" + peak_str, source_name, timestep)

            input_file_location = un.determine_rough_soh_input_file_location(peak_str, "find_centre_ky_1DFT.in")

            un.run_soh(input_file_location, soh_command)

            un.move_soh_rough_output_to_peak_folder(peak_str, "find_centre_ky_" + peak_str, source_name, timestep)

            input_file_location = un.determine_rough_soh_input_file_location(peak_str, "find_centre_kz_1DFT.in")

            un.run_soh(input_file_location, soh_command)

            un.move_soh_rough_output_to_peak_folder(peak_str, "find_centre_kz_" + peak_str, source_name, timestep)

    for i, pos in enumerate(compressed_pos_est):

        peak_str = un.make_peak_str(raw_pos_est[i])

        appended_string = "find_centre_kx_" + peak_str

        soh_output_file_location = un.determine_rough_soh_output_file_location(peak_str, source_name, timestep,
                                                                               appended_string)

        soh_output = un.read_from_soh_output(soh_output_file_location)

        k_max = un.find_point_of_max_height(soh_output)

        kx_centre = k_max[0]

        if plot is True:

            un.plot_pygnuplot(soh_output[0], soh_output[3], "./data/" + peak_str + "/find_centre_kx.png",
                              "./data/" + peak_str + "/find_centre_kx.dat")

        appended_string = "find_centre_ky_" + peak_str

        soh_output_file_location = un.determine_rough_soh_output_file_location(peak_str, source_name, timestep,
                                                                               appended_string)

        soh_output = un.read_from_soh_output(soh_output_file_location)

        k_max = un.find_point_of_max_height(soh_output)

        ky_centre = k_max[1]

        if plot is True:

            un.plot_pygnuplot(soh_output[1], soh_output[3], "./data/" + peak_str + "/find_centre_ky.png",
                              "./data/" + peak_str + "/find_centre_ky.dat")


        appended_string = "find_centre_kz_" + peak_str

        soh_output_file_location = un.determine_rough_soh_output_file_location(peak_str, source_name, timestep,
                                                                               appended_string)

        soh_output = un.read_from_soh_output(soh_output_file_location)

        k_max = un.find_point_of_max_height(soh_output)

        kz_centre = k_max[2]


        if plot is True:

            un.plot_pygnuplot(soh_output[2], soh_output[3], "./data/" + peak_str + "/find_centre_kz.png",
                              "./data/" + peak_str + "/find_centre_kz.dat")

        centre_guess_3DFT[i] = [kx_centre, ky_centre, kz_centre]

    #  Now that the initial guesses have been determined using the 1DFTs above, a 3DFT is performed to get as close as
    #  possible to the centre of the peak.

    dk = un.calc_dk_from_offset(offset, k_steps_find_centre_1D, k_steps_find_centre_1D, k_steps_find_centre_1D)

    for i, pos in enumerate(centre_guess_3DFT):

        k_start = un.find_simple_k_start(pos, dk)

        k_stop = un.find_simple_k_stop(pos, dk)

        peak_str = un.make_peak_str(raw_pos_est[i])

        input_file_location = un.determine_rough_soh_input_file_location(peak_str, "find_centre_3DFT.in")

        un.write_soh_input_3DFT(source_name, input_file_location, "find_centre_3DFT_" + peak_str, mass, a_lattice,
                                k_steps_find_centre_3D, k_start, k_stop)

    if run_soh is True:

        for i, pos in enumerate(centre_guess_3DFT):

            peak_str = un.make_peak_str(raw_pos_est[i])

            input_file_location = un.determine_rough_soh_input_file_location(peak_str, "find_centre_3DFT.in")

            un.run_soh(input_file_location, soh_command)

            un.move_soh_rough_output_to_peak_folder(peak_str, "find_centre_3DFT_" + peak_str, source_name, timestep)

    for i, pos in enumerate(centre_guess_3DFT):

        peak_str = un.make_peak_str(raw_pos_est[i])

        appended_string = "find_centre_3DFT_" + peak_str

        soh_output_file_location = un.determine_rough_soh_output_file_location(peak_str, source_name, timestep,
                                                                               appended_string)

        soh_output = un.read_from_soh_output(soh_output_file_location)

        k_max = un.find_point_of_max_height(soh_output)

        fitted_pos_est[i] = k_max

    return fitted_pos_est
示例#6
0
def run(run_soh, current_pos_est, raw_pos_est, source_name, timestep,
        undershoot, overshoot, source, mass, a_lattice, k_steps, num_cores):

    import units as un
    import copy
    import os

    print "Fitting to peak edges..."

    direction_str = ["kx", "ky", "kz"]

    k_start_accurate = copy.deepcopy(current_pos_est)
    k_stop_accurate = copy.deepcopy(current_pos_est)

    for i, pos in enumerate(raw_pos_est):

        peak_str = un.make_peak_str(pos)

        for j, direction in enumerate(direction_str):

            k_start, k_stop = un.calc_peak_edge_k_start_stop(
                current_pos_est[i], undershoot[j], overshoot[j])

            soh_location = un.determine_soh_edge_finding_input_file_location(
                direction, peak_str)

            un.write_soh_input_1DFT(source_name, soh_location,
                                    peak_str + "_find_edges_" + direction,
                                    mass, a_lattice, k_start, k_stop, k_steps)

    if run_soh is True:

        for i, pos in enumerate(raw_pos_est):

            peak_str = un.make_peak_str(pos)

            for j, direction in enumerate(direction_str):

                soh_location = un.determine_soh_edge_finding_input_file_location(
                    direction, peak_str)

                un.run_soh(soh_location, num_cores)

                un.move_soh_rough_output_to_peak_folder(
                    peak_str, peak_str + "_find_edges_" + direction,
                    source_name, timestep)

    for i, pos in enumerate(raw_pos_est):

        peak_str = un.make_peak_str(pos)

        for j, direction in enumerate(direction_str):

            soh_location = un.determine_soh_edge_finding_output_file_location(
                peak_str, direction, source, timestep)

            soh_output = un.read_from_soh_output(soh_location)

            un.plot_pygnuplot(
                soh_output[j], soh_output[3],
                os.getcwd() + "/data/" + peak_str + "/" + direction +
                "_lineout.png",
                os.getcwd() + "/data/" + peak_str + "/" + direction +
                "_lineout.dat")

            k_start_accurate[i][j], k_stop_accurate[i][
                j] = un.find_k_start_stop_for_peak_from_first_minima(
                    soh_output[j], soh_output[3])

    return k_start_accurate, k_stop_accurate