Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- from save_data import *
- [cells,grid] = load_data('europe_line1_ordered.pkl')
- dt = 4
- month = np.array([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,0])*24/dt
- m = np.zeros(13)
- for i in range(12):
- m[i] = m[i-1]+month[i]
- m = np.int16(m)
- exch = np.zeros(int(8760/dt))
- for cell in cells:
- for neighbour in cells:
- exch += grid.e_exch[cell.name][neighbour.name]
- # for i in range(int(8760/dt)):
- # #print((i+1)/12%2)
- # if (i+1)/(12/dt)%2 >=1:
- # exch[i] = 1
- exch = np.roll(exch,int(4/dt)) # décalle de 4h vers la droite pour commencer au début de la nuit
- night = np.zeros(12)
- day = np.zeros(12)
- for i in range(12):
- month = exch[m[i-1]:m[i]] # echange sur un mois
- for j in range(int(12/dt)):
- tmp = exch[m[i-1]:m[i]][::int(12/dt)] # prend 1 indice toute les 12h
- night[i] += sum(tmp[::2]) #garde un indice sur deux (nuit)
- day[i] += sum(np.roll(tmp,1)[::2]) # shift et ne garde qu'un indice sur deux (day)
- month = np.roll(month,-1) # shift le vecteur du mois pour décaler la fenetre de 1
- plt.figure()
- plt.plot(day,label = 'Day')
- plt.plot(night, label = 'Night')
- plt.title(cell.name)
- plt.legend()
- plt.savefig('img/day_night_'+cell.name)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement