@@ -1,93 +1,93 | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Form implementation generated from reading ui file '/home/roj-idl71/SignalChain/initwindowv2.ui' |
|
3 | # Form implementation generated from reading ui file '/home/roj-idl71/SignalChain/initwindowv2.ui' | |
4 | # |
|
4 | # | |
5 | # Created: Wed Mar 6 15:32:39 2013 |
|
5 | # Created: Wed Mar 6 15:32:39 2013 | |
6 | # by: PyQt4 UI code generator 4.8.6 |
|
6 | # by: PyQt4 UI code generator 4.8.6 | |
7 | # |
|
7 | # | |
8 | # WARNING! All changes made in this file will be lost! |
|
8 | # WARNING! All changes made in this file will be lost! | |
9 |
|
9 | |||
10 | from PyQt4 import QtCore, QtGui |
|
10 | from PyQt4 import QtCore, QtGui | |
11 |
|
11 | |||
12 | try: |
|
12 | try: | |
13 | _fromUtf8 = QtCore.QString.fromUtf8 |
|
13 | _fromUtf8 = QtCore.QString.fromUtf8 | |
14 | except AttributeError: |
|
14 | except AttributeError: | |
15 | _fromUtf8 = lambda s: s |
|
15 | _fromUtf8 = lambda s: s | |
16 |
|
16 | |||
17 | import os |
|
17 | import os | |
18 | from schainpy.gui.figures import tools |
|
18 | from schainpy.gui.figures import tools | |
19 |
|
19 | |||
20 | FIGURES_PATH = tools.get_path() |
|
20 | FIGURES_PATH = tools.get_path() | |
21 |
|
21 | |||
22 | class Ui_InitWindow(object): |
|
22 | class Ui_InitWindow(object): | |
23 | def setupUi(self, Dialog): |
|
23 | def setupUi(self, Dialog): | |
24 | Dialog.setObjectName(_fromUtf8("Dialog")) |
|
24 | Dialog.setObjectName(_fromUtf8("Dialog")) | |
25 | Dialog.resize(652, 496) |
|
25 | Dialog.resize(652, 496) | |
26 | Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) |
|
26 | Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) | |
27 | self.gridLayout = QtGui.QGridLayout(Dialog) |
|
27 | self.gridLayout = QtGui.QGridLayout(Dialog) | |
28 | self.gridLayout.setObjectName(_fromUtf8("gridLayout")) |
|
28 | self.gridLayout.setObjectName(_fromUtf8("gridLayout")) | |
29 | self.verticalLayout_3 = QtGui.QVBoxLayout() |
|
29 | self.verticalLayout_3 = QtGui.QVBoxLayout() | |
30 | self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) |
|
30 | self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) | |
31 | self.verticalLayout_4 = QtGui.QVBoxLayout() |
|
31 | self.verticalLayout_4 = QtGui.QVBoxLayout() | |
32 | self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4")) |
|
32 | self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4")) | |
33 | self.label_3 = QtGui.QLabel(Dialog) |
|
33 | self.label_3 = QtGui.QLabel(Dialog) | |
34 | font = QtGui.QFont() |
|
34 | font = QtGui.QFont() | |
35 | font.setFamily(_fromUtf8("Cambria")) |
|
35 | font.setFamily(_fromUtf8("Cambria")) | |
36 | font.setPointSize(22) |
|
36 | font.setPointSize(22) | |
37 | font.setBold(False) |
|
37 | font.setBold(False) | |
38 | font.setWeight(50) |
|
38 | font.setWeight(50) | |
39 | self.label_3.setFont(font) |
|
39 | self.label_3.setFont(font) | |
40 |
self.label_3.setText(QtGui.QApplication.translate("Dialog", "Signal Chain - Ver. |
|
40 | self.label_3.setText(QtGui.QApplication.translate("Dialog", "Signal Chain GUI - Ver. 2.0", None, QtGui.QApplication.UnicodeUTF8)) | |
41 | self.label_3.setObjectName(_fromUtf8("label_3")) |
|
41 | self.label_3.setObjectName(_fromUtf8("label_3")) | |
42 | self.verticalLayout_4.addWidget(self.label_3) |
|
42 | self.verticalLayout_4.addWidget(self.label_3) | |
43 | self.line_2 = QtGui.QFrame(Dialog) |
|
43 | self.line_2 = QtGui.QFrame(Dialog) | |
44 | self.line_2.setFrameShape(QtGui.QFrame.HLine) |
|
44 | self.line_2.setFrameShape(QtGui.QFrame.HLine) | |
45 | self.line_2.setFrameShadow(QtGui.QFrame.Sunken) |
|
45 | self.line_2.setFrameShadow(QtGui.QFrame.Sunken) | |
46 | self.line_2.setObjectName(_fromUtf8("line_2")) |
|
46 | self.line_2.setObjectName(_fromUtf8("line_2")) | |
47 | self.verticalLayout_4.addWidget(self.line_2) |
|
47 | self.verticalLayout_4.addWidget(self.line_2) | |
48 | self.label_4 = QtGui.QLabel(Dialog) |
|
48 | self.label_4 = QtGui.QLabel(Dialog) | |
49 | self.label_4.setText(_fromUtf8("")) |
|
49 | self.label_4.setText(_fromUtf8("")) | |
50 | self.label_4.setPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"w.jpg") ))) |
|
50 | self.label_4.setPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"w.jpg") ))) | |
51 | self.label_4.setScaledContents(True) |
|
51 | self.label_4.setScaledContents(True) | |
52 | self.label_4.setObjectName(_fromUtf8("label_4")) |
|
52 | self.label_4.setObjectName(_fromUtf8("label_4")) | |
53 | self.verticalLayout_4.addWidget(self.label_4) |
|
53 | self.verticalLayout_4.addWidget(self.label_4) | |
54 | self.verticalLayout_3.addLayout(self.verticalLayout_4) |
|
54 | self.verticalLayout_3.addLayout(self.verticalLayout_4) | |
55 | self.horizontalLayout_3 = QtGui.QHBoxLayout() |
|
55 | self.horizontalLayout_3 = QtGui.QHBoxLayout() | |
56 | self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) |
|
56 | self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) | |
57 | self.horizontalLayout_4 = QtGui.QHBoxLayout() |
|
57 | self.horizontalLayout_4 = QtGui.QHBoxLayout() | |
58 | self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) |
|
58 | self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) | |
59 | spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
59 | spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) | |
60 | self.horizontalLayout_4.addItem(spacerItem) |
|
60 | self.horizontalLayout_4.addItem(spacerItem) | |
61 | self.ExitBtn = QtGui.QPushButton(Dialog) |
|
61 | self.ExitBtn = QtGui.QPushButton(Dialog) | |
62 | self.ExitBtn.setText(QtGui.QApplication.translate("Dialog", "Exit", None, QtGui.QApplication.UnicodeUTF8)) |
|
62 | self.ExitBtn.setText(QtGui.QApplication.translate("Dialog", "Exit", None, QtGui.QApplication.UnicodeUTF8)) | |
63 | self.ExitBtn.setObjectName(_fromUtf8("ExitBtn")) |
|
63 | self.ExitBtn.setObjectName(_fromUtf8("ExitBtn")) | |
64 | self.horizontalLayout_4.addWidget(self.ExitBtn) |
|
64 | self.horizontalLayout_4.addWidget(self.ExitBtn) | |
65 | self.ContinueBtn = QtGui.QPushButton(Dialog) |
|
65 | self.ContinueBtn = QtGui.QPushButton(Dialog) | |
66 | self.ContinueBtn.setText(QtGui.QApplication.translate("Dialog", "Continue", None, QtGui.QApplication.UnicodeUTF8)) |
|
66 | self.ContinueBtn.setText(QtGui.QApplication.translate("Dialog", "Continue", None, QtGui.QApplication.UnicodeUTF8)) | |
67 | self.ContinueBtn.setObjectName(_fromUtf8("ContinueBtn")) |
|
67 | self.ContinueBtn.setObjectName(_fromUtf8("ContinueBtn")) | |
68 | self.horizontalLayout_4.addWidget(self.ContinueBtn) |
|
68 | self.horizontalLayout_4.addWidget(self.ContinueBtn) | |
69 | spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
|
69 | spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) | |
70 | self.horizontalLayout_4.addItem(spacerItem1) |
|
70 | self.horizontalLayout_4.addItem(spacerItem1) | |
71 | self.horizontalLayout_3.addLayout(self.horizontalLayout_4) |
|
71 | self.horizontalLayout_3.addLayout(self.horizontalLayout_4) | |
72 | self.verticalLayout_3.addLayout(self.horizontalLayout_3) |
|
72 | self.verticalLayout_3.addLayout(self.horizontalLayout_3) | |
73 | self.gridLayout.addLayout(self.verticalLayout_3, 0, 0, 1, 1) |
|
73 | self.gridLayout.addLayout(self.verticalLayout_3, 0, 0, 1, 1) | |
74 |
|
74 | |||
75 | self.retranslateUi(Dialog) |
|
75 | self.retranslateUi(Dialog) | |
76 | QtCore.QMetaObject.connectSlotsByName(Dialog) |
|
76 | QtCore.QMetaObject.connectSlotsByName(Dialog) | |
77 |
|
77 | |||
78 | def retranslateUi(self, Dialog): |
|
78 | def retranslateUi(self, Dialog): | |
79 | pass |
|
79 | pass | |
80 |
|
80 | |||
81 |
|
81 | |||
82 | if __name__ == "__main__": |
|
82 | if __name__ == "__main__": | |
83 | import sys |
|
83 | import sys | |
84 | app = QtGui.QApplication(sys.argv) |
|
84 | app = QtGui.QApplication(sys.argv) | |
85 | Dialog = QtGui.QDialog() |
|
85 | Dialog = QtGui.QDialog() | |
86 | ui = Ui_InitWindow() |
|
86 | ui = Ui_InitWindow() | |
87 | ui.setupUi(Dialog) |
|
87 | ui.setupUi(Dialog) | |
88 | Dialog.show() |
|
88 | Dialog.show() | |
89 | sys.exit(app.exec_()) |
|
89 | sys.exit(app.exec_()) | |
90 |
|
90 | |||
91 |
|
91 | |||
92 |
|
92 | |||
93 |
|
93 |
@@ -1,653 +1,653 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Jul 2, 2014 |
|
2 | Created on Jul 2, 2014 | |
3 |
|
3 | |||
4 | @author: roj-idl71 |
|
4 | @author: roj-idl71 | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import numpy |
|
7 | import numpy | |
8 |
|
8 | |||
9 | from jroIO_base import LOCALTIME, JRODataReader, JRODataWriter |
|
9 | from jroIO_base import LOCALTIME, JRODataReader, JRODataWriter | |
10 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
10 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation | |
11 | from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader |
|
11 | from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader | |
12 | from schainpy.model.data.jrodata import Voltage |
|
12 | from schainpy.model.data.jrodata import Voltage | |
13 |
|
13 | |||
14 | class VoltageReader(JRODataReader, ProcessingUnit): |
|
14 | class VoltageReader(JRODataReader, ProcessingUnit): | |
15 | """ |
|
15 | """ | |
16 | Esta clase permite leer datos de voltage desde archivos en formato rawdata (.r). La lectura |
|
16 | Esta clase permite leer datos de voltage desde archivos en formato rawdata (.r). La lectura | |
17 | de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones: |
|
17 | de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones: | |
18 | perfiles*alturas*canales) son almacenados en la variable "buffer". |
|
18 | perfiles*alturas*canales) son almacenados en la variable "buffer". | |
19 |
|
19 | |||
20 | perfiles * alturas * canales |
|
20 | perfiles * alturas * canales | |
21 |
|
21 | |||
22 | Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader, |
|
22 | Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader, | |
23 | RadarControllerHeader y Voltage. Los tres primeros se usan para almacenar informacion de la |
|
23 | RadarControllerHeader y Voltage. Los tres primeros se usan para almacenar informacion de la | |
24 | cabecera de datos (metadata), y el cuarto (Voltage) para obtener y almacenar un perfil de |
|
24 | cabecera de datos (metadata), y el cuarto (Voltage) para obtener y almacenar un perfil de | |
25 | datos desde el "buffer" cada vez que se ejecute el metodo "getData". |
|
25 | datos desde el "buffer" cada vez que se ejecute el metodo "getData". | |
26 |
|
26 | |||
27 | Example: |
|
27 | Example: | |
28 |
|
28 | |||
29 | dpath = "/home/myuser/data" |
|
29 | dpath = "/home/myuser/data" | |
30 |
|
30 | |||
31 | startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0) |
|
31 | startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0) | |
32 |
|
32 | |||
33 | endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0) |
|
33 | endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0) | |
34 |
|
34 | |||
35 | readerObj = VoltageReader() |
|
35 | readerObj = VoltageReader() | |
36 |
|
36 | |||
37 | readerObj.setup(dpath, startTime, endTime) |
|
37 | readerObj.setup(dpath, startTime, endTime) | |
38 |
|
38 | |||
39 | while(True): |
|
39 | while(True): | |
40 |
|
40 | |||
41 | #to get one profile |
|
41 | #to get one profile | |
42 | profile = readerObj.getData() |
|
42 | profile = readerObj.getData() | |
43 |
|
43 | |||
44 | #print the profile |
|
44 | #print the profile | |
45 | print profile |
|
45 | print profile | |
46 |
|
46 | |||
47 | #If you want to see all datablock |
|
47 | #If you want to see all datablock | |
48 | print readerObj.datablock |
|
48 | print readerObj.datablock | |
49 |
|
49 | |||
50 | if readerObj.flagNoMoreFiles: |
|
50 | if readerObj.flagNoMoreFiles: | |
51 | break |
|
51 | break | |
52 |
|
52 | |||
53 | """ |
|
53 | """ | |
54 |
|
54 | |||
55 | ext = ".r" |
|
55 | ext = ".r" | |
56 |
|
56 | |||
57 | optchar = "D" |
|
57 | optchar = "D" | |
58 | dataOut = None |
|
58 | dataOut = None | |
59 |
|
59 | |||
60 |
|
60 | |||
61 | def __init__(self): |
|
61 | def __init__(self): | |
62 | """ |
|
62 | """ | |
63 | Inicializador de la clase VoltageReader para la lectura de datos de voltage. |
|
63 | Inicializador de la clase VoltageReader para la lectura de datos de voltage. | |
64 |
|
64 | |||
65 | Input: |
|
65 | Input: | |
66 | dataOut : Objeto de la clase Voltage. Este objeto sera utilizado para |
|
66 | dataOut : Objeto de la clase Voltage. Este objeto sera utilizado para | |
67 | almacenar un perfil de datos cada vez que se haga un requerimiento |
|
67 | almacenar un perfil de datos cada vez que se haga un requerimiento | |
68 | (getData). El perfil sera obtenido a partir del buffer de datos, |
|
68 | (getData). El perfil sera obtenido a partir del buffer de datos, | |
69 | si el buffer esta vacio se hara un nuevo proceso de lectura de un |
|
69 | si el buffer esta vacio se hara un nuevo proceso de lectura de un | |
70 | bloque de datos. |
|
70 | bloque de datos. | |
71 | Si este parametro no es pasado se creara uno internamente. |
|
71 | Si este parametro no es pasado se creara uno internamente. | |
72 |
|
72 | |||
73 | Variables afectadas: |
|
73 | Variables afectadas: | |
74 | self.dataOut |
|
74 | self.dataOut | |
75 |
|
75 | |||
76 | Return: |
|
76 | Return: | |
77 | None |
|
77 | None | |
78 | """ |
|
78 | """ | |
79 |
|
79 | |||
80 | ProcessingUnit.__init__(self) |
|
80 | ProcessingUnit.__init__(self) | |
81 |
|
81 | |||
82 | self.isConfig = False |
|
82 | self.isConfig = False | |
83 |
|
83 | |||
84 | self.datablock = None |
|
84 | self.datablock = None | |
85 |
|
85 | |||
86 | self.utc = 0 |
|
86 | self.utc = 0 | |
87 |
|
87 | |||
88 | self.ext = ".r" |
|
88 | self.ext = ".r" | |
89 |
|
89 | |||
90 | self.optchar = "D" |
|
90 | self.optchar = "D" | |
91 |
|
91 | |||
92 | self.basicHeaderObj = BasicHeader(LOCALTIME) |
|
92 | self.basicHeaderObj = BasicHeader(LOCALTIME) | |
93 |
|
93 | |||
94 | self.systemHeaderObj = SystemHeader() |
|
94 | self.systemHeaderObj = SystemHeader() | |
95 |
|
95 | |||
96 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
96 | self.radarControllerHeaderObj = RadarControllerHeader() | |
97 |
|
97 | |||
98 | self.processingHeaderObj = ProcessingHeader() |
|
98 | self.processingHeaderObj = ProcessingHeader() | |
99 |
|
99 | |||
100 | self.online = 0 |
|
100 | self.online = 0 | |
101 |
|
101 | |||
102 | self.fp = None |
|
102 | self.fp = None | |
103 |
|
103 | |||
104 | self.idFile = None |
|
104 | self.idFile = None | |
105 |
|
105 | |||
106 | self.dtype = None |
|
106 | self.dtype = None | |
107 |
|
107 | |||
108 | self.fileSizeByHeader = None |
|
108 | self.fileSizeByHeader = None | |
109 |
|
109 | |||
110 | self.filenameList = [] |
|
110 | self.filenameList = [] | |
111 |
|
111 | |||
112 | self.filename = None |
|
112 | self.filename = None | |
113 |
|
113 | |||
114 | self.fileSize = None |
|
114 | self.fileSize = None | |
115 |
|
115 | |||
116 | self.firstHeaderSize = 0 |
|
116 | self.firstHeaderSize = 0 | |
117 |
|
117 | |||
118 | self.basicHeaderSize = 24 |
|
118 | self.basicHeaderSize = 24 | |
119 |
|
119 | |||
120 | self.pathList = [] |
|
120 | self.pathList = [] | |
121 |
|
121 | |||
122 | self.filenameList = [] |
|
122 | self.filenameList = [] | |
123 |
|
123 | |||
124 | self.lastUTTime = 0 |
|
124 | self.lastUTTime = 0 | |
125 |
|
125 | |||
126 | self.maxTimeStep = 30 |
|
126 | self.maxTimeStep = 30 | |
127 |
|
127 | |||
128 | self.flagNoMoreFiles = 0 |
|
128 | self.flagNoMoreFiles = 0 | |
129 |
|
129 | |||
130 | self.set = 0 |
|
130 | self.set = 0 | |
131 |
|
131 | |||
132 | self.path = None |
|
132 | self.path = None | |
133 |
|
133 | |||
134 | self.profileIndex = 2**32-1 |
|
134 | self.profileIndex = 2**32-1 | |
135 |
|
135 | |||
136 | self.delay = 3 #seconds |
|
136 | self.delay = 3 #seconds | |
137 |
|
137 | |||
138 | self.nTries = 3 #quantity tries |
|
138 | self.nTries = 3 #quantity tries | |
139 |
|
139 | |||
140 | self.nFiles = 3 #number of files for searching |
|
140 | self.nFiles = 3 #number of files for searching | |
141 |
|
141 | |||
142 | self.nReadBlocks = 0 |
|
142 | self.nReadBlocks = 0 | |
143 |
|
143 | |||
144 | self.flagIsNewFile = 1 |
|
144 | self.flagIsNewFile = 1 | |
145 |
|
145 | |||
146 | self.__isFirstTimeOnline = 1 |
|
146 | self.__isFirstTimeOnline = 1 | |
147 |
|
147 | |||
148 | # self.ippSeconds = 0 |
|
148 | # self.ippSeconds = 0 | |
149 |
|
149 | |||
150 | self.flagDiscontinuousBlock = 0 |
|
150 | self.flagDiscontinuousBlock = 0 | |
151 |
|
151 | |||
152 | self.flagIsNewBlock = 0 |
|
152 | self.flagIsNewBlock = 0 | |
153 |
|
153 | |||
154 | self.nTotalBlocks = 0 |
|
154 | self.nTotalBlocks = 0 | |
155 |
|
155 | |||
156 | self.blocksize = 0 |
|
156 | self.blocksize = 0 | |
157 |
|
157 | |||
158 | self.dataOut = self.createObjByDefault() |
|
158 | self.dataOut = self.createObjByDefault() | |
159 |
|
159 | |||
160 | self.nTxs = 1 |
|
160 | self.nTxs = 1 | |
161 |
|
161 | |||
162 | self.txIndex = 0 |
|
162 | self.txIndex = 0 | |
163 |
|
163 | |||
164 | def createObjByDefault(self): |
|
164 | def createObjByDefault(self): | |
165 |
|
165 | |||
166 | dataObj = Voltage() |
|
166 | dataObj = Voltage() | |
167 |
|
167 | |||
168 | return dataObj |
|
168 | return dataObj | |
169 |
|
169 | |||
170 | def __hasNotDataInBuffer(self): |
|
170 | def __hasNotDataInBuffer(self): | |
171 |
|
171 | |||
172 | if self.profileIndex >= self.processingHeaderObj.profilesPerBlock: |
|
172 | if self.profileIndex >= self.processingHeaderObj.profilesPerBlock: | |
173 | return 1 |
|
173 | return 1 | |
174 |
|
174 | |||
175 | return 0 |
|
175 | return 0 | |
176 |
|
176 | |||
177 |
|
177 | |||
178 | def getBlockDimension(self): |
|
178 | def getBlockDimension(self): | |
179 | """ |
|
179 | """ | |
180 | Obtiene la cantidad de puntos a leer por cada bloque de datos |
|
180 | Obtiene la cantidad de puntos a leer por cada bloque de datos | |
181 |
|
181 | |||
182 | Affected: |
|
182 | Affected: | |
183 | self.blocksize |
|
183 | self.blocksize | |
184 |
|
184 | |||
185 | Return: |
|
185 | Return: | |
186 | None |
|
186 | None | |
187 | """ |
|
187 | """ | |
188 | pts2read = self.processingHeaderObj.profilesPerBlock * self.processingHeaderObj.nHeights * self.systemHeaderObj.nChannels |
|
188 | pts2read = self.processingHeaderObj.profilesPerBlock * self.processingHeaderObj.nHeights * self.systemHeaderObj.nChannels | |
189 | self.blocksize = pts2read |
|
189 | self.blocksize = pts2read | |
190 |
|
190 | |||
191 |
|
191 | |||
192 | def readBlock(self): |
|
192 | def readBlock(self): | |
193 | """ |
|
193 | """ | |
194 | readBlock lee el bloque de datos desde la posicion actual del puntero del archivo |
|
194 | readBlock lee el bloque de datos desde la posicion actual del puntero del archivo | |
195 | (self.fp) y actualiza todos los parametros relacionados al bloque de datos |
|
195 | (self.fp) y actualiza todos los parametros relacionados al bloque de datos | |
196 | (metadata + data). La data leida es almacenada en el buffer y el contador del buffer |
|
196 | (metadata + data). La data leida es almacenada en el buffer y el contador del buffer | |
197 | es seteado a 0 |
|
197 | es seteado a 0 | |
198 |
|
198 | |||
199 | Inputs: |
|
199 | Inputs: | |
200 | None |
|
200 | None | |
201 |
|
201 | |||
202 | Return: |
|
202 | Return: | |
203 | None |
|
203 | None | |
204 |
|
204 | |||
205 | Affected: |
|
205 | Affected: | |
206 | self.profileIndex |
|
206 | self.profileIndex | |
207 | self.datablock |
|
207 | self.datablock | |
208 | self.flagIsNewFile |
|
208 | self.flagIsNewFile | |
209 | self.flagIsNewBlock |
|
209 | self.flagIsNewBlock | |
210 | self.nTotalBlocks |
|
210 | self.nTotalBlocks | |
211 |
|
211 | |||
212 | Exceptions: |
|
212 | Exceptions: | |
213 | Si un bloque leido no es un bloque valido |
|
213 | Si un bloque leido no es un bloque valido | |
214 | """ |
|
214 | """ | |
215 | current_pointer_location = self.fp.tell() |
|
215 | current_pointer_location = self.fp.tell() | |
216 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) |
|
216 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) | |
217 |
|
217 | |||
218 | try: |
|
218 | try: | |
219 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) |
|
219 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) | |
220 | except: |
|
220 | except: | |
221 | #print "The read block (%3d) has not enough data" %self.nReadBlocks |
|
221 | #print "The read block (%3d) has not enough data" %self.nReadBlocks | |
222 |
|
222 | |||
223 | if self.waitDataBlock(pointer_location=current_pointer_location): |
|
223 | if self.waitDataBlock(pointer_location=current_pointer_location): | |
224 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) |
|
224 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) | |
225 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) |
|
225 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) | |
226 | # return 0 |
|
226 | # return 0 | |
227 |
|
227 | |||
228 | junk = numpy.transpose(junk, (2,0,1)) |
|
228 | junk = numpy.transpose(junk, (2,0,1)) | |
229 | self.datablock = junk['real'] + junk['imag']*1j |
|
229 | self.datablock = junk['real'] + junk['imag']*1j | |
230 |
|
230 | |||
231 | self.profileIndex = 0 |
|
231 | self.profileIndex = 0 | |
232 |
|
232 | |||
233 | self.flagIsNewFile = 0 |
|
233 | self.flagIsNewFile = 0 | |
234 | self.flagIsNewBlock = 1 |
|
234 | self.flagIsNewBlock = 1 | |
235 |
|
235 | |||
236 | self.nTotalBlocks += 1 |
|
236 | self.nTotalBlocks += 1 | |
237 | self.nReadBlocks += 1 |
|
237 | self.nReadBlocks += 1 | |
238 |
|
238 | |||
239 | return 1 |
|
239 | return 1 | |
240 |
|
240 | |||
241 | def getFirstHeader(self): |
|
241 | def getFirstHeader(self): | |
242 |
|
242 | |||
243 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() |
|
243 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() | |
244 |
|
244 | |||
245 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() |
|
245 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() | |
246 |
|
246 | |||
247 | if self.nTxs > 1: |
|
247 | if self.nTxs > 1: | |
248 | self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs |
|
248 | self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs | |
249 |
|
249 | |||
250 | # self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt |
|
250 | # self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt | |
251 | # |
|
251 | # | |
252 | # if self.radarControllerHeaderObj.code != None: |
|
252 | # if self.radarControllerHeaderObj.code != None: | |
253 | # |
|
253 | # | |
254 | # self.dataOut.nCode = self.radarControllerHeaderObj.nCode |
|
254 | # self.dataOut.nCode = self.radarControllerHeaderObj.nCode | |
255 | # |
|
255 | # | |
256 | # self.dataOut.nBaud = self.radarControllerHeaderObj.nBaud |
|
256 | # self.dataOut.nBaud = self.radarControllerHeaderObj.nBaud | |
257 | # |
|
257 | # | |
258 | # self.dataOut.code = self.radarControllerHeaderObj.code |
|
258 | # self.dataOut.code = self.radarControllerHeaderObj.code | |
259 |
|
259 | |||
260 | self.dataOut.dtype = self.dtype |
|
260 | self.dataOut.dtype = self.dtype | |
261 |
|
261 | |||
262 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs |
|
262 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs | |
263 |
|
263 | |||
264 | if self.processingHeaderObj.nHeights % self.nTxs != 0: |
|
264 | if self.processingHeaderObj.nHeights % self.nTxs != 0: | |
265 | raise ValueError, "nTxs (%d) should be a multiple of nHeights (%d)" %(self.nTxs, self.processingHeaderObj.nHeights) |
|
265 | raise ValueError, "nTxs (%d) should be a multiple of nHeights (%d)" %(self.nTxs, self.processingHeaderObj.nHeights) | |
266 |
|
266 | |||
267 | xf = self.processingHeaderObj.firstHeight + int(self.processingHeaderObj.nHeights/self.nTxs)*self.processingHeaderObj.deltaHeight |
|
267 | xf = self.processingHeaderObj.firstHeight + int(self.processingHeaderObj.nHeights/self.nTxs)*self.processingHeaderObj.deltaHeight | |
268 |
|
268 | |||
269 | self.dataOut.heightList = numpy.arange(self.processingHeaderObj.firstHeight, xf, self.processingHeaderObj.deltaHeight) |
|
269 | self.dataOut.heightList = numpy.arange(self.processingHeaderObj.firstHeight, xf, self.processingHeaderObj.deltaHeight) | |
270 |
|
270 | |||
271 | self.dataOut.channelList = range(self.systemHeaderObj.nChannels) |
|
271 | self.dataOut.channelList = range(self.systemHeaderObj.nChannels) | |
272 |
|
272 | |||
273 | self.dataOut.nCohInt = self.processingHeaderObj.nCohInt |
|
273 | self.dataOut.nCohInt = self.processingHeaderObj.nCohInt | |
274 |
|
274 | |||
275 | self.dataOut.flagShiftFFT = False |
|
275 | self.dataOut.flagShiftFFT = False | |
276 |
|
276 | |||
277 | self.dataOut.flagDecodeData = False #asumo q la data no esta decodificada |
|
277 | self.dataOut.flagDecodeData = False #asumo q la data no esta decodificada | |
278 |
|
278 | |||
279 | self.dataOut.flagDeflipData = False #asumo q la data no esta sin flip |
|
279 | self.dataOut.flagDeflipData = False #asumo q la data no esta sin flip | |
280 |
|
280 | |||
281 | self.dataOut.flagShiftFFT = False |
|
281 | self.dataOut.flagShiftFFT = False | |
282 |
|
282 | |||
283 | def getData(self): |
|
283 | def getData(self): | |
284 | """ |
|
284 | """ | |
285 | getData obtiene una unidad de datos del buffer de lectura, un perfil, y la copia al objeto self.dataOut |
|
285 | getData obtiene una unidad de datos del buffer de lectura, un perfil, y la copia al objeto self.dataOut | |
286 | del tipo "Voltage" con todos los parametros asociados a este (metadata). cuando no hay datos |
|
286 | del tipo "Voltage" con todos los parametros asociados a este (metadata). cuando no hay datos | |
287 | en el buffer de lectura es necesario hacer una nueva lectura de los bloques de datos usando |
|
287 | en el buffer de lectura es necesario hacer una nueva lectura de los bloques de datos usando | |
288 | "readNextBlock" |
|
288 | "readNextBlock" | |
289 |
|
289 | |||
290 | Ademas incrementa el contador del buffer "self.profileIndex" en 1. |
|
290 | Ademas incrementa el contador del buffer "self.profileIndex" en 1. | |
291 |
|
291 | |||
292 | Return: |
|
292 | Return: | |
293 |
|
293 | |||
294 | Si el flag self.getByBlock ha sido seteado el bloque completo es copiado a self.dataOut y el self.profileIndex |
|
294 | Si el flag self.getByBlock ha sido seteado el bloque completo es copiado a self.dataOut y el self.profileIndex | |
295 | es igual al total de perfiles leidos desde el archivo. |
|
295 | es igual al total de perfiles leidos desde el archivo. | |
296 |
|
296 | |||
297 | Si self.getByBlock == False: |
|
297 | Si self.getByBlock == False: | |
298 |
|
298 | |||
299 | self.dataOut.data = buffer[:, thisProfile, :] |
|
299 | self.dataOut.data = buffer[:, thisProfile, :] | |
300 |
|
300 | |||
301 | shape = [nChannels, nHeis] |
|
301 | shape = [nChannels, nHeis] | |
302 |
|
302 | |||
303 | Si self.getByBlock == True: |
|
303 | Si self.getByBlock == True: | |
304 |
|
304 | |||
305 | self.dataOut.data = buffer[:, :, :] |
|
305 | self.dataOut.data = buffer[:, :, :] | |
306 |
|
306 | |||
307 | shape = [nChannels, nProfiles, nHeis] |
|
307 | shape = [nChannels, nProfiles, nHeis] | |
308 |
|
308 | |||
309 | Variables afectadas: |
|
309 | Variables afectadas: | |
310 | self.dataOut |
|
310 | self.dataOut | |
311 | self.profileIndex |
|
311 | self.profileIndex | |
312 |
|
312 | |||
313 | Affected: |
|
313 | Affected: | |
314 | self.dataOut |
|
314 | self.dataOut | |
315 | self.profileIndex |
|
315 | self.profileIndex | |
316 | self.flagDiscontinuousBlock |
|
316 | self.flagDiscontinuousBlock | |
317 | self.flagIsNewBlock |
|
317 | self.flagIsNewBlock | |
318 | """ |
|
318 | """ | |
319 |
|
319 | |||
320 | if self.flagNoMoreFiles: |
|
320 | if self.flagNoMoreFiles: | |
321 | self.dataOut.flagNoData = True |
|
321 | self.dataOut.flagNoData = True | |
322 | print 'Process finished' |
|
322 | print 'Process finished' | |
323 | return 0 |
|
323 | return 0 | |
324 |
|
324 | |||
325 | self.flagDiscontinuousBlock = 0 |
|
325 | self.flagDiscontinuousBlock = 0 | |
326 | self.flagIsNewBlock = 0 |
|
326 | self.flagIsNewBlock = 0 | |
327 |
|
327 | |||
328 | if self.__hasNotDataInBuffer(): |
|
328 | if self.__hasNotDataInBuffer(): | |
329 |
|
329 | |||
330 | if not( self.readNextBlock() ): |
|
330 | if not( self.readNextBlock() ): | |
331 | return 0 |
|
331 | return 0 | |
332 |
|
332 | |||
333 | self.getFirstHeader() |
|
333 | self.getFirstHeader() | |
334 |
|
334 | |||
335 | if self.datablock == None: |
|
335 | if self.datablock == None: | |
336 | self.dataOut.flagNoData = True |
|
336 | self.dataOut.flagNoData = True | |
337 | return 0 |
|
337 | return 0 | |
338 |
|
338 | |||
339 | if not self.getByBlock: |
|
339 | if not self.getByBlock: | |
340 |
|
340 | |||
341 | """ |
|
341 | """ | |
342 | Return profile by profile |
|
342 | Return profile by profile | |
343 |
|
343 | |||
344 | If nTxs > 1 then one profile is divided by nTxs and number of total |
|
344 | If nTxs > 1 then one profile is divided by nTxs and number of total | |
345 | blocks is increased by nTxs (nProfiles *= nTxs) |
|
345 | blocks is increased by nTxs (nProfiles *= nTxs) | |
346 | """ |
|
346 | """ | |
347 | if self.nTxs == 1: |
|
347 | if self.nTxs == 1: | |
348 | self.dataOut.flagDataAsBlock = False |
|
348 | self.dataOut.flagDataAsBlock = False | |
349 | self.dataOut.data = self.datablock[:,self.profileIndex,:] |
|
349 | self.dataOut.data = self.datablock[:,self.profileIndex,:] | |
350 | self.dataOut.profileIndex = self.profileIndex |
|
350 | self.dataOut.profileIndex = self.profileIndex | |
351 |
|
351 | |||
352 | self.profileIndex += 1 |
|
352 | self.profileIndex += 1 | |
353 |
|
353 | |||
354 | else: |
|
354 | else: | |
355 | self.dataOut.flagDataAsBlock = False |
|
355 | self.dataOut.flagDataAsBlock = False | |
356 |
|
356 | |||
357 | iniHei_ForThisTx = (self.txIndex)*int(self.processingHeaderObj.nHeights/self.nTxs) |
|
357 | iniHei_ForThisTx = (self.txIndex)*int(self.processingHeaderObj.nHeights/self.nTxs) | |
358 | endHei_ForThisTx = (self.txIndex+1)*int(self.processingHeaderObj.nHeights/self.nTxs) |
|
358 | endHei_ForThisTx = (self.txIndex+1)*int(self.processingHeaderObj.nHeights/self.nTxs) | |
359 |
|
359 | |||
360 | # print iniHei_ForThisTx, endHei_ForThisTx |
|
360 | # print iniHei_ForThisTx, endHei_ForThisTx | |
361 |
|
361 | |||
362 | self.dataOut.data = self.datablock[:, self.profileIndex, iniHei_ForThisTx:endHei_ForThisTx] |
|
362 | self.dataOut.data = self.datablock[:, self.profileIndex, iniHei_ForThisTx:endHei_ForThisTx] | |
363 | self.dataOut.profileIndex = self.profileIndex*self.nTxs + self.txIndex |
|
363 | self.dataOut.profileIndex = self.profileIndex*self.nTxs + self.txIndex | |
364 |
|
364 | |||
365 | self.txIndex += 1 |
|
365 | self.txIndex += 1 | |
366 |
|
366 | |||
367 | if self.txIndex == self.nTxs: |
|
367 | if self.txIndex == self.nTxs: | |
368 | self.txIndex = 0 |
|
368 | self.txIndex = 0 | |
369 | self.profileIndex += 1 |
|
369 | self.profileIndex += 1 | |
370 |
|
370 | |||
371 | else: |
|
371 | else: | |
372 | """ |
|
372 | """ | |
373 | Return all block |
|
373 | Return all block | |
374 | """ |
|
374 | """ | |
375 | self.dataOut.flagDataAsBlock = True |
|
375 | self.dataOut.flagDataAsBlock = True | |
376 | self.dataOut.data = self.datablock |
|
376 | self.dataOut.data = self.datablock | |
377 | self.dataOut.profileIndex = self.processingHeaderObj.profilesPerBlock - 1 |
|
377 | self.dataOut.profileIndex = self.processingHeaderObj.profilesPerBlock - 1 | |
378 |
|
378 | |||
379 | self.profileIndex = self.processingHeaderObj.profilesPerBlock - 1 |
|
379 | self.profileIndex = self.processingHeaderObj.profilesPerBlock - 1 | |
380 |
|
380 | |||
381 | self.dataOut.flagNoData = False |
|
381 | self.dataOut.flagNoData = False | |
382 |
|
382 | |||
383 | self.getBasicHeader() |
|
383 | self.getBasicHeader() | |
384 |
|
384 | |||
385 | self.dataOut.realtime = self.online |
|
385 | self.dataOut.realtime = self.online | |
386 |
|
386 | |||
387 | return self.dataOut.data |
|
387 | return self.dataOut.data | |
388 |
|
388 | |||
389 | class VoltageWriter(JRODataWriter, Operation): |
|
389 | class VoltageWriter(JRODataWriter, Operation): | |
390 | """ |
|
390 | """ | |
391 | Esta clase permite escribir datos de voltajes a archivos procesados (.r). La escritura |
|
391 | Esta clase permite escribir datos de voltajes a archivos procesados (.r). La escritura | |
392 | de los datos siempre se realiza por bloques. |
|
392 | de los datos siempre se realiza por bloques. | |
393 | """ |
|
393 | """ | |
394 |
|
394 | |||
395 | ext = ".r" |
|
395 | ext = ".r" | |
396 |
|
396 | |||
397 | optchar = "D" |
|
397 | optchar = "D" | |
398 |
|
398 | |||
399 | shapeBuffer = None |
|
399 | shapeBuffer = None | |
400 |
|
400 | |||
401 |
|
401 | |||
402 | def __init__(self): |
|
402 | def __init__(self): | |
403 | """ |
|
403 | """ | |
404 | Inicializador de la clase VoltageWriter para la escritura de datos de espectros. |
|
404 | Inicializador de la clase VoltageWriter para la escritura de datos de espectros. | |
405 |
|
405 | |||
406 | Affected: |
|
406 | Affected: | |
407 | self.dataOut |
|
407 | self.dataOut | |
408 |
|
408 | |||
409 | Return: None |
|
409 | Return: None | |
410 | """ |
|
410 | """ | |
411 | Operation.__init__(self) |
|
411 | Operation.__init__(self) | |
412 |
|
412 | |||
413 | self.nTotalBlocks = 0 |
|
413 | self.nTotalBlocks = 0 | |
414 |
|
414 | |||
415 | self.profileIndex = 0 |
|
415 | self.profileIndex = 0 | |
416 |
|
416 | |||
417 | self.isConfig = False |
|
417 | self.isConfig = False | |
418 |
|
418 | |||
419 | self.fp = None |
|
419 | self.fp = None | |
420 |
|
420 | |||
421 | self.flagIsNewFile = 1 |
|
421 | self.flagIsNewFile = 1 | |
422 |
|
422 | |||
423 | self.nTotalBlocks = 0 |
|
423 | self.nTotalBlocks = 0 | |
424 |
|
424 | |||
425 | self.flagIsNewBlock = 0 |
|
425 | self.flagIsNewBlock = 0 | |
426 |
|
426 | |||
427 | self.setFile = None |
|
427 | self.setFile = None | |
428 |
|
428 | |||
429 | self.dtype = None |
|
429 | self.dtype = None | |
430 |
|
430 | |||
431 | self.path = None |
|
431 | self.path = None | |
432 |
|
432 | |||
433 | self.filename = None |
|
433 | self.filename = None | |
434 |
|
434 | |||
435 | self.basicHeaderObj = BasicHeader(LOCALTIME) |
|
435 | self.basicHeaderObj = BasicHeader(LOCALTIME) | |
436 |
|
436 | |||
437 | self.systemHeaderObj = SystemHeader() |
|
437 | self.systemHeaderObj = SystemHeader() | |
438 |
|
438 | |||
439 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
439 | self.radarControllerHeaderObj = RadarControllerHeader() | |
440 |
|
440 | |||
441 | self.processingHeaderObj = ProcessingHeader() |
|
441 | self.processingHeaderObj = ProcessingHeader() | |
442 |
|
442 | |||
443 | def hasAllDataInBuffer(self): |
|
443 | def hasAllDataInBuffer(self): | |
444 | if self.profileIndex >= self.processingHeaderObj.profilesPerBlock: |
|
444 | if self.profileIndex >= self.processingHeaderObj.profilesPerBlock: | |
445 | return 1 |
|
445 | return 1 | |
446 | return 0 |
|
446 | return 0 | |
447 |
|
447 | |||
448 |
|
448 | |||
449 | def setBlockDimension(self): |
|
449 | def setBlockDimension(self): | |
450 | """ |
|
450 | """ | |
451 | Obtiene las formas dimensionales del los subbloques de datos que componen un bloque |
|
451 | Obtiene las formas dimensionales del los subbloques de datos que componen un bloque | |
452 |
|
452 | |||
453 | Affected: |
|
453 | Affected: | |
454 | self.shape_spc_Buffer |
|
454 | self.shape_spc_Buffer | |
455 | self.shape_cspc_Buffer |
|
455 | self.shape_cspc_Buffer | |
456 | self.shape_dc_Buffer |
|
456 | self.shape_dc_Buffer | |
457 |
|
457 | |||
458 | Return: None |
|
458 | Return: None | |
459 | """ |
|
459 | """ | |
460 | self.shapeBuffer = (self.processingHeaderObj.profilesPerBlock, |
|
460 | self.shapeBuffer = (self.processingHeaderObj.profilesPerBlock, | |
461 | self.processingHeaderObj.nHeights, |
|
461 | self.processingHeaderObj.nHeights, | |
462 | self.systemHeaderObj.nChannels) |
|
462 | self.systemHeaderObj.nChannels) | |
463 |
|
463 | |||
464 | self.datablock = numpy.zeros((self.systemHeaderObj.nChannels, |
|
464 | self.datablock = numpy.zeros((self.systemHeaderObj.nChannels, | |
465 | self.processingHeaderObj.profilesPerBlock, |
|
465 | self.processingHeaderObj.profilesPerBlock, | |
466 | self.processingHeaderObj.nHeights), |
|
466 | self.processingHeaderObj.nHeights), | |
467 | dtype=numpy.dtype('complex64')) |
|
467 | dtype=numpy.dtype('complex64')) | |
468 |
|
468 | |||
469 | def writeBlock(self): |
|
469 | def writeBlock(self): | |
470 | """ |
|
470 | """ | |
471 | Escribe el buffer en el file designado |
|
471 | Escribe el buffer en el file designado | |
472 |
|
472 | |||
473 | Affected: |
|
473 | Affected: | |
474 | self.profileIndex |
|
474 | self.profileIndex | |
475 | self.flagIsNewFile |
|
475 | self.flagIsNewFile | |
476 | self.flagIsNewBlock |
|
476 | self.flagIsNewBlock | |
477 | self.nTotalBlocks |
|
477 | self.nTotalBlocks | |
478 | self.blockIndex |
|
478 | self.blockIndex | |
479 |
|
479 | |||
480 | Return: None |
|
480 | Return: None | |
481 | """ |
|
481 | """ | |
482 | data = numpy.zeros( self.shapeBuffer, self.dtype ) |
|
482 | data = numpy.zeros( self.shapeBuffer, self.dtype ) | |
483 |
|
483 | |||
484 | junk = numpy.transpose(self.datablock, (1,2,0)) |
|
484 | junk = numpy.transpose(self.datablock, (1,2,0)) | |
485 |
|
485 | |||
486 | data['real'] = junk.real |
|
486 | data['real'] = junk.real | |
487 | data['imag'] = junk.imag |
|
487 | data['imag'] = junk.imag | |
488 |
|
488 | |||
489 | data = data.reshape( (-1) ) |
|
489 | data = data.reshape( (-1) ) | |
490 |
|
490 | |||
491 | data.tofile( self.fp ) |
|
491 | data.tofile( self.fp ) | |
492 |
|
492 | |||
493 | self.datablock.fill(0) |
|
493 | self.datablock.fill(0) | |
494 |
|
494 | |||
495 | self.profileIndex = 0 |
|
495 | self.profileIndex = 0 | |
496 | self.flagIsNewFile = 0 |
|
496 | self.flagIsNewFile = 0 | |
497 | self.flagIsNewBlock = 1 |
|
497 | self.flagIsNewBlock = 1 | |
498 |
|
498 | |||
499 | self.blockIndex += 1 |
|
499 | self.blockIndex += 1 | |
500 | self.nTotalBlocks += 1 |
|
500 | self.nTotalBlocks += 1 | |
501 |
|
501 | |||
502 |
print "[Writing] Block = " |
|
502 | # print "[Writing] Block = %04d" %self.blockIndex | |
503 |
|
503 | |||
504 | def putData(self): |
|
504 | def putData(self): | |
505 | """ |
|
505 | """ | |
506 | Setea un bloque de datos y luego los escribe en un file |
|
506 | Setea un bloque de datos y luego los escribe en un file | |
507 |
|
507 | |||
508 | Affected: |
|
508 | Affected: | |
509 | self.flagIsNewBlock |
|
509 | self.flagIsNewBlock | |
510 | self.profileIndex |
|
510 | self.profileIndex | |
511 |
|
511 | |||
512 | Return: |
|
512 | Return: | |
513 | 0 : Si no hay data o no hay mas files que puedan escribirse |
|
513 | 0 : Si no hay data o no hay mas files que puedan escribirse | |
514 | 1 : Si se escribio la data de un bloque en un file |
|
514 | 1 : Si se escribio la data de un bloque en un file | |
515 | """ |
|
515 | """ | |
516 | if self.dataOut.flagNoData: |
|
516 | if self.dataOut.flagNoData: | |
517 | return 0 |
|
517 | return 0 | |
518 |
|
518 | |||
519 | self.flagIsNewBlock = 0 |
|
519 | self.flagIsNewBlock = 0 | |
520 |
|
520 | |||
521 | if self.dataOut.flagDiscontinuousBlock: |
|
521 | if self.dataOut.flagDiscontinuousBlock: | |
522 | self.datablock.fill(0) |
|
522 | self.datablock.fill(0) | |
523 | self.profileIndex = 0 |
|
523 | self.profileIndex = 0 | |
524 | self.setNextFile() |
|
524 | self.setNextFile() | |
525 |
|
525 | |||
526 | if self.profileIndex == 0: |
|
526 | if self.profileIndex == 0: | |
527 | self.setBasicHeader() |
|
527 | self.setBasicHeader() | |
528 |
|
528 | |||
529 | self.datablock[:,self.profileIndex,:] = self.dataOut.data |
|
529 | self.datablock[:,self.profileIndex,:] = self.dataOut.data | |
530 |
|
530 | |||
531 | self.profileIndex += 1 |
|
531 | self.profileIndex += 1 | |
532 |
|
532 | |||
533 | if self.hasAllDataInBuffer(): |
|
533 | if self.hasAllDataInBuffer(): | |
534 | #if self.flagIsNewFile: |
|
534 | #if self.flagIsNewFile: | |
535 | self.writeNextBlock() |
|
535 | self.writeNextBlock() | |
536 | # self.setFirstHeader() |
|
536 | # self.setFirstHeader() | |
537 |
|
537 | |||
538 | return 1 |
|
538 | return 1 | |
539 |
|
539 | |||
540 | def __getProcessFlags(self): |
|
540 | def __getProcessFlags(self): | |
541 |
|
541 | |||
542 | processFlags = 0 |
|
542 | processFlags = 0 | |
543 |
|
543 | |||
544 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
544 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
545 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
545 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
546 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
546 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
547 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
547 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
548 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
548 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
549 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
549 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
550 |
|
550 | |||
551 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] |
|
551 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
552 |
|
552 | |||
553 |
|
553 | |||
554 |
|
554 | |||
555 | datatypeValueList = [PROCFLAG.DATATYPE_CHAR, |
|
555 | datatypeValueList = [PROCFLAG.DATATYPE_CHAR, | |
556 | PROCFLAG.DATATYPE_SHORT, |
|
556 | PROCFLAG.DATATYPE_SHORT, | |
557 | PROCFLAG.DATATYPE_LONG, |
|
557 | PROCFLAG.DATATYPE_LONG, | |
558 | PROCFLAG.DATATYPE_INT64, |
|
558 | PROCFLAG.DATATYPE_INT64, | |
559 | PROCFLAG.DATATYPE_FLOAT, |
|
559 | PROCFLAG.DATATYPE_FLOAT, | |
560 | PROCFLAG.DATATYPE_DOUBLE] |
|
560 | PROCFLAG.DATATYPE_DOUBLE] | |
561 |
|
561 | |||
562 |
|
562 | |||
563 | for index in range(len(dtypeList)): |
|
563 | for index in range(len(dtypeList)): | |
564 | if self.dataOut.dtype == dtypeList[index]: |
|
564 | if self.dataOut.dtype == dtypeList[index]: | |
565 | dtypeValue = datatypeValueList[index] |
|
565 | dtypeValue = datatypeValueList[index] | |
566 | break |
|
566 | break | |
567 |
|
567 | |||
568 | processFlags += dtypeValue |
|
568 | processFlags += dtypeValue | |
569 |
|
569 | |||
570 | if self.dataOut.flagDecodeData: |
|
570 | if self.dataOut.flagDecodeData: | |
571 | processFlags += PROCFLAG.DECODE_DATA |
|
571 | processFlags += PROCFLAG.DECODE_DATA | |
572 |
|
572 | |||
573 | if self.dataOut.flagDeflipData: |
|
573 | if self.dataOut.flagDeflipData: | |
574 | processFlags += PROCFLAG.DEFLIP_DATA |
|
574 | processFlags += PROCFLAG.DEFLIP_DATA | |
575 |
|
575 | |||
576 | if self.dataOut.code != None: |
|
576 | if self.dataOut.code != None: | |
577 | processFlags += PROCFLAG.DEFINE_PROCESS_CODE |
|
577 | processFlags += PROCFLAG.DEFINE_PROCESS_CODE | |
578 |
|
578 | |||
579 | if self.dataOut.nCohInt > 1: |
|
579 | if self.dataOut.nCohInt > 1: | |
580 | processFlags += PROCFLAG.COHERENT_INTEGRATION |
|
580 | processFlags += PROCFLAG.COHERENT_INTEGRATION | |
581 |
|
581 | |||
582 | return processFlags |
|
582 | return processFlags | |
583 |
|
583 | |||
584 |
|
584 | |||
585 | def __getBlockSize(self): |
|
585 | def __getBlockSize(self): | |
586 | ''' |
|
586 | ''' | |
587 | Este metodos determina el cantidad de bytes para un bloque de datos de tipo Voltage |
|
587 | Este metodos determina el cantidad de bytes para un bloque de datos de tipo Voltage | |
588 | ''' |
|
588 | ''' | |
589 |
|
589 | |||
590 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
590 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
591 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
591 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
592 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
592 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
593 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
593 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
594 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
594 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
595 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
595 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
596 |
|
596 | |||
597 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] |
|
597 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
598 | datatypeValueList = [1,2,4,8,4,8] |
|
598 | datatypeValueList = [1,2,4,8,4,8] | |
599 | for index in range(len(dtypeList)): |
|
599 | for index in range(len(dtypeList)): | |
600 | if self.dataOut.dtype == dtypeList[index]: |
|
600 | if self.dataOut.dtype == dtypeList[index]: | |
601 | datatypeValue = datatypeValueList[index] |
|
601 | datatypeValue = datatypeValueList[index] | |
602 | break |
|
602 | break | |
603 |
|
603 | |||
604 | blocksize = int(self.dataOut.nHeights * self.dataOut.nChannels * self.profilesPerBlock * datatypeValue * 2) |
|
604 | blocksize = int(self.dataOut.nHeights * self.dataOut.nChannels * self.profilesPerBlock * datatypeValue * 2) | |
605 |
|
605 | |||
606 | return blocksize |
|
606 | return blocksize | |
607 |
|
607 | |||
608 | def setFirstHeader(self): |
|
608 | def setFirstHeader(self): | |
609 |
|
609 | |||
610 | """ |
|
610 | """ | |
611 | Obtiene una copia del First Header |
|
611 | Obtiene una copia del First Header | |
612 |
|
612 | |||
613 | Affected: |
|
613 | Affected: | |
614 | self.systemHeaderObj |
|
614 | self.systemHeaderObj | |
615 | self.radarControllerHeaderObj |
|
615 | self.radarControllerHeaderObj | |
616 | self.dtype |
|
616 | self.dtype | |
617 |
|
617 | |||
618 | Return: |
|
618 | Return: | |
619 | None |
|
619 | None | |
620 | """ |
|
620 | """ | |
621 |
|
621 | |||
622 | self.systemHeaderObj = self.dataOut.systemHeaderObj.copy() |
|
622 | self.systemHeaderObj = self.dataOut.systemHeaderObj.copy() | |
623 | self.systemHeaderObj.nChannels = self.dataOut.nChannels |
|
623 | self.systemHeaderObj.nChannels = self.dataOut.nChannels | |
624 | self.radarControllerHeaderObj = self.dataOut.radarControllerHeaderObj.copy() |
|
624 | self.radarControllerHeaderObj = self.dataOut.radarControllerHeaderObj.copy() | |
625 |
|
625 | |||
626 | self.setBasicHeader() |
|
626 | self.setBasicHeader() | |
627 |
|
627 | |||
628 | processingHeaderSize = 40 # bytes |
|
628 | processingHeaderSize = 40 # bytes | |
629 | self.processingHeaderObj.dtype = 0 # Voltage |
|
629 | self.processingHeaderObj.dtype = 0 # Voltage | |
630 | self.processingHeaderObj.blockSize = self.__getBlockSize() |
|
630 | self.processingHeaderObj.blockSize = self.__getBlockSize() | |
631 | self.processingHeaderObj.profilesPerBlock = self.profilesPerBlock |
|
631 | self.processingHeaderObj.profilesPerBlock = self.profilesPerBlock | |
632 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile |
|
632 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile | |
633 | self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOut.processingHeaderObj.nWindows |
|
633 | self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOut.processingHeaderObj.nWindows | |
634 | self.processingHeaderObj.processFlags = self.__getProcessFlags() |
|
634 | self.processingHeaderObj.processFlags = self.__getProcessFlags() | |
635 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt |
|
635 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt | |
636 | self.processingHeaderObj.nIncohInt = 1 # Cuando la data de origen es de tipo Voltage |
|
636 | self.processingHeaderObj.nIncohInt = 1 # Cuando la data de origen es de tipo Voltage | |
637 | self.processingHeaderObj.totalSpectra = 0 # Cuando la data de origen es de tipo Voltage |
|
637 | self.processingHeaderObj.totalSpectra = 0 # Cuando la data de origen es de tipo Voltage | |
638 |
|
638 | |||
639 | # if self.dataOut.code != None: |
|
639 | # if self.dataOut.code != None: | |
640 | # self.processingHeaderObj.code = self.dataOut.code |
|
640 | # self.processingHeaderObj.code = self.dataOut.code | |
641 | # self.processingHeaderObj.nCode = self.dataOut.nCode |
|
641 | # self.processingHeaderObj.nCode = self.dataOut.nCode | |
642 | # self.processingHeaderObj.nBaud = self.dataOut.nBaud |
|
642 | # self.processingHeaderObj.nBaud = self.dataOut.nBaud | |
643 | # codesize = int(8 + 4 * self.dataOut.nCode * self.dataOut.nBaud) |
|
643 | # codesize = int(8 + 4 * self.dataOut.nCode * self.dataOut.nBaud) | |
644 | # processingHeaderSize += codesize |
|
644 | # processingHeaderSize += codesize | |
645 |
|
645 | |||
646 | if self.processingHeaderObj.nWindows != 0: |
|
646 | if self.processingHeaderObj.nWindows != 0: | |
647 | self.processingHeaderObj.firstHeight = self.dataOut.heightList[0] |
|
647 | self.processingHeaderObj.firstHeight = self.dataOut.heightList[0] | |
648 | self.processingHeaderObj.deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] |
|
648 | self.processingHeaderObj.deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] | |
649 | self.processingHeaderObj.nHeights = self.dataOut.nHeights |
|
649 | self.processingHeaderObj.nHeights = self.dataOut.nHeights | |
650 | self.processingHeaderObj.samplesWin = self.dataOut.nHeights |
|
650 | self.processingHeaderObj.samplesWin = self.dataOut.nHeights | |
651 | processingHeaderSize += 12 |
|
651 | processingHeaderSize += 12 | |
652 |
|
652 | |||
653 | self.processingHeaderObj.size = processingHeaderSize No newline at end of file |
|
653 | self.processingHeaderObj.size = processingHeaderSize |
General Comments 0
You need to be logged in to leave comments.
Login now