@@ -1,548 +1,537 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Feb 7, 2012 |
|
2 | Created on Feb 7, 2012 | |
3 |
|
3 | |||
4 | @author $Author$ |
|
4 | @author $Author$ | |
5 | @version $Id$ |
|
5 | @version $Id$ | |
6 | ''' |
|
6 | ''' | |
7 |
|
7 | |||
8 | import os, sys |
|
8 | import os, sys | |
9 | import numpy |
|
9 | import numpy | |
10 |
|
10 | |||
11 | path = os.path.split(os.getcwd())[0] |
|
11 | path = os.path.split(os.getcwd())[0] | |
12 | sys.path.append(path) |
|
12 | sys.path.append(path) | |
13 |
|
13 | |||
14 | from Model.Voltage import Voltage |
|
14 | from Model.Voltage import Voltage | |
15 | from IO.VoltageIO import VoltageWriter |
|
15 | from IO.VoltageIO import VoltageWriter | |
16 | from Graphics.VoltagePlot import Osciloscope |
|
16 | from Graphics.VoltagePlot import Osciloscope | |
17 |
|
17 | |||
18 | class VoltageProcessor: |
|
18 | class VoltageProcessor: | |
19 | ''' |
|
19 | ''' | |
20 | classdocs |
|
20 | classdocs | |
21 | ''' |
|
21 | ''' | |
22 |
|
22 | |||
23 | dataInObj = None |
|
23 | dataInObj = None | |
24 | dataOutObj = None |
|
24 | dataOutObj = None | |
25 |
|
25 | |||
26 | integratorObjIndex = None |
|
26 | integratorObjIndex = None | |
27 | decoderObjIndex = None |
|
27 | decoderObjIndex = None | |
28 | profSelectorObjIndex = None |
|
28 | profSelectorObjIndex = None | |
29 | writerObjIndex = None |
|
29 | writerObjIndex = None | |
30 | plotterObjIndex = None |
|
30 | plotterObjIndex = None | |
31 | flipIndex = None |
|
31 | flipIndex = None | |
32 |
|
32 | |||
33 | integratorObjList = [] |
|
33 | integratorObjList = [] | |
34 | decoderObjList = [] |
|
34 | decoderObjList = [] | |
35 | profileSelectorObjList = [] |
|
35 | profileSelectorObjList = [] | |
36 | writerObjList = [] |
|
36 | writerObjList = [] | |
37 | plotterObjList = [] |
|
37 | plotterObjList = [] | |
38 | m_Voltage= Voltage() |
|
38 | m_Voltage= Voltage() | |
39 |
|
39 | |||
40 | m_ProfileSelector= ProfileSelector() |
|
40 | m_ProfileSelector = ProfileSelector() | |
41 |
|
41 | |||
42 | m_Decoder= Decoder() |
|
42 | m_Decoder = Decoder() | |
43 |
|
43 | |||
44 | m_CoherentIntegrator= CoherentIntegrator() |
|
44 | m_CoherentIntegrator = CoherentIntegrator() | |
45 |
|
45 | |||
46 |
|
||||
47 | def __init__(self, dataInObj, dataOutObj=None): |
|
46 | def __init__(self, dataInObj, dataOutObj=None): | |
48 | ''' |
|
47 | ''' | |
49 | Constructor |
|
48 | Constructor | |
50 | ''' |
|
49 | ''' | |
51 |
|
50 | |||
52 | self.dataInObj = dataInObj |
|
51 | self.dataInObj = dataInObj | |
53 |
|
52 | |||
54 | if dataOutObj == None: |
|
53 | if dataOutObj == None: | |
55 | self.dataOutObj = Voltage() |
|
54 | self.dataOutObj = Voltage() | |
56 | else: |
|
55 | else: | |
57 | self.dataOutObj = dataOutObj |
|
56 | self.dataOutObj = dataOutObj | |
58 |
|
57 | |||
59 | self.integratorObjIndex = None |
|
58 | self.integratorObjIndex = None | |
60 | self.decoderObjIndex = None |
|
59 | self.decoderObjIndex = None | |
61 | self.profSelectorObjIndex = None |
|
60 | self.profSelectorObjIndex = None | |
62 | self.writerObjIndex = None |
|
61 | self.writerObjIndex = None | |
63 | self.plotterObjIndex = None |
|
62 | self.plotterObjIndex = None | |
64 | self.flipIndex = 1 |
|
63 | self.flipIndex = 1 | |
65 | self.integratorObjList = [] |
|
64 | self.integratorObjList = [] | |
66 | self.decoderObjList = [] |
|
65 | self.decoderObjList = [] | |
67 | self.profileSelectorObjList = [] |
|
66 | self.profileSelectorObjList = [] | |
68 | self.writerObjList = [] |
|
67 | self.writerObjList = [] | |
69 | self.plotterObjList = [] |
|
68 | self.plotterObjList = [] | |
70 |
|
69 | |||
71 | def init(self): |
|
70 | def init(self): | |
72 |
|
71 | |||
73 | self.integratorObjIndex = 0 |
|
72 | self.integratorObjIndex = 0 | |
74 | self.decoderObjIndex = 0 |
|
73 | self.decoderObjIndex = 0 | |
75 | self.profSelectorObjIndex = 0 |
|
74 | self.profSelectorObjIndex = 0 | |
76 | self.writerObjIndex = 0 |
|
75 | self.writerObjIndex = 0 | |
77 | self.plotterObjIndex = 0 |
|
76 | self.plotterObjIndex = 0 | |
78 | self.dataOutObj.copy(self.dataInObj) |
|
77 | self.dataOutObj.copy(self.dataInObj) | |
79 |
|
78 | |||
80 | if self.profSelectorObjIndex != None: |
|
79 | if self.profSelectorObjIndex != None: | |
81 | for profSelObj in self.profileSelectorObjList: |
|
80 | for profSelObj in self.profileSelectorObjList: | |
82 | profSelObj.incIndex() |
|
81 | profSelObj.incIndex() | |
83 |
|
82 | |||
84 | def addWriter(self, wrpath): |
|
83 | def addWriter(self, wrpath): | |
85 | objWriter = VoltageWriter(self.dataOutObj) |
|
84 | objWriter = VoltageWriter(self.dataOutObj) | |
86 | objWriter.setup(wrpath) |
|
85 | objWriter.setup(wrpath) | |
87 | self.writerObjList.append(objWriter) |
|
86 | self.writerObjList.append(objWriter) | |
88 |
|
87 | |||
89 | def addPlotter(self): |
|
88 | def addPlotter(self): | |
90 |
|
89 | |||
91 | plotObj = Osciloscope(self.dataOutObj,self.plotterObjIndex) |
|
90 | plotObj = Osciloscope(self.dataOutObj,self.plotterObjIndex) | |
92 | self.plotterObjList.append(plotObj) |
|
91 | self.plotterObjList.append(plotObj) | |
93 |
|
92 | |||
94 | def addIntegrator(self, nCohInt): |
|
93 | def addIntegrator(self, nCohInt): | |
95 |
|
94 | |||
96 | objCohInt = CoherentIntegrator(nCohInt) |
|
95 | objCohInt = CoherentIntegrator(nCohInt) | |
97 | self.integratorObjList.append(objCohInt) |
|
96 | self.integratorObjList.append(objCohInt) | |
98 |
|
97 | |||
99 | def addDecoder(self, code, ncode, nbaud): |
|
98 | def addDecoder(self, code, ncode, nbaud): | |
100 |
|
99 | |||
101 | objDecoder = Decoder(code,ncode,nbaud) |
|
100 | objDecoder = Decoder(code,ncode,nbaud) | |
102 | self.decoderObjList.append(objDecoder) |
|
101 | self.decoderObjList.append(objDecoder) | |
103 |
|
102 | |||
104 | def addProfileSelector(self, nProfiles): |
|
103 | def addProfileSelector(self, nProfiles): | |
105 |
|
104 | |||
106 | objProfSelector = ProfileSelector(nProfiles) |
|
105 | objProfSelector = ProfileSelector(nProfiles) | |
107 | self.profileSelectorObjList.append(objProfSelector) |
|
106 | self.profileSelectorObjList.append(objProfSelector) | |
108 |
|
107 | |||
109 | def writeData(self,wrpath): |
|
108 | def writeData(self,wrpath): | |
110 |
|
109 | |||
111 | if self.dataOutObj.flagNoData: |
|
110 | if self.dataOutObj.flagNoData: | |
112 | return 0 |
|
111 | return 0 | |
113 |
|
112 | |||
114 | if len(self.writerObjList) <= self.writerObjIndex: |
|
113 | if len(self.writerObjList) <= self.writerObjIndex: | |
115 | self.addWriter(wrpath) |
|
114 | self.addWriter(wrpath) | |
116 |
|
115 | |||
117 | self.writerObjList[self.writerObjIndex].putData() |
|
116 | self.writerObjList[self.writerObjIndex].putData() | |
118 |
|
117 | |||
119 | # myWrObj = self.writerObjList[self.writerObjIndex] |
|
118 | # myWrObj = self.writerObjList[self.writerObjIndex] | |
120 | # myWrObj.putData() |
|
119 | # myWrObj.putData() | |
121 |
|
120 | |||
122 | self.writerObjIndex += 1 |
|
121 | self.writerObjIndex += 1 | |
123 |
|
122 | |||
124 | def plotData(self,idProfile, type, xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''): |
|
123 | def plotData(self,idProfile, type, xmin=None, xmax=None, ymin=None, ymax=None, winTitle=''): | |
125 | if self.dataOutObj.flagNoData: |
|
124 | if self.dataOutObj.flagNoData: | |
126 | return 0 |
|
125 | return 0 | |
127 |
|
126 | |||
128 | if len(self.plotterObjList) <= self.plotterObjIndex: |
|
127 | if len(self.plotterObjList) <= self.plotterObjIndex: | |
129 | self.addPlotter() |
|
128 | self.addPlotter() | |
130 |
|
129 | |||
131 | self.plotterObjList[self.plotterObjIndex].plotData(type=type, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) |
|
130 | self.plotterObjList[self.plotterObjIndex].plotData(type=type, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,winTitle=winTitle) | |
132 |
|
131 | |||
133 | self.plotterObjIndex += 1 |
|
132 | self.plotterObjIndex += 1 | |
134 |
|
133 | |||
135 | def integrator(self, N): |
|
134 | def integrator(self, N): | |
136 |
|
135 | |||
137 | if self.dataOutObj.flagNoData: |
|
136 | if self.dataOutObj.flagNoData: | |
138 | return 0 |
|
137 | return 0 | |
139 |
|
138 | |||
140 | if len(self.integratorObjList) <= self.integratorObjIndex: |
|
139 | if len(self.integratorObjList) <= self.integratorObjIndex: | |
141 | self.addIntegrator(N) |
|
140 | self.addIntegrator(N) | |
142 |
|
141 | |||
143 | myCohIntObj = self.integratorObjList[self.integratorObjIndex] |
|
142 | myCohIntObj = self.integratorObjList[self.integratorObjIndex] | |
144 | myCohIntObj.exe(self.dataOutObj.data) |
|
143 | myCohIntObj.exe(self.dataOutObj.data) | |
145 |
|
144 | |||
146 | if myCohIntObj.flag: |
|
145 | if myCohIntObj.flag: | |
147 | self.dataOutObj.data = myCohIntObj.data |
|
146 | self.dataOutObj.data = myCohIntObj.data | |
148 | self.dataOutObj.m_ProcessingHeader.coherentInt *= N |
|
147 | self.dataOutObj.m_ProcessingHeader.coherentInt *= N | |
149 | self.dataOutObj.flagNoData = False |
|
148 | self.dataOutObj.flagNoData = False | |
150 |
|
149 | |||
151 | else: |
|
150 | else: | |
152 | self.dataOutObj.flagNoData = True |
|
151 | self.dataOutObj.flagNoData = True | |
153 |
|
152 | |||
154 | self.integratorObjIndex += 1 |
|
153 | self.integratorObjIndex += 1 | |
155 |
|
154 | |||
156 | def decoder(self,code=None,type = 0): |
|
155 | def decoder(self,code=None,type = 0): | |
157 |
|
156 | |||
158 | if self.dataOutObj.flagNoData: |
|
157 | if self.dataOutObj.flagNoData: | |
159 | return 0 |
|
158 | return 0 | |
160 |
|
159 | |||
161 | if code == None: |
|
160 | if code == None: | |
162 | code = self.dataOutObj.m_RadarControllerHeader.code |
|
161 | code = self.dataOutObj.m_RadarControllerHeader.code | |
163 | ncode, nbaud = code.shape |
|
162 | ncode, nbaud = code.shape | |
164 |
|
163 | |||
165 | if len(self.decoderObjList) <= self.decoderObjIndex: |
|
164 | if len(self.decoderObjList) <= self.decoderObjIndex: | |
166 | self.addDecoder(code,ncode,nbaud) |
|
165 | self.addDecoder(code,ncode,nbaud) | |
167 |
|
166 | |||
168 | myDecodObj = self.decoderObjList[self.decoderObjIndex] |
|
167 | myDecodObj = self.decoderObjList[self.decoderObjIndex] | |
169 | myDecodObj.exe(data=self.dataOutObj.data,type=type) |
|
168 | myDecodObj.exe(data=self.dataOutObj.data,type=type) | |
170 |
|
169 | |||
171 | if myDecodObj.flag: |
|
170 | if myDecodObj.flag: | |
172 | self.dataOutObj.data = myDecodObj.data |
|
171 | self.dataOutObj.data = myDecodObj.data | |
173 | self.dataOutObj.flagNoData = False |
|
172 | self.dataOutObj.flagNoData = False | |
174 | else: |
|
173 | else: | |
175 | self.dataOutObj.flagNoData = True |
|
174 | self.dataOutObj.flagNoData = True | |
176 |
|
175 | |||
177 | self.decoderObjIndex += 1 |
|
176 | self.decoderObjIndex += 1 | |
178 |
|
177 | |||
179 |
|
178 | |||
180 | def filterByHei(self, window): |
|
179 | def filterByHei(self, window): | |
181 | if window == None: |
|
180 | if window == None: | |
182 | window = self.dataOutObj.m_RadarControllerHeader.txA / self.dataOutObj.m_ProcessingHeader.deltaHeight[0] |
|
181 | window = self.dataOutObj.m_RadarControllerHeader.txA / self.dataOutObj.m_ProcessingHeader.deltaHeight[0] | |
183 |
|
182 | |||
184 | newdelta = self.dataOutObj.m_ProcessingHeader.deltaHeight[0] * window |
|
183 | newdelta = self.dataOutObj.m_ProcessingHeader.deltaHeight[0] * window | |
185 | dim1 = self.dataOutObj.data.shape[0] |
|
184 | dim1 = self.dataOutObj.data.shape[0] | |
186 | dim2 = self.dataOutObj.data.shape[1] |
|
185 | dim2 = self.dataOutObj.data.shape[1] | |
187 | r = dim2 % window |
|
186 | r = dim2 % window | |
188 |
|
187 | |||
189 | buffer = self.dataOutObj.data[:,0:dim2-r] |
|
188 | buffer = self.dataOutObj.data[:,0:dim2-r] | |
190 | buffer = buffer.reshape(dim1,dim2/window,window) |
|
189 | buffer = buffer.reshape(dim1,dim2/window,window) | |
191 | buffer = numpy.sum(buffer,2) |
|
190 | buffer = numpy.sum(buffer,2) | |
192 | self.dataOutObj.data = buffer |
|
191 | self.dataOutObj.data = buffer | |
193 |
|
192 | |||
194 | self.dataOutObj.m_ProcessingHeader.deltaHeight = newdelta |
|
193 | self.dataOutObj.m_ProcessingHeader.deltaHeight = newdelta | |
195 | self.dataOutObj.m_ProcessingHeader.numHeights = buffer.shape[1] |
|
194 | self.dataOutObj.m_ProcessingHeader.numHeights = buffer.shape[1] | |
196 |
|
195 | |||
197 | self.dataOutObj.nHeights = self.dataOutObj.m_ProcessingHeader.numHeights |
|
196 | self.dataOutObj.nHeights = self.dataOutObj.m_ProcessingHeader.numHeights | |
198 |
|
197 | |||
199 | #self.dataOutObj.heightList es un numpy.array |
|
198 | #self.dataOutObj.heightList es un numpy.array | |
200 | self.dataOutObj.heightList = numpy.arange(self.dataOutObj.m_ProcessingHeader.firstHeight[0],newdelta*self.dataOutObj.nHeights,newdelta) |
|
199 | self.dataOutObj.heightList = numpy.arange(self.dataOutObj.m_ProcessingHeader.firstHeight[0],newdelta*self.dataOutObj.nHeights,newdelta) | |
201 |
|
200 | |||
202 | def deFlip(self): |
|
201 | def deFlip(self): | |
203 | self.dataOutObj.data *= self.flipIndex |
|
202 | self.dataOutObj.data *= self.flipIndex | |
204 | self.flipIndex *= -1. |
|
203 | self.flipIndex *= -1. | |
205 |
|
204 | |||
206 | def selectChannels(self, channelList): |
|
205 | def selectChannels(self, channelList): | |
207 | """ |
|
206 | """ | |
208 |
Selecciona un bloque de datos en base a canales |
|
207 | Selecciona un bloque de datos en base a canales segun el channelList | |
209 |
|
208 | |||
210 | Input: |
|
209 | Input: | |
211 | channelList : lista sencilla de canales a seleccionar por ej. [2,3,7] |
|
210 | channelList : lista sencilla de canales a seleccionar por ej. [2,3,7] | |
212 |
|
211 | |||
213 | Affected: |
|
212 | Affected: | |
214 | self.dataOutObj.data |
|
213 | self.dataOutObj.data | |
215 | self.dataOutObj.channelList |
|
214 | self.dataOutObj.channelList | |
216 | self.dataOutObj.nChannels |
|
215 | self.dataOutObj.nChannels | |
217 | self.dataOutObj.m_ProcessingHeader.totalSpectra |
|
216 | self.dataOutObj.m_ProcessingHeader.totalSpectra | |
218 | self.dataOutObj.m_SystemHeader.numChannels |
|
217 | self.dataOutObj.m_SystemHeader.numChannels | |
219 | self.dataOutObj.m_ProcessingHeader.blockSize |
|
218 | self.dataOutObj.m_ProcessingHeader.blockSize | |
220 |
|
219 | |||
221 | Return: |
|
220 | Return: | |
222 | None |
|
221 | None | |
223 | """ |
|
222 | """ | |
224 | if self.dataOutObj.flagNoData: |
|
223 | if self.dataOutObj.flagNoData: | |
225 | return 0 |
|
224 | return 0 | |
226 |
|
225 | |||
227 | for channel in channelList: |
|
226 | for channel in channelList: | |
228 | if channel not in self.dataOutObj.channelList: |
|
227 | if channel not in self.dataOutObj.channelList: | |
229 | raise ValueError, "The value %d in channelList is not valid" %channel |
|
228 | raise ValueError, "The value %d in channelList is not valid" %channel | |
230 |
|
229 | |||
231 |
n |
|
230 | nChannels = len(channelList) | |
232 | profiles = self.dataOutObj.nProfiles |
|
231 | ||
233 | heights = self.dataOutObj.nHeights #m_ProcessingHeader.numHeights |
|
232 | data = self.dataOutObj.data[channelList,:] | |
234 |
|
233 | |||
235 | data = numpy.zeros( (nchannels,heights), dtype='complex' ) |
|
|||
236 | for index,channel in enumerate(channelList): |
|
|||
237 | data[index,:] = self.dataOutObj.data[channel,:] |
|
|||
238 |
|
||||
239 | self.dataOutObj.data = data |
|
234 | self.dataOutObj.data = data | |
240 | self.dataOutObj.channelList = channelList |
|
235 | self.dataOutObj.channelList = channelList | |
241 |
self.dataOutObj.nChannels = n |
|
236 | self.dataOutObj.nChannels = nChannels | |
242 | self.dataOutObj.m_ProcessingHeader.totalSpectra = nchannels |
|
237 | ||
243 |
self.dataOutObj.m_ |
|
238 | self.dataOutObj.m_ProcessingHeader.totalSpectra = nChannels | |
|
239 | self.dataOutObj.m_SystemHeader.numChannels = nChannels | |||
244 | self.dataOutObj.m_ProcessingHeader.blockSize = data.size |
|
240 | self.dataOutObj.m_ProcessingHeader.blockSize = data.size | |
245 | return 1 |
|
241 | return 1 | |
246 |
|
242 | |||
247 |
|
243 | |||
248 | def selectHeightsByValue(self, minHei, maxHei): |
|
244 | def selectHeightsByValue(self, minHei, maxHei): | |
249 | """ |
|
245 | """ | |
250 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango |
|
246 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango | |
251 | minHei <= height <= maxHei |
|
247 | minHei <= height <= maxHei | |
252 |
|
248 | |||
253 | Input: |
|
249 | Input: | |
254 | minHei : valor minimo de altura a considerar |
|
250 | minHei : valor minimo de altura a considerar | |
255 | maxHei : valor maximo de altura a considerar |
|
251 | maxHei : valor maximo de altura a considerar | |
256 |
|
252 | |||
257 | Affected: |
|
253 | Affected: | |
258 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex |
|
254 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex | |
259 |
|
255 | |||
260 | Return: |
|
256 | Return: | |
261 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
257 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
262 | """ |
|
258 | """ | |
263 | if self.dataOutObj.flagNoData: |
|
259 | if self.dataOutObj.flagNoData: | |
264 | return 0 |
|
260 | return 0 | |
265 |
|
261 | |||
266 | if (minHei < self.dataOutObj.heightList[0]) or (minHei > maxHei): |
|
262 | if (minHei < self.dataOutObj.heightList[0]) or (minHei > maxHei): | |
267 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
263 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) | |
268 |
|
264 | |||
269 | if (maxHei > self.dataOutObj.heightList[-1]): |
|
265 | if (maxHei > self.dataOutObj.heightList[-1]): | |
270 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
266 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) | |
271 |
|
267 | |||
272 | minIndex = 0 |
|
268 | minIndex = 0 | |
273 | maxIndex = 0 |
|
269 | maxIndex = 0 | |
274 | data = self.dataOutObj.heightList |
|
270 | data = self.dataOutObj.heightList | |
275 |
|
271 | |||
276 | for i,val in enumerate(data): |
|
272 | for i,val in enumerate(data): | |
277 | if val < minHei: |
|
273 | if val < minHei: | |
278 | continue |
|
274 | continue | |
279 | else: |
|
275 | else: | |
280 | minIndex = i; |
|
276 | minIndex = i; | |
281 | break |
|
277 | break | |
282 |
|
278 | |||
283 | for i,val in enumerate(data): |
|
279 | for i,val in enumerate(data): | |
284 | if val <= maxHei: |
|
280 | if val <= maxHei: | |
285 | maxIndex = i; |
|
281 | maxIndex = i; | |
286 | else: |
|
282 | else: | |
287 | break |
|
283 | break | |
288 |
|
284 | |||
289 | self.selectHeightsByIndex(minIndex, maxIndex) |
|
285 | self.selectHeightsByIndex(minIndex, maxIndex) | |
290 | return 1 |
|
286 | return 1 | |
291 |
|
287 | |||
292 |
|
288 | |||
293 | def selectHeightsByIndex(self, minIndex, maxIndex): |
|
289 | def selectHeightsByIndex(self, minIndex, maxIndex): | |
294 | """ |
|
290 | """ | |
295 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
291 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango | |
296 | minIndex <= index <= maxIndex |
|
292 | minIndex <= index <= maxIndex | |
297 |
|
293 | |||
298 | Input: |
|
294 | Input: | |
299 | minIndex : valor de indice minimo de altura a considerar |
|
295 | minIndex : valor de indice minimo de altura a considerar | |
300 | maxIndex : valor de indice maximo de altura a considerar |
|
296 | maxIndex : valor de indice maximo de altura a considerar | |
301 |
|
297 | |||
302 | Affected: |
|
298 | Affected: | |
303 | self.dataOutObj.data |
|
299 | self.dataOutObj.data | |
304 | self.dataOutObj.heightList |
|
300 | self.dataOutObj.heightList | |
305 | self.dataOutObj.nHeights |
|
301 | self.dataOutObj.nHeights | |
306 | self.dataOutObj.m_ProcessingHeader.blockSize |
|
302 | self.dataOutObj.m_ProcessingHeader.blockSize | |
307 | self.dataOutObj.m_ProcessingHeader.numHeights |
|
303 | self.dataOutObj.m_ProcessingHeader.numHeights | |
308 | self.dataOutObj.m_ProcessingHeader.firstHeight |
|
304 | self.dataOutObj.m_ProcessingHeader.firstHeight | |
309 | self.dataOutObj.m_RadarControllerHeader |
|
305 | self.dataOutObj.m_RadarControllerHeader | |
310 |
|
306 | |||
311 | Return: |
|
307 | Return: | |
312 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
308 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
313 | """ |
|
309 | """ | |
314 | if self.dataOutObj.flagNoData: |
|
310 | if self.dataOutObj.flagNoData: | |
315 | return 0 |
|
311 | return 0 | |
316 |
|
312 | |||
317 | if (minIndex < 0) or (minIndex > maxIndex): |
|
313 | if (minIndex < 0) or (minIndex > maxIndex): | |
318 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
314 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) | |
319 |
|
315 | |||
320 | if (maxIndex >= self.dataOutObj.nHeights): |
|
316 | if (maxIndex >= self.dataOutObj.nHeights): | |
321 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
317 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) | |
322 |
|
318 | |||
323 | nHeights = maxIndex - minIndex + 1 |
|
319 | nHeights = maxIndex - minIndex + 1 | |
324 | firstHeight = 0 |
|
|||
325 |
|
320 | |||
326 | #voltage |
|
321 | #voltage | |
327 | data = self.dataOutObj.data[:,minIndex:maxIndex+1] |
|
322 | data = self.dataOutObj.data[:,minIndex:maxIndex+1] | |
328 |
|
323 | |||
329 | firstHeight = self.dataOutObj.heightList[minIndex] |
|
324 | firstHeight = self.dataOutObj.heightList[minIndex] | |
330 |
|
325 | |||
331 | self.dataOutObj.data = data |
|
326 | self.dataOutObj.data = data | |
332 | self.dataOutObj.heightList = self.dataOutObj.heightList[minIndex:maxIndex+1] |
|
327 | self.dataOutObj.heightList = self.dataOutObj.heightList[minIndex:maxIndex+1] | |
333 | self.dataOutObj.nHeights = nHeights |
|
328 | self.dataOutObj.nHeights = nHeights | |
334 | self.dataOutObj.m_ProcessingHeader.blockSize = data.size |
|
329 | self.dataOutObj.m_ProcessingHeader.blockSize = data.size | |
335 | self.dataOutObj.m_ProcessingHeader.numHeights = nHeights |
|
330 | self.dataOutObj.m_ProcessingHeader.numHeights = nHeights | |
336 | self.dataOutObj.m_ProcessingHeader.firstHeight = firstHeight |
|
331 | self.dataOutObj.m_ProcessingHeader.firstHeight = firstHeight | |
337 | self.dataOutObj.m_RadarControllerHeader.numHeights = nHeights |
|
332 | self.dataOutObj.m_RadarControllerHeader.numHeights = nHeights | |
338 | return 1 |
|
333 | return 1 | |
339 |
|
334 | |||
340 | def selectProfilesByValue(self,indexList, nProfiles): |
|
335 | def selectProfilesByValue(self,indexList, nProfiles): | |
341 | if self.dataOutObj.flagNoData: |
|
336 | if self.dataOutObj.flagNoData: | |
342 | return 0 |
|
337 | return 0 | |
343 |
|
338 | |||
344 | if self.profSelectorObjIndex >= len(self.profileSelectorObjList): |
|
339 | if self.profSelectorObjIndex >= len(self.profileSelectorObjList): | |
345 | self.addProfileSelector(nProfiles) |
|
340 | self.addProfileSelector(nProfiles) | |
346 |
|
341 | |||
347 | profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex] |
|
342 | profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex] | |
348 |
|
343 | |||
349 | if not(profileSelectorObj.isProfileInList(indexList)): |
|
344 | if not(profileSelectorObj.isProfileInList(indexList)): | |
350 | self.dataOutObj.flagNoData = True |
|
345 | self.dataOutObj.flagNoData = True | |
351 | self.profSelectorObjIndex += 1 |
|
346 | self.profSelectorObjIndex += 1 | |
352 | return 0 |
|
347 | return 0 | |
353 |
|
348 | |||
354 | self.dataOutObj.flagNoData = False |
|
349 | self.dataOutObj.flagNoData = False | |
355 | self.profSelectorObjIndex += 1 |
|
350 | self.profSelectorObjIndex += 1 | |
356 |
|
351 | |||
357 | return 1 |
|
352 | return 1 | |
358 |
|
353 | |||
359 |
|
354 | |||
360 | def selectProfilesByIndex(self, minIndex, maxIndex, nProfiles): |
|
355 | def selectProfilesByIndex(self, minIndex, maxIndex, nProfiles): | |
361 | """ |
|
356 | """ | |
362 | Selecciona un bloque de datos en base a un grupo indices de perfiles segun el rango |
|
357 | Selecciona un bloque de datos en base a un grupo indices de perfiles segun el rango | |
363 | minIndex <= index <= maxIndex |
|
358 | minIndex <= index <= maxIndex | |
364 |
|
359 | |||
365 | Input: |
|
360 | Input: | |
366 | minIndex : valor de indice minimo de perfil a considerar |
|
361 | minIndex : valor de indice minimo de perfil a considerar | |
367 | maxIndex : valor de indice maximo de perfil a considerar |
|
362 | maxIndex : valor de indice maximo de perfil a considerar | |
368 | nProfiles : numero de profiles |
|
363 | nProfiles : numero de profiles | |
369 |
|
364 | |||
370 | Affected: |
|
365 | Affected: | |
371 | self.dataOutObj.flagNoData |
|
366 | self.dataOutObj.flagNoData | |
372 | self.profSelectorObjIndex |
|
367 | self.profSelectorObjIndex | |
373 |
|
368 | |||
374 | Return: |
|
369 | Return: | |
375 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
370 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
376 | """ |
|
371 | """ | |
377 |
|
372 | |||
378 | if self.dataOutObj.flagNoData: |
|
373 | if self.dataOutObj.flagNoData: | |
379 | return 0 |
|
374 | return 0 | |
380 |
|
375 | |||
381 | if self.profSelectorObjIndex >= len(self.profileSelectorObjList): |
|
376 | if self.profSelectorObjIndex >= len(self.profileSelectorObjList): | |
382 | self.addProfileSelector(nProfiles) |
|
377 | self.addProfileSelector(nProfiles) | |
383 |
|
378 | |||
384 | profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex] |
|
379 | profileSelectorObj = self.profileSelectorObjList[self.profSelectorObjIndex] | |
385 |
|
380 | |||
386 | if not(profileSelectorObj.isProfileInRange(minIndex, maxIndex)): |
|
381 | if not(profileSelectorObj.isProfileInRange(minIndex, maxIndex)): | |
387 | self.dataOutObj.flagNoData = True |
|
382 | self.dataOutObj.flagNoData = True | |
388 | self.profSelectorObjIndex += 1 |
|
383 | self.profSelectorObjIndex += 1 | |
389 | return 0 |
|
384 | return 0 | |
390 |
|
385 | |||
391 | self.dataOutObj.flagNoData = False |
|
386 | self.dataOutObj.flagNoData = False | |
392 | self.profSelectorObjIndex += 1 |
|
387 | self.profSelectorObjIndex += 1 | |
393 |
|
388 | |||
394 | return 1 |
|
389 | return 1 | |
395 |
|
390 | |||
396 | def selectNtxs(self, ntx): |
|
391 | def selectNtxs(self, ntx): | |
397 | pass |
|
392 | pass | |
398 |
|
393 | |||
399 |
|
394 | |||
400 | class Decoder: |
|
395 | class Decoder: | |
401 |
|
396 | |||
402 | data = None |
|
397 | data = None | |
403 | profCounter = 1 |
|
398 | profCounter = 1 | |
404 |
nCode = n |
|
399 | nCode = None | |
405 |
nBaud = |
|
400 | nBaud = None | |
406 | codeIndex = 0 |
|
401 | codeIndex = 0 | |
407 | code = code #this is a List |
|
402 | code = None | |
408 | fft_code = None |
|
|||
409 | flag = False |
|
403 | flag = False | |
410 | setCodeFft = False |
|
|||
411 |
|
404 | |||
412 | def __init__(self,code, ncode, nbaud): |
|
405 | def __init__(self,code, ncode, nbaud): | |
413 |
|
406 | |||
414 | self.data = None |
|
407 | self.data = None | |
415 | self.profCounter = 1 |
|
408 | self.profCounter = 1 | |
416 | self.nCode = ncode |
|
409 | self.nCode = ncode | |
417 | self.nBaud = nbaud |
|
410 | self.nBaud = nbaud | |
418 | self.codeIndex = 0 |
|
411 | self.codeIndex = 0 | |
419 | self.code = code #this is a List |
|
412 | self.code = code #this is a List | |
420 | self.fft_code = None |
|
|||
421 | self.flag = False |
|
413 | self.flag = False | |
422 | self.setCodeFft = False |
|
|||
423 |
|
414 | |||
424 | def exe(self, data, ndata=None, type = 0): |
|
415 | def exe(self, data, ndata=None, type = 0): | |
425 |
|
416 | |||
426 | if ndata == None: ndata = data.shape[1] |
|
417 | if ndata == None: ndata = data.shape[1] | |
427 |
|
418 | |||
428 | if type == 0: |
|
419 | if type == 0: | |
429 | self.convolutionInFreq(data,ndata) |
|
420 | self.convolutionInFreq(data,ndata) | |
430 |
|
421 | |||
431 | if type == 1: |
|
422 | if type == 1: | |
432 | self.convolutionInTime(data, ndata) |
|
423 | self.convolutionInTime(data, ndata) | |
433 |
|
424 | |||
434 | def convolutionInFreq(self,data, ndata): |
|
425 | def convolutionInFreq(self,data, ndata): | |
435 |
|
426 | |||
436 | newcode = numpy.zeros(ndata) |
|
427 | newcode = numpy.zeros(ndata) | |
437 | newcode[0:self.nBaud] = self.code[self.codeIndex] |
|
428 | newcode[0:self.nBaud] = self.code[self.codeIndex] | |
438 |
|
429 | |||
439 | self.codeIndex += 1 |
|
430 | self.codeIndex += 1 | |
440 |
|
431 | |||
441 | fft_data = numpy.fft.fft(data, axis=1) |
|
432 | fft_data = numpy.fft.fft(data, axis=1) | |
442 | fft_code = numpy.conj(numpy.fft.fft(newcode)) |
|
433 | fft_code = numpy.conj(numpy.fft.fft(newcode)) | |
443 | fft_code = fft_code.reshape(1,len(fft_code)) |
|
434 | fft_code = fft_code.reshape(1,len(fft_code)) | |
444 |
|
435 | |||
445 | conv = fft_data.copy() |
|
436 | conv = fft_data.copy() | |
446 | conv.fill(0) |
|
437 | conv.fill(0) | |
447 |
|
438 | |||
448 | conv = fft_data*fft_code # This other way to calculate multiplication between bidimensional arrays |
|
439 | conv = fft_data*fft_code | |
449 | # for i in range(ndata): |
|
|||
450 | # conv[i,:] = fft_data[i,:]*fft_code[i] |
|
|||
451 |
|
440 | |||
452 | self.data = numpy.fft.ifft(conv,axis=1) |
|
441 | self.data = numpy.fft.ifft(conv,axis=1) | |
453 | self.flag = True |
|
442 | self.flag = True | |
454 |
|
443 | |||
455 | if self.profCounter == self.nCode: |
|
444 | if self.profCounter == self.nCode: | |
456 | self.profCounter = 0 |
|
445 | self.profCounter = 0 | |
457 | self.codeIndex = 0 |
|
446 | self.codeIndex = 0 | |
458 |
|
447 | |||
459 | self.profCounter += 1 |
|
448 | self.profCounter += 1 | |
460 |
|
449 | |||
461 | def convolutionInTime(self, data, ndata): |
|
450 | def convolutionInTime(self, data, ndata): | |
462 |
|
451 | |||
463 | nchannel = data.shape[1] |
|
452 | nchannel = data.shape[1] | |
464 | newcode = self.code[self.codeIndex] |
|
453 | newcode = self.code[self.codeIndex] | |
465 | self.codeIndex += 1 |
|
454 | self.codeIndex += 1 | |
466 | conv = data.copy() |
|
455 | conv = data.copy() | |
467 | for i in range(nchannel): |
|
456 | for i in range(nchannel): | |
468 | conv[i,:] = numpy.correlate(data[i,:], newcode, 'same') |
|
457 | conv[i,:] = numpy.correlate(data[i,:], newcode, 'same') | |
469 |
|
458 | |||
470 | self.data = conv |
|
459 | self.data = conv | |
471 | self.flag = True |
|
460 | self.flag = True | |
472 |
|
461 | |||
473 | if self.profCounter == self.nCode: |
|
462 | if self.profCounter == self.nCode: | |
474 | self.profCounter = 0 |
|
463 | self.profCounter = 0 | |
475 | self.codeIndex = 0 |
|
464 | self.codeIndex = 0 | |
476 |
|
465 | |||
477 | self.profCounter += 1 |
|
466 | self.profCounter += 1 | |
478 |
|
467 | |||
479 |
|
468 | |||
480 | class CoherentIntegrator: |
|
469 | class CoherentIntegrator: | |
481 |
|
470 | |||
482 | profCounter = 1 |
|
471 | profCounter = 1 | |
483 | data = None |
|
472 | data = None | |
484 | buffer = None |
|
473 | buffer = None | |
485 | flag = False |
|
474 | flag = False | |
486 | nCohInt = N |
|
475 | nCohInt = None | |
487 |
|
476 | |||
488 | def __init__(self, N): |
|
477 | def __init__(self, N): | |
489 |
|
478 | |||
490 | self.profCounter = 1 |
|
479 | self.profCounter = 1 | |
491 | self.data = None |
|
480 | self.data = None | |
492 | self.buffer = None |
|
481 | self.buffer = None | |
493 | self.flag = False |
|
482 | self.flag = False | |
494 | self.nCohInt = N |
|
483 | self.nCohInt = N | |
495 |
|
484 | |||
496 | def exe(self, data): |
|
485 | def exe(self, data): | |
497 |
|
486 | |||
498 | if self.buffer == None: |
|
487 | if self.buffer == None: | |
499 | self.buffer = data |
|
488 | self.buffer = data | |
500 | else: |
|
489 | else: | |
501 | self.buffer = self.buffer + data |
|
490 | self.buffer = self.buffer + data | |
502 |
|
491 | |||
503 | if self.profCounter == self.nCohInt: |
|
492 | if self.profCounter == self.nCohInt: | |
504 | self.data = self.buffer |
|
493 | self.data = self.buffer | |
505 | self.buffer = None |
|
494 | self.buffer = None | |
506 | self.profCounter = 0 |
|
495 | self.profCounter = 0 | |
507 | self.flag = True |
|
496 | self.flag = True | |
508 | else: |
|
497 | else: | |
509 | self.flag = False |
|
498 | self.flag = False | |
510 |
|
499 | |||
511 | self.profCounter += 1 |
|
500 | self.profCounter += 1 | |
512 |
|
501 | |||
513 | class ProfileSelector: |
|
502 | class ProfileSelector: | |
514 |
|
503 | |||
515 | profileIndex = None |
|
504 | profileIndex = None | |
516 | # Tamanho total de los perfiles |
|
505 | # Tamanho total de los perfiles | |
517 | nProfiles = None |
|
506 | nProfiles = None | |
518 |
|
507 | |||
519 | def __init__(self, nProfiles): |
|
508 | def __init__(self, nProfiles): | |
520 |
|
509 | |||
521 | self.profileIndex = 0 |
|
510 | self.profileIndex = 0 | |
522 | self.nProfiles = nProfiles |
|
511 | self.nProfiles = nProfiles | |
523 |
|
512 | |||
524 | def incIndex(self): |
|
513 | def incIndex(self): | |
525 | self.profileIndex += 1 |
|
514 | self.profileIndex += 1 | |
526 |
|
515 | |||
527 | if self.profileIndex >= self.nProfiles: |
|
516 | if self.profileIndex >= self.nProfiles: | |
528 | self.profileIndex = 0 |
|
517 | self.profileIndex = 0 | |
529 |
|
518 | |||
530 | def isProfileInRange(self, minIndex, maxIndex): |
|
519 | def isProfileInRange(self, minIndex, maxIndex): | |
531 |
|
520 | |||
532 | if self.profileIndex < minIndex: |
|
521 | if self.profileIndex < minIndex: | |
533 | return False |
|
522 | return False | |
534 |
|
523 | |||
535 | if self.profileIndex > maxIndex: |
|
524 | if self.profileIndex > maxIndex: | |
536 | return False |
|
525 | return False | |
537 |
|
526 | |||
538 | return True |
|
527 | return True | |
539 |
|
528 | |||
540 | def isProfileInList(self, profileList): |
|
529 | def isProfileInList(self, profileList): | |
541 |
|
530 | |||
542 | if self.profileIndex not in profileList: |
|
531 | if self.profileIndex not in profileList: | |
543 | return False |
|
532 | return False | |
544 |
|
533 | |||
545 | return True |
|
534 | return True | |
546 |
|
535 | |||
547 |
|
536 | |||
548 | No newline at end of file |
|
537 |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now