Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1.  
  2. infacted_prediction = []
  3. hump_day = []
  4. for name in names[1:]:
  5. max_num_infacteted = []
  6. hd = []
  7. for j in range(120):
  8.  
  9. y = data[name]
  10. ind = np.where(y < 100)
  11. y = np.delete(y, ind)
  12.  
  13. len_data = len(y)
  14. new_end = j+10
  15. if new_end > len_data-1:
  16. continue
  17.  
  18. y = y[:new_end]
  19.  
  20. len_data = len(y)
  21. x = np.arange(len_data)
  22.  
  23. popt1, pcov = fit(func, x, y)
  24.  
  25. x_off = popt1[1]
  26.  
  27. x_fit = np.linspace(0, 120, 100)
  28.  
  29. if False:
  30. pl.clf()
  31. pl.title(name)
  32. pl.plot(x,y, 'x')
  33. pl.plot(x_fit , func(x_fit, *popt1))
  34. pl.xlim([0, 50])
  35. pl.ylim([0, 200000])
  36. pl.pause(0.2)
  37.  
  38. max_num_infacteted.append(func(100000, *popt1))
  39. hd.append(int(np.abs(popt1[1])))
  40. hump_day.append(hd)
  41. infacted_prediction.append(max_num_infacteted)
  42.  
  43.  
  44. count = 0
  45. for name in names[1:]:
  46.  
  47. infected_pred = infacted_prediction[count][-1]
  48. infected_curr = data[name][-1]
  49. conver = np.nansum(np.gradient(infacted_prediction[count][-7:]))/7
  50. mean = np.nanmean(infacted_prediction[count][-3:])
  51.  
  52. print(int(infected_curr),'\t', int(infected_pred),'\t', int(mean), '\t', int(np.abs(conver / len(infacted_prediction[count]))),'\t',name )
  53. count += 1
  54.  
  55. pl.clf()
  56. count = 0
  57. for name in names[1:]:
  58.  
  59. pl.subplot(2,4,count+1)
  60.  
  61. pl.title(name)
  62.  
  63. pl.plot(infacted_prediction[count], label=name)
  64.  
  65. if not ( count == 0 or count == 4 ):
  66. pl.yticks([])
  67.  
  68. count += 1
  69. pl.xlim([0, 50])
  70. pl.ylim([0, 500000])
  71.  
  72. pl.show()
  73.  
  74. pl.clf()
  75. count = 0
  76. for name in names[1:]:
  77.  
  78. pl.subplot(2,4,count+1)
  79.  
  80. pl.title(name)
  81.  
  82. #pl.plot(np.array(range(len(hump_day[count])))+10, hump_day[count], label=name)
  83. pl.plot(np.array(range(len(hump_day[count]))) + 10, np.abs(np.gradient(hump_day[count])), color='r', label=name)
  84.  
  85. if not ( count == 0 or count == 4 ):
  86. pl.yticks([])
  87.  
  88. count += 1
  89. pl.xlim([0, 50])
  90. pl.ylim([0, 20])
  91.  
  92. pl.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement