Exemplo n.º 1
0
# v9_75 = Run(vacuum_9_path + "2018_11_09__14_22_32.txt")
# v9_67 = Run(vacuum_9_path + "2018_11_09__14_33_41.txt")
# v9_60 = Run(vacuum_9_path + "2018_11_09__14_40_54.txt")
# v9_52 = Run(vacuum_9_path + "2018_11_09__14_47_23.txt")
# v9_45 = Run(vacuum_9_path + "2018_11_09__14_53_56.txt")
# v9_30 = Run(vacuum_9_path + "2018_11_09__15_00_15.txt")
# vacuum_9_runs = [v9_30, v9_45, v9_52, v9_60, v9_67, v9_75]

# all_1_runs = sample_1_runs + vacuum_1_runs
# all_3_runs = sample_3_runs + vacuum_3_runs
# all_9_runs = sample_9_runs + vacuum_9_runs

fit_params_old = fit_parameters(
    get_independent_variables_and_relative_intensities(v1_45),
    p0=[0.7, 1.2, .1],
    average_angle=0,
    precision=-1,
    use_errs=True,
    use_spike=False)
chi_squared_old = chi_squared(v1_45.independent_variables_array,
                              v1_45.relative_intensities,
                              v1_45.relative_std,
                              fit_params_old,
                              average_angle=0,
                              precision=-1)

