title='$\\beta$射线吸收曲线', clr='green', issetrange=0, save='3.png') print(k1, k2) h = 0 - (k1 * Al_m[0] + b1) print(h) Rx = ((-4 - h) - b2) / k2 print(Rx) R = Rx / 49 print(R) Emax = 1.85e-3 * Rx + 0.245 print(Emax) gendocx('gen.docx', '1.png', '2.png', '3.png', 'slope1, intercept1: %f %f' % (k1, b1), 'slope2, intercept2: %f %f' % (k2, b2)) # linear regression and plot # #1 # result = linear_regression(x, y) # setrange(x, y) # plt.scatter(x, y, marker='o', color='black', label='原始数据') # plt.plot(x, result['intercept'] + result['slope'] * x, 'r', label='拟合直线') # plt.xlabel('') # plt.ylabel('') # plt.legend(loc=4) # plt.title('') # plt.savefig('pic.png') # plt.show() # #2
# calculate the Re(Epsilon_m) re_epsilon_m = np**2 * math.sin(math.radians(theta_sp0))**2 * ns0**2 / \ (ns0**2 - np**2 * math.sin(math.radians(theta_sp0))**2) print(re_epsilon_m) ns2 = np * math.sin(math.radians(theta_sp2)) * \ math.sqrt(re_epsilon_m / (re_epsilon_m - np**2 * math.sin(math.radians(theta_sp2))**2)) print(ns2) ns3 = np * math.sin(math.radians(theta_sp3)) * \ math.sqrt(re_epsilon_m / (re_epsilon_m - np**2 * math.sin(math.radians(theta_sp3))**2)) print(ns3) # check the calc is correct ns2 = np * math.sin(math.radians(theta_sp0)) * \ math.sqrt(re_epsilon_m / (re_epsilon_m - np**2 * math.sin(math.radians(theta_sp0))**2)) print(ns2) gendocx('gen.docx', '1.png', '2.png', '3.png') # linear regression and plot # #1 # result = linear_regression(x, y) # setrange(x, y) # plt.scatter(x, y, marker='o', color='black', label='原始数据') # plt.plot(x, result['intercept'] + result['slope'] * x, 'r', label='拟合直线') # plt.xlabel('') # plt.ylabel('') # plt.legend(loc=4) # plt.title('') # plt.savefig('pic.png') # plt.show() # #2 # use automate tool
Ir = IIdown[np.argmin(IIdown)] I0 = 51 Ihalf = 2 * I0 * Ir / (I0 + Ir) dB = finddeltaB(IIdown, Bdown, Ihalf) print(Br, Ir, Ihalf, dB) # linear regression and plot # #1 # result = linear_regression(x, y) # setrange(x, y) # plt.scatter(x, y, marker='o', color='black', label='原始数据') # plt.plot(x, result['intercept'] + result['slope'] * x, 'r', label='拟合直线') # plt.xlabel('') # plt.ylabel('') # plt.legend(loc=4) # plt.title('') # plt.savefig('pic.png') # plt.show() # #2 # use automate tool # simple_linear_plot(x, y, xlab='x axis', ylab='y axis', title='my pic', save='pic.png') # generate docx #1 gendocx('gen.docx', '1.png') # generate docx #2 # docu = Document() # docuaddtitle(docu) # docuappend(docu, './picfull.png', './figure_1.png', './pic.png', result['string'], './picx.png') # docu.save('gen.docx')
simple_plot(redwl, redabs, show=0, issetrange=0, clr='red', islegend=0) simple_plot(bluewl, blueabs, show=0, issetrange=0, clr='blue', islegend=0) simple_plot(greenwl, greenabs, xlab='波长', ylab='吸收相对强度', save='2.png', issetrange=0, clr='green', islegend=0, title='红绿蓝滤波片的吸收光谱') redabs = [(purestg[i] - redstg[i]) / purestg[i] for i in range(len(purestg))] blueabs = [(purestg[i] - bluestg[i]) / purestg[i] for i in range(len(purestg))] greenabs = [(purestg[i] - greenstg[i]) / purestg[i] for i in range(len(purestg))] simple_plot(redwl, redabs, show=0, issetrange=0, clr='red', islegend=0) simple_plot(bluewl, blueabs, show=0, issetrange=0, clr='blue', islegend=0) simple_plot(greenwl, greenabs, xlab='波长', ylab='吸收相对比例', save='3.png', issetrange=0, clr='green', islegend=0, title='红绿蓝滤波片的吸收比例光谱') gendocx('gen.docx', '滤波片光谱分析', '1.png', '2.png', '3.png', '钠灯各线系光谱', './17000002/1Na589-300V.bmp', './17000002/2Na497-798V.bmp', './17000002/3Na568-633V.bmp', './17000002/4Na616-766V.bmp', '红宝石发射光谱', './17000002/Ruby-531V.bmp') # read data # # 1 # data, data_orig, name = readdata('./data.txt', need=0b111) # # 2 # fin = open('./data.txt', 'r', encoding='utf-8') # x = readoneline(fin) # y = readoneline(fin) # z = readonenumber(fin) # fin.close() # data process
# simple_plot(Ul21, Il21, show=0, issetrange=0) # simple_plot(Ul22, Il22, show=0, issetrange=0, xlab='U/V', ylab='I/uA', title='双探针伏安特性-P=40Pa, P=3.82W') # plt.show() # plt.savefig('42.png') # simple_plot(Ul2, Il2, show=0) # linear regression and plot # #1 # result = linear_regression(x, y) # setrange(x, y) # plt.scatter(x, y, marker='o', color='black', label='原始数据') # plt.plot(x, result['intercept'] + result['slope'] * x, 'r', label='拟合直线') # plt.xlabel('') # plt.ylabel('') # plt.legend(loc=4) # plt.title('') # plt.savefig('pic.png') # plt.show() # #2 # use automate tool # simple_linear_plot(x, y, xlab='x axis', ylab='y axis', title='my pic', save='pic.png') # generate docx #1 gendocx('gen.docx', '11.png', '12.png', '2.png', '3.png', '41.png', '42.png') # generate docx #2 # docu = Document() # docuaddtitle(docu) # docuappend(docu, './picfull.png', './figure_1.png', './pic.png', result['string'], './picx.png') # docu.save('gen.docx')
# xlab='f/Mhz', ylab='最高点间距', title='第2,3个信号间距随频率变化', save='2.png') # simple_plot(f, [math.cos(max2[i] - max1[i]) for i in range(len(f))], show=0, issetrange=0, lab='max2-max1', dot='+', # xlab='f/Mhz', ylab='最高点间距', title='第1,2个信号间距随频率变化') # simple_plot(f, [math.cos(max3[i] - max2[i]) for i in range(len(f))], show=1, issetrange=0, lab='max3-max2', dot='*', # xlab='f/Mhz', ylab='最高点间距', title='第2,3个信号间距随频率变化', save='2.png') # linear regression and plot # #1 # result = linear_regression(x, y) # setrange(x, y) # plt.scatter(x, y, marker='o', color='black', label='原始数据') # plt.plot(x, result['intercept'] + result['slope'] * x, 'r', label='拟合直线') # plt.xlabel('') # plt.ylabel('') # plt.legend(loc=4) # plt.title('') # plt.savefig('pic.png') # plt.show() # #2 # use automate tool # simple_linear_plot(x, y, xlab='x axis', ylab='y axis', title='my pic', save='pic.png') # generate docx #1 gendocx('gen.docx', '11.png', '12.png', '21.png', '22.png', '31.png', '32.png') # generate docx #2 # docu = Document() # docuaddtitle(docu) # docuappend(docu, './picfull.png', './figure_1.png', './pic.png', result['string'], './picx.png') # docu.save('gen.docx')
save='2.png') CntLn = np.log(Cnt) # d = 50 mg / cm^2 d = 50 Al_Real = Al_num * d slope, intercept = simple_linear_plot(Al_Real, CntLn, xlab='质量厚度$g/cm^{-2}$', ylab='选区计数率对数(射线强度)', title='半对数曲线曲线', save='3.png') print(-slope) print(math.log(1e4) / (-slope)) print((math.log(Cnt[0]) - 4 * math.log(10) - intercept) / slope) gendocx('gen.docx', '1.png', '2.png', '3.png', 'slope, intercept: %f %f' % (slope, intercept)) # linear regression and plot # #1 # result = linear_regression(x, y) # setrange(x, y) # plt.scatter(x, y, marker='o', color='black', label='原始数据') # plt.plot(x, result['intercept'] + result['slope'] * x, 'r', label='拟合直线') # plt.xlabel('') # plt.ylabel('') # plt.legend(loc=4) # plt.title('') # plt.savefig('pic.png') # plt.show() # #2 # use automate tool
k1, b1 = simple_linear_plot(t1, np.log(P1), xlab='t/s', ylab='ln(P)', title='粗真空lnP-t图', save='11.png') # the volume of bottle V = 2 print(k1, b1) print('Speed: ', - V * k1, ' L') simple_plot(t2, P2, xlab='时间/s', ylab='压强/Pa', title='低真空P-t图', save='2.png') simple_plot(t2, np.log(P2), xlab='t/s', ylab='ln(P)', title='低真空lnP-t图', show=0) k2, b2 = simple_linear_plot(t2[:4], np.log(P2[:4]), xlab='t/s', ylab='ln(P)', title='低真空lnP-t图', dotlab='使用的数据', save='21.png') # the volume of bottle V = 2 print(k2, b2) print('Speed(may be bad): ', - V * k2, ' L') gendocx('gen.docx', '1.png', '11.png', 'k: %f, b: %f' % (k1, b1), '2.png', '21.png', 'k: %f, b: %f' % (k2, b2)) # linear regression and plot # #1 # result = linear_regression(x, y) # setrange(x, y) # plt.scatter(x, y, marker='o', color='black', label='原始数据') # plt.plot(x, result['intercept'] + result['slope'] * x, 'r', label='拟合直线') # plt.xlabel('') # plt.ylabel('') # plt.legend(loc=4) # plt.title('') # plt.savefig('pic.png') # plt.show() # #2