-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathica_plot.py
190 lines (131 loc) · 4.92 KB
/
ica_plot.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
from intuitionistic_fuzzy_set import IFS
from universal_set import UniversalSet
# from ifs_lattice import piOrd, stdOrd
from ifs_2Dplot import plot_triangular, plot_bar_Intuitionistic
from ifs_3Dplot import plot_3D_histogramm
import matplotlib.pyplot as plt
from collections import OrderedDict
from openpyxl import load_workbook
import sys
import argparse
parser = argparse.ArgumentParser(
description='Plot ICA arguments handler',
)
parser.add_argument('-input_file', action="store",
type=str,
help = 'Input file name')
parser.add_argument('-sheet', action="store",
type=str,
help = 'Name of the sheet in the file')
parser.add_argument('-format', action="store",
type=str,
help = 'Format of input file: row or matrix')
parser.add_argument('-start', action="store",
dest="start", type=int)
parser.add_argument('-end', action="store",
dest="end", type=int)
parser.add_argument('--number_bins', action="store", default=15,
dest="number_bins", type=int)
parser.add_argument('-plot', action='append',
#dest='collection',
default=[],
help='What to plot: 2dHistogram, 2dHistogram, stackbars')
#evgeniy@evgeniy-TravelMate-P238-M:~$ python -input_file file_name -format 'row'
#-step_size 20 start 2 end 560 3dHistogram triangular stackbars
# python ica_plot.py -input_file ./ifsholder/SecondOrderICA_mutr_Dafi.xlsx
# -sheet GASeries_00030_MuNu -format row -start 2 -end 562 -plot 3dHistogram
main_path = "/home/evgeniy/Documents/IFS-Simulator/ifs-lattice/ifsholder/"
file_name = "Mutr_ICA_Evgeni.xlsx"
file_name ="SecondOrderICA_mutr_Dafi.xlsx"
sheet = "GASeries_00030_MuNu"
parsed = parser.parse_args(['-input_file', main_path + file_name, '-sheet', sheet,
'-format', 'row',
'-start', '2',
'-end', '562',
'-plot', ['2dHistogram','2DHistogram','stackbars']])
#
# main_path + file_name
# sheet = "GASeries_00030_MuNu"
start = 1 # 2
end = 561 # 562
def get_ifs(parsed):
def get_pair(str_pair):
lst = str_pair.strip(')(').split(',')
mu = lst[0].strip()
nu = lst[1].strip()
return float(mu), float(nu)
wb = load_workbook(parsed.input_file, read_only=True)
ws = wb[parsed.sheet]
start = parsed.start - 1
end = parsed.end -1
rows = list(ws.rows)
result = OrderedDict([(row[0].value, get_pair(row[1].value)) \
for row in rows[start:end]])
return result
'''
ws = wb["Res_Dian-full"]
def get_holder(start, end, data_generator):
rows = list(data_generator)[start:end]
holder = np.zeros((100,100), dtype=float)
for h, row in zip(holder, rows[0:100]):
h[:] = [r.value for r in row[1:101]]
return holder
def generate_universum_values(holder):
result = OrderedDict()
for idx, row in enumerate(holder):
for i in range(idx+1, len(holder)):
label = "G"+str(idx+1)+","+str(i+1)
#print(label)
#print(row[i])
result[label] = row[i]
return result
start_mu = 1
end_mu = 101
start_nu = 103
end_nu = 203
holder_mu = get_holder(start_mu, end_mu, ws.rows)
holder_nu = get_holder(start_nu, end_nu, ws.rows)
res_mu = generate_universum_values(holder_mu)
res_nu = generate_universum_values(holder_nu)
r = [(k1, (v1, v2)) for ((k1,v1),(k2,v2)) in zip(res_mu.items(), res_nu.items())]
result = OrderedDict(r)
'''
#for k, (v1,v2) in result.items():
# print(v1+v2)
# assert(v1+v2 <= 1.0001)
def main():
parsed = parser.parse_args(sys.argv[1:])
result = get_ifs(parsed)
#######################################
######################################
universe = UniversalSet(result.keys())
ifsG = IFS(universe, 1)
for k, value in result.items():
ifsG.set_bykey(k, value)
ifs01 = ifsG
####################################
####################################
plotbar = True
if 'stackbars' in parsed.plot:
plot_bar_Intuitionistic(ifs01)
# plot_together_Intuitionistic(ifs01)
indices, mus, nus, pis = ifs01.elements_split()
triangular = True
if '2dHistogram' in parsed.plot:
plot_triangular(mus, nus, ifs01.get_range(), bins=parsed.number_bins)
# test_legend()
# plot_triangular_with_arrows(ifs01)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#
# plot_membership_3Dhistogram(ifs01,ax, bins=10, typs=['mu','nu'])
#
plot3D = True
if '3dHistogram' in parsed.plot:
plot_3D_histogramm(ifs01, bins=parsed.number_bins)
#plt.axes().set_aspect('equal', 'datalim')
plt.show()
a = 10
print("Inside...")
if __name__ == "__main__":
main()