Ejemplo n.º 1
0
    def calc_data(self):
        x = numpy.array([self.data['list_t']])
        y = numpy.array([self.data['list_v_1']])
        xx = numpy.linspace(0, 10 * self.data['list_t[1]'], 100)
        matplotlib.pyplot.scatter(x, y)
        f = scipy.interpolate.interp1d(x, y, kind="cubic")
        ynew = f(xx)
        matplotlib.pyplot.plot(xx, ynew, "g")
        matplotlib.pyplot.show()
        ynew1 = f(self.data['list_q[1]'] + 0.001)
        ynew2 = f(self.data['list_q[1]'] - 0.001)
        v = math.fabs(ynew1 - ynew2) / 0.002
        self.data['v'] = v

        db = Method.average(self.data['list_db'])
        self.data['db'] = db
        dp = Method.average(self.data['list_dp'])
        self.data['dp'] = dp
        hb = Method.average(self.data['list_hb'])
        self.data['hb'] = hb
        hp = Method.average(self.data['list_hp'])
        self.data['hp'] = hp
        k = self.data['pl_m'] * 3 * 10**8 * self.data['v'] * (
            4 * self.data['hp'] + self.data['dp']
        ) / (self.data['dp'] + 2 * self.data['hp']) * self.data['hb'] / (
            self.data['list_q[0]'] -
            self.data['list_q[1]']) * 2 / (math.pi * self.data['db']**2)
        self.data['k'] = k
Ejemplo n.º 2
0
 def calc_uncertainty_d(self):
     # 计算光程差d的a,b及总不确定度
     Ua_2xita1 = Method.a_uncertainty(
         self.data['list_d_2xita1'])  # 这里容易写错,一定要用原始数据的数组
     Ub_2xita1 = 1.679e-4
     U_xita1 = sqrt(Ub_2xita1**2 + Ua_2xita1**2) / 2
     Ud1 = abs(self.data['d1'] * U_xita1 /
               tan(self.data['d_xita1_average']))
     Ub_2xita2 = 1.679e-4
     Ud2 = abs(self.data['d2'] * Ub_2xita2 /
               (2 * tan(3.14 * self.data['d_2xita2'] / 360)))
     self.uncertainty.update({
         "Ua_2xita1": Ua_2xita1,
         "Ub_2xita1": Ub_2xita1,
         "Ua_xita1": Ua_2xita1 / 2,
         "Ub_xita1": Ub_2xita1 / 2,
         "U_xita1": U_xita1,
         "Ud1": Ud1,
         "Ub_2xita2": Ub_2xita2,
         "Ub_xita2": Ub_2xita2 / 2,
         "Ud2": Ud2
     })
     d1 = self.data['d1']
     d2 = self.data['d2']
     d_av = (d1 / (Ud1**2) + d2 / (Ud2**2)) / (1 / (Ud1**2) + 1 / (Ud2**2))
     Ud_av = sqrt((Ud1**2) * (Ud2**2) / (Ud1**2) + (Ud2**2))
     self.uncertainty.update({"d_av": d_av, "Ud_av": Ud_av})
     self.data['final1'] = Method.final_expression(d_av, Ud_av)
