示例#1
0
        idxs.append(data[(data >= tranches[t])
                         & (data < tranches[t + 1])].index)
    return idxs


cmap = plt.get_cmap('plasma')
tranches_size = [0, 1, 7, 9, 10, 11]
idxs = get_idx_tranches(tranches_size, iris_poly.AU_SIZE)
f, ax = plt.subplots()
for i in range(len(idxs)):
    ps = util.list_polygons(polygons, idxs[i])
    util.plot_polygons(ps, color=cmap(i / (len(idxs) - 1)), ax=ax)
plt.title('Taille Aire Urbaine')
labels = ['Rural', 'AU<100k', '100k<AU<500k', '500k<AU', 'Paris']
cols = cmap([i / (len(idxs) - 1) for i in range(len(idxs))])
util.aspect_carte_france(ax, palette=cols, labels=labels)
#ax.set_title('Population of Urban Area (AU)')
plt.xticks([])
plt.yticks([])
f.set_size_inches(4.67, 4.06)
plt.tight_layout()
plt.savefig(r'c:\user\U546416\Pictures\SS - results\Thesis\aireUrbaine.pdf')
plt.savefig(r'c:\user\U546416\Pictures\SS - results\Thesis\aireUrbaine.jpg',
            dpi=300)

#%% Plot 2 according to Category of commune:
# Grand pole = 111
# peri urban = 112-120
# small pole = 200-300
# rural = 400
tranches_cat = [100, 111.5, 200, 400, 500]
示例#2
0
        if r.status_code == 200:
            if 'nom' in r.json()[0]:
                GRD.loc[i] = r.json()[0]['nom']    
    
    
    GRDnull = GRD[GRD.isnull()]




#%%
palette=['b','g','yellow','violet','purple','y','mediumslateblue','orange', 'c', 'silver']
f,ax= plt.subplots()
i=0

dsos = ['Enedis', 'GEREDIS Deux-Sèvres', 'SRD', 
        'URM (Metz)', 'Electricité de Strasbourg',
        'RSE - Régie Services Energie','Gaz électricité de Grenoble', 
        'SICAE-Oise', 'SICAE-Est',
        'Autres']

for dso in dsos:
    if dso == 'Autres':
        ies = iris_poly[iris_poly.GRD.isin(dsos[:-1]) == False].index
    else:
        ies = iris_poly[iris_poly.GRD == dso].index
    polys = [p for pp in ies for p in polygons[pp]]
    util.plot_polygons(polys, facecolor=palette[i], ax=ax, label=dso)
    i=i+1
util.aspect_carte_france(ax, palette=palette, labels=dsos)
示例#3
0
]

ssidf = SS[(SS.GRD == 'Enedis') & (SS.Departement.isin(util.deps_idf))].index
polys_idf = util.list_polygons(polygons_ss, ssidf)
colors_idf = [
    palette[max(0, int((SS_load['SSCharge[pu]'][ss] - 0.5) // 0.1))]
    for ss in ssidf for p in polygons_ss[ss]
]
#%%
labels = [
    str(ranges[i]) + '<PeakLoad<' + str(ranges[i + 1])
    for i in range(len(ranges) - 1)
]
ax1 = util.plot_polygons(polyss,
                         facecolors=colorss,
                         edgecolors='k',
                         linewidth=0.2)
ax2 = util.plot_polygons(polys_idf,
                         facecolors=colors_idf,
                         edgecolors='k',
                         linewidth=0.2)
util.aspect_carte_france(ax1, palette=palette, labels=labels)
util.aspect_carte_france(ax2, palette=palette, labels=labels, cns='idf')
#%% Save
#SS_profile.to_csv('SS_profiles.csv') #This is (way) too heavy (600MB, over 45s to load)
#SS_load.to_excel('SS_load.xlsx')

#%% Saving profiles one by one in a dedicated folder
folder = r'c:\user\U546416\Documents\PhD\Data\Mobilité\Data_Traitee\Conso\SS_profiles\\'
for ss in SS_profile:
    SS_profile[[ss]].to_csv(folder + ss + '.csv')
示例#4
0
polys = util.list_polygons(polygons, ies)
cmap = plt.get_cmap('YlOrRd')
pmax = 0.3
xpalette = np.arange(0, pmax, 0.05)
palette = cmap(xpalette / pmax)
labels = ['{}%'.format(int(i * 100)) for i in xpalette]

for c in cases:
    colors = cmap([
        data[c].IncreasePeak_pu[iris.SS[i]] / pmax for i in ies
        for p in polygons[i]
    ])

    f, ax = plt.subplots()
    util.plot_polygons(polys, color=colors, ax=ax)
    util.aspect_carte_france(ax, palette=palette, labels=labels)
    plt.xticks([])
    plt.yticks([])
    f.set_size_inches(4.67, 4.06)
    plt.tight_layout()

    plt.savefig(
        r'c:\user\U546416\Pictures\SS - results\Thesis\SSFR_incpeak_{}.pdf'.
        format(name[c]))
    plt.savefig(
        r'c:\user\U546416\Pictures\SS - results\Thesis\SSFR_incpeak_{}.jpg'.
        format(name[c]),
        dpi=300)

#%% plot increase in peak load brute force - IdF
polys = util.list_polygons(polygons, iesidf)
#%% plot PV installed per departement
pv_inst = dep_parc_prod.groupby('Code Département')['Puissance MW'].sum()
cmap = plt.get_cmap('plasma')
polys = util.list_polygons(util.do_polygons(dep_polys, plot=False),
                           dep_polys.index)
color = cmap([
    pv_inst[d] / pv_inst.max() for d in pv_inst.index
    for p in dep_polys.Polygon[d]
])

ax = util.plot_polygons(polys, color=color)
tranches = np.arange(0, 7, 1) * 100
labels = ['{:3} MW'.format(t) for t in tranches]
palette = list(cmap([i / 600 for i in tranches]))
util.aspect_carte_france(ax,
                         title='PV Installed capacity',
                         palette=palette,
                         labels=labels)

#%% plot PV per installed per type (tranche)

print('Loading Conso per IRIS')
#folder_consodata = r'c:\user\U546416\Documents\PhD\Data\Mobilité\Data_Traitee\Conso'
#iris = pd.read_csv(folder_consodata + r'\IRIS_enedis_2017.csv',
#                    engine='python', index_col=0)

pv_dep = dep_parc_prod.groupby(['DEP_CODE', 'TRANCHE']).P_MW.sum()
pv_inst_perc = pv_dep / dep_parc_prod.groupby(['DEP_CODE']).P_MW.sum()

for i in dep_parc_prod.TYPE_PV.unique():
    cmap = plt.get_cmap('plasma')
    color = cmap([
示例#6
0
avgh = (hhome.loc[nevsh.index] * bins).sum(axis=1) / nevsh
avgw = (hwork.loc[nevsw.index] * bins).sum(axis=1) / nevsw

#%% Plot using colormap

idxs = comm2019.CODE_COMM_2019[nevsh.index].dropna()
idxs = idxs[idxs.isin(polygons_comm)]
cmap = plt.get_cmap('plasma')
polys = util.list_polygons(polygons_comm, idxs)
colors = cmap([avgh[i]/50 for i in idxs.index for p in polygons_comm[idxs[i]]])

ax = util.plot_polygons(polys, color=colors)
tranches = [10, 30, 50, 70, 90]
labels = ['{:3}km<d<{:3}km'.format(str(t-10),str(t+10)) for t in tranches]
palette = list(cmap([i/100 for i in tranches]))
util.aspect_carte_france(ax, title='Average daily commuting distance [km]\n by commune of residence', palette=palette, labels=labels)

#%% Plot using green-blue-red palette
palette = ['b','lightgreen', 'forestgreen', 'khaki', 'gold', 'orange', 'r']
wbin = 15 #km of daily distance
tranches = [i*wbin for i in range(len(palette))]
labels = ['{:3}km<d<{:3}km'.format(str(t),str(t+wbin)) for t in tranches]
labels[-1] = labels[-1][:-6]

colors = [palette[min(int(avgh[i]/(wbin/2)), len(palette)-1)] for i in idxs.index for p in polygons_comm[idxs[i]]]
ax = util.plot_polygons(polys, facecolor=colors)
#util.aspect_carte_france(ax, title='Average daily commuting distance [km]\n by commune of residence', palette=palette, labels=labels)

util.aspect_carte_france(ax, palette=palette, labels=labels)
plt.tick_params(left=False,
                bottom=False,
示例#7
0
]
collectionA = PatchCollection(polyA, facecolors='r', label='Activité')
collectionH = PatchCollection(polyH, facecolors='b', label='Habitation')
collectionD = PatchCollection(polyD, facecolors='silver', label='Divers')
collectionZ = PatchCollection(polyZ, facecolors='g', label='Rural')

f, ax = plt.subplots()
ax.add_collection(collectionA)
ax.add_collection(collectionZ)
ax.add_collection(collectionD)
ax.add_collection(collectionH)
ax.autoscale()
plt.legend()

util.aspect_carte_france(ax=ax,
                         labels=['Habitation', 'Activité', 'Rural', 'Divers'],
                         palette=['b', 'r', 'g', 'silver'])

#%% Compute histograms per SS
print('Computing histograms per SS')
SS_hhome = {}
SS_hwork = {}
i = 0

hh = hhome.drop(['ZE', 'Status', 'UU', 'Dep'], axis=1)
hw = hwork.drop(['ZE', 'Status', 'UU', 'Dep'], axis=1)

#
print('Starting')
for ss in SS[SS.GRD == 'Enedis'].index:
    i += 1