@@ -152,7 +152,7 class OperationConf(ConfBase): | |||
|
152 | 152 | |
|
153 | 153 | className = eval(self.name) |
|
154 | 154 | |
|
155 | if 'Plot' in self.name or 'Writer' in self.name or 'Send' in self.name: | |
|
155 | if 'Plot' in self.name or 'Writer' in self.name or 'Send' in self.name or 'print' in self.name: | |
|
156 | 156 | kwargs = self.getKwargs() |
|
157 | 157 | opObj = className(self.id, self.id, self.project_id, self.err_queue, **kwargs) |
|
158 | 158 | opObj.start() |
@@ -1122,13 +1122,14 class PlotterData(object): | |||
|
1122 | 1122 | self.localtime = False |
|
1123 | 1123 | self.data = {} |
|
1124 | 1124 | self.meta = {} |
|
1125 | self.__times = [] | |
|
1126 | 1125 | self.__heights = [] |
|
1127 | 1126 | |
|
1128 | 1127 | if 'snr' in code: |
|
1129 | 1128 | self.plottypes = ['snr'] |
|
1130 | 1129 | elif code == 'spc': |
|
1131 | 1130 | self.plottypes = ['spc', 'noise', 'rti'] |
|
1131 | elif code == 'cspc': | |
|
1132 | self.plottypes = ['cspc', 'spc', 'noise', 'rti'] | |
|
1132 | 1133 | elif code == 'rti': |
|
1133 | 1134 | self.plottypes = ['noise', 'rti'] |
|
1134 | 1135 | else: |
@@ -1143,17 +1144,17 class PlotterData(object): | |||
|
1143 | 1144 | |
|
1144 | 1145 | def __str__(self): |
|
1145 | 1146 | dum = ['{}{}'.format(key, self.shape(key)) for key in self.data] |
|
1146 |
return 'Data[{}][{}]'.format(';'.join(dum), len(self. |
|
|
1147 | return 'Data[{}][{}]'.format(';'.join(dum), len(self.times)) | |
|
1147 | 1148 | |
|
1148 | 1149 | def __len__(self): |
|
1149 |
return len(self. |
|
|
1150 | return len(self.data[self.key]) | |
|
1150 | 1151 | |
|
1151 | 1152 | def __getitem__(self, key): |
|
1152 | 1153 | |
|
1153 | 1154 | if key not in self.data: |
|
1154 | 1155 | raise KeyError(log.error('Missing key: {}'.format(key))) |
|
1155 | 1156 | if 'spc' in key or not self.buffering: |
|
1156 | ret = self.data[key] | |
|
1157 | ret = self.data[key][self.tm] | |
|
1157 | 1158 | elif 'scope' in key: |
|
1158 | 1159 | ret = numpy.array(self.data[key][float(self.tm)]) |
|
1159 | 1160 | else: |
@@ -1171,8 +1172,8 class PlotterData(object): | |||
|
1171 | 1172 | ''' |
|
1172 | 1173 | self.type = '' |
|
1173 | 1174 | self.ready = False |
|
1175 | del self.data | |
|
1174 | 1176 | self.data = {} |
|
1175 | self.__times = [] | |
|
1176 | 1177 | self.__heights = [] |
|
1177 | 1178 | self.__all_heights = set() |
|
1178 | 1179 | for plot in self.plottypes: |
@@ -1198,15 +1199,14 class PlotterData(object): | |||
|
1198 | 1199 | if len(self.data[key]): |
|
1199 | 1200 | if 'spc' in key or not self.buffering: |
|
1200 | 1201 | return self.data[key].shape |
|
1201 |
return self.data[key][self. |
|
|
1202 | return self.data[key][self.times[0]].shape | |
|
1202 | 1203 | return (0,) |
|
1203 | 1204 | |
|
1204 | 1205 | def update(self, dataOut, tm): |
|
1205 | 1206 | ''' |
|
1206 | 1207 | Update data object with new dataOut |
|
1207 | 1208 | ''' |
|
1208 | if tm in self.__times: | |
|
1209 | return | |
|
1209 | ||
|
1210 | 1210 | self.profileIndex = dataOut.profileIndex |
|
1211 | 1211 | self.tm = tm |
|
1212 | 1212 | self.type = dataOut.type |
@@ -1223,16 +1223,14 class PlotterData(object): | |||
|
1223 | 1223 | if True in ['spc' in ptype for ptype in self.plottypes]: |
|
1224 | 1224 | self.xrange = (dataOut.getFreqRange(1)/1000., |
|
1225 | 1225 | dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
1226 | self.factor = dataOut.normFactor | |
|
1227 | 1226 | self.__heights.append(dataOut.heightList) |
|
1228 | 1227 | self.__all_heights.update(dataOut.heightList) |
|
1229 | self.__times.append(tm) | |
|
1228 | ||
|
1230 | 1229 | for plot in self.plottypes: |
|
1231 | 1230 | if plot in ('spc', 'spc_moments', 'spc_cut'): |
|
1232 | 1231 | z = dataOut.data_spc/dataOut.normFactor |
|
1233 | 1232 | buffer = 10*numpy.log10(z) |
|
1234 | 1233 | if plot == 'cspc': |
|
1235 | z = dataOut.data_spc/dataOut.normFactor | |
|
1236 | 1234 | buffer = (dataOut.data_spc, dataOut.data_cspc) |
|
1237 | 1235 | if plot == 'noise': |
|
1238 | 1236 | buffer = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
@@ -1270,18 +1268,17 class PlotterData(object): | |||
|
1270 | 1268 | self.nProfiles = dataOut.nProfiles |
|
1271 | 1269 | |
|
1272 | 1270 | if plot == 'spc': |
|
1273 | self.data['spc'] = buffer | |
|
1271 | self.data['spc'][tm] = buffer | |
|
1274 | 1272 | elif plot == 'cspc': |
|
1275 |
self.data['spc'] = buffer |
|
|
1276 | self.data['cspc'] = buffer[1] | |
|
1273 | self.data['cspc'][tm] = buffer | |
|
1277 | 1274 | elif plot == 'spc_moments': |
|
1278 | self.data['spc'] = buffer | |
|
1275 | self.data['spc'][tm] = buffer | |
|
1279 | 1276 | self.data['moments'][tm] = dataOut.moments |
|
1280 | 1277 | else: |
|
1281 | 1278 | if self.buffering: |
|
1282 | 1279 | self.data[plot][tm] = buffer |
|
1283 | 1280 | else: |
|
1284 | self.data[plot] = buffer | |
|
1281 | self.data[plot][tm] = buffer | |
|
1285 | 1282 | |
|
1286 | 1283 | if dataOut.channelList is None: |
|
1287 | 1284 | self.channels = range(buffer.shape[0]) |
@@ -1302,7 +1299,7 class PlotterData(object): | |||
|
1302 | 1299 | for key in self.data: |
|
1303 | 1300 | shape = self.shape(key)[:-1] + H.shape |
|
1304 | 1301 | for tm, obj in list(self.data[key].items()): |
|
1305 |
h = self.__heights[self. |
|
|
1302 | h = self.__heights[self.times.index(tm)] | |
|
1306 | 1303 | if H.size == h.size: |
|
1307 | 1304 | continue |
|
1308 | 1305 | index = numpy.where(numpy.in1d(H, h))[0] |
@@ -1313,19 +1310,18 class PlotterData(object): | |||
|
1313 | 1310 | dummy[index] = obj |
|
1314 | 1311 | self.data[key][tm] = dummy |
|
1315 | 1312 | |
|
1316 |
self.__heights = [H for tm in self. |
|
|
1313 | self.__heights = [H for tm in self.times] | |
|
1317 | 1314 | |
|
1318 | def jsonify(self, plot_name, plot_type, decimate=False): | |
|
1315 | def jsonify(self, tm, plot_name, plot_type, decimate=False): | |
|
1319 | 1316 | ''' |
|
1320 | 1317 | Convert data to json |
|
1321 | 1318 | ''' |
|
1322 | 1319 | |
|
1323 | tm = self.times[-1] | |
|
1324 | 1320 | dy = int(self.heights.size/self.MAXNUMY) + 1 |
|
1325 |
if self.key in ('spc', 'cspc') |
|
|
1326 | dx = int(self.data[self.key].shape[1]/self.MAXNUMX) + 1 | |
|
1321 | if self.key in ('spc', 'cspc'): | |
|
1322 | dx = int(self.data[self.key][tm].shape[1]/self.MAXNUMX) + 1 | |
|
1327 | 1323 | data = self.roundFloats( |
|
1328 | self.data[self.key][::, ::dx, ::dy].tolist()) | |
|
1324 | self.data[self.key][tm][::, ::dx, ::dy].tolist()) | |
|
1329 | 1325 | else: |
|
1330 | 1326 | if self.key is 'noise': |
|
1331 | 1327 | data = [[x] for x in self.roundFloats(self.data[self.key][tm].tolist())] |
@@ -1358,7 +1354,8 class PlotterData(object): | |||
|
1358 | 1354 | Return the list of times of the current data |
|
1359 | 1355 | ''' |
|
1360 | 1356 | |
|
1361 |
ret = numpy.array(self. |
|
|
1357 | ret = numpy.array([*self.data[self.key]]) | |
|
1358 | if self: | |
|
1362 | 1359 | ret.sort() |
|
1363 | 1360 | return ret |
|
1364 | 1361 |
@@ -202,7 +202,7 class Plot(Operation): | |||
|
202 | 202 | self.zlimits = kwargs.get('zlimits', None) |
|
203 | 203 | self.xmin = kwargs.get('xmin', None) |
|
204 | 204 | self.xmax = kwargs.get('xmax', None) |
|
205 |
self.xrange = kwargs.get('xrange', 2 |
|
|
205 | self.xrange = kwargs.get('xrange', 12) | |
|
206 | 206 | self.xscale = kwargs.get('xscale', None) |
|
207 | 207 | self.ymin = kwargs.get('ymin', None) |
|
208 | 208 | self.ymax = kwargs.get('ymax', None) |
@@ -228,6 +228,7 class Plot(Operation): | |||
|
228 | 228 | self.exp_code = kwargs.get('exp_code', None) |
|
229 | 229 | self.plot_server = kwargs.get('plot_server', False) |
|
230 | 230 | self.sender_period = kwargs.get('sender_period', 60) |
|
231 | self.tag = kwargs.get('tag', '') | |
|
231 | 232 | self.height_index = kwargs.get('height_index', None) |
|
232 | 233 | self.__throttle_plot = apply_throttle(self.throttle) |
|
233 | 234 | self.data = PlotterData( |
@@ -572,19 +573,29 class Plot(Operation): | |||
|
572 | 573 | |
|
573 | 574 | self.sender_time = self.data.tm |
|
574 | 575 | |
|
575 |
attrs = ['titles', 'zmin', 'zmax', ' |
|
|
576 | attrs = ['titles', 'zmin', 'zmax', 'tag', 'ymin', 'ymax'] | |
|
576 | 577 | for attr in attrs: |
|
577 | 578 | value = getattr(self, attr) |
|
578 |
if value |
|
|
579 | self.data.meta[attr] = getattr(self, attr) | |
|
579 | if value: | |
|
580 | if isinstance(value, (numpy.float32, numpy.float64)): | |
|
581 | value = round(float(value), 2) | |
|
582 | self.data.meta[attr] = value | |
|
583 | if self.colormap == 'jet': | |
|
584 | self.data.meta['colormap'] = 'Jet' | |
|
585 | elif 'RdBu' in self.colormap: | |
|
586 | self.data.meta['colormap'] = 'RdBu' | |
|
587 | else: | |
|
588 | self.data.meta['colormap'] = 'Viridis' | |
|
580 | 589 | self.data.meta['interval'] = int(interval) |
|
581 | msg = self.data.jsonify(self.plot_name, self.plot_type) | |
|
582 |
self.sender_queue.put(m |
|
|
590 | # msg = self.data.jsonify(self.data.tm, self.plot_name, self.plot_type) | |
|
591 | self.sender_queue.put(self.data.tm) | |
|
583 | 592 | |
|
584 | 593 | while True: |
|
585 | 594 | if self.sender_queue.empty(): |
|
586 | 595 | break |
|
587 |
|
|
|
596 | tm = self.sender_queue.get() | |
|
597 | msg = self.data.jsonify(tm, self.plot_name, self.plot_type) | |
|
598 | self.socket.send_string(msg) | |
|
588 | 599 | socks = dict(self.poll.poll(5000)) |
|
589 | 600 | if socks.get(self.socket) == zmq.POLLIN: |
|
590 | 601 | reply = self.socket.recv_string() |
@@ -598,7 +609,7 class Plot(Operation): | |||
|
598 | 609 | else: |
|
599 | 610 | log.warning( |
|
600 | 611 | "No response from server, retrying...", self.name) |
|
601 |
self.sender_queue.put(m |
|
|
612 | self.sender_queue.put(self.data.tm) | |
|
602 | 613 | self.socket.setsockopt(zmq.LINGER, 0) |
|
603 | 614 | self.socket.close() |
|
604 | 615 | self.poll.unregister(self.socket) |
@@ -647,9 +658,9 class Plot(Operation): | |||
|
647 | 658 | if self.localtime: |
|
648 | 659 | t -= time.timezone |
|
649 | 660 | |
|
650 | if 'buffer' in self.plot_type: | |
|
651 | 661 |
|
|
652 | 662 |
|
|
663 | if 'buffer' in self.plot_type: | |
|
653 | 664 | self.xmin = self.getDateTime(t).hour |
|
654 | 665 |
|
|
655 | 666 |
|
@@ -674,9 +685,10 class Plot(Operation): | |||
|
674 | 685 | if dataOut.useLocalTime and not self.localtime: |
|
675 | 686 | tm += time.timezone |
|
676 | 687 | |
|
677 |
if |
|
|
688 | if self.data and (tm - self.tmin) >= self.xrange*60*60: | |
|
678 | 689 | self.save_counter = self.save_period |
|
679 | 690 | self.__plot() |
|
691 | if 'time' in self.xaxis: | |
|
680 | 692 | self.xmin += self.xrange |
|
681 | 693 | if self.xmin >= 24: |
|
682 | 694 | self.xmin -= 24 |
@@ -126,39 +126,38 class CrossSpectraPlot(Plot): | |||
|
126 | 126 | |
|
127 | 127 | y = self.data.heights |
|
128 | 128 | self.y = y |
|
129 | spc = self.data['spc'] | |
|
130 |
|
|
|
129 | nspc = self.data['spc'] | |
|
130 | spc = self.data['cspc'][0] | |
|
131 | cspc = self.data['cspc'][1] | |
|
131 | 132 | |
|
132 | 133 | for n in range(self.nrows): |
|
133 |
noise = self.data['noise'][ |
|
|
134 | noise = self.data['noise'][:,-1] | |
|
134 | 135 | pair = self.data.pairs[n] |
|
135 | 136 | ax = self.axes[4 * n] |
|
136 | spc0 = 10.*numpy.log10(spc[pair[0]]/self.data.factor) | |
|
137 | 137 | if ax.firsttime: |
|
138 | 138 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
139 | 139 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
140 | self.zmin = self.zmin if self.zmin else numpy.nanmin(spc) | |
|
141 | self.zmax = self.zmax if self.zmax else numpy.nanmax(spc) | |
|
142 | ax.plt = ax.pcolormesh(x , y , spc0.T, | |
|
140 | self.zmin = self.zmin if self.zmin else numpy.nanmin(nspc) | |
|
141 | self.zmax = self.zmax if self.zmax else numpy.nanmax(nspc) | |
|
142 | ax.plt = ax.pcolormesh(x , y , nspc[pair[0]].T, | |
|
143 | 143 | vmin=self.zmin, |
|
144 | 144 | vmax=self.zmax, |
|
145 | 145 | cmap=plt.get_cmap(self.colormap) |
|
146 | 146 | ) |
|
147 | 147 | else: |
|
148 | ax.plt.set_array(spc0.T.ravel()) | |
|
149 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise)) | |
|
148 | ax.plt.set_array(nspc[pair[0]].T.ravel()) | |
|
149 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise[pair[0]])) | |
|
150 | 150 | |
|
151 | 151 | ax = self.axes[4 * n + 1] |
|
152 | spc1 = 10.*numpy.log10(spc[pair[1]]/self.data.factor) | |
|
153 | 152 | if ax.firsttime: |
|
154 | ax.plt = ax.pcolormesh(x , y, spc1.T, | |
|
153 | ax.plt = ax.pcolormesh(x , y, nspc[pair[1]].T, | |
|
155 | 154 | vmin=self.zmin, |
|
156 | 155 | vmax=self.zmax, |
|
157 | 156 | cmap=plt.get_cmap(self.colormap) |
|
158 | 157 | ) |
|
159 | 158 | else: |
|
160 | ax.plt.set_array(spc1.T.ravel()) | |
|
161 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise)) | |
|
159 | ax.plt.set_array(nspc[pair[1]].T.ravel()) | |
|
160 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise[pair[1]])) | |
|
162 | 161 | |
|
163 | 162 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
164 | 163 | coh = numpy.abs(out) |
@@ -300,6 +299,7 class NoisePlot(Plot): | |||
|
300 | 299 | self.nrows = 1 |
|
301 | 300 | self.nplots = 1 |
|
302 | 301 | self.ylabel = 'Intensity [dB]' |
|
302 | self.xlabel = 'Time' | |
|
303 | 303 | self.titles = ['Noise'] |
|
304 | 304 | self.colorbar = False |
|
305 | 305 |
@@ -21,3 +21,4 from .jroIO_mira35c import * | |||
|
21 | 21 | from .julIO_param import * |
|
22 | 22 | |
|
23 | 23 | from .pxIO_param import * |
|
24 | from .jroIO_simulator import * No newline at end of file |
@@ -14,7 +14,7 import time | |||
|
14 | 14 | import datetime |
|
15 | 15 | import zmq |
|
16 | 16 | |
|
17 | from schainpy.model.proc.jroproc_base import Operation | |
|
17 | from schainpy.model.proc.jroproc_base import Operation, MPDecorator | |
|
18 | 18 | from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader |
|
19 | 19 | from schainpy.model.data.jroheaderIO import get_dtype_index, get_numpy_dtype, get_procflag_dtype, get_dtype_width |
|
20 | 20 | from schainpy.utils import log |
@@ -1555,6 +1555,7 class JRODataWriter(Reader): | |||
|
1555 | 1555 | self.putData() |
|
1556 | 1556 | return self.dataOut |
|
1557 | 1557 | |
|
1558 | @MPDecorator | |
|
1558 | 1559 | class printInfo(Operation): |
|
1559 | 1560 | |
|
1560 | 1561 | def __init__(self): |
@@ -1564,7 +1565,7 class printInfo(Operation): | |||
|
1564 | 1565 | |
|
1565 | 1566 | def run(self, dataOut, headers = ['systemHeaderObj', 'radarControllerHeaderObj', 'processingHeaderObj']): |
|
1566 | 1567 | if self.__printInfo == False: |
|
1567 |
return |
|
|
1568 | return | |
|
1568 | 1569 | |
|
1569 | 1570 | for header in headers: |
|
1570 | 1571 | if hasattr(dataOut, header): |
@@ -1577,4 +1578,3 class printInfo(Operation): | |||
|
1577 | 1578 | log.warning('Header {} Not found in object'.format(header)) |
|
1578 | 1579 | |
|
1579 | 1580 | self.__printInfo = False |
|
1580 | return dataOut No newline at end of file |
@@ -377,6 +377,23 class setAttribute(Operation): | |||
|
377 | 377 | return dataOut |
|
378 | 378 | |
|
379 | 379 | |
|
380 | @MPDecorator | |
|
381 | class printAttribute(Operation): | |
|
382 | ''' | |
|
383 | Print an arbitrary attribute of dataOut | |
|
384 | ''' | |
|
385 | ||
|
386 | def __init__(self): | |
|
387 | ||
|
388 | Operation.__init__(self) | |
|
389 | ||
|
390 | def run(self, dataOut, attributes): | |
|
391 | ||
|
392 | for attr in attributes: | |
|
393 | if hasattr(dataOut, attr): | |
|
394 | log.log(getattr(dataOut, attr), attr) | |
|
395 | ||
|
396 | ||
|
380 | 397 | class interpolateHeights(Operation): |
|
381 | 398 | |
|
382 | 399 | def run(self, dataOut, topLim, botLim): |
General Comments 0
You need to be logged in to leave comments.
Login now