Ejemplo n.º 3
0
 def calc_uncertainty(self):
     # 计算一元线性回归的不确定度
     num_u_b = self.data['num_b'] * sqrt((1 / (self.data['num_r'] ** 2) - 1) / (8 - 2))
     self.data['num_u_b'] = num_u_b
     # 计算直径D的不确定度
     num_ua_D = Method.a_uncertainty(self.data['list_D'])
     num_ub_D = 0.03 / sqrt(3) /1000
     num_u_D = sqrt(num_ua_D ** 2 + num_ub_D ** 2)
     self.data.update({"num_ua_D":num_ua_D, "num_ub_D":num_ub_D, "num_u_D":num_u_D})
     # 电阻率不确定度的合成
     num_u_rho_rho = sqrt((num_u_D / self.data['num_D']) ** 2 + (num_u_b / self.data['num_b']) ** 2)
     num_rho = self.data['num_rho']
     num_u_rho = num_u_rho_rho * num_rho
     self.data.update({"num_u_rho_rho": num_u_rho_rho, "num_u_rho": num_u_rho})
     # 输出带不确定度的最终结果: 不确定度保留一位有效数字, 物理量结果与不确定度首位有效数字对齐
     self.data['final_1'] = Method.final_expression(self.data['num_rho'], self.data['num_u_rho'])
     # 单电桥测电阻
     # 灵敏度分析
     num_S = self.data['num_delta_n'] / self.data['num_delta_R_3']
     num_delta_lmd = 0.2 / num_S
     num_u_lmd = num_delta_lmd / sqrt(3)
     self.data.update({"num_S": num_S, "num_delta_lmd":num_delta_lmd, "num_u_lmd":num_u_lmd})
     # 仪器误差
     num_delta_yi = InstrumentError.dc_bridge(self.data['num_a_pct'], self.data['num_R_3'],self.data['num_R_0'])
     num_u_yi = num_delta_yi / sqrt(3)
     num_u_R_x = sqrt(num_u_yi ** 2 + num_u_lmd ** 2)
     self.data.update({"num_delta_yi": num_delta_yi, "num_u_yi": num_u_yi, "num_u_R_x": num_u_R_x})
     # 输出带不确定度的最终结果: 不确定度保留一位有效数字, 物理量结果与不确定度首位有效数字对齐
     self.data['final_2'] = Method.final_expression(self.data['num_R_3'], self.data['num_u_R_x'])
     print(self.data['final_2'])
Ejemplo n.º 4
0
 def calc_uncertainty(self):
     # 计算不确定度
     ub_d = 0.001 / sqrt(3)
     ua_d0 = Method.a_uncertainty(self.data['ld'])  # 这里容易写错,一定要用原始数据的数组
     u_d0 = sqrt(ua_d0**2 + ub_d**2)
     ua_dy = Method.a_uncertainty(self.data['yd'])
     u_dy = sqrt(ua_dy**2 + ub_d**2)
     u_lambda_y = self.data['lambda_y'] * sqrt(
         (u_dy / self.data['yd_avg'])**2 + (u_d0 / self.data['ld_avg'])**2)
     self.data.update({
         "ub_d": ub_d,
         "ua_d0": ua_d0,
         "u_d0": u_d0,
         "ua_dy": ua_dy,
         "u_dy": u_dy,
         "u_lambda_y": u_lambda_y
     })
     ua_dg = Method.a_uncertainty(self.data['gd'])
     u_dg = sqrt(ua_dg**2 + ub_d**2)
     u_lambda_g = self.data['lambda_g'] * sqrt(
         (u_dg / self.data['gd_avg'])**2 + (u_d0 / self.data['ld_avg'])**2)
     ua_dp = Method.a_uncertainty(self.data['pd'])
     u_dp = sqrt(ua_dp**2 + ub_d**2)
     u_lambda_p = self.data['lambda_p'] * sqrt(
         (u_dp / self.data['pd_avg'])**2 + (u_d0 / self.data['ld_avg'])**2)
     self.data.update({
         "ua_dg": ua_dg,
         "u_dg": u_dg,
         "u_lambda_g": u_lambda_g,
         "ua_dp": ua_dp,
         "u_dp": u_dp,
         "u_lambda_p": u_lambda_p
     })
Ejemplo n.º 5
0
 def calc_uncertainty_detail(data_list, result_list):
     sunc = Simplified()
     uncertain_data = {}
     ua_10delta_x = Method.a_uncertainty(result_list['diff_10delta_x'])
     ub_10delta_x = sunc.micrometer / sqrt(3)
     u_10delta_x = sqrt(ua_10delta_x**2 + ub_10delta_x**2)
     u_delta_x = u_10delta_x / 10
     ub_S = sqrt((sunc.steel_ruler / 10 / sqrt(3))**2 +
                 (data_list['delta_s'] / sqrt(3))**2)
     ub_b = sqrt((sunc.micrometer / sqrt(3))**2 +
                 (data_list['delta_b_b'] * result_list['b'] / sqrt(3))**2)
     ub_b1 = sqrt((sunc.micrometer / sqrt(3))**2 +
                  (data_list['delta_b_b'] * result_list['b1'] / sqrt(3))**2)
     u_lbd_lbd = sqrt((u_delta_x / result_list['delta_x'])**2 +
                      (ub_b / result_list['b'] / 2)**2 +
                      (ub_b1 / result_list['b1'] / 2)**2 + 2 *
                      ((ub_S / (result_list['S'] + result_list['S1']))**2))
     u_lbd = u_lbd_lbd * result_list['result_lambda']
     final_lbd = Method.final_expression(result_list['result_lambda'],
                                         u_lbd)
     uncertain_data['ua_10delta_x'] = ua_10delta_x
     uncertain_data['ub_10delta_x'] = ub_10delta_x
     uncertain_data['u_10delta_x'] = u_10delta_x
     uncertain_data['u_delta_x'] = u_delta_x
     uncertain_data['u_S'] = ub_S
     uncertain_data['u_b'] = ub_b
     uncertain_data['u_b1'] = ub_b1
     uncertain_data['u_lbd_lbd'] = u_lbd_lbd
     uncertain_data['u_lbd'] = u_lbd
     uncertain_data['final'] = final_lbd
     return uncertain_data
Ejemplo n.º 6
0
 def calc_uncertainty3(self):
     # 计算顶角A的a,b及总不确定度
     ua_delta = Method.a_uncertainty(
         self.data['list_delta'])  # 这里容易写错,一定要用原始数据的数组
     ub_delta = (1 / 60) / sqrt(3)
     u_delta = sqrt(ua_delta**2 + ub_delta**2)
     self.data.update({
         "ua_delta": ua_delta,
         "ub_delta": ub_delta,
         "u_delta": u_delta
     })
     part_1 = -1 / sin(self.data['aver_A'] / 180 * pi) - sin(
         self.data['aver_delta'] / 180 * pi) * cos(
             self.data['aver_A'] / 180 * pi) / (sin(
                 self.data['aver_A'] / 180 * pi)**2)
     part_4 = (cos(self.data['aver_A'] / 180 * pi) +
               sin(self.data['aver_delta'] / 180 * pi)) / sin(
                   self.data['aver_A'] / 180 * pi)
     n_delta = cos(
         self.data['aver_delta'] / 180 * pi) * part_4 / self.data['n2']
     n_A = part_1 * part_4 / self.data['n2']
     u_n2 = sqrt((n_delta * u_delta / 180 * pi)**2 +
                 (n_A * self.data['u_A'] / 180 * pi)**2)
     self.data['u_n2'] = u_n2
     self.data['final_n2'] = Method.final_expression(self.data['n2'], u_n2)
Ejemplo n.º 7
0
 def __init__(self):
     self.data = {}  # 存放实验中的各个物理量
     self.uncertainty = {}  # 存放物理量的不确定度
     self.report_data = {}  # 存放需要填入实验报告的
     print("1081 光的干涉实验\n1. 实验预习\n2. 数据处理")
     while True:
         try:
             oper = input("请选择: ").strip()
         except EOFError:
             sys.exit(0)
         if oper != '1' and oper != '2':
             print("输入内容非法!请输入一个数字1或2")
         else:
             break
     if oper == '1':
         print("现在开始实验预习")
         print("正在打开预习报告......")
         Method.start_file(self.PREVIEW_FILENAME)
     elif oper == '2':
         print("该实验没有自动数据处理")
         print("正在生成实验报告......")
         # 生成实验报告
         self.fill_report()
         print("实验报告生成完毕,正在打开......")
         Method.start_file(self.REPORT_OUTPUT_FILENAME)
         print("Done!")
Ejemplo n.º 8
0
 def calc_uncertainty1(self):
     # 计算顶角A的a,b及总不确定度
     ua_A = Method.a_uncertainty(self.data['list_A'])  # 这里容易写错,一定要用原始数据的数组
     ub_A = (1 / 60) / sqrt(3) / 2
     u_A = sqrt(ua_A**2 + ub_A**2)
     self.data.update({"ua_A": ua_A, "ub_A": ub_A, "u_A": u_A})
     self.data['final_A'] = Method.final_expression(self.data['aver_A'],
                                                    u_A)
Ejemplo n.º 9
0
 def calc_data(self):
     # list_dif_d 长度为x折半的数组,为逐差相减的结果
     # num_d 逐差法求得的平均值
     list_dtx = []
     for i in range(0, 10):
         list_dtx.append(
             (self.data['list_d2'][i] - self.data['list_d1'][i]) / 30)
     num_d = Method.average(list_dtx)
     num_dt_l = 30 * num_d
     num_lbd = 2 * num_d
     self.data['list_dtx'] = list_dtx
     self.data['num_d'] = num_d
     # num_lbd = round(num_lbd,5)
     num_ave_f = (float(
         (self.data['list_f'][0] + self.data['list_f'][1]) / 2.0))
     num_delta_f = abs(self.data['list_f'][0] -
                       self.data['list_f'][1]) / 2.0
     num_f = num_ave_f
     num_c = num_lbd * num_f
     self.data['num_lbd'] = num_lbd
     self.data['num_ave_f'] = num_ave_f
     self.data['num_delta_f'] = num_delta_f
     self.data['num_u_f'] = num_delta_f / sqrt(3)
     self.data['num_c'] = num_c
     self.data['num_f'] = num_f
Ejemplo n.º 10
0
 def calc_data_detail(data_list):
     result_data = {}
     diff_10delta_x, aver_10delta_x = Method.successive_diff(
         data_list['exp_data'])
     delta_x = aver_10delta_x / 10
     b = abs(data_list['bL'] - data_list['bR'])
     b1 = abs(data_list['b1L'] - data_list['b1R'])
     a = sqrt(b * b1)
     S = abs(data_list['K'] - data_list['L2'])
     S1 = abs(data_list['K'] - data_list['L1'])
     D = S + S1
     result_lambda = a / D * delta_x * 100000
     error = abs(result_lambda -
                 data_list['lambda_0']) / data_list['lambda_0'] * 100
     result_data['diff_10delta_x'] = diff_10delta_x
     result_data['aver_10delta_x'] = aver_10delta_x
     result_data['delta_x'] = delta_x
     result_data['b'] = b
     result_data['b1'] = b1
     result_data['a'] = a
     result_data['S'] = S
     result_data['S1'] = S1
     result_data['D'] = D
     result_data['result_lambda'] = result_lambda
     result_data['error'] = error
     return result_data
Ejemplo n.º 11
0
    def calc_uncertainty(self):
        # 计算线性拟合的A类不确定度
        Sigma = 0
        for i in range(0, len(self.data['X'])):
            Sigma += (self.data['Y'][i] - (self.data['b'] + self.data['a'] * self.data['X'][i]))**2
        k = len(self.data['X'])
        ua_B = (Sigma / (k - 2))**(1 / 2)
        ua_a = self.data['b'] * (((1 / self.data['r']**2 - 1) / (k - 2))**(1 / 2))
        X_square = []
        for i in range(0, k):
            X_square[i] = self.data['X'][i]**2
        ua_b = ua_a * (Method.average(X_square)**(1 / 2))
        self.data.update({"ua_B":ua_B, "ua_a":ua_a, "ua_b":ua_b})

        # 求theta的B类不确定度,分别合成不同V的不确定度,计算加权平均后V_avg的不确定度
        ub_theta = 1 / math.sqrt(3) * math.pi / 180
        u_V = []
        for i in range(0, 4):
            u_V.append(self.data['V'][i] * math.sqrt(1 / self.data['Theta'][i]**2 * ub_theta**2 + 1 / self.data['Magnetic_induction2'][i]**2 * ua_B**2))
        u_V1 = u_V[0]
        u_V2 = u_V[1]
        u_V3 = u_V[2]
        u_V4 = u_V[3]
        u2_Vavg = 1 / (u_V1**(-2) + u_V2**(-2) + u_V3**(-2) + u_V4**(-2))
        u_Vavg = math.sqrt(u2_Vavg)
        V_avg = u2_Vavg * (self.data['V'][0] / u_V1**2 + self.data['V'][1] / u_V2**2 + self.data['V'][2] / u_V3**2 + self.data['V'][3] / u_V4**2)
        self.data.update({"ub_theta":ub_theta, "u_V1":u_V1, "u_V2":u_V2, "u_V3":u_V3, "u_V4":u_V4, "u_Vavg":u_Vavg, "V_avg":V_avg})
Ejemplo n.º 12
0
 def calc_data_2(self):
     i = 0
     self.data['x_1'] = list_x_1 = []
     self.data['x_2'] = list_x_2 = []
     self.data["list_f"] = list_f = []
     while i<5 :
         list_f[i] = (list_x_1[i] + list_x_2[i])/2 - pl_x
         i = i + 1
     self.data["num_f"] = num_f = Method.average(self.data['list_f'])
