@@ -9,6 +9,7 import zmq | |||
|
9 | 9 | import numpy |
|
10 | 10 | import matplotlib |
|
11 | 11 | import matplotlib.pyplot as plt |
|
12 | from matplotlib.patches import Polygon | |
|
12 | 13 | from mpl_toolkits.axes_grid1 import make_axes_locatable |
|
13 | 14 | from matplotlib.ticker import FuncFormatter, LinearLocator, MultipleLocator |
|
14 | 15 | |
@@ -118,6 +119,7 class PlotData(Operation, Process): | |||
|
118 | 119 | self.channels = kwargs.get('channels', None) |
|
119 | 120 | self.titles = kwargs.get('titles', []) |
|
120 | 121 | self.polar = False |
|
122 | self.grid = kwargs.get('grid', False) | |
|
121 | 123 | |
|
122 | 124 | def __fmtTime(self, x, pos): |
|
123 | 125 | ''' |
@@ -392,7 +394,7 class PlotData(Operation, Process): | |||
|
392 | 394 | |
|
393 | 395 | Y = numpy.array([1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000]) |
|
394 | 396 | i = 1 if numpy.where(abs(ymax-ymin) <= Y)[0][0] < 0 else numpy.where(abs(ymax-ymin) <= Y)[0][0] |
|
395 |
ystep = Y[i] / |
|
|
397 | ystep = Y[i] / 10. | |
|
396 | 398 | |
|
397 | 399 | for n, ax in enumerate(self.axes): |
|
398 | 400 | if ax.firsttime: |
@@ -428,6 +430,8 class PlotData(Operation, Process): | |||
|
428 | 430 | ax.cbar.set_label(self.cb_labels[n], size=8) |
|
429 | 431 | else: |
|
430 | 432 | ax.cbar = None |
|
433 | if self.grid: | |
|
434 | ax.grid(True) | |
|
431 | 435 | |
|
432 | 436 | if not self.polar: |
|
433 | 437 | ax.set_xlim(xmin, xmax) |
@@ -1033,11 +1037,8 class PlotPolarMapData(PlotData): | |||
|
1033 | 1037 | self.cb_labels = self.data.meta['units'] |
|
1034 | 1038 | self.lat = self.data.meta['latitude'] |
|
1035 | 1039 | self.lon = self.data.meta['longitude'] |
|
1036 |
self.xmin, self.xmax = float(km2deg( |
|
|
1037 |
self.ymin, self.ymax = float(km2deg( |
|
|
1038 | log.error(type(self.ymin)) | |
|
1039 | #print km2deg(-50) + self.lon, km2deg(50) + self.lon | |
|
1040 | #print km2deg(-50) + self.lat, km2deg(50) + self.lat | |
|
1040 | self.xmin, self.xmax = float(km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon) | |
|
1041 | self.ymin, self.ymax = float(km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat) | |
|
1041 | 1042 | # self.polar = True |
|
1042 | 1043 | |
|
1043 | 1044 | def plot(self): |
@@ -1079,15 +1080,44 class PlotPolarMapData(PlotData): | |||
|
1079 | 1080 | if self.mode == 'A': |
|
1080 | 1081 | continue |
|
1081 | 1082 | |
|
1082 | f = open('/home/jespinoza/workspace/schain_scripts/distrito.csv') | |
|
1083 | ||
|
1083 | # plot district names | |
|
1084 | f = open('/data/workspace/schain_scripts/distrito.csv') | |
|
1084 | 1085 | for line in f: |
|
1085 | 1086 | label, lon, lat = [s.strip() for s in line.split(',') if s] |
|
1086 | 1087 | lat = float(lat) |
|
1087 | 1088 | lon = float(lon) |
|
1088 | ax.plot(lon, lat, '.b', ms=2) | |
|
1089 | # ax.plot(lon, lat, '.b', ms=2) | |
|
1089 | 1090 | ax.text(lon, lat, label.decode('utf8'), ha='center', va='bottom', size='8', color='black') |
|
1090 | ||
|
1091 | ||
|
1092 | # plot limites | |
|
1093 | limites =[] | |
|
1094 | tmp = [] | |
|
1095 | for line in open('/data/workspace/schain_scripts/lima.csv'): | |
|
1096 | if '#' in line: | |
|
1097 | if tmp: | |
|
1098 | limites.append(tmp) | |
|
1099 | tmp = [] | |
|
1100 | continue | |
|
1101 | values = line.strip().split(',') | |
|
1102 | tmp.append((float(values[0]), float(values[1]))) | |
|
1103 | for points in limites: | |
|
1104 | ax.add_patch(Polygon(points, ec='k', fc='none', ls='--', lw=0.5)) | |
|
1105 | ||
|
1106 | # plot Cuencas | |
|
1107 | for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'): | |
|
1108 | f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca)) | |
|
1109 | values = [line.strip().split(',') for line in f] | |
|
1110 | points = [(float(s[0]), float(s[1])) for s in values] | |
|
1111 | ax.add_patch(Polygon(points, ec='b', fc='none')) | |
|
1112 | ||
|
1113 | # plot grid | |
|
1114 | for r in (15, 30, 45, 60): | |
|
1115 | ax.add_artist(plt.Circle((self.lon, self.lat), km2deg(r), color='0.6', fill=False, lw=0.2)) | |
|
1116 | ax.text( | |
|
1117 | self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180), | |
|
1118 | self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180), | |
|
1119 | '{}km'.format(r), | |
|
1120 | ha='center', va='bottom', size='8', color='0.6', weight='heavy') | |
|
1091 | 1121 | |
|
1092 | 1122 | if self.mode == 'E': |
|
1093 | 1123 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) |
General Comments 0
You need to be logged in to leave comments.
Login now