示例#1
0
def run(pos_est, source_name, timestep, mass, a_lattice, N_atoms, k_steps,
        run_soh, num_cores):

    import units as un
    import logging as log

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

    print "Performing 3DFT of each peak..."

    offset = un.calc_k_offset_with_N_atoms(N_atoms)

    for i in pos_est:
        k_start = un.find_simple_k_start(i, offset)
        k_stop = un.find_simple_k_stop(i, offset)
        peak_str = un.make_peak_str(i)
        input_file_location = un.determine_accurate_soh_input_file_location(
            peak_str)
        un.write_soh_input_3DFT(source_name, input_file_location, peak_str,
                                mass, a_lattice, k_steps, k_start, k_stop)

    if run_soh is True:

        for i in pos_est:
            peak_str = un.make_peak_str(i)
            input_file_location = un.determine_accurate_soh_input_file_location(
                peak_str)
            un.run_soh(input_file_location, num_cores)
            un.move_soh_accurate_output_to_peak_folder(peak_str, source_name,
                                                       timestep)

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

    return
示例#2
0
def run(pos_est, source_location, mass, a_lattice, N_atoms, k_steps, run_soh):

    import units as un
    import logging as log

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

    offset = un.calc_k_offset_with_N_atoms(N_atoms)

    for i in pos_est:
        peak_str = un.make_peak_str(i)
        input_file_location = un.determine_accurate_soh_input_file_location(
            peak_str)
        k_start = un.find_simple_k_start(i, offset)
        k_stop = un.find_simple_k_stop(i, offset)
        k_start = un.convert_to_per_angstrom(k_start, a_lattice)
        k_stop = un.convert_to_per_angstrom(k_stop, a_lattice)
        un.write_soh_input_3DFT(source_location, input_file_location, peak_str,
                                mass, a_lattice, k_steps, k_start, k_stop)

    if run_soh == True:

        for i in pos_est:
            input_file_location = un.determine_accurate_soh_input_file_location(
                peak_str)
            un.run_soh(input_file_location)

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

    return
示例#3
0
def run(current_pos_est, pos_est, source_name, timestep, mass, a_lattice,
        k_steps, run_soh, k_start, k_stop, soh_command):

    import units as un
    import logging as log

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

    print "Performing accurate 3DFT of each peak..."

    for i, pos in enumerate(current_pos_est):

        peak_str = un.make_peak_str(pos_est[i])

        input_file_location = un.determine_accurate_soh_input_file_location(
            peak_str)

        un.write_soh_input_3DFT(source_name, input_file_location, peak_str,
                                mass, a_lattice, k_steps, k_start[i],
                                k_stop[i])

    if run_soh is True:

        for i in pos_est:

            peak_str = un.make_peak_str(i)

            input_file_location = un.determine_accurate_soh_input_file_location(
                peak_str)

            un.run_soh(input_file_location, soh_command)

            un.move_soh_accurate_output_to_peak_folder(peak_str, source_name,
                                                       timestep)

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

    return
示例#4
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
示例#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