Advertisement
Guest User

Untitled

a guest
May 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from save_data import *
  4.  
  5. [cells,grid] = load_data('europe_line1_ordered.pkl')
  6.  
  7. dt = 4
  8. month = np.array([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,0])*24/dt
  9. m = np.zeros(13)
  10. for i in range(12):
  11.     m[i] = m[i-1]+month[i]
  12. m = np.int16(m)
  13.  
  14. exch = np.zeros(int(8760/dt))
  15. for cell in cells:
  16.     for neighbour in cells:
  17.         exch += grid.e_exch[cell.name][neighbour.name]
  18.     # for i in range(int(8760/dt)):
  19.     #     #print((i+1)/12%2)
  20.     #     if (i+1)/(12/dt)%2 >=1:
  21.     #         exch[i] = 1
  22.     exch = np.roll(exch,int(4/dt)) # décalle de 4h vers la droite pour commencer au début de la nuit
  23.     night = np.zeros(12)
  24.     day = np.zeros(12)
  25.     for i in range(12):
  26.         month = exch[m[i-1]:m[i]] # echange sur un mois
  27.         for j in range(int(12/dt)):
  28.             tmp = exch[m[i-1]:m[i]][::int(12/dt)] # prend 1 indice toute les 12h
  29.             night[i] += sum(tmp[::2]) #garde un indice sur deux (nuit)
  30.             day[i] += sum(np.roll(tmp,1)[::2]) # shift et ne garde qu'un indice sur deux (day)
  31.             month = np.roll(month,-1) # shift le vecteur du mois pour décaler la fenetre de 1
  32.    
  33.     plt.figure()
  34.     plt.plot(day,label = 'Day')
  35.     plt.plot(night, label = 'Night')
  36.     plt.title(cell.name)
  37.     plt.legend()
  38.     plt.savefig('img/day_night_'+cell.name)
  39. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement