| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- # -*- coding: utf-8 -*-
- """
- Created on Wed Jul 11 09:28:46 2018
- @author: BI4
- """
- import matplotlib.patches as mpatches
- import matplotlib.pyplot as plt
- from mpl_toolkits.basemap import Basemap
- def plotMCT(flujos_inter):
- plt.figure(figsize=(24, 12))
- _map = Basemap(projection='merc',
- resolution='l',
- llcrnrlon=-93, llcrnrlat=7,
- urcrnrlon=-75, urcrnrlat=19)
- _map.drawcoastlines()
- _map.drawcountries(linewidth=1)
- _map.drawmapboundary(fill_color='#99ffff')
- _map.fillcontinents(color='#cc9966', lake_color='#99ffff')
- _lons = [-90.25, -88.9167, -86.5, -85, -84, -81]
- _lats = [15.5, 13.7, 15, 13, 10, 8.2]
- _inter = {'GUAESA': [0, 1, '{0} MW'],
- 'GUAHON': [0, 2, '{0} MW'],
- 'ESAHON': [1, 2, '{0} MW'],
- 'HONNIC': [2, 3, '{0} MW'],
- 'NICCRC': [3, 4, '{0} MW'],
- 'CRCPAN': [4, 5, '{0} MW']}
- _x, _y = _map(_lons, _lats)
- for i in _inter:
- a = [_x[_inter[i][0]], _x[_inter[i][1]]]
- b = [_y[_inter[i][0]], _y[_inter[i][1]]]
- if flujos_inter[i][1] >= flujos_inter[i][2] or flujos_inter[i][1] <= flujos_inter[i][0]:
- color = 'orangered'
- elif flujos_inter[i][1] >= 0.8*flujos_inter[i][2] or flujos_inter[i][1] <= 0.8*flujos_inter[i][0]:
- color = 'yellow'
- else:
- color = 'green'
- plt.plot(a, b, '-', color=color, linewidth=3, label=_inter[i][2])
- plt.text(sum(a)/2, sum(b)/2, '{:.2f} MW'.format(flujos_inter[i][1]*100),
- fontdict={'fontsize': 12,
- 'backgroundcolor': '#cc9966', 'fontweight': 'bold'},
- horizontalalignment='center',
- verticalalignment='center',)
- _map.plot(_x, _y, 'o', color='navy', markersize=18)
- red_patch = mpatches.Patch(
- color='red', label='Interconexión al 100% de capacidad')
- yellow_patch = mpatches.Patch(
- color='yellow', label='Interconexión a mas del 80% de capacidad')
- green_patch = mpatches.Patch(
- color='green', label='Interconexión a menos del 80% de capacidad')
- plt.legend(handles=[red_patch, yellow_patch,
- green_patch], loc=3, fontsize=16)
- plt.suptitle('Flujos entre Áreas de Control',
- fontsize=18, fontweight='bold')
- plt.show()
|