Esempio n. 1
0
def single_fitting(are_four_col):
    """
    Gets parameters from window, executes fitting for the chosen file (four or two columns depending on argument's value)
    displays fitting curves and data points from file
    :param are_four_col:
    :return:
    """
    # LOADING DATA AND AGGREGATION
    save_btn.place_forget()
    data = None
    if are_four_col:
        data = load_files.load_mapping_file(file_name.get())
    else:
        data = load_files.load_two_column_file(file_name.get())
    omega = data[2]
    intensity = data[3]

    is_bg_active = active_bg.get()
    result = ns.find_grain_diameter(
        omega,
        intensity,
        float(min_size.get()),
        float(max_size.get()) + float(size_step.get()),
        float(size_step.get()),
        True,
        read_params(),
        is_bg_active,
    )
    global f
    f.clf()
    f = result[4]
    f.suptitle(file_name.get().split("/")[-1])
    global canvas
    canvas = FigureCanvasTkAgg(f, master=root)
    canvas.get_tk_widget().place(x=0, y=30)
    canvas.get_tk_widget().configure(border=0, width=650, height=450)

    map_rbtn_one.place_forget()
    map_rbtn_two.place_forget()
    map_rbtn_three.place_forget()
    map_rbtn_four.place_forget()

    map_param_rbtn_one.place_forget()
    map_param_rbtn_two.place_forget()
    map_param_rbtn_three.place_forget()
    map_param_rbtn_four.place_forget()
    save_btn.place(x=545, y=1)
Esempio n. 2
0
def single_fitting(are_four_col):
    """
    Gets parameters from window, executes fitting for the chosen file (four or two columns depending on argument's value)
    displays fitting curves and data points from file
    :param are_four_col:
    :return:
    """
    # LOADING DATA AND AGGREGATION
    save_btn.place_forget()
    data = None
    if are_four_col:
        data = load_files.load_mapping_file(file_name.get())
    else:
        data = load_files.load_two_column_file(file_name.get())
    omega = data[2]
    intensity = data[3]

    is_bg_active = active_bg.get()
    result = ns.find_grain_diameter(
        omega, intensity, float(min_size.get()),
        float(max_size.get()) + float(size_step.get()), float(size_step.get()),
        True, read_params(), is_bg_active)
    global f
    f.clf()
    f = result[4]
    f.suptitle(file_name.get().split('/')[-1])
    global canvas
    canvas = FigureCanvasTkAgg(f, master=root)
    canvas.get_tk_widget().place(x=0, y=30)
    canvas.get_tk_widget().configure(border=0, width=650, height=450)

    map_rbtn_one.place_forget()
    map_rbtn_two.place_forget()
    map_rbtn_three.place_forget()
    map_rbtn_four.place_forget()

    map_param_rbtn_one.place_forget()
    map_param_rbtn_two.place_forget()
    map_param_rbtn_three.place_forget()
    map_param_rbtn_four.place_forget()
    save_btn.place(x=545, y=1)
