@@ -24,6 +24,8 matplotlib.pyplot.register_cmap(cmap=ncmap) | |||||
24 |
|
24 | |||
25 | CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'viridis', 'plasma', 'inferno', 'Greys', 'seismic', 'bwr', 'coolwarm', 'spectral')] |
|
25 | CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'viridis', 'plasma', 'inferno', 'Greys', 'seismic', 'bwr', 'coolwarm', 'spectral')] | |
26 |
|
26 | |||
|
27 | EARTH_RADIUS = 6.3710e3 | |||
|
28 | ||||
27 | def ll2xy(lat1, lon1, lat2, lon2): |
|
29 | def ll2xy(lat1, lon1, lat2, lon2): | |
28 |
|
30 | |||
29 | p = 0.017453292519943295 |
|
31 | p = 0.017453292519943295 | |
@@ -33,6 +35,13 def ll2xy(lat1, lon1, lat2, lon2): | |||||
33 | theta = -theta + numpy.pi/2 |
|
35 | theta = -theta + numpy.pi/2 | |
34 | return r*numpy.cos(theta), r*numpy.sin(theta) |
|
36 | return r*numpy.cos(theta), r*numpy.sin(theta) | |
35 |
|
37 | |||
|
38 | def km2deg(km): | |||
|
39 | ''' | |||
|
40 | Convert distance in km to degrees | |||
|
41 | ''' | |||
|
42 | ||||
|
43 | return numpy.rad2deg(km/EARTH_RADIUS) | |||
|
44 | ||||
36 | def figpause(interval): |
|
45 | def figpause(interval): | |
37 | backend = plt.rcParams['backend'] |
|
46 | backend = plt.rcParams['backend'] | |
38 | if backend in matplotlib.rcsetup.interactive_bk: |
|
47 | if backend in matplotlib.rcsetup.interactive_bk: | |
@@ -381,9 +390,9 class PlotData(Operation, Process): | |||||
381 | ymin = self.ymin if self.ymin else numpy.nanmin(self.y) |
|
390 | ymin = self.ymin if self.ymin else numpy.nanmin(self.y) | |
382 | ymax = self.ymax if self.ymax else numpy.nanmax(self.y) |
|
391 | ymax = self.ymax if self.ymax else numpy.nanmax(self.y) | |
383 |
|
392 | |||
384 | Y = numpy.array([5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000]) |
|
393 | Y = numpy.array([1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000]) | |
385 | i = 1 if numpy.where(abs(ymax-ymin) <= Y)[0][0] < 0 else numpy.where(abs(ymax-ymin) <= Y)[0][0] |
|
394 | i = 1 if numpy.where(abs(ymax-ymin) <= Y)[0][0] < 0 else numpy.where(abs(ymax-ymin) <= Y)[0][0] | |
386 | ystep = Y[i] / 5. |
|
395 | ystep = Y[i] / 5. | |
387 |
|
396 | |||
388 | for n, ax in enumerate(self.axes): |
|
397 | for n, ax in enumerate(self.axes): | |
389 | if ax.firsttime: |
|
398 | if ax.firsttime: | |
@@ -1006,6 +1015,7 class PlotPolarMapData(PlotData): | |||||
1006 | self.nrows = 1 |
|
1015 | self.nrows = 1 | |
1007 | self.width = 9 |
|
1016 | self.width = 9 | |
1008 | self.height = 8 |
|
1017 | self.height = 8 | |
|
1018 | self.mode = self.data.meta['mode'] | |||
1009 | if self.channels is not None: |
|
1019 | if self.channels is not None: | |
1010 | self.nplots = len(self.channels) |
|
1020 | self.nplots = len(self.channels) | |
1011 | self.nrows = len(self.channels) |
|
1021 | self.nrows = len(self.channels) | |
@@ -1013,26 +1023,35 class PlotPolarMapData(PlotData): | |||||
1013 | self.nplots = self.data.shape(self.CODE)[0] |
|
1023 | self.nplots = self.data.shape(self.CODE)[0] | |
1014 | self.nrows = self.nplots |
|
1024 | self.nrows = self.nplots | |
1015 | self.channels = range(self.nplots) |
|
1025 | self.channels = range(self.nplots) | |
1016 |
if self. |
|
1026 | if self.mode == 'E': | |
1017 |
self.xlabel = ' |
|
1027 | self.xlabel = 'Longitude' | |
1018 |
self.ylabel = ' |
|
1028 | self.ylabel = 'Latitude' | |
1019 | else: |
|
1029 | else: | |
1020 | self.xlabel = 'Range (km)' |
|
1030 | self.xlabel = 'Range (km)' | |
1021 | self.ylabel = 'Height (km)' |
|
1031 | self.ylabel = 'Height (km)' | |
1022 | self.bgcolor = 'white' |
|
1032 | self.bgcolor = 'white' | |
1023 | self.cb_labels = self.data.meta['units'] |
|
1033 | self.cb_labels = self.data.meta['units'] | |
1024 | # self.polar = True |
|
1034 | self.lat = self.data.meta['latitude'] | |
1025 |
|
1035 | self.lon = self.data.meta['longitude'] | ||
1026 | def plot(self): |
|
1036 | self.xmin, self.xmax = float(km2deg(-50) + self.lon), float(km2deg(50) + self.lon) | |
|
1037 | self.ymin, self.ymax = float(km2deg(-50) + self.lat), float(km2deg(50) + self.lat) | |||
|
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 | |||
|
1041 | # self.polar = True | |||
|
1042 | ||||
|
1043 | def plot(self): | |||
1027 |
|
1044 | |||
1028 | for n, ax in enumerate(self.axes): |
|
1045 | for n, ax in enumerate(self.axes): | |
1029 | data = self.data['param'][self.channels[n]] |
|
1046 | data = self.data['param'][self.channels[n]] | |
1030 |
|
1047 | |||
1031 | zeniths = numpy.linspace(0, self.data.meta['max_range'], data.shape[1]) |
|
1048 | zeniths = numpy.linspace(0, self.data.meta['max_range'], data.shape[1]) | |
1032 |
if self. |
|
1049 | if self.mode == 'E': | |
1033 | azimuths = -numpy.radians(self.data.heights)+numpy.pi/2 |
|
1050 | azimuths = -numpy.radians(self.data.heights)+numpy.pi/2 | |
1034 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
1051 | r, theta = numpy.meshgrid(zeniths, azimuths) | |
1035 | x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])) |
|
1052 | x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])) | |
|
1053 | x = km2deg(x) + self.lon | |||
|
1054 | y = km2deg(y) + self.lat | |||
1036 | else: |
|
1055 | else: | |
1037 | azimuths = numpy.radians(self.data.heights) |
|
1056 | azimuths = numpy.radians(self.data.heights) | |
1038 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
1057 | r, theta = numpy.meshgrid(zeniths, azimuths) | |
@@ -1057,29 +1076,25 class PlotPolarMapData(PlotData): | |||||
1057 | vmax=self.zmax, |
|
1076 | vmax=self.zmax, | |
1058 | cmap=self.cmaps[n]) |
|
1077 | cmap=self.cmaps[n]) | |
1059 |
|
1078 | |||
1060 |
if self. |
|
1079 | if self.mode == 'A': | |
1061 | continue |
|
1080 | continue | |
1062 |
|
1081 | |||
1063 | f = open('/home/jespinoza/workspace/schain_scripts/distrito.csv') |
|
1082 | f = open('/home/jespinoza/workspace/schain_scripts/distrito.csv') | |
1064 |
|
1083 | |||
1065 | lat1 = -11.96 |
|
|||
1066 | lon1 = -76.54 |
|
|||
1067 |
|
||||
1068 | for line in f: |
|
1084 | for line in f: | |
1069 | label, lon, lat = [s.strip() for s in line.split(',') if s] |
|
1085 | label, lon, lat = [s.strip() for s in line.split(',') if s] | |
1070 | lat = float(lat) |
|
1086 | lat = float(lat) | |
1071 | lon = float(lon) |
|
1087 | lon = float(lon) | |
1072 |
|
|
1088 | ax.plot(lon, lat, '.b', ms=2) | |
1073 | ax.plot(x, y, '.b', ms=2) |
|
1089 | ax.text(lon, lat, label.decode('utf8'), ha='center', va='bottom', size='8', color='black') | |
1074 | ax.text(x, y, label.decode('utf8'), ha='center', va='bottom', size='8', color='black') |
|
|||
1075 |
|
1090 | |||
1076 |
|
1091 | |||
1077 |
if self. |
|
1092 | if self.mode == 'E': | |
1078 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) |
|
1093 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) | |
1079 | label = 'E{:d}'.format(int(self.data.meta['elevation'])) |
|
1094 | label = 'E{:02d}'.format(int(self.data.meta['elevation'])) | |
1080 | else: |
|
1095 | else: | |
1081 | title = 'Az={}$^\circ$'.format(self.data.meta['azimuth']) |
|
1096 | title = 'Az={}$^\circ$'.format(self.data.meta['azimuth']) | |
1082 | label = 'A{:d}'.format(int(self.data.meta['azimuth'])) |
|
1097 | label = 'A{:02d}'.format(int(self.data.meta['azimuth'])) | |
1083 |
|
1098 | |||
1084 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] |
|
1099 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] | |
1085 | self.titles = ['{} {}'.format(self.data.parameters[x], title) for x in self.channels] |
|
1100 | self.titles = ['{} {}'.format(self.data.parameters[x], title) for x in self.channels] |
@@ -54,7 +54,7 class PXParametersProc(ProcessingUnit): | |||||
54 | else: |
|
54 | else: | |
55 | self.dataOut.heightList = self.dataOut.data['Elevation'] |
|
55 | self.dataOut.heightList = self.dataOut.data['Elevation'] | |
56 |
|
56 | |||
57 | attrs = ['units', 'elevation', 'azimuth', 'max_range'] |
|
57 | attrs = ['units', 'elevation', 'azimuth', 'max_range', 'latitude', 'longitude'] | |
58 | meta = {} |
|
58 | meta = {} | |
59 |
|
59 | |||
60 | for attr in attrs: |
|
60 | for attr in attrs: |
General Comments 0
You need to be logged in to leave comments.
Login now