The requested changes are too big and content was truncated. Show full diff
@@ -1,678 +1,678 | |||||
1 | import os |
|
1 | import os | |
2 | import datetime |
|
2 | import datetime | |
3 | import numpy |
|
3 | import numpy | |
4 |
|
4 | |||
5 | from schainpy.model.graphics.jroplot_base import Plot, plt |
|
5 | from schainpy.model.graphics.jroplot_base import Plot, plt | |
6 | from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot |
|
6 | from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot | |
7 | from schainpy.utils import log |
|
7 | from schainpy.utils import log | |
8 | # libreria wradlib |
|
8 | # libreria wradlib | |
9 | import wradlib as wrl |
|
9 | import wradlib as wrl | |
10 |
|
10 | |||
11 | EARTH_RADIUS = 6.3710e3 |
|
11 | EARTH_RADIUS = 6.3710e3 | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | def ll2xy(lat1, lon1, lat2, lon2): |
|
14 | def ll2xy(lat1, lon1, lat2, lon2): | |
15 |
|
15 | |||
16 | p = 0.017453292519943295 |
|
16 | p = 0.017453292519943295 | |
17 | a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \ |
|
17 | a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \ | |
18 | numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2 |
|
18 | numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2 | |
19 | r = 12742 * numpy.arcsin(numpy.sqrt(a)) |
|
19 | r = 12742 * numpy.arcsin(numpy.sqrt(a)) | |
20 | theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p) |
|
20 | theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p) | |
21 | * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p)) |
|
21 | * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p)) | |
22 | theta = -theta + numpy.pi/2 |
|
22 | theta = -theta + numpy.pi/2 | |
23 | return r*numpy.cos(theta), r*numpy.sin(theta) |
|
23 | return r*numpy.cos(theta), r*numpy.sin(theta) | |
24 |
|
24 | |||
25 |
|
25 | |||
26 | def km2deg(km): |
|
26 | def km2deg(km): | |
27 | ''' |
|
27 | ''' | |
28 | Convert distance in km to degrees |
|
28 | Convert distance in km to degrees | |
29 | ''' |
|
29 | ''' | |
30 |
|
30 | |||
31 | return numpy.rad2deg(km/EARTH_RADIUS) |
|
31 | return numpy.rad2deg(km/EARTH_RADIUS) | |
32 |
|
32 | |||
33 |
|
33 | |||
34 |
|
34 | |||
35 | class SpectralMomentsPlot(SpectraPlot): |
|
35 | class SpectralMomentsPlot(SpectraPlot): | |
36 | ''' |
|
36 | ''' | |
37 | Plot for Spectral Moments |
|
37 | Plot for Spectral Moments | |
38 | ''' |
|
38 | ''' | |
39 | CODE = 'spc_moments' |
|
39 | CODE = 'spc_moments' | |
40 | # colormap = 'jet' |
|
40 | # colormap = 'jet' | |
41 | # plot_type = 'pcolor' |
|
41 | # plot_type = 'pcolor' | |
42 |
|
42 | |||
43 | class DobleGaussianPlot(SpectraPlot): |
|
43 | class DobleGaussianPlot(SpectraPlot): | |
44 | ''' |
|
44 | ''' | |
45 | Plot for Double Gaussian Plot |
|
45 | Plot for Double Gaussian Plot | |
46 | ''' |
|
46 | ''' | |
47 | CODE = 'gaussian_fit' |
|
47 | CODE = 'gaussian_fit' | |
48 | # colormap = 'jet' |
|
48 | # colormap = 'jet' | |
49 | # plot_type = 'pcolor' |
|
49 | # plot_type = 'pcolor' | |
50 |
|
50 | |||
51 | class DoubleGaussianSpectraCutPlot(SpectraCutPlot): |
|
51 | class DoubleGaussianSpectraCutPlot(SpectraCutPlot): | |
52 | ''' |
|
52 | ''' | |
53 | Plot SpectraCut with Double Gaussian Fit |
|
53 | Plot SpectraCut with Double Gaussian Fit | |
54 | ''' |
|
54 | ''' | |
55 | CODE = 'cut_gaussian_fit' |
|
55 | CODE = 'cut_gaussian_fit' | |
56 |
|
56 | |||
57 | class SnrPlot(RTIPlot): |
|
57 | class SnrPlot(RTIPlot): | |
58 | ''' |
|
58 | ''' | |
59 | Plot for SNR Data |
|
59 | Plot for SNR Data | |
60 | ''' |
|
60 | ''' | |
61 |
|
61 | |||
62 | CODE = 'snr' |
|
62 | CODE = 'snr' | |
63 | colormap = 'jet' |
|
63 | colormap = 'jet' | |
64 |
|
64 | |||
65 | def update(self, dataOut): |
|
65 | def update(self, dataOut): | |
66 |
|
66 | |||
67 | data = { |
|
67 | data = { | |
68 | 'snr': 10*numpy.log10(dataOut.data_snr) |
|
68 | 'snr': 10*numpy.log10(dataOut.data_snr) | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | return data, {} |
|
71 | return data, {} | |
72 |
|
72 | |||
73 | class DopplerPlot(RTIPlot): |
|
73 | class DopplerPlot(RTIPlot): | |
74 | ''' |
|
74 | ''' | |
75 | Plot for DOPPLER Data (1st moment) |
|
75 | Plot for DOPPLER Data (1st moment) | |
76 | ''' |
|
76 | ''' | |
77 |
|
77 | |||
78 | CODE = 'dop' |
|
78 | CODE = 'dop' | |
79 | colormap = 'jet' |
|
79 | colormap = 'jet' | |
80 |
|
80 | |||
81 | def update(self, dataOut): |
|
81 | def update(self, dataOut): | |
82 |
|
82 | |||
83 | data = { |
|
83 | data = { | |
84 | 'dop': 10*numpy.log10(dataOut.data_dop) |
|
84 | 'dop': 10*numpy.log10(dataOut.data_dop) | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | return data, {} |
|
87 | return data, {} | |
88 |
|
88 | |||
89 | class PowerPlot(RTIPlot): |
|
89 | class PowerPlot(RTIPlot): | |
90 | ''' |
|
90 | ''' | |
91 | Plot for Power Data (0 moment) |
|
91 | Plot for Power Data (0 moment) | |
92 | ''' |
|
92 | ''' | |
93 |
|
93 | |||
94 | CODE = 'pow' |
|
94 | CODE = 'pow' | |
95 | colormap = 'jet' |
|
95 | colormap = 'jet' | |
96 |
|
96 | |||
97 | def update(self, dataOut): |
|
97 | def update(self, dataOut): | |
98 | data = { |
|
98 | data = { | |
99 | 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor) |
|
99 | 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor) | |
100 | } |
|
100 | } | |
101 | return data, {} |
|
101 | return data, {} | |
102 |
|
102 | |||
103 | class SpectralWidthPlot(RTIPlot): |
|
103 | class SpectralWidthPlot(RTIPlot): | |
104 | ''' |
|
104 | ''' | |
105 | Plot for Spectral Width Data (2nd moment) |
|
105 | Plot for Spectral Width Data (2nd moment) | |
106 | ''' |
|
106 | ''' | |
107 |
|
107 | |||
108 | CODE = 'width' |
|
108 | CODE = 'width' | |
109 | colormap = 'jet' |
|
109 | colormap = 'jet' | |
110 |
|
110 | |||
111 | def update(self, dataOut): |
|
111 | def update(self, dataOut): | |
112 |
|
112 | |||
113 | data = { |
|
113 | data = { | |
114 | 'width': dataOut.data_width |
|
114 | 'width': dataOut.data_width | |
115 | } |
|
115 | } | |
116 |
|
116 | |||
117 | return data, {} |
|
117 | return data, {} | |
118 |
|
118 | |||
119 | class SkyMapPlot(Plot): |
|
119 | class SkyMapPlot(Plot): | |
120 | ''' |
|
120 | ''' | |
121 | Plot for meteors detection data |
|
121 | Plot for meteors detection data | |
122 | ''' |
|
122 | ''' | |
123 |
|
123 | |||
124 | CODE = 'param' |
|
124 | CODE = 'param' | |
125 |
|
125 | |||
126 | def setup(self): |
|
126 | def setup(self): | |
127 |
|
127 | |||
128 | self.ncols = 1 |
|
128 | self.ncols = 1 | |
129 | self.nrows = 1 |
|
129 | self.nrows = 1 | |
130 | self.width = 7.2 |
|
130 | self.width = 7.2 | |
131 | self.height = 7.2 |
|
131 | self.height = 7.2 | |
132 | self.nplots = 1 |
|
132 | self.nplots = 1 | |
133 | self.xlabel = 'Zonal Zenith Angle (deg)' |
|
133 | self.xlabel = 'Zonal Zenith Angle (deg)' | |
134 | self.ylabel = 'Meridional Zenith Angle (deg)' |
|
134 | self.ylabel = 'Meridional Zenith Angle (deg)' | |
135 | self.polar = True |
|
135 | self.polar = True | |
136 | self.ymin = -180 |
|
136 | self.ymin = -180 | |
137 | self.ymax = 180 |
|
137 | self.ymax = 180 | |
138 | self.colorbar = False |
|
138 | self.colorbar = False | |
139 |
|
139 | |||
140 | def plot(self): |
|
140 | def plot(self): | |
141 |
|
141 | |||
142 | arrayParameters = numpy.concatenate(self.data['param']) |
|
142 | arrayParameters = numpy.concatenate(self.data['param']) | |
143 | error = arrayParameters[:, -1] |
|
143 | error = arrayParameters[:, -1] | |
144 | indValid = numpy.where(error == 0)[0] |
|
144 | indValid = numpy.where(error == 0)[0] | |
145 | finalMeteor = arrayParameters[indValid, :] |
|
145 | finalMeteor = arrayParameters[indValid, :] | |
146 | finalAzimuth = finalMeteor[:, 3] |
|
146 | finalAzimuth = finalMeteor[:, 3] | |
147 | finalZenith = finalMeteor[:, 4] |
|
147 | finalZenith = finalMeteor[:, 4] | |
148 |
|
148 | |||
149 | x = finalAzimuth * numpy.pi / 180 |
|
149 | x = finalAzimuth * numpy.pi / 180 | |
150 | y = finalZenith |
|
150 | y = finalZenith | |
151 |
|
151 | |||
152 | ax = self.axes[0] |
|
152 | ax = self.axes[0] | |
153 |
|
153 | |||
154 | if ax.firsttime: |
|
154 | if ax.firsttime: | |
155 | ax.plot = ax.plot(x, y, 'bo', markersize=5)[0] |
|
155 | ax.plot = ax.plot(x, y, 'bo', markersize=5)[0] | |
156 | else: |
|
156 | else: | |
157 | ax.plot.set_data(x, y) |
|
157 | ax.plot.set_data(x, y) | |
158 |
|
158 | |||
159 | dt1 = self.getDateTime(self.data.min_time).strftime('%y/%m/%d %H:%M:%S') |
|
159 | dt1 = self.getDateTime(self.data.min_time).strftime('%y/%m/%d %H:%M:%S') | |
160 | dt2 = self.getDateTime(self.data.max_time).strftime('%y/%m/%d %H:%M:%S') |
|
160 | dt2 = self.getDateTime(self.data.max_time).strftime('%y/%m/%d %H:%M:%S') | |
161 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, |
|
161 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, | |
162 | dt2, |
|
162 | dt2, | |
163 | len(x)) |
|
163 | len(x)) | |
164 | self.titles[0] = title |
|
164 | self.titles[0] = title | |
165 |
|
165 | |||
166 |
|
166 | |||
167 | class GenericRTIPlot(Plot): |
|
167 | class GenericRTIPlot(Plot): | |
168 | ''' |
|
168 | ''' | |
169 | Plot for data_xxxx object |
|
169 | Plot for data_xxxx object | |
170 | ''' |
|
170 | ''' | |
171 |
|
171 | |||
172 | CODE = 'param' |
|
172 | CODE = 'param' | |
173 | colormap = 'viridis' |
|
173 | colormap = 'viridis' | |
174 | plot_type = 'pcolorbuffer' |
|
174 | plot_type = 'pcolorbuffer' | |
175 |
|
175 | |||
176 | def setup(self): |
|
176 | def setup(self): | |
177 | self.xaxis = 'time' |
|
177 | self.xaxis = 'time' | |
178 | self.ncols = 1 |
|
178 | self.ncols = 1 | |
179 | self.nrows = self.data.shape('param')[0] |
|
179 | self.nrows = self.data.shape('param')[0] | |
180 | self.nplots = self.nrows |
|
180 | self.nplots = self.nrows | |
181 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95}) |
|
181 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95}) | |
182 |
|
182 | |||
183 | if not self.xlabel: |
|
183 | if not self.xlabel: | |
184 | self.xlabel = 'Time' |
|
184 | self.xlabel = 'Time' | |
185 |
|
185 | |||
186 | self.ylabel = 'Range [km]' |
|
186 | self.ylabel = 'Range [km]' | |
187 | if not self.titles: |
|
187 | if not self.titles: | |
188 | self.titles = ['Param {}'.format(x) for x in range(self.nrows)] |
|
188 | self.titles = ['Param {}'.format(x) for x in range(self.nrows)] | |
189 |
|
189 | |||
190 | def update(self, dataOut): |
|
190 | def update(self, dataOut): | |
191 |
|
191 | |||
192 | data = { |
|
192 | data = { | |
193 | 'param' : numpy.concatenate([getattr(dataOut, attr) for attr in self.attr_data], axis=0) |
|
193 | 'param' : numpy.concatenate([getattr(dataOut, attr) for attr in self.attr_data], axis=0) | |
194 | } |
|
194 | } | |
195 |
|
195 | |||
196 | meta = {} |
|
196 | meta = {} | |
197 |
|
197 | |||
198 | return data, meta |
|
198 | return data, meta | |
199 |
|
199 | |||
200 | def plot(self): |
|
200 | def plot(self): | |
201 | # self.data.normalize_heights() |
|
201 | # self.data.normalize_heights() | |
202 | self.x = self.data.times |
|
202 | self.x = self.data.times | |
203 | self.y = self.data.yrange |
|
203 | self.y = self.data.yrange | |
204 | self.z = self.data['param'] |
|
204 | self.z = self.data['param'] | |
205 | self.z = 10*numpy.log10(self.z) |
|
205 | self.z = 10*numpy.log10(self.z) | |
206 | self.z = numpy.ma.masked_invalid(self.z) |
|
206 | self.z = numpy.ma.masked_invalid(self.z) | |
207 |
|
207 | |||
208 | if self.decimation is None: |
|
208 | if self.decimation is None: | |
209 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
209 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
210 | else: |
|
210 | else: | |
211 | x, y, z = self.fill_gaps(*self.decimate()) |
|
211 | x, y, z = self.fill_gaps(*self.decimate()) | |
212 |
|
212 | |||
213 | for n, ax in enumerate(self.axes): |
|
213 | for n, ax in enumerate(self.axes): | |
214 |
|
214 | |||
215 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
215 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
216 | self.z[n]) |
|
216 | self.z[n]) | |
217 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
217 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
218 | self.z[n]) |
|
218 | self.z[n]) | |
219 |
|
219 | |||
220 | if ax.firsttime: |
|
220 | if ax.firsttime: | |
221 | if self.zlimits is not None: |
|
221 | if self.zlimits is not None: | |
222 | self.zmin, self.zmax = self.zlimits[n] |
|
222 | self.zmin, self.zmax = self.zlimits[n] | |
223 |
|
223 | |||
224 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
224 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
225 | vmin=self.zmin, |
|
225 | vmin=self.zmin, | |
226 | vmax=self.zmax, |
|
226 | vmax=self.zmax, | |
227 | cmap=self.cmaps[n] |
|
227 | cmap=self.cmaps[n] | |
228 | ) |
|
228 | ) | |
229 | else: |
|
229 | else: | |
230 | if self.zlimits is not None: |
|
230 | if self.zlimits is not None: | |
231 | self.zmin, self.zmax = self.zlimits[n] |
|
231 | self.zmin, self.zmax = self.zlimits[n] | |
232 | ax.collections.remove(ax.collections[0]) |
|
232 | ax.collections.remove(ax.collections[0]) | |
233 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
233 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
234 | vmin=self.zmin, |
|
234 | vmin=self.zmin, | |
235 | vmax=self.zmax, |
|
235 | vmax=self.zmax, | |
236 | cmap=self.cmaps[n] |
|
236 | cmap=self.cmaps[n] | |
237 | ) |
|
237 | ) | |
238 |
|
238 | |||
239 |
|
239 | |||
240 | class PolarMapPlot(Plot): |
|
240 | class PolarMapPlot(Plot): | |
241 | ''' |
|
241 | ''' | |
242 | Plot for weather radar |
|
242 | Plot for weather radar | |
243 | ''' |
|
243 | ''' | |
244 |
|
244 | |||
245 | CODE = 'param' |
|
245 | CODE = 'param' | |
246 | colormap = 'seismic' |
|
246 | colormap = 'seismic' | |
247 |
|
247 | |||
248 | def setup(self): |
|
248 | def setup(self): | |
249 | self.ncols = 1 |
|
249 | self.ncols = 1 | |
250 | self.nrows = 1 |
|
250 | self.nrows = 1 | |
251 | self.width = 9 |
|
251 | self.width = 9 | |
252 | self.height = 8 |
|
252 | self.height = 8 | |
253 | self.mode = self.data.meta['mode'] |
|
253 | self.mode = self.data.meta['mode'] | |
254 | if self.channels is not None: |
|
254 | if self.channels is not None: | |
255 | self.nplots = len(self.channels) |
|
255 | self.nplots = len(self.channels) | |
256 | self.nrows = len(self.channels) |
|
256 | self.nrows = len(self.channels) | |
257 | else: |
|
257 | else: | |
258 | self.nplots = self.data.shape(self.CODE)[0] |
|
258 | self.nplots = self.data.shape(self.CODE)[0] | |
259 | self.nrows = self.nplots |
|
259 | self.nrows = self.nplots | |
260 | self.channels = list(range(self.nplots)) |
|
260 | self.channels = list(range(self.nplots)) | |
261 | if self.mode == 'E': |
|
261 | if self.mode == 'E': | |
262 | self.xlabel = 'Longitude' |
|
262 | self.xlabel = 'Longitude' | |
263 | self.ylabel = 'Latitude' |
|
263 | self.ylabel = 'Latitude' | |
264 | else: |
|
264 | else: | |
265 | self.xlabel = 'Range (km)' |
|
265 | self.xlabel = 'Range (km)' | |
266 | self.ylabel = 'Height (km)' |
|
266 | self.ylabel = 'Height (km)' | |
267 | self.bgcolor = 'white' |
|
267 | self.bgcolor = 'white' | |
268 | self.cb_labels = self.data.meta['units'] |
|
268 | self.cb_labels = self.data.meta['units'] | |
269 | self.lat = self.data.meta['latitude'] |
|
269 | self.lat = self.data.meta['latitude'] | |
270 | self.lon = self.data.meta['longitude'] |
|
270 | self.lon = self.data.meta['longitude'] | |
271 | self.xmin, self.xmax = float( |
|
271 | self.xmin, self.xmax = float( | |
272 | km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon) |
|
272 | km2deg(self.xmin) + self.lon), float(km2deg(self.xmax) + self.lon) | |
273 | self.ymin, self.ymax = float( |
|
273 | self.ymin, self.ymax = float( | |
274 | km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat) |
|
274 | km2deg(self.ymin) + self.lat), float(km2deg(self.ymax) + self.lat) | |
275 | # self.polar = True |
|
275 | # self.polar = True | |
276 |
|
276 | |||
277 | def plot(self): |
|
277 | def plot(self): | |
278 |
|
278 | |||
279 | for n, ax in enumerate(self.axes): |
|
279 | for n, ax in enumerate(self.axes): | |
280 | data = self.data['param'][self.channels[n]] |
|
280 | data = self.data['param'][self.channels[n]] | |
281 |
|
281 | |||
282 | zeniths = numpy.linspace( |
|
282 | zeniths = numpy.linspace( | |
283 | 0, self.data.meta['max_range'], data.shape[1]) |
|
283 | 0, self.data.meta['max_range'], data.shape[1]) | |
284 | if self.mode == 'E': |
|
284 | if self.mode == 'E': | |
285 | azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2 |
|
285 | azimuths = -numpy.radians(self.data.yrange)+numpy.pi/2 | |
286 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
286 | r, theta = numpy.meshgrid(zeniths, azimuths) | |
287 | x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin( |
|
287 | x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin( | |
288 | theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])) |
|
288 | theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])) | |
289 | x = km2deg(x) + self.lon |
|
289 | x = km2deg(x) + self.lon | |
290 | y = km2deg(y) + self.lat |
|
290 | y = km2deg(y) + self.lat | |
291 | else: |
|
291 | else: | |
292 | azimuths = numpy.radians(self.data.yrange) |
|
292 | azimuths = numpy.radians(self.data.yrange) | |
293 | r, theta = numpy.meshgrid(zeniths, azimuths) |
|
293 | r, theta = numpy.meshgrid(zeniths, azimuths) | |
294 | x, y = r*numpy.cos(theta), r*numpy.sin(theta) |
|
294 | x, y = r*numpy.cos(theta), r*numpy.sin(theta) | |
295 | self.y = zeniths |
|
295 | self.y = zeniths | |
296 |
|
296 | |||
297 | if ax.firsttime: |
|
297 | if ax.firsttime: | |
298 | if self.zlimits is not None: |
|
298 | if self.zlimits is not None: | |
299 | self.zmin, self.zmax = self.zlimits[n] |
|
299 | self.zmin, self.zmax = self.zlimits[n] | |
300 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
300 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), | |
301 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
301 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), | |
302 | vmin=self.zmin, |
|
302 | vmin=self.zmin, | |
303 | vmax=self.zmax, |
|
303 | vmax=self.zmax, | |
304 | cmap=self.cmaps[n]) |
|
304 | cmap=self.cmaps[n]) | |
305 | else: |
|
305 | else: | |
306 | if self.zlimits is not None: |
|
306 | if self.zlimits is not None: | |
307 | self.zmin, self.zmax = self.zlimits[n] |
|
307 | self.zmin, self.zmax = self.zlimits[n] | |
308 | ax.collections.remove(ax.collections[0]) |
|
308 | ax.collections.remove(ax.collections[0]) | |
309 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
309 | ax.plt = ax.pcolormesh( # r, theta, numpy.ma.array(data, mask=numpy.isnan(data)), | |
310 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), |
|
310 | x, y, numpy.ma.array(data, mask=numpy.isnan(data)), | |
311 | vmin=self.zmin, |
|
311 | vmin=self.zmin, | |
312 | vmax=self.zmax, |
|
312 | vmax=self.zmax, | |
313 | cmap=self.cmaps[n]) |
|
313 | cmap=self.cmaps[n]) | |
314 |
|
314 | |||
315 | if self.mode == 'A': |
|
315 | if self.mode == 'A': | |
316 | continue |
|
316 | continue | |
317 |
|
317 | |||
318 | # plot district names |
|
318 | # plot district names | |
319 | f = open('/data/workspace/schain_scripts/distrito.csv') |
|
319 | f = open('/data/workspace/schain_scripts/distrito.csv') | |
320 | for line in f: |
|
320 | for line in f: | |
321 | label, lon, lat = [s.strip() for s in line.split(',') if s] |
|
321 | label, lon, lat = [s.strip() for s in line.split(',') if s] | |
322 | lat = float(lat) |
|
322 | lat = float(lat) | |
323 | lon = float(lon) |
|
323 | lon = float(lon) | |
324 | # ax.plot(lon, lat, '.b', ms=2) |
|
324 | # ax.plot(lon, lat, '.b', ms=2) | |
325 | ax.text(lon, lat, label.decode('utf8'), ha='center', |
|
325 | ax.text(lon, lat, label.decode('utf8'), ha='center', | |
326 | va='bottom', size='8', color='black') |
|
326 | va='bottom', size='8', color='black') | |
327 |
|
327 | |||
328 | # plot limites |
|
328 | # plot limites | |
329 | limites = [] |
|
329 | limites = [] | |
330 | tmp = [] |
|
330 | tmp = [] | |
331 | for line in open('/data/workspace/schain_scripts/lima.csv'): |
|
331 | for line in open('/data/workspace/schain_scripts/lima.csv'): | |
332 | if '#' in line: |
|
332 | if '#' in line: | |
333 | if tmp: |
|
333 | if tmp: | |
334 | limites.append(tmp) |
|
334 | limites.append(tmp) | |
335 | tmp = [] |
|
335 | tmp = [] | |
336 | continue |
|
336 | continue | |
337 | values = line.strip().split(',') |
|
337 | values = line.strip().split(',') | |
338 | tmp.append((float(values[0]), float(values[1]))) |
|
338 | tmp.append((float(values[0]), float(values[1]))) | |
339 | for points in limites: |
|
339 | for points in limites: | |
340 | ax.add_patch( |
|
340 | ax.add_patch( | |
341 | Polygon(points, ec='k', fc='none', ls='--', lw=0.5)) |
|
341 | Polygon(points, ec='k', fc='none', ls='--', lw=0.5)) | |
342 |
|
342 | |||
343 | # plot Cuencas |
|
343 | # plot Cuencas | |
344 | for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'): |
|
344 | for cuenca in ('rimac', 'lurin', 'mala', 'chillon', 'chilca', 'chancay-huaral'): | |
345 | f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca)) |
|
345 | f = open('/data/workspace/schain_scripts/{}.csv'.format(cuenca)) | |
346 | values = [line.strip().split(',') for line in f] |
|
346 | values = [line.strip().split(',') for line in f] | |
347 | points = [(float(s[0]), float(s[1])) for s in values] |
|
347 | points = [(float(s[0]), float(s[1])) for s in values] | |
348 | ax.add_patch(Polygon(points, ec='b', fc='none')) |
|
348 | ax.add_patch(Polygon(points, ec='b', fc='none')) | |
349 |
|
349 | |||
350 | # plot grid |
|
350 | # plot grid | |
351 | for r in (15, 30, 45, 60): |
|
351 | for r in (15, 30, 45, 60): | |
352 | ax.add_artist(plt.Circle((self.lon, self.lat), |
|
352 | ax.add_artist(plt.Circle((self.lon, self.lat), | |
353 | km2deg(r), color='0.6', fill=False, lw=0.2)) |
|
353 | km2deg(r), color='0.6', fill=False, lw=0.2)) | |
354 | ax.text( |
|
354 | ax.text( | |
355 | self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180), |
|
355 | self.lon + (km2deg(r))*numpy.cos(60*numpy.pi/180), | |
356 | self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180), |
|
356 | self.lat + (km2deg(r))*numpy.sin(60*numpy.pi/180), | |
357 | '{}km'.format(r), |
|
357 | '{}km'.format(r), | |
358 | ha='center', va='bottom', size='8', color='0.6', weight='heavy') |
|
358 | ha='center', va='bottom', size='8', color='0.6', weight='heavy') | |
359 |
|
359 | |||
360 | if self.mode == 'E': |
|
360 | if self.mode == 'E': | |
361 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) |
|
361 | title = 'El={}$^\circ$'.format(self.data.meta['elevation']) | |
362 | label = 'E{:02d}'.format(int(self.data.meta['elevation'])) |
|
362 | label = 'E{:02d}'.format(int(self.data.meta['elevation'])) | |
363 | else: |
|
363 | else: | |
364 | title = 'Az={}$^\circ$'.format(self.data.meta['azimuth']) |
|
364 | title = 'Az={}$^\circ$'.format(self.data.meta['azimuth']) | |
365 | label = 'A{:02d}'.format(int(self.data.meta['azimuth'])) |
|
365 | label = 'A{:02d}'.format(int(self.data.meta['azimuth'])) | |
366 |
|
366 | |||
367 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] |
|
367 | self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels] | |
368 | self.titles = ['{} {}'.format( |
|
368 | self.titles = ['{} {}'.format( | |
369 | self.data.parameters[x], title) for x in self.channels] |
|
369 | self.data.parameters[x], title) for x in self.channels] | |
370 |
|
370 | |||
371 | class WeatherPlot(Plot): |
|
371 | class WeatherPlot(Plot): | |
372 | CODE = 'weather' |
|
372 | CODE = 'weather' | |
373 | plot_name = 'weather' |
|
373 | plot_name = 'weather' | |
374 | plot_type = 'ppistyle' |
|
374 | plot_type = 'ppistyle' | |
375 | buffering = False |
|
375 | buffering = False | |
376 |
|
376 | |||
377 | def setup(self): |
|
377 | def setup(self): | |
378 | self.ncols = 1 |
|
378 | self.ncols = 1 | |
379 | self.nrows = 1 |
|
379 | self.nrows = 1 | |
380 | self.nplots= 1 |
|
380 | self.nplots= 1 | |
381 | self.ylabel= 'Range [Km]' |
|
381 | self.ylabel= 'Range [Km]' | |
382 | self.titles= ['Weather'] |
|
382 | self.titles= ['Weather'] | |
383 | self.colorbar=False |
|
383 | self.colorbar=False | |
384 | self.width =8 |
|
384 | self.width =8 | |
385 | self.height =8 |
|
385 | self.height =8 | |
386 | self.ini =0 |
|
386 | self.ini =0 | |
387 | self.len_azi =0 |
|
387 | self.len_azi =0 | |
388 | self.buffer_ini = None |
|
388 | self.buffer_ini = None | |
389 | self.buffer_azi = None |
|
389 | self.buffer_azi = None | |
390 | self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) |
|
390 | self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) | |
391 | self.flag =0 |
|
391 | self.flag =0 | |
392 | self.indicador= 0 |
|
392 | self.indicador= 0 | |
393 | self.last_data_azi = None |
|
393 | self.last_data_azi = None | |
394 | self.val_mean = None |
|
394 | self.val_mean = None | |
395 |
|
395 | |||
396 | def update(self, dataOut): |
|
396 | def update(self, dataOut): | |
397 |
|
397 | |||
398 | data = {} |
|
398 | data = {} | |
399 | meta = {} |
|
399 | meta = {} | |
400 | if hasattr(dataOut, 'dataPP_POWER'): |
|
400 | if hasattr(dataOut, 'dataPP_POWER'): | |
401 | factor = 1 |
|
401 | factor = 1 | |
402 |
|
402 | |||
403 | if hasattr(dataOut, 'nFFTPoints'): |
|
403 | if hasattr(dataOut, 'nFFTPoints'): | |
404 | factor = dataOut.normFactor |
|
404 | factor = dataOut.normFactor | |
405 |
|
405 | |||
406 | ####print("factor",factor) |
|
406 | ####print("factor",factor) | |
407 | data['weather'] = 10*numpy.log10(dataOut.data_360[1]/(factor)) |
|
407 | data['weather'] = 10*numpy.log10(dataOut.data_360[1]/(factor)) | |
408 | ####print("weather",data['weather']) |
|
408 | ####print("weather",data['weather']) | |
409 | data['azi'] = dataOut.data_azi |
|
409 | data['azi'] = dataOut.data_azi | |
410 | return data, meta |
|
410 | return data, meta | |
411 |
|
411 | |||
412 | def get2List(self,angulos): |
|
412 | def get2List(self,angulos): | |
413 | list1=[] |
|
413 | list1=[] | |
414 | list2=[] |
|
414 | list2=[] | |
415 | for i in reversed(range(len(angulos))): |
|
415 | for i in reversed(range(len(angulos))): | |
416 | diff_ = angulos[i]-angulos[i-1] |
|
416 | diff_ = angulos[i]-angulos[i-1] | |
417 | if diff_ >1.5: |
|
417 | if diff_ >1.5: | |
418 | list1.append(i-1) |
|
418 | list1.append(i-1) | |
419 | list2.append(diff_) |
|
419 | list2.append(diff_) | |
420 | return list(reversed(list1)),list(reversed(list2)) |
|
420 | return list(reversed(list1)),list(reversed(list2)) | |
421 |
|
421 | |||
422 | def fixData360(self,list_,ang_): |
|
422 | def fixData360(self,list_,ang_): | |
423 | if list_[0]==-1: |
|
423 | if list_[0]==-1: | |
424 | vec = numpy.where(ang_<ang_[0]) |
|
424 | vec = numpy.where(ang_<ang_[0]) | |
425 | ang_[vec] = ang_[vec]+360 |
|
425 | ang_[vec] = ang_[vec]+360 | |
426 | return ang_ |
|
426 | return ang_ | |
427 | return ang_ |
|
427 | return ang_ | |
428 |
|
428 | |||
429 |
|
429 | |||
430 | def fixData360HL(self,angulos): |
|
430 | def fixData360HL(self,angulos): | |
431 | vec = numpy.where(angulos>=360) |
|
431 | vec = numpy.where(angulos>=360) | |
432 | angulos[vec]=angulos[vec]-360 |
|
432 | angulos[vec]=angulos[vec]-360 | |
433 | return angulos |
|
433 | return angulos | |
434 |
|
434 | |||
435 | def search_pos(self,pos,list_): |
|
435 | def search_pos(self,pos,list_): | |
436 | for i in range(len(list_)): |
|
436 | for i in range(len(list_)): | |
437 | if pos == list_[i]: |
|
437 | if pos == list_[i]: | |
438 | return True,i |
|
438 | return True,i | |
439 | i=None |
|
439 | i=None | |
440 | return False,i |
|
440 | return False,i | |
441 |
|
441 | |||
442 | def fixDataComp(self,ang_,list1_,list2_): |
|
442 | def fixDataComp(self,ang_,list1_,list2_): | |
443 | size = len(ang_) |
|
443 | size = len(ang_) | |
444 | size2 = 0 |
|
444 | size2 = 0 | |
445 | for i in range(len(list2_)): |
|
445 | for i in range(len(list2_)): | |
446 | size2=size2+list2_[i]-1 |
|
446 | size2=size2+list2_[i]-1 | |
447 | new_size= size+size2 |
|
447 | new_size= size+size2 | |
448 | ang_new = numpy.zeros(new_size) |
|
448 | ang_new = numpy.zeros(new_size) | |
449 | ang_new2 = numpy.zeros(new_size) |
|
449 | ang_new2 = numpy.zeros(new_size) | |
450 |
|
450 | |||
451 | tmp = 0 |
|
451 | tmp = 0 | |
452 | c = 0 |
|
452 | c = 0 | |
453 | for i in range(len(ang_)): |
|
453 | for i in range(len(ang_)): | |
454 | ang_new[tmp +c] = ang_[i] |
|
454 | ang_new[tmp +c] = ang_[i] | |
455 | ang_new2[tmp+c] = ang_[i] |
|
455 | ang_new2[tmp+c] = ang_[i] | |
456 | condition , value = self.search_pos(i,list1_) |
|
456 | condition , value = self.search_pos(i,list1_) | |
457 | if condition: |
|
457 | if condition: | |
458 | pos = tmp + c + 1 |
|
458 | pos = tmp + c + 1 | |
459 | for k in range(list2_[value]-1): |
|
459 | for k in range(list2_[value]-1): | |
460 | ang_new[pos+k] = ang_new[pos+k-1]+1 |
|
460 | ang_new[pos+k] = ang_new[pos+k-1]+1 | |
461 | ang_new2[pos+k] = numpy.nan |
|
461 | ang_new2[pos+k] = numpy.nan | |
462 | tmp = pos +k |
|
462 | tmp = pos +k | |
463 | c = 0 |
|
463 | c = 0 | |
464 | c=c+1 |
|
464 | c=c+1 | |
465 | return ang_new,ang_new2 |
|
465 | return ang_new,ang_new2 | |
466 |
|
466 | |||
467 |
|
467 | |||
468 | def globalCheckPED(self,angulos): |
|
468 | def globalCheckPED(self,angulos): | |
469 | l1,l2 = self.get2List(angulos) |
|
469 | l1,l2 = self.get2List(angulos) | |
470 | if len(l1)>0: |
|
470 | if len(l1)>0: | |
471 | angulos2 = self.fixData360(list_=l1,ang_=angulos) |
|
471 | angulos2 = self.fixData360(list_=l1,ang_=angulos) | |
472 | l1,l2 = self.get2List(angulos2) |
|
472 | l1,l2 = self.get2List(angulos2) | |
473 |
|
473 | |||
474 | ang1_,ang2_ = self.fixDataComp(ang_=angulos2,list1_=l1,list2_=l2) |
|
474 | ang1_,ang2_ = self.fixDataComp(ang_=angulos2,list1_=l1,list2_=l2) | |
475 | ang1_ = self.fixData360HL(ang1_) |
|
475 | ang1_ = self.fixData360HL(ang1_) | |
476 | ang2_ = self.fixData360HL(ang2_) |
|
476 | ang2_ = self.fixData360HL(ang2_) | |
477 |
|
477 | |||
478 | else: |
|
478 | else: | |
479 | ang1_= angulos |
|
479 | ang1_= angulos | |
480 | ang2_= angulos |
|
480 | ang2_= angulos | |
481 | return ang1_,ang2_ |
|
481 | return ang1_,ang2_ | |
482 |
|
482 | |||
483 | def analizeDATA(self,data_azi): |
|
483 | def analizeDATA(self,data_azi): | |
484 | list1 = [] |
|
484 | list1 = [] | |
485 | list2 = [] |
|
485 | list2 = [] | |
486 | dat = data_azi |
|
486 | dat = data_azi | |
487 | for i in reversed(range(1,len(dat))): |
|
487 | for i in reversed(range(1,len(dat))): | |
488 | if dat[i]>dat[i-1]: |
|
488 | if dat[i]>dat[i-1]: | |
489 | diff = int(dat[i])-int(dat[i-1]) |
|
489 | diff = int(dat[i])-int(dat[i-1]) | |
490 | else: |
|
490 | else: | |
491 | diff = 360+int(dat[i])-int(dat[i-1]) |
|
491 | diff = 360+int(dat[i])-int(dat[i-1]) | |
492 | if diff > 1: |
|
492 | if diff > 1: | |
493 | list1.append(i-1) |
|
493 | list1.append(i-1) | |
494 | list2.append(diff-1) |
|
494 | list2.append(diff-1) | |
495 | return list1,list2 |
|
495 | return list1,list2 | |
496 |
|
496 | |||
497 | def fixDATANEW(self,data_azi,data_weather): |
|
497 | def fixDATANEW(self,data_azi,data_weather): | |
498 | list1,list2 = self.analizeDATA(data_azi) |
|
498 | list1,list2 = self.analizeDATA(data_azi) | |
499 | if len(list1)== 0: |
|
499 | if len(list1)== 0: | |
500 | return data_azi,data_weather |
|
500 | return data_azi,data_weather | |
501 | else: |
|
501 | else: | |
502 | resize = 0 |
|
502 | resize = 0 | |
503 | for i in range(len(list2)): |
|
503 | for i in range(len(list2)): | |
504 | resize= resize + list2[i] |
|
504 | resize= resize + list2[i] | |
505 | new_data_azi = numpy.resize(data_azi,resize) |
|
505 | new_data_azi = numpy.resize(data_azi,resize) | |
506 | new_data_weather= numpy.resize(date_weather,resize) |
|
506 | new_data_weather= numpy.resize(date_weather,resize) | |
507 |
|
507 | |||
508 | for i in range(len(list2)): |
|
508 | for i in range(len(list2)): | |
509 | j=0 |
|
509 | j=0 | |
510 | position=list1[i]+1 |
|
510 | position=list1[i]+1 | |
511 | for j in range(list2[i]): |
|
511 | for j in range(list2[i]): | |
512 | new_data_azi[position+j]=new_data_azi[position+j-1]+1 |
|
512 | new_data_azi[position+j]=new_data_azi[position+j-1]+1 | |
513 |
|
513 | |||
514 | return new_data_azi |
|
514 | return new_data_azi | |
515 |
|
515 | |||
516 | def fixDATA(self,data_azi): |
|
516 | def fixDATA(self,data_azi): | |
517 | data=data_azi |
|
517 | data=data_azi | |
518 | for i in range(len(data)): |
|
518 | for i in range(len(data)): | |
519 | if numpy.isnan(data[i]): |
|
519 | if numpy.isnan(data[i]): | |
520 | data[i]=data[i-1]+1 |
|
520 | data[i]=data[i-1]+1 | |
521 | return data |
|
521 | return data | |
522 |
|
522 | |||
523 | def replaceNAN(self,data_weather,data_azi,val): |
|
523 | def replaceNAN(self,data_weather,data_azi,val): | |
524 | ####print("----------------activeNEWFUNCTION") |
|
524 | ####print("----------------activeNEWFUNCTION") | |
525 | data= data_azi |
|
525 | data= data_azi | |
526 | data_T= data_weather |
|
526 | data_T= data_weather | |
527 | ####print("data_azi",data_azi) |
|
527 | ####print("data_azi",data_azi) | |
528 | ####print("VAL:",val) |
|
528 | ####print("VAL:",val) | |
529 | ####print("SHAPE",data_T.shape) |
|
529 | ####print("SHAPE",data_T.shape) | |
530 | for i in range(len(data)): |
|
530 | for i in range(len(data)): | |
531 | if numpy.isnan(data[i]): |
|
531 | if numpy.isnan(data[i]): | |
532 | ####print("NAN") |
|
532 | ####print("NAN") | |
533 | data_T[i,:]=numpy.ones(data_T.shape[1])*val |
|
533 | #data_T[i,:]=numpy.ones(data_T.shape[1])*val | |
534 |
|
|
534 | data_T[i,:]=numpy.ones(data_T.shape[1])*numpy.nan | |
535 | return data_T |
|
535 | return data_T | |
536 |
|
536 | |||
537 | def const_ploteo(self,data_weather,data_azi,step,res): |
|
537 | def const_ploteo(self,data_weather,data_azi,step,res): | |
538 | if self.ini==0: |
|
538 | if self.ini==0: | |
539 | #------- AZIMUTH |
|
539 | #------- AZIMUTH | |
540 | n = (360/res)-len(data_azi) |
|
540 | n = (360/res)-len(data_azi) | |
541 | #--------------------- new ------------------------- |
|
541 | #--------------------- new ------------------------- | |
542 | ####data_azi_old = data_azi |
|
542 | ####data_azi_old = data_azi | |
543 | data_azi_new ,data_azi_old= self.globalCheckPED(data_azi) |
|
543 | data_azi_new ,data_azi_old= self.globalCheckPED(data_azi) | |
544 | #------------------------ |
|
544 | #------------------------ | |
545 | ####data_azi_new = self.fixDATA(data_azi) |
|
545 | ####data_azi_new = self.fixDATA(data_azi) | |
546 | #ata_azi_new = self.fixDATANEW(data_azi) |
|
546 | #ata_azi_new = self.fixDATANEW(data_azi) | |
547 |
|
547 | |||
548 | start = data_azi_new[-1] + res |
|
548 | start = data_azi_new[-1] + res | |
549 | end = data_azi_new[0] - res |
|
549 | end = data_azi_new[0] - res | |
550 | ##### new |
|
550 | ##### new | |
551 | self.last_data_azi = end |
|
551 | self.last_data_azi = end | |
552 | if start>end: |
|
552 | if start>end: | |
553 | end = end + 360 |
|
553 | end = end + 360 | |
554 | azi_vacia = numpy.linspace(start,end,int(n)) |
|
554 | azi_vacia = numpy.linspace(start,end,int(n)) | |
555 | azi_vacia = numpy.where(azi_vacia>360,azi_vacia-360,azi_vacia) |
|
555 | azi_vacia = numpy.where(azi_vacia>360,azi_vacia-360,azi_vacia) | |
556 | data_azi = numpy.hstack((data_azi_new,azi_vacia)) |
|
556 | data_azi = numpy.hstack((data_azi_new,azi_vacia)) | |
557 | # RADAR |
|
557 | # RADAR | |
558 | val_mean = numpy.mean(data_weather[:,-1]) |
|
558 | val_mean = numpy.mean(data_weather[:,-1]) | |
559 | self.val_mean = val_mean |
|
559 | self.val_mean = val_mean | |
560 | data_weather_cmp = numpy.ones([(360-data_weather.shape[0]),data_weather.shape[1]])*val_mean |
|
560 | data_weather_cmp = numpy.ones([(360-data_weather.shape[0]),data_weather.shape[1]])*val_mean | |
561 | data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean) |
|
561 | data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean) | |
562 | data_weather = numpy.vstack((data_weather,data_weather_cmp)) |
|
562 | data_weather = numpy.vstack((data_weather,data_weather_cmp)) | |
563 | else: |
|
563 | else: | |
564 | # azimuth |
|
564 | # azimuth | |
565 | flag=0 |
|
565 | flag=0 | |
566 | start_azi = self.res_azi[0] |
|
566 | start_azi = self.res_azi[0] | |
567 | #-----------new------------ |
|
567 | #-----------new------------ | |
568 | data_azi ,data_azi_old= self.globalCheckPED(data_azi) |
|
568 | data_azi ,data_azi_old= self.globalCheckPED(data_azi) | |
569 | data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean) |
|
569 | data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean) | |
570 | #-------------------------- |
|
570 | #-------------------------- | |
571 | ####data_azi_old = data_azi |
|
571 | ####data_azi_old = data_azi | |
572 | ### weather ### |
|
572 | ### weather ### | |
573 | ####data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean) |
|
573 | ####data_weather = self.replaceNAN(data_weather=data_weather,data_azi=data_azi_old,val=self.val_mean) | |
574 |
|
574 | |||
575 | ####if numpy.isnan(data_azi[0]): |
|
575 | ####if numpy.isnan(data_azi[0]): | |
576 | #### data_azi[0]=self.last_data_azi+1 |
|
576 | #### data_azi[0]=self.last_data_azi+1 | |
577 | ####data_azi = self.fixDATA(data_azi) |
|
577 | ####data_azi = self.fixDATA(data_azi) | |
578 | start = data_azi[0] |
|
578 | start = data_azi[0] | |
579 | end = data_azi[-1] |
|
579 | end = data_azi[-1] | |
580 | self.last_data_azi= end |
|
580 | self.last_data_azi= end | |
581 | ####print("start",start) |
|
581 | ####print("start",start) | |
582 | ####print("end",end) |
|
582 | ####print("end",end) | |
583 | if start< start_azi: |
|
583 | if start< start_azi: | |
584 | start = start +360 |
|
584 | start = start +360 | |
585 | if end <start_azi: |
|
585 | if end <start_azi: | |
586 | end = end +360 |
|
586 | end = end +360 | |
587 | ####print("start",start) |
|
587 | ####print("start",start) | |
588 | ####print("end",end) |
|
588 | ####print("end",end) | |
589 | #### AQUI SERA LA MAGIA |
|
589 | #### AQUI SERA LA MAGIA | |
590 | pos_ini = int((start-start_azi)/res) |
|
590 | pos_ini = int((start-start_azi)/res) | |
591 | len_azi = len(data_azi) |
|
591 | len_azi = len(data_azi) | |
592 | if (360-pos_ini)<len_azi: |
|
592 | if (360-pos_ini)<len_azi: | |
593 | if pos_ini+1==360: |
|
593 | if pos_ini+1==360: | |
594 | pos_ini=0 |
|
594 | pos_ini=0 | |
595 | else: |
|
595 | else: | |
596 | flag=1 |
|
596 | flag=1 | |
597 | dif= 360-pos_ini |
|
597 | dif= 360-pos_ini | |
598 | comp= len_azi-dif |
|
598 | comp= len_azi-dif | |
599 |
|
599 | |||
600 | #----------------- |
|
600 | #----------------- | |
601 | ####print(pos_ini) |
|
601 | ####print(pos_ini) | |
602 | ####print(len_azi) |
|
602 | ####print(len_azi) | |
603 | ####print("shape",self.res_azi.shape) |
|
603 | ####print("shape",self.res_azi.shape) | |
604 | if flag==0: |
|
604 | if flag==0: | |
605 | # AZIMUTH |
|
605 | # AZIMUTH | |
606 | self.res_azi[pos_ini:pos_ini+len_azi] = data_azi |
|
606 | self.res_azi[pos_ini:pos_ini+len_azi] = data_azi | |
607 | # RADAR |
|
607 | # RADAR | |
608 | self.res_weather[pos_ini:pos_ini+len_azi,:] = data_weather |
|
608 | self.res_weather[pos_ini:pos_ini+len_azi,:] = data_weather | |
609 | else: |
|
609 | else: | |
610 | # AZIMUTH |
|
610 | # AZIMUTH | |
611 | self.res_azi[pos_ini:pos_ini+dif] = data_azi[0:dif] |
|
611 | self.res_azi[pos_ini:pos_ini+dif] = data_azi[0:dif] | |
612 | self.res_azi[0:comp] = data_azi[dif:] |
|
612 | self.res_azi[0:comp] = data_azi[dif:] | |
613 | # RADAR |
|
613 | # RADAR | |
614 | self.res_weather[pos_ini:pos_ini+dif,:] = data_weather[0:dif,:] |
|
614 | self.res_weather[pos_ini:pos_ini+dif,:] = data_weather[0:dif,:] | |
615 | self.res_weather[0:comp,:] = data_weather[dif:,:] |
|
615 | self.res_weather[0:comp,:] = data_weather[dif:,:] | |
616 | flag=0 |
|
616 | flag=0 | |
617 | data_azi = self.res_azi |
|
617 | data_azi = self.res_azi | |
618 | data_weather = self.res_weather |
|
618 | data_weather = self.res_weather | |
619 |
|
619 | |||
620 | return data_weather,data_azi |
|
620 | return data_weather,data_azi | |
621 |
|
621 | |||
622 | def plot(self): |
|
622 | def plot(self): | |
623 | #print("--------------------------------------",self.ini,"-----------------------------------") |
|
623 | #print("--------------------------------------",self.ini,"-----------------------------------") | |
624 | #numpy.set_printoptions(suppress=True) |
|
624 | #numpy.set_printoptions(suppress=True) | |
625 | ####print("times: ",self.data.times) |
|
625 | ####print("times: ",self.data.times) | |
626 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]).strftime('%Y-%m-%d %H:%M:%S') |
|
626 | thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]).strftime('%Y-%m-%d %H:%M:%S') | |
627 | #print("times: ",thisDatetime) |
|
627 | #print("times: ",thisDatetime) | |
628 | data = self.data[-1] |
|
628 | data = self.data[-1] | |
629 | ####ALTURA altura_tmp_h |
|
629 | ####ALTURA altura_tmp_h | |
630 | ###print("Y RANGES",self.data.yrange,len(self.data.yrange)) |
|
630 | ###print("Y RANGES",self.data.yrange,len(self.data.yrange)) | |
631 | ###altura_h = (data['weather'].shape[1])/10.0 |
|
631 | ###altura_h = (data['weather'].shape[1])/10.0 | |
632 | ###stoprange = float(altura_h*0.3)#stoprange = float(33*1.5) por ahora 400 |
|
632 | ###stoprange = float(altura_h*0.3)#stoprange = float(33*1.5) por ahora 400 | |
633 | ###rangestep = float(0.03) |
|
633 | ###rangestep = float(0.03) | |
634 | ###r = numpy.arange(0, stoprange, rangestep) |
|
634 | ###r = numpy.arange(0, stoprange, rangestep) | |
635 | ###print("r",r,len(r)) |
|
635 | ###print("r",r,len(r)) | |
636 | #-----------------------------update---------------------- |
|
636 | #-----------------------------update---------------------- | |
637 | r= self.data.yrange |
|
637 | r= self.data.yrange | |
638 | delta_height = r[1]-r[0] |
|
638 | delta_height = r[1]-r[0] | |
639 | #print("1",r) |
|
639 | #print("1",r) | |
640 | r_mask= numpy.where(r>=0)[0] |
|
640 | r_mask= numpy.where(r>=0)[0] | |
641 | r = numpy.arange(len(r_mask))*delta_height |
|
641 | r = numpy.arange(len(r_mask))*delta_height | |
642 | #print("2",r) |
|
642 | #print("2",r) | |
643 | self.y = 2*r |
|
643 | self.y = 2*r | |
644 | ######self.y = self.data.yrange |
|
644 | ######self.y = self.data.yrange | |
645 | # RADAR |
|
645 | # RADAR | |
646 | #data_weather = data['weather'] |
|
646 | #data_weather = data['weather'] | |
647 | # PEDESTAL |
|
647 | # PEDESTAL | |
648 | #data_azi = data['azi'] |
|
648 | #data_azi = data['azi'] | |
649 | res = 1 |
|
649 | res = 1 | |
650 | # STEP |
|
650 | # STEP | |
651 | step = (360/(res*data['weather'].shape[0])) |
|
651 | step = (360/(res*data['weather'].shape[0])) | |
652 | #print("shape wr_data", wr_data.shape) |
|
652 | #print("shape wr_data", wr_data.shape) | |
653 | #print("shape wr_azi",wr_azi.shape) |
|
653 | #print("shape wr_azi",wr_azi.shape) | |
654 | #print("step",step) |
|
654 | #print("step",step) | |
655 | ####print("Time---->",self.data.times[-1],thisDatetime) |
|
655 | ####print("Time---->",self.data.times[-1],thisDatetime) | |
656 | #print("alturas", len(self.y))numpy.where(r>=0) |
|
656 | #print("alturas", len(self.y))numpy.where(r>=0) | |
657 | self.res_weather, self.res_azi = self.const_ploteo(data_weather=data['weather'][:,r_mask],data_azi=data['azi'],step=step,res=res) |
|
657 | self.res_weather, self.res_azi = self.const_ploteo(data_weather=data['weather'][:,r_mask],data_azi=data['azi'],step=step,res=res) | |
658 | #numpy.set_printoptions(suppress=True) |
|
658 | #numpy.set_printoptions(suppress=True) | |
659 | #print("resultado",self.res_azi) |
|
659 | #print("resultado",self.res_azi) | |
660 | ###########################/DATA_RM/10_tmp/ch0############################### |
|
660 | ###########################/DATA_RM/10_tmp/ch0############################### | |
661 | ################# PLOTEO ################### |
|
661 | ################# PLOTEO ################### | |
662 | ########################################################## |
|
662 | ########################################################## | |
663 |
|
663 | |||
664 | for i,ax in enumerate(self.axes): |
|
664 | for i,ax in enumerate(self.axes): | |
665 | if ax.firsttime: |
|
665 | if ax.firsttime: | |
666 | plt.clf() |
|
666 | plt.clf() | |
667 | cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=8, vmax=35) |
|
667 | cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=8, vmax=35) | |
668 | else: |
|
668 | else: | |
669 | plt.clf() |
|
669 | plt.clf() | |
670 | cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=8, vmax=35) |
|
670 | cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=8, vmax=35) | |
671 | caax = cgax.parasites[0] |
|
671 | caax = cgax.parasites[0] | |
672 | paax = cgax.parasites[1] |
|
672 | paax = cgax.parasites[1] | |
673 | cbar = plt.gcf().colorbar(pm, pad=0.075) |
|
673 | cbar = plt.gcf().colorbar(pm, pad=0.075) | |
674 | caax.set_xlabel('x_range [km]') |
|
674 | caax.set_xlabel('x_range [km]') | |
675 | caax.set_ylabel('y_range [km]') |
|
675 | caax.set_ylabel('y_range [km]') | |
676 | plt.text(1.0, 1.05, 'azimuth '+str(thisDatetime)+" step "+str(self.ini), transform=caax.transAxes, va='bottom',ha='right') |
|
676 | plt.text(1.0, 1.05, 'azimuth '+str(thisDatetime)+" step "+str(self.ini), transform=caax.transAxes, va='bottom',ha='right') | |
677 |
|
677 | |||
678 | self.ini= self.ini+1 |
|
678 | self.ini= self.ini+1 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now