##// END OF EJS Templates
Fix bug in CrossSpectraPlot
George Yong -
r1201:2ee3e6bd4db0
parent child
Show More
@@ -1112,7 +1112,7 class PlotterData(object):
1112 MAXNUMY = 100
1112 MAXNUMY = 100
1113
1113
1114 def __init__(self, code, throttle_value, exp_code, buffering=True):
1114 def __init__(self, code, throttle_value, exp_code, buffering=True):
1115
1115
1116 self.throttle = throttle_value
1116 self.throttle = throttle_value
1117 self.exp_code = exp_code
1117 self.exp_code = exp_code
1118 self.buffering = buffering
1118 self.buffering = buffering
@@ -1173,11 +1173,11 class PlotterData(object):
1173 plot = 'snr'
1173 plot = 'snr'
1174 self.data[plot] = {}
1174 self.data[plot] = {}
1175
1175
1176 if 'spc' in self.data or 'rti' in self.data:
1176 if 'spc' in self.data or 'rti' in self.data or 'cspc' in self.data:
1177 self.data['noise'] = {}
1177 self.data['noise'] = {}
1178 if 'noise' not in self.plottypes:
1178 if 'noise' not in self.plottypes:
1179 self.plottypes.append('noise')
1179 self.plottypes.append('noise')
1180
1180
1181 def shape(self, key):
1181 def shape(self, key):
1182 '''
1182 '''
1183 Get the shape of the one-element data for the given key
1183 Get the shape of the one-element data for the given key
@@ -1193,10 +1193,10 class PlotterData(object):
1193 '''
1193 '''
1194 Update data object with new dataOut
1194 Update data object with new dataOut
1195 '''
1195 '''
1196
1196
1197 if tm in self.__times:
1197 if tm in self.__times:
1198 return
1198 return
1199
1199
1200 self.type = dataOut.type
1200 self.type = dataOut.type
1201 self.parameters = getattr(dataOut, 'parameters', [])
1201 self.parameters = getattr(dataOut, 'parameters', [])
1202 if hasattr(dataOut, 'pairsList'):
1202 if hasattr(dataOut, 'pairsList'):
@@ -1209,16 +1209,18 class PlotterData(object):
1209 if 'spc' in self.plottypes or 'cspc' in self.plottypes:
1209 if 'spc' in self.plottypes or 'cspc' in self.plottypes:
1210 self.xrange = (dataOut.getFreqRange(1)/1000.,
1210 self.xrange = (dataOut.getFreqRange(1)/1000.,
1211 dataOut.getAcfRange(1), dataOut.getVelRange(1))
1211 dataOut.getAcfRange(1), dataOut.getVelRange(1))
1212 self.factor = dataOut.normFactor
1212 self.__heights.append(dataOut.heightList)
1213 self.__heights.append(dataOut.heightList)
1213 self.__all_heights.update(dataOut.heightList)
1214 self.__all_heights.update(dataOut.heightList)
1214 self.__times.append(tm)
1215 self.__times.append(tm)
1215
1216
1216 for plot in self.plottypes:
1217 for plot in self.plottypes:
1217 if plot == 'spc':
1218 if plot == 'spc':
1218 z = dataOut.data_spc/dataOut.normFactor
1219 z = dataOut.data_spc/dataOut.normFactor
1219 buffer = 10*numpy.log10(z)
1220 buffer = 10*numpy.log10(z)
1220 if plot == 'cspc':
1221 if plot == 'cspc':
1221 buffer = dataOut.data_cspc
1222 z = dataOut.data_spc/dataOut.normFactor
1223 buffer = (dataOut.data_spc, dataOut.data_cspc)
1222 if plot == 'noise':
1224 if plot == 'noise':
1223 buffer = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
1225 buffer = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor)
1224 if plot == 'rti':
1226 if plot == 'rti':
@@ -1242,8 +1244,11 class PlotterData(object):
1242 if plot == 'param':
1244 if plot == 'param':
1243 buffer = dataOut.data_param
1245 buffer = dataOut.data_param
1244
1246
1245 if 'spc' in plot:
1247 if plot == 'spc':
1246 self.data[plot] = buffer
1248 self.data[plot] = buffer
1249 elif plot == 'cspc':
1250 self.data['spc'] = buffer[0]
1251 self.data['cspc'] = buffer[1]
1247 else:
1252 else:
1248 if self.buffering:
1253 if self.buffering:
1249 self.data[plot][tm] = buffer
1254 self.data[plot][tm] = buffer
@@ -672,7 +672,7 class Plot(Operation):
672 ax.set_title('{} {} {}'.format(
672 ax.set_title('{} {} {}'.format(
673 self.titles[n],
673 self.titles[n],
674 self.getDateTime(self.data.max_time).strftime(
674 self.getDateTime(self.data.max_time).strftime(
675 '%Y-%m-%dT%H:%M:%S'),
675 '%H:%M:%S'),
676 self.time_label),
676 self.time_label),
677 size=8)
677 size=8)
678 else:
678 else:
@@ -112,6 +112,7 class SpectraPlot(Plot):
112 class CrossSpectraPlot(Plot):
112 class CrossSpectraPlot(Plot):
113
113
114 CODE = 'cspc'
114 CODE = 'cspc'
115 colormap = 'jet'
115 zmin_coh = None
116 zmin_coh = None
116 zmax_coh = None
117 zmax_coh = None
117 zmin_phase = None
118 zmin_phase = None
@@ -138,7 +139,7 class CrossSpectraPlot(Plot):
138 else:
139 else:
139 x = self.data.xrange[2]
140 x = self.data.xrange[2]
140 self.xlabel = "Velocity (m/s)"
141 self.xlabel = "Velocity (m/s)"
141
142
142 self.titles = []
143 self.titles = []
143
144
144 y = self.data.heights
145 y = self.data.heights
@@ -150,32 +151,33 class CrossSpectraPlot(Plot):
150 noise = self.data['noise'][n][-1]
151 noise = self.data['noise'][n][-1]
151 pair = self.data.pairs[n]
152 pair = self.data.pairs[n]
152 ax = self.axes[4 * n]
153 ax = self.axes[4 * n]
153 ax3 = self.axes[4 * n + 3]
154 spc0 = 10.*numpy.log10(spc[pair[0]]/self.data.factor)
154 if ax.firsttime:
155 if ax.firsttime:
155 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
156 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
156 self.xmin = self.xmin if self.xmin else -self.xmax
157 self.xmin = self.xmin if self.xmin else -self.xmax
157 self.zmin = self.zmin if self.zmin else numpy.nanmin(spc)
158 self.zmin = self.zmin if self.zmin else numpy.nanmin(spc)
158 self.zmax = self.zmax if self.zmax else numpy.nanmax(spc)
159 self.zmax = self.zmax if self.zmax else numpy.nanmax(spc)
159 ax.plt = ax.pcolormesh(x, y, spc[pair[0]].T,
160 ax.plt = ax.pcolormesh(x , y , spc0.T,
160 vmin=self.zmin,
161 vmin=self.zmin,
161 vmax=self.zmax,
162 vmax=self.zmax,
162 cmap=plt.get_cmap(self.colormap)
163 cmap=plt.get_cmap(self.colormap)
163 )
164 )
164 else:
165 else:
165 ax.plt.set_array(spc[pair[0]].T.ravel())
166 ax.plt.set_array(spc0.T.ravel())
166 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
167 self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise))
167
168
168 ax = self.axes[4 * n + 1]
169 ax = self.axes[4 * n + 1]
170 spc1 = 10.*numpy.log10(spc[pair[1]]/self.data.factor)
169 if ax.firsttime:
171 if ax.firsttime:
170 ax.plt = ax.pcolormesh(x, y, spc[pair[1]].T,
172 ax.plt = ax.pcolormesh(x , y, spc1.T,
171 vmin=self.zmin,
173 vmin=self.zmin,
172 vmax=self.zmax,
174 vmax=self.zmax,
173 cmap=plt.get_cmap(self.colormap)
175 cmap=plt.get_cmap(self.colormap)
174 )
176 )
175 else:
177 else:
176 ax.plt.set_array(spc[pair[1]].T.ravel())
178 ax.plt.set_array(spc1.T.ravel())
177 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
179 self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise))
178
180
179 out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
181 out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
180 coh = numpy.abs(out)
182 coh = numpy.abs(out)
181 phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
183 phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
@@ -191,13 +193,13 class CrossSpectraPlot(Plot):
191 ax.plt.set_array(coh.T.ravel())
193 ax.plt.set_array(coh.T.ravel())
192 self.titles.append(
194 self.titles.append(
193 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
195 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
194
196
195 ax = self.axes[4 * n + 3]
197 ax = self.axes[4 * n + 3]
196 if ax.firsttime:
198 if ax.firsttime:
197 ax.plt = ax.pcolormesh(x, y, phase.T,
199 ax.plt = ax.pcolormesh(x, y, phase.T,
198 vmin=-180,
200 vmin=-180,
199 vmax=180,
201 vmax=180,
200 cmap=plt.get_cmap(self.colormap_phase)
202 cmap=plt.get_cmap(self.colormap_phase)
201 )
203 )
202 else:
204 else:
203 ax.plt.set_array(phase.T.ravel())
205 ax.plt.set_array(phase.T.ravel())
@@ -611,3 +613,4 class PolarMapPlot(Plot):
611 self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels]
613 self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels]
612 self.titles = ['{} {}'.format(
614 self.titles = ['{} {}'.format(
613 self.data.parameters[x], title) for x in self.channels]
615 self.data.parameters[x], title) for x in self.channels]
616 No newline at end of file
@@ -190,9 +190,8 def MPDecorator(BaseClass):
190 self.sender = None
190 self.sender = None
191 self.receiver = None
191 self.receiver = None
192 self.name = BaseClass.__name__
192 self.name = BaseClass.__name__
193 if 'plot' in self.name.lower():
193 if 'plot' in self.name.lower() and not self.name.endswith('_'):
194 if not self.name.endswith('_'):
194 self.name = '{}{}'.format(self.CODE.upper(), 'Plot')
195 self.name = '{}{}'.format(self.CODE.upper(), 'Plot')
196 self.start_time = time.time()
195 self.start_time = time.time()
197
196
198 if len(self.args) is 3:
197 if len(self.args) is 3:
@@ -294,7 +293,7 def MPDecorator(BaseClass):
294 op(**kwargs)
293 op(**kwargs)
295 elif optype == 'other' and not self.dataOut.flagNoData:
294 elif optype == 'other' and not self.dataOut.flagNoData:
296 self.dataOut = op.run(self.dataOut, **kwargs)
295 self.dataOut = op.run(self.dataOut, **kwargs)
297 elif optype == 'external':
296 elif optype == 'external' and not self.dataOut.flagNoData:
298 if not self.dataOut.flagNoData or self.dataOut.error:
297 if not self.dataOut.flagNoData or self.dataOut.error:
299 self.publish(self.dataOut, opId)
298 self.publish(self.dataOut, opId)
300
299
General Comments 0
You need to be logged in to leave comments. Login now