-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsourcedata.py
54 lines (39 loc) · 1.19 KB
/
sourcedata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author YongXin SHI
# Email [email protected]
# Date 2016/04/30
import xlrd as xl
def open_excel(file= 'file.xls'):
try:
data = xl.open_workbook(file)
return data
except Exception.e:
print(str(e))
def data(num = 1):
# 打开表格,file为excel文件对象
file = open_excel('c4h10.xlsx')
# 按序号获取excel工作表,sheets()返回一个列表,由下表指定工作表
table = file.sheets()[0]
# 按列获取工作表数据,第一列是波长
wave = table.col_values(0)
# 按列获取工作表数据,第二列是强度,以后同理,每两列为一组(波长,强度)
intensity = table.col_values(num)
#print(wave)
data = [[],[]]
data[0] = wave
data[1] = intensity
return data
# 行和列交换
def source(data):
return list(list(i) for i in zip(*data))
# 滤波
def wave_filtering(daa):
m = (max(daa[1])-min(daa[1]))*0.6+min(daa[1])
med = (max(daa[1])-min(daa[1]))*0.5+min(daa[1])
data = source(daa)
for num in range(len(data)):
if data[num][1] < m:
data[num][1] = 3000
data = source(data)
return data