##// END OF EJS Templates
Se agrega clase para ploteo de Espectros Cruzados.
Daniel Valdez -
r215:eb698777be0f
parent child
Show More
@@ -1,305 +1,305
1 1 import numpy
2 2 import datetime
3 3 import matplotlib
4 4 matplotlib.use("TKAgg")
5 5 import matplotlib.pyplot
6 6 import matplotlib.dates
7 7 #import scitools.numpyutils
8 8 from mpl_toolkits.axes_grid1 import make_axes_locatable
9 9
10 10 from matplotlib.dates import DayLocator, HourLocator, MinuteLocator, SecondLocator, DateFormatter
11 11 from matplotlib.ticker import FuncFormatter
12 12 from matplotlib.ticker import *
13 13
14 def init(idfigure, wintitle, width, height, facecolor="w"):
15
16 matplotlib.pyplot.ioff()
17 fig = matplotlib.pyplot.matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor)
18 fig.canvas.manager.set_window_title(wintitle)
19 fig.canvas.manager.resize(width, height)
20 matplotlib.pyplot.ion()
21
22 return fig
23
24 def setWinTitle(fig, title):
25
26 fig.canvas.manager.set_window_title(title)
27
28 def setTitle(idfigure, title):
29 fig = matplotlib.pyplot.figure(idfigure)
30 fig.suptitle(title)
31
32 def makeAxes(idfigure, nrow, ncol, xpos, ypos, colspan, rowspan):
33 fig = matplotlib.pyplot.figure(idfigure)
34 ax = matplotlib.pyplot.subplot2grid((nrow, ncol), (xpos, ypos), colspan=colspan, rowspan=rowspan)
35 return ax
36
37 def setTextFromAxes(idfigure, ax, title):
38 fig = matplotlib.pyplot.figure(idfigure)
39 ax.annotate(title, xy=(.1, .99),
40 xycoords='figure fraction',
41 horizontalalignment='left', verticalalignment='top',
42 fontsize=10)
43
44 def pline(ax, x, y, xmin, xmax, ymin, ymax, xlabel, ylabel, title, firsttime):
45
46 if firsttime:
47 ax.plot(x, y)
48 ax.set_xlim([xmin,xmax])
49 ax.set_ylim([ymin,ymax])
50 ax.set_xlabel(xlabel, size=8)
51 ax.set_ylabel(ylabel, size=8)
52 ax.set_title(title, size=10)
53 matplotlib.pyplot.tight_layout()
54 else:
55 ax.lines[0].set_data(x,y)
56
57 def draw(idfigure):
58
59 fig = matplotlib.pyplot.figure(idfigure)
60 fig.canvas.draw()
61
62 def pcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, xlabel, ylabel, title, firsttime, mesh):
63
64 if firsttime:
65 divider = make_axes_locatable(ax)
66 ax_cb = divider.new_horizontal(size="4%", pad=0.05)
67 fig1 = ax.get_figure()
68 fig1.add_axes(ax_cb)
69
70 ax.set_xlim([xmin,xmax])
71 ax.set_ylim([ymin,ymax])
72 ax.set_xlabel(xlabel)
73 ax.set_ylabel(ylabel)
74 ax.set_title(title)
75 print x
76 imesh=ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax)
77 matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
78 ax_cb.yaxis.tick_right()
79 for tl in ax_cb.get_yticklabels():
80 tl.set_visible(True)
81 ax_cb.yaxis.tick_right()
82 matplotlib.pyplot.tight_layout()
83 return imesh
84 else:
14 #def init(idfigure, wintitle, width, height, facecolor="w"):
15 #
16 # matplotlib.pyplot.ioff()
17 # fig = matplotlib.pyplot.matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor)
18 # fig.canvas.manager.set_window_title(wintitle)
19 # fig.canvas.manager.resize(width, height)
20 # matplotlib.pyplot.ion()
21 #
22 # return fig
23 #
24 #def setWinTitle(fig, title):
25 #
26 # fig.canvas.manager.set_window_title(title)
27 #
28 #def setTitle(idfigure, title):
29 # fig = matplotlib.pyplot.figure(idfigure)
30 # fig.suptitle(title)
31 #
32 #def makeAxes(idfigure, nrow, ncol, xpos, ypos, colspan, rowspan):
33 # fig = matplotlib.pyplot.figure(idfigure)
34 # ax = matplotlib.pyplot.subplot2grid((nrow, ncol), (xpos, ypos), colspan=colspan, rowspan=rowspan)
35 # return ax
36 #
37 #def setTextFromAxes(idfigure, ax, title):
38 # fig = matplotlib.pyplot.figure(idfigure)
39 # ax.annotate(title, xy=(.1, .99),
40 # xycoords='figure fraction',
41 # horizontalalignment='left', verticalalignment='top',
42 # fontsize=10)
43 #
44 #def pline(ax, x, y, xmin, xmax, ymin, ymax, xlabel, ylabel, title, firsttime):
45 #
46 # if firsttime:
47 # ax.plot(x, y)
85 48 # ax.set_xlim([xmin,xmax])
86 49 # ax.set_ylim([ymin,ymax])
87 ax.set_xlabel(xlabel)
88 ax.set_ylabel(ylabel)
89 ax.set_title(title)
90
91 z = z.T
92 # z = z[0:-1,0:-1]
93 mesh.set_array(z.ravel())
94
95 return mesh
50 # ax.set_xlabel(xlabel, size=8)
51 # ax.set_ylabel(ylabel, size=8)
52 # ax.set_title(title, size=10)
53 # matplotlib.pyplot.tight_layout()
54 # else:
55 # ax.lines[0].set_data(x,y)
56 #
57 #def draw(idfigure):
58 #
59 # fig = matplotlib.pyplot.figure(idfigure)
60 # fig.canvas.draw()
61 #
62 #def pcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, xlabel, ylabel, title, firsttime, mesh):
63 #
64 # if firsttime:
65 # divider = make_axes_locatable(ax)
66 # ax_cb = divider.new_horizontal(size="4%", pad=0.05)
67 # fig1 = ax.get_figure()
68 # fig1.add_axes(ax_cb)
69 #
70 # ax.set_xlim([xmin,xmax])
71 # ax.set_ylim([ymin,ymax])
72 # ax.set_xlabel(xlabel)
73 # ax.set_ylabel(ylabel)
74 # ax.set_title(title)
75 # print x
76 # imesh=ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax)
77 # matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
78 # ax_cb.yaxis.tick_right()
79 # for tl in ax_cb.get_yticklabels():
80 # tl.set_visible(True)
81 # ax_cb.yaxis.tick_right()
82 # matplotlib.pyplot.tight_layout()
83 # return imesh
84 # else:
85 ## ax.set_xlim([xmin,xmax])
86 ## ax.set_ylim([ymin,ymax])
87 # ax.set_xlabel(xlabel)
88 # ax.set_ylabel(ylabel)
89 # ax.set_title(title)
90 #
91 # z = z.T
92 ## z = z[0:-1,0:-1]
93 # mesh.set_array(z.ravel())
94 #
95 # return mesh
96 96
97 97 ###########################################
98 98 #Actualizacion de las funciones del driver
99 99 ###########################################
100 100
101 101 def createFigure(idfigure, wintitle, width, height, facecolor="w"):
102 102
103 103 matplotlib.pyplot.ioff()
104 104 fig = matplotlib.pyplot.matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor)
105 105 fig.canvas.manager.set_window_title(wintitle)
106 106 fig.canvas.manager.resize(width, height)
107 107 matplotlib.pyplot.ion()
108 108
109 109 return fig
110 110
111 111 def closeFigure():
112 112
113 113 matplotlib.pyplot.ioff()
114 114 matplotlib.pyplot.show()
115 115
116 116 return
117 117
118 118 def saveFigure(fig, filename):
119 119 fig.savefig(filename)
120 120
121 121 def setWinTitle(fig, title):
122 122
123 123 fig.canvas.manager.set_window_title(title)
124 124
125 125 def setTitle(fig, title):
126 126
127 127 fig.suptitle(title)
128 128
129 129 def createAxes(fig, nrow, ncol, xpos, ypos, colspan, rowspan):
130 130
131 131 matplotlib.pyplot.figure(fig.number)
132 132 axes = matplotlib.pyplot.subplot2grid((nrow, ncol),
133 133 (xpos, ypos),
134 134 colspan=colspan,
135 135 rowspan=rowspan)
136 136 return axes
137 137
138 138 def setAxesText(ax, text):
139 139
140 140 ax.annotate(text,
141 141 xy = (.1, .99),
142 142 xycoords = 'figure fraction',
143 143 horizontalalignment = 'left',
144 144 verticalalignment = 'top',
145 145 fontsize = 10)
146 146
147 147 def printLabels(ax, xlabel, ylabel, title):
148 148
149 149 ax.set_xlabel(xlabel, size=11)
150 150 ax.set_ylabel(ylabel, size=11)
151 151 ax.set_title(title, size=12)
152 152
153 153 def createPline(ax, x, y, xmin, xmax, ymin, ymax, xlabel='', ylabel='', title='',
154 154 ticksize=9, xtick_visible=True, ytick_visible=True,
155 155 nxticks=4, nyticks=10,
156 156 grid=None):
157 157
158 158 """
159 159
160 160 Input:
161 161 grid : None, 'both', 'x', 'y'
162 162 """
163 163
164 164 ax.plot(x, y)
165 165 ax.set_xlim([xmin,xmax])
166 166 ax.set_ylim([ymin,ymax])
167 167
168 168 printLabels(ax, xlabel, ylabel, title)
169 169
170 170 ######################################################
171 171 xtickspos = numpy.arange(nxticks)*int((xmax-xmin)/nxticks) + int(xmin)
172 172 ax.set_xticks(xtickspos)
173 173
174 174 for tick in ax.get_xticklabels():
175 175 tick.set_visible(xtick_visible)
176 176
177 177 for tick in ax.xaxis.get_major_ticks():
178 178 tick.label.set_fontsize(ticksize)
179 179
180 180 ######################################################
181 181 for tick in ax.get_yticklabels():
182 182 tick.set_visible(ytick_visible)
183 183
184 184 for tick in ax.yaxis.get_major_ticks():
185 185 tick.label.set_fontsize(ticksize)
186 186
187 187 iplot = ax.lines[-1]
188 188
189 189 ######################################################
190 190 if '0.' in matplotlib.__version__[0:2]:
191 191 print "The matplotlib version has to be updated to 1.1 or newer"
192 192 return iplot
193 193
194 194 if '1.0.' in matplotlib.__version__[0:4]:
195 195 print "The matplotlib version has to be updated to 1.1 or newer"
196 196 return iplot
197 197
198 198 if grid != None:
199 199 ax.grid(b=True, which='major', axis=grid)
200 200
201 201 matplotlib.pyplot.tight_layout()
202 202
203 203 return iplot
204 204
205 205 def pline(iplot, x, y, xlabel='', ylabel='', title=''):
206 206
207 207 ax = iplot.get_axes()
208 208
209 209 printLabels(ax, xlabel, ylabel, title)
210 210
211 211 iplot.set_data(x, y)
212 212
213 213 def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax,
214 214 xlabel='', ylabel='', title='', ticksize = 9,
215 215 cblabel='', cbsize="5%",
216 216 XAxisAsTime=False):
217 217
218 218 divider = make_axes_locatable(ax)
219 219 ax_cb = divider.new_horizontal(size=cbsize, pad=0.05)
220 220 fig = ax.get_figure()
221 221 fig.add_axes(ax_cb)
222 222
223 223 ax.set_xlim([xmin,xmax])
224 224 ax.set_ylim([ymin,ymax])
225 225
226 226 printLabels(ax, xlabel, ylabel, title)
227 227
228 228 imesh = ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax)
229 229 cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb)
230 230 cb.set_label(cblabel)
231 231
232 232 # for tl in ax_cb.get_yticklabels():
233 233 # tl.set_visible(True)
234 234
235 235 for tick in ax.yaxis.get_major_ticks():
236 236 tick.label.set_fontsize(ticksize)
237 237
238 238 for tick in ax.xaxis.get_major_ticks():
239 239 tick.label.set_fontsize(ticksize)
240 240
241 241 for tick in cb.ax.get_yticklabels():
242 242 tick.set_fontsize(ticksize)
243 243
244 244 ax_cb.yaxis.tick_right()
245 245
246 246 if '0.' in matplotlib.__version__[0:2]:
247 247 print "The matplotlib version has to be updated to 1.1 or newer"
248 248 return imesh
249 249
250 250 if '1.0.' in matplotlib.__version__[0:4]:
251 251 print "The matplotlib version has to be updated to 1.1 or newer"
252 252 return imesh
253 253
254 254 matplotlib.pyplot.tight_layout()
255 255
256 256 if XAxisAsTime:
257 257
258 258 func = lambda x, pos: ('%s') %(datetime.datetime.fromtimestamp(x).strftime("%H:%M:%S"))
259 259 ax.xaxis.set_major_formatter(FuncFormatter(func))
260 260 ax.xaxis.set_major_locator(LinearLocator(7))
261 261
262 262 # seconds = numpy.array([xmin, xmax])
263 263 # datesList = map(datetime.datetime.fromtimestamp, seconds)
264 264 # ax.set_xlim([datesList[0],datesList[-1]])
265 265 # ax.xaxis.set_major_locator(MinuteLocator(numpy.arange(0,61,10)))
266 266 # ax.xaxis.set_minor_locator(SecondLocator(numpy.arange(0,61,60)))
267 267 # ax.xaxis.set_major_formatter(DateFormatter("%H:%M:%S"))
268 268 # xdateList = map(datetime.datetime.fromtimestamp, x)
269 269 # xdate = matplotlib.dates.date2num(xdateList)
270 270 # x = xdate
271 271
272 272 # labels = []
273 273 # for item in ax.xaxis.get_ticklabels():
274 274 # stri = item.get_text()
275 275 # text = datetime.datetime.fromtimestamp(float(stri))
276 276 # labels.append(text)
277 277 #
278 278 # ax.xaxis.set_ticklabels(labels)
279 279 return imesh
280 280
281 281 def pcolor(imesh, z, xlabel='', ylabel='', title=''):
282 282
283 283 z = z.T
284 284
285 285 ax = imesh.get_axes()
286 286
287 287 printLabels(ax, xlabel, ylabel, title)
288 288
289 289 imesh.set_array(z.ravel())
290 290
291 291 def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title=''):
292 292
293 293 # xdateList = map(datetime.datetime.fromtimestamp, x)
294 294 # xdate = matplotlib.dates.date2num(xdateList)
295 295
296 296 printLabels(ax, xlabel, ylabel, title)
297 297
298 298 imesh = ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax)
299 299
300 300 def draw(fig):
301 301
302 302 if type(fig) == 'int':
303 303 raise ValueError, "This parameter should be of tpye matplotlib figure"
304 304
305 305 fig.canvas.draw() No newline at end of file
@@ -1,494 +1,506
1 1 '''
2 2
3 3 $Author: murco $
4 4 $Id: JROData.py 173 2012-11-20 15:06:21Z murco $
5 5 '''
6 6
7 7 import os, sys
8 8 import copy
9 9 import numpy
10 10
11 11 from jroheaderIO import SystemHeader, RadarControllerHeader
12 12
13 13 def hildebrand_sekhon(data, navg):
14 14 """
15 15 This method is for the objective determination of de noise level in Doppler spectra. This
16 16 implementation technique is based on the fact that the standard deviation of the spectral
17 17 densities is equal to the mean spectral density for white Gaussian noise
18 18
19 19 Inputs:
20 20 Data : heights
21 21 navg : numbers of averages
22 22
23 23 Return:
24 24 -1 : any error
25 25 anoise : noise's level
26 26 """
27 27
28 28 dataflat = data.copy().reshape(-1)
29 29 dataflat.sort()
30 30 npts = dataflat.size #numbers of points of the data
31 31
32 32 if npts < 32:
33 33 print "error in noise - requires at least 32 points"
34 34 return -1.0
35 35
36 36 dataflat2 = numpy.power(dataflat,2)
37 37
38 38 cs = numpy.cumsum(dataflat)
39 39 cs2 = numpy.cumsum(dataflat2)
40 40
41 41 # data sorted in ascending order
42 42 nmin = int((npts + 7.)/8)
43 43
44 44 for i in range(nmin, npts):
45 45 s = cs[i]
46 46 s2 = cs2[i]
47 47 p = s / float(i);
48 48 p2 = p**2;
49 49 q = s2 / float(i) - p2;
50 50 leftc = p2;
51 51 rightc = q * float(navg);
52 52 R2 = leftc/rightc
53 53
54 54 # Signal detect: R2 < 1 (R2 = leftc/rightc)
55 55 if R2 < 1:
56 56 npts_noise = i
57 57 break
58 58
59 59
60 60 anoise = numpy.average(dataflat[0:npts_noise])
61 61
62 62 return anoise;
63 63
64 64 def sorting_bruce(data, navg):
65 65
66 66 data = data.copy()
67 67
68 68 sortdata = numpy.sort(data)
69 69 lenOfData = len(data)
70 70 nums_min = lenOfData/10
71 71
72 72 if (lenOfData/10) > 0:
73 73 nums_min = lenOfData/10
74 74 else:
75 75 nums_min = 0
76 76
77 77 rtest = 1.0 + 1.0/navg
78 78
79 79 sum = 0.
80 80
81 81 sumq = 0.
82 82
83 83 j = 0
84 84
85 85 cont = 1
86 86
87 87 while((cont==1)and(j<lenOfData)):
88 88
89 89 sum += sortdata[j]
90 90
91 91 sumq += sortdata[j]**2
92 92
93 93 j += 1
94 94
95 95 if j > nums_min:
96 96 if ((sumq*j) <= (rtest*sum**2)):
97 97 lnoise = sum / j
98 98 else:
99 99 j = j - 1
100 100 sum = sum - sordata[j]
101 101 sumq = sumq - sordata[j]**2
102 102 cont = 0
103 103
104 104 if j == nums_min:
105 105 lnoise = sum /j
106 106
107 107 return lnoise
108 108
109 109 class JROData:
110 110
111 111 # m_BasicHeader = BasicHeader()
112 112 # m_ProcessingHeader = ProcessingHeader()
113 113
114 114 systemHeaderObj = SystemHeader()
115 115
116 116 radarControllerHeaderObj = RadarControllerHeader()
117 117
118 118 # data = None
119 119
120 120 type = None
121 121
122 122 dtype = None
123 123
124 124 # nChannels = None
125 125
126 126 # nHeights = None
127 127
128 128 nProfiles = None
129 129
130 130 heightList = None
131 131
132 132 channelList = None
133 133
134 134 flagNoData = True
135 135
136 136 flagTimeBlock = False
137 137
138 138 utctime = None
139 139
140 140 blocksize = None
141 141
142 142 nCode = None
143 143
144 144 nBaud = None
145 145
146 146 code = None
147 147
148 148 flagDecodeData = True #asumo q la data esta decodificada
149 149
150 150 flagDeflipData = True #asumo q la data esta sin flip
151 151
152 152 flagShiftFFT = False
153 153
154 154 ippSeconds = None
155 155
156 156 timeInterval = None
157 157
158 158 nCohInt = None
159 159
160 160 noise = None
161 161
162 162 #Speed of ligth
163 163 C = 3e8
164 164
165 165 frequency = 49.92e6
166 166
167 167 def __init__(self):
168 168
169 169 raise ValueError, "This class has not been implemented"
170 170
171 171 def copy(self, inputObj=None):
172 172
173 173 if inputObj == None:
174 174 return copy.deepcopy(self)
175 175
176 176 for key in inputObj.__dict__.keys():
177 177 self.__dict__[key] = inputObj.__dict__[key]
178 178
179 179 def deepcopy(self):
180 180
181 181 return copy.deepcopy(self)
182 182
183 183 def isEmpty(self):
184 184
185 185 return self.flagNoData
186 186
187 187 def getNoise(self):
188 188
189 189 raise ValueError, "Not implemented"
190 190
191 191 def getNChannels(self):
192 192
193 193 return len(self.channelList)
194 194
195 195 def getChannelIndexList(self):
196 196
197 197 return range(self.nChannels)
198 198
199 199 def getNHeights(self):
200 200
201 201 return len(self.heightList)
202 202
203 203 def getHeiRange(self, extrapoints=0):
204 204
205 205 heis = self.heightList
206 206 # deltah = self.heightList[1] - self.heightList[0]
207 207 #
208 208 # heis.append(self.heightList[-1])
209 209
210 210 return heis
211 211
212 212 def getDatatime(self):
213 213
214 214 datatime = []
215 215
216 216 datatime.append(self.utctime)
217 217 datatime.append(self.utctime + 2*self.timeInterval)
218 218
219 219 datatime = numpy.array(datatime)
220 220
221 221 return datatime
222 222
223 223 def getFmax(self):
224 224
225 225 PRF = 1./(self.ippSeconds * self.nCohInt)
226 226
227 227 fmax = PRF/2.
228 228
229 229 return fmax
230 230
231 231 def getVmax(self):
232 232
233 233 _lambda = self.C/self.frequency
234 234
235 235 vmax = self.getFmax() * _lambda / 2.
236 236
237 237 return vmax
238 238
239 239 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
240 240 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
241 241
242 242 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
243 243
244 244 noise = property(getNoise, "I'm the 'nHeights' property.")
245 245
246 246 class Voltage(JROData):
247 247
248 248 #data es un numpy array de 2 dmensiones (canales, alturas)
249 249 data = None
250 250
251 251 def __init__(self):
252 252 '''
253 253 Constructor
254 254 '''
255 255
256 256 self.radarControllerHeaderObj = RadarControllerHeader()
257 257
258 258 self.systemHeaderObj = SystemHeader()
259 259
260 260 self.type = "Voltage"
261 261
262 262 self.data = None
263 263
264 264 self.dtype = None
265 265
266 266 # self.nChannels = 0
267 267
268 268 # self.nHeights = 0
269 269
270 270 self.nProfiles = None
271 271
272 272 self.heightList = None
273 273
274 274 self.channelList = None
275 275
276 276 # self.channelIndexList = None
277 277
278 278 self.flagNoData = True
279 279
280 280 self.flagTimeBlock = False
281 281
282 282 self.utctime = None
283 283
284 284 self.nCohInt = None
285 285
286 286 self.blocksize = None
287 287
288 288 def getNoisebyHildebrand(self):
289 289 """
290 290 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
291 291
292 292 Return:
293 293 noiselevel
294 294 """
295 295
296 296 for channel in range(self.nChannels):
297 297 daux = self.data_spc[channel,:,:]
298 298 self.noise[channel] = hildebrand_sekhon(daux, self.nCohInt)
299 299
300 300 return self.noise
301 301
302 302 def getNoise(self, type = 1):
303 303
304 304 self.noise = numpy.zeros(self.nChannels)
305 305
306 306 if type == 1:
307 307 noise = self.getNoisebyHildebrand()
308 308
309 309 return 10*numpy.log10(noise)
310 310
311 311 class Spectra(JROData):
312 312
313 313 #data es un numpy array de 2 dmensiones (canales, perfiles, alturas)
314 314 data_spc = None
315 315
316 316 #data es un numpy array de 2 dmensiones (canales, pares, alturas)
317 317 data_cspc = None
318 318
319 319 #data es un numpy array de 2 dmensiones (canales, alturas)
320 320 data_dc = None
321 321
322 322 nFFTPoints = None
323 323
324 324 nPairs = None
325 325
326 326 pairsList = None
327 327
328 328 nIncohInt = None
329 329
330 330 wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia
331 331
332 332 nCohInt = None #se requiere para determinar el valor de timeInterval
333 333
334 334 def __init__(self):
335 335 '''
336 336 Constructor
337 337 '''
338 338
339 339 self.radarControllerHeaderObj = RadarControllerHeader()
340 340
341 341 self.systemHeaderObj = SystemHeader()
342 342
343 343 self.type = "Spectra"
344 344
345 345 # self.data = None
346 346
347 347 self.dtype = None
348 348
349 349 # self.nChannels = 0
350 350
351 351 # self.nHeights = 0
352 352
353 353 self.nProfiles = None
354 354
355 355 self.heightList = None
356 356
357 357 self.channelList = None
358 358
359 359 # self.channelIndexList = None
360 360
361 361 self.flagNoData = True
362 362
363 363 self.flagTimeBlock = False
364 364
365 365 self.utctime = None
366 366
367 367 self.nCohInt = None
368 368
369 369 self.nIncohInt = None
370 370
371 371 self.blocksize = None
372 372
373 373 self.nFFTPoints = None
374 374
375 375 self.wavelength = None
376
377 def getFreqRange(self, extrapoints=0):
378
379 delfreq = 2 * self.getFmax() / self.nFFTPoints
380 freqrange = deltafreqs*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
381
382 return freqrange
383
384 def getVelRange(self, extrapoints=0):
385
386 deltav = 2 * self.getVmax() / self.nFFTPoints
387 velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2
388
389 return velrange
390 376
391 377 def getNoisebyHildebrand(self):
392 378 """
393 379 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
394 380
395 381 Return:
396 382 noiselevel
397 383 """
398 384
399 385 for channel in range(self.nChannels):
400 386 daux = self.data_spc[channel,:,:]
401 387 self.noise[channel] = hildebrand_sekhon(daux, self.nIncohInt)
402 388
403 389 return self.noise
404 390
405 391 def getNoisebyWindow(self, heiIndexMin=0, heiIndexMax=-1, freqIndexMin=0, freqIndexMax=-1):
406 392 """
407 393 Determina el ruido del canal utilizando la ventana indicada con las coordenadas:
408 394 (heiIndexMIn, freqIndexMin) hasta (heiIndexMax, freqIndexMAx)
409 395
410 396 Inputs:
411 397 heiIndexMin: Limite inferior del eje de alturas
412 398 heiIndexMax: Limite superior del eje de alturas
413 399 freqIndexMin: Limite inferior del eje de frecuencia
414 400 freqIndexMax: Limite supoerior del eje de frecuencia
415 401 """
416 402
417 403 data = self.data_spc[:, heiIndexMin:heiIndexMax, freqIndexMin:freqIndexMax]
418 404
419 405 for channel in range(self.nChannels):
420 406 daux = data[channel,:,:]
421 407 self.noise[channel] = numpy.average(daux)
422 408
423 409 return self.noise
424 410
425 411 def getNoisebySort(self):
426 412
427 413 for channel in range(self.nChannels):
428 414 daux = self.data_spc[channel,:,:]
429 415 self.noise[channel] = sorting_bruce(daux, self.nIncohInt)
430 416
431 417 return self.noise
432 418
433 419 def getNoise(self, type = 1):
434 420
435 421 self.noise = numpy.zeros(self.nChannels)
436 422
437 423 if type == 1:
438 424 noise = self.getNoisebyHildebrand()
439 425
440 426 if type == 2:
441 427 noise = self.getNoisebySort()
442 428
443 429 if type == 3:
444 430 noise = self.getNoisebyWindow()
445 431
446 432 return 10*numpy.log10(noise)
433
434
435 def getFreqRange(self, extrapoints=0):
436
437 delfreq = 2 * self.getFmax() / self.nFFTPoints
438 freqrange = deltafreqs*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
439
440 return freqrange
441
442 def getVelRange(self, extrapoints=0):
443
444 deltav = 2 * self.getVmax() / self.nFFTPoints
445 velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2
446
447 return velrange
448
449 def getNPairs(self):
450
451 return len(self.pairsList)
452
453 def getPairsIndexList(self):
454
455 return range(self.nPairs)
456
457 nPairs = property(getNPairs, "I'm the 'nPairs' property.")
458 pairsIndexList = property(getPairsIndexList, "I'm the 'pairsIndexList' property.")
447 459
448 460 class SpectraHeis(JROData):
449 461
450 462 data_spc = None
451 463
452 464 data_cspc = None
453 465
454 466 data_dc = None
455 467
456 468 nFFTPoints = None
457 469
458 470 nPairs = None
459 471
460 472 pairsList = None
461 473
462 474 nIncohInt = None
463 475
464 476 def __init__(self):
465 477
466 478 self.radarControllerHeaderObj = RadarControllerHeader()
467 479
468 480 self.systemHeaderObj = SystemHeader()
469 481
470 482 self.type = "SpectraHeis"
471 483
472 484 self.dtype = None
473 485
474 486 # self.nChannels = 0
475 487
476 488 # self.nHeights = 0
477 489
478 490 self.nProfiles = None
479 491
480 492 self.heightList = None
481 493
482 494 self.channelList = None
483 495
484 496 # self.channelIndexList = None
485 497
486 498 self.flagNoData = True
487 499
488 500 self.flagTimeBlock = False
489 501
490 502 self.nPairs = 0
491 503
492 504 self.utctime = None
493 505
494 506 self.blocksize = None
@@ -1,427 +1,586
1 1 import numpy
2 2 import time, datetime
3 3 from graphics.figure import *
4 4
5 class CrossSpectraPlot(Figure):
6
7 __isConfig = None
8 __nsubplots = None
9
10 WIDTHPROF = None
11 HEIGHTPROF = None
12 PREFIX = 'spc'
13
14 def __init__(self):
15
16 self.__isConfig = False
17 self.__nsubplots = 4
18
19 self.WIDTH = 300
20 self.HEIGHT = 400
21 self.WIDTHPROF = 0
22 self.HEIGHTPROF = 0
23
24 def getSubplots(self):
25
26 ncol = 4
27 nrow = self.nplots
28
29 return nrow, ncol
30
31 def setup(self, idfigure, nplots, wintitle, showprofile=True):
32
33 self.__showprofile = showprofile
34 self.nplots = nplots
35
36 ncolspan = 1
37 colspan = 1
38
39 self.createFigure(idfigure = idfigure,
40 wintitle = wintitle,
41 widthplot = self.WIDTH + self.WIDTHPROF,
42 heightplot = self.HEIGHT + self.HEIGHTPROF)
43
44 nrow, ncol = self.getSubplots()
45
46 counter = 0
47 for y in range(nrow):
48 for x in range(ncol):
49 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
50
51 counter += 1
52
53 def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True',
54 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
55 save=False, figpath='./', figfile=None):
56
57 """
58
59 Input:
60 dataOut :
61 idfigure :
62 wintitle :
63 channelList :
64 showProfile :
65 xmin : None,
66 xmax : None,
67 ymin : None,
68 ymax : None,
69 zmin : None,
70 zmax : None
71 """
72
73 if pairsList == None:
74 pairsIndexList = dataOut.pairsIndexList
75 else:
76 pairsIndexList = []
77 for pair in pairsList:
78 if pair not in dataOut.pairsList:
79 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
80 pairsIndexList.append(dataOut.pairsList.index(pair))
81
82 x = dataOut.getVelRange(1)
83 y = dataOut.getHeiRange()
84 z = 10.*numpy.log10(dataOut.data_spc[:,:,:])
85 avg = numpy.average(numpy.abs(z), axis=1)
86
87 noise = dataOut.getNoise()
88
89 if not self.__isConfig:
90
91 nplots = len(pairsIndexList)
92
93 self.setup(idfigure=idfigure,
94 nplots=nplots,
95 wintitle=wintitle,
96 showprofile=showprofile)
97
98 if xmin == None: xmin = numpy.nanmin(x)
99 if xmax == None: xmax = numpy.nanmax(x)
100 if ymin == None: ymin = numpy.nanmin(y)
101 if ymax == None: ymax = numpy.nanmax(y)
102 if zmin == None: zmin = numpy.nanmin(avg)*0.9
103 if zmax == None: zmax = numpy.nanmax(avg)*0.9
104
105 self.__isConfig = True
106
107 thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime)
108 title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
109 xlabel = "Velocity (m/s)"
110 ylabel = "Range (Km)"
111
112 self.setWinTitle(title)
113
114 for i in range(self.nplots):
115 pair = dataOut.pairsList[pairsIndexList[i]]
116
117 title = "Channel %d: %4.2fdB" %(pair[0], noise[pair[0]])
118 z = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:])
119 axes0 = self.axesList[i*self.__nsubplots]
120 axes0.pcolor(x, y, z,
121 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
122 xlabel=xlabel, ylabel=ylabel, title=title,
123 ticksize=9, cblabel='')
124
125 title = "Channel %d: %4.2fdB" %(pair[1], noise[pair[1]])
126 z = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:])
127 axes0 = self.axesList[i*self.__nsubplots+1]
128 axes0.pcolor(x, y, z,
129 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
130 xlabel=xlabel, ylabel=ylabel, title=title,
131 ticksize=9, cblabel='')
132
133 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:])
134 coherence = numpy.abs(coherenceComplex)
135 phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
136
137
138 title = "Coherence %d%d" %(pair[0], pair[1])
139 axes0 = self.axesList[i*self.__nsubplots+2]
140 axes0.pcolor(x, y, coherence,
141 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-1, zmax=1,
142 xlabel=xlabel, ylabel=ylabel, title=title,
143 ticksize=9, cblabel='')
144
145 title = "Phase %d%d" %(pair[0], pair[1])
146 axes0 = self.axesList[i*self.__nsubplots+3]
147 axes0.pcolor(x, y, phase,
148 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
149 xlabel=xlabel, ylabel=ylabel, title=title,
150 ticksize=9, cblabel='')
151
152
153
154 self.draw()
155
156 if save:
157 date = thisDatetime.strftime("%Y%m%d")
158 if figfile == None:
159 figfile = self.getFilename(name = date)
160
161 self.saveFigure(figpath, figfile)
162
163
5 164 class RTIPlot(Figure):
6 165
7 166 __isConfig = None
8 167 __nsubplots = None
9 168
10 169 WIDTHPROF = None
11 170 HEIGHTPROF = None
12 171 PREFIX = 'rti'
13 172
14 173 def __init__(self):
15 174
16 175 self.__timerange = 24*60*60
17 176 self.__isConfig = False
18 177 self.__nsubplots = 1
19 178
20 179 self.WIDTH = 800
21 180 self.HEIGHT = 200
22 181 self.WIDTHPROF = 120
23 182 self.HEIGHTPROF = 0
24 183
25 184 def getSubplots(self):
26 185
27 186 ncol = 1
28 187 nrow = self.nplots
29 188
30 189 return nrow, ncol
31 190
32 191 def setup(self, idfigure, nplots, wintitle, showprofile=True):
33 192
34 193 self.__showprofile = showprofile
35 194 self.nplots = nplots
36 195
37 196 ncolspan = 1
38 197 colspan = 1
39 198 if showprofile:
40 199 ncolspan = 7
41 200 colspan = 6
42 201 self.__nsubplots = 2
43 202
44 203 self.createFigure(idfigure = idfigure,
45 204 wintitle = wintitle,
46 205 widthplot = self.WIDTH + self.WIDTHPROF,
47 206 heightplot = self.HEIGHT + self.HEIGHTPROF)
48 207
49 208 nrow, ncol = self.getSubplots()
50 209
51 210 counter = 0
52 211 for y in range(nrow):
53 212 for x in range(ncol):
54 213
55 214 if counter >= self.nplots:
56 215 break
57 216
58 217 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
59 218
60 219 if showprofile:
61 220 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
62 221
63 222 counter += 1
64 223
65 224 def __getTimeLim(self, x, xmin, xmax):
66 225
67 226 thisdatetime = datetime.datetime.fromtimestamp(numpy.min(x))
68 227 thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0))
69 228
70 229 ####################################################
71 230 #If the x is out of xrange
72 231 if xmax < (thisdatetime - thisdate).seconds/(60*60.):
73 232 xmin = None
74 233 xmax = None
75 234
76 235 if xmin == None:
77 236 td = thisdatetime - thisdate
78 237 xmin = td.seconds/(60*60.)
79 238
80 239 if xmax == None:
81 240 xmax = xmin + self.__timerange/(60*60.)
82 241
83 242 mindt = thisdate + datetime.timedelta(0,0,0,0,0, xmin)
84 243 tmin = time.mktime(mindt.timetuple())
85 244
86 245 maxdt = thisdate + datetime.timedelta(0,0,0,0,0, xmax)
87 246 tmax = time.mktime(maxdt.timetuple())
88 247
89 248 self.__timerange = tmax - tmin
90 249
91 250 return tmin, tmax
92 251
93 252 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
94 253 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
95 254 timerange=None,
96 255 save=False, figpath='./', figfile=None):
97 256
98 257 """
99 258
100 259 Input:
101 260 dataOut :
102 261 idfigure :
103 262 wintitle :
104 263 channelList :
105 264 showProfile :
106 265 xmin : None,
107 266 xmax : None,
108 267 ymin : None,
109 268 ymax : None,
110 269 zmin : None,
111 270 zmax : None
112 271 """
113 272
114 273 if channelList == None:
115 274 channelIndexList = dataOut.channelIndexList
116 275 else:
117 276 channelIndexList = []
118 277 for channel in channelList:
119 278 if channel not in dataOut.channelList:
120 279 raise ValueError, "Channel %d is not in dataOut.channelList"
121 channelIndexList.append(dataOut.channelList.index(chachannel))
280 channelIndexList.append(dataOut.channelList.index(channel))
122 281
123 282 if timerange != None:
124 283 self.__timerange = timerange
125 284
126 285 tmin = None
127 286 tmax = None
128 287 x = dataOut.getDatatime()
129 288 y = dataOut.getHeiRange()
130 289 z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:])
131 290 avg = numpy.average(z, axis=1)
132 291
133 292 noise = dataOut.getNoise()
134 293
135 294 if not self.__isConfig:
136 295
137 296 nplots = len(channelIndexList)
138 297
139 298 self.setup(idfigure=idfigure,
140 299 nplots=nplots,
141 300 wintitle=wintitle,
142 301 showprofile=showprofile)
143 302
144 303 tmin, tmax = self.__getTimeLim(x, xmin, xmax)
145 304 if ymin == None: ymin = numpy.nanmin(y)
146 305 if ymax == None: ymax = numpy.nanmax(y)
147 306 if zmin == None: zmin = numpy.nanmin(avg)*0.9
148 307 if zmax == None: zmax = numpy.nanmax(avg)*0.9
149 308
150 309 self.__isConfig = True
151 310
152 311 thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime)
153 312 title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y"))
154 313 xlabel = "Velocity (m/s)"
155 314 ylabel = "Range (Km)"
156 315
157 316 self.setWinTitle(title)
158 317
159 318 for i in range(self.nplots):
160 319 title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
161 320 axes = self.axesList[i*self.__nsubplots]
162 321 z = avg[i].reshape((1,-1))
163 322 axes.pcolor(x, y, z,
164 323 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
165 324 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
166 325 ticksize=9, cblabel='', cbsize="1%")
167 326
168 327 if self.__showprofile:
169 328 axes = self.axesList[i*self.__nsubplots +1]
170 329 axes.pline(avg[i], y,
171 330 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
172 331 xlabel='dB', ylabel='', title='',
173 332 ytick_visible=False,
174 333 grid='x')
175 334
176 335 self.draw()
177 336
178 337 if save:
179 338 date = thisDatetime.strftime("%Y%m%d")
180 339 if figfile == None:
181 340 figfile = self.getFilename(name = date)
182 341
183 342 self.saveFigure(figpath, figfile)
184 343
185 344 if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax:
186 345 self.__isConfig = False
187 346
188 347 class SpectraPlot(Figure):
189 348
190 349 __isConfig = None
191 350 __nsubplots = None
192 351
193 352 WIDTHPROF = None
194 353 HEIGHTPROF = None
195 354 PREFIX = 'spc'
196 355
197 356 def __init__(self):
198 357
199 358 self.__isConfig = False
200 359 self.__nsubplots = 1
201 360
202 361 self.WIDTH = 300
203 362 self.HEIGHT = 400
204 363 self.WIDTHPROF = 120
205 364 self.HEIGHTPROF = 0
206 365
207 366 def getSubplots(self):
208 367
209 368 ncol = int(numpy.sqrt(self.nplots)+0.9)
210 369 nrow = int(self.nplots*1./ncol + 0.9)
211 370
212 371 return nrow, ncol
213 372
214 373 def setup(self, idfigure, nplots, wintitle, showprofile=True):
215 374
216 375 self.__showprofile = showprofile
217 376 self.nplots = nplots
218 377
219 378 ncolspan = 1
220 379 colspan = 1
221 380 if showprofile:
222 381 ncolspan = 3
223 382 colspan = 2
224 383 self.__nsubplots = 2
225 384
226 385 self.createFigure(idfigure = idfigure,
227 386 wintitle = wintitle,
228 387 widthplot = self.WIDTH + self.WIDTHPROF,
229 388 heightplot = self.HEIGHT + self.HEIGHTPROF)
230 389
231 390 nrow, ncol = self.getSubplots()
232 391
233 392 counter = 0
234 393 for y in range(nrow):
235 394 for x in range(ncol):
236 395
237 396 if counter >= self.nplots:
238 397 break
239 398
240 399 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
241 400
242 401 if showprofile:
243 402 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
244 403
245 404 counter += 1
246 405
247 406 def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True',
248 407 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
249 408 save=False, figpath='./', figfile=None):
250 409
251 410 """
252 411
253 412 Input:
254 413 dataOut :
255 414 idfigure :
256 415 wintitle :
257 416 channelList :
258 417 showProfile :
259 418 xmin : None,
260 419 xmax : None,
261 420 ymin : None,
262 421 ymax : None,
263 422 zmin : None,
264 423 zmax : None
265 424 """
266 425
267 426 if channelList == None:
268 427 channelIndexList = dataOut.channelIndexList
269 428 else:
270 429 channelIndexList = []
271 430 for channel in channelList:
272 431 if channel not in dataOut.channelList:
273 432 raise ValueError, "Channel %d is not in dataOut.channelList"
274 433 channelIndexList.append(dataOut.channelList.index(channel))
275 434
276 435 x = dataOut.getVelRange(1)
277 436 y = dataOut.getHeiRange()
278 437 z = 10.*numpy.log10(dataOut.data_spc[channelIndexList,:,:])
279 438 avg = numpy.average(z, axis=1)
280 439
281 440 noise = dataOut.getNoise()
282 441
283 442 if not self.__isConfig:
284 443
285 444 nplots = len(channelIndexList)
286 445
287 446 self.setup(idfigure=idfigure,
288 447 nplots=nplots,
289 448 wintitle=wintitle,
290 449 showprofile=showprofile)
291 450
292 451 if xmin == None: xmin = numpy.nanmin(x)
293 452 if xmax == None: xmax = numpy.nanmax(x)
294 453 if ymin == None: ymin = numpy.nanmin(y)
295 454 if ymax == None: ymax = numpy.nanmax(y)
296 455 if zmin == None: zmin = numpy.nanmin(avg)*0.9
297 456 if zmax == None: zmax = numpy.nanmax(avg)*0.9
298 457
299 458 self.__isConfig = True
300 459
301 460 thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime)
302 461 title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
303 462 xlabel = "Velocity (m/s)"
304 463 ylabel = "Range (Km)"
305 464
306 465 self.setWinTitle(title)
307 466
308 467 for i in range(self.nplots):
309 468 title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noise[i])
310 469 axes = self.axesList[i*self.__nsubplots]
311 470 axes.pcolor(x, y, z[i,:,:],
312 471 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
313 472 xlabel=xlabel, ylabel=ylabel, title=title,
314 473 ticksize=9, cblabel='')
315 474
316 475 if self.__showprofile:
317 476 axes = self.axesList[i*self.__nsubplots +1]
318 477 axes.pline(avg[i], y,
319 478 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
320 479 xlabel='dB', ylabel='', title='',
321 480 ytick_visible=False,
322 481 grid='x')
323 482
324 483 self.draw()
325 484
326 485 if save:
327 486 date = thisDatetime.strftime("%Y%m%d")
328 487 if figfile == None:
329 488 figfile = self.getFilename(name = date)
330 489
331 490 self.saveFigure(figpath, figfile)
332 491
333 492 class Scope(Figure):
334 493
335 494 __isConfig = None
336 495
337 496 def __init__(self):
338 497
339 498 self.__isConfig = False
340 499 self.WIDTH = 600
341 500 self.HEIGHT = 200
342 501
343 502 def getSubplots(self):
344 503
345 504 nrow = self.nplots
346 505 ncol = 3
347 506 return nrow, ncol
348 507
349 508 def setup(self, idfigure, nplots, wintitle):
350 509
351 510 self.createFigure(idfigure, wintitle)
352 511
353 512 nrow,ncol = self.getSubplots()
354 513 colspan = 3
355 514 rowspan = 1
356 515
357 516 for i in range(nplots):
358 517 self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
359 518
360 519 self.nplots = nplots
361 520
362 521 def run(self, dataOut, idfigure, wintitle="", channelList=None,
363 522 xmin=None, xmax=None, ymin=None, ymax=None, save=False, filename=None):
364 523
365 524 """
366 525
367 526 Input:
368 527 dataOut :
369 528 idfigure :
370 529 wintitle :
371 530 channelList :
372 531 xmin : None,
373 532 xmax : None,
374 533 ymin : None,
375 534 ymax : None,
376 535 """
377 536
378 537 if channelList == None:
379 538 channelIndexList = dataOut.channelIndexList
380 539 else:
381 540 channelIndexList = []
382 541 for channel in channelList:
383 542 if channel not in dataOut.channelList:
384 543 raise ValueError, "Channel %d is not in dataOut.channelList"
385 channelIndexList.append(dataOut.channelList.index(chachannel))
544 channelIndexList.append(dataOut.channelList.index(channel))
386 545
387 546 x = dataOut.heightList
388 547 y = dataOut.data[channelList,:] * numpy.conjugate(dataOut.data[channelList,:])
389 548 y = y.real
390 549
391 550 noise = dataOut.getNoise()
392 551
393 552 if not self.__isConfig:
394 553 nplots = len(channelList)
395 554
396 555 self.setup(idfigure=idfigure,
397 556 nplots=nplots,
398 557 wintitle=wintitle)
399 558
400 559 if xmin == None: xmin = numpy.nanmin(x)
401 560 if xmax == None: xmax = numpy.nanmax(x)
402 561 if ymin == None: ymin = numpy.nanmin(y)
403 562 if ymax == None: ymax = numpy.nanmax(y)
404 563
405 564 self.__isConfig = True
406 565
407 566
408 567 thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime)
409 568 title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
410 569 xlabel = "Range (Km)"
411 570 ylabel = "Intensity"
412 571
413 572 self.setWinTitle(title)
414 573
415 574 for i in range(len(self.axesList)):
416 575 title = "Channel %d: %4.2fdB" %(i, noise[i])
417 576 axes = self.axesList[i]
418 577 ychannel = y[i,:]
419 578 axes.pline(x, ychannel,
420 579 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
421 580 xlabel=xlabel, ylabel=ylabel, title=title)
422 581
423 582 self.draw()
424 583
425 584 if save:
426 585 self.saveFigure(filename)
427 586 No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now