Advertisement
Savelyev_Vyacheslav

RdGraf

Mar 13th, 2022
782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.82 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import time
  4. import os
  5.  
  6. H2 = 100
  7. CH4 = 40
  8. C2H6 = 10
  9. C2H4 = 15
  10. C2H2 = 20
  11.  
  12. GasPPM = [H2, CH4, C2H6, C2H4, C2H2]
  13. setName = ["H2", "CH4", "C2H6", "C2H4", "C2H2"]
  14. def setIn(H2,text):
  15.     try:
  16.         H2.append(float(input(text)))
  17.     except:
  18.         print("Ошибка ввода")
  19.         vvod()
  20.     time.sleep(0.1);
  21.     os.system('cls||clear')
  22. def vvod():
  23.     print("Вводим газы ")
  24.     GasPPM = []
  25.     for item in setName:
  26.         setIn(GasPPM,'   Введите '+item+'>> ')
  27. vvod()
  28.  
  29.  
  30. def PpmToPr(GasPPM):
  31.     arr1 = np.divide(GasPPM, max(GasPPM))
  32.     return list(arr1)
  33.  
  34. ox = [*range(1,6)]
  35. oy = PpmToPr(GasPPM)
  36.  
  37.  
  38. def orderPoint(GasPPM):
  39.     #copyAr=[]
  40.     #copyAr = GasPPM
  41.     aaa = list(zip(GasPPM, [0,1,2,3,4]))
  42.     aaa.sort(reverse=True)
  43.     a,b = zip(*aaa)
  44.     return list(b)
  45.  
  46. def chekD(T2,setVal):
  47.     for item in T2:
  48.         if (item == setVal):
  49.             return 1
  50.     return 0
  51.  
  52. def TypeID(setGaz,setVal):
  53.     i=0
  54.     for item in setGaz:
  55.         if chekD(item,setVal):
  56.             return i
  57.         i += 1
  58.     return -1
  59.  
  60. print(orderPoint(GasPPM))
  61.  
  62. def outD(setVal):
  63.     D1 = [[0, 1, 4, 3, 2]]; PDn = [[0, 1, 2, 3, 4]]; Iskr = [[0, 3, 1, 4, 2]]; Duga = [[0, 4, 3, 1, 2], [4, 0, 1, 3, 2]];
  64.     T2 = [[1, 3, 0, 2, 4],[1, 0, 3, 2, 4],[1, 3, 2, 0, 4]]; T2toPD = [[1, 0, 2, 3, 4]];
  65.     T3 = [[3, 1, 4, 0, 2],[3, 2, 1, 4, 0],[3, 2, 1, 0, 4]]; T3toDuga = [[3, 1, 0, 4, 2]];
  66.     setGaz = [D1, PDn, Iskr, Duga, T2, T2toPD, T3, T3toDuga]
  67.     setName2 = ['D1', 'PDn', 'Iskr', 'Duga', 'T2', 'T2toPD', 'T3', 'T3toDuga']
  68.     Name = TypeID(setGaz,setVal)
  69.     if Name == -1:
  70.         return "None"
  71.     else:
  72.         return setName2[TypeID(setGaz,setVal)]
  73.  
  74.  
  75. print( outD( orderPoint(GasPPM)  ) )
  76.  
  77.  
  78. plt.plot(ox, oy)
  79. plt.show()
  80.  
  81.  
  82.  
  83.  
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement