##// END OF EJS Templates
Dentro del paquete IO se agrego un sufijo "IO" a todos los modulos
Miguel Valdez -
r20:b88be568bb0c
parent child
Show More
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
@@ -1,606 +1,603
1 1 """
2 2 Created on Feb 7, 2012
3 3
4 4 @autor $Author$
5 5 @version $Id$
6 6
7 7 """
8 8
9 9 import numpy
10 10 import plplot
11 11
12 12 class BaseGraph:
13 13 """
14 14
15 15 """
16 16
17 hasNotRange = True
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
17
51 18
52 19 def __init__(self):
53 20 """
54 21
55 22 """
56 pass
57
58 def hasNotXrange(self):
23 self.hasNotRange = True
59 24
60 if self.xrange == None:
61 return 1
25 self.xrange = None
26 self.yrange = None
27 self.zrange = None
62 28
63 return 0
64
65 def hasNotYrange(self):
29 self.xlabel = None
30 self.ylabel = None
31 self.title = None
66 32
67 if self.yrange == None:
68 return 1
33 self.legends = None
69 34
70 return 0
71
72 def hasNotZrange(self):
35 self.__name = None
36
37 self.__colormap = None
38 self.__colbox = None
39 self.__colleg = None
40
41 self.__xpos = None
42 self.__ypos = None
73 43
74 if self.zrange == None:
75 return 1
44 self.__xopt = None #"bcnst"
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 56 def setName(self, name):
79 57 self.__name = name
80 58
81 59 def setScreenPos(self, xpos, ypos):
82 60 self.__xpos = xpos
83 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 63 def setOpt(self, xopt, yopt):
96 64 self.__xopt = xopt
97 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 67 def setXAxisAsTime(self):
119 68 self.__xrangeIsTime = True
120
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)
69
133 70
134 71 def setup(self, title=None, xlabel=None, ylabel=None, colormap=None):
135 72 """
136 73 """
137 74 self.title = title
138 75 self.xlabel = xlabel
139 76 self.ylabel = ylabel
140 77 self.__colormap = colormap
141
142 def initSubpage(self):
143
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)
78
79 def plotBox(self, xmin, xmax, ymin, ymax):
80 """
149 81
82 """
150 83 if self.__xrangeIsTime:
151 84 plplot.pltimefmt("%H:%M")
152 85
153 self.setColormap()
154 self.initPlot()
155
156 def initPlot(self):
157 """
158
159 """
160 if plplot.plgdev() == '':
161 raise ValueError, "Plot device has not been initialize"
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()
86 plplot.plvpor(self.__xpos[0], self.__xpos[1], self.__ypos[0], self.__ypos[1])
87 plplot.plwind(float(xmin),
88 float(xmax),
89 float(ymin),
90 float(ymax)
91 )
92 plplot.plbox(self.__xopt, 0.0, 0, self.__yopt, 0.0, 0)
93 plplot.pllab(self.xlabel, self.ylabel, self.title)
94
172 95
173 def colorbarPlot(self):
96 def colorbarPlot(self, xmin=0., xmax=1., ymin=0., ymax=1.):
174 97 data = numpy.arange(256)
175 98 data = numpy.reshape(data, (1,-1))
176 99
177 self.plotBox()
100 self.plotBox(xmin, xmax, ymin, ymax)
178 101 plplot.plimage(data,
179 self.xrange[0],
180 self.xrange[1],
181 self.yrange[0],
182 self.yrange[1],
102 float(xmin),
103 float(xmax),
104 float(ymin),
105 float(ymax),
183 106 0.,
184 107 255.,
185 self.xrange[0],
186 self.xrange[1],
187 self.yrange[0],
188 self.yrange[1],)
108 float(xmin),
109 float(xmax),
110 float(ymin),
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 120 plplot.plline(x, y)
193 121
194 122 def basicXYwithErrorPlot(self):
195 123 pass
196 124
197 def basicLineTimePlot(self):
198 pass
125 def basicLineTimePlot(self, x, y, xmin=None, xmax=None, ymin=None, ymax=None, colline=1):
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 136 def basicPcolorPlot(self, data, x, y, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
201 137 """
202 138 """
203 139 if xmin == None: xmin = x[0]
204 140 if xmax == None: xmax = x[-1]
205 141 if ymin == None: ymin = y[0]
206 142 if ymax == None: ymax = y[-1]
207 143 if zmin == None: zmin = numpy.nanmin(data)
208 144 if zmax == None: zmax = numpy.nanmax(data)
209 145
210 self.plotBox()
211 146 plplot.plimage(data,
212 147 float(x[0]),
213 148 float(x[-1]),
214 149 float(y[0]),
215 150 float(y[-1]),
216 151 float(zmin),
217 152 float(zmax),
218 153 float(xmin),
219 154 float(xmax),
220 155 float(ymin),
221 156 float(ymax)
222 157 )
223 158
224 159 def __getBoxpltr(self, x, y, deltax=None, deltay=None):
225 160
226 161 if not(len(x)>1 and len(y)>1):
227 162 raise ValueError, "x axis and y axis are empty"
228 163
229 164 if deltax == None: deltax = x[-1] - x[-2]
230 165 if deltay == None: deltay = y[-1] - y[-2]
231 166
232 167 x1 = numpy.append(x, x[-1] + deltax)
233 168 y1 = numpy.append(y, y[-1] + deltay)
234 169
235 170 xg = (numpy.multiply.outer(x1, numpy.ones(len(y1))))
236 171 yg = (numpy.multiply.outer(numpy.ones(len(x1)), y1))
237 172
238 173 self.__xg = xg
239 174 self.__yg = yg
240 175
241 176 def advPcolorPlot(self, data, x, y, zmin=0., zmax=0.):
242 177 """
243 178 """
244 179
245 180 if self.__xg == None and self.__yg == None:
246 181 self.__getBoxpltr(x, y)
247 182
248 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 309 class ColorPlot():
252 310
253 311
254 312 graphObjDict = {}
255 313 showColorbar = False
256 314 showPowerProfile = True
257 315
258 316 __szchar = 0.7
259 317 __xrange = None
260 318 __yrange = None
261 319 __zrange = None
262 320
263 321 m_BaseGraph = BaseGraph()
264 322
265 323 def __init__(self):
266 324
267 325 key = "colorplot"
268 326 self.m_BaseGraph.setName(key)
269 327
270 328 self.graphObjDict[key] = self.m_BaseGraph
271 329
272 330 def setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False, XAxisAsTime=False):
273 331 """
274 332 """
275 333
276 334 self.m_BaseGraph.setSubpage(subpage)
277 335 self.m_BaseGraph.setSzchar(self.__szchar)
278 self.m_BaseGraph.setOpt("bcnts","bcnts")
336 self.m_BaseGraph.setOpt("bcnts","bcntsv")
279 337 self.m_BaseGraph.setup(title,
280 338 xlabel,
281 339 ylabel,
282 340 colormap)
283 341
284 342 if showColorbar:
285 343 key = "colorbar"
286 344
287 345 cmapObj = BaseGraph()
288 346 cmapObj.setName(key)
289 347 cmapObj.setSubpage(subpage)
290 348 cmapObj.setSzchar(self.__szchar)
291 349 cmapObj.setOpt("bc","bcmt")
292 350 cmapObj.setup(title="dBs",
293 351 xlabel="",
294 352 ylabel="",
295 353 colormap=colormap)
296 354
297 355 self.graphObjDict[key] = cmapObj
298 356
299 357
300 358 if showPowerProfile:
301 359 key = "powerprof"
302 360
303 361 powObj = BaseGraph()
304 362 powObj.setName(key)
305 363 powObj.setSubpage(subpage)
306 364 powObj.setSzchar(self.__szchar)
307 365 plplot.pllsty(2)
308 366 powObj.setOpt("bcntg","bc")
309 367 plplot.pllsty(1)
310 368 powObj.setup(title="Power Profile",
311 369 xlabel="dBs",
312 370 ylabel="")
313 371
314 372 self.graphObjDict[key] = powObj
315 373
316 374 self.showColorbar = showColorbar
317 375 self.showPowerProfile = showPowerProfile
318 self.setPos()
376 self.setScreenPos()
319 377
320 378 if XAxisAsTime:
321 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 385 if self.showColorbar:
328 386 xw -= xcmapw + deltaxcmap
329 387
330 388 if self.showPowerProfile:
331 389 xw -= xpoww + deltaxpow
332 390
333 391 xf = xi + xw
334 392 yf = yi + yw
335 393 xcmapf = xf
336 394
337 395 self.m_BaseGraph.setScreenPos([xi, xf], [yi, yf])
338 396
339 397 if self.showColorbar:
340 398 xcmapi = xf + deltaxcmap
341 399 xcmapf = xcmapi + xcmapw
342 400
343 401 key = "colorbar"
344 402 cmapObj = self.graphObjDict[key]
345 403 cmapObj.setScreenPos([xcmapi, xcmapf], [yi, yf])
346 404
347 405 if self.showPowerProfile:
348 406
349 407 xpowi = xcmapf + deltaxpow
350 408 xpowf = xpowi + xpoww
351 409
352 410 key = "powerprof"
353 411 powObj = self.graphObjDict[key]
354 412 powObj.setScreenPos([xpowi, xpowf], [yi, yf])
355 413
356 414 def setRanges(self, xrange, yrange, zrange):
357 415
358 416 self.m_BaseGraph.setRanges(xrange, yrange, zrange)
359 417
360 418 keyList = self.graphObjDict.keys()
361 419
362 420 key = "colorbar"
363 421 if key in keyList:
364 422 cmapObj = self.graphObjDict[key]
365 423 cmapObj.setRanges([0., 1.], zrange)
366 424
367 425 key = "powerprof"
368 426 if key in keyList:
369 427 powObj = self.graphObjDict[key]
370 428 powObj.setRanges(zrange, yrange)
371 429
372 430 def plotData(self, data, x=None, y=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None):
373 431 """
374 432 """
375 433
376 434 try:
377 435 nX, nY = numpy.shape(data)
378 436 except:
379 437 raise ValueError, "data is not a numpy array"
380 438
381 439 if x == None: x = numpy.arange(nX)
382 440 if y == None: y = numpy.arange(nY)
383 441
384 442 if xmin == None: xmin = x[0]
385 443 if xmax == None: xmax = x[-1]
386 444 if ymin == None: ymin = y[0]
387 445 if ymax == None: ymax = y[-1]
388 446 if zmin == None: zmin = numpy.nanmin(data)
389 447 if zmax == None: zmax = numpy.nanmax(data)
390 448
391 449 if self.m_BaseGraph.hasNotRange:
392 450 self.setRanges([xmin, xmax], [ymin,ymax], [zmin,zmax])
393 451
394 452 self.m_BaseGraph.initSubpage()
395 453 self.m_BaseGraph.basicPcolorPlot(data, x, y, xmin, xmax, ymin, ymax, self.m_BaseGraph.zrange[0], self.m_BaseGraph.zrange[1])
396 454
397 455 if self.showColorbar:
398 456 key = "colorbar"
399 457 cmapObj = self.graphObjDict[key]
400 458 cmapObj.colorbarPlot()
401 459
402 460 if self.showPowerProfile:
403 461 power = numpy.average(data, axis=1)
404 462
405 463 step = (ymax - ymin)/(nY-1)
406 464 heis = numpy.arange(ymin, ymax + step, step)
407 465
408 466 key = "powerprof"
409 467 powObj = self.graphObjDict[key]
410 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 470 def cmap1_init(colormap="gray"):
474 471
475 472 ncolor = None
476 473 rgb_lvl = None
477 474
478 475 # Routine for defining a specific color map 1 in HLS space.
479 476 # if gray is true, use basic grayscale variation from half-dark to light.
480 477 # otherwise use false color variation from blue (240 deg) to red (360 deg).
481 478
482 479 # Independent variable of control points.
483 480 i = numpy.array((0., 1.))
484 481 if colormap=="gray":
485 482 ncolor = 256
486 483 # Hue for control points. Doesn't matter since saturation is zero.
487 484 h = numpy.array((0., 0.))
488 485 # Lightness ranging from half-dark (for interest) to light.
489 486 l = numpy.array((0.5, 1.))
490 487 # Gray scale has zero saturation
491 488 s = numpy.array((0., 0.))
492 489
493 490 # number of cmap1 colours is 256 in this case.
494 491 plplot.plscmap1n(ncolor)
495 492 # Interpolate between control points to set up cmap1.
496 493 plplot.plscmap1l(0, i, h, l, s)
497 494
498 495 return None
499 496
500 497 if colormap=="br_green":
501 498 ncolor = 256
502 499 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
503 500 h = numpy.array((240., 0.))
504 501 # Lightness and saturation are constant (values taken from C example).
505 502 l = numpy.array((0.6, 0.6))
506 503 s = numpy.array((0.8, 0.8))
507 504
508 505 # number of cmap1 colours is 256 in this case.
509 506 plplot.plscmap1n(ncolor)
510 507 # Interpolate between control points to set up cmap1.
511 508 plplot.plscmap1l(0, i, h, l, s)
512 509
513 510 return None
514 511
515 512 if colormap=="tricolor":
516 513 ncolor = 3
517 514 # Hue ranges from blue (240 deg) to red (0 or 360 deg)
518 515 h = numpy.array((240., 0.))
519 516 # Lightness and saturation are constant (values taken from C example).
520 517 l = numpy.array((0.6, 0.6))
521 518 s = numpy.array((0.8, 0.8))
522 519
523 520 # number of cmap1 colours is 256 in this case.
524 521 plplot.plscmap1n(ncolor)
525 522 # Interpolate between control points to set up cmap1.
526 523 plplot.plscmap1l(0, i, h, l, s)
527 524
528 525 return None
529 526
530 527 if colormap == 'rgb' or colormap == 'rgb666':
531 528
532 529 color_sz = 6
533 530 ncolor = color_sz*color_sz*color_sz
534 531 pos = numpy.zeros((ncolor))
535 532 r = numpy.zeros((ncolor))
536 533 g = numpy.zeros((ncolor))
537 534 b = numpy.zeros((ncolor))
538 535 ind = 0
539 536 for ri in range(color_sz):
540 537 for gi in range(color_sz):
541 538 for bi in range(color_sz):
542 539 r[ind] = ri/(color_sz-1.0)
543 540 g[ind] = gi/(color_sz-1.0)
544 541 b[ind] = bi/(color_sz-1.0)
545 542 pos[ind] = ind/(ncolor-1.0)
546 543 ind += 1
547 544 rgb_lvl = [6,6,6] #Levels for RGB colors
548 545
549 546 if colormap == 'rgb676':
550 547 ncolor = 6*7*6
551 548 pos = numpy.zeros((ncolor))
552 549 r = numpy.zeros((ncolor))
553 550 g = numpy.zeros((ncolor))
554 551 b = numpy.zeros((ncolor))
555 552 ind = 0
556 553 for ri in range(8):
557 554 for gi in range(8):
558 555 for bi in range(4):
559 556 r[ind] = ri/(6-1.0)
560 557 g[ind] = gi/(7-1.0)
561 558 b[ind] = bi/(6-1.0)
562 559 pos[ind] = ind/(ncolor-1.0)
563 560 ind += 1
564 561 rgb_lvl = [6,7,6] #Levels for RGB colors
565 562
566 563 if colormap == 'rgb685':
567 564 ncolor = 6*8*5
568 565 pos = numpy.zeros((ncolor))
569 566 r = numpy.zeros((ncolor))
570 567 g = numpy.zeros((ncolor))
571 568 b = numpy.zeros((ncolor))
572 569 ind = 0
573 570 for ri in range(8):
574 571 for gi in range(8):
575 572 for bi in range(4):
576 573 r[ind] = ri/(6-1.0)
577 574 g[ind] = gi/(8-1.0)
578 575 b[ind] = bi/(5-1.0)
579 576 pos[ind] = ind/(ncolor-1.0)
580 577 ind += 1
581 578 rgb_lvl = [6,8,5] #Levels for RGB colors
582 579
583 580 if colormap == 'rgb884':
584 581 ncolor = 8*8*4
585 582 pos = numpy.zeros((ncolor))
586 583 r = numpy.zeros((ncolor))
587 584 g = numpy.zeros((ncolor))
588 585 b = numpy.zeros((ncolor))
589 586 ind = 0
590 587 for ri in range(8):
591 588 for gi in range(8):
592 589 for bi in range(4):
593 590 r[ind] = ri/(8-1.0)
594 591 g[ind] = gi/(8-1.0)
595 592 b[ind] = bi/(4-1.0)
596 593 pos[ind] = ind/(ncolor-1.0)
597 594 ind += 1
598 595 rgb_lvl = [8,8,4] #Levels for RGB colors
599 596
600 597 if ncolor == None:
601 598 raise ValueError, "The colormap selected is not valid"
602 599
603 600 plplot.plscmap1n(ncolor)
604 601 plplot.plscmap1l(1, pos, r, g, b)
605 602
606 603 return rgb_lvl No newline at end of file
@@ -1,96 +1,175
1 1 '''
2 2 Created on Feb 7, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7 import os, sys
8 8 import numpy
9 9 import plplot
10 10
11 11 path = os.path.split(os.getcwd())[0]
12 12 sys.path.append(path)
13 13
14 from Graphics.BasicGraph import *
14 from Graphics.BaseGraph import *
15 15 from Model.Voltage import Voltage
16 16
17 17 class Osciloscope():
18 18
19 graphObjDict = {}
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"
19 def __init__(self, Voltage):
29 20
30 baseObj = BasicGraph()
31 baseObj.setName(key)
21 """
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 setup(self, subpage, title="", xlabel="", ylabel="", colormap="jet", showColorbar=False, showPowerProfile=False):
37 pass
38
39 def setRanges(self, xrange, yrange, zrange):
40 pass
46 def __addGraph(self, subpage, title="", xlabel="", ylabel="", XAxisAsTime=False):
47
48 graphObj = LinearPlot()
49 graphObj.setup(subpage, title="", xlabel="", ylabel="", XAxisAsTime=False)
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):
43 pass
56 # def setXRange(self, xmin, xmax):
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 126 class VoltagePlot(object):
48 127 '''
49 128 classdocs
50 129 '''
51 130
52 131 __m_Voltage = None
53 132
54 133 def __init__(self, m_Voltage):
55 134 '''
56 135 Constructor
57 136 '''
58 137 self.__m_Voltage = m_Voltage
59 138
60 139 def setup(self):
61 140 pass
62 141
63 142 def addGraph(self, type, xrange=None, yrange=None, zrange=None):
64 143 pass
65 144
66 145 def plotData(self):
67 146 pass
68 147
69 148 if __name__ == '__main__':
70 149
71 150 import numpy
72 151
73 152 plplot.plsetopt("geometry", "%dx%d" %(450*2, 200*2))
74 153 plplot.plsdev("xcairo")
75 154 plplot.plscolbg(255,255,255)
76 155 plplot.plscol0(1,0,0,0)
77 156 plplot.plinit()
78 157 plplot.plssub(1, 2)
79 158
80 159 nx = 64
81 160 ny = 100
82 161
83 162 data = numpy.random.uniform(-50,50,(nx,ny))
84 163
85 164 baseObj = RTI()
86 165 baseObj.setup(1, "Spectrum", "Frequency", "Range", "br_green", False, False)
87 166 baseObj.plotData(data)
88 167
89 168 data = numpy.random.uniform(-50,50,(nx,ny))
90 169
91 170 base2Obj = RTI()
92 171 base2Obj.setup(2, "Spectrum", "Frequency", "Range", "br_green", True, True)
93 172 base2Obj.plotData(data)
94 173
95 174 plplot.plend()
96 175 exit(0) No newline at end of file
@@ -1,17 +1,17
1 1 '''
2 2 Created on 23/01/2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7
8 from Data import DataReader
9 from Data import DataWriter
8 from DataIO import DataReader
9 from DataIO import DataWriter
10 10
11 11 class CorrelationReader(DataReader):
12 12 def __init__(self):
13 13 pass
14 14
15 15 class CorrelationWriter(DataWriter):
16 16 def __init__(self):
17 17 pass No newline at end of file
1 NO CONTENT: file renamed from schainpy/IO/Data.py to schainpy/IO/DataIO.py
@@ -1,317 +1,317
1 1 '''
2 2 Created on 23/01/2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7
8 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 10 class BasicHeader:
48 11
49 12 def __init__(self):
50 13 self.size = 0
51 14 self.version = 0
52 15 self.dataBlock = 0
53 16 self.utc = 0
54 17 self.miliSecond = 0
55 18 self.timeZone = 0
56 19 self.dstFlag = 0
57 20 self.errorCount = 0
58 21 self.struct = numpy.dtype([
59 22 ('nSize','<u4'),
60 23 ('nVersion','<u2'),
61 24 ('nDataBlockId','<u4'),
62 25 ('nUtime','<u4'),
63 26 ('nMilsec','<u2'),
64 27 ('nTimezone','<i2'),
65 28 ('nDstflag','<i2'),
66 29 ('nErrorCount','<u4')
67 30 ])
68 31 pass
69 32
70 33 def read(self, fp):
71 34
72 35 header = numpy.fromfile(fp, self.struct,1)
73 36 self.size = header['nSize'][0]
74 37 self.version = header['nVersion'][0]
75 38 self.dataBlock = header['nDataBlockId'][0]
76 39 self.utc = header['nUtime'][0]
77 40 self.miliSecond = header['nMilsec'][0]
78 41 self.timeZone = header['nTimezone'][0]
79 42 self.dstFlag = header['nDstflag'][0]
80 43 self.errorCount = header['nErrorCount'][0]
81 44
82 45 return 1
83 46
84 47 def copy(self):
85 48
86 49 obj = BasicHeader()
87 50 obj.size = self.size
88 51 obj.version = self.version
89 52 obj.dataBlock = self.dataBlock
90 53 obj.utc = self.utc
91 54 obj.miliSecond = self.miliSecond
92 55 obj.timeZone = self.timeZone
93 56 obj.dstFlag = self.dstFlag
94 57 obj.errorCount = self.errorCount
95 58
96 59 return obj
97 60
98 61 class SystemHeader:
99 62
100 63 def __init__(self):
101 64 self.size = 0
102 65 self.numSamples = 0
103 66 self.numProfiles = 0
104 67 self.numChannels = 0
105 68 self.adcResolution = 0
106 69 self.pciDioBusWidth = 0
107 70 self.struct = numpy.dtype([
108 71 ('nSize','<u4'),
109 72 ('nNumSamples','<u4'),
110 73 ('nNumProfiles','<u4'),
111 74 ('nNumChannels','<u4'),
112 75 ('nADCResolution','<u4'),
113 76 ('nPCDIOBusWidth','<u4'),
114 77 ])
115 78
116 79
117 80 def read(self, fp):
118 81 header = numpy.fromfile(fp,self.struct,1)
119 82 self.size = header['nSize'][0]
120 83 self.numSamples = header['nNumSamples'][0]
121 84 self.numProfiles = header['nNumProfiles'][0]
122 85 self.numChannels = header['nNumChannels'][0]
123 86 self.adcResolution = header['nADCResolution'][0]
124 87 self.pciDioBusWidth = header['nPCDIOBusWidth'][0]
125 88
126 89
127 90 return 1
128 91
129 92 def copy(self):
130 93
131 94 obj = SystemHeader()
132 95 obj.size = self.size
133 96 obj.numSamples = self.numSamples
134 97 obj.numProfiles = self.numProfiles
135 98 obj.numChannels = self.numChannels
136 99 obj.adcResolution = self.adcResolution
137 100 self.pciDioBusWidth = self.pciDioBusWidth
138 101
139 102
140 103 return obj
141 104
142 105 class RadarControllerHeader:
143 106
144 107
145 108 def __init__(self):
146 109 self.size = 0
147 110 self.expType = 0
148 111 self.nTx = 0
149 112 self.ipp = 0
150 113 self.txA = 0
151 114 self.txB = 0
152 115 self.numWindows = 0
153 116 self.numTaus = 0
154 117 self.codeType = 0
155 118 self.line6Function = 0
156 119 self.line5Fuction = 0
157 120 self.fClock = 0
158 121 self.prePulseBefore = 0
159 122 self.prePulserAfter = 0
160 123 self.rangeIpp = 0
161 124 self.rangeTxA = 0
162 125 self.rangeTxB = 0
163 126 self.struct = numpy.dtype([
164 127 ('nSize','<u4'),
165 128 ('nExpType','<u4'),
166 129 ('nNTx','<u4'),
167 130 ('fIpp','<f4'),
168 131 ('fTxA','<f4'),
169 132 ('fTxB','<f4'),
170 133 ('nNumWindows','<u4'),
171 134 ('nNumTaus','<u4'),
172 135 ('nCodeType','<u4'),
173 136 ('nLine6Function','<u4'),
174 137 ('nLine5Function','<u4'),
175 138 ('fClock','<f4'),
176 139 ('nPrePulseBefore','<u4'),
177 140 ('nPrePulseAfter','<u4'),
178 141 ('sRangeIPP','<a20'),
179 142 ('sRangeTxA','<a20'),
180 143 ('sRangeTxB','<a20'),
181 144 ])
182 145
183 146
184 147 def read(self, fp):
185 148 header = numpy.fromfile(fp,self.struct,1)
186 149 self.size = header['nSize'][0]
187 150 self.expType = header['nExpType'][0]
188 151 self.nTx = header['nNTx'][0]
189 152 self.ipp = header['fIpp'][0]
190 153 self.txA = header['fTxA'][0]
191 154 self.txB = header['fTxB'][0]
192 155 self.numWindows = header['nNumWindows'][0]
193 156 self.numTaus = header['nNumTaus'][0]
194 157 self.codeType = header['nCodeType'][0]
195 158 self.line6Function = header['nLine6Function'][0]
196 159 self.line5Fuction = header['nLine5Function'][0]
197 160 self.fClock = header['fClock'][0]
198 161 self.prePulseBefore = header['nPrePulseBefore'][0]
199 162 self.prePulserAfter = header['nPrePulseAfter'][0]
200 163 self.rangeIpp = header['sRangeIPP'][0]
201 164 self.rangeTxA = header['sRangeTxA'][0]
202 165 self.rangeTxB = header['sRangeTxB'][0]
203 166 # jump Dynamic Radar Controller Header
204 167 jumpHeader = self.size - 116
205 168 fp.seek(fp.tell() + jumpHeader)
206 169
207 170 return 1
208 171
209 172 def copy(self):
210 173
211 174 obj = RadarControllerHeader()
212 175 obj.size = self.size
213 176 obj.expType = self.expType
214 177 obj.nTx = self.nTx
215 178 obj.ipp = self.ipp
216 179 obj.txA = self.txA
217 180 obj.txB = self.txB
218 181 obj.numWindows = self.numWindows
219 182 obj.numTaus = self.numTaus
220 183 obj.codeType = self.codeType
221 184 obj.line6Function = self.line6Function
222 185 obj.line5Fuction = self.line5Fuction
223 186 obj.fClock = self.fClock
224 187 obj.prePulseBefore = self.prePulseBefore
225 188 obj.prePulserAfter = self.prePulserAfter
226 189 obj.rangeIpp = self.rangeIpp
227 190 obj.rangeTxA = self.rangeTxA
228 191 obj.rangeTxB = self.rangeTxB
229 192
230 193 return obj
231 194
232 195 class ProcessingHeader:
233 196
234 197 def __init__(self):
235 198 self.size = 0
236 199 self.dataType = 0
237 200 self.blockSize = 0
238 201 self.profilesPerBlock = 0
239 202 self.dataBlocksPerFile = 0
240 203 self.numWindows = 0
241 204 self.processFlags = 0
242 205 self.coherentInt = 0
243 206 self.incoherentInt = 0
244 207 self.totalSpectra = 0
245 208 self.struct = numpy.dtype([
246 209 ('nSize','<u4'),
247 210 ('nDataType','<u4'),
248 211 ('nSizeOfDataBlock','<u4'),
249 212 ('nProfilesperBlock','<u4'),
250 213 ('nDataBlocksperFile','<u4'),
251 214 ('nNumWindows','<u4'),
252 215 ('nProcessFlags','<u4'),
253 216 ('nCoherentIntegrations','<u4'),
254 217 ('nIncoherentIntegrations','<u4'),
255 218 ('nTotalSpectra','<u4')
256 219 ])
257 220 self.samplingWindow = 0
258 221 self.structSamplingWindow = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')])
259 222 self.numHeights = 0
260 223 self.firstHeight = 0
261 224 self.deltaHeight = 0
262 225 self.samplesWin = 0
263 226 self.spectraComb = 0
264 227 self.numCode = 0
265 228 self.codes = 0
266 229 self.numBaud = 0
267 230
268 231 def read(self, fp):
269 232 header = numpy.fromfile(fp,self.struct,1)
270 233 self.size = header['nSize'][0]
271 234 self.dataType = header['nDataType'][0]
272 235 self.blockSize = header['nSizeOfDataBlock'][0]
273 236 self.profilesPerBlock = header['nProfilesperBlock'][0]
274 237 self.dataBlocksPerFile = header['nDataBlocksperFile'][0]
275 238 self.numWindows = header['nNumWindows'][0]
276 239 self.processFlags = header['nProcessFlags']
277 240 self.coherentInt = header['nCoherentIntegrations'][0]
278 241 self.incoherentInt = header['nIncoherentIntegrations'][0]
279 242 self.totalSpectra = header['nTotalSpectra'][0]
280 243 self.samplingWindow = numpy.fromfile(fp,self.structSamplingWindow,self.numWindows)
281 244 self.numHeights = numpy.sum(self.samplingWindow['nsa'])
282 245 self.firstHeight = self.samplingWindow['h0']
283 246 self.deltaHeight = self.samplingWindow['dh']
284 247 self.samplesWin = self.samplingWindow['nsa']
285 248 self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra)
286 249 if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE:
287 250 self.numCode = numpy.fromfile(fp,'<u4',1)
288 251 self.numBaud = numpy.fromfile(fp,'<u4',1)
289 252 self.codes = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode)
290 253
291 254
292 255 return 1
293 256
294 257 def copy(self):
295 258
296 259 obj = ProcessingHeader()
297 260 obj.size = self.size
298 261 obj.dataType = self.dataType
299 262 obj.blockSize = self.blockSize
300 263 obj.profilesPerBlock = self.profilesPerBlock
301 264 obj.dataBlocksPerFile = self.dataBlocksPerFile
302 265 obj.numWindows = self.numWindows
303 266 obj.processFlags = self.processFlags
304 267 obj.coherentInt = self.coherentInt
305 268 obj.incoherentInt = self.incoherentInt
306 269 obj.totalSpectra = self.totalSpectra
307 270 obj.samplingWindow = self.samplingWindow
308 271 obj.numHeights = self.numHeights
309 272 obj.firstHeight = self.firstHeight
310 273 obj.deltaHeight = self.deltaHeight
311 274 obj.samplesWin = self.samplesWin
312 275 obj.spectraComb = self.spectraComb
313 276 obj.numCode = self.numCode
314 277 obj.numBaud = self.numBaud
315 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
@@ -1,20 +1,20
1 1 '''
2 2 Created on 23/01/2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7
8 8 from Header import *
9 from Data import DataReader
10 from Data import DataWriter
9 from DataIO import DataReader
10 from DataIO import DataWriter
11 11
12 12
13 13 class SpectraReader(DataReader):
14 14 def __init__(self):
15 15 pass
16 16
17 17 class SpectraWriter(DataWriter):
18 18 def __init__(self):
19 19 pass
20 20
@@ -1,54 +1,61
1 1 '''
2 2 Created on Feb 7, 2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7 import os, sys
8 8
9 9 path = os.path.split(os.getcwd())[0]
10 10 sys.path.append(path)
11 11
12 12 from Model.Data import Data
13 from IO.Header import *
13 from IO.HeaderIO import *
14 14
15 15 class Voltage(Data):
16 16 '''
17 17 classdocs
18 18 '''
19
20
21 19
22
23
24 20 def __init__(self):
25 21 '''
26 22 Constructor
27 23 '''
28 24
29 25 self.m_RadarControllerHeader= RadarControllerHeader()
30
31 self.m_ProcessingHeader= ProcessingHeader()
32 26
27 self.m_ProcessingHeader= ProcessingHeader()
28
33 29 self.m_SystemHeader= SystemHeader()
34
30
35 31 self.m_BasicHeader= BasicHeader()
36 32
37 33 #data es un numpy array de 3 dmensiones (perfiles, alturas y canales)
38 34 self.data = None
39 35
40 self.dataType = None
36 self.heights = None
41 37
42 38 self.noData = True
43 39
40 self.nProfiles = None
41
42 self.idProfile = None
43
44 self.dataType = None
44 45
45
46 46 def copy(self):
47 47 obj = Voltage()
48 48 obj.m_BasicHeader = self.m_BasicHeader.copy()
49 49 obj.m_SystemHeader = self.m_SystemHeader.copy()
50 50 obj.m_RadarControllerHeader = self.m_RadarControllerHeader.copy()
51 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 60 return obj
54 61 No newline at end of file
1 NO CONTENT: file was removed
This diff has been collapsed as it changes many lines, (626 lines changed) Show them Hide them
General Comments 0
You need to be logged in to leave comments. Login now