Advertisement
MagicWinnie

Untitled

Mar 14th, 2020
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. import numpy as np
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4.  
  5.  
  6. path = "forecasts.csv"
  7.  
  8. df = pd.read_csv(path, encoding = "utf8")
  9.  
  10. gens = {
  11. "Солнце 50%": (3, [5, 10, 10]),
  12. "Ветер 50%": (1, [10])
  13. }
  14. cons = {
  15. "Больницы 50%": (2, [7, 5]),
  16. "Заводы 50%": (2, [8, 7]),
  17. "Дома 50%": (6, [8, 7, 8, 5, 8, 8])
  18. }
  19.  
  20. total_gen = 0
  21. total_con = 0
  22.  
  23.  
  24. array_gen = []
  25. array_con = []
  26.  
  27. array_gen_cost = []
  28. array_con_cost = []
  29.  
  30.  
  31. for i in range(len(df)):
  32. total_gen = 0
  33. total_con = 0
  34.  
  35. gen_cost = 0
  36. con_cost = 0
  37. for j in gens:
  38. total_gen += gens[j][0]*df[j][i]
  39. for k in range(len(gens[j][1])):
  40. gen_cost += gens[j][1][k]
  41. if i in list(range(0,20)) or i in list(range(40, 66)):
  42. total_gen += 10
  43. gen_cost += 40
  44. for j in cons:
  45. total_con += cons[j][0]*df[j][i]
  46. for k in range(len(cons[j][1])):
  47. con_cost += cons[j][1][k]
  48. array_gen.append(total_gen)
  49. array_con.append(total_con)
  50.  
  51. array_gen_cost.append(gen_cost)
  52. array_con_cost.append(con_cost)
  53.  
  54.  
  55. fig, ax = plt.subplots()
  56.  
  57. ax.plot(array_con, '-b', label="Consumed")
  58. ax.plot(array_gen, '-g', label="Generated")
  59. ax.legend()
  60.  
  61. plt.show()
  62.  
  63.  
  64. fig, ax = plt.subplots()
  65.  
  66. ax.plot(array_con_cost, '-b', label="Consumed")
  67. ax.plot(array_gen_cost, '-g', label="Generated")
  68. ax.legend()
  69.  
  70. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement