-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbar.py
More file actions
60 lines (47 loc) · 1.29 KB
/
bar.py
File metadata and controls
60 lines (47 loc) · 1.29 KB
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
55
56
57
58
59
60
# read data from file
import csv
import numpy as np
import matplotlib.pyplot as plt
data_file = "arabian_sea200602.pix"
#rowValue = input("Enter the row value")
rowValue = 4
result = {}
with open(data_file,'r') as f:
reader = csv.reader(f, delimiter=' ')
for row in reader:
if row[0] in result:
temp = float(row[rowValue])
result[row[0]].append(temp)
else:
result[row[0]] = [row[rowValue]]
# Get all the keys of the list and store it in a tuple
keys = list(result.keys())
keys.sort()
# calculate mean and stanard devaition for the data
resultMean = []
resultStd = []
for value in keys:
temp = np.array(result[value], dtype="float")
a = np.mean(temp) #mean for date
b = np.std(temp) #std for date
#value contains the date
#use this 3 varaible to write to file
resultMean.append(np.mean(temp))
resultStd.append(np.std(temp))
#########
N = len(resultMean)
x = range(1, N + 1)
width = 1 / 1.5
plt.figure(1)
plt.title('Bar Graph')
plt.ylabel('total_AOD fine Mean', fontsize=12)
plt.xlabel('Date', fontsize=12)
plt.bar(x, resultMean, width, color="blue",yerr=resultStd)
plt.xticks(x, size="small")
# plt.show()
plt.
# draw histogram
plt.figure(2)
plt.title("Histograph")
plt.hist(resultMean, bins=N, color="green")
plt.show()