Ejemplo n.º 13
0
 def calc_uncertainty(self):
     # 计算光程差d的a,b及总不确定度
     ua_d = Method.a_uncertainty(self.data['list_d'])  # 这里容易写错,一定要用原始数据的数组
     ub_d = 0.00005 / sqrt(3)
     u_d = sqrt(ua_d**2 + ub_d**2)
     self.uncertainty.update({"ua_d": ua_d, "ub_d": ub_d, "u_d": u_d})
     # 计算圈数N的不确定度
     N = self.data['N']
     u_N = 1 / sqrt(3)
     self.uncertainty['u_N'] = u_N
     d, N = self.data['d'], self.data['N']
     # 波长的不确定度合成
     u_lbd_lbd = sqrt((u_d / d)**2 + (u_N / N)**2)
     lbd = self.data['lbd']
     u_lbd = u_lbd_lbd * lbd
     self.uncertainty.update({"u_lbd_lbd": u_lbd_lbd, "u_lbd": u_lbd})
     # 输出带不确定度的最终结果: 不确定度保留一位有效数字, 物理量结果与不确定度首位有效数字对齐
     self.data['final'] = Method.final_expression(lbd, u_lbd)
Ejemplo n.º 14
0
 def calc_data1(self):
     list_A = []
     for rows in self.data['list_data'][0]:
         row = []
         for item in rows:
             value_degree = Method.degree_trans(item)
             if (value_degree > 1000) | (value_degree < -1000):
                 print('数据出现错误,请检查实验表格第' +
                       str(self.data['list_data'].index(rows) + 4) + '行第' +
                       str(rows.index(item) + 2) + '列的度和分是否以空格分隔')
             else:
                 row.append(value_degree)
         value_A = (row[3] + row[2] - row[1] - row[0]) / 4
         if value_A < 0:
             value_A = value_A + 90
         list_A.append(value_A)
     aver_A = Method.average(list_A)
     self.data['list_A'] = list_A
     self.data['aver_A'] = aver_A
Ejemplo n.º 15
0
 def calc_data(self):
     # 求直径D的平均值
     num_D = Method.average(self.data['list_D'])
     self.data['num_D'] = num_D
     # 一元线性回归求电阻率
     num_b, num_a, num_r = Fitting.linear(self.data['list_l'], self.data['list_R_x'])
     self.data['num_b'] = num_b
     self.data['num_r'] = num_r
     num_rho = math.pi * num_D * num_D * num_b / 4
     self.data['num_rho']=num_rho
Ejemplo n.º 16
0
 def calc_data_3(self):
     i = 0
     self.data['list_3_f'] = list_3_f = []
     self.data['list_a'] = list_a = []
     self.data['list_b'] = list_b = []
     self.data['overline_3_f'] = overline_3_f
     while i<5 :
         list_3_f[i] = ( list_a[i]^2 - list_b[i]^2 ) / 4*list_b[i]
         i = i + 1
     overline_3_f = Method.average(self.data['list_3_f'])
Ejemplo n.º 17
0
 def calc_uncertainty2(self):
     # 计算顶角A的a,b及总不确定度
     ua_delta_m = Method.a_uncertainty(
         self.data['list_delta_m'])  # 这里容易写错,一定要用原始数据的数组
     ub_delta_m = (1 / 60) / sqrt(3)
     u_delta_m = sqrt(ua_delta_m**2 + ub_delta_m**2)
     self.data.update({
         "ua_delta_m": ua_delta_m,
         "ub_delta_m": ub_delta_m,
         "u_delta_m": u_delta_m
     })
     part_1 = cos((self.data['aver_delta_m'] / 180 * pi +
                   self.data['aver_A'] / 180 * pi) / 2)
     part_4 = sin(self.data['aver_A'] / 180 * pi / 2)
     n_delta_m = 0.5 * part_1 / part_4
     n_A = -sin(self.data['aver_delta_m'] / 180 * pi / 2) / 2 / (part_4**2)
     u_n1 = sqrt((n_delta_m * u_delta_m / 180 * pi)**2 +
                 (n_A * self.data['u_A'] / 180 * pi)**2)
     self.data['u_n1'] = u_n1
     self.data['final_n1'] = Method.final_expression(self.data['n1'], u_n1)
Ejemplo n.º 18
0
 def calc_data(self):
     N = 100
     self.data['N'] = N
     # 逐差法计算100圈光程差d
     dif_d_arr, d = Method.successive_diff(self.data['d_arr'])
     self.data['dif_d_arr'] = dif_d_arr
     self.data['d'] = d
     # 按公式计算待测光的波长
     lbd = 2 * d / (len(dif_d_arr) * N)
     lbd = lbd * 1e6
     self.data['lbd'] = lbd