Esempio n. 3
0
def agg_data(data, min_size, max_size, size_step, params, sample_type):
    X = data[0]
    Y = data[1]
    raman_shift = data[2]
    intensity = data[3]

    current_Y = Y[0]
    current_X = X[0]
    result_diameter = []
    column_diameter = []
    result_sigma = []
    column_sigma = []
    result_intensity = []
    column_intensity = []
    result_omega_0 = []
    column_omega_0 = []

    for ii in range(0, len(X)):

        if (Y[ii] != current_Y):

            choose_condition = (Y == current_Y)*(X == current_X)
            func_result = nanograin_size.find_grain_diameter(raman_shift[choose_condition], intensity[choose_condition],
                                                             min_size, max_size, size_step, False, params, True)
            column_diameter.append(func_result[0])  # function returns (diameter, sigma, omega_0, peak_high)
            column_sigma.append(func_result[1])
            column_omega_0.append(func_result[2])
            column_intensity.append(func_result[3])
            current_Y = Y[ii]
        if (X[ii] != current_X):
            print("y")
            print(current_Y)
            print("x")
            print(current_X)
            progress = round(ii/len(X) * 100,1)
            msg = """#####################################################################################"""+\
                    "   PROGRESS:  " + str(progress) + \
                    """    ###################################################################################"""
            print(msg)

            result_diameter.append(column_diameter)
            result_sigma.append(column_sigma)
            result_omega_0.append(column_omega_0)
            result_intensity.append(column_intensity)
            column_diameter = []
            column_sigma = []
            column_omega_0 = []
            column_intensity = []
            current_X = X[ii]
        if (ii == (len(X) - 1)):
            choose_condition = (Y == current_Y)*(X == current_X)
            func_result = nanograin_size.find_grain_diameter(raman_shift[choose_condition], intensity[choose_condition],
                                                             min_size, max_size, size_step, False, params,
                                                             True)
            column_diameter.append(func_result[0])  # function returns (diameter, sigma, omega_0, peak_high)
            column_sigma.append(func_result[1])
            column_omega_0.append(func_result[2])
            column_intensity.append(func_result[3])
            result_diameter.append(column_diameter)
            result_sigma.append(column_sigma)
            result_omega_0.append(column_omega_0)
            result_intensity.append(column_intensity)
            print("y")
            print(current_Y)
            print("x")
            print(current_X)


    #return result_diameter, result_sigma, result_omega_0, result_intensity
    return  result_diameter, result_sigma, result_omega_0, result_intensity
Esempio n. 4
0
def agg_data(data, min_size, max_size, size_step, params, sample_type):
    X = data[0]
    Y = data[1]
    raman_shift = data[2]
    intensity = data[3]

    current_Y = Y[0]
    current_X = X[0]
    result_diameter = []
    column_diameter = []
    result_sigma = []
    column_sigma = []
    result_intensity = []
    column_intensity = []
    result_omega_0 = []
    column_omega_0 = []

    for ii in range(0, len(X)):

        if (Y[ii] != current_Y):

            choose_condition = (Y == current_Y) * (X == current_X)
            func_result = nanograin_size.find_grain_diameter(
                raman_shift[choose_condition], intensity[choose_condition],
                min_size, max_size, size_step, False, params, True)
            column_diameter.append(
                func_result[0]
            )  # function returns (diameter, sigma, omega_0, peak_high)
            column_sigma.append(func_result[1])
            column_omega_0.append(func_result[2])
            column_intensity.append(func_result[3])
            current_Y = Y[ii]
        if (X[ii] != current_X):
            print("y")
            print(current_Y)
            print("x")
            print(current_X)
            progress = round(ii / len(X) * 100, 1)
            msg = """#####################################################################################"""+\
                    "   PROGRESS:  " + str(progress) + \
                    """    ###################################################################################"""
            print(msg)

            result_diameter.append(column_diameter)
            result_sigma.append(column_sigma)
            result_omega_0.append(column_omega_0)
            result_intensity.append(column_intensity)
            column_diameter = []
            column_sigma = []
            column_omega_0 = []
            column_intensity = []
            current_X = X[ii]
        if (ii == (len(X) - 1)):
            choose_condition = (Y == current_Y) * (X == current_X)
            func_result = nanograin_size.find_grain_diameter(
                raman_shift[choose_condition], intensity[choose_condition],
                min_size, max_size, size_step, False, params, True)
            column_diameter.append(
                func_result[0]
            )  # function returns (diameter, sigma, omega_0, peak_high)
            column_sigma.append(func_result[1])
            column_omega_0.append(func_result[2])
            column_intensity.append(func_result[3])
            result_diameter.append(column_diameter)
            result_sigma.append(column_sigma)
            result_omega_0.append(column_omega_0)
            result_intensity.append(column_intensity)
            print("y")
            print(current_Y)
            print("x")
            print(current_X)

    #return result_diameter, result_sigma, result_omega_0, result_intensity
    return result_diameter, result_sigma, result_omega_0, result_intensity