@@ -1,59 +1,61 | |||
|
1 | 1 | import numpy |
|
2 | 2 | |
|
3 | 3 | class AMISR: |
|
4 | 4 | def __init__(self): |
|
5 | 5 | self.flagNoData = True |
|
6 | 6 | self.data = None |
|
7 | 7 | self.utctime = None |
|
8 | 8 | self.type = "AMISR" |
|
9 | 9 | |
|
10 | 10 | #propiedades para compatibilidad con Voltages |
|
11 |
self.timeZone = |
|
|
11 | self.timeZone = 0#timezone like jroheader, difference in minutes between UTC and localtime | |
|
12 | 12 | self.dstFlag = 0#self.dataIn.dstFlag |
|
13 | 13 | self.errorCount = 0#self.dataIn.errorCount |
|
14 | 14 | self.useLocalTime = True#self.dataIn.useLocalTime |
|
15 | 15 | |
|
16 | 16 | self.radarControllerHeaderObj = None#self.dataIn.radarControllerHeaderObj.copy() |
|
17 | 17 | self.systemHeaderObj = None#self.dataIn.systemHeaderObj.copy() |
|
18 | 18 | self.channelList = [0]#self.dataIn.channelList esto solo aplica para el caso de AMISR |
|
19 | 19 | self.dtype = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
20 | 20 | |
|
21 | 21 | self.flagTimeBlock = None#self.dataIn.flagTimeBlock |
|
22 | 22 | #self.utctime = #self.firstdatatime |
|
23 | 23 | self.flagDecodeData = None#self.dataIn.flagDecodeData #asumo q la data esta decodificada |
|
24 | 24 | self.flagDeflipData = None#self.dataIn.flagDeflipData #asumo q la data esta sin flip |
|
25 | 25 | |
|
26 | 26 | self.nCohInt = 1#self.dataIn.nCohInt |
|
27 | 27 | self.nIncohInt = 1 |
|
28 | 28 | self.ippSeconds = None#self.dataIn.ippSeconds, segun el filename/Setup/Tufile |
|
29 | 29 | self.windowOfFilter = None#self.dataIn.windowOfFilter |
|
30 | 30 | |
|
31 | 31 | self.timeInterval = None#self.dataIn.timeInterval*self.dataOut.nFFTPoints*self.dataOut.nIncohInt |
|
32 | 32 | self.frequency = None#self.dataIn.frequency |
|
33 | 33 | self.realtime = 0#self.dataIn.realtime |
|
34 | 34 | |
|
35 | 35 | #actualizar en la lectura de datos |
|
36 | 36 | self.heightList = None#self.dataIn.heightList |
|
37 | 37 | self.nProfiles = None#Number of samples or nFFTPoints |
|
38 | 38 | self.nRecords = None |
|
39 | 39 | self.nBeams = None |
|
40 | 40 | self.nBaud = None#self.dataIn.nBaud |
|
41 | 41 | self.nCode = None#self.dataIn.nCode |
|
42 | 42 | self.code = None#self.dataIn.code |
|
43 | 43 | |
|
44 | 44 | #consideracion para los Beams |
|
45 | 45 | self.beamCodeDict = None |
|
46 | 46 | self.beamRangeDict = None |
|
47 | 47 | |
|
48 | self.npulseByFrame = None | |
|
49 | ||
|
48 | 50 | def copy(self, inputObj=None): |
|
49 | 51 | |
|
50 | 52 | if inputObj == None: |
|
51 | 53 | return copy.deepcopy(self) |
|
52 | 54 | |
|
53 | 55 | for key in inputObj.__dict__.keys(): |
|
54 | 56 | self.__dict__[key] = inputObj.__dict__[key] |
|
55 | 57 | |
|
56 | 58 | |
|
57 | 59 | def isEmpty(self): |
|
58 | 60 | |
|
59 | 61 | return self.flagNoData No newline at end of file |
@@ -1,590 +1,590 | |||
|
1 | 1 | import os |
|
2 | 2 | import numpy |
|
3 | 3 | import time, datetime |
|
4 | 4 | import mpldriver |
|
5 | from customftp import * | |
|
5 | ||
|
6 | 6 | |
|
7 | 7 | import Queue |
|
8 | 8 | import threading |
|
9 | 9 | |
|
10 | 10 | def isRealtime(utcdatatime): |
|
11 | 11 | utcnow = time.mktime(time.localtime()) |
|
12 | 12 | delta = abs(utcnow - utcdatatime) # abs |
|
13 | 13 | if delta >= 30.: |
|
14 | 14 | return False |
|
15 | 15 | return True |
|
16 | 16 | |
|
17 | 17 | |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | class Figure: |
|
21 | 21 | |
|
22 | 22 | __driver = mpldriver |
|
23 | 23 | __isConfigThread = False |
|
24 | 24 | fig = None |
|
25 | 25 | |
|
26 | 26 | id = None |
|
27 | 27 | wintitle = None |
|
28 | 28 | width = None |
|
29 | 29 | height = None |
|
30 | 30 | nplots = None |
|
31 | 31 | timerange = None |
|
32 | 32 | |
|
33 | 33 | axesObjList = [] |
|
34 | 34 | |
|
35 | 35 | WIDTH = None |
|
36 | 36 | HEIGHT = None |
|
37 | 37 | PREFIX = 'fig' |
|
38 | 38 | |
|
39 | 39 | xmin = None |
|
40 | 40 | xmax = None |
|
41 | 41 | |
|
42 | 42 | def __init__(self): |
|
43 | 43 | |
|
44 | 44 | raise ValueError, "This method is not implemented" |
|
45 | 45 | |
|
46 | 46 | def __del__(self): |
|
47 | 47 | |
|
48 | 48 | self.__driver.closeFigure() |
|
49 | 49 | |
|
50 | 50 | def getFilename(self, name, ext='.png'): |
|
51 | 51 | |
|
52 | 52 | path = '%s%03d' %(self.PREFIX, self.id) |
|
53 | 53 | filename = '%s_%s%s' %(self.PREFIX, name, ext) |
|
54 | 54 | return os.path.join(path, filename) |
|
55 | 55 | |
|
56 | 56 | def getAxesObjList(self): |
|
57 | 57 | |
|
58 | 58 | return self.axesObjList |
|
59 | 59 | |
|
60 | 60 | def getSubplots(self): |
|
61 | 61 | |
|
62 | 62 | raise ValueError, "Abstract method: This method should be defined" |
|
63 | 63 | |
|
64 | 64 | def getScreenDim(self, widthplot, heightplot): |
|
65 | 65 | |
|
66 | 66 | nrow, ncol = self.getSubplots() |
|
67 | 67 | |
|
68 | 68 | widthscreen = widthplot*ncol |
|
69 | 69 | heightscreen = heightplot*nrow |
|
70 | 70 | |
|
71 | 71 | return widthscreen, heightscreen |
|
72 | 72 | |
|
73 | 73 | def getTimeLim(self, x, xmin=None, xmax=None, timerange=None): |
|
74 | 74 | |
|
75 | 75 | if self.xmin != None and self.xmax != None: |
|
76 | 76 | if timerange == None: |
|
77 | 77 | timerange = self.xmax - self.xmin |
|
78 | 78 | xmin = self.xmin + timerange |
|
79 | 79 | xmax = self.xmax + timerange |
|
80 | 80 | |
|
81 | 81 | return xmin, xmax |
|
82 | 82 | |
|
83 | 83 | |
|
84 | 84 | if timerange != None and self.xmin == None and self.xmax == None: |
|
85 | 85 | txmin = x[0] - x[0]%timerange |
|
86 | 86 | thisdatetime = datetime.datetime.utcfromtimestamp(txmin) |
|
87 | 87 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) |
|
88 | 88 | xmin = (thisdatetime - thisdate).seconds/(60*60.) |
|
89 | 89 | xmax = xmin + timerange/(60*60.) |
|
90 | 90 | |
|
91 | 91 | |
|
92 | 92 | if timerange == None: |
|
93 | 93 | txmin = numpy.min(x) |
|
94 | 94 | thisdatetime = datetime.datetime.utcfromtimestamp(txmin) |
|
95 | 95 | thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) |
|
96 | 96 | |
|
97 | 97 | mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone) |
|
98 | 98 | xmin_sec = time.mktime(mindt.timetuple()) |
|
99 | 99 | |
|
100 | 100 | maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone) |
|
101 | 101 | xmax_sec = time.mktime(maxdt.timetuple()) |
|
102 | 102 | |
|
103 | 103 | return xmin_sec, xmax_sec |
|
104 | 104 | |
|
105 | 105 | |
|
106 | 106 | |
|
107 | 107 | |
|
108 | 108 | |
|
109 | 109 | # if timerange != None: |
|
110 | 110 | # txmin = x[0] - x[0]%timerange |
|
111 | 111 | # else: |
|
112 | 112 | # txmin = numpy.min(x) |
|
113 | 113 | # |
|
114 | 114 | # thisdatetime = datetime.datetime.utcfromtimestamp(txmin) |
|
115 | 115 | # thisdate = datetime.datetime.combine(thisdatetime.date(), datetime.time(0,0,0)) |
|
116 | 116 | # |
|
117 | 117 | # #################################################### |
|
118 | 118 | # #If the x is out of xrange |
|
119 | 119 | # if xmax != None: |
|
120 | 120 | # if xmax < (thisdatetime - thisdate).seconds/(60*60.): |
|
121 | 121 | # xmin = None |
|
122 | 122 | # xmax = None |
|
123 | 123 | # |
|
124 | 124 | # if xmin == None: |
|
125 | 125 | # td = thisdatetime - thisdate |
|
126 | 126 | # xmin = td.seconds/(60*60.) |
|
127 | 127 | # |
|
128 | 128 | # if xmax == None: |
|
129 | 129 | # xmax = xmin + self.timerange/(60*60.) |
|
130 | 130 | # |
|
131 | 131 | # mindt = thisdate + datetime.timedelta(hours=xmin) - datetime.timedelta(seconds=time.timezone) |
|
132 | 132 | # tmin = time.mktime(mindt.timetuple()) |
|
133 | 133 | # |
|
134 | 134 | # maxdt = thisdate + datetime.timedelta(hours=xmax) - datetime.timedelta(seconds=time.timezone) |
|
135 | 135 | # tmax = time.mktime(maxdt.timetuple()) |
|
136 | 136 | # |
|
137 | 137 | # #self.timerange = tmax - tmin |
|
138 | 138 | # |
|
139 | 139 | # return tmin, tmax |
|
140 | 140 | |
|
141 | 141 | def init(self, id, nplots, wintitle): |
|
142 | 142 | |
|
143 | 143 | raise ValueError, "This method has been replaced with createFigure" |
|
144 | 144 | |
|
145 | 145 | def createFigure(self, id, wintitle, widthplot=None, heightplot=None, show=True): |
|
146 | 146 | |
|
147 | 147 | """ |
|
148 | 148 | Crea la figura de acuerdo al driver y parametros seleccionados seleccionados. |
|
149 | 149 | Las dimensiones de la pantalla es calculada a partir de los atributos self.WIDTH |
|
150 | 150 | y self.HEIGHT y el numero de subplots (nrow, ncol) |
|
151 | 151 | |
|
152 | 152 | Input: |
|
153 | 153 | id : Los parametros necesarios son |
|
154 | 154 | wintitle : |
|
155 | 155 | |
|
156 | 156 | """ |
|
157 | 157 | |
|
158 | 158 | if widthplot == None: |
|
159 | 159 | widthplot = self.WIDTH |
|
160 | 160 | |
|
161 | 161 | if heightplot == None: |
|
162 | 162 | heightplot = self.HEIGHT |
|
163 | 163 | |
|
164 | 164 | self.id = id |
|
165 | 165 | |
|
166 | 166 | self.wintitle = wintitle |
|
167 | 167 | |
|
168 | 168 | self.widthscreen, self.heightscreen = self.getScreenDim(widthplot, heightplot) |
|
169 | 169 | |
|
170 | 170 | self.fig = self.__driver.createFigure(id=self.id, |
|
171 | 171 | wintitle=self.wintitle, |
|
172 | 172 | width=self.widthscreen, |
|
173 | 173 | height=self.heightscreen, |
|
174 | 174 | show=show) |
|
175 | 175 | |
|
176 | 176 | self.axesObjList = [] |
|
177 | 177 | |
|
178 | 178 | |
|
179 | 179 | def setDriver(self, driver=mpldriver): |
|
180 | 180 | |
|
181 | 181 | self.__driver = driver |
|
182 | 182 | |
|
183 | 183 | def setTitle(self, title): |
|
184 | 184 | |
|
185 | 185 | self.__driver.setTitle(self.fig, title) |
|
186 | 186 | |
|
187 | 187 | def setWinTitle(self, title): |
|
188 | 188 | |
|
189 | 189 | self.__driver.setWinTitle(self.fig, title=title) |
|
190 | 190 | |
|
191 | 191 | def setTextFromAxes(self, text): |
|
192 | 192 | |
|
193 | 193 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo setText de la clase Axes" |
|
194 | 194 | |
|
195 | 195 | def makeAxes(self, nrow, ncol, xpos, ypos, colspan, rowspan): |
|
196 | 196 | |
|
197 | 197 | raise ValueError, "Este metodo ha sido reemplazaado con el metodo addAxes" |
|
198 | 198 | |
|
199 | 199 | def addAxes(self, *args): |
|
200 | 200 | """ |
|
201 | 201 | |
|
202 | 202 | Input: |
|
203 | 203 | *args : Los parametros necesarios son |
|
204 | 204 | nrow, ncol, xpos, ypos, colspan, rowspan |
|
205 | 205 | """ |
|
206 | 206 | |
|
207 | 207 | axesObj = Axes(self.fig, *args) |
|
208 | 208 | self.axesObjList.append(axesObj) |
|
209 | 209 | |
|
210 | 210 | def saveFigure(self, figpath, figfile, *args): |
|
211 | 211 | |
|
212 | 212 | filename = os.path.join(figpath, figfile) |
|
213 | 213 | |
|
214 | 214 | fullpath = os.path.split(filename)[0] |
|
215 | 215 | |
|
216 | 216 | if not os.path.exists(fullpath): |
|
217 | 217 | subpath = os.path.split(fullpath)[0] |
|
218 | 218 | |
|
219 | 219 | if not os.path.exists(subpath): |
|
220 | 220 | os.mkdir(subpath) |
|
221 | 221 | |
|
222 | 222 | os.mkdir(fullpath) |
|
223 | 223 | |
|
224 | 224 | self.__driver.saveFigure(self.fig, filename, *args) |
|
225 | 225 | |
|
226 | 226 | |
|
227 | 227 | |
|
228 | 228 | |
|
229 | 229 | def getNameToFtp(self, thisDatetime, FTP_WEI, EXP_CODE, SUB_EXP_CODE, PLOT_CODE, PLOT_POS): |
|
230 | 230 | YEAR_STR = '%4.4d'%thisDatetime.timetuple().tm_year |
|
231 | 231 | DOY_STR = '%3.3d'%thisDatetime.timetuple().tm_yday |
|
232 | 232 | FTP_WEI = '%2.2d'%FTP_WEI |
|
233 | 233 | EXP_CODE = '%3.3d'%EXP_CODE |
|
234 | 234 | SUB_EXP_CODE = '%2.2d'%SUB_EXP_CODE |
|
235 | 235 | PLOT_CODE = '%2.2d'%PLOT_CODE |
|
236 | 236 | PLOT_POS = '%2.2d'%PLOT_POS |
|
237 | 237 | name = YEAR_STR + DOY_STR + FTP_WEI + EXP_CODE + SUB_EXP_CODE + PLOT_CODE + PLOT_POS |
|
238 | 238 | return name |
|
239 | 239 | |
|
240 | 240 | def draw(self): |
|
241 | 241 | |
|
242 | 242 | self.__driver.draw(self.fig) |
|
243 | 243 | |
|
244 | 244 | def run(self): |
|
245 | 245 | |
|
246 | 246 | raise ValueError, "This method is not implemented" |
|
247 | 247 | |
|
248 | 248 | def close(self): |
|
249 | 249 | |
|
250 | 250 | self.__driver.show(True) |
|
251 | 251 | |
|
252 | 252 | axesList = property(getAxesObjList) |
|
253 | 253 | |
|
254 | 254 | |
|
255 | 255 | class Axes: |
|
256 | 256 | |
|
257 | 257 | __driver = mpldriver |
|
258 | 258 | fig = None |
|
259 | 259 | ax = None |
|
260 | 260 | plot = None |
|
261 | 261 | __missing = 1E30 |
|
262 | 262 | __firsttime = None |
|
263 | 263 | |
|
264 | 264 | __showprofile = False |
|
265 | 265 | |
|
266 | 266 | xmin = None |
|
267 | 267 | xmax = None |
|
268 | 268 | ymin = None |
|
269 | 269 | ymax = None |
|
270 | 270 | zmin = None |
|
271 | 271 | zmax = None |
|
272 | 272 | |
|
273 | 273 | x_buffer = None |
|
274 | 274 | z_buffer = None |
|
275 | 275 | |
|
276 | 276 | decimationx = None |
|
277 | 277 | decimationy = None |
|
278 | 278 | |
|
279 | 279 | __MAXNUMX = 300 |
|
280 | 280 | __MAXNUMY = 150 |
|
281 | 281 | |
|
282 | 282 | def __init__(self, *args): |
|
283 | 283 | |
|
284 | 284 | """ |
|
285 | 285 | |
|
286 | 286 | Input: |
|
287 | 287 | *args : Los parametros necesarios son |
|
288 | 288 | fig, nrow, ncol, xpos, ypos, colspan, rowspan |
|
289 | 289 | """ |
|
290 | 290 | |
|
291 | 291 | ax = self.__driver.createAxes(*args) |
|
292 | 292 | self.fig = args[0] |
|
293 | 293 | self.ax = ax |
|
294 | 294 | self.plot = None |
|
295 | 295 | |
|
296 | 296 | self.__firsttime = True |
|
297 | 297 | self.idlineList = [] |
|
298 | 298 | |
|
299 | 299 | self.x_buffer = numpy.array([]) |
|
300 | 300 | self.z_buffer = numpy.array([]) |
|
301 | 301 | |
|
302 | 302 | def setText(self, text): |
|
303 | 303 | |
|
304 | 304 | self.__driver.setAxesText(self.ax, text) |
|
305 | 305 | |
|
306 | 306 | def setXAxisAsTime(self): |
|
307 | 307 | pass |
|
308 | 308 | |
|
309 | 309 | def pline(self, x, y, |
|
310 | 310 | xmin=None, xmax=None, |
|
311 | 311 | ymin=None, ymax=None, |
|
312 | 312 | xlabel='', ylabel='', |
|
313 | 313 | title='', |
|
314 | 314 | **kwargs): |
|
315 | 315 | |
|
316 | 316 | """ |
|
317 | 317 | |
|
318 | 318 | Input: |
|
319 | 319 | x : |
|
320 | 320 | y : |
|
321 | 321 | xmin : |
|
322 | 322 | xmax : |
|
323 | 323 | ymin : |
|
324 | 324 | ymax : |
|
325 | 325 | xlabel : |
|
326 | 326 | ylabel : |
|
327 | 327 | title : |
|
328 | 328 | **kwargs : Los parametros aceptados son |
|
329 | 329 | |
|
330 | 330 | ticksize |
|
331 | 331 | ytick_visible |
|
332 | 332 | """ |
|
333 | 333 | |
|
334 | 334 | if self.__firsttime: |
|
335 | 335 | |
|
336 | 336 | if xmin == None: xmin = numpy.nanmin(x) |
|
337 | 337 | if xmax == None: xmax = numpy.nanmax(x) |
|
338 | 338 | if ymin == None: ymin = numpy.nanmin(y) |
|
339 | 339 | if ymax == None: ymax = numpy.nanmax(y) |
|
340 | 340 | |
|
341 | 341 | self.plot = self.__driver.createPline(self.ax, x, y, |
|
342 | 342 | xmin, xmax, |
|
343 | 343 | ymin, ymax, |
|
344 | 344 | xlabel=xlabel, |
|
345 | 345 | ylabel=ylabel, |
|
346 | 346 | title=title, |
|
347 | 347 | **kwargs) |
|
348 | 348 | |
|
349 | 349 | self.idlineList.append(0) |
|
350 | 350 | self.__firsttime = False |
|
351 | 351 | return |
|
352 | 352 | |
|
353 | 353 | self.__driver.pline(self.plot, x, y, xlabel=xlabel, |
|
354 | 354 | ylabel=ylabel, |
|
355 | 355 | title=title) |
|
356 | 356 | |
|
357 | 357 | def addpline(self, x, y, idline, **kwargs): |
|
358 | 358 | lines = self.ax.lines |
|
359 | 359 | |
|
360 | 360 | if idline in self.idlineList: |
|
361 | 361 | self.__driver.set_linedata(self.ax, x, y, idline) |
|
362 | 362 | |
|
363 | 363 | if idline not in(self.idlineList): |
|
364 | 364 | self.__driver.addpline(self.ax, x, y, **kwargs) |
|
365 | 365 | self.idlineList.append(idline) |
|
366 | 366 | |
|
367 | 367 | return |
|
368 | 368 | |
|
369 | 369 | def pmultiline(self, x, y, |
|
370 | 370 | xmin=None, xmax=None, |
|
371 | 371 | ymin=None, ymax=None, |
|
372 | 372 | xlabel='', ylabel='', |
|
373 | 373 | title='', |
|
374 | 374 | **kwargs): |
|
375 | 375 | |
|
376 | 376 | if self.__firsttime: |
|
377 | 377 | |
|
378 | 378 | if xmin == None: xmin = numpy.nanmin(x) |
|
379 | 379 | if xmax == None: xmax = numpy.nanmax(x) |
|
380 | 380 | if ymin == None: ymin = numpy.nanmin(y) |
|
381 | 381 | if ymax == None: ymax = numpy.nanmax(y) |
|
382 | 382 | |
|
383 | 383 | self.plot = self.__driver.createPmultiline(self.ax, x, y, |
|
384 | 384 | xmin, xmax, |
|
385 | 385 | ymin, ymax, |
|
386 | 386 | xlabel=xlabel, |
|
387 | 387 | ylabel=ylabel, |
|
388 | 388 | title=title, |
|
389 | 389 | **kwargs) |
|
390 | 390 | self.__firsttime = False |
|
391 | 391 | return |
|
392 | 392 | |
|
393 | 393 | self.__driver.pmultiline(self.plot, x, y, xlabel=xlabel, |
|
394 | 394 | ylabel=ylabel, |
|
395 | 395 | title=title) |
|
396 | 396 | |
|
397 | 397 | def pmultilineyaxis(self, x, y, |
|
398 | 398 | xmin=None, xmax=None, |
|
399 | 399 | ymin=None, ymax=None, |
|
400 | 400 | xlabel='', ylabel='', |
|
401 | 401 | title='', |
|
402 | 402 | **kwargs): |
|
403 | 403 | |
|
404 | 404 | if self.__firsttime: |
|
405 | 405 | |
|
406 | 406 | if xmin == None: xmin = numpy.nanmin(x) |
|
407 | 407 | if xmax == None: xmax = numpy.nanmax(x) |
|
408 | 408 | if ymin == None: ymin = numpy.nanmin(y) |
|
409 | 409 | if ymax == None: ymax = numpy.nanmax(y) |
|
410 | 410 | |
|
411 | 411 | self.plot = self.__driver.createPmultilineYAxis(self.ax, x, y, |
|
412 | 412 | xmin, xmax, |
|
413 | 413 | ymin, ymax, |
|
414 | 414 | xlabel=xlabel, |
|
415 | 415 | ylabel=ylabel, |
|
416 | 416 | title=title, |
|
417 | 417 | **kwargs) |
|
418 | 418 | if self.xmin == None: self.xmin = xmin |
|
419 | 419 | if self.xmax == None: self.xmax = xmax |
|
420 | 420 | if self.ymin == None: self.ymin = ymin |
|
421 | 421 | if self.ymax == None: self.ymax = ymax |
|
422 | 422 | |
|
423 | 423 | self.__firsttime = False |
|
424 | 424 | return |
|
425 | 425 | |
|
426 | 426 | self.__driver.pmultilineyaxis(self.plot, x, y, xlabel=xlabel, |
|
427 | 427 | ylabel=ylabel, |
|
428 | 428 | title=title) |
|
429 | 429 | |
|
430 | 430 | def pcolor(self, x, y, z, |
|
431 | 431 | xmin=None, xmax=None, |
|
432 | 432 | ymin=None, ymax=None, |
|
433 | 433 | zmin=None, zmax=None, |
|
434 | 434 | xlabel='', ylabel='', |
|
435 | 435 | title='', rti = False, colormap='jet', |
|
436 | 436 | **kwargs): |
|
437 | 437 | |
|
438 | 438 | """ |
|
439 | 439 | Input: |
|
440 | 440 | x : |
|
441 | 441 | y : |
|
442 | 442 | x : |
|
443 | 443 | xmin : |
|
444 | 444 | xmax : |
|
445 | 445 | ymin : |
|
446 | 446 | ymax : |
|
447 | 447 | zmin : |
|
448 | 448 | zmax : |
|
449 | 449 | xlabel : |
|
450 | 450 | ylabel : |
|
451 | 451 | title : |
|
452 | 452 | **kwargs : Los parametros aceptados son |
|
453 | 453 | ticksize=9, |
|
454 | 454 | cblabel='' |
|
455 | 455 | rti = True or False |
|
456 | 456 | """ |
|
457 | 457 | |
|
458 | 458 | if self.__firsttime: |
|
459 | 459 | |
|
460 | 460 | if xmin == None: xmin = numpy.nanmin(x) |
|
461 | 461 | if xmax == None: xmax = numpy.nanmax(x) |
|
462 | 462 | if ymin == None: ymin = numpy.nanmin(y) |
|
463 | 463 | if ymax == None: ymax = numpy.nanmax(y) |
|
464 | 464 | if zmin == None: zmin = numpy.nanmin(z) |
|
465 | 465 | if zmax == None: zmax = numpy.nanmax(z) |
|
466 | 466 | |
|
467 | 467 | |
|
468 | 468 | self.plot = self.__driver.createPcolor(self.ax, x, y, z, |
|
469 | 469 | xmin, xmax, |
|
470 | 470 | ymin, ymax, |
|
471 | 471 | zmin, zmax, |
|
472 | 472 | xlabel=xlabel, |
|
473 | 473 | ylabel=ylabel, |
|
474 | 474 | title=title, |
|
475 | 475 | colormap=colormap, |
|
476 | 476 | **kwargs) |
|
477 | 477 | |
|
478 | 478 | if self.xmin == None: self.xmin = xmin |
|
479 | 479 | if self.xmax == None: self.xmax = xmax |
|
480 | 480 | if self.ymin == None: self.ymin = ymin |
|
481 | 481 | if self.ymax == None: self.ymax = ymax |
|
482 | 482 | if self.zmin == None: self.zmin = zmin |
|
483 | 483 | if self.zmax == None: self.zmax = zmax |
|
484 | 484 | |
|
485 | 485 | self.__firsttime = False |
|
486 | 486 | return |
|
487 | 487 | |
|
488 | 488 | if rti: |
|
489 | 489 | self.__driver.addpcolor(self.ax, x, y, z, self.zmin, self.zmax, |
|
490 | 490 | xlabel=xlabel, |
|
491 | 491 | ylabel=ylabel, |
|
492 | 492 | title=title, |
|
493 | 493 | colormap=colormap) |
|
494 | 494 | return |
|
495 | 495 | |
|
496 | 496 | self.__driver.pcolor(self.plot, z, |
|
497 | 497 | xlabel=xlabel, |
|
498 | 498 | ylabel=ylabel, |
|
499 | 499 | title=title) |
|
500 | 500 | |
|
501 | 501 | def pcolorbuffer(self, x, y, z, |
|
502 | 502 | xmin=None, xmax=None, |
|
503 | 503 | ymin=None, ymax=None, |
|
504 | 504 | zmin=None, zmax=None, |
|
505 | 505 | xlabel='', ylabel='', |
|
506 | 506 | title='', rti = True, colormap='jet', |
|
507 | 507 | maxNumX = None, maxNumY = None, |
|
508 | 508 | **kwargs): |
|
509 | 509 | |
|
510 | 510 | if maxNumX == None: |
|
511 | 511 | maxNumX = self.__MAXNUMX |
|
512 | 512 | |
|
513 | 513 | if maxNumY == None: |
|
514 | 514 | maxNumY = self.__MAXNUMY |
|
515 | 515 | |
|
516 | 516 | if self.__firsttime: |
|
517 | 517 | self.z_buffer = z |
|
518 | 518 | self.x_buffer = numpy.hstack((self.x_buffer, x)) |
|
519 | 519 | |
|
520 | 520 | if xmin == None: xmin = numpy.nanmin(x) |
|
521 | 521 | if xmax == None: xmax = numpy.nanmax(x) |
|
522 | 522 | if ymin == None: ymin = numpy.nanmin(y) |
|
523 | 523 | if ymax == None: ymax = numpy.nanmax(y) |
|
524 | 524 | if zmin == None: zmin = numpy.nanmin(z) |
|
525 | 525 | if zmax == None: zmax = numpy.nanmax(z) |
|
526 | 526 | |
|
527 | 527 | |
|
528 | 528 | self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z, |
|
529 | 529 | xmin, xmax, |
|
530 | 530 | ymin, ymax, |
|
531 | 531 | zmin, zmax, |
|
532 | 532 | xlabel=xlabel, |
|
533 | 533 | ylabel=ylabel, |
|
534 | 534 | title=title, |
|
535 | 535 | colormap=colormap, |
|
536 | 536 | **kwargs) |
|
537 | 537 | |
|
538 | 538 | if self.xmin == None: self.xmin = xmin |
|
539 | 539 | if self.xmax == None: self.xmax = xmax |
|
540 | 540 | if self.ymin == None: self.ymin = ymin |
|
541 | 541 | if self.ymax == None: self.ymax = ymax |
|
542 | 542 | if self.zmin == None: self.zmin = zmin |
|
543 | 543 | if self.zmax == None: self.zmax = zmax |
|
544 | 544 | |
|
545 | 545 | self.__firsttime = False |
|
546 | 546 | return |
|
547 | 547 | |
|
548 | 548 | self.x_buffer = numpy.hstack((self.x_buffer, x[-1])) |
|
549 | 549 | self.z_buffer = numpy.hstack((self.z_buffer, z)) |
|
550 | 550 | |
|
551 | 551 | if self.decimationx == None: |
|
552 | 552 | deltax = float(self.xmax - self.xmin)/maxNumX |
|
553 | 553 | deltay = float(self.ymax - self.ymin)/maxNumY |
|
554 | 554 | |
|
555 | 555 | resolutionx = self.x_buffer[2]-self.x_buffer[0] |
|
556 | 556 | resolutiony = y[1]-y[0] |
|
557 | 557 | |
|
558 | 558 | self.decimationx = numpy.ceil(deltax / resolutionx) |
|
559 | 559 | self.decimationy = numpy.ceil(deltay / resolutiony) |
|
560 | 560 | |
|
561 | 561 | z_buffer = self.z_buffer.reshape(-1,len(y)) |
|
562 | 562 | |
|
563 | 563 | x_buffer = self.x_buffer[::self.decimationx] |
|
564 | 564 | y_buffer = y[::self.decimationy] |
|
565 | 565 | z_buffer = z_buffer[::self.decimationx, ::self.decimationy] |
|
566 | 566 | #=================================================== |
|
567 | 567 | |
|
568 | 568 | x_buffer, y_buffer, z_buffer = self.__fillGaps(x_buffer, y_buffer, z_buffer) |
|
569 | 569 | |
|
570 | 570 | self.__driver.addpcolorbuffer(self.ax, x_buffer, y_buffer, z_buffer, self.zmin, self.zmax, |
|
571 | 571 | xlabel=xlabel, |
|
572 | 572 | ylabel=ylabel, |
|
573 | 573 | title=title, |
|
574 | 574 | colormap=colormap) |
|
575 | 575 | def __fillGaps(self, x_buffer, y_buffer, z_buffer): |
|
576 | 576 | |
|
577 | 577 | deltas = x_buffer[1:] - x_buffer[0:-1] |
|
578 | 578 | x_median = numpy.median(deltas) |
|
579 | 579 | |
|
580 | 580 | index = numpy.where(deltas >= 2*x_median) |
|
581 | 581 | |
|
582 | 582 | if len(index[0]) != 0: |
|
583 | 583 | z_buffer[index[0],::] = self.__missing |
|
584 | 584 | z_buffer = numpy.ma.masked_inside(z_buffer,0.99*self.__missing,1.01*self.__missing) |
|
585 | 585 | |
|
586 | 586 | return x_buffer, y_buffer, z_buffer |
|
587 | 587 | |
|
588 | 588 | |
|
589 | 589 | |
|
590 | 590 | No newline at end of file |
@@ -1,542 +1,573 | |||
|
1 | 1 | ''' |
|
2 | 2 | @author: Daniel Suarez |
|
3 | 3 | ''' |
|
4 | 4 | |
|
5 | 5 | import os |
|
6 | 6 | import sys |
|
7 | 7 | import glob |
|
8 | 8 | import fnmatch |
|
9 | 9 | import datetime |
|
10 | import time | |
|
10 | 11 | import re |
|
11 | 12 | import h5py |
|
12 | 13 | import numpy |
|
13 | 14 | |
|
14 | 15 | from model.proc.jroproc_base import ProcessingUnit, Operation |
|
15 | 16 | from model.data.jroamisr import AMISR |
|
16 | 17 | |
|
17 | 18 | class RadacHeader(): |
|
18 | 19 | def __init__(self, fp): |
|
19 | 20 | header = 'Raw11/Data/RadacHeader' |
|
20 | 21 | self.beamCodeByPulse = fp.get(header+'/BeamCode') |
|
21 | 22 | self.beamCode = fp.get('Raw11/Data/Beamcodes') |
|
22 | 23 | self.code = fp.get(header+'/Code') |
|
23 | 24 | self.frameCount = fp.get(header+'/FrameCount') |
|
24 | 25 | self.modeGroup = fp.get(header+'/ModeGroup') |
|
25 | 26 | self.nsamplesPulse = fp.get(header+'/NSamplesPulse') |
|
26 | 27 | self.pulseCount = fp.get(header+'/PulseCount') |
|
27 | 28 | self.radacTime = fp.get(header+'/RadacTime') |
|
28 | 29 | self.timeCount = fp.get(header+'/TimeCount') |
|
29 | 30 | self.timeStatus = fp.get(header+'/TimeStatus') |
|
30 | 31 | |
|
31 | 32 | self.nrecords = self.pulseCount.shape[0] #nblocks |
|
32 | 33 | self.npulses = self.pulseCount.shape[1] #nprofile |
|
33 | 34 | self.nsamples = self.nsamplesPulse[0,0] #ngates |
|
34 | 35 | self.nbeams = self.beamCode.shape[1] |
|
35 | ||
|
36 | ||
|
36 | 37 | |
|
37 | 38 | def getIndexRangeToPulse(self, idrecord=0): |
|
38 | indexToZero = numpy.where(self.pulseCount.value[idrecord,:]==0) | |
|
39 | startPulseCountId = indexToZero[0][0] | |
|
40 | endPulseCountId = startPulseCountId - 1 | |
|
41 | range1 = numpy.arange(startPulseCountId,self.npulses,1) | |
|
42 | range2 = numpy.arange(0,startPulseCountId,1) | |
|
43 | return range1, range2 | |
|
44 | ||
|
39 | #indexToZero = numpy.where(self.pulseCount.value[idrecord,:]==0) | |
|
40 | #startPulseCountId = indexToZero[0][0] | |
|
41 | #endPulseCountId = startPulseCountId - 1 | |
|
42 | #range1 = numpy.arange(startPulseCountId,self.npulses,1) | |
|
43 | #range2 = numpy.arange(0,startPulseCountId,1) | |
|
44 | #return range1, range2 | |
|
45 | ||
|
46 | looking_zeros_index = numpy.where(self.pulseCount.value[idrecord,:]==0)[0] | |
|
47 | getLastIndexZero = looking_zeros_index[-1] | |
|
48 | index_data = numpy.arange(0,getLastIndexZero,1) | |
|
49 | index_buffer = numpy.arange(getLastIndexZero,self.npulses,1) | |
|
50 | return index_data, index_buffer | |
|
45 | 51 | |
|
46 | 52 | class AMISRReader(ProcessingUnit): |
|
47 | 53 | |
|
48 | 54 | path = None |
|
49 | 55 | startDate = None |
|
50 | 56 | endDate = None |
|
51 | 57 | startTime = None |
|
52 | 58 | endTime = None |
|
53 | 59 | walk = None |
|
54 | 60 | isConfig = False |
|
55 | 61 | |
|
56 | 62 | def __init__(self): |
|
57 | 63 | self.set = None |
|
58 | 64 | self.subset = None |
|
59 | 65 | self.extension_file = '.h5' |
|
60 | 66 | self.dtc_str = 'dtc' |
|
61 | 67 | self.dtc_id = 0 |
|
62 | 68 | self.status = True |
|
63 | 69 | self.isConfig = False |
|
64 | 70 | self.dirnameList = [] |
|
65 | 71 | self.filenameList = [] |
|
66 | 72 | self.fileIndex = None |
|
67 | 73 | self.flagNoMoreFiles = False |
|
68 | 74 | self.flagIsNewFile = 0 |
|
69 | 75 | self.filename = '' |
|
70 | 76 | self.amisrFilePointer = None |
|
71 | 77 | self.radacHeaderObj = None |
|
72 | 78 | self.dataOut = self.__createObjByDefault() |
|
73 | 79 | self.datablock = None |
|
74 | 80 | self.rest_datablock = None |
|
75 | 81 | self.range = None |
|
76 | 82 | self.idrecord_count = 0 |
|
77 | 83 | self.profileIndex = 0 |
|
78 |
self.i |
|
|
79 |
self.i |
|
|
84 | self.index_amisr_sample = None | |
|
85 | self.index_amisr_buffer = None | |
|
80 | 86 | self.beamCodeByFrame = None |
|
81 | 87 | self.radacTimeByFrame = None |
|
82 | 88 | #atributos originales tal y como esta en el archivo de datos |
|
83 | 89 | self.beamCodesFromFile = None |
|
84 | 90 | self.radacTimeFromFile = None |
|
85 | 91 | self.rangeFromFile = None |
|
86 | 92 | self.dataByFrame = None |
|
87 | 93 | self.dataset = None |
|
88 | 94 | |
|
89 | 95 | self.beamCodeDict = {} |
|
90 | 96 | self.beamRangeDict = {} |
|
91 | 97 | |
|
92 | 98 | #experiment cgf file |
|
93 | 99 | self.npulsesint_fromfile = None |
|
94 | 100 | self.recordsperfile_fromfile = None |
|
95 | 101 | self.nbeamcodes_fromfile = None |
|
96 | 102 | self.ngates_fromfile = None |
|
97 | 103 | self.ippSeconds_fromfile = None |
|
98 | 104 | self.frequency_h5file = None |
|
99 | 105 | |
|
100 | 106 | |
|
101 | 107 | self.__firstFile = True |
|
102 | 108 | self.buffer_radactime = None |
|
103 | 109 | |
|
110 | self.index4_schain_datablock = None | |
|
111 | self.index4_buffer = None | |
|
112 | self.schain_datablock = None | |
|
113 | self.buffer = None | |
|
114 | self.linear_pulseCount = None | |
|
115 | self.npulseByFrame = None | |
|
116 | self.profileIndex_offset = None | |
|
117 | self.timezone = 'ut' | |
|
118 | ||
|
104 | 119 | def __createObjByDefault(self): |
|
105 | 120 | |
|
106 | 121 | dataObj = AMISR() |
|
107 | 122 | |
|
108 | 123 | return dataObj |
|
109 | 124 | |
|
110 | 125 | def __setParameters(self,path,startDate,endDate,startTime,endTime,walk): |
|
111 | 126 | self.path = path |
|
112 | 127 | self.startDate = startDate |
|
113 | 128 | self.endDate = endDate |
|
114 | 129 | self.startTime = startTime |
|
115 | 130 | self.endTime = endTime |
|
116 | 131 | self.walk = walk |
|
117 | 132 | |
|
118 | 133 | def __checkPath(self): |
|
119 | 134 | if os.path.exists(self.path): |
|
120 | 135 | self.status = 1 |
|
121 | 136 | else: |
|
122 | 137 | self.status = 0 |
|
123 | 138 | print 'Path:%s does not exists'%self.path |
|
124 | 139 | |
|
125 | 140 | return |
|
126 | 141 | |
|
127 | 142 | def __selDates(self, amisr_dirname_format): |
|
128 | 143 | try: |
|
129 | 144 | year = int(amisr_dirname_format[0:4]) |
|
130 | 145 | month = int(amisr_dirname_format[4:6]) |
|
131 | 146 | dom = int(amisr_dirname_format[6:8]) |
|
132 | 147 | thisDate = datetime.date(year,month,dom) |
|
133 | 148 | |
|
134 | 149 | if (thisDate>=self.startDate and thisDate <= self.endDate): |
|
135 | 150 | return amisr_dirname_format |
|
136 | 151 | except: |
|
137 | 152 | return None |
|
138 | 153 | |
|
139 | 154 | def __findDataForDates(self): |
|
140 | 155 | |
|
141 | 156 | |
|
142 | 157 | |
|
143 | 158 | if not(self.status): |
|
144 | 159 | return None |
|
145 | 160 | |
|
146 | 161 | pat = '\d+.\d+' |
|
147 | 162 | dirnameList = [re.search(pat,x) for x in os.listdir(self.path)] |
|
148 | 163 | dirnameList = filter(lambda x:x!=None,dirnameList) |
|
149 | 164 | dirnameList = [x.string for x in dirnameList] |
|
150 | 165 | dirnameList = [self.__selDates(x) for x in dirnameList] |
|
151 | 166 | dirnameList = filter(lambda x:x!=None,dirnameList) |
|
152 | 167 | if len(dirnameList)>0: |
|
153 | 168 | self.status = 1 |
|
154 | 169 | self.dirnameList = dirnameList |
|
155 | 170 | self.dirnameList.sort() |
|
156 | 171 | else: |
|
157 | 172 | self.status = 0 |
|
158 | 173 | return None |
|
159 | 174 | |
|
160 | 175 | def __getTimeFromData(self): |
|
161 | 176 | pass |
|
162 | 177 | |
|
163 | 178 | def __filterByGlob1(self, dirName): |
|
164 | 179 | filter_files = glob.glob1(dirName, '*.*%s'%self.extension_file) |
|
165 | 180 | filterDict = {} |
|
166 | 181 | filterDict.setdefault(dirName) |
|
167 | 182 | filterDict[dirName] = filter_files |
|
168 | 183 | return filterDict |
|
169 | 184 | |
|
170 | 185 | def __getFilenameList(self, fileListInKeys, dirList): |
|
171 | 186 | for value in fileListInKeys: |
|
172 | 187 | dirName = value.keys()[0] |
|
173 | 188 | for file in value[dirName]: |
|
174 | 189 | filename = os.path.join(dirName, file) |
|
175 | 190 | self.filenameList.append(filename) |
|
176 | 191 | |
|
177 | 192 | |
|
178 | 193 | def __selectDataForTimes(self): |
|
179 | 194 | #aun no esta implementado el filtro for tiempo |
|
180 | 195 | if not(self.status): |
|
181 | 196 | return None |
|
182 | 197 | |
|
183 | 198 | dirList = [os.path.join(self.path,x) for x in self.dirnameList] |
|
184 | 199 | |
|
185 | 200 | fileListInKeys = [self.__filterByGlob1(x) for x in dirList] |
|
186 | 201 | |
|
187 | 202 | self.__getFilenameList(fileListInKeys, dirList) |
|
188 | 203 | |
|
189 | 204 | if len(self.filenameList)>0: |
|
190 | 205 | self.status = 1 |
|
191 | 206 | self.filenameList.sort() |
|
192 | 207 | else: |
|
193 | 208 | self.status = 0 |
|
194 | 209 | return None |
|
195 | 210 | |
|
196 | 211 | |
|
197 | 212 | def __searchFilesOffline(self, |
|
198 | 213 | path, |
|
199 | 214 | startDate, |
|
200 | 215 | endDate, |
|
201 | 216 | startTime=datetime.time(0,0,0), |
|
202 | 217 | endTime=datetime.time(23,59,59), |
|
203 | 218 | walk=True): |
|
204 | 219 | |
|
205 | 220 | self.__setParameters(path, startDate, endDate, startTime, endTime, walk) |
|
206 | 221 | |
|
207 | 222 | self.__checkPath() |
|
208 | 223 | |
|
209 | 224 | self.__findDataForDates() |
|
210 | 225 | |
|
211 | 226 | self.__selectDataForTimes() |
|
212 | 227 | |
|
213 | 228 | for i in range(len(self.filenameList)): |
|
214 | 229 | print "%s" %(self.filenameList[i]) |
|
215 | 230 | |
|
216 | 231 | return |
|
217 | 232 | |
|
218 | 233 | def __setNextFileOffline(self): |
|
219 | 234 | idFile = self.fileIndex |
|
220 | 235 | |
|
221 | 236 | while (True): |
|
222 | 237 | idFile += 1 |
|
223 | 238 | if not(idFile < len(self.filenameList)): |
|
224 | 239 | self.flagNoMoreFiles = 1 |
|
225 | 240 | print "No more Files" |
|
226 | 241 | return 0 |
|
227 | 242 | |
|
228 | 243 | filename = self.filenameList[idFile] |
|
229 | 244 | |
|
230 | 245 | amisrFilePointer = h5py.File(filename,'r') |
|
231 | 246 | |
|
232 | 247 | break |
|
233 | 248 | |
|
234 | 249 | self.flagIsNewFile = 1 |
|
235 | 250 | self.fileIndex = idFile |
|
236 | 251 | self.filename = filename |
|
237 | 252 | |
|
238 | 253 | self.amisrFilePointer = amisrFilePointer |
|
239 | 254 | |
|
240 | 255 | print "Setting the file: %s"%self.filename |
|
241 | 256 | |
|
242 | 257 | return 1 |
|
243 | 258 | |
|
244 | 259 | def __readHeader(self): |
|
245 | 260 | self.radacHeaderObj = RadacHeader(self.amisrFilePointer) |
|
246 | 261 | |
|
247 | 262 | #update values from experiment cfg file |
|
248 | 263 | if self.radacHeaderObj.nrecords == self.recordsperfile_fromfile: |
|
249 | 264 | self.radacHeaderObj.nrecords = self.recordsperfile_fromfile |
|
250 | 265 | self.radacHeaderObj.nbeams = self.nbeamcodes_fromfile |
|
251 | 266 | self.radacHeaderObj.npulses = self.npulsesint_fromfile |
|
252 | 267 | self.radacHeaderObj.nsamples = self.ngates_fromfile |
|
253 | 268 | |
|
269 | #looking index list for data | |
|
270 | start_index = self.radacHeaderObj.pulseCount[0,:][0] | |
|
271 | end_index = self.radacHeaderObj.npulses | |
|
272 | range4data = range(start_index, end_index) | |
|
273 | self.index4_schain_datablock = numpy.array(range4data) | |
|
274 | ||
|
275 | buffer_start_index = 0 | |
|
276 | buffer_end_index = self.radacHeaderObj.pulseCount[0,:][0] | |
|
277 | range4buffer = range(buffer_start_index, buffer_end_index) | |
|
278 | self.index4_buffer = numpy.array(range4buffer) | |
|
279 | ||
|
280 | self.linear_pulseCount = numpy.array(range4data + range4buffer) | |
|
281 | self.npulseByFrame = max(self.radacHeaderObj.pulseCount[0,:]+1) | |
|
282 | ||
|
254 | 283 | #get tuning frequency |
|
255 | 284 | frequency_h5file_dataset = self.amisrFilePointer.get('Rx'+'/TuningFrequency') |
|
256 | 285 | self.frequency_h5file = frequency_h5file_dataset[0,0] |
|
257 | 286 | |
|
258 | 287 | self.flagIsNewFile = 1 |
|
259 | 288 | |
|
260 | 289 | def __getBeamCode(self): |
|
261 | 290 | self.beamCodeDict = {} |
|
262 | 291 | self.beamRangeDict = {} |
|
263 | 292 | |
|
264 | 293 | for i in range(len(self.radacHeaderObj.beamCode[0,:])): |
|
265 | 294 | self.beamCodeDict.setdefault(i) |
|
266 | 295 | self.beamRangeDict.setdefault(i) |
|
267 | 296 | self.beamCodeDict[i] = self.radacHeaderObj.beamCode[0,i] |
|
268 | 297 | |
|
269 | 298 | |
|
270 | 299 | just4record0 = self.radacHeaderObj.beamCodeByPulse[0,:] |
|
271 | 300 | |
|
272 | 301 | for i in range(len(self.beamCodeDict.values())): |
|
273 | 302 | xx = numpy.where(just4record0==self.beamCodeDict.values()[i]) |
|
274 | 303 | self.beamRangeDict[i] = xx[0] |
|
275 | 304 | |
|
276 | 305 | def __getExpParameters(self): |
|
277 | 306 | if not(self.status): |
|
278 | 307 | return None |
|
279 | 308 | |
|
280 | 309 | experimentCfgPath = os.path.join(self.path, self.dirnameList[0], 'Setup') |
|
281 | 310 | |
|
282 | 311 | expFinder = glob.glob1(experimentCfgPath,'*.exp') |
|
283 | 312 | if len(expFinder)== 0: |
|
284 | 313 | self.status = 0 |
|
285 | 314 | return None |
|
286 | 315 | |
|
287 | 316 | experimentFilename = os.path.join(experimentCfgPath,expFinder[0]) |
|
288 | 317 | |
|
289 | 318 | f = open(experimentFilename) |
|
290 | 319 | lines = f.readlines() |
|
291 | 320 | f.close() |
|
292 | 321 | |
|
293 | 322 | parmsList = ['npulsesint*','recordsperfile*','nbeamcodes*','ngates*'] |
|
294 | 323 | filterList = [fnmatch.filter(lines, x) for x in parmsList] |
|
295 | 324 | |
|
296 | 325 | |
|
297 | 326 | values = [re.sub(r'\D',"",x[0]) for x in filterList] |
|
298 | 327 | |
|
299 | 328 | self.npulsesint_fromfile = int(values[0]) |
|
300 | 329 | self.recordsperfile_fromfile = int(values[1]) |
|
301 | 330 | self.nbeamcodes_fromfile = int(values[2]) |
|
302 | 331 | self.ngates_fromfile = int(values[3]) |
|
303 | 332 | |
|
304 | 333 | tufileFinder = fnmatch.filter(lines, 'tufile=*') |
|
305 | 334 | tufile = tufileFinder[0].split('=')[1].split('\n')[0] |
|
306 | 335 | tufilename = os.path.join(experimentCfgPath,tufile) |
|
307 | 336 | |
|
308 | 337 | f = open(tufilename) |
|
309 | 338 | lines = f.readlines() |
|
310 | 339 | f.close() |
|
311 | 340 | self.ippSeconds_fromfile = float(lines[1].split()[2])/1E6 |
|
312 | 341 | |
|
313 | 342 | |
|
314 | 343 | self.status = 1 |
|
315 | 344 | |
|
316 | 345 | def __setIdsAndArrays(self): |
|
317 | 346 | self.dataByFrame = self.__setDataByFrame() |
|
318 | 347 | self.beamCodeByFrame = self.amisrFilePointer.get('Raw11/Data/RadacHeader/BeamCode').value[0, :] |
|
319 | 348 | self.readRanges() |
|
320 |
self.i |
|
|
349 | self.index_amisr_sample, self.index_amisr_buffer = self.radacHeaderObj.getIndexRangeToPulse(0) | |
|
321 | 350 | self.radacTimeByFrame = numpy.zeros(self.radacHeaderObj.npulses) |
|
322 | 351 | self.buffer_radactime = numpy.zeros_like(self.radacTimeByFrame) |
|
323 | 352 | |
|
324 | 353 | |
|
325 | 354 | def __setNextFile(self): |
|
326 | 355 | |
|
327 | 356 | newFile = self.__setNextFileOffline() |
|
328 | 357 | |
|
329 | 358 | if not(newFile): |
|
330 | 359 | return 0 |
|
331 | 360 | |
|
332 | 361 | self.__readHeader() |
|
333 | 362 | |
|
334 | 363 | if self.__firstFile: |
|
335 | 364 | self.__setIdsAndArrays() |
|
336 | 365 | self.__firstFile = False |
|
337 | 366 | |
|
338 | 367 | self.__getBeamCode() |
|
339 | 368 | self.readDataBlock() |
|
340 | 369 | |
|
341 | 370 | |
|
342 | 371 | def setup(self,path=None, |
|
343 | 372 | startDate=None, |
|
344 | 373 | endDate=None, |
|
345 | 374 | startTime=datetime.time(0,0,0), |
|
346 | 375 | endTime=datetime.time(23,59,59), |
|
347 |
walk=True |
|
|
376 | walk=True, | |
|
377 | timezone='ut',): | |
|
348 | 378 | |
|
379 | self.timezone = timezone | |
|
349 | 380 | #Busqueda de archivos offline |
|
350 | 381 | self.__searchFilesOffline(path, startDate, endDate, startTime, endTime, walk) |
|
351 | 382 | |
|
352 | 383 | if not(self.filenameList): |
|
353 | 384 | print "There is no files into the folder: %s"%(path) |
|
354 | 385 | |
|
355 | 386 | sys.exit(-1) |
|
356 | 387 | |
|
357 | 388 | self.__getExpParameters() |
|
358 | 389 | |
|
359 | 390 | self.fileIndex = -1 |
|
360 | 391 | |
|
361 | 392 | self.__setNextFile() |
|
393 | ||
|
394 | first_beamcode = self.radacHeaderObj.beamCodeByPulse[0,0] | |
|
395 | index = numpy.where(self.radacHeaderObj.beamCodeByPulse[0,:]!=first_beamcode)[0][0] | |
|
396 | self.profileIndex_offset = self.radacHeaderObj.pulseCount[0,:][index] | |
|
397 | self.profileIndex = self.profileIndex_offset | |
|
362 | 398 | |
|
363 | 399 | def readRanges(self): |
|
364 | 400 | dataset = self.amisrFilePointer.get('Raw11/Data/Samples/Range') |
|
365 | 401 | #self.rangeFromFile = dataset.value |
|
366 | 402 | self.rangeFromFile = numpy.reshape(dataset.value,(-1)) |
|
367 | 403 | return range |
|
368 | 404 | |
|
369 | 405 | |
|
370 | 406 | def readRadacTime(self,idrecord, range1, range2): |
|
371 | 407 | self.radacTimeFromFile = self.radacHeaderObj.radacTime.value |
|
372 | 408 | |
|
373 | 409 | radacTimeByFrame = numpy.zeros((self.radacHeaderObj.npulses)) |
|
374 | 410 | #radacTimeByFrame = dataset[idrecord - 1,range1] |
|
375 | 411 | #radacTimeByFrame = dataset[idrecord,range2] |
|
376 | 412 | |
|
377 | 413 | return radacTimeByFrame |
|
378 | 414 | |
|
379 | 415 | def readBeamCode(self, idrecord, range1, range2): |
|
380 | 416 | dataset = self.amisrFilePointer.get('Raw11/Data/RadacHeader/BeamCode') |
|
381 | 417 | beamcodeByFrame = numpy.zeros((self.radacHeaderObj.npulses)) |
|
382 | 418 | self.beamCodesFromFile = dataset.value |
|
383 | 419 | |
|
384 | 420 | #beamcodeByFrame[range1] = dataset[idrecord - 1, range1] |
|
385 | 421 | #beamcodeByFrame[range2] = dataset[idrecord, range2] |
|
386 | 422 | beamcodeByFrame[range1] = dataset[idrecord, range1] |
|
387 | 423 | beamcodeByFrame[range2] = dataset[idrecord, range2] |
|
388 | 424 | |
|
389 | 425 | return beamcodeByFrame |
|
390 | 426 | |
|
391 | 427 | |
|
392 | 428 | def __setDataByFrame(self): |
|
393 | 429 | ndata = 2 # porque es complejo |
|
394 | 430 | dataByFrame = numpy.zeros((self.radacHeaderObj.npulses, self.radacHeaderObj.nsamples, ndata)) |
|
395 | 431 | return dataByFrame |
|
396 | 432 | |
|
397 | 433 | def __readDataSet(self): |
|
398 | 434 | dataset = self.amisrFilePointer.get('Raw11/Data/Samples/Data') |
|
399 | 435 | return dataset |
|
400 | 436 | |
|
401 | 437 | def __setDataBlock(self,): |
|
402 | 438 | real = self.dataByFrame[:,:,0] #asumo que 0 es real |
|
403 | 439 | imag = self.dataByFrame[:,:,1] #asumo que 1 es imaginario |
|
404 | 440 | datablock = real + imag*1j #armo el complejo |
|
405 | 441 | return datablock |
|
406 | 442 | |
|
407 | 443 | def readSamples_version1(self,idrecord): |
|
408 | 444 | #estas tres primeras lineas solo se deben ejecutar una vez |
|
409 | 445 | if self.flagIsNewFile: |
|
410 | 446 | #reading dataset |
|
411 | 447 | self.dataset = self.__readDataSet() |
|
412 | 448 | self.flagIsNewFile = 0 |
|
413 | 449 | |
|
414 | 450 | if idrecord == 0: |
|
415 | #if self.buffer_last_record == None: | |
|
416 | selectorById = self.radacHeaderObj.pulseCount[0,self.idpulse_range2] | |
|
417 | ||
|
418 | self.dataByFrame[selectorById,:,:] = self.dataset[0, self.idpulse_range2,:,:] | |
|
419 | ||
|
420 | self.radacTimeByFrame[selectorById] = self.radacHeaderObj.radacTime[0, self.idpulse_range2] | |
|
421 | ||
|
422 | selectorById = self.radacHeaderObj.pulseCount[0,self.idpulse_range1] | |
|
423 | ||
|
424 | self.radacTimeByFrame[selectorById] = self.buffer_radactime[selectorById] | |
|
425 | ||
|
451 | self.dataByFrame[self.index4_schain_datablock, : ,:] = self.dataset[0, self.index_amisr_sample,:,:] | |
|
452 | self.radacTimeByFrame[self.index4_schain_datablock] = self.radacHeaderObj.radacTime[0, self.index_amisr_sample] | |
|
426 | 453 | datablock = self.__setDataBlock() |
|
427 | 454 | |
|
455 | self.buffer = self.dataset[0, self.index_amisr_buffer,:,:] | |
|
456 | self.buffer_radactime = self.radacHeaderObj.radacTime[0, self.index_amisr_buffer] | |
|
457 | ||
|
428 | 458 | return datablock |
|
429 | 459 | |
|
430 | selectorById = self.radacHeaderObj.pulseCount[idrecord-1,self.idpulse_range1] | |
|
431 | self.dataByFrame[selectorById,:,:] = self.dataset[idrecord-1, self.idpulse_range1, :, :] | |
|
432 | self.radacTimeByFrame[selectorById] = self.radacHeaderObj.radacTime[idrecord-1, self.idpulse_range1] | |
|
433 | ||
|
434 | selectorById = self.radacHeaderObj.pulseCount[idrecord,self.idpulse_range2]#data incompleta ultimo archivo de carpeta, verifica el record real segun la dimension del arreglo de datos | |
|
435 | self.dataByFrame[selectorById,:,:] = self.dataset[idrecord, self.idpulse_range2, :, :] | |
|
436 | self.radacTimeByFrame[selectorById] = self.radacHeaderObj.radacTime[idrecord, self.idpulse_range2] | |
|
437 | ||
|
438 | datablock = self.__setDataBlock() | |
|
460 | self.dataByFrame[self.index4_buffer,:,:] = self.buffer.copy() | |
|
461 | self.radacTimeByFrame[self.index4_buffer] = self.buffer_radactime.copy() | |
|
462 | self.dataByFrame[self.index4_schain_datablock,:,:] = self.dataset[idrecord, self.index_amisr_sample,:,:] | |
|
463 | self.radacTimeByFrame[self.index4_schain_datablock] = self.radacHeaderObj.radacTime[idrecord, self.index_amisr_sample] | |
|
464 | datablock = self.__setDataBlock() | |
|
439 | 465 | |
|
440 |
sele |
|
|
441 | self.dataByFrame[selectorById,:,:] = self.dataset[idrecord, self.idpulse_range1, :, :] | |
|
442 | self.buffer_radactime[selectorById] = self.radacHeaderObj.radacTime[idrecord, self.idpulse_range1] | |
|
466 | self.buffer = self.dataset[idrecord, self.index_amisr_buffer, :, :] | |
|
467 | self.buffer_radactime = self.radacHeaderObj.radacTime[idrecord, self.index_amisr_buffer] | |
|
443 | 468 | |
|
444 | 469 | return datablock |
|
445 | 470 | |
|
446 | 471 | |
|
447 | 472 | def readSamples(self,idrecord): |
|
448 | 473 | if self.flagIsNewFile: |
|
449 | 474 | self.dataByFrame = self.__setDataByFrame() |
|
450 | 475 | self.beamCodeByFrame = self.amisrFilePointer.get('Raw11/Data/RadacHeader/BeamCode').value[idrecord, :] |
|
451 | 476 | |
|
452 | 477 | #reading ranges |
|
453 | 478 | self.readRanges() |
|
454 | 479 | #reading dataset |
|
455 | 480 | self.dataset = self.__readDataSet() |
|
456 | 481 | |
|
457 | 482 | self.flagIsNewFile = 0 |
|
458 | 483 | self.radacTimeByFrame = self.radacHeaderObj.radacTime.value[idrecord, :] |
|
459 | 484 | self.dataByFrame = self.dataset[idrecord, :, :, :] |
|
460 | 485 | datablock = self.__setDataBlock() |
|
461 | 486 | return datablock |
|
462 | 487 | |
|
463 | 488 | |
|
464 | 489 | def readDataBlock(self): |
|
465 | 490 | |
|
466 | 491 | self.datablock = self.readSamples_version1(self.idrecord_count) |
|
467 | 492 | #self.datablock = self.readSamples(self.idrecord_count) |
|
468 | 493 | #print 'record:', self.idrecord_count |
|
469 | 494 | |
|
470 | 495 | self.idrecord_count += 1 |
|
471 | 496 | self.profileIndex = 0 |
|
472 | 497 | |
|
473 | 498 | if self.idrecord_count >= self.radacHeaderObj.nrecords: |
|
474 | 499 | self.idrecord_count = 0 |
|
475 | 500 | self.flagIsNewFile = 1 |
|
476 | 501 | |
|
477 | 502 | def readNextBlock(self): |
|
478 | 503 | |
|
479 | 504 | self.readDataBlock() |
|
480 | 505 | |
|
481 | 506 | if self.flagIsNewFile: |
|
482 | 507 | self.__setNextFile() |
|
483 | 508 | pass |
|
484 | 509 | |
|
485 | 510 | def __hasNotDataInBuffer(self): |
|
486 | 511 | #self.radacHeaderObj.npulses debe ser otra variable para considerar el numero de pulsos a tomar en el primer y ultimo record |
|
487 | 512 | if self.profileIndex >= self.radacHeaderObj.npulses: |
|
488 | 513 | return 1 |
|
489 | 514 | return 0 |
|
490 | 515 | |
|
491 | 516 | def printUTC(self): |
|
492 | 517 | print self.dataOut.utctime |
|
493 | 518 | print '' |
|
494 | 519 | |
|
495 | 520 | def setObjProperties(self): |
|
496 | 521 | self.dataOut.heightList = self.rangeFromFile/1000.0 #km |
|
497 | 522 | self.dataOut.nProfiles = self.radacHeaderObj.npulses |
|
498 | 523 | self.dataOut.nRecords = self.radacHeaderObj.nrecords |
|
499 | 524 | self.dataOut.nBeams = self.radacHeaderObj.nbeams |
|
500 | 525 | self.dataOut.ippSeconds = self.ippSeconds_fromfile |
|
501 | 526 | self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt |
|
502 | 527 | self.dataOut.frequency = self.frequency_h5file |
|
528 | self.dataOut.npulseByFrame = self.npulseByFrame | |
|
503 | 529 | self.dataOut.nBaud = None |
|
504 | 530 | self.dataOut.nCode = None |
|
505 | 531 | self.dataOut.code = None |
|
506 | 532 | |
|
507 | 533 | self.dataOut.beamCodeDict = self.beamCodeDict |
|
508 | 534 | self.dataOut.beamRangeDict = self.beamRangeDict |
|
509 | ||
|
535 | ||
|
536 | if self.timezone == 'lt': | |
|
537 | self.dataOut.timeZone = time.timezone / 60. #get the timezone in minutes | |
|
538 | else: | |
|
539 | self.dataOut.timeZone = 0 #by default time is UTC | |
|
540 | ||
|
510 | 541 | def getData(self): |
|
511 | 542 | |
|
512 | 543 | if self.flagNoMoreFiles: |
|
513 | 544 | self.dataOut.flagNoData = True |
|
514 | 545 | print 'Process finished' |
|
515 | 546 | return 0 |
|
516 | 547 | |
|
517 | 548 | if self.__hasNotDataInBuffer(): |
|
518 | 549 | self.readNextBlock() |
|
519 | 550 | |
|
520 | 551 | |
|
521 | 552 | if self.datablock == None: # setear esta condicion cuando no hayan datos por leers |
|
522 | 553 | self.dataOut.flagNoData = True |
|
523 | 554 | return 0 |
|
524 | 555 | |
|
525 | 556 | self.dataOut.data = numpy.reshape(self.datablock[self.profileIndex,:],(1,-1)) |
|
526 | 557 | |
|
527 | 558 | self.dataOut.utctime = self.radacTimeByFrame[self.profileIndex] |
|
528 | 559 | |
|
529 | 560 | self.dataOut.flagNoData = False |
|
530 | 561 | |
|
531 | 562 | self.profileIndex += 1 |
|
532 | 563 | |
|
533 | 564 | return self.dataOut.data |
|
534 | 565 | |
|
535 | 566 | |
|
536 | 567 | def run(self, **kwargs): |
|
537 | 568 | if not(self.isConfig): |
|
538 | 569 | self.setup(**kwargs) |
|
539 | 570 | self.setObjProperties() |
|
540 | 571 | self.isConfig = True |
|
541 | 572 | |
|
542 | 573 | self.getData() |
@@ -1,82 +1,87 | |||
|
1 | 1 | ''' |
|
2 | 2 | @author: Daniel Suarez |
|
3 | 3 | ''' |
|
4 | 4 | |
|
5 | 5 | from jroproc_base import ProcessingUnit, Operation |
|
6 | 6 | from model.data.jroamisr import AMISR |
|
7 | 7 | |
|
8 | 8 | class AMISRProc(ProcessingUnit): |
|
9 | 9 | def __init__(self): |
|
10 | 10 | ProcessingUnit.__init__(self) |
|
11 | 11 | self.objectDict = {} |
|
12 | 12 | self.dataOut = AMISR() |
|
13 | 13 | |
|
14 | 14 | def run(self): |
|
15 | 15 | if self.dataIn.type == 'AMISR': |
|
16 | 16 | self.dataOut.copy(self.dataIn) |
|
17 | 17 | |
|
18 | 18 | |
|
19 | 19 | class PrintInfo(Operation): |
|
20 | 20 | def __init__(self): |
|
21 | pass | |
|
21 | self.__isPrinted = False | |
|
22 | 22 | |
|
23 | 23 | def run(self, dataOut): |
|
24 | 24 | |
|
25 | print 'Number of Records by File: %d'%dataOut.nRecords | |
|
26 |
print 'Number of |
|
|
27 |
print 'Number of |
|
|
28 | print 'Ipp Seconds: %f'%dataOut.ippSeconds | |
|
29 |
print 'Number of |
|
|
30 | print 'BeamCodes:' | |
|
31 | beamStrList = ['Beam %d -> Code %d'%(k,v) for k,v in dataOut.beamCodeDict.items()] | |
|
32 | for b in beamStrList: | |
|
33 | print b | |
|
25 | if not self.__isPrinted: | |
|
26 | print 'Number of Records by File: %d'%dataOut.nRecords | |
|
27 | print 'Number of Pulses: %d'%dataOut.nProfiles | |
|
28 | print 'Number of Pulses by Frame: %d'%dataOut.npulseByFrame | |
|
29 | print 'Number of Samples by Pulse: %d'%len(dataOut.heightList) | |
|
30 | print 'Ipp Seconds: %f'%dataOut.ippSeconds | |
|
31 | print 'Number of Beams: %d'%dataOut.nBeams | |
|
32 | print 'BeamCodes:' | |
|
33 | beamStrList = ['Beam %d -> Code %d'%(k,v) for k,v in dataOut.beamCodeDict.items()] | |
|
34 | for b in beamStrList: | |
|
35 | print b | |
|
36 | self.__isPrinted = True | |
|
37 | ||
|
38 | return | |
|
34 | 39 | |
|
35 | 40 | |
|
36 | 41 | class BeamSelector(Operation): |
|
37 | 42 | profileIndex = None |
|
38 | 43 | nProfiles = None |
|
39 | 44 | |
|
40 | 45 | def __init__(self): |
|
41 | 46 | |
|
42 | 47 | self.profileIndex = 0 |
|
43 | 48 | |
|
44 | 49 | def incIndex(self): |
|
45 | 50 | self.profileIndex += 1 |
|
46 | 51 | |
|
47 | 52 | if self.profileIndex >= self.nProfiles: |
|
48 | 53 | self.profileIndex = 0 |
|
49 | 54 | |
|
50 | 55 | def isProfileInRange(self, minIndex, maxIndex): |
|
51 | 56 | |
|
52 | 57 | if self.profileIndex < minIndex: |
|
53 | 58 | return False |
|
54 | 59 | |
|
55 | 60 | if self.profileIndex > maxIndex: |
|
56 | 61 | return False |
|
57 | 62 | |
|
58 | 63 | return True |
|
59 | 64 | |
|
60 | 65 | def isProfileInList(self, profileList): |
|
61 | 66 | |
|
62 | 67 | if self.profileIndex not in profileList: |
|
63 | 68 | return False |
|
64 | 69 | |
|
65 | 70 | return True |
|
66 | 71 | |
|
67 | 72 | def run(self, dataOut, beam=None): |
|
68 | 73 | |
|
69 | 74 | dataOut.flagNoData = True |
|
70 | 75 | self.nProfiles = dataOut.nProfiles |
|
71 | 76 | |
|
72 | 77 | if beam != None: |
|
73 | 78 | if self.isProfileInList(dataOut.beamRangeDict[beam]): |
|
74 | 79 | dataOut.flagNoData = False |
|
75 | 80 | |
|
76 | 81 | self.incIndex() |
|
77 | 82 | return 1 |
|
78 | 83 | |
|
79 | 84 | else: |
|
80 | 85 | raise ValueError, "BeamSelector needs beam value" |
|
81 | 86 | |
|
82 | 87 | return 0 No newline at end of file |
@@ -1,79 +1,83 | |||
|
1 | 1 | import os, sys |
|
2 | 2 | |
|
3 | 3 | path = os.path.split(os.getcwd())[0] |
|
4 | 4 | sys.path.append(path) |
|
5 | 5 | |
|
6 | 6 | from controller import * |
|
7 | 7 | |
|
8 | 8 | desc = "AMISR Experiment" |
|
9 | 9 | |
|
10 | 10 | filename = "amisr_reader.xml" |
|
11 | 11 | |
|
12 | 12 | controllerObj = Project() |
|
13 | 13 | |
|
14 | 14 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
15 | 15 | |
|
16 | path = os.path.join(os.environ['HOME'],'Documents/amisr') | |
|
17 | 16 | |
|
17 | path = os.path.join(os.environ['HOME'],'Development/amisr/data') | |
|
18 | #path = os.path.join(os.environ['HOME'],'Documents/amisr') | |
|
18 | 19 | figpath = os.path.join(os.environ['HOME'],'Pictures/amisr') |
|
19 | 20 | |
|
20 | 21 | readUnitConfObj = controllerObj.addReadUnit(datatype='AMISRReader', |
|
21 | 22 | path=path, |
|
22 |
startDate='2014/0 |
|
|
23 |
endDate='2014/ |
|
|
23 | startDate='2014/01/06', | |
|
24 | endDate='2014/12/06', | |
|
24 | 25 | startTime='00:00:00', |
|
25 | 26 | endTime='23:59:59', |
|
26 |
walk=1 |
|
|
27 | walk=1, | |
|
28 | timezone='lt') | |
|
27 | 29 | |
|
28 | 30 | #AMISR Processing Unit |
|
29 | 31 | procUnitAMISRBeam0 = controllerObj.addProcUnit(datatype='AMISRProc', inputId=readUnitConfObj.getId()) |
|
30 | 32 | |
|
33 | opObj11 = procUnitAMISRBeam0.addOperation(name='PrintInfo', optype='other') | |
|
34 | ||
|
31 | 35 | #Beam Selector |
|
32 | 36 | opObj11 = procUnitAMISRBeam0.addOperation(name='BeamSelector', optype='other') |
|
33 | 37 | opObj11.addParameter(name='beam', value='0', format='int') |
|
34 | 38 | |
|
35 | 39 | #Voltage Processing Unit |
|
36 | 40 | procUnitConfObjBeam0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=procUnitAMISRBeam0.getId()) |
|
37 | 41 | #Coherent Integration |
|
38 | 42 | opObj11 = procUnitConfObjBeam0.addOperation(name='CohInt', optype='other') |
|
39 | 43 | opObj11.addParameter(name='n', value='128', format='int') |
|
40 | 44 | #Spectra Unit Processing, getting spectras with nProfiles and nFFTPoints |
|
41 | 45 | procUnitConfObjSpectraBeam0 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjBeam0.getId()) |
|
42 | 46 | procUnitConfObjSpectraBeam0.addParameter(name='nFFTPoints', value=32, format='int') |
|
43 | 47 | procUnitConfObjSpectraBeam0.addParameter(name='nProfiles', value=32, format='int') |
|
44 | 48 | #Noise Estimation |
|
45 | 49 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='getNoise') |
|
46 | 50 | opObj11.addParameter(name='minHei', value='100', format='float') |
|
47 |
opObj11.addParameter(name='maxHei', value=' |
|
|
51 | opObj11.addParameter(name='maxHei', value='300', format='float') | |
|
48 | 52 | |
|
49 | 53 | #SpectraPlot |
|
50 | 54 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='SpectraPlot', optype='other') |
|
51 | 55 | opObj11.addParameter(name='id', value='100', format='int') |
|
52 | 56 | opObj11.addParameter(name='wintitle', value='AMISR Beam 0', format='str') |
|
53 | 57 | |
|
54 | 58 | #RTIPlot |
|
55 | 59 | title0 = 'RTI AMISR Beam 0' |
|
56 | 60 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='RTIPlot', optype='other') |
|
57 | 61 | opObj11.addParameter(name='id', value='200', format='int') |
|
58 | 62 | opObj11.addParameter(name='wintitle', value=title0, format='str') |
|
59 | 63 | opObj11.addParameter(name='showprofile', value='0', format='int') |
|
60 | 64 | #Setting RTI time using xmin,xmax |
|
61 |
opObj11.addParameter(name='xmin', value=' |
|
|
62 |
opObj11.addParameter(name='xmax', value=' |
|
|
65 | opObj11.addParameter(name='xmin', value='15', format='int') | |
|
66 | opObj11.addParameter(name='xmax', value='23', format='int') | |
|
63 | 67 | #Setting dB range with zmin, zmax |
|
64 | opObj11.addParameter(name='zmin', value='45', format='int') | |
|
65 | opObj11.addParameter(name='zmax', value='70', format='int') | |
|
68 | #opObj11.addParameter(name='zmin', value='45', format='int') | |
|
69 | #opObj11.addParameter(name='zmax', value='70', format='int') | |
|
66 | 70 | #Save RTI |
|
67 | figfile0 = 'amisr_rti_beam0.png' | |
|
68 | opObj11.addParameter(name='figpath', value=figpath, format='str') | |
|
71 | #figfile0 = 'amisr_rti_beam0.png' | |
|
72 | #opObj11.addParameter(name='figpath', value=figpath, format='str') | |
|
69 | 73 | #opObj11.addParameter(name='figfile', value=figfile0, format='str') |
|
70 | 74 | |
|
71 | 75 | |
|
72 | 76 | print "Escribiendo el archivo XML" |
|
73 | 77 | controllerObj.writeXml(filename) |
|
74 | 78 | print "Leyendo el archivo XML" |
|
75 | 79 | controllerObj.readXml(filename) |
|
76 | 80 | |
|
77 | 81 | controllerObj.createObjects() |
|
78 | 82 | controllerObj.connectObjects() |
|
79 | 83 | controllerObj.run() |
General Comments 0
You need to be logged in to leave comments.
Login now