Ejemplo n.º 19
0
 def calc_data(self):
     N = 100
     self.data['N'] = N
     # 逐差法计算100圈光程差d
     list_dif_d, d = Method.successive_diff(self.data['list_d'])
     self.data['list_dif_d'] = list_dif_d
     self.data['d'] = d
     # 按公式计算待测光的波长
     lbd = 2 * d / (len(list_dif_d) * N)
     lbd = lbd * 1e6
     self.data['lbd'] = lbd
Ejemplo n.º 20
0
 def calc_uncertainty(self):
     # 计算光程差d的a,b及总不确定度
     ua_d = Method.a_uncertainty(self.data['d_arr'])  # 这里容易写错,一定要用原始数据的数组
     ub_d = 0.00005 / sqrt(3)
     u_d = sqrt(ua_d**2 + ub_d**2)
     self.data.update({"ua_d": ua_d, "ub_d": ub_d, "u_d": u_d})
     # 计算圈数N的不确定度
     N = self.data['N']
     u_N = 1 / sqrt(3)
     self.data['u_N'] = u_N
     d, N = self.data['d'], self.data['N']
     # 波长的不确定度合成
     u_lbd_lbd = sqrt((u_d / d)**2 + (u_N / N)**2)
     lbd = self.data['lbd']
     u_lbd = u_lbd_lbd * lbd
     self.data.update({"u_lbd_lbd": u_lbd_lbd, "u_lbd": u_lbd})
     # 输出带不确定度的最终结果
     # TODO: 输出最终结果的修约方法稍稍有点问题,待修改
     bse, pwr = Method.scientific_notation(u_lbd)
     lbd_f = int(lbd * (10**pwr)) / (10**pwr)  # 保留有效数字,截断处理
     self.data['final'] = "%.0f±%.0f" % (lbd_f, bse)
Ejemplo n.º 21
0
 def calc_uncertainty(self):
     num_sum = 0
     for i in range(0, 8):
         num_sum += (self.data['list_Y'][i] -
                     self.data['list_X'][i] * self.data['num_a'])**2
     num_u_A = sqrt(num_sum / (48 * 21))
     num_u_E = num_u_A * self.data['num_para']
     num_eta = abs(self.data['num_E'] - 70 * 1e9) / (70 * 1e9) * 100
     self.data['num_u_A'] = num_u_A
     self.data['num_u_E'] = num_u_E
     self.data['num_eta'] = num_eta
     self.data['final'] = Method.final_expression(
         self.data['num_E'] / 1e9, self.data['num_u_E'] / 1e9)
Ejemplo n.º 22
0
 def calc_data(self):
     # 计算间距
     yd = [], gd = [], pd = [], ld = []
     for i in range(0, 6):
         yd[i] = self.data['yl'][i] - self.data['yr'][i]
         gd[i] = self.data['gl'][i] - self.data['gr'][i]
         pd[i] = self.data['pl'][i] - self.data['pr'][i]
         ld[i] = self.data['ll'][i] - self.data['lr'][i]
     self.data['yd'] = yd, self.data['gd'] = gd, self.data[
         'pd'] = pd, self.data['ld'] = ld
     yd_avg = Method.average(yd)
     gd_avg = Method.average(gd)
     pd_avg = Method.average(pd)
     ld_avg = Method.average(ld)
     self.data['yd_avg'] = yd_avg, self.data['gd_avg'] = gd_avg, self.data[
         'pd_avg'] = pd_avg, self.data['ld_avg'] = ld_avg
     # 计算波长
     lambda_y = yd_avg / ld_avg * self.data['lambda_0']
     lambda_g = gd_avg / ld_avg * self.data['lambda_0']
     lambda_p = pd_avg / ld_avg * self.data['lambda_0']
     self.data['lambda_y'] = lambda_y, self.data[
         'lambda_g'] = lambda_g, self.data['lambda_p'] = lambda_p