fit_params_new = fit_parameters_grid(
    get_independent_variables_and_relative_intensities(v1_45),
    #rho_start=0.15, rho_end=0.25, rho_num=10, n_start=1., n_end=1.2, n_num=10, gamma_start=0.05, gamma_end=0.2, gamma_num=10, plot=True, show=False) # fine
    rho_start=0.55,
    rho_end=0.85,
    run_data = get_independent_variables_and_relative_intensities(runs[ii])
    # plot_runs(runs[ii], title=sample_name+" in 0.2 barg LXe, {0:g} deg, 178 nm".format(angles[ii]), log=True, include_legend=True, errorbars=True, legend_loc=0)
    if angles[ii] < 40:
        shift_max = 1.04
        spec_max = 1.691
    else:
        shift_max = 1.09
        spec_max = 2.6
    # Parameters are albedo, specular normalization, gamma, angle shift (last is overall scaling, nu; not needed)
    print(spec_max)
    fit_params = fit_parameters(
        run_data,
        p0=[0.1, np.minimum(1.7, spec_max), .1, 0.9, 1.0],
        average_angle=-1,
        precision=-1,
        sigma_theta_i=-1,
        use_errs=True,
        use_spike=True,
        use_nu=False,
        bounds=([0.01, 1.69 + 1e-4, 0.03, 0.84,
                 0.3], [1.6, spec_max, 0.6, shift_max,
                        1.7]))  # theta_r shift range is +5 to -10 deg
    #fit_params=fit_params_simple[ii]
    # fit_params=[.051,2.47,.076,1]

    print("Fit parameters (rho_L, n, gamma): " + str(fit_params))

    # Plot BRIDF model from fits
    n_LXe_178 = 1.69
    sigma_theta_i = -1
    precision = -1
    average_angle = -1
# plt.text(0.88,0.84,r"$75^{\circ}$",transform=plt.gca().transAxes,fontsize=13) # Positions for hi_p
# plt.text(0.85,0.72,r"$67^{\circ}$",transform=plt.gca().transAxes,fontsize=13)
# plt.text(0.78,0.52,r"$60^{\circ}$",transform=plt.gca().transAxes,fontsize=13)
# plt.text(0.78,0.3,r"$52^{\circ}$",transform=plt.gca().transAxes,fontsize=13)
# plt.text(0.67,0.16,r"$45^{\circ}$",transform=plt.gca().transAxes,fontsize=13)
# plt.text(0.1,0.4,r"$30^{\circ}$",transform=plt.gca().transAxes,fontsize=13)
t0=time.time()

# Fit data
# tmp = np.array([[1,2],[3,4]])
# tmp2 = list(tmp)
# print(tmp,tmp2)
# tmp1=np.arange(10)
# tmp2=np.arange(4,14)
# print(tmp1,tmp2,np.linspace(tmp1,tmp2,1))
fit_params = fit_parameters(get_independent_variables_and_relative_intensities(runs),p0=[0.99,1.54,.15],average_angle=4, precision=.25, sigma_theta_i=2., use_errs=True,use_spike=False,bounds=([0.5,1.4,0.04],[1.2,1.8,0.3]))#[0.5,1.4,0.04,5.0],[1.2,1.8,0.3,50.]#[0.5,1.4,0.1],[1.0,1.8,0.3]#[0.01,1.01,0.05],[2.0,3.0,0.5]
#fit_params_ang = fit_parameters_and_angle(get_independent_variables_and_relative_intensities(runs),average_angle=4.)
#fit_ang = fit_params_ang[0]
#fit_params = fit_params_ang[1:]
#fit_params= [0.68114103391512837, 1.6259581862678401, 0.11282346636450034, 8.5642437795248174]#[0.947, 1.555, 0.091]#[0.784,1.568,0.144]#[0.86,1.50,0.07]#[0.72,1.45,0.2]#[0.800,1.581,0.157]#
# Fitter params for s9 in vacuum after LXe, 2.15 solid angle
fit_params_vacuum=[0.68114103391512837, 1.6259581862678401, 0.11282346636450034, 8.5642437795248174]
# Fitter parameters for s9 in LXe, 2.15 solid angle factor, Lorentz model
fit_params_lowp=[0.9466040398353657, 1.5542353537306548, 0.09079476300181971]
fit_params_hip=[0.9871481402574648, 1.5715034469520426, 0.09586940402324681]
#fit_params=fit_params_lowp
# # Fitted parameters for s9 2.44 solid angle factor
# fit_params_lowp=[0.784,1.568,0.144]
# fit_params_lowp2=[0.892,1.563,0.176]
# fit_params_hip=[0.800,1.581,0.157]
# fit_params_hip2=[0.868,1.558,0.225]
from TSTR_fit_new import fit_parameters, BRIDF_plotter, reflectance_diffuse, reflectance_specular

m18path = "vuv_height_comparison_and_first_data/M18 turn/center of sample/"
m1830 = Run(m18path + "2018_08_30__15_16_18.txt")
m1845 = Run(m18path + "2018_08_30__15_22_02.txt")
m1860 = Run(m18path + "2018_08_30__15_29_09.txt")
m1875 = Run(m18path + "2018_08_30__15_35_27.txt")

runs = [m1830, m1845, m1860, m1875]

plot_runs(runs,
          title="M18 turn, 175nm",
          log=True,
          labels=["30 degrees", "45 degrees", "60 degrees", "75 degrees"])

fit_params = fit_parameters(
    get_independent_variables_and_relative_intensities(runs))
plot_TSTR_fit(30., 1., fit_params, label="fitted", color="k")
plot_TSTR_fit(45., 1., fit_params, color="k")
plot_TSTR_fit(60., 1., fit_params, color="k")
plot_TSTR_fit(75., 1., fit_params, color="k")

plt.figure()

x = [30, 45, 60, 75]

y_diffuse = [reflectance_diffuse(theta, 1., 0.5, fit_params) for theta in x]
y_specular = [reflectance_specular(theta, 1., 0.5, fit_params) for theta in x]
y_total = [y_diffuse[i] + y_specular[i] for i in range(len(y_specular))]

plt.plot(x, y_diffuse, label="diffuse")
plt.plot(x, y_specular, label="specular")
Exemplo n.º 5
0
v9_60 = Run(vacuum_9_path + "2018_11_09__14_40_54.txt")
v9_52 = Run(vacuum_9_path + "2018_11_09__14_47_23.txt")
v9_45 = Run(vacuum_9_path + "2018_11_09__14_53_56.txt")
v9_30 = Run(vacuum_9_path + "2018_11_09__15_00_15.txt")
vacuum_9_runs = [v9_30, v9_45, v9_52, v9_60, v9_67, v9_75]

all_1_runs = sample_1_runs + vacuum_1_runs
all_3_runs = sample_3_runs + vacuum_3_runs
all_9_runs = sample_9_runs + vacuum_9_runs

# vacuum individual fits

fit_params = fit_parameters(
    get_independent_variables_and_relative_intensities(v1_30),
    p0=[0.24, 1.2, .1, 5.0],
    average_angle=4.,
    precision=0.25,
    use_errs=True,
    use_spike=True)
plot_runs(v1_30,
          title="Sample 1 (LUX), 178nm, Vacuum, 30 degrees",
          label="data",
          log=True)
plot_TSTR_fit(30.,
              1.,
              fit_params,
              label="fitted",
              color="k",
              average_angle=4.,
              precision=0.25)
print("done with 30")
Exemplo n.º 6
0
precision = 0.25
average_angle = 4

chi_30_list = []
chi_45_list = []
chi_52_list = []
chi_60_list = []
chi_67_list = []
chi_75_list = []

independent_variables_array_intensity_array = get_independent_variables_and_relative_intensities(
    runs)
fit_params_all = fit_parameters(independent_variables_array_intensity_array,
                                p0=[0.99, 1.54, .15],
                                average_angle=average_angle,
                                precision=precision,
                                sigma_theta_i=sigma_theta_i,
                                use_errs=True,
                                use_spike=False,
                                bounds=([0.5, 1.4, 0.04], [1.2, 2.0, 0.3]))
"""
independent_variables_array_intensity_array = get_independent_variables_and_relative_intensities(s9_30)
fit_params_30 = fit_parameters(independent_variables_array_intensity_array,p0=[0.99,1.54,.15],
	average_angle=average_angle, precision=precision, sigma_theta_i=sigma_theta_i, use_errs=True,use_spike=False,bounds=([0.5,1.4,0.04],[10.,2.0,0.5]))
chi_30_list.append(chi_squared(independent_variables_array_intensity_array[0], independent_variables_array_intensity_array[1], 
	independent_variables_array_intensity_array[2], fit_params_30, average_angle=average_angle, precision=precision, sigma_theta_i=sigma_theta_i))
print("done fitting 30...")
independent_variables_array_intensity_array = get_independent_variables_and_relative_intensities(s9_45)
fit_params_45 = fit_parameters(independent_variables_array_intensity_array,p0=[0.99,1.54,.15],
	average_angle=average_angle, precision=precision, sigma_theta_i=sigma_theta_i, use_errs=True,use_spike=False,bounds=([0.5,1.4,0.04],[10.,2.0,0.5]))
chi_45_list.append(chi_squared(independent_variables_array_intensity_array[0], independent_variables_array_intensity_array[1], 
	independent_variables_array_intensity_array[2], fit_params_45, average_angle=average_angle, precision=precision, sigma_theta_i=sigma_theta_i))
#spec30 = Run(specpath + "2018_09_04__11_31_30.txt")
#spec35 = Run(specpath + "2018_10_02__16_55_53.txt")
#spec45 = Run(specpath + "2018_09_04__11_39_44.txt")
#spec50 = Run(specpath + "2018_10_02__17_01_27.txt")
#spec60 = Run(specpath + "2018_09_04__11_45_54.txt")

runs = [m1830,m1845,m1860,m1875]#[m18pol30, m18pol45, m18pol60, m18pol75]#[m1875]#
labels=["30 degrees","45 degrees","60 degrees","75 degrees"]#["30 degrees", "45 degrees", "60 degrees", "75 degrees"]#["75 degrees"]#

# Plot BRIDF data
sample_name="M18 turn"
plot_runs(runs, title=sample_name+", 175 nm", log=True, labels=labels, errorbars=True,legend_loc=6)
t0=time.time()

# Fit data
fit_params = fit_parameters(get_independent_variables_and_relative_intensities(runs),p0=[0.75,1.57,0.2],average_angle=4., precision=-1,use_errs=True,use_spike=False)
#fit_params_ang = fit_parameters_and_angle(get_independent_variables_and_relative_intensities(runs),average_angle=4.)
#fit_ang = fit_params_ang[0]
#fit_params = fit_params_ang[1:]
print("Fit parameters (rho_L, n, gamma): "+str(fit_params))
#print("Fit angle: "+str(fit_ang))
t1=time.time()
print("Fitting time: {0}".format(t1-t0))

# Plot BRIDF model from fits
#plot_TSTR_fit(8., 1., fit_params, label="fitted", color="k", average_angle=4., precision=-1)
plot_TSTR_fit(33., 1., fit_params, color="k", average_angle=4., precision=-1)
plot_TSTR_fit(45., 1., fit_params, color="k", average_angle=4., precision=-1)
plot_TSTR_fit(61., 1., fit_params, color="k", average_angle=4., precision=-1)
plot_TSTR_fit(76, 1., fit_params, color="k", average_angle=4., precision=-1)
#plt.text(0.1,0.1,r"Fit: $\rho_L$={0:.3f}, n={1:.2f}, $\gamma$={2:.3f}".format(*fit_params),transform=plt.gca().transAxes,fontsize=13)