##// END OF EJS Templates
Change AER to Geodetic coordinates in PX plots
jespinoza -
r1145:e6529314b4b0
parent child
Show More
@@ -24,6 +24,8 matplotlib.pyplot.register_cmap(cmap=ncmap)
24 24
25 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 29 def ll2xy(lat1, lon1, lat2, lon2):
28 30
29 31 p = 0.017453292519943295
@@ -33,6 +35,13 def ll2xy(lat1, lon1, lat2, lon2):
33 35 theta = -theta + numpy.pi/2
34 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 45 def figpause(interval):
37 46 backend = plt.rcParams['backend']
38 47 if backend in matplotlib.rcsetup.interactive_bk:
@@ -381,7 +390,7 class PlotData(Operation, Process):
381 390 ymin = self.ymin if self.ymin else numpy.nanmin(self.y)
382 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 394 i = 1 if numpy.where(abs(ymax-ymin) <= Y)[0][0] < 0 else numpy.where(abs(ymax-ymin) <= Y)[0][0]
386 395 ystep = Y[i] / 5.
387 396
@@ -1006,6 +1015,7 class PlotPolarMapData(PlotData):
1006 1015 self.nrows = 1
1007 1016 self.width = 9
1008 1017 self.height = 8
1018 self.mode = self.data.meta['mode']
1009 1019 if self.channels is not None:
1010 1020 self.nplots = len(self.channels)
1011 1021 self.nrows = len(self.channels)
@@ -1013,14 +1023,21 class PlotPolarMapData(PlotData):
1013 1023 self.nplots = self.data.shape(self.CODE)[0]
1014 1024 self.nrows = self.nplots
1015 1025 self.channels = range(self.nplots)
1016 if self.data.meta['mode'] == 'E':
1017 self.xlabel = 'Zonal Distance (km)'
1018 self.ylabel = 'Meridional Distance (km)'
1026 if self.mode == 'E':
1027 self.xlabel = 'Longitude'
1028 self.ylabel = 'Latitude'
1019 1029 else:
1020 1030 self.xlabel = 'Range (km)'
1021 1031 self.ylabel = 'Height (km)'
1022 1032 self.bgcolor = 'white'
1023 1033 self.cb_labels = self.data.meta['units']
1034 self.lat = self.data.meta['latitude']
1035 self.lon = self.data.meta['longitude']
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
1024 1041 # self.polar = True
1025 1042
1026 1043 def plot(self):
@@ -1029,10 +1046,12 class PlotPolarMapData(PlotData):
1029 1046 data = self.data['param'][self.channels[n]]
1030 1047
1031 1048 zeniths = numpy.linspace(0, self.data.meta['max_range'], data.shape[1])
1032 if self.data.meta['mode'] == 'E':
1049 if self.mode == 'E':
1033 1050 azimuths = -numpy.radians(self.data.heights)+numpy.pi/2
1034 1051 r, theta = numpy.meshgrid(zeniths, azimuths)
1035 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 1055 else:
1037 1056 azimuths = numpy.radians(self.data.heights)
1038 1057 r, theta = numpy.meshgrid(zeniths, azimuths)
@@ -1057,29 +1076,25 class PlotPolarMapData(PlotData):
1057 1076 vmax=self.zmax,
1058 1077 cmap=self.cmaps[n])
1059 1078
1060 if self.data.meta['mode'] == 'A':
1079 if self.mode == 'A':
1061 1080 continue
1062 1081
1063 1082 f = open('/home/jespinoza/workspace/schain_scripts/distrito.csv')
1064 1083
1065 lat1 = -11.96
1066 lon1 = -76.54
1067
1068 1084 for line in f:
1069 1085 label, lon, lat = [s.strip() for s in line.split(',') if s]
1070 1086 lat = float(lat)
1071 1087 lon = float(lon)
1072 x, y = ll2xy(lat1, lon1, lat, lon)
1073 ax.plot(x, y, '.b', ms=2)
1074 ax.text(x, y, label.decode('utf8'), ha='center', va='bottom', size='8', color='black')
1088 ax.plot(lon, lat, '.b', ms=2)
1089 ax.text(lon, lat, label.decode('utf8'), ha='center', va='bottom', size='8', color='black')
1075 1090
1076 1091
1077 if self.data.meta['mode'] == 'E':
1092 if self.mode == 'E':
1078 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 1095 else:
1081 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 1099 self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels]
1085 1100 self.titles = ['{} {}'.format(self.data.parameters[x], title) for x in self.channels]
@@ -54,7 +54,7 class PXParametersProc(ProcessingUnit):
54 54 else:
55 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 58 meta = {}
59 59
60 60 for attr in attrs:
General Comments 0
You need to be logged in to leave comments. Login now