Ejemplo n.º 23
0
 def calc_uncertainty(self):
     list_tmp = []
     for i in self.data['list_dtx']:
         list_tmp.append(i * 0.001 / 15)
     # num_ua_d = sqrt( (Method.variance(self.data['list_d'])) / (10 * 9) )
     num_ua_d = Method.a_uncertainty(list_tmp)
     # print(num_ua_d)
     num_ub1_d = 0.005 / sqrt(3)
     num_ub2_d = 0.1 / sqrt(3)
     num_u_d = sqrt(num_ua_d**2 + num_ub1_d**2 + num_ub2_d**2)
     self.data.update({
         "num_ua_d": num_ua_d,
         "num_ub1_d": num_ub1_d,
         "num_ub2_d": num_ub2_d,
         "num_u_d": num_u_d
     })
     num_d = self.data['num_d']
     num_lbd = self.data['num_lbd']
     num_c = self.data['num_c']
     num_f = self.data['num_f']
     num_u_f = self.data['num_u_f']
     num_u_lbd = 2 * num_u_d
     num_u_c_c = sqrt((num_u_lbd / num_lbd)**2 + (num_u_f / num_f)**2)
     num_u_c = num_u_c_c * num_c
     self.data['num_u_c'] = num_u_c
     self.data['num_u_c_c'] = num_u_c_c
     self.data.update({"num_u_lbd": num_u_lbd})
     num_u_lbd_1bit, pwr = Method.scientific_notation(num_u_lbd)
     num_u_f_1bit, pwr = Method.scientific_notation(
         num_u_f)  # 将不确定度转化为只有一位有效数字的科学计数法
     num_u_c_1bit, pwr = Method.scientific_notation(
         num_u_c)  # 将不确定度转化为只有一位有效数字的科学计数法
     num_fin_lbd = int(num_lbd * (10**pwr)) / (10**pwr)  # 对物理量保留有效数字,截断处理
     num_fin_f = int(num_f * (10**pwr)) / (10**pwr)
     num_fin_c = int(num_c * (10**pwr)) / (10**pwr)
     self.data['num_fin_c'] = "%.2f±%.2f" % (num_fin_c, num_u_c_1bit)
     self.data['num_fin_f'] = "%.0f±%.0f" % (num_fin_f, num_u_f_1bit)
     self.data['num_fin_lbd'] = "%.0f±%.0f" % (num_fin_lbd, num_u_lbd_1bit)
Ejemplo n.º 24
0
    def calc_data(self):
        x = arr_k = asarray(self.data['arr_k'])
        y = arr_D_sq = asarray(self.data['arr_D_sq'])
        b, a, r = Fitting.linear(x, y)
        self.data['b'] = b
        self.data['a'] = a
        self.data['r'] = r
        x_mean = Method.average(x)
        y_mean = Method.average(y)
        x_sq_mean = Method.average(x ** 2)
        y_sq_mean = Method.average(y ** 2)
        xy_mean = Method.average(x * y)

        self.data['x_mean'] = x_mean
        self.data['y_mean'] = y_mean
        self.data['x_sq_mean'] = x_sq_mean
        self.data['y_sq_mean'] = y_sq_mean
        self.data['xy_mean'] = xy_mean

        lbd = self.data['lambda'] * 1e-6
        R = b / (4 * lbd)
        self.data['R'] = R
        pass
Ejemplo n.º 25
0
 def calc_data2(self):
     list_delta_m = []
     for rows in self.data['list_data'][1]:
         row = []
         for item in rows:
             value_degree = Method.degree_trans(item)
             if (value_degree > 1000) | (value_degree < -1000):
                 print('数据出现错误,请检查实验表格第' +
                       str(self.data['list_data'].index(rows) + 4) + '行第' +
                       str(rows.index(item) + 8) + '列的度和分是否以空格分隔')
             else:
                 row.append(value_degree)
         value_delta_m = (row[3] + row[2] - row[1] - row[0]) / 2
         if value_delta_m < 0:
             value_delta_m = value_delta_m + 180
         list_delta_m.append(value_delta_m)
     delta_m = Method.average(list_delta_m)
     n1 = float(
         sin((delta_m + self.data['aver_A']) / 360 * pi) /
         sin(self.data['aver_A'] / 360 * pi))
     self.data['list_delta_m'] = list_delta_m
     self.data['aver_delta_m'] = delta_m
     self.data['n1'] = n1
Ejemplo n.º 26
0
    def calc_uncertainty(self):
        Ua = Method.a_uncertainty(self.data['list_dif_d'])  # a类不确定度
        Ub = 0.1 / (numpy.sqrt(3))  # b类不确定度
        U = numpy.sqrt(numpy.square(Ua) + numpy.square(Ub))  # 总的不确定度
        self.data.update({"Ua": Ua, "Ub": Ub, "U": U})
        ave_d = self.data['ave_d']
        #res_final, unc_final, pwr = Method.final_expression(ave_d,U)
        #self.data['final'] = "(%s±%s)*10e(%s)"%(res_final,unc_final,pwr)

        #base_U, pwr = Method.scientific_notation(U) #将不确定度转化为只有一位有效数字的科学计数法
        #volt_final = int(ave_d *(10**pwr))/(10 ** pwr) #对物理量保留有效数字,截断处理
        self.data['final'] = "%.1f±%.1f" % (ave_d, U)
        self.data['relative_error'] = abs(
            (float(int(ave_d * 10) / 10 - 11.55)) / 11.55)
Ejemplo n.º 27
0
 def calc_data3(self):
     list_delta = []
     for rows in self.data['list_data'][2]:
         row = []
         for item in rows:
             value_degree = Method.degree_trans(item)
             if (value_degree > 1000) | (value_degree < -1000):
                 print('数据出现错误,请检查实验表格第' +
                       str(self.data['list_data'].index(rows) + 4) + '行第' +
                       str(rows.index(item) + 14) + '列的度和分是否以空格分隔')
             else:
                 row.append(value_degree)
         value_delta = (row[0] + row[1] - row[2] - row[3]) / 2
         if value_delta < 0:
             value_delta = value_delta + 180
         list_delta.append(value_delta)
     delta = Method.average(list_delta)
     n2 = float(
         sqrt((
             (cos(self.data['aver_A'] / 180 * pi) + sin(delta / 180 * pi)) /
             sin(self.data['aver_A'] / 180 * pi))**2 + 1))
     self.data['list_delta'] = list_delta
     self.data['aver_delta'] = delta
     self.data['n2'] = n2
Ejemplo n.º 28
0
 def calc_uncertainty(self):
     b = self.data['b']
     n = len(self.data['arr_D'])
     r = self.data['r']
     lbd = self.data['lambda'] * 1e-6
     ua_b = b * sqrt((1 / (n - 2)) * ((1 / (r ** 2)) - 1))
     ub_b = 0.005 / sqrt(3)
     u_b = sqrt(ua_b ** 2 + ub_b ** 2)
     u_R = u_b / (4 * lbd)
     R = self.data['R']
     res, unc, pwr = Method.final_expression(R, u_R)
     self.uncertainty['ua_b'] = ua_b
     self.uncertainty['ub_b'] = ub_b
     self.uncertainty['u_b'] = u_b
     self.uncertainty['u_R'] = u_R
     self.data['final'] = "(%.0f ± %.0f)e%d" % (res, unc, int(pwr))
     pass
Ejemplo n.º 29
0
    def calc_data(self):
        list_phi_1 = []
        i = 0
        while i < 8:
            list_phi_1[i] = asin(sin(list_phi_0[i]) / num_n)
            i = i + 1
        self.data['list_phi_1'] = list_phi_1

        list_num_b = []
        list_num_b = Method.linear(list_f_s , list_phi_1)
        num_b = list_num_b[0]
        self.data['num_b'] = num_b

        num_v_s = num_lambda_0 * num_b / num_n 
        self.data[' num_v_s'] =  num_v_s
        num_percent = abs( num_v_s - num_v_0 ) / num_v_0 * 100
        self.data[' num_percent'] =  num_percent
Ejemplo n.º 30
0
 def calc_uncertainty(self):
     list_a = []
     list_x = self.data['list_x']
     list_y = self.data['list_y']
     list_graph2 = self.data['list_graph2']
     voltage_begin = self.data['voltage_begin']
     voltage_end = self.data['voltage_end']
     resitence = self.data['resitence']
     c1 = self.data['c1']
     c0 = self.data['c0']
     list_weight = self.data['list_weight']
     m_water = list_weight[1] - list_weight[0]
     for i in range(len(list_x)):
         list_a.append(list_y[i] - list_graph2[1] * list_x[i])
     self.data['list_a'] = list_a
     Ua = Method.a_uncertainty(self.data['list_a'])
     self.data['Ua'] = Ua
     UJ = abs(
         ((voltage_begin + voltage_end) / 2)**2 /
         (Ua * resitence *
          (c0 * m_water * 0.001 + c1 * list_weight[3] * 0.001 + 64.38)))
     self.data['UJ'] = UJ