This diff has been collapsed as it changes many lines, (801 lines changed) Show them Hide them | |||||
@@ -0,0 +1,801 | |||||
|
1 | ''' | |||
|
2 | Created on 23/01/2012 | |||
|
3 | ||||
|
4 | @author $Author$ | |||
|
5 | @version $Id$ | |||
|
6 | ''' | |||
|
7 | ||||
|
8 | import os, sys | |||
|
9 | import numpy | |||
|
10 | import glob | |||
|
11 | import fnmatch | |||
|
12 | import time, datetime | |||
|
13 | ||||
|
14 | path = os.path.split(os.getcwd())[0] | |||
|
15 | sys.path.append(path) | |||
|
16 | ||||
|
17 | from IO.HeaderIO import * | |||
|
18 | from IO.DataIO import DataReader | |||
|
19 | from IO.DataIO import DataWriter | |||
|
20 | ||||
|
21 | from Model.Voltage import Voltage | |||
|
22 | ||||
|
23 | def isThisFileinRange(filename, startUTSeconds, endUTSeconds): | |||
|
24 | """ | |||
|
25 | Esta funcion determina si un archivo de datos en formato Jicamarca(.r) se encuentra | |||
|
26 | o no dentro del rango de fecha especificado. | |||
|
27 | ||||
|
28 | Inputs: | |||
|
29 | filename : nombre completo del archivo de datos en formato Jicamarca (.r) | |||
|
30 | ||||
|
31 | startUTSeconds : fecha inicial del rango seleccionado. La fecha esta dada en | |||
|
32 | segundos contados desde 01/01/1970. | |||
|
33 | endUTSeconds : fecha final del rango seleccionado. La fecha esta dada en | |||
|
34 | segundos contados desde 01/01/1970. | |||
|
35 | ||||
|
36 | Return: | |||
|
37 | Boolean : Retorna True si el archivo de datos contiene datos en el rango de | |||
|
38 | fecha especificado, de lo contrario retorna False. | |||
|
39 | ||||
|
40 | Excepciones: | |||
|
41 | Si el archivo no existe o no puede ser abierto | |||
|
42 | Si la cabecera no puede ser leida. | |||
|
43 | ||||
|
44 | """ | |||
|
45 | m_BasicHeader = BasicHeader() | |||
|
46 | ||||
|
47 | try: | |||
|
48 | fp = open(filename,'rb') | |||
|
49 | except: | |||
|
50 | raise IOError, "The file %s can't be opened" %(filename) | |||
|
51 | ||||
|
52 | if not(m_BasicHeader.read(fp)): | |||
|
53 | raise IOError, "The file %s has not a valid header" %(filename) | |||
|
54 | ||||
|
55 | fp.close() | |||
|
56 | ||||
|
57 | if not ((startUTSeconds <= m_BasicHeader.utc) and (endUTSeconds >= m_BasicHeader.utc)): | |||
|
58 | return 0 | |||
|
59 | ||||
|
60 | return 1 | |||
|
61 | ||||
|
62 | class VoltageReader(DataReader): | |||
|
63 | """ | |||
|
64 | Esta clase permite leer datos de voltage desde archivos en formato rawdata (.r). La lectura | |||
|
65 | de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones: | |||
|
66 | perfiles*alturas*canales) son almacenados en la variable "buffer". | |||
|
67 | ||||
|
68 | Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader, | |||
|
69 | RadarControllerHeader y Voltage. Los tres primeros se usan para almacenar informacion de la | |||
|
70 | cabecera de datos (metadata), y el cuarto (Voltage) para obtener y almacenar un perfil de | |||
|
71 | datos desde el "buffer" cada vez que se ejecute el metodo "getData". | |||
|
72 | ||||
|
73 | Example: | |||
|
74 | ||||
|
75 | dpath = "/home/myuser/data" | |||
|
76 | ||||
|
77 | startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0) | |||
|
78 | ||||
|
79 | endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0) | |||
|
80 | ||||
|
81 | readerObj = VoltageReader() | |||
|
82 | ||||
|
83 | readerObj.setup(dpath, startTime, endTime) | |||
|
84 | ||||
|
85 | while(True): | |||
|
86 | ||||
|
87 | readerObj.getData() | |||
|
88 | ||||
|
89 | print readerObj.m_Voltage.data | |||
|
90 | ||||
|
91 | if readerObj.noMoreFiles: | |||
|
92 | break | |||
|
93 | ||||
|
94 | """ | |||
|
95 | ||||
|
96 | #speed of light | |||
|
97 | __c = 3E8 | |||
|
98 | ||||
|
99 | def __init__(self, m_Voltage = None): | |||
|
100 | """ | |||
|
101 | Inicializador de la clase VoltageReader para la lectura de datos de voltage. | |||
|
102 | ||||
|
103 | Input: | |||
|
104 | m_Voltage : Objeto de la clase Voltage. Este objeto sera utilizado para | |||
|
105 | almacenar un perfil de datos cada vez que se haga un requerimiento | |||
|
106 | (getData). El perfil sera obtenido a partir del buffer de datos, | |||
|
107 | si el buffer esta vacio se hara un nuevo proceso de lectura de un | |||
|
108 | bloque de datos. | |||
|
109 | Si este parametro no es pasado se creara uno internamente. | |||
|
110 | ||||
|
111 | Variables afectadas: | |||
|
112 | self.m_Voltage | |||
|
113 | self.m_BasicHeader | |||
|
114 | self.m_SystemHeader | |||
|
115 | self.m_RadarControllerHeader | |||
|
116 | self.m_ProcessingHeader | |||
|
117 | ||||
|
118 | ||||
|
119 | Return: | |||
|
120 | Void | |||
|
121 | ||||
|
122 | """ | |||
|
123 | if m_Voltage == None: | |||
|
124 | m_Voltage = Voltage() | |||
|
125 | ||||
|
126 | if not(isinstance(m_Voltage, Voltage)): | |||
|
127 | raise ValueError, "in VoltageReader, m_Voltage must be an Voltage class object" | |||
|
128 | ||||
|
129 | self.m_Voltage = m_Voltage | |||
|
130 | ||||
|
131 | self.m_BasicHeader = BasicHeader() | |||
|
132 | ||||
|
133 | self.m_SystemHeader = SystemHeader() | |||
|
134 | ||||
|
135 | self.m_RadarControllerHeader = RadarControllerHeader() | |||
|
136 | ||||
|
137 | self.m_ProcessingHeader = ProcessingHeader() | |||
|
138 | ||||
|
139 | self.__fp = None | |||
|
140 | ||||
|
141 | self.__idFile = None | |||
|
142 | ||||
|
143 | self.__startDateTime = None | |||
|
144 | ||||
|
145 | self.__endDateTime = None | |||
|
146 | ||||
|
147 | self.__dataType = None | |||
|
148 | ||||
|
149 | self.__fileSizeByHeader = 0 | |||
|
150 | ||||
|
151 | self.__pathList = [] | |||
|
152 | ||||
|
153 | self.filenameList = [] | |||
|
154 | ||||
|
155 | self.__lastUTTime = 0 | |||
|
156 | ||||
|
157 | self.__maxTimeStep = 30 | |||
|
158 | ||||
|
159 | self.__flagIsNewFile = 0 | |||
|
160 | ||||
|
161 | self.__ippSeconds = 0 | |||
|
162 | ||||
|
163 | self.flagResetProcessing = 0 | |||
|
164 | ||||
|
165 | self.flagIsNewBlock = 0 | |||
|
166 | ||||
|
167 | self.noMoreFiles = 0 | |||
|
168 | ||||
|
169 | self.nReadBlocks = 0 | |||
|
170 | ||||
|
171 | self.online = 0 | |||
|
172 | ||||
|
173 | self.filename = None | |||
|
174 | ||||
|
175 | self.fileSize = None | |||
|
176 | ||||
|
177 | self.firstHeaderSize = 0 | |||
|
178 | ||||
|
179 | self.basicHeaderSize = 24 | |||
|
180 | ||||
|
181 | self.idProfile = 0 | |||
|
182 | ||||
|
183 | self.__buffer = 0 | |||
|
184 | ||||
|
185 | self.__buffer_id = 9999 | |||
|
186 | ||||
|
187 | def __rdSystemHeader(self,fp=None): | |||
|
188 | if fp == None: | |||
|
189 | fp = self.__fp | |||
|
190 | ||||
|
191 | self.m_SystemHeader.read(fp) | |||
|
192 | ||||
|
193 | def __rdRadarControllerHeader(self,fp=None): | |||
|
194 | if fp == None: | |||
|
195 | fp = self.__fp | |||
|
196 | ||||
|
197 | self.m_RadarControllerHeader.read(fp) | |||
|
198 | ||||
|
199 | def __rdProcessingHeader(self,fp=None): | |||
|
200 | if fp == None: | |||
|
201 | fp = self.__fp | |||
|
202 | ||||
|
203 | self.m_ProcessingHeader.read(fp) | |||
|
204 | ||||
|
205 | def __rdBasicHeader(self, fp=None): | |||
|
206 | ||||
|
207 | if fp == None: | |||
|
208 | fp = self.__fp | |||
|
209 | ||||
|
210 | self.m_BasicHeader.read(fp) | |||
|
211 | ||||
|
212 | def __readFirstHeader(self): | |||
|
213 | ||||
|
214 | self.__rdBasicHeader() | |||
|
215 | self.__rdSystemHeader() | |||
|
216 | self.__rdRadarControllerHeader() | |||
|
217 | self.__rdProcessingHeader() | |||
|
218 | self.firstHeaderSize = self.m_BasicHeader.size | |||
|
219 | ||||
|
220 | data_type=int(numpy.log2((self.m_ProcessingHeader.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR)) | |||
|
221 | if data_type == 0: | |||
|
222 | tmp = numpy.dtype([('real','<i1'),('imag','<i1')]) | |||
|
223 | ||||
|
224 | elif data_type == 1: | |||
|
225 | tmp = numpy.dtype([('real','<i2'),('imag','<i2')]) | |||
|
226 | ||||
|
227 | elif data_type == 2: | |||
|
228 | tmp = numpy.dtype([('real','<i4'),('imag','<i4')]) | |||
|
229 | ||||
|
230 | elif data_type == 3: | |||
|
231 | tmp = numpy.dtype([('real','<i8'),('imag','<i8')]) | |||
|
232 | ||||
|
233 | elif data_type == 4: | |||
|
234 | tmp = numpy.dtype([('real','<f4'),('imag','<f4')]) | |||
|
235 | ||||
|
236 | elif data_type == 5: | |||
|
237 | tmp = numpy.dtype([('real','<f8'),('imag','<f8')]) | |||
|
238 | ||||
|
239 | else: | |||
|
240 | raise ValueError, 'Data type was not defined' | |||
|
241 | ||||
|
242 | xi = self.m_ProcessingHeader.firstHeight | |||
|
243 | step = self.m_ProcessingHeader.deltaHeight | |||
|
244 | xf = xi + self.m_ProcessingHeader.numHeights*step | |||
|
245 | ||||
|
246 | self.__heights = numpy.arange(xi, xf, step) | |||
|
247 | self.__dataType = tmp | |||
|
248 | self.__fileSizeByHeader = self.m_ProcessingHeader.dataBlocksPerFile * self.m_ProcessingHeader.blockSize + self.firstHeaderSize + self.basicHeaderSize*(self.m_ProcessingHeader.dataBlocksPerFile - 1) | |||
|
249 | self.__ippSeconds = 2*1000*self.m_RadarControllerHeader.ipp/self.__c | |||
|
250 | ||||
|
251 | def __setNextFileOnline(self): | |||
|
252 | return 0 | |||
|
253 | ||||
|
254 | def __setNextFileOffline(self): | |||
|
255 | ||||
|
256 | idFile = self.__idFile | |||
|
257 | while(True): | |||
|
258 | ||||
|
259 | idFile += 1 | |||
|
260 | ||||
|
261 | if not(idFile < len(self.filenameList)): | |||
|
262 | self.noMoreFiles = 1 | |||
|
263 | return 0 | |||
|
264 | ||||
|
265 | filename = self.filenameList[idFile] | |||
|
266 | fileSize = os.path.getsize(filename) | |||
|
267 | ||||
|
268 | try: | |||
|
269 | fp = open(filename,'rb') | |||
|
270 | except: | |||
|
271 | raise IOError, "The file %s can't be opened" %filename | |||
|
272 | ||||
|
273 | currentSize = fileSize - fp.tell() | |||
|
274 | neededSize = self.m_ProcessingHeader.blockSize + self.firstHeaderSize | |||
|
275 | ||||
|
276 | if (currentSize < neededSize): | |||
|
277 | print "Skipping the file %s due to it hasn't enough data" %filename | |||
|
278 | continue | |||
|
279 | ||||
|
280 | break | |||
|
281 | ||||
|
282 | self.__flagIsNewFile = 1 | |||
|
283 | self.__idFile = idFile | |||
|
284 | self.filename = filename | |||
|
285 | self.fileSize = fileSize | |||
|
286 | self.__fp = fp | |||
|
287 | ||||
|
288 | print 'Setting the file: %s'%self.filename | |||
|
289 | ||||
|
290 | return 1 | |||
|
291 | ||||
|
292 | def __setNextFile(self): | |||
|
293 | ||||
|
294 | if self.online: | |||
|
295 | newFile = self.__setNextFileOnline() | |||
|
296 | else: | |||
|
297 | newFile = self.__setNextFileOffline() | |||
|
298 | ||||
|
299 | if not(newFile): | |||
|
300 | return 0 | |||
|
301 | ||||
|
302 | self.__readFirstHeader() | |||
|
303 | ||||
|
304 | return 1 | |||
|
305 | ||||
|
306 | def __setNewBlock(self): | |||
|
307 | ||||
|
308 | if self.__fp == None: | |||
|
309 | return 0 | |||
|
310 | ||||
|
311 | if self.__flagIsNewFile: | |||
|
312 | return 1 | |||
|
313 | ||||
|
314 | currentSize = self.fileSize - self.__fp.tell() | |||
|
315 | neededSize = self.m_ProcessingHeader.blockSize + self.basicHeaderSize | |||
|
316 | ||||
|
317 | #If there is enough data setting new data block | |||
|
318 | if (currentSize >= neededSize): | |||
|
319 | self.__rdBasicHeader() | |||
|
320 | return 1 | |||
|
321 | ||||
|
322 | #Setting new file | |||
|
323 | if not(self.__setNextFile()): | |||
|
324 | return 0 | |||
|
325 | ||||
|
326 | deltaTime = self.m_BasicHeader.utc - self.__lastUTTime # check this | |||
|
327 | ||||
|
328 | self.flagResetProcessing = 0 | |||
|
329 | ||||
|
330 | if deltaTime > self.__maxTimeStep: | |||
|
331 | self.flagResetProcessing = 1 | |||
|
332 | self.nReadBlocks = 0 | |||
|
333 | ||||
|
334 | return 1 | |||
|
335 | ||||
|
336 | def __readBlock(self): | |||
|
337 | """ | |||
|
338 | __readBlock lee el bloque de datos desde la posicion actual del puntero del archivo | |||
|
339 | (self.__fp) y actualiza todos los parametros relacionados al bloque de datos | |||
|
340 | (metadata + data). La data leida es almacenada en el buffer y el contador del buffer | |||
|
341 | es seteado a 0 | |||
|
342 | ||||
|
343 | ||||
|
344 | Inputs: | |||
|
345 | None | |||
|
346 | ||||
|
347 | Return: | |||
|
348 | None | |||
|
349 | ||||
|
350 | Variables afectadas: | |||
|
351 | ||||
|
352 | self.__buffer_id | |||
|
353 | ||||
|
354 | self.__buffer | |||
|
355 | ||||
|
356 | self.__flagIsNewFile | |||
|
357 | ||||
|
358 | self.idProfile | |||
|
359 | ||||
|
360 | self.flagIsNewBlock | |||
|
361 | ||||
|
362 | self.nReadBlocks | |||
|
363 | ||||
|
364 | """ | |||
|
365 | ||||
|
366 | pts2read = self.m_ProcessingHeader.profilesPerBlock*self.m_ProcessingHeader.numHeights*self.m_SystemHeader.numChannels | |||
|
367 | ||||
|
368 | junk = numpy.fromfile(self.__fp, self.__dataType, pts2read) | |||
|
369 | ||||
|
370 | junk = junk.reshape((self.m_ProcessingHeader.profilesPerBlock, self.m_ProcessingHeader.numHeights, self.m_SystemHeader.numChannels)) | |||
|
371 | ||||
|
372 | data = junk['real'] + junk['imag']*1j | |||
|
373 | ||||
|
374 | self.__buffer_id = 0 | |||
|
375 | ||||
|
376 | self.__buffer = data | |||
|
377 | ||||
|
378 | self.__flagIsNewFile = 0 | |||
|
379 | ||||
|
380 | self.idProfile = 0 | |||
|
381 | ||||
|
382 | self.flagIsNewBlock = 1 | |||
|
383 | ||||
|
384 | self.nReadBlocks += 1 | |||
|
385 | ||||
|
386 | def __hasNotDataInBuffer(self): | |||
|
387 | if self.__buffer_id >= self.m_ProcessingHeader.profilesPerBlock: | |||
|
388 | return 1 | |||
|
389 | ||||
|
390 | return 0 | |||
|
391 | ||||
|
392 | def __searchFiles(self, path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r"): | |||
|
393 | """ | |||
|
394 | __searchFiles realiza una busqueda de los archivos que coincidan con los parametros | |||
|
395 | especificados y se encuentren ubicados en el path indicado. Para realizar una busqueda | |||
|
396 | correcta la estructura de directorios debe ser la siguiente: | |||
|
397 | ||||
|
398 | ...path/D[yyyy][ddd]/expLabel/D[yyyy][ddd][sss].ext | |||
|
399 | ||||
|
400 | [yyyy]: anio | |||
|
401 | [ddd] : dia del anio | |||
|
402 | [sss] : set del archivo | |||
|
403 | ||||
|
404 | Inputs: | |||
|
405 | path : Directorio de datos donde se realizara la busqueda. Todos los | |||
|
406 | ficheros que concidan con el criterio de busqueda seran | |||
|
407 | almacenados en una lista y luego retornados. | |||
|
408 | startDateTime : Fecha inicial. Rechaza todos los archivos donde | |||
|
409 | file end time < startDateTime (obejto datetime.datetime) | |||
|
410 | ||||
|
411 | endDateTime : Fecha final. Rechaza todos los archivos donde | |||
|
412 | file start time > endDateTime (obejto datetime.datetime) | |||
|
413 | ||||
|
414 | set : Set del primer archivo a leer. Por defecto None | |||
|
415 | ||||
|
416 | expLabel : Nombre del subdirectorio de datos. Por defecto "" | |||
|
417 | ||||
|
418 | ext : Extension de los archivos a leer. Por defecto .r | |||
|
419 | ||||
|
420 | Return: | |||
|
421 | ||||
|
422 | (pathList, filenameList) | |||
|
423 | ||||
|
424 | pathList : Lista de directorios donde se encontraron archivos dentro | |||
|
425 | de los parametros especificados | |||
|
426 | filenameList : Lista de archivos (ruta completa) que coincidieron con los | |||
|
427 | parametros especificados. | |||
|
428 | ||||
|
429 | Variables afectadas: | |||
|
430 | ||||
|
431 | self.filenameList: Lista de archivos (ruta completa) que la clase utiliza | |||
|
432 | como fuente para leer los bloque de datos, si se termina | |||
|
433 | de leer todos los bloques de datos de un determinado | |||
|
434 | archivo se pasa al siguiente archivo de la lista. | |||
|
435 | ||||
|
436 | Excepciones: | |||
|
437 | ||||
|
438 | """ | |||
|
439 | ||||
|
440 | print "Searching files ..." | |||
|
441 | ||||
|
442 | dirList = [] | |||
|
443 | for thisPath in os.listdir(path): | |||
|
444 | if os.path.isdir(os.path.join(path,thisPath)): | |||
|
445 | dirList.append(thisPath) | |||
|
446 | ||||
|
447 | pathList = [] | |||
|
448 | ||||
|
449 | thisDateTime = startDateTime | |||
|
450 | ||||
|
451 | while(thisDateTime <= endDateTime): | |||
|
452 | year = thisDateTime.timetuple().tm_year | |||
|
453 | doy = thisDateTime.timetuple().tm_yday | |||
|
454 | ||||
|
455 | match = fnmatch.filter(dirList, '?' + '%4.4d%3.3d' % (year,doy)) | |||
|
456 | if len(match) == 0: | |||
|
457 | thisDateTime += datetime.timedelta(1) | |||
|
458 | continue | |||
|
459 | ||||
|
460 | pathList.append(os.path.join(path,match[0],expLabel)) | |||
|
461 | thisDateTime += datetime.timedelta(1) | |||
|
462 | ||||
|
463 | startUtSeconds = time.mktime(startDateTime.timetuple()) | |||
|
464 | endUtSeconds = time.mktime(endDateTime.timetuple()) | |||
|
465 | ||||
|
466 | filenameList = [] | |||
|
467 | for thisPath in pathList: | |||
|
468 | fileList = glob.glob1(thisPath, "*%s" %ext) | |||
|
469 | fileList.sort() | |||
|
470 | for file in fileList: | |||
|
471 | filename = os.path.join(thisPath,file) | |||
|
472 | if isThisFileinRange(filename, startUtSeconds, endUtSeconds): | |||
|
473 | filenameList.append(filename) | |||
|
474 | ||||
|
475 | self.filenameList = filenameList | |||
|
476 | ||||
|
477 | return pathList, filenameList | |||
|
478 | ||||
|
479 | def setup(self, path, startDateTime, endDateTime=None, set=None, expLabel = "", ext = ".r", online = 0): | |||
|
480 | """ | |||
|
481 | setup configura los parametros de lectura de la clase VoltageReader. | |||
|
482 | ||||
|
483 | Si el modo de lectura es offline, primero se realiza una busqueda de todos los archivos | |||
|
484 | que coincidan con los parametros especificados; esta lista de archivos son almacenados en | |||
|
485 | self.filenameList. | |||
|
486 | ||||
|
487 | Input: | |||
|
488 | path : Directorios donde se ubican los datos a leer. Dentro de este | |||
|
489 | directorio deberia de estar subdirectorios de la forma: | |||
|
490 | ||||
|
491 | path/D[yyyy][ddd]/expLabel/P[yyyy][ddd][sss][ext] | |||
|
492 | ||||
|
493 | startDateTime : Fecha inicial. Rechaza todos los archivos donde | |||
|
494 | file end time < startDatetime (obejto datetime.datetime) | |||
|
495 | ||||
|
496 | endDateTime : Fecha final. Si no es None, rechaza todos los archivos donde | |||
|
497 | file end time < startDatetime (obejto datetime.datetime) | |||
|
498 | ||||
|
499 | set : Set del primer archivo a leer. Por defecto None | |||
|
500 | ||||
|
501 | expLabel : Nombre del subdirectorio de datos. Por defecto "" | |||
|
502 | ||||
|
503 | ext : Extension de los archivos a leer. Por defecto .r | |||
|
504 | ||||
|
505 | online : | |||
|
506 | ||||
|
507 | Return: | |||
|
508 | ||||
|
509 | Affected: | |||
|
510 | ||||
|
511 | Excepciones: | |||
|
512 | ||||
|
513 | Example: | |||
|
514 | ||||
|
515 | """ | |||
|
516 | ||||
|
517 | if online == 0: | |||
|
518 | pathList, filenameList = self.__searchFiles(path, startDateTime, endDateTime, set, expLabel, ext) | |||
|
519 | ||||
|
520 | self.__idFile = -1 | |||
|
521 | ||||
|
522 | if not(self.__setNextFile()): | |||
|
523 | print "No files in range: %s - %s" %(startDateTime.ctime(), endDateTime.ctime()) | |||
|
524 | return 0 | |||
|
525 | ||||
|
526 | self.startUTCSeconds = time.mktime(startDateTime.timetuple()) | |||
|
527 | self.endUTCSeconds = time.mktime(endDateTime.timetuple()) | |||
|
528 | ||||
|
529 | self.startYear = startDateTime.timetuple().tm_year | |||
|
530 | self.endYear = endDateTime.timetuple().tm_year | |||
|
531 | ||||
|
532 | self.startDoy = startDateTime.timetuple().tm_yday | |||
|
533 | self.endDoy = endDateTime.timetuple().tm_yday | |||
|
534 | #call fillHeaderValues() - to Data Object | |||
|
535 | ||||
|
536 | self.__pathList = pathList | |||
|
537 | self.filenameList = filenameList | |||
|
538 | self.online = online | |||
|
539 | ||||
|
540 | def readNextBlock(self): | |||
|
541 | """ | |||
|
542 | readNextBlock establece un nuevo bloque de datos a leer y los lee, si es que no existiese | |||
|
543 | mas bloques disponibles en el archivo actual salta al siguiente. | |||
|
544 | ||||
|
545 | """ | |||
|
546 | ||||
|
547 | if not(self.__setNewBlock()): | |||
|
548 | return 0 | |||
|
549 | ||||
|
550 | self.__readBlock() | |||
|
551 | ||||
|
552 | self.__lastUTTime = self.m_BasicHeader.utc | |||
|
553 | ||||
|
554 | return 1 | |||
|
555 | ||||
|
556 | def getData(self): | |||
|
557 | """ | |||
|
558 | getData obtiene una unidad de datos del buffer de lectura y la copia a la clase "Voltage" | |||
|
559 | con todos los parametros asociados a este (metadata). cuando no hay datos en el buffer de | |||
|
560 | lectura es necesario hacer una nueva lectura de los bloques de datos usando "readNextBlock" | |||
|
561 | ||||
|
562 | Ademas incrementa el contador del buffer en 1. | |||
|
563 | ||||
|
564 | Inputs: | |||
|
565 | None | |||
|
566 | ||||
|
567 | Return: | |||
|
568 | data : retorna un perfil de voltages (alturas * canales) copiados desde el | |||
|
569 | buffer. Si no hay mas archivos a leer retorna None. | |||
|
570 | ||||
|
571 | Variables afectadas: | |||
|
572 | self.m_Voltage | |||
|
573 | self.__buffer_id | |||
|
574 | self.idProfile | |||
|
575 | ||||
|
576 | Excepciones: | |||
|
577 | ||||
|
578 | """ | |||
|
579 | self.flagResetProcessing = 0 | |||
|
580 | self.flagIsNewBlock = 0 | |||
|
581 | ||||
|
582 | if self.__hasNotDataInBuffer(): | |||
|
583 | self.readNextBlock() | |||
|
584 | ||||
|
585 | if self.noMoreFiles == 1: | |||
|
586 | print 'Process finished' | |||
|
587 | return None | |||
|
588 | ||||
|
589 | #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) | |||
|
590 | data = self.__buffer[self.__buffer_id,:,:] | |||
|
591 | ||||
|
592 | time = self.m_BasicHeader.utc + self.__buffer_id*self.__ippSeconds | |||
|
593 | ||||
|
594 | self.m_Voltage.m_BasicHeader = self.m_BasicHeader.copy() | |||
|
595 | self.m_Voltage.m_ProcessingHeader = self.m_ProcessingHeader.copy() | |||
|
596 | self.m_Voltage.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() | |||
|
597 | self.m_Voltage.m_SystemHeader = self.m_SystemHeader.copy() | |||
|
598 | self.m_Voltage.m_BasicHeader.utc = time | |||
|
599 | self.m_Voltage.data = data | |||
|
600 | self.m_Voltage.heights = self.__heights | |||
|
601 | self.m_Voltage.idProfile = self.idProfile | |||
|
602 | self.m_Voltage.dataType = self.__dataType | |||
|
603 | ||||
|
604 | self.__buffer_id += 1 | |||
|
605 | self.idProfile += 1 | |||
|
606 | ||||
|
607 | #call setData - to Data Object | |||
|
608 | ||||
|
609 | return data | |||
|
610 | ||||
|
611 | ||||
|
612 | ||||
|
613 | ||||
|
614 | class VoltageWriter(DataWriter): | |||
|
615 | ||||
|
616 | ||||
|
617 | def __init__(self, m_Voltage = None): | |||
|
618 | ||||
|
619 | if m_Voltage == None: | |||
|
620 | m_Voltage = Voltage() | |||
|
621 | ||||
|
622 | self.m_Voltage = m_Voltage | |||
|
623 | ||||
|
624 | self.__fp = None | |||
|
625 | ||||
|
626 | self.__blocksCounter = 0 | |||
|
627 | ||||
|
628 | self.__setFile = None | |||
|
629 | ||||
|
630 | self.__flagIsNewFile = 0 | |||
|
631 | ||||
|
632 | self.__buffer = 0 | |||
|
633 | ||||
|
634 | self.__buffer_id = 0 | |||
|
635 | ||||
|
636 | self.__dataType = None | |||
|
637 | ||||
|
638 | self.__ext = None | |||
|
639 | ||||
|
640 | self.nWriteBlocks = 0 | |||
|
641 | ||||
|
642 | self.flagIsNewBlock = 0 | |||
|
643 | ||||
|
644 | self.noMoreFiles = 0 | |||
|
645 | ||||
|
646 | self.filename = None | |||
|
647 | ||||
|
648 | self.m_BasicHeader= BasicHeader() | |||
|
649 | ||||
|
650 | self.m_SystemHeader = SystemHeader() | |||
|
651 | ||||
|
652 | self.m_RadarControllerHeader = RadarControllerHeader() | |||
|
653 | ||||
|
654 | self.m_ProcessingHeader = ProcessingHeader() | |||
|
655 | ||||
|
656 | def __setNextFile(self): | |||
|
657 | setFile = self.__setFile | |||
|
658 | ext = self.__ext | |||
|
659 | path = self.__path | |||
|
660 | ||||
|
661 | setFile += 1 | |||
|
662 | ||||
|
663 | if not(self.__blocksCounter >= self.m_ProcessingHeader.dataBlocksPerFile): | |||
|
664 | self.__fp.close() | |||
|
665 | return 0 | |||
|
666 | ||||
|
667 | timeTuple = time.localtime(self.m_Voltage.m_BasicHeader.utc) # utc from m_Voltage | |||
|
668 | file = 'D%4.4d%3.3d%3.3d%s' % (timeTuple.tm_year,timeTuple.tm_doy,setFile,ext) | |||
|
669 | subfolder = 'D%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_doy) | |||
|
670 | tmp = os.path.join(path,subfolder) | |||
|
671 | if not(os.path.exists(tmp)): | |||
|
672 | os.mkdir(tmp) | |||
|
673 | ||||
|
674 | filename = os.path.join(path,subfolder,file) | |||
|
675 | fp = open(filename,'wb') | |||
|
676 | ||||
|
677 | ||||
|
678 | ||||
|
679 | #guardando atributos | |||
|
680 | self.filename = filename | |||
|
681 | self.__subfolder = subfolder | |||
|
682 | self.__fp = fp | |||
|
683 | self.__setFile = setFile | |||
|
684 | self.__flagIsNewFile = 1 | |||
|
685 | ||||
|
686 | print 'Writing the file: %s'%self.filename | |||
|
687 | ||||
|
688 | return 1 | |||
|
689 | ||||
|
690 | ||||
|
691 | ||||
|
692 | def __setNewBlock(self): | |||
|
693 | if self.__fp == None: | |||
|
694 | return 0 | |||
|
695 | ||||
|
696 | if self.__flagIsNewFile: | |||
|
697 | return 1 | |||
|
698 | ||||
|
699 | #Bloques completados? | |||
|
700 | if self.__blocksCounter < self.m_ProcessingHeader.profilesPerBlock: | |||
|
701 | self.__writeBasicHeader() | |||
|
702 | return 1 | |||
|
703 | ||||
|
704 | if not(self.__setNextFile()): | |||
|
705 | return 0 | |||
|
706 | ||||
|
707 | self.__writeFirstHeader() | |||
|
708 | ||||
|
709 | return 1 | |||
|
710 | ||||
|
711 | def __writeBlock(self): | |||
|
712 | ||||
|
713 | numpy.save(self.__fp,self.__buffer) | |||
|
714 | ||||
|
715 | self.__buffer = numpy.array([],self.__dataType) | |||
|
716 | ||||
|
717 | self.__buffer_id = 0 | |||
|
718 | ||||
|
719 | self.__flagIsNewFile = 0 | |||
|
720 | ||||
|
721 | self.flagIsNewBlock = 1 | |||
|
722 | ||||
|
723 | self.nWriteBlocks += 1 | |||
|
724 | ||||
|
725 | self.__blocksCounter += 1 | |||
|
726 | ||||
|
727 | def writeNextBlock(self): | |||
|
728 | if not(self.__setNewBlock()): | |||
|
729 | return 0 | |||
|
730 | ||||
|
731 | self.__writeBlock() | |||
|
732 | ||||
|
733 | return 1 | |||
|
734 | ||||
|
735 | def __hasAllDataInBuffer(self): | |||
|
736 | if self.__buffer_id >= self.m_ProcessingHeader.profilesPerBlock: | |||
|
737 | return 1 | |||
|
738 | ||||
|
739 | return 0 | |||
|
740 | ||||
|
741 | def putData(self): | |||
|
742 | self.flagIsNewBlock = 0 | |||
|
743 | ||||
|
744 | if self.m_Voltage.noData: | |||
|
745 | return None | |||
|
746 | ||||
|
747 | shape = self.m_Voltage.data.shape | |||
|
748 | data = numpy.zeros(shape,self.__dataType) | |||
|
749 | data['real'] = self.m_Voltage.data.real | |||
|
750 | data['imag'] = self.m_Voltage.data.imag | |||
|
751 | data = data.reshape((-1)) | |||
|
752 | ||||
|
753 | self.__buffer = numpy.hstack((self.__buffer,data)) | |||
|
754 | ||||
|
755 | self.__buffer_id += 1 | |||
|
756 | ||||
|
757 | if __hasAllDataInBuffer(): | |||
|
758 | self.writeNextBlock() | |||
|
759 | ||||
|
760 | ||||
|
761 | if self.noMoreFiles: | |||
|
762 | print 'Process finished' | |||
|
763 | return None | |||
|
764 | ||||
|
765 | return 1 | |||
|
766 | ||||
|
767 | ||||
|
768 | def setup(self,path,set=None,format=None): | |||
|
769 | ||||
|
770 | if set == None: | |||
|
771 | set = -1 | |||
|
772 | else: | |||
|
773 | set -= 1 | |||
|
774 | ||||
|
775 | if format == 'hdf5': | |||
|
776 | ext = '.hdf5' | |||
|
777 | print 'call hdf5 library' | |||
|
778 | return 0 | |||
|
779 | ||||
|
780 | if format == 'rawdata': | |||
|
781 | ext = '.r' | |||
|
782 | ||||
|
783 | #call to config_headers | |||
|
784 | ||||
|
785 | self.__setFile = set | |||
|
786 | ||||
|
787 | if not(self.__setNextFile()): | |||
|
788 | print "zzzzzzzzzzzz" | |||
|
789 | return 0 | |||
|
790 | ||||
|
791 | self.__writeFirstHeader() # dentro de esta funcion se debe setear e __dataType | |||
|
792 | ||||
|
793 | self.__buffer = numpy.array([],self.__dataType) | |||
|
794 | ||||
|
795 | ||||
|
796 | ||||
|
797 | def __writeBasicHeader(self): | |||
|
798 | pass | |||
|
799 | ||||
|
800 | def __writeFirstHeader(self): | |||
|
801 | pass No newline at end of file |
@@ -0,0 +1,59 | |||||
|
1 | ''' | |||
|
2 | Created on 23/01/2012 | |||
|
3 | ||||
|
4 | @author $Author$ | |||
|
5 | @version $Id$ | |||
|
6 | ''' | |||
|
7 | import os, sys | |||
|
8 | import time, datetime | |||
|
9 | ||||
|
10 | from Model.Voltage import Voltage | |||
|
11 | from IO.VoltageIO import VoltageReader | |||
|
12 | from Graphics.VoltagePlot import Osciloscope | |||
|
13 | ||||
|
14 | class TestSChain(): | |||
|
15 | ||||
|
16 | ||||
|
17 | def __init__(self): | |||
|
18 | self.setValues() | |||
|
19 | self.createObjects() | |||
|
20 | self.testSChain() | |||
|
21 | pass | |||
|
22 | ||||
|
23 | def setValues(self): | |||
|
24 | ||||
|
25 | self.path = '/home/roj-idl71/Data/RAWDATA/DP_Faraday/' | |||
|
26 | self.path = '/home/roj-idl71/Data/RAWDATA/IMAGING' | |||
|
27 | #self.path = '/remote/puma/2004_11/DVD/' | |||
|
28 | self.startDateTime = datetime.datetime(2004,5,1,17,49,0) | |||
|
29 | self.endDateTime = datetime.datetime(2012,5,1,18,10,0) | |||
|
30 | ||||
|
31 | def createObjects(self): | |||
|
32 | ||||
|
33 | self.voltageObj = Voltage() | |||
|
34 | self.readerObj = VoltageReader(self.voltageObj) | |||
|
35 | self.plotObj = Osciloscope(self.voltageObj) | |||
|
36 | ||||
|
37 | self.readerObj.setup(self.path, self.startDateTime, self.endDateTime) | |||
|
38 | ||||
|
39 | def testSChain(self): | |||
|
40 | ||||
|
41 | while(True): | |||
|
42 | ||||
|
43 | self.readerObj.getData() | |||
|
44 | self.plotObj.plotData(idProfile = 1, type='iq', ymin = -100, ymax = 100) | |||
|
45 | ||||
|
46 | if self.readerObj.flagResetProcessing: | |||
|
47 | print 'jump' | |||
|
48 | ||||
|
49 | # if self.readerObj.flagIsNewBlock: | |||
|
50 | # print 'Block No %04d, Time: %s'%(self.readerObj.nReadBlocks, | |||
|
51 | # datetime.datetime.fromtimestamp(self.readerObj.m_BasicHeader.utc)) | |||
|
52 | ||||
|
53 | if self.readerObj.noMoreFiles: | |||
|
54 | break | |||
|
55 | ||||
|
56 | self.plotObj.end() | |||
|
57 | ||||
|
58 | if __name__ == '__main__': | |||
|
59 | TestSChain() No newline at end of file |
@@ -14,122 +14,59 class BaseGraph: | |||||
14 |
|
14 | |||
15 | """ |
|
15 | """ | |
16 |
|
16 | |||
17 | hasNotRange = True |
|
17 | ||
18 |
|
||||
19 | xrange = None |
|
|||
20 | yrange = None |
|
|||
21 | zrange = None |
|
|||
22 |
|
||||
23 | xlabel = None |
|
|||
24 | ylabel = None |
|
|||
25 | title = None |
|
|||
26 |
|
||||
27 | legends = None |
|
|||
28 |
|
||||
29 | __name = None |
|
|||
30 | __subpage = None |
|
|||
31 | __szchar = None |
|
|||
32 |
|
||||
33 | __colormap = None |
|
|||
34 | __colbox = None |
|
|||
35 | __colleg = None |
|
|||
36 |
|
||||
37 | __xpos = None |
|
|||
38 | __ypos = None |
|
|||
39 |
|
||||
40 | __xopt = None #"bcnst" |
|
|||
41 | __yopt = None #"bcnstv" |
|
|||
42 |
|
||||
43 | __xlpos = None |
|
|||
44 | __ylpos = None |
|
|||
45 |
|
||||
46 | __xrangeIsTime = False |
|
|||
47 |
|
||||
48 | #Advanced |
|
|||
49 | __xg = None |
|
|||
50 | __yg = None |
|
|||
51 |
|
18 | |||
52 | def __init__(self): |
|
19 | def __init__(self): | |
53 | """ |
|
20 | """ | |
54 |
|
21 | |||
55 | """ |
|
22 | """ | |
56 | pass |
|
23 | self.hasNotRange = True | |
57 |
|
||||
58 | def hasNotXrange(self): |
|
|||
59 |
|
24 | |||
60 |
|
|
25 | self.xrange = None | |
61 | return 1 |
|
26 | self.yrange = None | |
|
27 | self.zrange = None | |||
62 |
|
28 | |||
63 | return 0 |
|
29 | self.xlabel = None | |
64 |
|
30 | self.ylabel = None | ||
65 | def hasNotYrange(self): |
|
31 | self.title = None | |
66 |
|
32 | |||
67 |
|
|
33 | self.legends = None | |
68 | return 1 |
|
|||
69 |
|
34 | |||
70 | return 0 |
|
35 | self.__name = None | |
71 |
|
36 | |||
72 | def hasNotZrange(self): |
|
37 | self.__colormap = None | |
|
38 | self.__colbox = None | |||
|
39 | self.__colleg = None | |||
|
40 | ||||
|
41 | self.__xpos = None | |||
|
42 | self.__ypos = None | |||
73 |
|
43 | |||
74 |
|
|
44 | self.__xopt = None #"bcnst" | |
75 | return 1 |
|
45 | self.__yopt = None #"bcnstv" | |
|
46 | ||||
|
47 | self.__xlpos = None | |||
|
48 | self.__ylpos = None | |||
|
49 | ||||
|
50 | self.__xrangeIsTime = False | |||
|
51 | ||||
|
52 | #Advanced | |||
|
53 | self.__xg = None | |||
|
54 | self.__yg = None | |||
76 |
|
55 | |||
77 | return 0 |
|
|||
78 | def setName(self, name): |
|
56 | def setName(self, name): | |
79 | self.__name = name |
|
57 | self.__name = name | |
80 |
|
58 | |||
81 | def setScreenPos(self, xpos, ypos): |
|
59 | def setScreenPos(self, xpos, ypos): | |
82 | self.__xpos = xpos |
|
60 | self.__xpos = xpos | |
83 | self.__ypos = ypos |
|
61 | self.__ypos = ypos | |
84 |
|
||||
85 | def setScreenPosbyWidth(self, xoff, yoff, xw, yw): |
|
|||
86 | self.__xpos = [xoff, xoff + xw] |
|
|||
87 | self.__ypos = [yoff, yoff + yw] |
|
|||
88 |
|
||||
89 | def setSubpage(self, subpage): |
|
|||
90 | self.__subpage = subpage |
|
|||
91 |
|
||||
92 | def setSzchar(self, szchar): |
|
|||
93 | self.__szchar = szchar |
|
|||
94 |
|
62 | |||
95 | def setOpt(self, xopt, yopt): |
|
63 | def setOpt(self, xopt, yopt): | |
96 | self.__xopt = xopt |
|
64 | self.__xopt = xopt | |
97 | self.__yopt = yopt |
|
65 | self.__yopt = yopt | |
98 |
|
||||
99 | def setRanges(self, xrange, yrange, zrange=None): |
|
|||
100 | """ |
|
|||
101 | """ |
|
|||
102 | self.xrange = xrange |
|
|||
103 |
|
||||
104 | self.yrange = yrange |
|
|||
105 |
|
||||
106 | if zrange != None: |
|
|||
107 | self.zrange = zrange |
|
|||
108 |
|
||||
109 | self.hasNotRange = False |
|
|||
110 |
|
||||
111 | def setColormap(self, colormap=None): |
|
|||
112 |
|
66 | |||
113 | if colormap == None: |
|
|||
114 | colormap = self.__colormap |
|
|||
115 |
|
||||
116 | cmap1_init(colormap) |
|
|||
117 |
|
||||
118 | def setXAxisAsTime(self): |
|
67 | def setXAxisAsTime(self): | |
119 | self.__xrangeIsTime = True |
|
68 | self.__xrangeIsTime = True | |
120 |
|
69 | |||
121 | def plotBox(self): |
|
|||
122 | """ |
|
|||
123 |
|
||||
124 | """ |
|
|||
125 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) |
|
|||
126 | plplot.plwind(float(self.xrange[0]), |
|
|||
127 | float(self.xrange[1]), |
|
|||
128 | float(self.yrange[0]), |
|
|||
129 | float(self.yrange[1]) |
|
|||
130 | ) |
|
|||
131 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) |
|
|||
132 | plplot.pllab(self.xlabel, self.ylabel, self.title) |
|
|||
133 |
|
70 | |||
134 | def setup(self, title=None, xlabel=None, ylabel=None, colormap=None): |
|
71 | def setup(self, title=None, xlabel=None, ylabel=None, colormap=None): | |
135 | """ |
|
72 | """ | |
@@ -138,64 +75,63 class BaseGraph: | |||||
138 | self.xlabel = xlabel |
|
75 | self.xlabel = xlabel | |
139 | self.ylabel = ylabel |
|
76 | self.ylabel = ylabel | |
140 | self.__colormap = colormap |
|
77 | self.__colormap = colormap | |
141 |
|
78 | |||
142 | def initSubpage(self): |
|
79 | def plotBox(self, xmin, xmax, ymin, ymax): | |
143 |
|
80 | """ | ||
144 | if plplot.plgdev() == '': |
|
|||
145 | raise ValueError, "Plot device has not been initialize" |
|
|||
146 |
|
||||
147 | plplot.pladv(self.__subpage) |
|
|||
148 | plplot.plschr(0.0, self.__szchar) |
|
|||
149 |
|
|
81 | ||
|
82 | """ | |||
150 | if self.__xrangeIsTime: |
|
83 | if self.__xrangeIsTime: | |
151 | plplot.pltimefmt("%H:%M") |
|
84 | plplot.pltimefmt("%H:%M") | |
152 |
|
85 | |||
153 | self.setColormap() |
|
86 | plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1]) | |
154 | self.initPlot() |
|
87 | plplot.plwind(float(xmin), | |
155 |
|
88 | float(xmax), | ||
156 | def initPlot(self): |
|
89 | float(ymin), | |
157 | """ |
|
90 | float(ymax) | |
158 |
|
91 | ) | ||
159 | """ |
|
92 | plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0) | |
160 | if plplot.plgdev() == '': |
|
93 | plplot.pllab(self.xlabel, self.ylabel, self.title) | |
161 | raise ValueError, "Plot device has not been initialize" |
|
94 | ||
162 |
|
||||
163 | xrange = self.xrange |
|
|||
164 | if xrange == None: |
|
|||
165 | xrange = [0., 1.] |
|
|||
166 |
|
||||
167 | yrange = self.yrange |
|
|||
168 | if yrange == None: |
|
|||
169 | yrange = [0., 1.] |
|
|||
170 |
|
||||
171 | self.plotBox() |
|
|||
172 |
|
95 | |||
173 | def colorbarPlot(self): |
|
96 | def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.): | |
174 | data = numpy.arange(256) |
|
97 | data = numpy.arange(256) | |
175 | data = numpy.reshape(data, (1,-1)) |
|
98 | data = numpy.reshape(data, (1,-1)) | |
176 |
|
99 | |||
177 | self.plotBox() |
|
100 | self.plotBox(xmin, xmax, ymin, ymax) | |
178 | plplot.plimage(data, |
|
101 | plplot.plimage(data, | |
179 |
|
|
102 | float(xmin), | |
180 |
|
|
103 | float(xmax), | |
181 |
|
|
104 | float(ymin), | |
182 |
|
|
105 | float(ymax), | |
183 | 0., |
|
106 | 0., | |
184 | 255., |
|
107 | 255., | |
185 |
|
|
108 | float(xmin), | |
186 |
|
|
109 | float(xmax), | |
187 |
|
|
110 | float(ymin), | |
188 |
|
|
111 | float(ymax)) | |
|
112 | ||||
|
113 | def basicXYPlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None): | |||
|
114 | ||||
|
115 | if xmin == None: xmin = x[0] | |||
|
116 | if xmax == None: xmax = x[-1] | |||
|
117 | if ymin == None: ymin = y[0] | |||
|
118 | if ymax == None: ymax = y[-1] | |||
189 |
|
119 | |||
190 | def basicXYPlot(self, x, y): |
|
|||
191 | self.plotBox() |
|
|||
192 | plplot.plline(x, y) |
|
120 | plplot.plline(x, y) | |
193 |
|
121 | |||
194 | def basicXYwithErrorPlot(self): |
|
122 | def basicXYwithErrorPlot(self): | |
195 | pass |
|
123 | pass | |
196 |
|
124 | |||
197 | def basicLineTimePlot(self): |
|
125 | def basicLineTimePlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1): | |
198 |
|
|
126 | ||
|
127 | if xmin == None: xmin = x[0] | |||
|
128 | if xmax == None: xmax = x[-1] | |||
|
129 | if ymin == None: ymin = y[0] | |||
|
130 | if ymax == None: ymax = y[-1] | |||
|
131 | ||||
|
132 | plplot.plcol0(colline) | |||
|
133 | plplot.plline(x, y) | |||
|
134 | plplot.plcol0(1) | |||
199 |
|
135 | |||
200 | def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): |
|
136 | def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): | |
201 | """ |
|
137 | """ | |
@@ -207,7 +143,6 class BaseGraph: | |||||
207 | if zmin == None: zmin = numpy.nanmin(data) |
|
143 | if zmin == None: zmin = numpy.nanmin(data) | |
208 | if zmax == None: zmax = numpy.nanmax(data) |
|
144 | if zmax == None: zmax = numpy.nanmax(data) | |
209 |
|
145 | |||
210 | self.plotBox() |
|
|||
211 | plplot.plimage(data, |
|
146 | plplot.plimage(data, | |
212 | float(x[0]), |
|
147 | float(x[0]), | |
213 | float(x[-1]), |
|
148 | float(x[-1]), | |
@@ -248,6 +183,129 class BaseGraph: | |||||
248 | plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg) |
|
183 | plplot.plimagefr(data, x[0], x[-1], y[0], y[-1], 0., 0., zmin, zmax, plplot.pltr2, self.__xg, self.__yg) | |
249 |
|
184 | |||
250 |
|
185 | |||
|
186 | class LinearPlot(): | |||
|
187 | ||||
|
188 | __szchar = 1.0 | |||
|
189 | __xrange = None | |||
|
190 | __yrange = None | |||
|
191 | ||||
|
192 | m_BaseGraph = None | |||
|
193 | ||||
|
194 | def __init__(self): | |||
|
195 | ||||
|
196 | ||||
|
197 | key = "linearplot" | |||
|
198 | self.m_BaseGraph = BaseGraph() | |||
|
199 | self.m_BaseGraph.setName(key) | |||
|
200 | ||||
|
201 | def setColormap(self, colormap="br_green"): | |||
|
202 | ||||
|
203 | if colormap == None: | |||
|
204 | colormap = self.__colormap | |||
|
205 | ||||
|
206 | cmap1_init(colormap) | |||
|
207 | ||||
|
208 | def iniSubpage(self): | |||
|
209 | ||||
|
210 | if plplot.plgdev() == '': | |||
|
211 | raise ValueError, "Plot device has not been initialize" | |||
|
212 | ||||
|
213 | plplot.pladv(self.__subpage) | |||
|
214 | plplot.plschr(0.0, self.__szchar) | |||
|
215 | ||||
|
216 | self.setColormap() | |||
|
217 | ||||
|
218 | def setScreenPos(self, width='small'): | |||
|
219 | ||||
|
220 | if width == 'small': | |||
|
221 | xi = 0.12; yi = 0.14; xw = 0.78; yw = 0.80 | |||
|
222 | ||||
|
223 | if width == 'medium': | |||
|
224 | xi = 0.07; yi = 0.10; xw = 0.90; yw = 0.60 | |||
|
225 | ||||
|
226 | xf = xi + xw | |||
|
227 | yf = yi + yw | |||
|
228 | ||||
|
229 | self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf]) | |||
|
230 | ||||
|
231 | def setup(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False): | |||
|
232 | """ | |||
|
233 | """ | |||
|
234 | ||||
|
235 | self.m_BaseGraph.setOpt("bcnts","bcntsv") | |||
|
236 | self.m_BaseGraph.setup(title, | |||
|
237 | xlabel, | |||
|
238 | ylabel | |||
|
239 | ) | |||
|
240 | ||||
|
241 | self.setScreenPos(width='medium') | |||
|
242 | ||||
|
243 | if XAxisAsTime: | |||
|
244 | self.m_BaseGraph.setXAxisAsTime() | |||
|
245 | ||||
|
246 | self.__subpage = subpage | |||
|
247 | # def setRanges(self, xrange, yrange, zrange): | |||
|
248 | # | |||
|
249 | # self.m_BaseGraph.setRanges(xrange, yrange, zrange) | |||
|
250 | ||||
|
251 | def plotData(self, x, y=None, xmin=None, xmax=None, ymin=None, ymax=None, colline=1): | |||
|
252 | """ | |||
|
253 | Inputs: | |||
|
254 | ||||
|
255 | x : Numpy array of dimension 1 | |||
|
256 | y : Numpy array of dimension 1 | |||
|
257 | ||||
|
258 | """ | |||
|
259 | ||||
|
260 | try: | |||
|
261 | nX = numpy.shape(x) | |||
|
262 | except: | |||
|
263 | raise ValueError, "x is not a numpy array" | |||
|
264 | ||||
|
265 | if y == None: y = numpy.arange(nX) | |||
|
266 | ||||
|
267 | if xmin == None: xmin = x[0] | |||
|
268 | if xmax == None: xmax = x[-1] | |||
|
269 | if ymin == None: ymin = y[0] | |||
|
270 | if ymax == None: ymax = y[-1] | |||
|
271 | ||||
|
272 | self.m_BaseGraph.plotBox(xmin, xmax, ymin, ymax) | |||
|
273 | self.m_BaseGraph.basicLineTimePlot(x, y, xmin, xmax, ymin, ymax, colline) | |||
|
274 | ||||
|
275 | def plotComplexData(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1, type='power'): | |||
|
276 | """ | |||
|
277 | Inputs: | |||
|
278 | ||||
|
279 | x : Numpy array of dimension 1 | |||
|
280 | y : Complex numpy array of dimension 1 | |||
|
281 | ||||
|
282 | """ | |||
|
283 | ||||
|
284 | try: | |||
|
285 | nX = numpy.shape(x) | |||
|
286 | except: | |||
|
287 | raise ValueError, "x is not a numpy array" | |||
|
288 | ||||
|
289 | try: | |||
|
290 | nY = numpy.shape(y) | |||
|
291 | except: | |||
|
292 | raise ValueError, "y is not a numpy array" | |||
|
293 | ||||
|
294 | if xmin == None: xmin = x[0] | |||
|
295 | if xmax == None: xmax = x[-1] | |||
|
296 | if ymin == None: ymin = y[0] | |||
|
297 | if ymax == None: ymax = y[-1] | |||
|
298 | ||||
|
299 | self.m_BaseGraph.plotBox(xmin, xmax, ymin, ymax) | |||
|
300 | ||||
|
301 | if type.lower() == 'power': | |||
|
302 | self.m_BaseGraph.basicLineTimePlot(x, abs(y), xmin, xmax, ymin, ymax, colline) | |||
|
303 | ||||
|
304 | if type.lower() == 'iq': | |||
|
305 | ||||
|
306 | self.m_BaseGraph.basicLineTimePlot(x, y.real, xmin, xmax, ymin, ymax, colline) | |||
|
307 | self.m_BaseGraph.basicLineTimePlot(x, y.imag, xmin, xmax, ymin, ymax, colline+1) | |||
|
308 | ||||
251 | class ColorPlot(): |
|
309 | class ColorPlot(): | |
252 |
|
310 | |||
253 |
|
311 | |||
@@ -275,7 +333,7 class ColorPlot(): | |||||
275 |
|
333 | |||
276 | self.m_BaseGraph.setSubpage(subpage) |
|
334 | self.m_BaseGraph.setSubpage(subpage) | |
277 | self.m_BaseGraph.setSzchar(self.__szchar) |
|
335 | self.m_BaseGraph.setSzchar(self.__szchar) | |
278 | self.m_BaseGraph.setOpt("bcnts","bcnts") |
|
336 | self.m_BaseGraph.setOpt("bcnts","bcntsv") | |
279 | self.m_BaseGraph.setup(title, |
|
337 | self.m_BaseGraph.setup(title, | |
280 | xlabel, |
|
338 | xlabel, | |
281 | ylabel, |
|
339 | ylabel, | |
@@ -315,14 +373,14 class ColorPlot(): | |||||
315 |
|
373 | |||
316 | self.showColorbar = showColorbar |
|
374 | self.showColorbar = showColorbar | |
317 | self.showPowerProfile = showPowerProfile |
|
375 | self.showPowerProfile = showPowerProfile | |
318 | self.setPos() |
|
376 | self.setScreenPos() | |
319 |
|
377 | |||
320 | if XAxisAsTime: |
|
378 | if XAxisAsTime: | |
321 | self.m_BaseGraph.setXAxisAsTime() |
|
379 | self.m_BaseGraph.setXAxisAsTime() | |
322 | #self.setPos(xi = 0.05, yi = 0.18, xw = 0.92, yw = 0.74, xcmapw = 0.015, xpoww = 0.14, deltaxcmap = 0.01, deltaxpow = 0.02) |
|
380 | #self.setScreenPos(xi = 0.05, yi = 0.18, xw = 0.92, yw = 0.74, xcmapw = 0.015, xpoww = 0.14, deltaxcmap = 0.01, deltaxpow = 0.02) | |
323 |
|
381 | |||
324 |
|
382 | |||
325 | def setPos(self, xi = 0.12, yi = 0.14, xw = 0.78, yw = 0.80, xcmapw = 0.05, xpoww = 0.24, deltaxcmap = 0.02, deltaxpow = 0.06): |
|
383 | def setScreenPos(self, xi = 0.12, yi = 0.14, xw = 0.78, yw = 0.80, xcmapw = 0.05, xpoww = 0.24, deltaxcmap = 0.02, deltaxpow = 0.06): | |
326 |
|
384 | |||
327 | if self.showColorbar: |
|
385 | if self.showColorbar: | |
328 | xw -= xcmapw + deltaxcmap |
|
386 | xw -= xcmapw + deltaxcmap | |
@@ -409,67 +467,6 class ColorPlot(): | |||||
409 | powObj = self.graphObjDict[key] |
|
467 | powObj = self.graphObjDict[key] | |
410 | powObj.basicXYPlot(power, heis) |
|
468 | powObj.basicXYPlot(power, heis) | |
411 |
|
469 | |||
412 | class LinearPlot(): |
|
|||
413 |
|
||||
414 | __szchar = 0.7 |
|
|||
415 | __xrange = None |
|
|||
416 | __yrange = None |
|
|||
417 |
|
||||
418 | m_BaseGraph = BaseGraph() |
|
|||
419 |
|
||||
420 | def __init__(self): |
|
|||
421 |
|
||||
422 | key = "linearplot" |
|
|||
423 | self.m_BaseGraph.setName(key) |
|
|||
424 |
|
||||
425 | self.graphObjDict[key] = self.m_BaseGraph |
|
|||
426 |
|
||||
427 | def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", XAxisAsTime=False): |
|
|||
428 | """ |
|
|||
429 | """ |
|
|||
430 |
|
||||
431 | self.m_BaseGraph.setSubpage(subpage) |
|
|||
432 | self.m_BaseGraph.setSzchar(self.__szchar) |
|
|||
433 | self.m_BaseGraph.setOpt("bcnts","bcnts") |
|
|||
434 | self.m_BaseGraph.setup(title, |
|
|||
435 | xlabel, |
|
|||
436 | ylabel, |
|
|||
437 | colormap) |
|
|||
438 |
|
||||
439 | self.setPos() |
|
|||
440 |
|
||||
441 | if XAxisAsTime: |
|
|||
442 | self.m_BaseGraph.setXAxisAsTime() |
|
|||
443 | #self.setPos(xi = 0.05, yi = 0.18, xw = 0.92, yw = 0.74, xcmapw = 0.015, xpoww = 0.14, deltaxcmap = 0.01, deltaxpow = 0.02) |
|
|||
444 |
|
||||
445 |
|
||||
446 | def setPos(self, xi = 0.12, yi = 0.14, xw = 0.78, yw = 0.80): |
|
|||
447 |
|
||||
448 | xf = xi + xw |
|
|||
449 | yf = yi + yw |
|
|||
450 |
|
||||
451 | self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf]) |
|
|||
452 |
|
||||
453 | def setRanges(self, xrange, yrange, zrange): |
|
|||
454 |
|
||||
455 | self.m_BaseGraph.setRanges(xrange, yrange, zrange) |
|
|||
456 |
|
||||
457 | def plotData(self, x, y): |
|
|||
458 | """ |
|
|||
459 | """ |
|
|||
460 | xmin = x[0] |
|
|||
461 | xmax = x[-1] |
|
|||
462 |
|
||||
463 | ymin = y[0] |
|
|||
464 | ymax = y[-1] |
|
|||
465 |
|
||||
466 | if self.m_BaseGraph.hasNotRange: |
|
|||
467 | self.setRanges([xmin, xmax], [ymin,ymax]) |
|
|||
468 |
|
||||
469 | self.m_BaseGraph.initSubpage() |
|
|||
470 | self.m_BaseGraph.basicLineTimePlot(x, y) |
|
|||
471 |
|
||||
472 |
|
||||
473 | def cmap1_init(colormap="gray"): |
|
470 | def cmap1_init(colormap="gray"): | |
474 |
|
471 | |||
475 | ncolor = None |
|
472 | ncolor = None |
@@ -11,39 +11,118 import plplot | |||||
11 | path = os.path.split(os.getcwd())[0] |
|
11 | path = os.path.split(os.getcwd())[0] | |
12 | sys.path.append(path) |
|
12 | sys.path.append(path) | |
13 |
|
13 | |||
14 |
from Graphics.Bas |
|
14 | from Graphics.BaseGraph import * | |
15 | from Model.Voltage import Voltage |
|
15 | from Model.Voltage import Voltage | |
16 |
|
16 | |||
17 | class Osciloscope(): |
|
17 | class Osciloscope(): | |
18 |
|
18 | |||
19 | graphObjDict = {} |
|
19 | def __init__(self, Voltage): | |
20 | showPower = True |
|
|||
21 |
|
||||
22 | __szchar = 0.7 |
|
|||
23 | __xrange = None |
|
|||
24 | __yrange = None |
|
|||
25 | __zrange = None |
|
|||
26 |
|
||||
27 | def __init__(self): |
|
|||
28 | key = "osc" |
|
|||
29 |
|
|
20 | ||
30 | baseObj = BasicGraph() |
|
21 | """ | |
31 | baseObj.setName(key) |
|
|||
32 |
|
|
22 | ||
33 | self.graphObjDict[key] = baseObj |
|
23 | Inputs: | |
|
24 | ||||
|
25 | type: "power" ->> Potencia | |||
|
26 | "iq" ->> Real + Imaginario | |||
|
27 | """ | |||
|
28 | ||||
|
29 | self.__isPlotConfig = False | |||
|
30 | ||||
|
31 | self.__isPlotIni = False | |||
|
32 | ||||
|
33 | self.__xrange = None | |||
|
34 | ||||
|
35 | self.__yrange = None | |||
|
36 | ||||
|
37 | self.m_Voltage = None | |||
|
38 | ||||
|
39 | self.nGraphs = 0 | |||
|
40 | ||||
|
41 | self.graphObjList = [] | |||
|
42 | ||||
|
43 | self.m_Voltage = Voltage | |||
34 |
|
44 | |||
35 |
|
45 | |||
36 |
def |
|
46 | def __addGraph(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False): | |
37 |
|
|
47 | ||
38 |
|
48 | graphObj = LinearPlot() | ||
39 | def setRanges(self, xrange, yrange, zrange): |
|
49 | graphObj.setup(subpage, title="", xlabel="", ylabel="", XAxisAsTime=False) | |
40 | pass |
|
50 | #graphObj.setScreenPos() | |
|
51 | ||||
|
52 | self.graphObjList.append(graphObj) | |||
|
53 | ||||
|
54 | del graphObj | |||
41 |
|
55 | |||
42 | def plotData(self, data , xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None): |
|
56 | # def setXRange(self, xmin, xmax): | |
43 | pass |
|
57 | # self.__xrange = (xmin, xmax) | |
|
58 | # | |||
|
59 | # def setYRange(self, ymin, ymax): | |||
|
60 | # self.__yrange = (ymin, ymax) | |||
44 |
|
61 | |||
|
62 | ||||
|
63 | def setup(self, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False): | |||
|
64 | ||||
|
65 | nChan = int(self.m_Voltage.m_SystemHeader.numChannels) | |||
|
66 | ||||
|
67 | myTitle = "" | |||
|
68 | myXlabel = "" | |||
|
69 | myYlabel = "" | |||
|
70 | ||||
|
71 | for i in range(nChan): | |||
|
72 | if titleList != None: | |||
|
73 | myTitle = titleList[i] | |||
|
74 | myXlabel = xlabelList[i] | |||
|
75 | myYlabel = ylabelList[i] | |||
|
76 | ||||
|
77 | self.__addGraph(i+1, title=myTitle, xlabel=myXlabel, ylabel=myYlabel, XAxisAsTime=XAxisAsTime) | |||
|
78 | ||||
|
79 | self.nGraphs = nChan | |||
|
80 | self.__isPlotConfig = True | |||
45 |
|
81 | |||
|
82 | def iniPlot(self): | |||
|
83 | plplot.plsetopt("geometry", "%dx%d" %(700, 115*self.nGraphs)) | |||
|
84 | plplot.plsdev("xcairo") | |||
|
85 | plplot.plscolbg(255,255,255) | |||
|
86 | plplot.plscol0(1,0,0,0) | |||
|
87 | plplot.plinit() | |||
|
88 | plplot.plspause(False) | |||
|
89 | plplot.plssub(1, self.nGraphs) | |||
|
90 | ||||
|
91 | self.__isPlotIni = True | |||
|
92 | ||||
|
93 | def plotData(self, xmin=None, xmax=None, ymin=None, ymax=None, idProfile=None, titleList=None, xlabelList=None, ylabelList=None, XAxisAsTime=False, type='iq'): | |||
|
94 | ||||
|
95 | if idProfile != None and idProfile != self.m_Voltage.idProfile: | |||
|
96 | return | |||
|
97 | ||||
|
98 | if not(self.__isPlotConfig): | |||
|
99 | self.setup(titleList, xlabelList, ylabelList, XAxisAsTime) | |||
|
100 | ||||
|
101 | if not(self.__isPlotIni): | |||
|
102 | self.iniPlot() | |||
|
103 | ||||
|
104 | data = self.m_Voltage.data | |||
|
105 | ||||
|
106 | x = self.m_Voltage.heights | |||
|
107 | ||||
|
108 | if xmin == None: xmin = x[0] | |||
|
109 | if xmax == None: xmax = x[-1] | |||
|
110 | if ymin == None: ymin = numpy.nanmin(abs(data)) | |||
|
111 | if ymax == None: ymax = numpy.nanmax(abs(data)) | |||
|
112 | ||||
|
113 | plplot.plbop() | |||
|
114 | for i in range(self.nGraphs): | |||
|
115 | y = data[:,i] | |||
|
116 | ||||
|
117 | self.graphObjList[i].iniSubpage() | |||
|
118 | self.graphObjList[i].plotComplexData(x, y, xmin, xmax, ymin, ymax, 8, type) | |||
|
119 | ||||
|
120 | plplot.plflush() | |||
|
121 | plplot.pleop() | |||
46 |
|
122 | |||
|
123 | def end(self): | |||
|
124 | plplot.plend() | |||
|
125 | ||||
47 | class VoltagePlot(object): |
|
126 | class VoltagePlot(object): | |
48 | ''' |
|
127 | ''' | |
49 | classdocs |
|
128 | classdocs |
@@ -5,8 +5,8 Created on 23/01/2012 | |||||
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
8 | from Data import DataReader |
|
8 | from DataIO import DataReader | |
9 | from Data import DataWriter |
|
9 | from DataIO import DataWriter | |
10 |
|
10 | |||
11 | class CorrelationReader(DataReader): |
|
11 | class CorrelationReader(DataReader): | |
12 | def __init__(self): |
|
12 | def __init__(self): |
1 | NO CONTENT: file renamed from schainpy/IO/Data.py to schainpy/IO/DataIO.py |
|
NO CONTENT: file renamed from schainpy/IO/Data.py to schainpy/IO/DataIO.py |
@@ -7,43 +7,6 Created on 23/01/2012 | |||||
7 |
|
7 | |||
8 | import numpy |
|
8 | import numpy | |
9 |
|
9 | |||
10 | class PROCFLAG: |
|
|||
11 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
|
|||
12 | DECODE_DATA = numpy.uint32(0x00000002) |
|
|||
13 | SPECTRA_CALC = numpy.uint32(0x00000004) |
|
|||
14 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) |
|
|||
15 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) |
|
|||
16 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) |
|
|||
17 |
|
||||
18 | DATATYPE_CHAR = numpy.uint32(0x00000040) |
|
|||
19 | DATATYPE_SHORT = numpy.uint32(0x00000080) |
|
|||
20 | DATATYPE_LONG = numpy.uint32(0x00000100) |
|
|||
21 | DATATYPE_INT64 = numpy.uint32(0x00000200) |
|
|||
22 | DATATYPE_FLOAT = numpy.uint32(0x00000400) |
|
|||
23 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) |
|
|||
24 |
|
||||
25 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) |
|
|||
26 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) |
|
|||
27 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) |
|
|||
28 |
|
||||
29 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) |
|
|||
30 | DEFLIP_DATA = numpy.uint32(0x00010000) |
|
|||
31 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) |
|
|||
32 |
|
||||
33 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) |
|
|||
34 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) |
|
|||
35 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) |
|
|||
36 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) |
|
|||
37 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) |
|
|||
38 |
|
||||
39 | EXP_NAME_ESP = numpy.uint32(0x00200000) |
|
|||
40 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) |
|
|||
41 |
|
||||
42 | OPERATION_MASK = numpy.uint32(0x0000003F) |
|
|||
43 | DATATYPE_MASK = numpy.uint32(0x00000FC0) |
|
|||
44 | DATAARRANGE_MASK = numpy.uint32(0x00007000) |
|
|||
45 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) |
|
|||
46 |
|
||||
47 | class BasicHeader: |
|
10 | class BasicHeader: | |
48 |
|
11 | |||
49 | def __init__(self): |
|
12 | def __init__(self): | |
@@ -314,4 +277,41 class ProcessingHeader: | |||||
314 | obj.numBaud = self.numBaud |
|
277 | obj.numBaud = self.numBaud | |
315 | obj.codes = self.codes |
|
278 | obj.codes = self.codes | |
316 |
|
279 | |||
317 | return obj No newline at end of file |
|
280 | return obj | |
|
281 | ||||
|
282 | class PROCFLAG: | |||
|
283 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) | |||
|
284 | DECODE_DATA = numpy.uint32(0x00000002) | |||
|
285 | SPECTRA_CALC = numpy.uint32(0x00000004) | |||
|
286 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) | |||
|
287 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) | |||
|
288 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) | |||
|
289 | ||||
|
290 | DATATYPE_CHAR = numpy.uint32(0x00000040) | |||
|
291 | DATATYPE_SHORT = numpy.uint32(0x00000080) | |||
|
292 | DATATYPE_LONG = numpy.uint32(0x00000100) | |||
|
293 | DATATYPE_INT64 = numpy.uint32(0x00000200) | |||
|
294 | DATATYPE_FLOAT = numpy.uint32(0x00000400) | |||
|
295 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) | |||
|
296 | ||||
|
297 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) | |||
|
298 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) | |||
|
299 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) | |||
|
300 | ||||
|
301 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) | |||
|
302 | DEFLIP_DATA = numpy.uint32(0x00010000) | |||
|
303 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) | |||
|
304 | ||||
|
305 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) | |||
|
306 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) | |||
|
307 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) | |||
|
308 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) | |||
|
309 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) | |||
|
310 | ||||
|
311 | EXP_NAME_ESP = numpy.uint32(0x00200000) | |||
|
312 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) | |||
|
313 | ||||
|
314 | OPERATION_MASK = numpy.uint32(0x0000003F) | |||
|
315 | DATATYPE_MASK = numpy.uint32(0x00000FC0) | |||
|
316 | DATAARRANGE_MASK = numpy.uint32(0x00007000) | |||
|
317 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) No newline at end of file |
@@ -6,8 +6,8 Created on 23/01/2012 | |||||
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
8 | from Header import * |
|
8 | from Header import * | |
9 | from Data import DataReader |
|
9 | from DataIO import DataReader | |
10 | from Data import DataWriter |
|
10 | from DataIO import DataWriter | |
11 |
|
11 | |||
12 |
|
12 | |||
13 | class SpectraReader(DataReader): |
|
13 | class SpectraReader(DataReader): |
@@ -10,39 +10,39 path = os.path.split(os.getcwd())[0] | |||||
10 | sys.path.append(path) |
|
10 | sys.path.append(path) | |
11 |
|
11 | |||
12 | from Model.Data import Data |
|
12 | from Model.Data import Data | |
13 | from IO.Header import * |
|
13 | from IO.HeaderIO import * | |
14 |
|
14 | |||
15 | class Voltage(Data): |
|
15 | class Voltage(Data): | |
16 | ''' |
|
16 | ''' | |
17 | classdocs |
|
17 | classdocs | |
18 | ''' |
|
18 | ''' | |
19 |
|
||||
20 |
|
||||
21 |
|
19 | |||
22 |
|
||||
23 |
|
||||
24 | def __init__(self): |
|
20 | def __init__(self): | |
25 | ''' |
|
21 | ''' | |
26 | Constructor |
|
22 | Constructor | |
27 | ''' |
|
23 | ''' | |
28 |
|
24 | |||
29 | self.m_RadarControllerHeader= RadarControllerHeader() |
|
25 | self.m_RadarControllerHeader= RadarControllerHeader() | |
30 |
|
||||
31 | self.m_ProcessingHeader= ProcessingHeader() |
|
|||
32 |
|
26 | |||
|
27 | self.m_ProcessingHeader= ProcessingHeader() | |||
|
28 | ||||
33 | self.m_SystemHeader= SystemHeader() |
|
29 | self.m_SystemHeader= SystemHeader() | |
34 |
|
|
30 | ||
35 | self.m_BasicHeader= BasicHeader() |
|
31 | self.m_BasicHeader= BasicHeader() | |
36 |
|
32 | |||
37 | #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) |
|
33 | #data es un numpy array de 3 dmensiones (perfiles, alturas y canales) | |
38 | self.data = None |
|
34 | self.data = None | |
39 |
|
35 | |||
40 |
self. |
|
36 | self.heights = None | |
41 |
|
37 | |||
42 | self.noData = True |
|
38 | self.noData = True | |
43 |
|
39 | |||
|
40 | self.nProfiles = None | |||
|
41 | ||||
|
42 | self.idProfile = None | |||
|
43 | ||||
|
44 | self.dataType = None | |||
44 |
|
45 | |||
45 |
|
||||
46 | def copy(self): |
|
46 | def copy(self): | |
47 | obj = Voltage() |
|
47 | obj = Voltage() | |
48 | obj.m_BasicHeader = self.m_BasicHeader.copy() |
|
48 | obj.m_BasicHeader = self.m_BasicHeader.copy() | |
@@ -50,5 +50,12 class Voltage(Data): | |||||
50 | obj.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() |
|
50 | obj.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() | |
51 | obj.m_ProcessingHeader = self.m_ProcessingHeader.copy() |
|
51 | obj.m_ProcessingHeader = self.m_ProcessingHeader.copy() | |
52 |
|
52 | |||
|
53 | obj.data = self.data | |||
|
54 | obj.heights = self.heights | |||
|
55 | obj.noData = self.noData | |||
|
56 | ||||
|
57 | obj.nProfiles = self.nProfiles | |||
|
58 | obj.idProfile = self.idProfile | |||
|
59 | ||||
53 | return obj |
|
60 | return obj | |
54 | No newline at end of file |
|
61 |
General Comments 0
You need to be logged in to leave comments.
Login now