Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np # мадуль для массива
- import matplotlib.pyplot as plt # для графиков
- step = 1 # шаг
- end = 100 # сторона треугольника
- def makeTryAngl(step, end_): # создает все точки на треугольнике формат Дюваля массив []
- arTotal = []
- for i in np.arange(0, end_+1, step):
- for j in np.arange(0, end_+1, step):
- x = end_ - round(i,1)
- y = round(j,2)
- bary = end_-x-y
- if bary >= 0:
- x = end_ - round(i,1)
- y = round(j,2)
- z = end_ - x - y
- arTotal.append([x,y,z])
- return arTotal
- def DuvToCoor(TryAngl): # меняет формат точек из дюваля в классический (Х и У) формат массив
- Draw = []
- for item in TryAngl:
- y = item[1]*3**0.5/2
- x = end - item[0] - item[1]*0.5
- Draw.append([x,y])
- return Draw
- def CATsection(TryAngl, x1,x2, y1,y2, z1,z2): # вырезает куски графика где x1 начало х2 конец
- leg=[]
- for item in TryAngl:
- if (item[0] >= x1 and item[0] <= x2) and (item[1] >= y1 and item[1] <= y2) and (item[2] >= z1 and item[2] <= z2):
- leg.append(tuple(item))
- return set(leg)
- def graf(TryAngl, color_="none"): # отрисовывет на графике массив точек
- font1 = {'family':'serif','color':'blue','size':20}
- font2 = {'family':'serif','color':'darkred','size':15}
- plt.title("DuvalTriAngle", fontdict = font1)
- plt.xlabel("C2H2", fontdict = font2)
- plt.ylabel("CH4", fontdict = font2)
- z = 3**0.5/2; p = 5
- # os Y
- plt.text(0, 10*z, "10"); plt.text(p, 20*z, "20"); plt.text(2*p, 30*z, "30")
- plt.text(3*p, 40*z, "40"); plt.text(4*p, 50*z, "50"); plt.text(5*p, 60*z, "60"); plt.text(6*p, 70*z, "70")
- plt.text(7*p, 80*z, "80"); plt.text(8*p, 90*z, "90"); plt.text(9*p, 101*z, "100");
- # os Z
- plt.text(102-p, 10*z, "90"); plt.text(102-2*p, 20*z, "80"); plt.text(102-3*p, 30*z, "70")
- plt.text(102-4*p, 40*z, "60"); plt.text(102-5*p, 50*z, "50"); plt.text(102-6*p, 60*z, "40")
- plt.text(102-7*p, 70*z, "30"); plt.text(102-8*p, 80*z, "20"); plt.text(102-9*p, 90*z, "10");
- #Ось X
- ds=-3.5
- plt.text(-3, ds, "0"); plt.text(10, ds, "10"); plt.text(20, ds, "20")
- plt.text(30, ds, "30"); plt.text(40, ds, "40"); plt.text(50, ds, "50"); plt.text(60, ds, "60")
- plt.text(70, ds, "70"); plt.text(80, ds, "80"); plt.text(90, ds, "90"); plt.text(100, ds, "100");
- Draw = DuvToCoor(TryAngl)
- frame = plt.gca()
- frame.axes.get_xaxis().set_ticks([])
- frame.axes.get_yaxis().set_ticks([])
- plt.yticks(rotation=-30)
- plt.tick_params(axis='y', which='both', labelleft=False, labelright=True)
- x1, y1 = zip(*Draw); x1 = list(x1); y1 = list(y1)
- if color_ == "none":
- plt.plot(x1, y1)
- else:
- plt.plot(x1, y1, color = color_)
- def grafPtr(x,y,z): # отрисовывет на графике точку
- pp = 100/(x+y+z)
- Draw = DuvToCoor([[x*pp,y*pp,z*pp]])
- x1, y1 = zip(*Draw); x1 = list(x1); y1 = list(y1)
- plt.plot(x1, y1,color = "black", marker = "o", linestyle= "--", linewidth = 1, markersize = 4)
- def grafPtr2(x,y,z): # отрисовывет на графике точку
- pp = 100/(x+y+z)
- Draw = DuvToCoor([[x*pp,y*pp,z*pp]])
- x1, y1 = zip(*Draw); x1 = list(x1); y1 = list(y1)
- plt.plot(x1, y1,color = "blue", marker = "x", linestyle= "--"'D1', 'PD', 'T1', 'T2', 'T3', 'D2', 'D2', 'DT', 'DT', 'DT']
- def ALL():
- graf(D2_1,'orange')
- graf(D2_2, 'orange')
- graf(T3, "#f3f")
- graf(T2, '#f00')
- graf(T1, "#3fc")
- graf(PD, "#099")
- graf(D1, "#666")
- graf(DT_1, '#75ff89')
- graf(DT_2, '#75ff89')
- graf(DT_3, '#75ff89')
- def Find(C2H2,CH4,C2H4, ArAll, AllName):
- j=0
- pp = 100/(C2H2+CH4+C2H4)
- C2H2 = round(C2H2*pp, 0)
- CH4 = round(CH4*pp, 0)
- C2H4 = round(C2H4*pp, 0)
- for i in ArAll:
- if(C2H2,CH4,C2H4) in i:
- print(AllName[j])
- j+=1
- Mimo={(43,33,9,23,1),(70,1,0,29,9),(70,5,3,9,25,6),(37,29,6,33,3),(35,7,35,7,28,6),(68,5,16,7,14,8),(14,60,5,25,6),(0,45,4,54,6),(0,98,4,1,6),(4,6,71,1,24,3),(0,98,2),(0,48,7,51,3),(0,6,39,8,59,6),(1,3,52,7,46)}
- Popal={(0,100,0),(0,5,99,1,0,5),(0,100,0),(0,100,0),(0,7,98,7,0,6),(0,2,99,7,0,1),(0,99,7,0,3),(0,1,99,8,0,1),(0,99,9,0,1),(45,9,32,8,21,3),(67,5,12,5,20,1),(93,8,1,2,5,1),(78,5,17),(63,6,15,21,4),(61,8,16,8,21,4),(22,2,55,6,22,2),(65,16,7,18,3),(74,13,8,12,1),(75,9,10,9,13,1),(67,2,20,1,12,7),(20,62,9,17,1),(58,5,22,1,19,5),(57,1,33,4,9,5),(59,1,19,4,21,5),(54,8,34,2,11),(59,21,2,19,8),(32,1,47,8,20,1),(40,3,37,8,21,9),(86,7,1,7,11,7),(86,2,3,2,10,7),(65,8,7,7,26,4),(56,3,13,30,7),(54,2,16,5,29,3),(47,8,20,1,32,1),(45,8,24,9,29,3),(39,9,32,7,27,4),(32,5,43,3,24,1),(49,2,16,2,34,6),(42,1,21,37),(28,2,39,9,31,8),(27,6,41,7,30,8),(38,8,23,5,37,7),(22,4,44,2,33,5),(45,2,28,8,26),(59,4,14,26,6),(50,25,25),(46,4,29,9,23,7),(44,4,16,7,38,9),(51,3,19,29,7),(40,9,26,6,32,4),(33,5,26,40,4),(47,3,27,3,25,5),(29,40,1,30,9),(44,7,10,6,44,7),(35,2,30,8,34,1),(49,3,15,8,34,9),(46,30,24),(50,6,15,8,33,5),(36,4,28,3,35,4),(33,9,30,4,35,7),(47,5,14,4,38,1),(58,8,15,7,25,5),(29,35,5,35,5),(57,6,13,1,29,3),(31,6,20,6,47,8),(32,2,39,3,28,4),(55,3,13,7,31),(42,1,21,8,36,2),(35,7,30,9,33,3),(40,28,7,31,3),(36,4,28,6,35),(24,42,2,33,9),(29,9,35,4,34,8),(33,3,36,4,30,3),(42,5,27,5,30),(45,7,19,3,35),(0,2,71,2,28,7),(0,2,52,8,46,9),(1,69,4,29,6),(3,1,84,4,12,5),(0,81,8,18,2),(0,89,6,10,4),(1,7,95,6,2,7),(0,1,71,9,28),(1,5,58,3,40,2),(1,9,84,6,13,5),(0,40,1,59,9),(2,6,36,3,61,1),(0,7,44,55,3),(2,34,1,63,9),(0,43,7,56,2),(9,3,28,8,61,9),(1,1,44,4,54,5),(11,8,23,7,64,5),(0,2,10,3,89,5),(1,2,22,7,76),(2,2,32,7,65,1),(10,6,37,1,52,2),(8,2,37,3,54,4),(5,3,7,87,7),(1,5,28,7,69,8),(0,5,39,60,5)}
- ALL()
- for item in Popal:
- grafPtr2(item[0],item[1],item[2])
- for item in Mimo:
- grafPtr(item[0],item[1],item[2])
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement