-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlithology_hist.py
142 lines (99 loc) · 4.6 KB
/
lithology_hist.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#precip 0.4 only. Hist and Box one plot.
import matplotlib
matplotlib.use("Agg")
from matplotlib import pyplot as plt
import pandas as pd
import sys
import matplotlib.patches as mpatches
target = '/exports/csce/datastore/geos/users/s1134744/LSDTopoTools/Topographic_projects/full_himalaya_5000/'
source= '0_4_ex_MChiSegmented_burned_outlier_removed.csv'
def getAxisHist(column):
with open(target+source,'r') as csvfile:
df_a = pd.read_csv(csvfile,delimiter=',')
for_hist = []
for x in [1,2,3,4]:
df = df_a[df_a['tectonics'] == x]
x_list = df[column].tolist()
y_list = df['m_chi'].tolist()
for_hist.append(x_list)
return for_hist
def getAxisBox(column,mins,maxs):
x_list = []
x_ticks = []
with open(target+source,'r') as csvfile:
df = pd.read_csv(csvfile,delimiter=',')
selectedDF = df[df['m_chi'] > 0]
selectedDF = selectedDF[selectedDF['quaternary_burned_data'] == 1]
for lower,upper in zip(mins,maxs):
selectedDF = df[df[column] >= lower]
selectedDF = selectedDF[selectedDF[column] < upper]
series = selectedDF['m_chi']
lister = series.tolist()
data_count = len(lister)
#for labeling x axis
#label = str(lower)+'\n n:'+str(data_count)
x_ticks.append(str(data_count))
x_list.append(lister)
return x_list,x_ticks
colours = ['b','g','r','y','c','m']
numbers_a = [30000,50000,90000,100000,110000,120000]
numbers_b = [40000,60000,100000,110000,120000,130000]
bin_names = ["Metamorphics","Acid Plutonic Rocks","Carbonate Sedimentary Rocks",
"Mixed Sedimentary Rocks","Siliciclastic Sedimentary Rocks",
"Unconsolidated Sediments"]
fig = plt.figure(1, figsize=(15,9))
#x_list,y_list = getAxisBox('burned_dat',range(10000,170000,10000),range(20000,180000,10000))
x_list = getAxisHist('burned_dat')
#print x_list,y_list
names = ["Evaporites","Ice \n and \n Glaciers","Metamorphics","NoData",
"Acid \n Plutonic \n Rocks","Basin \n Plutonic \n Rocks",
"Intermediate \n Plutonic \n Rocks","Pyroclastics","Carbonate \n Sedimentary \n Rocks",
"Mixed \n Sedimentary \n Rocks","Siliciclastic \n Sedimentary \n Rocks",
"Unconsolidated \n Sediments","Acid \n Volcanic \n Rocks","Basic \n Volcanic \n Rocks",
"Intermediate \n Volcanic \n Rocks","Water \n Bodies"]
#names = ['0-500','500-1000','1000-1500','1500-2000','2000-2500','2500-3000','3000-3500','3500-4000','4000-4500','4500-5000','5000-5500','5500-6000']
#ax = fig.add_subplot(111)
legends = []
titles = ['Sub Himalaya','Lesser Himalaya','Greater Himalaya','Tethyan Himalaya']
print x_list
locations = [221,222,223,224]
for x,location,title in zip(x_list,locations,titles):
ax = fig.add_subplot(location)
N,bins,patches = ax.hist(x,bins=range(10000,170000,10000),stacked=False)
i = 2
patches[i].set_facecolor('b')
i = 4
patches[i].set_facecolor('g')
i = 8
patches[i].set_facecolor('r')
i = 9
patches[i].set_facecolor('y')
i = 10
patches[i].set_facecolor('c')
i = 11
patches[i].set_facecolor('m')
#plt.xticks([35000,55000,95000,105000,115000,125000],bin_names)
plt.ylabel("Frequency",fontsize=18)
#plt.xlabel("GLIM Lithology Class",fontsize=18)
plt.title(title)
ax.get_xaxis().set_visible(False)
for colour,name in zip(colours,bin_names):
legend = mpatches.Patch(color=colour, label=name)
legends.append(legend)
leg = fig.legend(legends, bin_names,'lower center',ncol=3,title='GLIM Lithology Class')
#N,bins,patches = ax.hist(x,bins=range(10000,170000,10000),stacked=False)
i = 2
#patches[i].set_facecolor('b')
i = 4
#patches[i].set_facecolor('r')
i = 8
#patches[i].set_facecolor('c')
i = 9
#patches[i].set_facecolor('y')
i = 10
#patches[i].set_facecolor('m')
#plt.xticks(range(15000,185000,10000),names)
#plt.ylabel("Frequency",fontsize=18)
#plt.xlabel("GLIM Lithology Class",fontsize=18)
#fig.tight_layout()
fig.savefig('../lithology_sub_hist_5000.png', bbox_inches='tight')