@@ -1,1264 +1,1281 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author: murco $ |
|
3 | $Author: murco $ | |
4 | $Id: JROData.py 173 2012-11-20 15:06:21Z murco $ |
|
4 | $Id: JROData.py 173 2012-11-20 15:06:21Z murco $ | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import copy |
|
7 | import copy | |
8 | import numpy |
|
8 | import numpy | |
9 | import datetime |
|
9 | import datetime | |
10 |
|
10 | |||
11 | from jroheaderIO import SystemHeader, RadarControllerHeader |
|
11 | from jroheaderIO import SystemHeader, RadarControllerHeader | |
12 | from schainpy import cSchain |
|
12 | from schainpy import cSchain | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | def getNumpyDtype(dataTypeCode): |
|
15 | def getNumpyDtype(dataTypeCode): | |
16 |
|
16 | |||
17 | if dataTypeCode == 0: |
|
17 | if dataTypeCode == 0: | |
18 | numpyDtype = numpy.dtype([('real', '<i1'), ('imag', '<i1')]) |
|
18 | numpyDtype = numpy.dtype([('real', '<i1'), ('imag', '<i1')]) | |
19 | elif dataTypeCode == 1: |
|
19 | elif dataTypeCode == 1: | |
20 | numpyDtype = numpy.dtype([('real', '<i2'), ('imag', '<i2')]) |
|
20 | numpyDtype = numpy.dtype([('real', '<i2'), ('imag', '<i2')]) | |
21 | elif dataTypeCode == 2: |
|
21 | elif dataTypeCode == 2: | |
22 | numpyDtype = numpy.dtype([('real', '<i4'), ('imag', '<i4')]) |
|
22 | numpyDtype = numpy.dtype([('real', '<i4'), ('imag', '<i4')]) | |
23 | elif dataTypeCode == 3: |
|
23 | elif dataTypeCode == 3: | |
24 | numpyDtype = numpy.dtype([('real', '<i8'), ('imag', '<i8')]) |
|
24 | numpyDtype = numpy.dtype([('real', '<i8'), ('imag', '<i8')]) | |
25 | elif dataTypeCode == 4: |
|
25 | elif dataTypeCode == 4: | |
26 | numpyDtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')]) |
|
26 | numpyDtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')]) | |
27 | elif dataTypeCode == 5: |
|
27 | elif dataTypeCode == 5: | |
28 | numpyDtype = numpy.dtype([('real', '<f8'), ('imag', '<f8')]) |
|
28 | numpyDtype = numpy.dtype([('real', '<f8'), ('imag', '<f8')]) | |
29 | else: |
|
29 | else: | |
30 | raise ValueError, 'dataTypeCode was not defined' |
|
30 | raise ValueError, 'dataTypeCode was not defined' | |
31 |
|
31 | |||
32 | return numpyDtype |
|
32 | return numpyDtype | |
33 |
|
33 | |||
34 |
|
34 | |||
35 | def getDataTypeCode(numpyDtype): |
|
35 | def getDataTypeCode(numpyDtype): | |
36 |
|
36 | |||
37 | if numpyDtype == numpy.dtype([('real', '<i1'), ('imag', '<i1')]): |
|
37 | if numpyDtype == numpy.dtype([('real', '<i1'), ('imag', '<i1')]): | |
38 | datatype = 0 |
|
38 | datatype = 0 | |
39 | elif numpyDtype == numpy.dtype([('real', '<i2'), ('imag', '<i2')]): |
|
39 | elif numpyDtype == numpy.dtype([('real', '<i2'), ('imag', '<i2')]): | |
40 | datatype = 1 |
|
40 | datatype = 1 | |
41 | elif numpyDtype == numpy.dtype([('real', '<i4'), ('imag', '<i4')]): |
|
41 | elif numpyDtype == numpy.dtype([('real', '<i4'), ('imag', '<i4')]): | |
42 | datatype = 2 |
|
42 | datatype = 2 | |
43 | elif numpyDtype == numpy.dtype([('real', '<i8'), ('imag', '<i8')]): |
|
43 | elif numpyDtype == numpy.dtype([('real', '<i8'), ('imag', '<i8')]): | |
44 | datatype = 3 |
|
44 | datatype = 3 | |
45 | elif numpyDtype == numpy.dtype([('real', '<f4'), ('imag', '<f4')]): |
|
45 | elif numpyDtype == numpy.dtype([('real', '<f4'), ('imag', '<f4')]): | |
46 | datatype = 4 |
|
46 | datatype = 4 | |
47 | elif numpyDtype == numpy.dtype([('real', '<f8'), ('imag', '<f8')]): |
|
47 | elif numpyDtype == numpy.dtype([('real', '<f8'), ('imag', '<f8')]): | |
48 | datatype = 5 |
|
48 | datatype = 5 | |
49 | else: |
|
49 | else: | |
50 | datatype = None |
|
50 | datatype = None | |
51 |
|
51 | |||
52 | return datatype |
|
52 | return datatype | |
53 |
|
53 | |||
54 |
|
54 | |||
55 | def hildebrand_sekhon(data, navg): |
|
55 | def hildebrand_sekhon(data, navg): | |
56 | """ |
|
56 | """ | |
57 | This method is for the objective determination of the noise level in Doppler spectra. This |
|
57 | This method is for the objective determination of the noise level in Doppler spectra. This | |
58 | implementation technique is based on the fact that the standard deviation of the spectral |
|
58 | implementation technique is based on the fact that the standard deviation of the spectral | |
59 | densities is equal to the mean spectral density for white Gaussian noise |
|
59 | densities is equal to the mean spectral density for white Gaussian noise | |
60 |
|
60 | |||
61 | Inputs: |
|
61 | Inputs: | |
62 | Data : heights |
|
62 | Data : heights | |
63 | navg : numbers of averages |
|
63 | navg : numbers of averages | |
64 |
|
64 | |||
65 | Return: |
|
65 | Return: | |
66 | -1 : any error |
|
66 | -1 : any error | |
67 | anoise : noise's level |
|
67 | anoise : noise's level | |
68 | """ |
|
68 | """ | |
69 |
|
69 | |||
70 | sortdata = numpy.sort(data, axis=None) |
|
70 | sortdata = numpy.sort(data, axis=None) | |
71 | # lenOfData = len(sortdata) |
|
71 | # lenOfData = len(sortdata) | |
72 | # nums_min = lenOfData*0.2 |
|
72 | # nums_min = lenOfData*0.2 | |
73 | # |
|
73 | # | |
74 | # if nums_min <= 5: |
|
74 | # if nums_min <= 5: | |
75 | # nums_min = 5 |
|
75 | # nums_min = 5 | |
76 | # |
|
76 | # | |
77 | # sump = 0. |
|
77 | # sump = 0. | |
78 | # |
|
78 | # | |
79 | # sumq = 0. |
|
79 | # sumq = 0. | |
80 | # |
|
80 | # | |
81 | # j = 0 |
|
81 | # j = 0 | |
82 | # |
|
82 | # | |
83 | # cont = 1 |
|
83 | # cont = 1 | |
84 | # |
|
84 | # | |
85 | # while((cont==1)and(j<lenOfData)): |
|
85 | # while((cont==1)and(j<lenOfData)): | |
86 | # |
|
86 | # | |
87 | # sump += sortdata[j] |
|
87 | # sump += sortdata[j] | |
88 | # |
|
88 | # | |
89 | # sumq += sortdata[j]**2 |
|
89 | # sumq += sortdata[j]**2 | |
90 | # |
|
90 | # | |
91 | # if j > nums_min: |
|
91 | # if j > nums_min: | |
92 | # rtest = float(j)/(j-1) + 1.0/navg |
|
92 | # rtest = float(j)/(j-1) + 1.0/navg | |
93 | # if ((sumq*j) > (rtest*sump**2)): |
|
93 | # if ((sumq*j) > (rtest*sump**2)): | |
94 | # j = j - 1 |
|
94 | # j = j - 1 | |
95 | # sump = sump - sortdata[j] |
|
95 | # sump = sump - sortdata[j] | |
96 | # sumq = sumq - sortdata[j]**2 |
|
96 | # sumq = sumq - sortdata[j]**2 | |
97 | # cont = 0 |
|
97 | # cont = 0 | |
98 | # |
|
98 | # | |
99 | # j += 1 |
|
99 | # j += 1 | |
100 | # |
|
100 | # | |
101 | # lnoise = sump /j |
|
101 | # lnoise = sump /j | |
102 | # |
|
102 | # | |
103 | # return lnoise |
|
103 | # return lnoise | |
104 |
|
104 | |||
105 | return cSchain.hildebrand_sekhon(sortdata, navg) |
|
105 | return cSchain.hildebrand_sekhon(sortdata, navg) | |
106 |
|
106 | |||
107 |
|
107 | |||
108 | class Beam: |
|
108 | class Beam: | |
109 |
|
109 | |||
110 | def __init__(self): |
|
110 | def __init__(self): | |
111 | self.codeList = [] |
|
111 | self.codeList = [] | |
112 | self.azimuthList = [] |
|
112 | self.azimuthList = [] | |
113 | self.zenithList = [] |
|
113 | self.zenithList = [] | |
114 |
|
114 | |||
115 |
|
115 | |||
116 | class GenericData(object): |
|
116 | class GenericData(object): | |
117 |
|
117 | |||
118 | flagNoData = True |
|
118 | flagNoData = True | |
119 |
|
119 | |||
120 | def copy(self, inputObj=None): |
|
120 | def copy(self, inputObj=None): | |
121 |
|
121 | |||
122 | if inputObj == None: |
|
122 | if inputObj == None: | |
123 | return copy.deepcopy(self) |
|
123 | return copy.deepcopy(self) | |
124 |
|
124 | |||
125 | for key in inputObj.__dict__.keys(): |
|
125 | for key in inputObj.__dict__.keys(): | |
126 |
|
126 | |||
127 | attribute = inputObj.__dict__[key] |
|
127 | attribute = inputObj.__dict__[key] | |
128 |
|
128 | |||
129 | # If this attribute is a tuple or list |
|
129 | # If this attribute is a tuple or list | |
130 | if type(inputObj.__dict__[key]) in (tuple, list): |
|
130 | if type(inputObj.__dict__[key]) in (tuple, list): | |
131 | self.__dict__[key] = attribute[:] |
|
131 | self.__dict__[key] = attribute[:] | |
132 | continue |
|
132 | continue | |
133 |
|
133 | |||
134 | # If this attribute is another object or instance |
|
134 | # If this attribute is another object or instance | |
135 | if hasattr(attribute, '__dict__'): |
|
135 | if hasattr(attribute, '__dict__'): | |
136 | self.__dict__[key] = attribute.copy() |
|
136 | self.__dict__[key] = attribute.copy() | |
137 | continue |
|
137 | continue | |
138 |
|
138 | |||
139 | self.__dict__[key] = inputObj.__dict__[key] |
|
139 | self.__dict__[key] = inputObj.__dict__[key] | |
140 |
|
140 | |||
141 | def deepcopy(self): |
|
141 | def deepcopy(self): | |
142 |
|
142 | |||
143 | return copy.deepcopy(self) |
|
143 | return copy.deepcopy(self) | |
144 |
|
144 | |||
145 | def isEmpty(self): |
|
145 | def isEmpty(self): | |
146 |
|
146 | |||
147 | return self.flagNoData |
|
147 | return self.flagNoData | |
148 |
|
148 | |||
149 |
|
149 | |||
150 | class JROData(GenericData): |
|
150 | class JROData(GenericData): | |
151 |
|
151 | |||
152 | # m_BasicHeader = BasicHeader() |
|
152 | # m_BasicHeader = BasicHeader() | |
153 | # m_ProcessingHeader = ProcessingHeader() |
|
153 | # m_ProcessingHeader = ProcessingHeader() | |
154 |
|
154 | |||
155 | systemHeaderObj = SystemHeader() |
|
155 | systemHeaderObj = SystemHeader() | |
156 |
|
156 | |||
157 | radarControllerHeaderObj = RadarControllerHeader() |
|
157 | radarControllerHeaderObj = RadarControllerHeader() | |
158 |
|
158 | |||
159 | # data = None |
|
159 | # data = None | |
160 |
|
160 | |||
161 | type = None |
|
161 | type = None | |
162 |
|
162 | |||
163 | datatype = None # dtype but in string |
|
163 | datatype = None # dtype but in string | |
164 |
|
164 | |||
165 | # dtype = None |
|
165 | # dtype = None | |
166 |
|
166 | |||
167 | # nChannels = None |
|
167 | # nChannels = None | |
168 |
|
168 | |||
169 | # nHeights = None |
|
169 | # nHeights = None | |
170 |
|
170 | |||
171 | nProfiles = None |
|
171 | nProfiles = None | |
172 |
|
172 | |||
173 | heightList = None |
|
173 | heightList = None | |
174 |
|
174 | |||
175 | channelList = None |
|
175 | channelList = None | |
176 |
|
176 | |||
177 | flagDiscontinuousBlock = False |
|
177 | flagDiscontinuousBlock = False | |
178 |
|
178 | |||
179 | useLocalTime = False |
|
179 | useLocalTime = False | |
180 |
|
180 | |||
181 | utctime = None |
|
181 | utctime = None | |
182 |
|
182 | |||
183 | timeZone = None |
|
183 | timeZone = None | |
184 |
|
184 | |||
185 | dstFlag = None |
|
185 | dstFlag = None | |
186 |
|
186 | |||
187 | errorCount = None |
|
187 | errorCount = None | |
188 |
|
188 | |||
189 | blocksize = None |
|
189 | blocksize = None | |
190 |
|
190 | |||
191 | # nCode = None |
|
191 | # nCode = None | |
192 | # |
|
192 | # | |
193 | # nBaud = None |
|
193 | # nBaud = None | |
194 | # |
|
194 | # | |
195 | # code = None |
|
195 | # code = None | |
196 |
|
196 | |||
197 | flagDecodeData = False # asumo q la data no esta decodificada |
|
197 | flagDecodeData = False # asumo q la data no esta decodificada | |
198 |
|
198 | |||
199 | flagDeflipData = False # asumo q la data no esta sin flip |
|
199 | flagDeflipData = False # asumo q la data no esta sin flip | |
200 |
|
200 | |||
201 | flagShiftFFT = False |
|
201 | flagShiftFFT = False | |
202 |
|
202 | |||
203 | # ippSeconds = None |
|
203 | # ippSeconds = None | |
204 |
|
204 | |||
205 | # timeInterval = None |
|
205 | # timeInterval = None | |
206 |
|
206 | |||
207 | nCohInt = None |
|
207 | nCohInt = None | |
208 |
|
208 | |||
209 | # noise = None |
|
209 | # noise = None | |
210 |
|
210 | |||
211 | windowOfFilter = 1 |
|
211 | windowOfFilter = 1 | |
212 |
|
212 | |||
213 | # Speed of ligth |
|
213 | # Speed of ligth | |
214 | C = 3e8 |
|
214 | C = 3e8 | |
215 |
|
215 | |||
216 | frequency = 49.92e6 |
|
216 | frequency = 49.92e6 | |
217 |
|
217 | |||
218 | realtime = False |
|
218 | realtime = False | |
219 |
|
219 | |||
220 | beacon_heiIndexList = None |
|
220 | beacon_heiIndexList = None | |
221 |
|
221 | |||
222 | last_block = None |
|
222 | last_block = None | |
223 |
|
223 | |||
224 | blocknow = None |
|
224 | blocknow = None | |
225 |
|
225 | |||
226 | azimuth = None |
|
226 | azimuth = None | |
227 |
|
227 | |||
228 | zenith = None |
|
228 | zenith = None | |
229 |
|
229 | |||
230 | beam = Beam() |
|
230 | beam = Beam() | |
231 |
|
231 | |||
232 | profileIndex = None |
|
232 | profileIndex = None | |
233 |
|
233 | |||
234 | def getNoise(self): |
|
234 | def getNoise(self): | |
235 |
|
235 | |||
236 | raise NotImplementedError |
|
236 | raise NotImplementedError | |
237 |
|
237 | |||
238 | def getNChannels(self): |
|
238 | def getNChannels(self): | |
239 |
|
239 | |||
240 | return len(self.channelList) |
|
240 | return len(self.channelList) | |
241 |
|
241 | |||
242 | def getChannelIndexList(self): |
|
242 | def getChannelIndexList(self): | |
243 |
|
243 | |||
244 | return range(self.nChannels) |
|
244 | return range(self.nChannels) | |
245 |
|
245 | |||
246 | def getNHeights(self): |
|
246 | def getNHeights(self): | |
247 |
|
247 | |||
248 | return len(self.heightList) |
|
248 | return len(self.heightList) | |
249 |
|
249 | |||
250 | def getHeiRange(self, extrapoints=0): |
|
250 | def getHeiRange(self, extrapoints=0): | |
251 |
|
251 | |||
252 | heis = self.heightList |
|
252 | heis = self.heightList | |
253 | # deltah = self.heightList[1] - self.heightList[0] |
|
253 | # deltah = self.heightList[1] - self.heightList[0] | |
254 | # |
|
254 | # | |
255 | # heis.append(self.heightList[-1]) |
|
255 | # heis.append(self.heightList[-1]) | |
256 |
|
256 | |||
257 | return heis |
|
257 | return heis | |
258 |
|
258 | |||
259 | def getDeltaH(self): |
|
259 | def getDeltaH(self): | |
260 |
|
260 | |||
261 | delta = self.heightList[1] - self.heightList[0] |
|
261 | delta = self.heightList[1] - self.heightList[0] | |
262 |
|
262 | |||
263 | return delta |
|
263 | return delta | |
264 |
|
264 | |||
265 | def getltctime(self): |
|
265 | def getltctime(self): | |
266 |
|
266 | |||
267 | if self.useLocalTime: |
|
267 | if self.useLocalTime: | |
268 | return self.utctime - self.timeZone * 60 |
|
268 | return self.utctime - self.timeZone * 60 | |
269 |
|
269 | |||
270 | return self.utctime |
|
270 | return self.utctime | |
271 |
|
271 | |||
272 | def getDatatime(self): |
|
272 | def getDatatime(self): | |
273 |
|
273 | |||
274 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
274 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) | |
275 | return datatimeValue |
|
275 | return datatimeValue | |
276 |
|
276 | |||
277 | def getTimeRange(self): |
|
277 | def getTimeRange(self): | |
278 |
|
278 | |||
279 | datatime = [] |
|
279 | datatime = [] | |
280 |
|
280 | |||
281 | datatime.append(self.ltctime) |
|
281 | datatime.append(self.ltctime) | |
282 | datatime.append(self.ltctime + self.timeInterval + 1) |
|
282 | datatime.append(self.ltctime + self.timeInterval + 1) | |
283 |
|
283 | |||
284 | datatime = numpy.array(datatime) |
|
284 | datatime = numpy.array(datatime) | |
285 |
|
285 | |||
286 | return datatime |
|
286 | return datatime | |
287 |
|
287 | |||
288 | def getFmaxTimeResponse(self): |
|
288 | def getFmaxTimeResponse(self): | |
289 |
|
289 | |||
290 | period = (10**-6) * self.getDeltaH() / (0.15) |
|
290 | period = (10**-6) * self.getDeltaH() / (0.15) | |
291 |
|
291 | |||
292 | PRF = 1. / (period * self.nCohInt) |
|
292 | PRF = 1. / (period * self.nCohInt) | |
293 |
|
293 | |||
294 | fmax = PRF |
|
294 | fmax = PRF | |
295 |
|
295 | |||
296 | return fmax |
|
296 | return fmax | |
297 |
|
297 | |||
298 | def getFmax(self): |
|
298 | def getFmax(self): | |
299 | PRF = 1. / (self.ippSeconds * self.nCohInt) |
|
299 | PRF = 1. / (self.ippSeconds * self.nCohInt) | |
300 | #print "ippSeconds",self.ippSeconds |
|
300 | #print "ippSeconds",self.ippSeconds | |
301 | #print "nCohInt",self.nIncohInt |
|
301 | #print "nCohInt",self.nIncohInt | |
302 | #print PRF |
|
302 | #print PRF | |
303 | #import time |
|
303 | #import time | |
304 | #time.sleep(30) |
|
304 | #time.sleep(30) | |
305 | fmax = PRF |
|
305 | fmax = PRF | |
306 | return fmax |
|
306 | return fmax | |
307 |
|
307 | |||
308 | def getVmax(self): |
|
308 | def getVmax(self): | |
309 |
|
309 | |||
310 | _lambda = self.C / self.frequency |
|
310 | _lambda = self.C / self.frequency | |
311 |
|
311 | |||
312 | vmax = self.getFmax() * _lambda / 2 |
|
312 | vmax = self.getFmax() * _lambda / 2 | |
313 |
|
313 | |||
314 | return vmax |
|
314 | return vmax | |
315 |
|
315 | |||
316 | def get_ippSeconds(self): |
|
316 | def get_ippSeconds(self): | |
317 | ''' |
|
317 | ''' | |
318 | ''' |
|
318 | ''' | |
319 | return self.radarControllerHeaderObj.ippSeconds |
|
319 | return self.radarControllerHeaderObj.ippSeconds | |
320 |
|
320 | |||
321 | def set_ippSeconds(self, ippSeconds): |
|
321 | def set_ippSeconds(self, ippSeconds): | |
322 | ''' |
|
322 | ''' | |
323 | ''' |
|
323 | ''' | |
324 |
|
324 | |||
325 | self.radarControllerHeaderObj.ippSeconds = ippSeconds |
|
325 | self.radarControllerHeaderObj.ippSeconds = ippSeconds | |
326 |
|
326 | |||
327 | return |
|
327 | return | |
328 |
|
328 | |||
329 | def get_dtype(self): |
|
329 | def get_dtype(self): | |
330 | ''' |
|
330 | ''' | |
331 | ''' |
|
331 | ''' | |
332 | return getNumpyDtype(self.datatype) |
|
332 | return getNumpyDtype(self.datatype) | |
333 |
|
333 | |||
334 | def set_dtype(self, numpyDtype): |
|
334 | def set_dtype(self, numpyDtype): | |
335 | ''' |
|
335 | ''' | |
336 | ''' |
|
336 | ''' | |
337 |
|
337 | |||
338 | self.datatype = getDataTypeCode(numpyDtype) |
|
338 | self.datatype = getDataTypeCode(numpyDtype) | |
339 |
|
339 | |||
340 | def get_code(self): |
|
340 | def get_code(self): | |
341 | ''' |
|
341 | ''' | |
342 | ''' |
|
342 | ''' | |
343 | return self.radarControllerHeaderObj.code |
|
343 | return self.radarControllerHeaderObj.code | |
344 |
|
344 | |||
345 | def set_code(self, code): |
|
345 | def set_code(self, code): | |
346 | ''' |
|
346 | ''' | |
347 | ''' |
|
347 | ''' | |
348 | self.radarControllerHeaderObj.code = code |
|
348 | self.radarControllerHeaderObj.code = code | |
349 |
|
349 | |||
350 | return |
|
350 | return | |
351 |
|
351 | |||
352 | def get_ncode(self): |
|
352 | def get_ncode(self): | |
353 | ''' |
|
353 | ''' | |
354 | ''' |
|
354 | ''' | |
355 | return self.radarControllerHeaderObj.nCode |
|
355 | return self.radarControllerHeaderObj.nCode | |
356 |
|
356 | |||
357 | def set_ncode(self, nCode): |
|
357 | def set_ncode(self, nCode): | |
358 | ''' |
|
358 | ''' | |
359 | ''' |
|
359 | ''' | |
360 | self.radarControllerHeaderObj.nCode = nCode |
|
360 | self.radarControllerHeaderObj.nCode = nCode | |
361 |
|
361 | |||
362 | return |
|
362 | return | |
363 |
|
363 | |||
364 | def get_nbaud(self): |
|
364 | def get_nbaud(self): | |
365 | ''' |
|
365 | ''' | |
366 | ''' |
|
366 | ''' | |
367 | return self.radarControllerHeaderObj.nBaud |
|
367 | return self.radarControllerHeaderObj.nBaud | |
368 |
|
368 | |||
369 | def set_nbaud(self, nBaud): |
|
369 | def set_nbaud(self, nBaud): | |
370 | ''' |
|
370 | ''' | |
371 | ''' |
|
371 | ''' | |
372 | self.radarControllerHeaderObj.nBaud = nBaud |
|
372 | self.radarControllerHeaderObj.nBaud = nBaud | |
373 |
|
373 | |||
374 | return |
|
374 | return | |
375 |
|
375 | |||
376 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
376 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
377 | channelIndexList = property( |
|
377 | channelIndexList = property( | |
378 | getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
378 | getChannelIndexList, "I'm the 'channelIndexList' property.") | |
379 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
379 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
380 | #noise = property(getNoise, "I'm the 'nHeights' property.") |
|
380 | #noise = property(getNoise, "I'm the 'nHeights' property.") | |
381 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
381 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
382 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
382 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
383 | ippSeconds = property(get_ippSeconds, set_ippSeconds) |
|
383 | ippSeconds = property(get_ippSeconds, set_ippSeconds) | |
384 | dtype = property(get_dtype, set_dtype) |
|
384 | dtype = property(get_dtype, set_dtype) | |
385 | # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
385 | # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
386 | code = property(get_code, set_code) |
|
386 | code = property(get_code, set_code) | |
387 | nCode = property(get_ncode, set_ncode) |
|
387 | nCode = property(get_ncode, set_ncode) | |
388 | nBaud = property(get_nbaud, set_nbaud) |
|
388 | nBaud = property(get_nbaud, set_nbaud) | |
389 |
|
389 | |||
390 |
|
390 | |||
391 | class Voltage(JROData): |
|
391 | class Voltage(JROData): | |
392 |
|
392 | |||
393 | # data es un numpy array de 2 dmensiones (canales, alturas) |
|
393 | # data es un numpy array de 2 dmensiones (canales, alturas) | |
394 | data = None |
|
394 | data = None | |
395 |
|
395 | |||
396 | def __init__(self): |
|
396 | def __init__(self): | |
397 | ''' |
|
397 | ''' | |
398 | Constructor |
|
398 | Constructor | |
399 | ''' |
|
399 | ''' | |
400 |
|
400 | |||
401 | self.useLocalTime = True |
|
401 | self.useLocalTime = True | |
402 |
|
402 | |||
403 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
403 | self.radarControllerHeaderObj = RadarControllerHeader() | |
404 |
|
404 | |||
405 | self.systemHeaderObj = SystemHeader() |
|
405 | self.systemHeaderObj = SystemHeader() | |
406 |
|
406 | |||
407 | self.type = "Voltage" |
|
407 | self.type = "Voltage" | |
408 |
|
408 | |||
409 | self.data = None |
|
409 | self.data = None | |
410 |
|
410 | |||
411 | # self.dtype = None |
|
411 | # self.dtype = None | |
412 |
|
412 | |||
413 | # self.nChannels = 0 |
|
413 | # self.nChannels = 0 | |
414 |
|
414 | |||
415 | # self.nHeights = 0 |
|
415 | # self.nHeights = 0 | |
416 |
|
416 | |||
417 | self.nProfiles = None |
|
417 | self.nProfiles = None | |
418 |
|
418 | |||
419 | self.heightList = None |
|
419 | self.heightList = None | |
420 |
|
420 | |||
421 | self.channelList = None |
|
421 | self.channelList = None | |
422 |
|
422 | |||
423 | # self.channelIndexList = None |
|
423 | # self.channelIndexList = None | |
424 |
|
424 | |||
425 | self.flagNoData = True |
|
425 | self.flagNoData = True | |
426 |
|
426 | |||
427 | self.flagDiscontinuousBlock = False |
|
427 | self.flagDiscontinuousBlock = False | |
428 |
|
428 | |||
429 | self.utctime = None |
|
429 | self.utctime = None | |
430 |
|
430 | |||
431 | self.timeZone = None |
|
431 | self.timeZone = None | |
432 |
|
432 | |||
433 | self.dstFlag = None |
|
433 | self.dstFlag = None | |
434 |
|
434 | |||
435 | self.errorCount = None |
|
435 | self.errorCount = None | |
436 |
|
436 | |||
437 | self.nCohInt = None |
|
437 | self.nCohInt = None | |
438 |
|
438 | |||
439 | self.blocksize = None |
|
439 | self.blocksize = None | |
440 |
|
440 | |||
441 | self.flagDecodeData = False # asumo q la data no esta decodificada |
|
441 | self.flagDecodeData = False # asumo q la data no esta decodificada | |
442 |
|
442 | |||
443 | self.flagDeflipData = False # asumo q la data no esta sin flip |
|
443 | self.flagDeflipData = False # asumo q la data no esta sin flip | |
444 |
|
444 | |||
445 | self.flagShiftFFT = False |
|
445 | self.flagShiftFFT = False | |
446 |
|
446 | |||
447 | self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil |
|
447 | self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil | |
448 |
|
448 | |||
|
449 | self.ippFactor = 1 | |||
|
450 | ||||
449 | self.profileIndex = 0 |
|
451 | self.profileIndex = 0 | |
450 |
|
452 | |||
451 | def getNoisebyHildebrand(self, channel=None): |
|
453 | def getNoisebyHildebrand(self, channel=None): | |
452 | """ |
|
454 | """ | |
453 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
455 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
454 |
|
456 | |||
455 | Return: |
|
457 | Return: | |
456 | noiselevel |
|
458 | noiselevel | |
457 | """ |
|
459 | """ | |
458 |
|
460 | |||
459 | if channel != None: |
|
461 | if channel != None: | |
460 | data = self.data[channel] |
|
462 | data = self.data[channel] | |
461 | nChannels = 1 |
|
463 | nChannels = 1 | |
462 | else: |
|
464 | else: | |
463 | data = self.data |
|
465 | data = self.data | |
464 | nChannels = self.nChannels |
|
466 | nChannels = self.nChannels | |
465 |
|
467 | |||
466 | noise = numpy.zeros(nChannels) |
|
468 | noise = numpy.zeros(nChannels) | |
467 | power = data * numpy.conjugate(data) |
|
469 | power = data * numpy.conjugate(data) | |
468 |
|
470 | |||
469 | for thisChannel in range(nChannels): |
|
471 | for thisChannel in range(nChannels): | |
470 | if nChannels == 1: |
|
472 | if nChannels == 1: | |
471 | daux = power[:].real |
|
473 | daux = power[:].real | |
472 | else: |
|
474 | else: | |
473 | daux = power[thisChannel, :].real |
|
475 | daux = power[thisChannel, :].real | |
474 | noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt) |
|
476 | noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt) | |
475 |
|
477 | |||
476 | return noise |
|
478 | return noise | |
477 |
|
479 | |||
478 | def getNoise(self, type=1, channel=None): |
|
480 | def getNoise(self, type=1, channel=None): | |
479 |
|
481 | |||
480 | if type == 1: |
|
482 | if type == 1: | |
481 | noise = self.getNoisebyHildebrand(channel) |
|
483 | noise = self.getNoisebyHildebrand(channel) | |
482 |
|
484 | |||
483 | return noise |
|
485 | return noise | |
484 |
|
486 | |||
485 | def getPower(self, channel=None): |
|
487 | def getPower(self, channel=None): | |
486 |
|
488 | |||
487 | if channel != None: |
|
489 | if channel != None: | |
488 | data = self.data[channel] |
|
490 | data = self.data[channel] | |
489 | else: |
|
491 | else: | |
490 | data = self.data |
|
492 | data = self.data | |
491 |
|
493 | |||
492 | power = data * numpy.conjugate(data) |
|
494 | power = data * numpy.conjugate(data) | |
493 | powerdB = 10 * numpy.log10(power.real) |
|
495 | powerdB = 10 * numpy.log10(power.real) | |
494 | powerdB = numpy.squeeze(powerdB) |
|
496 | powerdB = numpy.squeeze(powerdB) | |
495 |
|
497 | |||
496 | return powerdB |
|
498 | return powerdB | |
497 |
|
499 | |||
498 | def getTimeInterval(self): |
|
500 | def getTimeInterval(self): | |
499 |
|
501 | |||
500 | timeInterval = self.ippSeconds * self.nCohInt |
|
502 | timeInterval = self.ippSeconds * self.nCohInt | |
501 |
|
503 | |||
502 | return timeInterval |
|
504 | return timeInterval | |
503 |
|
505 | |||
|
506 | def getAcfRange(self, extrapoints=0): | |||
|
507 | #print "GET ACF RANGE" | |||
|
508 | #print "NFFTPoints",self.nFFTPoints | |||
|
509 | #print "IPPFactor", self.ippFactor | |||
|
510 | #deltafreq = 10. / ( self.getFmax() / (self.nFFTPoints * self.ippFactor) ) | |||
|
511 | deltatime = 1./(self.getFmax()/ self.ippFactor) | |||
|
512 | #print "getFmax",self.getFmax() | |||
|
513 | #import time | |||
|
514 | #time.sleep(30) | |||
|
515 | timerange = deltatime * \ | |||
|
516 | (numpy.arange(self.nProfiles + extrapoints))#- self.nProfiles / 2.) | |||
|
517 | #- deltafreq / 2 | |||
|
518 | #print "timerange",timerange | |||
|
519 | return timerange | |||
|
520 | ||||
504 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
521 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
505 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
522 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
506 |
|
523 | |||
507 |
|
524 | |||
508 | class Spectra(JROData): |
|
525 | class Spectra(JROData): | |
509 |
|
526 | |||
510 | # data spc es un numpy array de 2 dmensiones (canales, perfiles, alturas) |
|
527 | # data spc es un numpy array de 2 dmensiones (canales, perfiles, alturas) | |
511 | data_spc = None |
|
528 | data_spc = None | |
512 |
|
529 | |||
513 | # data cspc es un numpy array de 2 dmensiones (canales, pares, alturas) |
|
530 | # data cspc es un numpy array de 2 dmensiones (canales, pares, alturas) | |
514 | data_cspc = None |
|
531 | data_cspc = None | |
515 |
|
532 | |||
516 | # data dc es un numpy array de 2 dmensiones (canales, alturas) |
|
533 | # data dc es un numpy array de 2 dmensiones (canales, alturas) | |
517 | data_dc = None |
|
534 | data_dc = None | |
518 |
|
535 | |||
519 | # data power |
|
536 | # data power | |
520 | data_pwr = None |
|
537 | data_pwr = None | |
521 |
|
538 | |||
522 | nFFTPoints = None |
|
539 | nFFTPoints = None | |
523 |
|
540 | |||
524 | # nPairs = None |
|
541 | # nPairs = None | |
525 |
|
542 | |||
526 | pairsList = None |
|
543 | pairsList = None | |
527 |
|
544 | |||
528 | nIncohInt = None |
|
545 | nIncohInt = None | |
529 |
|
546 | |||
530 | wavelength = None # Necesario para cacular el rango de velocidad desde la frecuencia |
|
547 | wavelength = None # Necesario para cacular el rango de velocidad desde la frecuencia | |
531 |
|
548 | |||
532 | nCohInt = None # se requiere para determinar el valor de timeInterval |
|
549 | nCohInt = None # se requiere para determinar el valor de timeInterval | |
533 |
|
550 | |||
534 | ippFactor = None |
|
551 | ippFactor = None | |
535 |
|
552 | |||
536 | profileIndex = 0 |
|
553 | profileIndex = 0 | |
537 |
|
554 | |||
538 | plotting = "spectra" |
|
555 | plotting = "spectra" | |
539 |
|
556 | |||
540 | def __init__(self): |
|
557 | def __init__(self): | |
541 | ''' |
|
558 | ''' | |
542 | Constructor |
|
559 | Constructor | |
543 | ''' |
|
560 | ''' | |
544 |
|
561 | |||
545 | self.useLocalTime = True |
|
562 | self.useLocalTime = True | |
546 |
|
563 | |||
547 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
564 | self.radarControllerHeaderObj = RadarControllerHeader() | |
548 |
|
565 | |||
549 | self.systemHeaderObj = SystemHeader() |
|
566 | self.systemHeaderObj = SystemHeader() | |
550 |
|
567 | |||
551 | self.type = "Spectra" |
|
568 | self.type = "Spectra" | |
552 |
|
569 | |||
553 | # self.data = None |
|
570 | # self.data = None | |
554 |
|
571 | |||
555 | # self.dtype = None |
|
572 | # self.dtype = None | |
556 |
|
573 | |||
557 | # self.nChannels = 0 |
|
574 | # self.nChannels = 0 | |
558 |
|
575 | |||
559 | # self.nHeights = 0 |
|
576 | # self.nHeights = 0 | |
560 |
|
577 | |||
561 | self.nProfiles = None |
|
578 | self.nProfiles = None | |
562 |
|
579 | |||
563 | self.heightList = None |
|
580 | self.heightList = None | |
564 |
|
581 | |||
565 | self.channelList = None |
|
582 | self.channelList = None | |
566 |
|
583 | |||
567 | # self.channelIndexList = None |
|
584 | # self.channelIndexList = None | |
568 |
|
585 | |||
569 | self.pairsList = None |
|
586 | self.pairsList = None | |
570 |
|
587 | |||
571 | self.flagNoData = True |
|
588 | self.flagNoData = True | |
572 |
|
589 | |||
573 | self.flagDiscontinuousBlock = False |
|
590 | self.flagDiscontinuousBlock = False | |
574 |
|
591 | |||
575 | self.utctime = None |
|
592 | self.utctime = None | |
576 |
|
593 | |||
577 | self.nCohInt = None |
|
594 | self.nCohInt = None | |
578 |
|
595 | |||
579 | self.nIncohInt = None |
|
596 | self.nIncohInt = None | |
580 |
|
597 | |||
581 | self.blocksize = None |
|
598 | self.blocksize = None | |
582 |
|
599 | |||
583 | self.nFFTPoints = None |
|
600 | self.nFFTPoints = None | |
584 |
|
601 | |||
585 | self.wavelength = None |
|
602 | self.wavelength = None | |
586 |
|
603 | |||
587 | self.flagDecodeData = False # asumo q la data no esta decodificada |
|
604 | self.flagDecodeData = False # asumo q la data no esta decodificada | |
588 |
|
605 | |||
589 | self.flagDeflipData = False # asumo q la data no esta sin flip |
|
606 | self.flagDeflipData = False # asumo q la data no esta sin flip | |
590 |
|
607 | |||
591 | self.flagShiftFFT = False |
|
608 | self.flagShiftFFT = False | |
592 |
|
609 | |||
593 | self.ippFactor = 1 |
|
610 | self.ippFactor = 1 | |
594 |
|
611 | |||
595 | #self.noise = None |
|
612 | #self.noise = None | |
596 |
|
613 | |||
597 | self.beacon_heiIndexList = [] |
|
614 | self.beacon_heiIndexList = [] | |
598 |
|
615 | |||
599 | self.noise_estimation = None |
|
616 | self.noise_estimation = None | |
600 |
|
617 | |||
601 | def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): |
|
618 | def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): | |
602 | """ |
|
619 | """ | |
603 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
620 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
604 |
|
621 | |||
605 | Return: |
|
622 | Return: | |
606 | noiselevel |
|
623 | noiselevel | |
607 | """ |
|
624 | """ | |
608 |
|
625 | |||
609 | noise = numpy.zeros(self.nChannels) |
|
626 | noise = numpy.zeros(self.nChannels) | |
610 |
|
627 | |||
611 | for channel in range(self.nChannels): |
|
628 | for channel in range(self.nChannels): | |
612 | daux = self.data_spc[channel, |
|
629 | daux = self.data_spc[channel, | |
613 | xmin_index:xmax_index, ymin_index:ymax_index] |
|
630 | xmin_index:xmax_index, ymin_index:ymax_index] | |
614 |
|
631 | |||
615 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) |
|
632 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) | |
616 |
|
633 | |||
617 | return noise |
|
634 | return noise | |
618 |
|
635 | |||
619 | def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): |
|
636 | def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): | |
620 |
|
637 | |||
621 | if self.noise_estimation is not None: |
|
638 | if self.noise_estimation is not None: | |
622 | # this was estimated by getNoise Operation defined in jroproc_spectra.py |
|
639 | # this was estimated by getNoise Operation defined in jroproc_spectra.py | |
623 | return self.noise_estimation |
|
640 | return self.noise_estimation | |
624 | else: |
|
641 | else: | |
625 | noise = self.getNoisebyHildebrand( |
|
642 | noise = self.getNoisebyHildebrand( | |
626 | xmin_index, xmax_index, ymin_index, ymax_index) |
|
643 | xmin_index, xmax_index, ymin_index, ymax_index) | |
627 | return noise |
|
644 | return noise | |
628 |
|
645 | |||
629 | def getFreqRangeTimeResponse(self, extrapoints=0): |
|
646 | def getFreqRangeTimeResponse(self, extrapoints=0): | |
630 |
|
647 | |||
631 | deltafreq = self.getFmaxTimeResponse() / (self.nFFTPoints * self.ippFactor) |
|
648 | deltafreq = self.getFmaxTimeResponse() / (self.nFFTPoints * self.ippFactor) | |
632 | freqrange = deltafreq * \ |
|
649 | freqrange = deltafreq * \ | |
633 | (numpy.arange(self.nFFTPoints + extrapoints) - |
|
650 | (numpy.arange(self.nFFTPoints + extrapoints) - | |
634 | self.nFFTPoints / 2.) - deltafreq / 2 |
|
651 | self.nFFTPoints / 2.) - deltafreq / 2 | |
635 |
|
652 | |||
636 | return freqrange |
|
653 | return freqrange | |
637 |
|
654 | |||
638 | def getAcfRange(self, extrapoints=0): |
|
655 | def getAcfRange(self, extrapoints=0): | |
639 | #print "GET ACF RANGE" |
|
656 | #print "GET ACF RANGE" | |
640 | #print "NFFTPoints",self.nFFTPoints |
|
657 | #print "NFFTPoints",self.nFFTPoints | |
641 | #print "IPPFactor", self.ippFactor |
|
658 | #print "IPPFactor", self.ippFactor | |
642 | #deltafreq = 10. / ( self.getFmax() / (self.nFFTPoints * self.ippFactor) ) |
|
659 | #deltafreq = 10. / ( self.getFmax() / (self.nFFTPoints * self.ippFactor) ) | |
643 | deltatime = 1./(self.getFmax()/ self.ippFactor) |
|
660 | deltatime = 1./(self.getFmax()/ self.ippFactor) | |
644 | #print "getFmax",self.getFmax() |
|
661 | #print "getFmax",self.getFmax() | |
645 | #import time |
|
662 | #import time | |
646 | #time.sleep(30) |
|
663 | #time.sleep(30) | |
647 | timerange = deltatime * \ |
|
664 | timerange = deltatime * \ | |
648 | (numpy.arange(self.nFFTPoints + extrapoints) - |
|
665 | (numpy.arange(self.nFFTPoints + extrapoints) - | |
649 | self.nFFTPoints / 2.) |
|
666 | self.nFFTPoints / 2.) | |
650 | #- deltafreq / 2 |
|
667 | #- deltafreq / 2 | |
651 | #print "timerange",timerange |
|
668 | #print "timerange",timerange | |
652 | return timerange |
|
669 | return timerange | |
653 |
|
670 | |||
654 | def getFreqRange(self, extrapoints=0): |
|
671 | def getFreqRange(self, extrapoints=0): | |
655 |
|
672 | |||
656 | deltafreq = self.getFmax() / (self.nFFTPoints * self.ippFactor) |
|
673 | deltafreq = self.getFmax() / (self.nFFTPoints * self.ippFactor) | |
657 | #print "deltafreq", deltafreq |
|
674 | #print "deltafreq", deltafreq | |
658 | freqrange = deltafreq * \ |
|
675 | freqrange = deltafreq * \ | |
659 | (numpy.arange(self.nFFTPoints + extrapoints) - |
|
676 | (numpy.arange(self.nFFTPoints + extrapoints) - | |
660 | self.nFFTPoints / 2.) - deltafreq / 2 |
|
677 | self.nFFTPoints / 2.) - deltafreq / 2 | |
661 | #print "freqrange",freqrange |
|
678 | #print "freqrange",freqrange | |
662 | return freqrange |
|
679 | return freqrange | |
663 |
|
680 | |||
664 | def getVelRange(self, extrapoints=0): |
|
681 | def getVelRange(self, extrapoints=0): | |
665 |
|
682 | |||
666 | deltav = self.getVmax() / (self.nFFTPoints * self.ippFactor) |
|
683 | deltav = self.getVmax() / (self.nFFTPoints * self.ippFactor) | |
667 | velrange = deltav * (numpy.arange(self.nFFTPoints + |
|
684 | velrange = deltav * (numpy.arange(self.nFFTPoints + | |
668 | extrapoints) - self.nFFTPoints / 2.) # - deltav/2 |
|
685 | extrapoints) - self.nFFTPoints / 2.) # - deltav/2 | |
669 |
|
686 | |||
670 | return velrange |
|
687 | return velrange | |
671 |
|
688 | |||
672 | def getNPairs(self): |
|
689 | def getNPairs(self): | |
673 |
|
690 | |||
674 | return len(self.pairsList) |
|
691 | return len(self.pairsList) | |
675 |
|
692 | |||
676 | def getPairsIndexList(self): |
|
693 | def getPairsIndexList(self): | |
677 |
|
694 | |||
678 | return range(self.nPairs) |
|
695 | return range(self.nPairs) | |
679 |
|
696 | |||
680 | def getNormFactor(self): |
|
697 | def getNormFactor(self): | |
681 |
|
698 | |||
682 | pwcode = 1 |
|
699 | pwcode = 1 | |
683 |
|
700 | |||
684 | if self.flagDecodeData: |
|
701 | if self.flagDecodeData: | |
685 | pwcode = numpy.sum(self.code[0]**2) |
|
702 | pwcode = numpy.sum(self.code[0]**2) | |
686 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter |
|
703 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
687 | normFactor = self.nProfiles * self.nIncohInt * \ |
|
704 | normFactor = self.nProfiles * self.nIncohInt * \ | |
688 | self.nCohInt * pwcode * self.windowOfFilter |
|
705 | self.nCohInt * pwcode * self.windowOfFilter | |
689 |
|
706 | |||
690 | return normFactor |
|
707 | return normFactor | |
691 |
|
708 | |||
692 | def getFlagCspc(self): |
|
709 | def getFlagCspc(self): | |
693 |
|
710 | |||
694 | if self.data_cspc is None: |
|
711 | if self.data_cspc is None: | |
695 | return True |
|
712 | return True | |
696 |
|
713 | |||
697 | return False |
|
714 | return False | |
698 |
|
715 | |||
699 | def getFlagDc(self): |
|
716 | def getFlagDc(self): | |
700 |
|
717 | |||
701 | if self.data_dc is None: |
|
718 | if self.data_dc is None: | |
702 | return True |
|
719 | return True | |
703 |
|
720 | |||
704 | return False |
|
721 | return False | |
705 |
|
722 | |||
706 | def getTimeInterval(self): |
|
723 | def getTimeInterval(self): | |
707 |
|
724 | |||
708 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles * self.ippFactor |
|
725 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles * self.ippFactor | |
709 |
|
726 | |||
710 | return timeInterval |
|
727 | return timeInterval | |
711 |
|
728 | |||
712 | def getPower(self): |
|
729 | def getPower(self): | |
713 |
|
730 | |||
714 | factor = self.normFactor |
|
731 | factor = self.normFactor | |
715 | z = self.data_spc / factor |
|
732 | z = self.data_spc / factor | |
716 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
733 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
717 | avg = numpy.average(z, axis=1) |
|
734 | avg = numpy.average(z, axis=1) | |
718 |
|
735 | |||
719 | return 10 * numpy.log10(avg) |
|
736 | return 10 * numpy.log10(avg) | |
720 |
|
737 | |||
721 | def getCoherence(self, pairsList=None, phase=False): |
|
738 | def getCoherence(self, pairsList=None, phase=False): | |
722 |
|
739 | |||
723 | z = [] |
|
740 | z = [] | |
724 | if pairsList is None: |
|
741 | if pairsList is None: | |
725 | pairsIndexList = self.pairsIndexList |
|
742 | pairsIndexList = self.pairsIndexList | |
726 | else: |
|
743 | else: | |
727 | pairsIndexList = [] |
|
744 | pairsIndexList = [] | |
728 | for pair in pairsList: |
|
745 | for pair in pairsList: | |
729 | if pair not in self.pairsList: |
|
746 | if pair not in self.pairsList: | |
730 | raise ValueError, "Pair %s is not in dataOut.pairsList" % ( |
|
747 | raise ValueError, "Pair %s is not in dataOut.pairsList" % ( | |
731 | pair) |
|
748 | pair) | |
732 | pairsIndexList.append(self.pairsList.index(pair)) |
|
749 | pairsIndexList.append(self.pairsList.index(pair)) | |
733 | for i in range(len(pairsIndexList)): |
|
750 | for i in range(len(pairsIndexList)): | |
734 | pair = self.pairsList[pairsIndexList[i]] |
|
751 | pair = self.pairsList[pairsIndexList[i]] | |
735 | ccf = numpy.average( |
|
752 | ccf = numpy.average( | |
736 | self.data_cspc[pairsIndexList[i], :, :], axis=0) |
|
753 | self.data_cspc[pairsIndexList[i], :, :], axis=0) | |
737 | powa = numpy.average(self.data_spc[pair[0], :, :], axis=0) |
|
754 | powa = numpy.average(self.data_spc[pair[0], :, :], axis=0) | |
738 | powb = numpy.average(self.data_spc[pair[1], :, :], axis=0) |
|
755 | powb = numpy.average(self.data_spc[pair[1], :, :], axis=0) | |
739 | avgcoherenceComplex = ccf / numpy.sqrt(powa * powb) |
|
756 | avgcoherenceComplex = ccf / numpy.sqrt(powa * powb) | |
740 | if phase: |
|
757 | if phase: | |
741 | data = numpy.arctan2(avgcoherenceComplex.imag, |
|
758 | data = numpy.arctan2(avgcoherenceComplex.imag, | |
742 | avgcoherenceComplex.real) * 180 / numpy.pi |
|
759 | avgcoherenceComplex.real) * 180 / numpy.pi | |
743 | else: |
|
760 | else: | |
744 | data = numpy.abs(avgcoherenceComplex) |
|
761 | data = numpy.abs(avgcoherenceComplex) | |
745 |
|
762 | |||
746 | z.append(data) |
|
763 | z.append(data) | |
747 |
|
764 | |||
748 | return numpy.array(z) |
|
765 | return numpy.array(z) | |
749 |
|
766 | |||
750 | def setValue(self, value): |
|
767 | def setValue(self, value): | |
751 |
|
768 | |||
752 | print "This property should not be initialized" |
|
769 | print "This property should not be initialized" | |
753 |
|
770 | |||
754 | return |
|
771 | return | |
755 |
|
772 | |||
756 | nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.") |
|
773 | nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.") | |
757 | pairsIndexList = property( |
|
774 | pairsIndexList = property( | |
758 | getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.") |
|
775 | getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.") | |
759 | normFactor = property(getNormFactor, setValue, |
|
776 | normFactor = property(getNormFactor, setValue, | |
760 | "I'm the 'getNormFactor' property.") |
|
777 | "I'm the 'getNormFactor' property.") | |
761 | flag_cspc = property(getFlagCspc, setValue) |
|
778 | flag_cspc = property(getFlagCspc, setValue) | |
762 | flag_dc = property(getFlagDc, setValue) |
|
779 | flag_dc = property(getFlagDc, setValue) | |
763 | noise = property(getNoise, setValue, "I'm the 'nHeights' property.") |
|
780 | noise = property(getNoise, setValue, "I'm the 'nHeights' property.") | |
764 | timeInterval = property(getTimeInterval, setValue, |
|
781 | timeInterval = property(getTimeInterval, setValue, | |
765 | "I'm the 'timeInterval' property") |
|
782 | "I'm the 'timeInterval' property") | |
766 |
|
783 | |||
767 |
|
784 | |||
768 | class SpectraHeis(Spectra): |
|
785 | class SpectraHeis(Spectra): | |
769 |
|
786 | |||
770 | data_spc = None |
|
787 | data_spc = None | |
771 |
|
788 | |||
772 | data_cspc = None |
|
789 | data_cspc = None | |
773 |
|
790 | |||
774 | data_dc = None |
|
791 | data_dc = None | |
775 |
|
792 | |||
776 | nFFTPoints = None |
|
793 | nFFTPoints = None | |
777 |
|
794 | |||
778 | # nPairs = None |
|
795 | # nPairs = None | |
779 |
|
796 | |||
780 | pairsList = None |
|
797 | pairsList = None | |
781 |
|
798 | |||
782 | nCohInt = None |
|
799 | nCohInt = None | |
783 |
|
800 | |||
784 | nIncohInt = None |
|
801 | nIncohInt = None | |
785 |
|
802 | |||
786 | def __init__(self): |
|
803 | def __init__(self): | |
787 |
|
804 | |||
788 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
805 | self.radarControllerHeaderObj = RadarControllerHeader() | |
789 |
|
806 | |||
790 | self.systemHeaderObj = SystemHeader() |
|
807 | self.systemHeaderObj = SystemHeader() | |
791 |
|
808 | |||
792 | self.type = "SpectraHeis" |
|
809 | self.type = "SpectraHeis" | |
793 |
|
810 | |||
794 | # self.dtype = None |
|
811 | # self.dtype = None | |
795 |
|
812 | |||
796 | # self.nChannels = 0 |
|
813 | # self.nChannels = 0 | |
797 |
|
814 | |||
798 | # self.nHeights = 0 |
|
815 | # self.nHeights = 0 | |
799 |
|
816 | |||
800 | self.nProfiles = None |
|
817 | self.nProfiles = None | |
801 |
|
818 | |||
802 | self.heightList = None |
|
819 | self.heightList = None | |
803 |
|
820 | |||
804 | self.channelList = None |
|
821 | self.channelList = None | |
805 |
|
822 | |||
806 | # self.channelIndexList = None |
|
823 | # self.channelIndexList = None | |
807 |
|
824 | |||
808 | self.flagNoData = True |
|
825 | self.flagNoData = True | |
809 |
|
826 | |||
810 | self.flagDiscontinuousBlock = False |
|
827 | self.flagDiscontinuousBlock = False | |
811 |
|
828 | |||
812 | # self.nPairs = 0 |
|
829 | # self.nPairs = 0 | |
813 |
|
830 | |||
814 | self.utctime = None |
|
831 | self.utctime = None | |
815 |
|
832 | |||
816 | self.blocksize = None |
|
833 | self.blocksize = None | |
817 |
|
834 | |||
818 | self.profileIndex = 0 |
|
835 | self.profileIndex = 0 | |
819 |
|
836 | |||
820 | self.nCohInt = 1 |
|
837 | self.nCohInt = 1 | |
821 |
|
838 | |||
822 | self.nIncohInt = 1 |
|
839 | self.nIncohInt = 1 | |
823 |
|
840 | |||
824 | def getNormFactor(self): |
|
841 | def getNormFactor(self): | |
825 | pwcode = 1 |
|
842 | pwcode = 1 | |
826 | if self.flagDecodeData: |
|
843 | if self.flagDecodeData: | |
827 | pwcode = numpy.sum(self.code[0]**2) |
|
844 | pwcode = numpy.sum(self.code[0]**2) | |
828 |
|
845 | |||
829 | normFactor = self.nIncohInt * self.nCohInt * pwcode |
|
846 | normFactor = self.nIncohInt * self.nCohInt * pwcode | |
830 |
|
847 | |||
831 | return normFactor |
|
848 | return normFactor | |
832 |
|
849 | |||
833 | def getTimeInterval(self): |
|
850 | def getTimeInterval(self): | |
834 |
|
851 | |||
835 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt |
|
852 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt | |
836 |
|
853 | |||
837 | return timeInterval |
|
854 | return timeInterval | |
838 |
|
855 | |||
839 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") |
|
856 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") | |
840 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
857 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
841 |
|
858 | |||
842 |
|
859 | |||
843 | class Fits(JROData): |
|
860 | class Fits(JROData): | |
844 |
|
861 | |||
845 | heightList = None |
|
862 | heightList = None | |
846 |
|
863 | |||
847 | channelList = None |
|
864 | channelList = None | |
848 |
|
865 | |||
849 | flagNoData = True |
|
866 | flagNoData = True | |
850 |
|
867 | |||
851 | flagDiscontinuousBlock = False |
|
868 | flagDiscontinuousBlock = False | |
852 |
|
869 | |||
853 | useLocalTime = False |
|
870 | useLocalTime = False | |
854 |
|
871 | |||
855 | utctime = None |
|
872 | utctime = None | |
856 |
|
873 | |||
857 | timeZone = None |
|
874 | timeZone = None | |
858 |
|
875 | |||
859 | # ippSeconds = None |
|
876 | # ippSeconds = None | |
860 |
|
877 | |||
861 | # timeInterval = None |
|
878 | # timeInterval = None | |
862 |
|
879 | |||
863 | nCohInt = None |
|
880 | nCohInt = None | |
864 |
|
881 | |||
865 | nIncohInt = None |
|
882 | nIncohInt = None | |
866 |
|
883 | |||
867 | noise = None |
|
884 | noise = None | |
868 |
|
885 | |||
869 | windowOfFilter = 1 |
|
886 | windowOfFilter = 1 | |
870 |
|
887 | |||
871 | # Speed of ligth |
|
888 | # Speed of ligth | |
872 | C = 3e8 |
|
889 | C = 3e8 | |
873 |
|
890 | |||
874 | frequency = 49.92e6 |
|
891 | frequency = 49.92e6 | |
875 |
|
892 | |||
876 | realtime = False |
|
893 | realtime = False | |
877 |
|
894 | |||
878 | def __init__(self): |
|
895 | def __init__(self): | |
879 |
|
896 | |||
880 | self.type = "Fits" |
|
897 | self.type = "Fits" | |
881 |
|
898 | |||
882 | self.nProfiles = None |
|
899 | self.nProfiles = None | |
883 |
|
900 | |||
884 | self.heightList = None |
|
901 | self.heightList = None | |
885 |
|
902 | |||
886 | self.channelList = None |
|
903 | self.channelList = None | |
887 |
|
904 | |||
888 | # self.channelIndexList = None |
|
905 | # self.channelIndexList = None | |
889 |
|
906 | |||
890 | self.flagNoData = True |
|
907 | self.flagNoData = True | |
891 |
|
908 | |||
892 | self.utctime = None |
|
909 | self.utctime = None | |
893 |
|
910 | |||
894 | self.nCohInt = 1 |
|
911 | self.nCohInt = 1 | |
895 |
|
912 | |||
896 | self.nIncohInt = 1 |
|
913 | self.nIncohInt = 1 | |
897 |
|
914 | |||
898 | self.useLocalTime = True |
|
915 | self.useLocalTime = True | |
899 |
|
916 | |||
900 | self.profileIndex = 0 |
|
917 | self.profileIndex = 0 | |
901 |
|
918 | |||
902 | # self.utctime = None |
|
919 | # self.utctime = None | |
903 | # self.timeZone = None |
|
920 | # self.timeZone = None | |
904 | # self.ltctime = None |
|
921 | # self.ltctime = None | |
905 | # self.timeInterval = None |
|
922 | # self.timeInterval = None | |
906 | # self.header = None |
|
923 | # self.header = None | |
907 | # self.data_header = None |
|
924 | # self.data_header = None | |
908 | # self.data = None |
|
925 | # self.data = None | |
909 | # self.datatime = None |
|
926 | # self.datatime = None | |
910 | # self.flagNoData = False |
|
927 | # self.flagNoData = False | |
911 | # self.expName = '' |
|
928 | # self.expName = '' | |
912 | # self.nChannels = None |
|
929 | # self.nChannels = None | |
913 | # self.nSamples = None |
|
930 | # self.nSamples = None | |
914 | # self.dataBlocksPerFile = None |
|
931 | # self.dataBlocksPerFile = None | |
915 | # self.comments = '' |
|
932 | # self.comments = '' | |
916 | # |
|
933 | # | |
917 |
|
934 | |||
918 | def getltctime(self): |
|
935 | def getltctime(self): | |
919 |
|
936 | |||
920 | if self.useLocalTime: |
|
937 | if self.useLocalTime: | |
921 | return self.utctime - self.timeZone * 60 |
|
938 | return self.utctime - self.timeZone * 60 | |
922 |
|
939 | |||
923 | return self.utctime |
|
940 | return self.utctime | |
924 |
|
941 | |||
925 | def getDatatime(self): |
|
942 | def getDatatime(self): | |
926 |
|
943 | |||
927 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
944 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) | |
928 | return datatime |
|
945 | return datatime | |
929 |
|
946 | |||
930 | def getTimeRange(self): |
|
947 | def getTimeRange(self): | |
931 |
|
948 | |||
932 | datatime = [] |
|
949 | datatime = [] | |
933 |
|
950 | |||
934 | datatime.append(self.ltctime) |
|
951 | datatime.append(self.ltctime) | |
935 | datatime.append(self.ltctime + self.timeInterval) |
|
952 | datatime.append(self.ltctime + self.timeInterval) | |
936 |
|
953 | |||
937 | datatime = numpy.array(datatime) |
|
954 | datatime = numpy.array(datatime) | |
938 |
|
955 | |||
939 | return datatime |
|
956 | return datatime | |
940 |
|
957 | |||
941 | def getHeiRange(self): |
|
958 | def getHeiRange(self): | |
942 |
|
959 | |||
943 | heis = self.heightList |
|
960 | heis = self.heightList | |
944 |
|
961 | |||
945 | return heis |
|
962 | return heis | |
946 |
|
963 | |||
947 | def getNHeights(self): |
|
964 | def getNHeights(self): | |
948 |
|
965 | |||
949 | return len(self.heightList) |
|
966 | return len(self.heightList) | |
950 |
|
967 | |||
951 | def getNChannels(self): |
|
968 | def getNChannels(self): | |
952 |
|
969 | |||
953 | return len(self.channelList) |
|
970 | return len(self.channelList) | |
954 |
|
971 | |||
955 | def getChannelIndexList(self): |
|
972 | def getChannelIndexList(self): | |
956 |
|
973 | |||
957 | return range(self.nChannels) |
|
974 | return range(self.nChannels) | |
958 |
|
975 | |||
959 | def getNoise(self, type=1): |
|
976 | def getNoise(self, type=1): | |
960 |
|
977 | |||
961 | #noise = numpy.zeros(self.nChannels) |
|
978 | #noise = numpy.zeros(self.nChannels) | |
962 |
|
979 | |||
963 | if type == 1: |
|
980 | if type == 1: | |
964 | noise = self.getNoisebyHildebrand() |
|
981 | noise = self.getNoisebyHildebrand() | |
965 |
|
982 | |||
966 | if type == 2: |
|
983 | if type == 2: | |
967 | noise = self.getNoisebySort() |
|
984 | noise = self.getNoisebySort() | |
968 |
|
985 | |||
969 | if type == 3: |
|
986 | if type == 3: | |
970 | noise = self.getNoisebyWindow() |
|
987 | noise = self.getNoisebyWindow() | |
971 |
|
988 | |||
972 | return noise |
|
989 | return noise | |
973 |
|
990 | |||
974 | def getTimeInterval(self): |
|
991 | def getTimeInterval(self): | |
975 |
|
992 | |||
976 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt |
|
993 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt | |
977 |
|
994 | |||
978 | return timeInterval |
|
995 | return timeInterval | |
979 |
|
996 | |||
980 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
997 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
981 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
998 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
982 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
999 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
983 | channelIndexList = property( |
|
1000 | channelIndexList = property( | |
984 | getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
1001 | getChannelIndexList, "I'm the 'channelIndexList' property.") | |
985 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
1002 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
986 |
|
1003 | |||
987 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
1004 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
988 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
1005 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
989 |
|
1006 | |||
990 |
|
1007 | |||
991 | class Correlation(JROData): |
|
1008 | class Correlation(JROData): | |
992 |
|
1009 | |||
993 | noise = None |
|
1010 | noise = None | |
994 |
|
1011 | |||
995 | SNR = None |
|
1012 | SNR = None | |
996 |
|
1013 | |||
997 | #-------------------------------------------------- |
|
1014 | #-------------------------------------------------- | |
998 |
|
1015 | |||
999 | mode = None |
|
1016 | mode = None | |
1000 |
|
1017 | |||
1001 | split = False |
|
1018 | split = False | |
1002 |
|
1019 | |||
1003 | data_cf = None |
|
1020 | data_cf = None | |
1004 |
|
1021 | |||
1005 | lags = None |
|
1022 | lags = None | |
1006 |
|
1023 | |||
1007 | lagRange = None |
|
1024 | lagRange = None | |
1008 |
|
1025 | |||
1009 | pairsList = None |
|
1026 | pairsList = None | |
1010 |
|
1027 | |||
1011 | normFactor = None |
|
1028 | normFactor = None | |
1012 |
|
1029 | |||
1013 | #-------------------------------------------------- |
|
1030 | #-------------------------------------------------- | |
1014 |
|
1031 | |||
1015 | # calculateVelocity = None |
|
1032 | # calculateVelocity = None | |
1016 |
|
1033 | |||
1017 | nLags = None |
|
1034 | nLags = None | |
1018 |
|
1035 | |||
1019 | nPairs = None |
|
1036 | nPairs = None | |
1020 |
|
1037 | |||
1021 | nAvg = None |
|
1038 | nAvg = None | |
1022 |
|
1039 | |||
1023 | def __init__(self): |
|
1040 | def __init__(self): | |
1024 | ''' |
|
1041 | ''' | |
1025 | Constructor |
|
1042 | Constructor | |
1026 | ''' |
|
1043 | ''' | |
1027 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
1044 | self.radarControllerHeaderObj = RadarControllerHeader() | |
1028 |
|
1045 | |||
1029 | self.systemHeaderObj = SystemHeader() |
|
1046 | self.systemHeaderObj = SystemHeader() | |
1030 |
|
1047 | |||
1031 | self.type = "Correlation" |
|
1048 | self.type = "Correlation" | |
1032 |
|
1049 | |||
1033 | self.data = None |
|
1050 | self.data = None | |
1034 |
|
1051 | |||
1035 | self.dtype = None |
|
1052 | self.dtype = None | |
1036 |
|
1053 | |||
1037 | self.nProfiles = None |
|
1054 | self.nProfiles = None | |
1038 |
|
1055 | |||
1039 | self.heightList = None |
|
1056 | self.heightList = None | |
1040 |
|
1057 | |||
1041 | self.channelList = None |
|
1058 | self.channelList = None | |
1042 |
|
1059 | |||
1043 | self.flagNoData = True |
|
1060 | self.flagNoData = True | |
1044 |
|
1061 | |||
1045 | self.flagDiscontinuousBlock = False |
|
1062 | self.flagDiscontinuousBlock = False | |
1046 |
|
1063 | |||
1047 | self.utctime = None |
|
1064 | self.utctime = None | |
1048 |
|
1065 | |||
1049 | self.timeZone = None |
|
1066 | self.timeZone = None | |
1050 |
|
1067 | |||
1051 | self.dstFlag = None |
|
1068 | self.dstFlag = None | |
1052 |
|
1069 | |||
1053 | self.errorCount = None |
|
1070 | self.errorCount = None | |
1054 |
|
1071 | |||
1055 | self.blocksize = None |
|
1072 | self.blocksize = None | |
1056 |
|
1073 | |||
1057 | self.flagDecodeData = False # asumo q la data no esta decodificada |
|
1074 | self.flagDecodeData = False # asumo q la data no esta decodificada | |
1058 |
|
1075 | |||
1059 | self.flagDeflipData = False # asumo q la data no esta sin flip |
|
1076 | self.flagDeflipData = False # asumo q la data no esta sin flip | |
1060 |
|
1077 | |||
1061 | self.pairsList = None |
|
1078 | self.pairsList = None | |
1062 |
|
1079 | |||
1063 | self.nPoints = None |
|
1080 | self.nPoints = None | |
1064 |
|
1081 | |||
1065 | def getPairsList(self): |
|
1082 | def getPairsList(self): | |
1066 |
|
1083 | |||
1067 | return self.pairsList |
|
1084 | return self.pairsList | |
1068 |
|
1085 | |||
1069 | def getNoise(self, mode=2): |
|
1086 | def getNoise(self, mode=2): | |
1070 |
|
1087 | |||
1071 | indR = numpy.where(self.lagR == 0)[0][0] |
|
1088 | indR = numpy.where(self.lagR == 0)[0][0] | |
1072 | indT = numpy.where(self.lagT == 0)[0][0] |
|
1089 | indT = numpy.where(self.lagT == 0)[0][0] | |
1073 |
|
1090 | |||
1074 | jspectra0 = self.data_corr[:, :, indR, :] |
|
1091 | jspectra0 = self.data_corr[:, :, indR, :] | |
1075 | jspectra = copy.copy(jspectra0) |
|
1092 | jspectra = copy.copy(jspectra0) | |
1076 |
|
1093 | |||
1077 | num_chan = jspectra.shape[0] |
|
1094 | num_chan = jspectra.shape[0] | |
1078 | num_hei = jspectra.shape[2] |
|
1095 | num_hei = jspectra.shape[2] | |
1079 |
|
1096 | |||
1080 | freq_dc = jspectra.shape[1] / 2 |
|
1097 | freq_dc = jspectra.shape[1] / 2 | |
1081 | ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc |
|
1098 | ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc | |
1082 |
|
1099 | |||
1083 | if ind_vel[0] < 0: |
|
1100 | if ind_vel[0] < 0: | |
1084 | ind_vel[range(0, 1)] = ind_vel[range(0, 1)] + self.num_prof |
|
1101 | ind_vel[range(0, 1)] = ind_vel[range(0, 1)] + self.num_prof | |
1085 |
|
1102 | |||
1086 | if mode == 1: |
|
1103 | if mode == 1: | |
1087 | jspectra[:, freq_dc, :] = ( |
|
1104 | jspectra[:, freq_dc, :] = ( | |
1088 | jspectra[:, ind_vel[1], :] + jspectra[:, ind_vel[2], :]) / 2 # CORRECCION |
|
1105 | jspectra[:, ind_vel[1], :] + jspectra[:, ind_vel[2], :]) / 2 # CORRECCION | |
1089 |
|
1106 | |||
1090 | if mode == 2: |
|
1107 | if mode == 2: | |
1091 |
|
1108 | |||
1092 | vel = numpy.array([-2, -1, 1, 2]) |
|
1109 | vel = numpy.array([-2, -1, 1, 2]) | |
1093 | xx = numpy.zeros([4, 4]) |
|
1110 | xx = numpy.zeros([4, 4]) | |
1094 |
|
1111 | |||
1095 | for fil in range(4): |
|
1112 | for fil in range(4): | |
1096 | xx[fil, :] = vel[fil]**numpy.asarray(range(4)) |
|
1113 | xx[fil, :] = vel[fil]**numpy.asarray(range(4)) | |
1097 |
|
1114 | |||
1098 | xx_inv = numpy.linalg.inv(xx) |
|
1115 | xx_inv = numpy.linalg.inv(xx) | |
1099 | xx_aux = xx_inv[0, :] |
|
1116 | xx_aux = xx_inv[0, :] | |
1100 |
|
1117 | |||
1101 | for ich in range(num_chan): |
|
1118 | for ich in range(num_chan): | |
1102 | yy = jspectra[ich, ind_vel, :] |
|
1119 | yy = jspectra[ich, ind_vel, :] | |
1103 | jspectra[ich, freq_dc, :] = numpy.dot(xx_aux, yy) |
|
1120 | jspectra[ich, freq_dc, :] = numpy.dot(xx_aux, yy) | |
1104 |
|
1121 | |||
1105 | junkid = jspectra[ich, freq_dc, :] <= 0 |
|
1122 | junkid = jspectra[ich, freq_dc, :] <= 0 | |
1106 | cjunkid = sum(junkid) |
|
1123 | cjunkid = sum(junkid) | |
1107 |
|
1124 | |||
1108 | if cjunkid.any(): |
|
1125 | if cjunkid.any(): | |
1109 | jspectra[ich, freq_dc, junkid.nonzero()] = ( |
|
1126 | jspectra[ich, freq_dc, junkid.nonzero()] = ( | |
1110 | jspectra[ich, ind_vel[1], junkid] + jspectra[ich, ind_vel[2], junkid]) / 2 |
|
1127 | jspectra[ich, ind_vel[1], junkid] + jspectra[ich, ind_vel[2], junkid]) / 2 | |
1111 |
|
1128 | |||
1112 | noise = jspectra0[:, freq_dc, :] - jspectra[:, freq_dc, :] |
|
1129 | noise = jspectra0[:, freq_dc, :] - jspectra[:, freq_dc, :] | |
1113 |
|
1130 | |||
1114 | return noise |
|
1131 | return noise | |
1115 |
|
1132 | |||
1116 | def getTimeInterval(self): |
|
1133 | def getTimeInterval(self): | |
1117 |
|
1134 | |||
1118 | timeInterval = self.ippSeconds * self.nCohInt * self.nProfiles |
|
1135 | timeInterval = self.ippSeconds * self.nCohInt * self.nProfiles | |
1119 |
|
1136 | |||
1120 | return timeInterval |
|
1137 | return timeInterval | |
1121 |
|
1138 | |||
1122 | def splitFunctions(self): |
|
1139 | def splitFunctions(self): | |
1123 |
|
1140 | |||
1124 | pairsList = self.pairsList |
|
1141 | pairsList = self.pairsList | |
1125 | ccf_pairs = [] |
|
1142 | ccf_pairs = [] | |
1126 | acf_pairs = [] |
|
1143 | acf_pairs = [] | |
1127 | ccf_ind = [] |
|
1144 | ccf_ind = [] | |
1128 | acf_ind = [] |
|
1145 | acf_ind = [] | |
1129 | for l in range(len(pairsList)): |
|
1146 | for l in range(len(pairsList)): | |
1130 | chan0 = pairsList[l][0] |
|
1147 | chan0 = pairsList[l][0] | |
1131 | chan1 = pairsList[l][1] |
|
1148 | chan1 = pairsList[l][1] | |
1132 |
|
1149 | |||
1133 | # Obteniendo pares de Autocorrelacion |
|
1150 | # Obteniendo pares de Autocorrelacion | |
1134 | if chan0 == chan1: |
|
1151 | if chan0 == chan1: | |
1135 | acf_pairs.append(chan0) |
|
1152 | acf_pairs.append(chan0) | |
1136 | acf_ind.append(l) |
|
1153 | acf_ind.append(l) | |
1137 | else: |
|
1154 | else: | |
1138 | ccf_pairs.append(pairsList[l]) |
|
1155 | ccf_pairs.append(pairsList[l]) | |
1139 | ccf_ind.append(l) |
|
1156 | ccf_ind.append(l) | |
1140 |
|
1157 | |||
1141 | data_acf = self.data_cf[acf_ind] |
|
1158 | data_acf = self.data_cf[acf_ind] | |
1142 | data_ccf = self.data_cf[ccf_ind] |
|
1159 | data_ccf = self.data_cf[ccf_ind] | |
1143 |
|
1160 | |||
1144 | return acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf |
|
1161 | return acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf | |
1145 |
|
1162 | |||
1146 | def getNormFactor(self): |
|
1163 | def getNormFactor(self): | |
1147 | acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf = self.splitFunctions() |
|
1164 | acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf = self.splitFunctions() | |
1148 | acf_pairs = numpy.array(acf_pairs) |
|
1165 | acf_pairs = numpy.array(acf_pairs) | |
1149 | normFactor = numpy.zeros((self.nPairs, self.nHeights)) |
|
1166 | normFactor = numpy.zeros((self.nPairs, self.nHeights)) | |
1150 |
|
1167 | |||
1151 | for p in range(self.nPairs): |
|
1168 | for p in range(self.nPairs): | |
1152 | pair = self.pairsList[p] |
|
1169 | pair = self.pairsList[p] | |
1153 |
|
1170 | |||
1154 | ch0 = pair[0] |
|
1171 | ch0 = pair[0] | |
1155 | ch1 = pair[1] |
|
1172 | ch1 = pair[1] | |
1156 |
|
1173 | |||
1157 | ch0_max = numpy.max(data_acf[acf_pairs == ch0, :, :], axis=1) |
|
1174 | ch0_max = numpy.max(data_acf[acf_pairs == ch0, :, :], axis=1) | |
1158 | ch1_max = numpy.max(data_acf[acf_pairs == ch1, :, :], axis=1) |
|
1175 | ch1_max = numpy.max(data_acf[acf_pairs == ch1, :, :], axis=1) | |
1159 | normFactor[p, :] = numpy.sqrt(ch0_max * ch1_max) |
|
1176 | normFactor[p, :] = numpy.sqrt(ch0_max * ch1_max) | |
1160 |
|
1177 | |||
1161 | return normFactor |
|
1178 | return normFactor | |
1162 |
|
1179 | |||
1163 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
1180 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
1164 | normFactor = property(getNormFactor, "I'm the 'normFactor property'") |
|
1181 | normFactor = property(getNormFactor, "I'm the 'normFactor property'") | |
1165 |
|
1182 | |||
1166 |
|
1183 | |||
1167 | class Parameters(Spectra): |
|
1184 | class Parameters(Spectra): | |
1168 |
|
1185 | |||
1169 | experimentInfo = None # Information about the experiment |
|
1186 | experimentInfo = None # Information about the experiment | |
1170 |
|
1187 | |||
1171 | # Information from previous data |
|
1188 | # Information from previous data | |
1172 |
|
1189 | |||
1173 | inputUnit = None # Type of data to be processed |
|
1190 | inputUnit = None # Type of data to be processed | |
1174 |
|
1191 | |||
1175 | operation = None # Type of operation to parametrize |
|
1192 | operation = None # Type of operation to parametrize | |
1176 |
|
1193 | |||
1177 | # normFactor = None #Normalization Factor |
|
1194 | # normFactor = None #Normalization Factor | |
1178 |
|
1195 | |||
1179 | groupList = None # List of Pairs, Groups, etc |
|
1196 | groupList = None # List of Pairs, Groups, etc | |
1180 |
|
1197 | |||
1181 | # Parameters |
|
1198 | # Parameters | |
1182 |
|
1199 | |||
1183 | data_param = None # Parameters obtained |
|
1200 | data_param = None # Parameters obtained | |
1184 |
|
1201 | |||
1185 | data_pre = None # Data Pre Parametrization |
|
1202 | data_pre = None # Data Pre Parametrization | |
1186 |
|
1203 | |||
1187 | data_SNR = None # Signal to Noise Ratio |
|
1204 | data_SNR = None # Signal to Noise Ratio | |
1188 |
|
1205 | |||
1189 | # heightRange = None #Heights |
|
1206 | # heightRange = None #Heights | |
1190 |
|
1207 | |||
1191 | abscissaList = None # Abscissa, can be velocities, lags or time |
|
1208 | abscissaList = None # Abscissa, can be velocities, lags or time | |
1192 |
|
1209 | |||
1193 | # noise = None #Noise Potency |
|
1210 | # noise = None #Noise Potency | |
1194 |
|
1211 | |||
1195 | utctimeInit = None # Initial UTC time |
|
1212 | utctimeInit = None # Initial UTC time | |
1196 |
|
1213 | |||
1197 | paramInterval = None # Time interval to calculate Parameters in seconds |
|
1214 | paramInterval = None # Time interval to calculate Parameters in seconds | |
1198 |
|
1215 | |||
1199 | useLocalTime = True |
|
1216 | useLocalTime = True | |
1200 |
|
1217 | |||
1201 | # Fitting |
|
1218 | # Fitting | |
1202 |
|
1219 | |||
1203 | data_error = None # Error of the estimation |
|
1220 | data_error = None # Error of the estimation | |
1204 |
|
1221 | |||
1205 | constants = None |
|
1222 | constants = None | |
1206 |
|
1223 | |||
1207 | library = None |
|
1224 | library = None | |
1208 |
|
1225 | |||
1209 | # Output signal |
|
1226 | # Output signal | |
1210 |
|
1227 | |||
1211 | outputInterval = None # Time interval to calculate output signal in seconds |
|
1228 | outputInterval = None # Time interval to calculate output signal in seconds | |
1212 |
|
1229 | |||
1213 | data_output = None # Out signal |
|
1230 | data_output = None # Out signal | |
1214 |
|
1231 | |||
1215 | nAvg = None |
|
1232 | nAvg = None | |
1216 |
|
1233 | |||
1217 | noise_estimation = None |
|
1234 | noise_estimation = None | |
1218 |
|
1235 | |||
1219 | GauSPC = None # Fit gaussian SPC |
|
1236 | GauSPC = None # Fit gaussian SPC | |
1220 |
|
1237 | |||
1221 | def __init__(self): |
|
1238 | def __init__(self): | |
1222 | ''' |
|
1239 | ''' | |
1223 | Constructor |
|
1240 | Constructor | |
1224 | ''' |
|
1241 | ''' | |
1225 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
1242 | self.radarControllerHeaderObj = RadarControllerHeader() | |
1226 |
|
1243 | |||
1227 | self.systemHeaderObj = SystemHeader() |
|
1244 | self.systemHeaderObj = SystemHeader() | |
1228 |
|
1245 | |||
1229 | self.type = "Parameters" |
|
1246 | self.type = "Parameters" | |
1230 |
|
1247 | |||
1231 | def getTimeRange1(self, interval): |
|
1248 | def getTimeRange1(self, interval): | |
1232 |
|
1249 | |||
1233 | datatime = [] |
|
1250 | datatime = [] | |
1234 |
|
1251 | |||
1235 | if self.useLocalTime: |
|
1252 | if self.useLocalTime: | |
1236 | time1 = self.utctimeInit - self.timeZone * 60 |
|
1253 | time1 = self.utctimeInit - self.timeZone * 60 | |
1237 | else: |
|
1254 | else: | |
1238 | time1 = self.utctimeInit |
|
1255 | time1 = self.utctimeInit | |
1239 |
|
1256 | |||
1240 | datatime.append(time1) |
|
1257 | datatime.append(time1) | |
1241 | datatime.append(time1 + interval) |
|
1258 | datatime.append(time1 + interval) | |
1242 | datatime = numpy.array(datatime) |
|
1259 | datatime = numpy.array(datatime) | |
1243 |
|
1260 | |||
1244 | return datatime |
|
1261 | return datatime | |
1245 |
|
1262 | |||
1246 | def getTimeInterval(self): |
|
1263 | def getTimeInterval(self): | |
1247 |
|
1264 | |||
1248 | if hasattr(self, 'timeInterval1'): |
|
1265 | if hasattr(self, 'timeInterval1'): | |
1249 | return self.timeInterval1 |
|
1266 | return self.timeInterval1 | |
1250 | else: |
|
1267 | else: | |
1251 | return self.paramInterval |
|
1268 | return self.paramInterval | |
1252 |
|
1269 | |||
1253 | def setValue(self, value): |
|
1270 | def setValue(self, value): | |
1254 |
|
1271 | |||
1255 | print "This property should not be initialized" |
|
1272 | print "This property should not be initialized" | |
1256 |
|
1273 | |||
1257 | return |
|
1274 | return | |
1258 |
|
1275 | |||
1259 | def getNoise(self): |
|
1276 | def getNoise(self): | |
1260 |
|
1277 | |||
1261 | return self.spc_noise |
|
1278 | return self.spc_noise | |
1262 |
|
1279 | |||
1263 | timeInterval = property(getTimeInterval) |
|
1280 | timeInterval = property(getTimeInterval) | |
1264 | noise = property(getNoise, setValue, "I'm the 'Noise' property.") |
|
1281 | noise = property(getNoise, setValue, "I'm the 'Noise' property.") |
@@ -1,225 +1,426 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Jul 9, 2014 |
|
2 | Created on Jul 9, 2014 | |
3 |
|
3 | |||
4 | @author: roj-idl71 |
|
4 | @author: roj-idl71 | |
5 | ''' |
|
5 | ''' | |
6 | import os |
|
6 | import os | |
7 | import datetime |
|
7 | import datetime | |
8 | import numpy |
|
8 | import numpy | |
9 |
|
9 | |||
10 | from figure import Figure |
|
10 | from figure import Figure | |
|
11 | from plotting_codes import * | |||
11 |
|
12 | |||
12 | class Scope(Figure): |
|
13 | class Scope(Figure): | |
13 |
|
14 | |||
14 | isConfig = None |
|
15 | isConfig = None | |
15 |
|
16 | |||
16 | def __init__(self, **kwargs): |
|
17 | def __init__(self, **kwargs): | |
17 | Figure.__init__(self, **kwargs) |
|
18 | Figure.__init__(self, **kwargs) | |
18 | self.isConfig = False |
|
19 | self.isConfig = False | |
19 | self.WIDTH = 300 |
|
20 | self.WIDTH = 300 | |
20 | self.HEIGHT = 200 |
|
21 | self.HEIGHT = 200 | |
21 | self.counter_imagwr = 0 |
|
22 | self.counter_imagwr = 0 | |
22 |
|
23 | |||
23 | def getSubplots(self): |
|
24 | def getSubplots(self): | |
24 |
|
25 | |||
25 | nrow = self.nplots |
|
26 | nrow = self.nplots | |
26 | ncol = 3 |
|
27 | ncol = 3 | |
27 | return nrow, ncol |
|
28 | return nrow, ncol | |
28 |
|
29 | |||
29 | def setup(self, id, nplots, wintitle, show): |
|
30 | def setup(self, id, nplots, wintitle, show): | |
30 |
|
31 | |||
31 | self.nplots = nplots |
|
32 | self.nplots = nplots | |
32 |
|
33 | |||
33 | self.createFigure(id=id, |
|
34 | self.createFigure(id=id, | |
34 | wintitle=wintitle, |
|
35 | wintitle=wintitle, | |
35 | show=show) |
|
36 | show=show) | |
36 |
|
37 | |||
37 | nrow,ncol = self.getSubplots() |
|
38 | nrow,ncol = self.getSubplots() | |
38 | colspan = 3 |
|
39 | colspan = 3 | |
39 | rowspan = 1 |
|
40 | rowspan = 1 | |
40 |
|
41 | |||
41 | for i in range(nplots): |
|
42 | for i in range(nplots): | |
42 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
43 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
43 |
|
44 | |||
44 | def plot_iq(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax): |
|
45 | def plot_iq(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax): | |
45 | yreal = y[channelIndexList,:].real |
|
46 | yreal = y[channelIndexList,:].real | |
46 | yimag = y[channelIndexList,:].imag |
|
47 | yimag = y[channelIndexList,:].imag | |
47 |
|
48 | |||
48 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
49 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
49 | xlabel = "Range (Km)" |
|
50 | xlabel = "Range (Km)" | |
50 | ylabel = "Intensity - IQ" |
|
51 | ylabel = "Intensity - IQ" | |
51 |
|
52 | |||
52 | if not self.isConfig: |
|
53 | if not self.isConfig: | |
53 | nplots = len(channelIndexList) |
|
54 | nplots = len(channelIndexList) | |
54 |
|
55 | |||
55 | self.setup(id=id, |
|
56 | self.setup(id=id, | |
56 | nplots=nplots, |
|
57 | nplots=nplots, | |
57 | wintitle='', |
|
58 | wintitle='', | |
58 | show=show) |
|
59 | show=show) | |
59 |
|
60 | |||
60 | if xmin == None: xmin = numpy.nanmin(x) |
|
61 | if xmin == None: xmin = numpy.nanmin(x) | |
61 | if xmax == None: xmax = numpy.nanmax(x) |
|
62 | if xmax == None: xmax = numpy.nanmax(x) | |
62 | if ymin == None: ymin = min(numpy.nanmin(yreal),numpy.nanmin(yimag)) |
|
63 | if ymin == None: ymin = min(numpy.nanmin(yreal),numpy.nanmin(yimag)) | |
63 | if ymax == None: ymax = max(numpy.nanmax(yreal),numpy.nanmax(yimag)) |
|
64 | if ymax == None: ymax = max(numpy.nanmax(yreal),numpy.nanmax(yimag)) | |
64 |
|
65 | |||
65 | self.isConfig = True |
|
66 | self.isConfig = True | |
66 |
|
67 | |||
67 | self.setWinTitle(title) |
|
68 | self.setWinTitle(title) | |
68 |
|
69 | |||
69 | for i in range(len(self.axesList)): |
|
70 | for i in range(len(self.axesList)): | |
70 | title = "Channel %d" %(i) |
|
71 | title = "Channel %d" %(i) | |
71 | axes = self.axesList[i] |
|
72 | axes = self.axesList[i] | |
72 |
|
73 | |||
73 | axes.pline(x, yreal[i,:], |
|
74 | axes.pline(x, yreal[i,:], | |
74 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
75 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
75 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
76 | xlabel=xlabel, ylabel=ylabel, title=title) | |
76 |
|
77 | |||
77 | axes.addpline(x, yimag[i,:], idline=1, color="red", linestyle="solid", lw=2) |
|
78 | axes.addpline(x, yimag[i,:], idline=1, color="red", linestyle="solid", lw=2) | |
78 |
|
79 | |||
79 | def plot_power(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax): |
|
80 | def plot_power(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax): | |
80 | y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:]) |
|
81 | y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:]) | |
81 | yreal = y.real |
|
82 | yreal = y.real | |
82 |
|
83 | |||
83 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
84 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
84 | xlabel = "Range (Km)" |
|
85 | xlabel = "Range (Km)" | |
85 | ylabel = "Intensity" |
|
86 | ylabel = "Intensity" | |
86 |
|
87 | |||
87 | if not self.isConfig: |
|
88 | if not self.isConfig: | |
88 | nplots = len(channelIndexList) |
|
89 | nplots = len(channelIndexList) | |
89 |
|
90 | |||
90 | self.setup(id=id, |
|
91 | self.setup(id=id, | |
91 | nplots=nplots, |
|
92 | nplots=nplots, | |
92 | wintitle='', |
|
93 | wintitle='', | |
93 | show=show) |
|
94 | show=show) | |
94 |
|
95 | |||
95 | if xmin == None: xmin = numpy.nanmin(x) |
|
96 | if xmin == None: xmin = numpy.nanmin(x) | |
96 | if xmax == None: xmax = numpy.nanmax(x) |
|
97 | if xmax == None: xmax = numpy.nanmax(x) | |
97 | if ymin == None: ymin = numpy.nanmin(yreal) |
|
98 | if ymin == None: ymin = numpy.nanmin(yreal) | |
98 | if ymax == None: ymax = numpy.nanmax(yreal) |
|
99 | if ymax == None: ymax = numpy.nanmax(yreal) | |
99 |
|
100 | |||
100 | self.isConfig = True |
|
101 | self.isConfig = True | |
101 |
|
102 | |||
102 | self.setWinTitle(title) |
|
103 | self.setWinTitle(title) | |
103 |
|
104 | |||
104 | for i in range(len(self.axesList)): |
|
105 | for i in range(len(self.axesList)): | |
105 | title = "Channel %d" %(i) |
|
106 | title = "Channel %d" %(i) | |
106 | axes = self.axesList[i] |
|
107 | axes = self.axesList[i] | |
107 | ychannel = yreal[i,:] |
|
108 | ychannel = yreal[i,:] | |
108 | axes.pline(x, ychannel, |
|
109 | axes.pline(x, ychannel, | |
109 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
110 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
110 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
111 | xlabel=xlabel, ylabel=ylabel, title=title) | |
111 |
|
112 | |||
112 |
|
113 | |||
113 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
114 | def run(self, dataOut, id, wintitle="", channelList=None, | |
114 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
115 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, | |
115 | figpath='./', figfile=None, show=True, wr_period=1, |
|
116 | figpath='./', figfile=None, show=True, wr_period=1, | |
116 | ftp=False, server=None, folder=None, username=None, password=None, type='power', **kwargs): |
|
117 | ftp=False, server=None, folder=None, username=None, password=None, type='power', **kwargs): | |
117 |
|
118 | |||
118 | """ |
|
119 | """ | |
119 |
|
120 | |||
120 | Input: |
|
121 | Input: | |
121 | dataOut : |
|
122 | dataOut : | |
122 | id : |
|
123 | id : | |
123 | wintitle : |
|
124 | wintitle : | |
124 | channelList : |
|
125 | channelList : | |
125 | xmin : None, |
|
126 | xmin : None, | |
126 | xmax : None, |
|
127 | xmax : None, | |
127 | ymin : None, |
|
128 | ymin : None, | |
128 | ymax : None, |
|
129 | ymax : None, | |
129 | """ |
|
130 | """ | |
130 |
|
131 | |||
131 | if channelList == None: |
|
132 | if channelList == None: | |
132 | channelIndexList = dataOut.channelIndexList |
|
133 | channelIndexList = dataOut.channelIndexList | |
133 | else: |
|
134 | else: | |
134 | channelIndexList = [] |
|
135 | channelIndexList = [] | |
135 | for channel in channelList: |
|
136 | for channel in channelList: | |
136 | if channel not in dataOut.channelList: |
|
137 | if channel not in dataOut.channelList: | |
137 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
138 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
138 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
139 | channelIndexList.append(dataOut.channelList.index(channel)) | |
139 |
|
140 | |||
140 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
141 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
141 |
|
142 | |||
142 | if dataOut.flagDataAsBlock: |
|
143 | if dataOut.flagDataAsBlock: | |
143 |
|
144 | |||
144 | for i in range(dataOut.nProfiles): |
|
145 | for i in range(dataOut.nProfiles): | |
145 |
|
146 | |||
146 | wintitle1 = wintitle + " [Profile = %d] " %i |
|
147 | wintitle1 = wintitle + " [Profile = %d] " %i | |
147 |
|
148 | |||
148 | if type == "power": |
|
149 | if type == "power": | |
149 | self.plot_power(dataOut.heightList, |
|
150 | self.plot_power(dataOut.heightList, | |
150 | dataOut.data[:,i,:], |
|
151 | dataOut.data[:,i,:], | |
151 | id, |
|
152 | id, | |
152 | channelIndexList, |
|
153 | channelIndexList, | |
153 | thisDatetime, |
|
154 | thisDatetime, | |
154 | wintitle1, |
|
155 | wintitle1, | |
155 | show, |
|
156 | show, | |
156 | xmin, |
|
157 | xmin, | |
157 | xmax, |
|
158 | xmax, | |
158 | ymin, |
|
159 | ymin, | |
159 | ymax) |
|
160 | ymax) | |
160 |
|
161 | |||
161 | if type == "iq": |
|
162 | if type == "iq": | |
162 | self.plot_iq(dataOut.heightList, |
|
163 | self.plot_iq(dataOut.heightList, | |
163 | dataOut.data[:,i,:], |
|
164 | dataOut.data[:,i,:], | |
164 | id, |
|
165 | id, | |
165 | channelIndexList, |
|
166 | channelIndexList, | |
166 | thisDatetime, |
|
167 | thisDatetime, | |
167 | wintitle1, |
|
168 | wintitle1, | |
168 | show, |
|
169 | show, | |
169 | xmin, |
|
170 | xmin, | |
170 | xmax, |
|
171 | xmax, | |
171 | ymin, |
|
172 | ymin, | |
172 | ymax) |
|
173 | ymax) | |
173 |
|
174 | |||
174 | self.draw() |
|
175 | self.draw() | |
175 |
|
176 | |||
176 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
177 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
177 | figfile = self.getFilename(name = str_datetime) + "_" + str(i) |
|
178 | figfile = self.getFilename(name = str_datetime) + "_" + str(i) | |
178 |
|
179 | |||
179 | self.save(figpath=figpath, |
|
180 | self.save(figpath=figpath, | |
180 | figfile=figfile, |
|
181 | figfile=figfile, | |
181 | save=save, |
|
182 | save=save, | |
182 | ftp=ftp, |
|
183 | ftp=ftp, | |
183 | wr_period=wr_period, |
|
184 | wr_period=wr_period, | |
184 | thisDatetime=thisDatetime) |
|
185 | thisDatetime=thisDatetime) | |
185 |
|
186 | |||
186 | else: |
|
187 | else: | |
187 | wintitle += " [Profile = %d] " %dataOut.profileIndex |
|
188 | wintitle += " [Profile = %d] " %dataOut.profileIndex | |
188 |
|
189 | |||
189 | if type == "power": |
|
190 | if type == "power": | |
190 | self.plot_power(dataOut.heightList, |
|
191 | self.plot_power(dataOut.heightList, | |
191 | dataOut.data, |
|
192 | dataOut.data, | |
192 | id, |
|
193 | id, | |
193 | channelIndexList, |
|
194 | channelIndexList, | |
194 | thisDatetime, |
|
195 | thisDatetime, | |
195 | wintitle, |
|
196 | wintitle, | |
196 | show, |
|
197 | show, | |
197 | xmin, |
|
198 | xmin, | |
198 | xmax, |
|
199 | xmax, | |
199 | ymin, |
|
200 | ymin, | |
200 | ymax) |
|
201 | ymax) | |
201 |
|
202 | |||
202 | if type == "iq": |
|
203 | if type == "iq": | |
203 | self.plot_iq(dataOut.heightList, |
|
204 | self.plot_iq(dataOut.heightList, | |
204 | dataOut.data, |
|
205 | dataOut.data, | |
205 | id, |
|
206 | id, | |
206 | channelIndexList, |
|
207 | channelIndexList, | |
207 | thisDatetime, |
|
208 | thisDatetime, | |
208 | wintitle, |
|
209 | wintitle, | |
209 | show, |
|
210 | show, | |
210 | xmin, |
|
211 | xmin, | |
211 | xmax, |
|
212 | xmax, | |
212 | ymin, |
|
213 | ymin, | |
213 | ymax) |
|
214 | ymax) | |
214 |
|
215 | |||
215 | self.draw() |
|
216 | self.draw() | |
216 |
|
217 | |||
217 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") + "_" + str(dataOut.profileIndex) |
|
218 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") + "_" + str(dataOut.profileIndex) | |
218 | figfile = self.getFilename(name = str_datetime) |
|
219 | figfile = self.getFilename(name = str_datetime) | |
219 |
|
220 | |||
220 | self.save(figpath=figpath, |
|
221 | self.save(figpath=figpath, | |
221 | figfile=figfile, |
|
222 | figfile=figfile, | |
222 | save=save, |
|
223 | save=save, | |
223 | ftp=ftp, |
|
224 | ftp=ftp, | |
224 | wr_period=wr_period, |
|
225 | wr_period=wr_period, | |
225 | thisDatetime=thisDatetime) |
|
226 | thisDatetime=thisDatetime) | |
|
227 | ||||
|
228 | ||||
|
229 | class VoltACFPLot(Figure): | |||
|
230 | ||||
|
231 | isConfig = None | |||
|
232 | __nsubplots = None | |||
|
233 | PREFIX = 'voltacf' | |||
|
234 | ||||
|
235 | def __init__(self, **kwargs): | |||
|
236 | Figure.__init__(self,**kwargs) | |||
|
237 | self.isConfig = False | |||
|
238 | self.__nsubplots = 1 | |||
|
239 | self.PLOT_CODE = VOLT_ACF_CODE | |||
|
240 | self.WIDTH = 900 | |||
|
241 | self.HEIGHT = 700 | |||
|
242 | self.counter_imagwr= 0 | |||
|
243 | self.FTP_WEI = None | |||
|
244 | self.EXP_CODE = None | |||
|
245 | self.SUB_EXP_CODE = None | |||
|
246 | self.PLOT_POS = None | |||
|
247 | ||||
|
248 | def getSubplots(self) : | |||
|
249 | ncol = 1 | |||
|
250 | nrow = 1 | |||
|
251 | return nrow, ncol | |||
|
252 | ||||
|
253 | def setup(self,id, nplots,wintitle,show): | |||
|
254 | self.nplots = nplots | |||
|
255 | ncolspan = 1 | |||
|
256 | colspan = 1 | |||
|
257 | self.createFigure(id=id, | |||
|
258 | wintitle = wintitle, | |||
|
259 | widthplot = self.WIDTH, | |||
|
260 | heightplot = self.HEIGHT, | |||
|
261 | show = show) | |||
|
262 | nrow, ncol = self.getSubplots() | |||
|
263 | counter = 0 | |||
|
264 | for y in range(nrow): | |||
|
265 | for x in range(ncol): | |||
|
266 | self.addAxes(nrow, ncol*ncolspan,y, x*ncolspan, colspan, 1) | |||
|
267 | ||||
|
268 | def run(self,dataOut, id, wintitle="",channelList = None , channel =None, nSamples = None, | |||
|
269 | nSampleList= None, resolutionFactor=None, xmin= None, xmax = None, ymin=None, ymax=None, | |||
|
270 | save= False, figpath='./', figfile= None,show= True, ftp= False, wr_period=1, server= None, | |||
|
271 | folder= None, username =None, password= None, ftp_wei=0 , exp_code=0,sub_exp_code=0,plot_pos=0, | |||
|
272 | xaxis="time"): | |||
|
273 | ||||
|
274 | channel0 = channel | |||
|
275 | nSamples = nSamples | |||
|
276 | resFactor = resolutionFactor | |||
|
277 | ||||
|
278 | if nSamples == None: | |||
|
279 | nSamples = 20 | |||
|
280 | ||||
|
281 | if resFactor == None: | |||
|
282 | resFactor = 5 | |||
|
283 | ||||
|
284 | if channel0 == None: | |||
|
285 | channel0 = 0 | |||
|
286 | else: | |||
|
287 | if channel0 not in dataOut.channelList: | |||
|
288 | raise ValueError, "Channel %d is not in %s dataOut.channelList"%(channel0, dataOut.channelList) | |||
|
289 | ||||
|
290 | if channelList == None: | |||
|
291 | channelIndexList = dataOut.channelIndexList | |||
|
292 | channelList = dataOut.channelList | |||
|
293 | ||||
|
294 | else: | |||
|
295 | channelIndexList = [] | |||
|
296 | for channel in channelList: | |||
|
297 | if channel not in dataOut.channelList: | |||
|
298 | raise ValueError, "Channel %d is not in dataOut.channelList" | |||
|
299 | channelIndexList.append(dataOut.channelList.index(channel)) | |||
|
300 | ||||
|
301 | ||||
|
302 | #factor = dataOut.normFactor | |||
|
303 | y = dataOut.getHeiRange() | |||
|
304 | #print y, dataOut.heightList[0] | |||
|
305 | #print "pause" | |||
|
306 | #import time | |||
|
307 | #time.sleep(10) | |||
|
308 | deltaHeight = dataOut.heightList[1]-dataOut.heightList[0] | |||
|
309 | z = dataOut.data | |||
|
310 | ||||
|
311 | shape = dataOut.data.shape | |||
|
312 | hei_index = numpy.arange(shape[2]) | |||
|
313 | hei_plot = numpy.arange(nSamples)*resFactor | |||
|
314 | ||||
|
315 | if nSampleList is not None: | |||
|
316 | for nsample in nSampleList: | |||
|
317 | if nsample not in dataOut.heightList/deltaHeight: | |||
|
318 | print "Lista available : %s "%(dataOut.heightList/deltaHeight) | |||
|
319 | raise ValueError, "nsample %d is not in %s dataOut.heightList"%(nsample,dataOut.heightList) | |||
|
320 | ||||
|
321 | if nSampleList is not None: | |||
|
322 | hei_plot = numpy.array(nSampleList)*resFactor | |||
|
323 | ||||
|
324 | if hei_plot[-1] >= hei_index[-1]: | |||
|
325 | print ("La cantidad de puntos en altura es %d y la resolucion es %f Km"%(hei_plot.shape[0],deltaHeight*resFactor )) | |||
|
326 | raise ValueError, "resFactor %d multiplicado por el valor de %d nSamples es mayor a %d cantidad total de puntos"%(resFactor,nSamples,hei_index[-1]) | |||
|
327 | ||||
|
328 | #escalamiento -1 a 1 a resolucion (factor de resolucion en altura)* deltaHeight | |||
|
329 | #min = numpy.min(z[0,:,0]) | |||
|
330 | #max =numpy.max(z[0,:,0]) | |||
|
331 | for i in range(shape[0]): | |||
|
332 | for j in range(shape[2]): | |||
|
333 | min = numpy.min(z[i,:,j]) | |||
|
334 | max = numpy.max(z[i,:,j]) | |||
|
335 | z[i,:,j]= (((z[i,:,j]-min)/(max-min))*deltaHeight*resFactor + j*deltaHeight+dataOut.heightList[0]) | |||
|
336 | ||||
|
337 | ||||
|
338 | if xaxis == "time": | |||
|
339 | x = dataOut.getAcfRange()*1000 | |||
|
340 | zdB = z[channel0,:,hei_plot] | |||
|
341 | xlabel = "Time (ms)" | |||
|
342 | ylabel = "VOLT_ACF" | |||
|
343 | ||||
|
344 | ||||
|
345 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |||
|
346 | title = wintitle + "VOLT ACF Plot Ch %s %s" %(channel0,thisDatetime.strftime("%d-%b-%Y")) | |||
|
347 | ||||
|
348 | if not self.isConfig: | |||
|
349 | ||||
|
350 | nplots = 1 | |||
|
351 | ||||
|
352 | self.setup(id=id, | |||
|
353 | nplots=nplots, | |||
|
354 | wintitle=wintitle, | |||
|
355 | show=show) | |||
|
356 | ||||
|
357 | if xmin == None: xmin = numpy.nanmin(x)#*0.9 | |||
|
358 | if xmax == None: xmax = numpy.nanmax(x)#*1.1 | |||
|
359 | if ymin == None: ymin = numpy.nanmin(zdB) | |||
|
360 | if ymax == None: ymax = numpy.nanmax(zdB) | |||
|
361 | ||||
|
362 | print ("El parametro resFactor es %d y la resolucion en altura es %f"%(resFactor,deltaHeight )) | |||
|
363 | print ("La cantidad de puntos en altura es %d y la nueva resolucion es %f Km"%(hei_plot.shape[0],deltaHeight*resFactor )) | |||
|
364 | print ("La altura maxima es %d Km"%(hei_plot[-1]*deltaHeight )) | |||
|
365 | ||||
|
366 | self.FTP_WEI = ftp_wei | |||
|
367 | self.EXP_CODE = exp_code | |||
|
368 | self.SUB_EXP_CODE = sub_exp_code | |||
|
369 | self.PLOT_POS = plot_pos | |||
|
370 | ||||
|
371 | self.isConfig = True | |||
|
372 | ||||
|
373 | self.setWinTitle(title) | |||
|
374 | ||||
|
375 | title = "VOLT ACF Plot: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |||
|
376 | axes = self.axesList[0] | |||
|
377 | ||||
|
378 | legendlabels = ["Range = %dKm" %y[i] for i in hei_plot] | |||
|
379 | ||||
|
380 | axes.pmultilineyaxis( x, zdB, | |||
|
381 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |||
|
382 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |||
|
383 | ytick_visible=True, nxticks=5, | |||
|
384 | grid='x') | |||
|
385 | ||||
|
386 | self.draw() | |||
|
387 | ||||
|
388 | if figfile == None: | |||
|
389 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |||
|
390 | name = str_datetime | |||
|
391 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |||
|
392 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) | |||
|
393 | figfile = self.getFilename(name) | |||
|
394 | ||||
|
395 | self.save(figpath=figpath, | |||
|
396 | figfile=figfile, | |||
|
397 | save=save, | |||
|
398 | ftp=ftp, | |||
|
399 | wr_period=wr_period, | |||
|
400 | thisDatetime=thisDatetime) | |||
|
401 | ||||
|
402 | ||||
|
403 | ||||
|
404 | ||||
|
405 | ||||
|
406 | ||||
|
407 | ||||
|
408 | ||||
|
409 | ||||
|
410 | ||||
|
411 | ||||
|
412 | ||||
|
413 | ||||
|
414 | ||||
|
415 | ||||
|
416 | ||||
|
417 | ||||
|
418 | ||||
|
419 | ||||
|
420 | ||||
|
421 | ||||
|
422 | ||||
|
423 | ||||
|
424 | ||||
|
425 | ||||
|
426 |
@@ -1,29 +1,33 | |||||
1 | ''' |
|
1 | ''' | |
2 | @author: roj-idl71 |
|
2 | @author: roj-idl71 | |
3 | ''' |
|
3 | ''' | |
|
4 | #USED IN jroplot_voltage.py | |||
|
5 | VOLT_ACF_CODE =11 # Volt Autocorrelation function | |||
|
6 | ||||
4 | #USED IN jroplot_spectra.py |
|
7 | #USED IN jroplot_spectra.py | |
5 | RTI_CODE = 0 #Range time intensity (RTI). |
|
8 | RTI_CODE = 0 #Range time intensity (RTI). | |
6 | SPEC_CODE = 1 #Spectra (and Cross-spectra) information. |
|
9 | SPEC_CODE = 1 #Spectra (and Cross-spectra) information. | |
7 | CROSS_CODE = 2 #Cross-Correlation information. |
|
10 | CROSS_CODE = 2 #Cross-Correlation information. | |
8 | COH_CODE = 3 #Coherence map. |
|
11 | COH_CODE = 3 #Coherence map. | |
9 | BASE_CODE = 4 #Base lines graphic. |
|
12 | BASE_CODE = 4 #Base lines graphic. | |
10 | ROW_CODE = 5 #Row Spectra. |
|
13 | ROW_CODE = 5 #Row Spectra. | |
11 | TOTAL_CODE = 6 #Total Power. |
|
14 | TOTAL_CODE = 6 #Total Power. | |
12 | DRIFT_CODE = 7 #Drifts graphics. |
|
15 | DRIFT_CODE = 7 #Drifts graphics. | |
13 | HEIGHT_CODE = 8 #Height profile. |
|
16 | HEIGHT_CODE = 8 #Height profile. | |
14 | PHASE_CODE = 9 #Signal Phase. |
|
17 | PHASE_CODE = 9 #Signal Phase. | |
15 | ACF_CODE = 10 #Autocorrelation function. |
|
18 | ACF_CODE = 10 #Autocorrelation function. | |
16 |
|
19 | |||
|
20 | ||||
17 | POWER_CODE = 16 |
|
21 | POWER_CODE = 16 | |
18 | NOISE_CODE = 17 |
|
22 | NOISE_CODE = 17 | |
19 | BEACON_CODE = 18 |
|
23 | BEACON_CODE = 18 | |
20 |
|
24 | |||
21 | #USED IN jroplot_parameters.py |
|
25 | #USED IN jroplot_parameters.py | |
22 | WIND_CODE = 22 |
|
26 | WIND_CODE = 22 | |
23 | MSKYMAP_CODE = 23 |
|
27 | MSKYMAP_CODE = 23 | |
24 | MPHASE_CODE = 24 |
|
28 | MPHASE_CODE = 24 | |
25 |
|
29 | |||
26 | MOMENTS_CODE = 25 |
|
30 | MOMENTS_CODE = 25 | |
27 | PARMS_CODE = 26 |
|
31 | PARMS_CODE = 26 | |
28 | SPECFIT_CODE = 27 |
|
32 | SPECFIT_CODE = 27 | |
29 | EWDRIFT_CODE = 28 |
|
33 | EWDRIFT_CODE = 28 |
@@ -1,1666 +1,1667 | |||||
1 | import sys |
|
1 | import sys | |
2 | import numpy |
|
2 | import numpy | |
3 | from scipy import interpolate |
|
3 | from scipy import interpolate | |
4 | from schainpy import cSchain |
|
4 | from schainpy import cSchain | |
5 | from jroproc_base import ProcessingUnit, Operation |
|
5 | from jroproc_base import ProcessingUnit, Operation | |
6 | from schainpy.model.data.jrodata import Voltage |
|
6 | from schainpy.model.data.jrodata import Voltage | |
7 | from time import time |
|
7 | from time import time | |
8 |
|
8 | |||
9 | import math |
|
9 | import math | |
10 |
|
10 | |||
11 | def rep_seq(x, rep=10): |
|
11 | def rep_seq(x, rep=10): | |
12 | L = len(x) * rep |
|
12 | L = len(x) * rep | |
13 | res = numpy.zeros(L, dtype=x.dtype) |
|
13 | res = numpy.zeros(L, dtype=x.dtype) | |
14 | idx = numpy.arange(len(x)) * rep |
|
14 | idx = numpy.arange(len(x)) * rep | |
15 | for i in numpy.arange(rep): |
|
15 | for i in numpy.arange(rep): | |
16 | res[idx + i] = x |
|
16 | res[idx + i] = x | |
17 | return(res) |
|
17 | return(res) | |
18 |
|
18 | |||
19 |
|
19 | |||
20 | def create_pseudo_random_code(clen=10000, seed=0): |
|
20 | def create_pseudo_random_code(clen=10000, seed=0): | |
21 | """ |
|
21 | """ | |
22 | seed is a way of reproducing the random code without |
|
22 | seed is a way of reproducing the random code without | |
23 | having to store all actual codes. the seed can then |
|
23 | having to store all actual codes. the seed can then | |
24 | act as a sort of station_id. |
|
24 | act as a sort of station_id. | |
25 |
|
25 | |||
26 | """ |
|
26 | """ | |
27 | numpy.random.seed(seed) |
|
27 | numpy.random.seed(seed) | |
28 | phases = numpy.array( |
|
28 | phases = numpy.array( | |
29 | numpy.exp(1.0j * 2.0 * math.pi * numpy.random.random(clen)), |
|
29 | numpy.exp(1.0j * 2.0 * math.pi * numpy.random.random(clen)), | |
30 | dtype=numpy.complex64, |
|
30 | dtype=numpy.complex64, | |
31 | ) |
|
31 | ) | |
32 | return(phases) |
|
32 | return(phases) | |
33 |
|
33 | |||
34 |
|
34 | |||
35 | def periodic_convolution_matrix(envelope, rmin=0, rmax=100): |
|
35 | def periodic_convolution_matrix(envelope, rmin=0, rmax=100): | |
36 | """ |
|
36 | """ | |
37 | we imply that the number of measurements is equal to the number of elements |
|
37 | we imply that the number of measurements is equal to the number of elements | |
38 | in code |
|
38 | in code | |
39 |
|
39 | |||
40 | """ |
|
40 | """ | |
41 | L = len(envelope) |
|
41 | L = len(envelope) | |
42 | ridx = numpy.arange(rmin, rmax) |
|
42 | ridx = numpy.arange(rmin, rmax) | |
43 | A = numpy.zeros([L, rmax-rmin], dtype=numpy.complex64) |
|
43 | A = numpy.zeros([L, rmax-rmin], dtype=numpy.complex64) | |
44 | for i in numpy.arange(L): |
|
44 | for i in numpy.arange(L): | |
45 | A[i, :] = envelope[(i-ridx) % L] |
|
45 | A[i, :] = envelope[(i-ridx) % L] | |
46 | result = {} |
|
46 | result = {} | |
47 | result['A'] = A |
|
47 | result['A'] = A | |
48 | result['ridx'] = ridx |
|
48 | result['ridx'] = ridx | |
49 | return(result) |
|
49 | return(result) | |
50 |
|
50 | |||
51 |
|
51 | |||
52 | B_cache = 0 |
|
52 | B_cache = 0 | |
53 | r_cache = 0 |
|
53 | r_cache = 0 | |
54 | B_cached = False |
|
54 | B_cached = False | |
55 | def create_estimation_matrix(code, rmin=0, rmax=1000, cache=True): |
|
55 | def create_estimation_matrix(code, rmin=0, rmax=1000, cache=True): | |
56 | global B_cache |
|
56 | global B_cache | |
57 | global r_cache |
|
57 | global r_cache | |
58 | global B_cached |
|
58 | global B_cached | |
59 |
|
59 | |||
60 | if not cache or not B_cached: |
|
60 | if not cache or not B_cached: | |
61 | r_cache = periodic_convolution_matrix( |
|
61 | r_cache = periodic_convolution_matrix( | |
62 | envelope=code, rmin=rmin, rmax=rmax, |
|
62 | envelope=code, rmin=rmin, rmax=rmax, | |
63 | ) |
|
63 | ) | |
64 | A = r_cache['A'] |
|
64 | A = r_cache['A'] | |
65 | Ah = numpy.transpose(numpy.conjugate(A)) |
|
65 | Ah = numpy.transpose(numpy.conjugate(A)) | |
66 | B_cache = numpy.dot(numpy.linalg.inv(numpy.dot(Ah, A)), Ah) |
|
66 | B_cache = numpy.dot(numpy.linalg.inv(numpy.dot(Ah, A)), Ah) | |
67 | r_cache['B'] = B_cache |
|
67 | r_cache['B'] = B_cache | |
68 | B_cached = True |
|
68 | B_cached = True | |
69 | return(r_cache) |
|
69 | return(r_cache) | |
70 | else: |
|
70 | else: | |
71 | return(r_cache) |
|
71 | return(r_cache) | |
72 |
|
72 | |||
73 | class VoltageProc(ProcessingUnit): |
|
73 | class VoltageProc(ProcessingUnit): | |
74 |
|
74 | |||
75 |
|
75 | |||
76 | def __init__(self, **kwargs): |
|
76 | def __init__(self, **kwargs): | |
77 |
|
77 | |||
78 | ProcessingUnit.__init__(self, **kwargs) |
|
78 | ProcessingUnit.__init__(self, **kwargs) | |
79 |
|
79 | |||
80 | # self.objectDict = {} |
|
80 | # self.objectDict = {} | |
81 | self.dataOut = Voltage() |
|
81 | self.dataOut = Voltage() | |
82 | self.flip = 1 |
|
82 | self.flip = 1 | |
83 |
|
83 | |||
84 | def run(self): |
|
84 | def run(self): | |
85 | if self.dataIn.type == 'AMISR': |
|
85 | if self.dataIn.type == 'AMISR': | |
86 | self.__updateObjFromAmisrInput() |
|
86 | self.__updateObjFromAmisrInput() | |
87 |
|
87 | |||
88 | if self.dataIn.type == 'Voltage': |
|
88 | if self.dataIn.type == 'Voltage': | |
89 | self.dataOut.copy(self.dataIn) |
|
89 | self.dataOut.copy(self.dataIn) | |
90 |
|
90 | |||
91 | # self.dataOut.copy(self.dataIn) |
|
91 | # self.dataOut.copy(self.dataIn) | |
92 |
|
92 | |||
93 | def __updateObjFromAmisrInput(self): |
|
93 | def __updateObjFromAmisrInput(self): | |
94 |
|
94 | |||
95 | self.dataOut.timeZone = self.dataIn.timeZone |
|
95 | self.dataOut.timeZone = self.dataIn.timeZone | |
96 | self.dataOut.dstFlag = self.dataIn.dstFlag |
|
96 | self.dataOut.dstFlag = self.dataIn.dstFlag | |
97 | self.dataOut.errorCount = self.dataIn.errorCount |
|
97 | self.dataOut.errorCount = self.dataIn.errorCount | |
98 | self.dataOut.useLocalTime = self.dataIn.useLocalTime |
|
98 | self.dataOut.useLocalTime = self.dataIn.useLocalTime | |
99 |
|
99 | |||
100 | self.dataOut.flagNoData = self.dataIn.flagNoData |
|
100 | self.dataOut.flagNoData = self.dataIn.flagNoData | |
101 | self.dataOut.data = self.dataIn.data |
|
101 | self.dataOut.data = self.dataIn.data | |
102 | self.dataOut.utctime = self.dataIn.utctime |
|
102 | self.dataOut.utctime = self.dataIn.utctime | |
103 | self.dataOut.channelList = self.dataIn.channelList |
|
103 | self.dataOut.channelList = self.dataIn.channelList | |
104 | # self.dataOut.timeInterval = self.dataIn.timeInterval |
|
104 | # self.dataOut.timeInterval = self.dataIn.timeInterval | |
105 | self.dataOut.heightList = self.dataIn.heightList |
|
105 | self.dataOut.heightList = self.dataIn.heightList | |
106 | self.dataOut.nProfiles = self.dataIn.nProfiles |
|
106 | self.dataOut.nProfiles = self.dataIn.nProfiles | |
107 |
|
107 | |||
108 | self.dataOut.nCohInt = self.dataIn.nCohInt |
|
108 | self.dataOut.nCohInt = self.dataIn.nCohInt | |
109 | self.dataOut.ippSeconds = self.dataIn.ippSeconds |
|
109 | self.dataOut.ippSeconds = self.dataIn.ippSeconds | |
110 | self.dataOut.frequency = self.dataIn.frequency |
|
110 | self.dataOut.frequency = self.dataIn.frequency | |
111 |
|
111 | |||
112 | self.dataOut.azimuth = self.dataIn.azimuth |
|
112 | self.dataOut.azimuth = self.dataIn.azimuth | |
113 | self.dataOut.zenith = self.dataIn.zenith |
|
113 | self.dataOut.zenith = self.dataIn.zenith | |
114 |
|
114 | |||
115 | self.dataOut.beam.codeList = self.dataIn.beam.codeList |
|
115 | self.dataOut.beam.codeList = self.dataIn.beam.codeList | |
116 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList |
|
116 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList | |
117 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList |
|
117 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList | |
118 | # |
|
118 | # | |
119 | # pass# |
|
119 | # pass# | |
120 | # |
|
120 | # | |
121 | # def init(self): |
|
121 | # def init(self): | |
122 | # |
|
122 | # | |
123 | # |
|
123 | # | |
124 | # if self.dataIn.type == 'AMISR': |
|
124 | # if self.dataIn.type == 'AMISR': | |
125 | # self.__updateObjFromAmisrInput() |
|
125 | # self.__updateObjFromAmisrInput() | |
126 | # |
|
126 | # | |
127 | # if self.dataIn.type == 'Voltage': |
|
127 | # if self.dataIn.type == 'Voltage': | |
128 | # self.dataOut.copy(self.dataIn) |
|
128 | # self.dataOut.copy(self.dataIn) | |
129 | # # No necesita copiar en cada init() los atributos de dataIn |
|
129 | # # No necesita copiar en cada init() los atributos de dataIn | |
130 | # # la copia deberia hacerse por cada nuevo bloque de datos |
|
130 | # # la copia deberia hacerse por cada nuevo bloque de datos | |
131 |
|
131 | |||
132 | def selectChannels(self, channelList): |
|
132 | def selectChannels(self, channelList): | |
133 |
|
133 | |||
134 | channelIndexList = [] |
|
134 | channelIndexList = [] | |
135 |
|
135 | |||
136 | for channel in channelList: |
|
136 | for channel in channelList: | |
137 | if channel not in self.dataOut.channelList: |
|
137 | if channel not in self.dataOut.channelList: | |
138 | raise ValueError, "Channel %d is not in %s" %(channel, str(self.dataOut.channelList)) |
|
138 | raise ValueError, "Channel %d is not in %s" %(channel, str(self.dataOut.channelList)) | |
139 |
|
139 | |||
140 | index = self.dataOut.channelList.index(channel) |
|
140 | index = self.dataOut.channelList.index(channel) | |
141 | channelIndexList.append(index) |
|
141 | channelIndexList.append(index) | |
142 |
|
142 | |||
143 | self.selectChannelsByIndex(channelIndexList) |
|
143 | self.selectChannelsByIndex(channelIndexList) | |
144 |
|
144 | |||
145 | def selectChannelsByIndex(self, channelIndexList): |
|
145 | def selectChannelsByIndex(self, channelIndexList): | |
146 | """ |
|
146 | """ | |
147 | Selecciona un bloque de datos en base a canales segun el channelIndexList |
|
147 | Selecciona un bloque de datos en base a canales segun el channelIndexList | |
148 |
|
148 | |||
149 | Input: |
|
149 | Input: | |
150 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] |
|
150 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] | |
151 |
|
151 | |||
152 | Affected: |
|
152 | Affected: | |
153 | self.dataOut.data |
|
153 | self.dataOut.data | |
154 | self.dataOut.channelIndexList |
|
154 | self.dataOut.channelIndexList | |
155 | self.dataOut.nChannels |
|
155 | self.dataOut.nChannels | |
156 | self.dataOut.m_ProcessingHeader.totalSpectra |
|
156 | self.dataOut.m_ProcessingHeader.totalSpectra | |
157 | self.dataOut.systemHeaderObj.numChannels |
|
157 | self.dataOut.systemHeaderObj.numChannels | |
158 | self.dataOut.m_ProcessingHeader.blockSize |
|
158 | self.dataOut.m_ProcessingHeader.blockSize | |
159 |
|
159 | |||
160 | Return: |
|
160 | Return: | |
161 | None |
|
161 | None | |
162 | """ |
|
162 | """ | |
163 |
|
163 | |||
164 | for channelIndex in channelIndexList: |
|
164 | for channelIndex in channelIndexList: | |
165 | if channelIndex not in self.dataOut.channelIndexList: |
|
165 | if channelIndex not in self.dataOut.channelIndexList: | |
166 | print channelIndexList |
|
166 | print channelIndexList | |
167 | raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex |
|
167 | raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex | |
168 |
|
168 | |||
169 | if self.dataOut.flagDataAsBlock: |
|
169 | if self.dataOut.flagDataAsBlock: | |
170 | """ |
|
170 | """ | |
171 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
171 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
172 | """ |
|
172 | """ | |
173 | data = self.dataOut.data[channelIndexList,:,:] |
|
173 | data = self.dataOut.data[channelIndexList,:,:] | |
174 | else: |
|
174 | else: | |
175 | data = self.dataOut.data[channelIndexList,:] |
|
175 | data = self.dataOut.data[channelIndexList,:] | |
176 |
|
176 | |||
177 | self.dataOut.data = data |
|
177 | self.dataOut.data = data | |
178 | self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] |
|
178 | self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] | |
179 | # self.dataOut.nChannels = nChannels |
|
179 | # self.dataOut.nChannels = nChannels | |
180 |
|
180 | |||
181 | return 1 |
|
181 | return 1 | |
182 |
|
182 | |||
183 | def selectHeights(self, minHei=None, maxHei=None): |
|
183 | def selectHeights(self, minHei=None, maxHei=None): | |
184 | """ |
|
184 | """ | |
185 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango |
|
185 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango | |
186 | minHei <= height <= maxHei |
|
186 | minHei <= height <= maxHei | |
187 |
|
187 | |||
188 | Input: |
|
188 | Input: | |
189 | minHei : valor minimo de altura a considerar |
|
189 | minHei : valor minimo de altura a considerar | |
190 | maxHei : valor maximo de altura a considerar |
|
190 | maxHei : valor maximo de altura a considerar | |
191 |
|
191 | |||
192 | Affected: |
|
192 | Affected: | |
193 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex |
|
193 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex | |
194 |
|
194 | |||
195 | Return: |
|
195 | Return: | |
196 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
196 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
197 | """ |
|
197 | """ | |
198 |
|
198 | |||
199 | if minHei == None: |
|
199 | if minHei == None: | |
200 | minHei = self.dataOut.heightList[0] |
|
200 | minHei = self.dataOut.heightList[0] | |
201 |
|
201 | |||
202 | if maxHei == None: |
|
202 | if maxHei == None: | |
203 | maxHei = self.dataOut.heightList[-1] |
|
203 | maxHei = self.dataOut.heightList[-1] | |
204 |
|
204 | |||
205 | if (minHei < self.dataOut.heightList[0]): |
|
205 | if (minHei < self.dataOut.heightList[0]): | |
206 | minHei = self.dataOut.heightList[0] |
|
206 | minHei = self.dataOut.heightList[0] | |
207 |
|
207 | |||
208 | if (maxHei > self.dataOut.heightList[-1]): |
|
208 | if (maxHei > self.dataOut.heightList[-1]): | |
209 | maxHei = self.dataOut.heightList[-1] |
|
209 | maxHei = self.dataOut.heightList[-1] | |
210 |
|
210 | |||
211 | minIndex = 0 |
|
211 | minIndex = 0 | |
212 | maxIndex = 0 |
|
212 | maxIndex = 0 | |
213 | heights = self.dataOut.heightList |
|
213 | heights = self.dataOut.heightList | |
214 |
|
214 | |||
215 | inda = numpy.where(heights >= minHei) |
|
215 | inda = numpy.where(heights >= minHei) | |
216 | indb = numpy.where(heights <= maxHei) |
|
216 | indb = numpy.where(heights <= maxHei) | |
217 |
|
217 | |||
218 | try: |
|
218 | try: | |
219 | minIndex = inda[0][0] |
|
219 | minIndex = inda[0][0] | |
220 | except: |
|
220 | except: | |
221 | minIndex = 0 |
|
221 | minIndex = 0 | |
222 |
|
222 | |||
223 | try: |
|
223 | try: | |
224 | maxIndex = indb[0][-1] |
|
224 | maxIndex = indb[0][-1] | |
225 | except: |
|
225 | except: | |
226 | maxIndex = len(heights) |
|
226 | maxIndex = len(heights) | |
227 |
|
227 | |||
228 | self.selectHeightsByIndex(minIndex, maxIndex) |
|
228 | self.selectHeightsByIndex(minIndex, maxIndex) | |
229 |
|
229 | |||
230 | return 1 |
|
230 | return 1 | |
231 |
|
231 | |||
232 |
|
232 | |||
233 | def selectHeightsByIndex(self, minIndex, maxIndex): |
|
233 | def selectHeightsByIndex(self, minIndex, maxIndex): | |
234 | """ |
|
234 | """ | |
235 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
235 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango | |
236 | minIndex <= index <= maxIndex |
|
236 | minIndex <= index <= maxIndex | |
237 |
|
237 | |||
238 | Input: |
|
238 | Input: | |
239 | minIndex : valor de indice minimo de altura a considerar |
|
239 | minIndex : valor de indice minimo de altura a considerar | |
240 | maxIndex : valor de indice maximo de altura a considerar |
|
240 | maxIndex : valor de indice maximo de altura a considerar | |
241 |
|
241 | |||
242 | Affected: |
|
242 | Affected: | |
243 | self.dataOut.data |
|
243 | self.dataOut.data | |
244 | self.dataOut.heightList |
|
244 | self.dataOut.heightList | |
245 |
|
245 | |||
246 | Return: |
|
246 | Return: | |
247 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
247 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
248 | """ |
|
248 | """ | |
249 |
|
249 | |||
250 | if (minIndex < 0) or (minIndex > maxIndex): |
|
250 | if (minIndex < 0) or (minIndex > maxIndex): | |
251 | raise ValueError, "Height index range (%d,%d) is not valid" % (minIndex, maxIndex) |
|
251 | raise ValueError, "Height index range (%d,%d) is not valid" % (minIndex, maxIndex) | |
252 |
|
252 | |||
253 | if (maxIndex >= self.dataOut.nHeights): |
|
253 | if (maxIndex >= self.dataOut.nHeights): | |
254 | maxIndex = self.dataOut.nHeights |
|
254 | maxIndex = self.dataOut.nHeights | |
255 |
|
255 | |||
256 | #voltage |
|
256 | #voltage | |
257 | if self.dataOut.flagDataAsBlock: |
|
257 | if self.dataOut.flagDataAsBlock: | |
258 | """ |
|
258 | """ | |
259 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
259 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
260 | """ |
|
260 | """ | |
261 | data = self.dataOut.data[:,:, minIndex:maxIndex] |
|
261 | data = self.dataOut.data[:,:, minIndex:maxIndex] | |
262 | else: |
|
262 | else: | |
263 | data = self.dataOut.data[:, minIndex:maxIndex] |
|
263 | data = self.dataOut.data[:, minIndex:maxIndex] | |
264 |
|
264 | |||
265 | # firstHeight = self.dataOut.heightList[minIndex] |
|
265 | # firstHeight = self.dataOut.heightList[minIndex] | |
266 |
|
266 | |||
267 | self.dataOut.data = data |
|
267 | self.dataOut.data = data | |
268 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex] |
|
268 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex] | |
269 |
|
269 | |||
270 | if self.dataOut.nHeights <= 1: |
|
270 | if self.dataOut.nHeights <= 1: | |
271 | raise ValueError, "selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights) |
|
271 | raise ValueError, "selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights) | |
272 |
|
272 | |||
273 | return 1 |
|
273 | return 1 | |
274 |
|
274 | |||
275 |
|
275 | |||
276 | def filterByHeights(self, window): |
|
276 | def filterByHeights(self, window): | |
277 |
|
277 | |||
278 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] |
|
278 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] | |
279 |
|
279 | |||
280 | if window == None: |
|
280 | if window == None: | |
281 | window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight |
|
281 | window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight | |
282 |
|
282 | |||
283 | newdelta = deltaHeight * window |
|
283 | newdelta = deltaHeight * window | |
284 | r = self.dataOut.nHeights % window |
|
284 | r = self.dataOut.nHeights % window | |
285 | newheights = (self.dataOut.nHeights-r)/window |
|
285 | newheights = (self.dataOut.nHeights-r)/window | |
286 |
|
286 | |||
287 | if newheights <= 1: |
|
287 | if newheights <= 1: | |
288 | raise ValueError, "filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window) |
|
288 | raise ValueError, "filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window) | |
289 |
|
289 | |||
290 | if self.dataOut.flagDataAsBlock: |
|
290 | if self.dataOut.flagDataAsBlock: | |
291 | """ |
|
291 | """ | |
292 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
292 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
293 | """ |
|
293 | """ | |
294 | buffer = self.dataOut.data[:, :, 0:self.dataOut.nHeights-r] |
|
294 | buffer = self.dataOut.data[:, :, 0:self.dataOut.nHeights-r] | |
295 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nProfiles,self.dataOut.nHeights/window,window) |
|
295 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nProfiles,self.dataOut.nHeights/window,window) | |
296 | buffer = numpy.sum(buffer,3) |
|
296 | buffer = numpy.sum(buffer,3) | |
297 |
|
297 | |||
298 | else: |
|
298 | else: | |
299 | buffer = self.dataOut.data[:,0:self.dataOut.nHeights-r] |
|
299 | buffer = self.dataOut.data[:,0:self.dataOut.nHeights-r] | |
300 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nHeights/window,window) |
|
300 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nHeights/window,window) | |
301 | buffer = numpy.sum(buffer,2) |
|
301 | buffer = numpy.sum(buffer,2) | |
302 |
|
302 | |||
303 | self.dataOut.data = buffer |
|
303 | self.dataOut.data = buffer | |
304 | self.dataOut.heightList = self.dataOut.heightList[0] + numpy.arange( newheights )*newdelta |
|
304 | self.dataOut.heightList = self.dataOut.heightList[0] + numpy.arange( newheights )*newdelta | |
305 | self.dataOut.windowOfFilter = window |
|
305 | self.dataOut.windowOfFilter = window | |
306 |
|
306 | |||
307 | def setH0(self, h0, deltaHeight = None): |
|
307 | def setH0(self, h0, deltaHeight = None): | |
308 |
|
308 | |||
309 | if not deltaHeight: |
|
309 | if not deltaHeight: | |
310 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] |
|
310 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] | |
311 |
|
311 | |||
312 | nHeights = self.dataOut.nHeights |
|
312 | nHeights = self.dataOut.nHeights | |
313 |
|
313 | |||
314 | newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight |
|
314 | newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight | |
315 |
|
315 | |||
316 | self.dataOut.heightList = newHeiRange |
|
316 | self.dataOut.heightList = newHeiRange | |
317 |
|
317 | |||
318 | def deFlip(self, channelList = []): |
|
318 | def deFlip(self, channelList = []): | |
319 |
|
319 | |||
320 | data = self.dataOut.data.copy() |
|
320 | data = self.dataOut.data.copy() | |
321 |
|
321 | |||
322 | if self.dataOut.flagDataAsBlock: |
|
322 | if self.dataOut.flagDataAsBlock: | |
323 | flip = self.flip |
|
323 | flip = self.flip | |
324 | profileList = range(self.dataOut.nProfiles) |
|
324 | profileList = range(self.dataOut.nProfiles) | |
325 |
|
325 | |||
326 | if not channelList: |
|
326 | if not channelList: | |
327 | for thisProfile in profileList: |
|
327 | for thisProfile in profileList: | |
328 | data[:,thisProfile,:] = data[:,thisProfile,:]*flip |
|
328 | data[:,thisProfile,:] = data[:,thisProfile,:]*flip | |
329 | flip *= -1.0 |
|
329 | flip *= -1.0 | |
330 | else: |
|
330 | else: | |
331 | for thisChannel in channelList: |
|
331 | for thisChannel in channelList: | |
332 | if thisChannel not in self.dataOut.channelList: |
|
332 | if thisChannel not in self.dataOut.channelList: | |
333 | continue |
|
333 | continue | |
334 |
|
334 | |||
335 | for thisProfile in profileList: |
|
335 | for thisProfile in profileList: | |
336 | data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip |
|
336 | data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip | |
337 | flip *= -1.0 |
|
337 | flip *= -1.0 | |
338 |
|
338 | |||
339 | self.flip = flip |
|
339 | self.flip = flip | |
340 |
|
340 | |||
341 | else: |
|
341 | else: | |
342 | if not channelList: |
|
342 | if not channelList: | |
343 | data[:,:] = data[:,:]*self.flip |
|
343 | data[:,:] = data[:,:]*self.flip | |
344 | else: |
|
344 | else: | |
345 | for thisChannel in channelList: |
|
345 | for thisChannel in channelList: | |
346 | if thisChannel not in self.dataOut.channelList: |
|
346 | if thisChannel not in self.dataOut.channelList: | |
347 | continue |
|
347 | continue | |
348 |
|
348 | |||
349 | data[thisChannel,:] = data[thisChannel,:]*self.flip |
|
349 | data[thisChannel,:] = data[thisChannel,:]*self.flip | |
350 |
|
350 | |||
351 | self.flip *= -1. |
|
351 | self.flip *= -1. | |
352 |
|
352 | |||
353 | self.dataOut.data = data |
|
353 | self.dataOut.data = data | |
354 |
|
354 | |||
355 | def setRadarFrequency(self, frequency=None): |
|
355 | def setRadarFrequency(self, frequency=None): | |
356 |
|
356 | |||
357 | if frequency != None: |
|
357 | if frequency != None: | |
358 | self.dataOut.frequency = frequency |
|
358 | self.dataOut.frequency = frequency | |
359 |
|
359 | |||
360 | return 1 |
|
360 | return 1 | |
361 |
|
361 | |||
362 | def interpolateHeights(self, topLim, botLim): |
|
362 | def interpolateHeights(self, topLim, botLim): | |
363 | #69 al 72 para julia |
|
363 | #69 al 72 para julia | |
364 | #82-84 para meteoros |
|
364 | #82-84 para meteoros | |
365 | if len(numpy.shape(self.dataOut.data))==2: |
|
365 | if len(numpy.shape(self.dataOut.data))==2: | |
366 | sampInterp = (self.dataOut.data[:,botLim-1] + self.dataOut.data[:,topLim+1])/2 |
|
366 | sampInterp = (self.dataOut.data[:,botLim-1] + self.dataOut.data[:,topLim+1])/2 | |
367 | sampInterp = numpy.transpose(numpy.tile(sampInterp,(topLim-botLim + 1,1))) |
|
367 | sampInterp = numpy.transpose(numpy.tile(sampInterp,(topLim-botLim + 1,1))) | |
368 | #self.dataOut.data[:,botLim:limSup+1] = sampInterp |
|
368 | #self.dataOut.data[:,botLim:limSup+1] = sampInterp | |
369 | self.dataOut.data[:,botLim:topLim+1] = sampInterp |
|
369 | self.dataOut.data[:,botLim:topLim+1] = sampInterp | |
370 | else: |
|
370 | else: | |
371 | nHeights = self.dataOut.data.shape[2] |
|
371 | nHeights = self.dataOut.data.shape[2] | |
372 | x = numpy.hstack((numpy.arange(botLim),numpy.arange(topLim+1,nHeights))) |
|
372 | x = numpy.hstack((numpy.arange(botLim),numpy.arange(topLim+1,nHeights))) | |
373 | y = self.dataOut.data[:,:,range(botLim)+range(topLim+1,nHeights)] |
|
373 | y = self.dataOut.data[:,:,range(botLim)+range(topLim+1,nHeights)] | |
374 | f = interpolate.interp1d(x, y, axis = 2) |
|
374 | f = interpolate.interp1d(x, y, axis = 2) | |
375 | xnew = numpy.arange(botLim,topLim+1) |
|
375 | xnew = numpy.arange(botLim,topLim+1) | |
376 | ynew = f(xnew) |
|
376 | ynew = f(xnew) | |
377 |
|
377 | |||
378 | self.dataOut.data[:,:,botLim:topLim+1] = ynew |
|
378 | self.dataOut.data[:,:,botLim:topLim+1] = ynew | |
379 |
|
379 | |||
380 | # import collections |
|
380 | # import collections | |
381 |
|
381 | |||
382 | class CohInt(Operation): |
|
382 | class CohInt(Operation): | |
383 |
|
383 | |||
384 | isConfig = False |
|
384 | isConfig = False | |
385 | __profIndex = 0 |
|
385 | __profIndex = 0 | |
386 | __byTime = False |
|
386 | __byTime = False | |
387 | __initime = None |
|
387 | __initime = None | |
388 | __lastdatatime = None |
|
388 | __lastdatatime = None | |
389 | __integrationtime = None |
|
389 | __integrationtime = None | |
390 | __buffer = None |
|
390 | __buffer = None | |
391 | __bufferStride = [] |
|
391 | __bufferStride = [] | |
392 | __dataReady = False |
|
392 | __dataReady = False | |
393 | __profIndexStride = 0 |
|
393 | __profIndexStride = 0 | |
394 | __dataToPutStride = False |
|
394 | __dataToPutStride = False | |
395 | n = None |
|
395 | n = None | |
396 |
|
396 | |||
397 | def __init__(self, **kwargs): |
|
397 | def __init__(self, **kwargs): | |
398 |
|
398 | |||
399 | Operation.__init__(self, **kwargs) |
|
399 | Operation.__init__(self, **kwargs) | |
400 |
|
400 | |||
401 | # self.isConfig = False |
|
401 | # self.isConfig = False | |
402 |
|
402 | |||
403 | def setup(self, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False): |
|
403 | def setup(self, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False): | |
404 | """ |
|
404 | """ | |
405 | Set the parameters of the integration class. |
|
405 | Set the parameters of the integration class. | |
406 |
|
406 | |||
407 | Inputs: |
|
407 | Inputs: | |
408 |
|
408 | |||
409 | n : Number of coherent integrations |
|
409 | n : Number of coherent integrations | |
410 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work |
|
410 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
411 | overlapping : |
|
411 | overlapping : | |
412 | """ |
|
412 | """ | |
413 |
|
413 | |||
414 | self.__initime = None |
|
414 | self.__initime = None | |
415 | self.__lastdatatime = 0 |
|
415 | self.__lastdatatime = 0 | |
416 | self.__buffer = None |
|
416 | self.__buffer = None | |
417 | self.__dataReady = False |
|
417 | self.__dataReady = False | |
418 | self.byblock = byblock |
|
418 | self.byblock = byblock | |
419 | self.stride = stride |
|
419 | self.stride = stride | |
420 |
|
420 | |||
421 | if n == None and timeInterval == None: |
|
421 | if n == None and timeInterval == None: | |
422 | raise ValueError, "n or timeInterval should be specified ..." |
|
422 | raise ValueError, "n or timeInterval should be specified ..." | |
423 |
|
423 | |||
424 | if n != None: |
|
424 | if n != None: | |
425 | self.n = n |
|
425 | self.n = n | |
426 | self.__byTime = False |
|
426 | self.__byTime = False | |
427 | else: |
|
427 | else: | |
428 | self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line |
|
428 | self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line | |
429 | self.n = 9999 |
|
429 | self.n = 9999 | |
430 | self.__byTime = True |
|
430 | self.__byTime = True | |
431 |
|
431 | |||
432 | if overlapping: |
|
432 | if overlapping: | |
433 | self.__withOverlapping = True |
|
433 | self.__withOverlapping = True | |
434 | self.__buffer = None |
|
434 | self.__buffer = None | |
435 | else: |
|
435 | else: | |
436 | self.__withOverlapping = False |
|
436 | self.__withOverlapping = False | |
437 | self.__buffer = 0 |
|
437 | self.__buffer = 0 | |
438 |
|
438 | |||
439 | self.__profIndex = 0 |
|
439 | self.__profIndex = 0 | |
440 |
|
440 | |||
441 | def putData(self, data): |
|
441 | def putData(self, data): | |
442 |
|
442 | |||
443 | """ |
|
443 | """ | |
444 | Add a profile to the __buffer and increase in one the __profileIndex |
|
444 | Add a profile to the __buffer and increase in one the __profileIndex | |
445 |
|
445 | |||
446 | """ |
|
446 | """ | |
447 |
|
447 | |||
448 | if not self.__withOverlapping: |
|
448 | if not self.__withOverlapping: | |
449 | self.__buffer += data.copy() |
|
449 | self.__buffer += data.copy() | |
450 | self.__profIndex += 1 |
|
450 | self.__profIndex += 1 | |
451 | return |
|
451 | return | |
452 |
|
452 | |||
453 | #Overlapping data |
|
453 | #Overlapping data | |
454 | nChannels, nHeis = data.shape |
|
454 | nChannels, nHeis = data.shape | |
455 | data = numpy.reshape(data, (1, nChannels, nHeis)) |
|
455 | data = numpy.reshape(data, (1, nChannels, nHeis)) | |
456 |
|
456 | |||
457 | #If the buffer is empty then it takes the data value |
|
457 | #If the buffer is empty then it takes the data value | |
458 | if self.__buffer is None: |
|
458 | if self.__buffer is None: | |
459 | self.__buffer = data |
|
459 | self.__buffer = data | |
460 | self.__profIndex += 1 |
|
460 | self.__profIndex += 1 | |
461 | return |
|
461 | return | |
462 |
|
462 | |||
463 | #If the buffer length is lower than n then stakcing the data value |
|
463 | #If the buffer length is lower than n then stakcing the data value | |
464 | if self.__profIndex < self.n: |
|
464 | if self.__profIndex < self.n: | |
465 | self.__buffer = numpy.vstack((self.__buffer, data)) |
|
465 | self.__buffer = numpy.vstack((self.__buffer, data)) | |
466 | self.__profIndex += 1 |
|
466 | self.__profIndex += 1 | |
467 | return |
|
467 | return | |
468 |
|
468 | |||
469 | #If the buffer length is equal to n then replacing the last buffer value with the data value |
|
469 | #If the buffer length is equal to n then replacing the last buffer value with the data value | |
470 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) |
|
470 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) | |
471 | self.__buffer[self.n-1] = data |
|
471 | self.__buffer[self.n-1] = data | |
472 | self.__profIndex = self.n |
|
472 | self.__profIndex = self.n | |
473 | return |
|
473 | return | |
474 |
|
474 | |||
475 |
|
475 | |||
476 | def pushData(self): |
|
476 | def pushData(self): | |
477 | """ |
|
477 | """ | |
478 | Return the sum of the last profiles and the profiles used in the sum. |
|
478 | Return the sum of the last profiles and the profiles used in the sum. | |
479 |
|
479 | |||
480 | Affected: |
|
480 | Affected: | |
481 |
|
481 | |||
482 | self.__profileIndex |
|
482 | self.__profileIndex | |
483 |
|
483 | |||
484 | """ |
|
484 | """ | |
485 |
|
485 | |||
486 | if not self.__withOverlapping: |
|
486 | if not self.__withOverlapping: | |
487 | data = self.__buffer |
|
487 | data = self.__buffer | |
488 | n = self.__profIndex |
|
488 | n = self.__profIndex | |
489 |
|
489 | |||
490 | self.__buffer = 0 |
|
490 | self.__buffer = 0 | |
491 | self.__profIndex = 0 |
|
491 | self.__profIndex = 0 | |
492 |
|
492 | |||
493 | return data, n |
|
493 | return data, n | |
494 |
|
494 | |||
495 | #Integration with Overlapping |
|
495 | #Integration with Overlapping | |
496 | data = numpy.sum(self.__buffer, axis=0) |
|
496 | data = numpy.sum(self.__buffer, axis=0) | |
497 | # print data |
|
497 | # print data | |
498 | # raise |
|
498 | # raise | |
499 | n = self.__profIndex |
|
499 | n = self.__profIndex | |
500 |
|
500 | |||
501 | return data, n |
|
501 | return data, n | |
502 |
|
502 | |||
503 | def byProfiles(self, data): |
|
503 | def byProfiles(self, data): | |
504 |
|
504 | |||
505 | self.__dataReady = False |
|
505 | self.__dataReady = False | |
506 | avgdata = None |
|
506 | avgdata = None | |
507 | # n = None |
|
507 | # n = None | |
508 | # print data |
|
508 | # print data | |
509 | # raise |
|
509 | # raise | |
510 | self.putData(data) |
|
510 | self.putData(data) | |
511 |
|
511 | |||
512 | if self.__profIndex == self.n: |
|
512 | if self.__profIndex == self.n: | |
513 | avgdata, n = self.pushData() |
|
513 | avgdata, n = self.pushData() | |
514 | self.__dataReady = True |
|
514 | self.__dataReady = True | |
515 |
|
515 | |||
516 | return avgdata |
|
516 | return avgdata | |
517 |
|
517 | |||
518 | def byTime(self, data, datatime): |
|
518 | def byTime(self, data, datatime): | |
519 |
|
519 | |||
520 | self.__dataReady = False |
|
520 | self.__dataReady = False | |
521 | avgdata = None |
|
521 | avgdata = None | |
522 | n = None |
|
522 | n = None | |
523 |
|
523 | |||
524 | self.putData(data) |
|
524 | self.putData(data) | |
525 |
|
525 | |||
526 | if (datatime - self.__initime) >= self.__integrationtime: |
|
526 | if (datatime - self.__initime) >= self.__integrationtime: | |
527 | avgdata, n = self.pushData() |
|
527 | avgdata, n = self.pushData() | |
528 | self.n = n |
|
528 | self.n = n | |
529 | self.__dataReady = True |
|
529 | self.__dataReady = True | |
530 |
|
530 | |||
531 | return avgdata |
|
531 | return avgdata | |
532 |
|
532 | |||
533 | def integrateByStride(self, data, datatime): |
|
533 | def integrateByStride(self, data, datatime): | |
534 | # print data |
|
534 | # print data | |
535 | if self.__profIndex == 0: |
|
535 | if self.__profIndex == 0: | |
536 | self.__buffer = [[data.copy(), datatime]] |
|
536 | self.__buffer = [[data.copy(), datatime]] | |
537 | else: |
|
537 | else: | |
538 | self.__buffer.append([data.copy(),datatime]) |
|
538 | self.__buffer.append([data.copy(),datatime]) | |
539 | self.__profIndex += 1 |
|
539 | self.__profIndex += 1 | |
540 | self.__dataReady = False |
|
540 | self.__dataReady = False | |
541 |
|
541 | |||
542 | if self.__profIndex == self.n * self.stride : |
|
542 | if self.__profIndex == self.n * self.stride : | |
543 | self.__dataToPutStride = True |
|
543 | self.__dataToPutStride = True | |
544 | self.__profIndexStride = 0 |
|
544 | self.__profIndexStride = 0 | |
545 | self.__profIndex = 0 |
|
545 | self.__profIndex = 0 | |
546 | self.__bufferStride = [] |
|
546 | self.__bufferStride = [] | |
547 | for i in range(self.stride): |
|
547 | for i in range(self.stride): | |
548 | current = self.__buffer[i::self.stride] |
|
548 | current = self.__buffer[i::self.stride] | |
549 | data = numpy.sum([t[0] for t in current], axis=0) |
|
549 | data = numpy.sum([t[0] for t in current], axis=0) | |
550 | avgdatatime = numpy.average([t[1] for t in current]) |
|
550 | avgdatatime = numpy.average([t[1] for t in current]) | |
551 | # print data |
|
551 | # print data | |
552 | self.__bufferStride.append((data, avgdatatime)) |
|
552 | self.__bufferStride.append((data, avgdatatime)) | |
553 |
|
553 | |||
554 | if self.__dataToPutStride: |
|
554 | if self.__dataToPutStride: | |
555 | self.__dataReady = True |
|
555 | self.__dataReady = True | |
556 | self.__profIndexStride += 1 |
|
556 | self.__profIndexStride += 1 | |
557 | if self.__profIndexStride == self.stride: |
|
557 | if self.__profIndexStride == self.stride: | |
558 | self.__dataToPutStride = False |
|
558 | self.__dataToPutStride = False | |
559 | # print self.__bufferStride[self.__profIndexStride - 1] |
|
559 | # print self.__bufferStride[self.__profIndexStride - 1] | |
560 | # raise |
|
560 | # raise | |
561 | return self.__bufferStride[self.__profIndexStride - 1] |
|
561 | return self.__bufferStride[self.__profIndexStride - 1] | |
562 |
|
562 | |||
563 |
|
563 | |||
564 | return None, None |
|
564 | return None, None | |
565 |
|
565 | |||
566 | def integrate(self, data, datatime=None): |
|
566 | def integrate(self, data, datatime=None): | |
567 |
|
567 | |||
568 | if self.__initime == None: |
|
568 | if self.__initime == None: | |
569 | self.__initime = datatime |
|
569 | self.__initime = datatime | |
570 |
|
570 | |||
571 | if self.__byTime: |
|
571 | if self.__byTime: | |
572 | avgdata = self.byTime(data, datatime) |
|
572 | avgdata = self.byTime(data, datatime) | |
573 | else: |
|
573 | else: | |
574 | avgdata = self.byProfiles(data) |
|
574 | avgdata = self.byProfiles(data) | |
575 |
|
575 | |||
576 |
|
576 | |||
577 | self.__lastdatatime = datatime |
|
577 | self.__lastdatatime = datatime | |
578 |
|
578 | |||
579 | if avgdata is None: |
|
579 | if avgdata is None: | |
580 | return None, None |
|
580 | return None, None | |
581 |
|
581 | |||
582 | avgdatatime = self.__initime |
|
582 | avgdatatime = self.__initime | |
583 |
|
583 | |||
584 | deltatime = datatime - self.__lastdatatime |
|
584 | deltatime = datatime - self.__lastdatatime | |
585 |
|
585 | |||
586 | if not self.__withOverlapping: |
|
586 | if not self.__withOverlapping: | |
587 | self.__initime = datatime |
|
587 | self.__initime = datatime | |
588 | else: |
|
588 | else: | |
589 | self.__initime += deltatime |
|
589 | self.__initime += deltatime | |
590 |
|
590 | |||
591 | return avgdata, avgdatatime |
|
591 | return avgdata, avgdatatime | |
592 |
|
592 | |||
593 | def integrateByBlock(self, dataOut): |
|
593 | def integrateByBlock(self, dataOut): | |
594 |
|
594 | |||
595 | times = int(dataOut.data.shape[1]/self.n) |
|
595 | times = int(dataOut.data.shape[1]/self.n) | |
596 | avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex) |
|
596 | avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex) | |
597 |
|
597 | |||
598 | id_min = 0 |
|
598 | id_min = 0 | |
599 | id_max = self.n |
|
599 | id_max = self.n | |
600 |
|
600 | |||
601 | for i in range(times): |
|
601 | for i in range(times): | |
602 | junk = dataOut.data[:,id_min:id_max,:] |
|
602 | junk = dataOut.data[:,id_min:id_max,:] | |
603 | avgdata[:,i,:] = junk.sum(axis=1) |
|
603 | avgdata[:,i,:] = junk.sum(axis=1) | |
604 | id_min += self.n |
|
604 | id_min += self.n | |
605 | id_max += self.n |
|
605 | id_max += self.n | |
606 |
|
606 | |||
607 | timeInterval = dataOut.ippSeconds*self.n |
|
607 | timeInterval = dataOut.ippSeconds*self.n | |
608 | avgdatatime = (times - 1) * timeInterval + dataOut.utctime |
|
608 | avgdatatime = (times - 1) * timeInterval + dataOut.utctime | |
609 | self.__dataReady = True |
|
609 | self.__dataReady = True | |
610 | return avgdata, avgdatatime |
|
610 | return avgdata, avgdatatime | |
611 |
|
611 | |||
612 | def run(self, dataOut, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False, **kwargs): |
|
612 | def run(self, dataOut, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False, **kwargs): | |
613 | if not self.isConfig: |
|
613 | if not self.isConfig: | |
614 | self.setup(n=n, stride=stride, timeInterval=timeInterval, overlapping=overlapping, byblock=byblock, **kwargs) |
|
614 | self.setup(n=n, stride=stride, timeInterval=timeInterval, overlapping=overlapping, byblock=byblock, **kwargs) | |
615 | self.isConfig = True |
|
615 | self.isConfig = True | |
616 |
|
616 | |||
617 | if dataOut.flagDataAsBlock: |
|
617 | if dataOut.flagDataAsBlock: | |
618 | """ |
|
618 | """ | |
619 | Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
619 | Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
620 | """ |
|
620 | """ | |
621 | avgdata, avgdatatime = self.integrateByBlock(dataOut) |
|
621 | avgdata, avgdatatime = self.integrateByBlock(dataOut) | |
622 | dataOut.nProfiles /= self.n |
|
622 | dataOut.nProfiles /= self.n | |
623 | else: |
|
623 | else: | |
624 | if stride is None: |
|
624 | if stride is None: | |
625 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) |
|
625 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) | |
626 | else: |
|
626 | else: | |
627 | avgdata, avgdatatime = self.integrateByStride(dataOut.data, dataOut.utctime) |
|
627 | avgdata, avgdatatime = self.integrateByStride(dataOut.data, dataOut.utctime) | |
628 |
|
628 | |||
629 |
|
629 | |||
630 | # dataOut.timeInterval *= n |
|
630 | # dataOut.timeInterval *= n | |
631 | dataOut.flagNoData = True |
|
631 | dataOut.flagNoData = True | |
632 |
|
632 | |||
633 | if self.__dataReady: |
|
633 | if self.__dataReady: | |
634 | dataOut.data = avgdata |
|
634 | dataOut.data = avgdata | |
635 | dataOut.nCohInt *= self.n |
|
635 | dataOut.nCohInt *= self.n | |
636 | dataOut.utctime = avgdatatime |
|
636 | dataOut.utctime = avgdatatime | |
637 | # print avgdata, avgdatatime |
|
637 | # print avgdata, avgdatatime | |
638 | # raise |
|
638 | # raise | |
639 | # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt |
|
639 | # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt | |
640 | dataOut.flagNoData = False |
|
640 | dataOut.flagNoData = False | |
641 |
|
641 | |||
642 | class Decoder(Operation): |
|
642 | class Decoder(Operation): | |
643 |
|
643 | |||
644 | isConfig = False |
|
644 | isConfig = False | |
645 | __profIndex = 0 |
|
645 | __profIndex = 0 | |
646 |
|
646 | |||
647 | code = None |
|
647 | code = None | |
648 |
|
648 | |||
649 | nCode = None |
|
649 | nCode = None | |
650 | nBaud = None |
|
650 | nBaud = None | |
651 |
|
651 | |||
652 | def __init__(self, **kwargs): |
|
652 | def __init__(self, **kwargs): | |
653 |
|
653 | |||
654 | Operation.__init__(self, **kwargs) |
|
654 | Operation.__init__(self, **kwargs) | |
655 |
|
655 | |||
656 | self.times = None |
|
656 | self.times = None | |
657 | self.osamp = None |
|
657 | self.osamp = None | |
658 | # self.__setValues = False |
|
658 | # self.__setValues = False | |
659 | self.isConfig = False |
|
659 | self.isConfig = False | |
660 |
|
660 | |||
661 | def setup(self, code, osamp, dataOut): |
|
661 | def setup(self, code, osamp, dataOut): | |
662 |
|
662 | |||
663 | self.__profIndex = 0 |
|
663 | self.__profIndex = 0 | |
664 |
|
664 | |||
665 | self.code = code |
|
665 | self.code = code | |
666 |
|
666 | |||
667 | self.nCode = len(code) |
|
667 | self.nCode = len(code) | |
668 | self.nBaud = len(code[0]) |
|
668 | self.nBaud = len(code[0]) | |
669 |
|
669 | |||
670 | if (osamp != None) and (osamp >1): |
|
670 | if (osamp != None) and (osamp >1): | |
671 | self.osamp = osamp |
|
671 | self.osamp = osamp | |
672 | self.code = numpy.repeat(code, repeats=self.osamp, axis=1) |
|
672 | self.code = numpy.repeat(code, repeats=self.osamp, axis=1) | |
673 | self.nBaud = self.nBaud*self.osamp |
|
673 | self.nBaud = self.nBaud*self.osamp | |
674 |
|
674 | |||
675 | self.__nChannels = dataOut.nChannels |
|
675 | self.__nChannels = dataOut.nChannels | |
676 | self.__nProfiles = dataOut.nProfiles |
|
676 | self.__nProfiles = dataOut.nProfiles | |
677 | self.__nHeis = dataOut.nHeights |
|
677 | self.__nHeis = dataOut.nHeights | |
678 |
|
678 | |||
679 | if self.__nHeis < self.nBaud: |
|
679 | if self.__nHeis < self.nBaud: | |
680 | raise ValueError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud) |
|
680 | raise ValueError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud) | |
681 |
|
681 | |||
682 | #Frequency |
|
682 | #Frequency | |
683 | __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex) |
|
683 | __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex) | |
684 |
|
684 | |||
685 | __codeBuffer[:,0:self.nBaud] = self.code |
|
685 | __codeBuffer[:,0:self.nBaud] = self.code | |
686 |
|
686 | |||
687 | self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1)) |
|
687 | self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1)) | |
688 |
|
688 | |||
689 | if dataOut.flagDataAsBlock: |
|
689 | if dataOut.flagDataAsBlock: | |
690 |
|
690 | |||
691 | self.ndatadec = self.__nHeis #- self.nBaud + 1 |
|
691 | self.ndatadec = self.__nHeis #- self.nBaud + 1 | |
692 |
|
692 | |||
693 | self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex) |
|
693 | self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex) | |
694 |
|
694 | |||
695 | else: |
|
695 | else: | |
696 |
|
696 | |||
697 | #Time |
|
697 | #Time | |
698 | self.ndatadec = self.__nHeis #- self.nBaud + 1 |
|
698 | self.ndatadec = self.__nHeis #- self.nBaud + 1 | |
699 |
|
699 | |||
700 | self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex) |
|
700 | self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex) | |
701 |
|
701 | |||
702 | def __convolutionInFreq(self, data): |
|
702 | def __convolutionInFreq(self, data): | |
703 |
|
703 | |||
704 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) |
|
704 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) | |
705 |
|
705 | |||
706 | fft_data = numpy.fft.fft(data, axis=1) |
|
706 | fft_data = numpy.fft.fft(data, axis=1) | |
707 |
|
707 | |||
708 | conv = fft_data*fft_code |
|
708 | conv = fft_data*fft_code | |
709 |
|
709 | |||
710 | data = numpy.fft.ifft(conv,axis=1) |
|
710 | data = numpy.fft.ifft(conv,axis=1) | |
711 |
|
711 | |||
712 | return data |
|
712 | return data | |
713 |
|
713 | |||
714 | def __convolutionInFreqOpt(self, data): |
|
714 | def __convolutionInFreqOpt(self, data): | |
715 |
|
715 | |||
716 | raise NotImplementedError |
|
716 | raise NotImplementedError | |
717 |
|
717 | |||
718 | def __convolutionInTime(self, data): |
|
718 | def __convolutionInTime(self, data): | |
719 |
|
719 | |||
720 | code = self.code[self.__profIndex] |
|
720 | code = self.code[self.__profIndex] | |
721 | for i in range(self.__nChannels): |
|
721 | for i in range(self.__nChannels): | |
722 | self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='full')[self.nBaud-1:] |
|
722 | self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='full')[self.nBaud-1:] | |
723 |
|
723 | |||
724 | return self.datadecTime |
|
724 | return self.datadecTime | |
725 |
|
725 | |||
726 | def __convolutionByBlockInTime(self, data): |
|
726 | def __convolutionByBlockInTime(self, data): | |
727 |
|
727 | |||
728 | repetitions = self.__nProfiles / self.nCode |
|
728 | repetitions = self.__nProfiles / self.nCode | |
729 |
|
729 | |||
730 | junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize)) |
|
730 | junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize)) | |
731 | junk = junk.flatten() |
|
731 | junk = junk.flatten() | |
732 | code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud)) |
|
732 | code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud)) | |
733 | profilesList = xrange(self.__nProfiles) |
|
733 | profilesList = xrange(self.__nProfiles) | |
734 |
|
734 | |||
735 | for i in range(self.__nChannels): |
|
735 | for i in range(self.__nChannels): | |
736 | for j in profilesList: |
|
736 | for j in profilesList: | |
737 | self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:] |
|
737 | self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:] | |
738 | return self.datadecTime |
|
738 | return self.datadecTime | |
739 |
|
739 | |||
740 | def __convolutionByBlockInFreq(self, data): |
|
740 | def __convolutionByBlockInFreq(self, data): | |
741 |
|
741 | |||
742 | raise NotImplementedError, "Decoder by frequency fro Blocks not implemented" |
|
742 | raise NotImplementedError, "Decoder by frequency fro Blocks not implemented" | |
743 |
|
743 | |||
744 |
|
744 | |||
745 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) |
|
745 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) | |
746 |
|
746 | |||
747 | fft_data = numpy.fft.fft(data, axis=2) |
|
747 | fft_data = numpy.fft.fft(data, axis=2) | |
748 |
|
748 | |||
749 | conv = fft_data*fft_code |
|
749 | conv = fft_data*fft_code | |
750 |
|
750 | |||
751 | data = numpy.fft.ifft(conv,axis=2) |
|
751 | data = numpy.fft.ifft(conv,axis=2) | |
752 |
|
752 | |||
753 | return data |
|
753 | return data | |
754 |
|
754 | |||
755 |
|
755 | |||
756 | def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None): |
|
756 | def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None): | |
757 |
|
757 | |||
758 | if dataOut.flagDecodeData: |
|
758 | if dataOut.flagDecodeData: | |
759 | print "This data is already decoded, recoding again ..." |
|
759 | print "This data is already decoded, recoding again ..." | |
760 |
|
760 | |||
761 | if not self.isConfig: |
|
761 | if not self.isConfig: | |
762 |
|
762 | |||
763 | if code is None: |
|
763 | if code is None: | |
764 | if dataOut.code is None: |
|
764 | if dataOut.code is None: | |
765 | raise ValueError, "Code could not be read from %s instance. Enter a value in Code parameter" %dataOut.type |
|
765 | raise ValueError, "Code could not be read from %s instance. Enter a value in Code parameter" %dataOut.type | |
766 |
|
766 | |||
767 | code = dataOut.code |
|
767 | code = dataOut.code | |
768 | else: |
|
768 | else: | |
769 | code = numpy.array(code).reshape(nCode,nBaud) |
|
769 | code = numpy.array(code).reshape(nCode,nBaud) | |
770 | self.setup(code, osamp, dataOut) |
|
770 | self.setup(code, osamp, dataOut) | |
771 |
|
771 | |||
772 | self.isConfig = True |
|
772 | self.isConfig = True | |
773 |
|
773 | |||
774 | if mode == 3: |
|
774 | if mode == 3: | |
775 | sys.stderr.write("Decoder Warning: mode=%d is not valid, using mode=0\n" %mode) |
|
775 | sys.stderr.write("Decoder Warning: mode=%d is not valid, using mode=0\n" %mode) | |
776 |
|
776 | |||
777 | if times != None: |
|
777 | if times != None: | |
778 | sys.stderr.write("Decoder Warning: Argument 'times' in not used anymore\n") |
|
778 | sys.stderr.write("Decoder Warning: Argument 'times' in not used anymore\n") | |
779 |
|
779 | |||
780 | if self.code is None: |
|
780 | if self.code is None: | |
781 | print "Fail decoding: Code is not defined." |
|
781 | print "Fail decoding: Code is not defined." | |
782 | return |
|
782 | return | |
783 |
|
783 | |||
784 | self.__nProfiles = dataOut.nProfiles |
|
784 | self.__nProfiles = dataOut.nProfiles | |
785 | datadec = None |
|
785 | datadec = None | |
786 |
|
786 | |||
787 | if mode == 3: |
|
787 | if mode == 3: | |
788 | mode = 0 |
|
788 | mode = 0 | |
789 |
|
789 | |||
790 | if dataOut.flagDataAsBlock: |
|
790 | if dataOut.flagDataAsBlock: | |
791 | """ |
|
791 | """ | |
792 | Decoding when data have been read as block, |
|
792 | Decoding when data have been read as block, | |
793 | """ |
|
793 | """ | |
794 |
|
794 | |||
795 | if mode == 0: |
|
795 | if mode == 0: | |
796 | datadec = self.__convolutionByBlockInTime(dataOut.data) |
|
796 | datadec = self.__convolutionByBlockInTime(dataOut.data) | |
797 | if mode == 1: |
|
797 | if mode == 1: | |
798 | datadec = self.__convolutionByBlockInFreq(dataOut.data) |
|
798 | datadec = self.__convolutionByBlockInFreq(dataOut.data) | |
799 | else: |
|
799 | else: | |
800 | """ |
|
800 | """ | |
801 | Decoding when data have been read profile by profile |
|
801 | Decoding when data have been read profile by profile | |
802 | """ |
|
802 | """ | |
803 | if mode == 0: |
|
803 | if mode == 0: | |
804 | datadec = self.__convolutionInTime(dataOut.data) |
|
804 | datadec = self.__convolutionInTime(dataOut.data) | |
805 |
|
805 | |||
806 | if mode == 1: |
|
806 | if mode == 1: | |
807 | datadec = self.__convolutionInFreq(dataOut.data) |
|
807 | datadec = self.__convolutionInFreq(dataOut.data) | |
808 |
|
808 | |||
809 | if mode == 2: |
|
809 | if mode == 2: | |
810 | datadec = self.__convolutionInFreqOpt(dataOut.data) |
|
810 | datadec = self.__convolutionInFreqOpt(dataOut.data) | |
811 |
|
811 | |||
812 | if datadec is None: |
|
812 | if datadec is None: | |
813 | raise ValueError, "Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode |
|
813 | raise ValueError, "Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode | |
814 |
|
814 | |||
815 | dataOut.code = self.code |
|
815 | dataOut.code = self.code | |
816 | dataOut.nCode = self.nCode |
|
816 | dataOut.nCode = self.nCode | |
817 | dataOut.nBaud = self.nBaud |
|
817 | dataOut.nBaud = self.nBaud | |
818 |
|
818 | |||
819 | dataOut.data = datadec |
|
819 | dataOut.data = datadec | |
820 |
|
820 | |||
821 | dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]] |
|
821 | dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]] | |
822 |
|
822 | |||
823 | dataOut.flagDecodeData = True #asumo q la data esta decodificada |
|
823 | dataOut.flagDecodeData = True #asumo q la data esta decodificada | |
824 |
|
824 | |||
825 | if self.__profIndex == self.nCode-1: |
|
825 | if self.__profIndex == self.nCode-1: | |
826 | self.__profIndex = 0 |
|
826 | self.__profIndex = 0 | |
827 | return 1 |
|
827 | return 1 | |
828 |
|
828 | |||
829 | self.__profIndex += 1 |
|
829 | self.__profIndex += 1 | |
830 |
|
830 | |||
831 | return 1 |
|
831 | return 1 | |
832 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip |
|
832 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip | |
833 |
|
833 | |||
834 |
|
834 | |||
835 | class ProfileConcat(Operation): |
|
835 | class ProfileConcat(Operation): | |
836 |
|
836 | |||
837 | isConfig = False |
|
837 | isConfig = False | |
838 | buffer = None |
|
838 | buffer = None | |
839 | concat_m =None |
|
839 | concat_m =None | |
840 |
|
840 | |||
841 | def __init__(self, **kwargs): |
|
841 | def __init__(self, **kwargs): | |
842 |
|
842 | |||
843 | Operation.__init__(self, **kwargs) |
|
843 | Operation.__init__(self, **kwargs) | |
844 | self.profileIndex = 0 |
|
844 | self.profileIndex = 0 | |
845 |
|
845 | |||
846 | def reset(self): |
|
846 | def reset(self): | |
847 | self.buffer = numpy.zeros_like(self.buffer) |
|
847 | self.buffer = numpy.zeros_like(self.buffer) | |
848 | self.start_index = 0 |
|
848 | self.start_index = 0 | |
849 | self.times = 1 |
|
849 | self.times = 1 | |
850 |
|
850 | |||
851 | def setup(self, data, m, n=1): |
|
851 | def setup(self, data, m, n=1): | |
852 | self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0])) |
|
852 | self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0])) | |
853 | self.nHeights = data.shape[1]#.nHeights |
|
853 | self.nHeights = data.shape[1]#.nHeights | |
854 | self.start_index = 0 |
|
854 | self.start_index = 0 | |
855 | self.times = 1 |
|
855 | self.times = 1 | |
856 |
|
856 | |||
857 | def concat(self, data): |
|
857 | def concat(self, data): | |
858 |
|
858 | |||
859 | self.buffer[:,self.start_index:self.nHeights*self.times] = data.copy() |
|
859 | self.buffer[:,self.start_index:self.nHeights*self.times] = data.copy() | |
860 | self.start_index = self.start_index + self.nHeights |
|
860 | self.start_index = self.start_index + self.nHeights | |
861 |
|
861 | |||
862 | def run(self, dataOut, m): |
|
862 | def run(self, dataOut, m): | |
863 |
|
863 | |||
864 | self.concat_m= m |
|
864 | self.concat_m= m | |
865 | dataOut.flagNoData = True |
|
865 | dataOut.flagNoData = True | |
866 |
|
866 | |||
867 | if not self.isConfig: |
|
867 | if not self.isConfig: | |
868 | self.setup(dataOut.data, m, 1) |
|
868 | self.setup(dataOut.data, m, 1) | |
869 | self.isConfig = True |
|
869 | self.isConfig = True | |
870 |
|
870 | |||
871 | if dataOut.flagDataAsBlock: |
|
871 | if dataOut.flagDataAsBlock: | |
872 | raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False" |
|
872 | raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False" | |
873 |
|
873 | |||
874 | else: |
|
874 | else: | |
875 | self.concat(dataOut.data) |
|
875 | self.concat(dataOut.data) | |
876 | self.times += 1 |
|
876 | self.times += 1 | |
877 | if self.times > m: |
|
877 | if self.times > m: | |
878 | dataOut.data = self.buffer |
|
878 | dataOut.data = self.buffer | |
879 | self.reset() |
|
879 | self.reset() | |
880 | dataOut.flagNoData = False |
|
880 | dataOut.flagNoData = False | |
881 | # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas |
|
881 | # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas | |
882 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
882 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
883 | xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m |
|
883 | xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m | |
884 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) |
|
884 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) | |
885 | dataOut.ippSeconds *= m |
|
885 | dataOut.ippSeconds *= m | |
886 | dataOut.concat_m = int(m) |
|
886 | dataOut.concat_m = int(m) | |
887 |
|
887 | |||
888 | class ProfileSelector(Operation): |
|
888 | class ProfileSelector(Operation): | |
889 |
|
889 | |||
890 | profileIndex = None |
|
890 | profileIndex = None | |
891 | # Tamanho total de los perfiles |
|
891 | # Tamanho total de los perfiles | |
892 | nProfiles = None |
|
892 | nProfiles = None | |
893 |
|
893 | |||
894 | def __init__(self, **kwargs): |
|
894 | def __init__(self, **kwargs): | |
895 |
|
895 | |||
896 | Operation.__init__(self, **kwargs) |
|
896 | Operation.__init__(self, **kwargs) | |
897 | self.profileIndex = 0 |
|
897 | self.profileIndex = 0 | |
898 |
|
898 | |||
899 | def incProfileIndex(self): |
|
899 | def incProfileIndex(self): | |
900 |
|
900 | |||
901 | self.profileIndex += 1 |
|
901 | self.profileIndex += 1 | |
902 |
|
902 | |||
903 | if self.profileIndex >= self.nProfiles: |
|
903 | if self.profileIndex >= self.nProfiles: | |
904 | self.profileIndex = 0 |
|
904 | self.profileIndex = 0 | |
905 |
|
905 | |||
906 | def isThisProfileInRange(self, profileIndex, minIndex, maxIndex): |
|
906 | def isThisProfileInRange(self, profileIndex, minIndex, maxIndex): | |
907 |
|
907 | |||
908 | if profileIndex < minIndex: |
|
908 | if profileIndex < minIndex: | |
909 | return False |
|
909 | return False | |
910 |
|
910 | |||
911 | if profileIndex > maxIndex: |
|
911 | if profileIndex > maxIndex: | |
912 | return False |
|
912 | return False | |
913 |
|
913 | |||
914 | return True |
|
914 | return True | |
915 |
|
915 | |||
916 | def isThisProfileInList(self, profileIndex, profileList): |
|
916 | def isThisProfileInList(self, profileIndex, profileList): | |
917 |
|
917 | |||
918 | if profileIndex not in profileList: |
|
918 | if profileIndex not in profileList: | |
919 | return False |
|
919 | return False | |
920 |
|
920 | |||
921 | return True |
|
921 | return True | |
922 |
|
922 | |||
923 | def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None): |
|
923 | def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None): | |
924 |
|
924 | |||
925 | """ |
|
925 | """ | |
926 | ProfileSelector: |
|
926 | ProfileSelector: | |
927 |
|
927 | |||
928 | Inputs: |
|
928 | Inputs: | |
929 | profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8) |
|
929 | profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8) | |
930 |
|
930 | |||
931 | profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30) |
|
931 | profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30) | |
932 |
|
932 | |||
933 | rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256)) |
|
933 | rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256)) | |
934 |
|
934 | |||
935 | """ |
|
935 | """ | |
936 |
|
936 | |||
937 | if rangeList is not None: |
|
937 | if rangeList is not None: | |
938 | if type(rangeList[0]) not in (tuple, list): |
|
938 | if type(rangeList[0]) not in (tuple, list): | |
939 | rangeList = [rangeList] |
|
939 | rangeList = [rangeList] | |
940 |
|
940 | |||
941 | dataOut.flagNoData = True |
|
941 | dataOut.flagNoData = True | |
942 |
|
942 | |||
943 | if dataOut.flagDataAsBlock: |
|
943 | if dataOut.flagDataAsBlock: | |
944 | """ |
|
944 | """ | |
945 | data dimension = [nChannels, nProfiles, nHeis] |
|
945 | data dimension = [nChannels, nProfiles, nHeis] | |
946 | """ |
|
946 | """ | |
947 | if profileList != None: |
|
947 | if profileList != None: | |
948 | dataOut.data = dataOut.data[:,profileList,:] |
|
948 | dataOut.data = dataOut.data[:,profileList,:] | |
949 |
|
949 | |||
950 | if profileRangeList != None: |
|
950 | if profileRangeList != None: | |
951 | minIndex = profileRangeList[0] |
|
951 | minIndex = profileRangeList[0] | |
952 | maxIndex = profileRangeList[1] |
|
952 | maxIndex = profileRangeList[1] | |
953 | profileList = range(minIndex, maxIndex+1) |
|
953 | profileList = range(minIndex, maxIndex+1) | |
954 |
|
954 | |||
955 | dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:] |
|
955 | dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:] | |
956 |
|
956 | |||
957 | if rangeList != None: |
|
957 | if rangeList != None: | |
958 |
|
958 | |||
959 | profileList = [] |
|
959 | profileList = [] | |
960 |
|
960 | |||
961 | for thisRange in rangeList: |
|
961 | for thisRange in rangeList: | |
962 | minIndex = thisRange[0] |
|
962 | minIndex = thisRange[0] | |
963 | maxIndex = thisRange[1] |
|
963 | maxIndex = thisRange[1] | |
964 |
|
964 | |||
965 | profileList.extend(range(minIndex, maxIndex+1)) |
|
965 | profileList.extend(range(minIndex, maxIndex+1)) | |
966 |
|
966 | |||
967 | dataOut.data = dataOut.data[:,profileList,:] |
|
967 | dataOut.data = dataOut.data[:,profileList,:] | |
968 |
|
968 | |||
969 | dataOut.nProfiles = len(profileList) |
|
969 | dataOut.nProfiles = len(profileList) | |
970 | dataOut.profileIndex = dataOut.nProfiles - 1 |
|
970 | dataOut.profileIndex = dataOut.nProfiles - 1 | |
971 | dataOut.flagNoData = False |
|
971 | dataOut.flagNoData = False | |
972 |
|
972 | |||
973 | return True |
|
973 | return True | |
974 |
|
974 | |||
975 | """ |
|
975 | """ | |
976 | data dimension = [nChannels, nHeis] |
|
976 | data dimension = [nChannels, nHeis] | |
977 | """ |
|
977 | """ | |
978 |
|
978 | |||
979 | if profileList != None: |
|
979 | if profileList != None: | |
980 |
|
980 | |||
981 | if self.isThisProfileInList(dataOut.profileIndex, profileList): |
|
981 | if self.isThisProfileInList(dataOut.profileIndex, profileList): | |
982 |
|
982 | |||
983 | self.nProfiles = len(profileList) |
|
983 | self.nProfiles = len(profileList) | |
984 | dataOut.nProfiles = self.nProfiles |
|
984 | dataOut.nProfiles = self.nProfiles | |
985 | dataOut.profileIndex = self.profileIndex |
|
985 | dataOut.profileIndex = self.profileIndex | |
986 | dataOut.flagNoData = False |
|
986 | dataOut.flagNoData = False | |
987 |
|
987 | |||
988 | self.incProfileIndex() |
|
988 | self.incProfileIndex() | |
989 | return True |
|
989 | return True | |
990 |
|
990 | |||
991 | if profileRangeList != None: |
|
991 | if profileRangeList != None: | |
992 |
|
992 | |||
993 | minIndex = profileRangeList[0] |
|
993 | minIndex = profileRangeList[0] | |
994 | maxIndex = profileRangeList[1] |
|
994 | maxIndex = profileRangeList[1] | |
995 |
|
995 | |||
996 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): |
|
996 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): | |
997 |
|
997 | |||
998 | self.nProfiles = maxIndex - minIndex + 1 |
|
998 | self.nProfiles = maxIndex - minIndex + 1 | |
999 | dataOut.nProfiles = self.nProfiles |
|
999 | dataOut.nProfiles = self.nProfiles | |
1000 | dataOut.profileIndex = self.profileIndex |
|
1000 | dataOut.profileIndex = self.profileIndex | |
1001 | dataOut.flagNoData = False |
|
1001 | dataOut.flagNoData = False | |
1002 |
|
1002 | |||
1003 | self.incProfileIndex() |
|
1003 | self.incProfileIndex() | |
1004 | return True |
|
1004 | return True | |
1005 |
|
1005 | |||
1006 | if rangeList != None: |
|
1006 | if rangeList != None: | |
1007 |
|
1007 | |||
1008 | nProfiles = 0 |
|
1008 | nProfiles = 0 | |
1009 |
|
1009 | |||
1010 | for thisRange in rangeList: |
|
1010 | for thisRange in rangeList: | |
1011 | minIndex = thisRange[0] |
|
1011 | minIndex = thisRange[0] | |
1012 | maxIndex = thisRange[1] |
|
1012 | maxIndex = thisRange[1] | |
1013 |
|
1013 | |||
1014 | nProfiles += maxIndex - minIndex + 1 |
|
1014 | nProfiles += maxIndex - minIndex + 1 | |
1015 |
|
1015 | |||
1016 | for thisRange in rangeList: |
|
1016 | for thisRange in rangeList: | |
1017 |
|
1017 | |||
1018 | minIndex = thisRange[0] |
|
1018 | minIndex = thisRange[0] | |
1019 | maxIndex = thisRange[1] |
|
1019 | maxIndex = thisRange[1] | |
1020 |
|
1020 | |||
1021 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): |
|
1021 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): | |
1022 |
|
1022 | |||
1023 | self.nProfiles = nProfiles |
|
1023 | self.nProfiles = nProfiles | |
1024 | dataOut.nProfiles = self.nProfiles |
|
1024 | dataOut.nProfiles = self.nProfiles | |
1025 | dataOut.profileIndex = self.profileIndex |
|
1025 | dataOut.profileIndex = self.profileIndex | |
1026 | dataOut.flagNoData = False |
|
1026 | dataOut.flagNoData = False | |
1027 |
|
1027 | |||
1028 | self.incProfileIndex() |
|
1028 | self.incProfileIndex() | |
1029 |
|
1029 | |||
1030 | break |
|
1030 | break | |
1031 |
|
1031 | |||
1032 | return True |
|
1032 | return True | |
1033 |
|
1033 | |||
1034 |
|
1034 | |||
1035 | if beam != None: #beam is only for AMISR data |
|
1035 | if beam != None: #beam is only for AMISR data | |
1036 | if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]): |
|
1036 | if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]): | |
1037 | dataOut.flagNoData = False |
|
1037 | dataOut.flagNoData = False | |
1038 | dataOut.profileIndex = self.profileIndex |
|
1038 | dataOut.profileIndex = self.profileIndex | |
1039 |
|
1039 | |||
1040 | self.incProfileIndex() |
|
1040 | self.incProfileIndex() | |
1041 |
|
1041 | |||
1042 | return True |
|
1042 | return True | |
1043 |
|
1043 | |||
1044 | raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter" |
|
1044 | raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter" | |
1045 |
|
1045 | |||
1046 | return False |
|
1046 | return False | |
1047 |
|
1047 | |||
1048 | class Reshaper(Operation): |
|
1048 | class Reshaper(Operation): | |
1049 |
|
1049 | |||
1050 | def __init__(self, **kwargs): |
|
1050 | def __init__(self, **kwargs): | |
1051 |
|
1051 | |||
1052 | Operation.__init__(self, **kwargs) |
|
1052 | Operation.__init__(self, **kwargs) | |
1053 |
|
1053 | |||
1054 | self.__buffer = None |
|
1054 | self.__buffer = None | |
1055 | self.__nitems = 0 |
|
1055 | self.__nitems = 0 | |
1056 |
|
1056 | |||
1057 | def __appendProfile(self, dataOut, nTxs): |
|
1057 | def __appendProfile(self, dataOut, nTxs): | |
1058 |
|
1058 | |||
1059 | if self.__buffer is None: |
|
1059 | if self.__buffer is None: | |
1060 | shape = (dataOut.nChannels, int(dataOut.nHeights/nTxs) ) |
|
1060 | shape = (dataOut.nChannels, int(dataOut.nHeights/nTxs) ) | |
1061 | self.__buffer = numpy.empty(shape, dtype = dataOut.data.dtype) |
|
1061 | self.__buffer = numpy.empty(shape, dtype = dataOut.data.dtype) | |
1062 |
|
1062 | |||
1063 | ini = dataOut.nHeights * self.__nitems |
|
1063 | ini = dataOut.nHeights * self.__nitems | |
1064 | end = ini + dataOut.nHeights |
|
1064 | end = ini + dataOut.nHeights | |
1065 |
|
1065 | |||
1066 | self.__buffer[:, ini:end] = dataOut.data |
|
1066 | self.__buffer[:, ini:end] = dataOut.data | |
1067 |
|
1067 | |||
1068 | self.__nitems += 1 |
|
1068 | self.__nitems += 1 | |
1069 |
|
1069 | |||
1070 | return int(self.__nitems*nTxs) |
|
1070 | return int(self.__nitems*nTxs) | |
1071 |
|
1071 | |||
1072 | def __getBuffer(self): |
|
1072 | def __getBuffer(self): | |
1073 |
|
1073 | |||
1074 | if self.__nitems == int(1./self.__nTxs): |
|
1074 | if self.__nitems == int(1./self.__nTxs): | |
1075 |
|
1075 | |||
1076 | self.__nitems = 0 |
|
1076 | self.__nitems = 0 | |
1077 |
|
1077 | |||
1078 | return self.__buffer.copy() |
|
1078 | return self.__buffer.copy() | |
1079 |
|
1079 | |||
1080 | return None |
|
1080 | return None | |
1081 |
|
1081 | |||
1082 | def __checkInputs(self, dataOut, shape, nTxs): |
|
1082 | def __checkInputs(self, dataOut, shape, nTxs): | |
1083 |
|
1083 | |||
1084 | if shape is None and nTxs is None: |
|
1084 | if shape is None and nTxs is None: | |
1085 | raise ValueError, "Reshaper: shape of factor should be defined" |
|
1085 | raise ValueError, "Reshaper: shape of factor should be defined" | |
1086 |
|
1086 | |||
1087 | if nTxs: |
|
1087 | if nTxs: | |
1088 | if nTxs < 0: |
|
1088 | if nTxs < 0: | |
1089 | raise ValueError, "nTxs should be greater than 0" |
|
1089 | raise ValueError, "nTxs should be greater than 0" | |
1090 |
|
1090 | |||
1091 | if nTxs < 1 and dataOut.nProfiles % (1./nTxs) != 0: |
|
1091 | if nTxs < 1 and dataOut.nProfiles % (1./nTxs) != 0: | |
1092 | raise ValueError, "nProfiles= %d is not divisibled by (1./nTxs) = %f" %(dataOut.nProfiles, (1./nTxs)) |
|
1092 | raise ValueError, "nProfiles= %d is not divisibled by (1./nTxs) = %f" %(dataOut.nProfiles, (1./nTxs)) | |
1093 |
|
1093 | |||
1094 | shape = [dataOut.nChannels, dataOut.nProfiles*nTxs, dataOut.nHeights/nTxs] |
|
1094 | shape = [dataOut.nChannels, dataOut.nProfiles*nTxs, dataOut.nHeights/nTxs] | |
1095 |
|
1095 | |||
1096 | return shape, nTxs |
|
1096 | return shape, nTxs | |
1097 |
|
1097 | |||
1098 | if len(shape) != 2 and len(shape) != 3: |
|
1098 | if len(shape) != 2 and len(shape) != 3: | |
1099 | raise ValueError, "shape dimension should be equal to 2 or 3. shape = (nProfiles, nHeis) or (nChannels, nProfiles, nHeis). Actually shape = (%d, %d, %d)" %(dataOut.nChannels, dataOut.nProfiles, dataOut.nHeights) |
|
1099 | raise ValueError, "shape dimension should be equal to 2 or 3. shape = (nProfiles, nHeis) or (nChannels, nProfiles, nHeis). Actually shape = (%d, %d, %d)" %(dataOut.nChannels, dataOut.nProfiles, dataOut.nHeights) | |
1100 |
|
1100 | |||
1101 | if len(shape) == 2: |
|
1101 | if len(shape) == 2: | |
1102 | shape_tuple = [dataOut.nChannels] |
|
1102 | shape_tuple = [dataOut.nChannels] | |
1103 | shape_tuple.extend(shape) |
|
1103 | shape_tuple.extend(shape) | |
1104 | else: |
|
1104 | else: | |
1105 | shape_tuple = list(shape) |
|
1105 | shape_tuple = list(shape) | |
1106 |
|
1106 | |||
1107 | nTxs = 1.0*shape_tuple[1]/dataOut.nProfiles |
|
1107 | nTxs = 1.0*shape_tuple[1]/dataOut.nProfiles | |
1108 |
|
1108 | |||
1109 | return shape_tuple, nTxs |
|
1109 | return shape_tuple, nTxs | |
1110 |
|
1110 | |||
1111 | def run(self, dataOut, shape=None, nTxs=None): |
|
1111 | def run(self, dataOut, shape=None, nTxs=None): | |
1112 |
|
1112 | |||
1113 | shape_tuple, self.__nTxs = self.__checkInputs(dataOut, shape, nTxs) |
|
1113 | shape_tuple, self.__nTxs = self.__checkInputs(dataOut, shape, nTxs) | |
1114 |
|
1114 | |||
1115 | dataOut.flagNoData = True |
|
1115 | dataOut.flagNoData = True | |
1116 | profileIndex = None |
|
1116 | profileIndex = None | |
1117 |
|
1117 | |||
1118 | if dataOut.flagDataAsBlock: |
|
1118 | if dataOut.flagDataAsBlock: | |
1119 |
|
1119 | |||
1120 | dataOut.data = numpy.reshape(dataOut.data, shape_tuple) |
|
1120 | dataOut.data = numpy.reshape(dataOut.data, shape_tuple) | |
1121 | dataOut.flagNoData = False |
|
1121 | dataOut.flagNoData = False | |
1122 |
|
1122 | |||
1123 | profileIndex = int(dataOut.nProfiles*self.__nTxs) - 1 |
|
1123 | profileIndex = int(dataOut.nProfiles*self.__nTxs) - 1 | |
1124 |
|
1124 | |||
1125 | else: |
|
1125 | else: | |
1126 |
|
1126 | |||
1127 | if self.__nTxs < 1: |
|
1127 | if self.__nTxs < 1: | |
1128 |
|
1128 | |||
1129 | self.__appendProfile(dataOut, self.__nTxs) |
|
1129 | self.__appendProfile(dataOut, self.__nTxs) | |
1130 | new_data = self.__getBuffer() |
|
1130 | new_data = self.__getBuffer() | |
1131 |
|
1131 | |||
1132 | if new_data is not None: |
|
1132 | if new_data is not None: | |
1133 | dataOut.data = new_data |
|
1133 | dataOut.data = new_data | |
1134 | dataOut.flagNoData = False |
|
1134 | dataOut.flagNoData = False | |
1135 |
|
1135 | |||
1136 | profileIndex = dataOut.profileIndex*nTxs |
|
1136 | profileIndex = dataOut.profileIndex*nTxs | |
1137 |
|
1137 | |||
1138 | else: |
|
1138 | else: | |
1139 | raise ValueError, "nTxs should be greater than 0 and lower than 1, or use VoltageReader(..., getblock=True)" |
|
1139 | raise ValueError, "nTxs should be greater than 0 and lower than 1, or use VoltageReader(..., getblock=True)" | |
1140 |
|
1140 | |||
1141 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1141 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1142 |
|
1142 | |||
1143 | dataOut.heightList = numpy.arange(dataOut.nHeights/self.__nTxs) * deltaHeight + dataOut.heightList[0] |
|
1143 | dataOut.heightList = numpy.arange(dataOut.nHeights/self.__nTxs) * deltaHeight + dataOut.heightList[0] | |
1144 |
|
1144 | |||
1145 | dataOut.nProfiles = int(dataOut.nProfiles*self.__nTxs) |
|
1145 | dataOut.nProfiles = int(dataOut.nProfiles*self.__nTxs) | |
1146 |
|
1146 | |||
1147 | dataOut.profileIndex = profileIndex |
|
1147 | dataOut.profileIndex = profileIndex | |
1148 |
|
1148 | |||
1149 | dataOut.ippSeconds /= self.__nTxs |
|
1149 | dataOut.ippSeconds /= self.__nTxs | |
1150 |
|
1150 | |||
1151 | class SplitProfiles(Operation): |
|
1151 | class SplitProfiles(Operation): | |
1152 |
|
1152 | |||
1153 | def __init__(self, **kwargs): |
|
1153 | def __init__(self, **kwargs): | |
1154 |
|
1154 | |||
1155 | Operation.__init__(self, **kwargs) |
|
1155 | Operation.__init__(self, **kwargs) | |
1156 |
|
1156 | |||
1157 | def run(self, dataOut, n): |
|
1157 | def run(self, dataOut, n): | |
1158 |
|
1158 | |||
1159 | dataOut.flagNoData = True |
|
1159 | dataOut.flagNoData = True | |
1160 | profileIndex = None |
|
1160 | profileIndex = None | |
1161 |
|
1161 | |||
1162 | if dataOut.flagDataAsBlock: |
|
1162 | if dataOut.flagDataAsBlock: | |
1163 |
|
1163 | |||
1164 | #nchannels, nprofiles, nsamples |
|
1164 | #nchannels, nprofiles, nsamples | |
1165 | shape = dataOut.data.shape |
|
1165 | shape = dataOut.data.shape | |
1166 |
|
1166 | |||
1167 | if shape[2] % n != 0: |
|
1167 | if shape[2] % n != 0: | |
1168 | raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[2]) |
|
1168 | raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[2]) | |
1169 |
|
1169 | |||
1170 | new_shape = shape[0], shape[1]*n, shape[2]/n |
|
1170 | new_shape = shape[0], shape[1]*n, shape[2]/n | |
1171 |
|
1171 | |||
1172 | dataOut.data = numpy.reshape(dataOut.data, new_shape) |
|
1172 | dataOut.data = numpy.reshape(dataOut.data, new_shape) | |
1173 | dataOut.flagNoData = False |
|
1173 | dataOut.flagNoData = False | |
1174 |
|
1174 | |||
1175 | profileIndex = int(dataOut.nProfiles/n) - 1 |
|
1175 | profileIndex = int(dataOut.nProfiles/n) - 1 | |
1176 |
|
1176 | |||
1177 | else: |
|
1177 | else: | |
1178 |
|
1178 | |||
1179 | raise ValueError, "Could not split the data when is read Profile by Profile. Use VoltageReader(..., getblock=True)" |
|
1179 | raise ValueError, "Could not split the data when is read Profile by Profile. Use VoltageReader(..., getblock=True)" | |
1180 |
|
1180 | |||
1181 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1181 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1182 |
|
1182 | |||
1183 | dataOut.heightList = numpy.arange(dataOut.nHeights/n) * deltaHeight + dataOut.heightList[0] |
|
1183 | dataOut.heightList = numpy.arange(dataOut.nHeights/n) * deltaHeight + dataOut.heightList[0] | |
1184 |
|
1184 | |||
1185 | dataOut.nProfiles = int(dataOut.nProfiles*n) |
|
1185 | dataOut.nProfiles = int(dataOut.nProfiles*n) | |
1186 |
|
1186 | |||
1187 | dataOut.profileIndex = profileIndex |
|
1187 | dataOut.profileIndex = profileIndex | |
1188 |
|
1188 | |||
1189 | dataOut.ippSeconds /= n |
|
1189 | dataOut.ippSeconds /= n | |
1190 |
|
1190 | |||
1191 | class CombineProfiles(Operation): |
|
1191 | class CombineProfiles(Operation): | |
1192 |
|
1192 | |||
1193 | def __init__(self, **kwargs): |
|
1193 | def __init__(self, **kwargs): | |
1194 |
|
1194 | |||
1195 | Operation.__init__(self, **kwargs) |
|
1195 | Operation.__init__(self, **kwargs) | |
1196 |
|
1196 | |||
1197 | self.__remData = None |
|
1197 | self.__remData = None | |
1198 | self.__profileIndex = 0 |
|
1198 | self.__profileIndex = 0 | |
1199 |
|
1199 | |||
1200 | def run(self, dataOut, n): |
|
1200 | def run(self, dataOut, n): | |
1201 |
|
1201 | |||
1202 | dataOut.flagNoData = True |
|
1202 | dataOut.flagNoData = True | |
1203 | profileIndex = None |
|
1203 | profileIndex = None | |
1204 |
|
1204 | |||
1205 | if dataOut.flagDataAsBlock: |
|
1205 | if dataOut.flagDataAsBlock: | |
1206 |
|
1206 | |||
1207 | #nchannels, nprofiles, nsamples |
|
1207 | #nchannels, nprofiles, nsamples | |
1208 | shape = dataOut.data.shape |
|
1208 | shape = dataOut.data.shape | |
1209 | new_shape = shape[0], shape[1]/n, shape[2]*n |
|
1209 | new_shape = shape[0], shape[1]/n, shape[2]*n | |
1210 |
|
1210 | |||
1211 | if shape[1] % n != 0: |
|
1211 | if shape[1] % n != 0: | |
1212 | raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[1]) |
|
1212 | raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[1]) | |
1213 |
|
1213 | |||
1214 | dataOut.data = numpy.reshape(dataOut.data, new_shape) |
|
1214 | dataOut.data = numpy.reshape(dataOut.data, new_shape) | |
1215 | dataOut.flagNoData = False |
|
1215 | dataOut.flagNoData = False | |
1216 |
|
1216 | |||
1217 | profileIndex = int(dataOut.nProfiles*n) - 1 |
|
1217 | profileIndex = int(dataOut.nProfiles*n) - 1 | |
1218 |
|
1218 | |||
1219 | else: |
|
1219 | else: | |
1220 |
|
1220 | |||
1221 | #nchannels, nsamples |
|
1221 | #nchannels, nsamples | |
1222 | if self.__remData is None: |
|
1222 | if self.__remData is None: | |
1223 | newData = dataOut.data |
|
1223 | newData = dataOut.data | |
1224 | else: |
|
1224 | else: | |
1225 | newData = numpy.concatenate((self.__remData, dataOut.data), axis=1) |
|
1225 | newData = numpy.concatenate((self.__remData, dataOut.data), axis=1) | |
1226 |
|
1226 | |||
1227 | self.__profileIndex += 1 |
|
1227 | self.__profileIndex += 1 | |
1228 |
|
1228 | |||
1229 | if self.__profileIndex < n: |
|
1229 | if self.__profileIndex < n: | |
1230 | self.__remData = newData |
|
1230 | self.__remData = newData | |
1231 | #continue |
|
1231 | #continue | |
1232 | return |
|
1232 | return | |
1233 |
|
1233 | |||
1234 | self.__profileIndex = 0 |
|
1234 | self.__profileIndex = 0 | |
1235 | self.__remData = None |
|
1235 | self.__remData = None | |
1236 |
|
1236 | |||
1237 | dataOut.data = newData |
|
1237 | dataOut.data = newData | |
1238 | dataOut.flagNoData = False |
|
1238 | dataOut.flagNoData = False | |
1239 |
|
1239 | |||
1240 | profileIndex = dataOut.profileIndex/n |
|
1240 | profileIndex = dataOut.profileIndex/n | |
1241 |
|
1241 | |||
1242 |
|
1242 | |||
1243 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1243 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1244 |
|
1244 | |||
1245 | dataOut.heightList = numpy.arange(dataOut.nHeights*n) * deltaHeight + dataOut.heightList[0] |
|
1245 | dataOut.heightList = numpy.arange(dataOut.nHeights*n) * deltaHeight + dataOut.heightList[0] | |
1246 |
|
1246 | |||
1247 | dataOut.nProfiles = int(dataOut.nProfiles/n) |
|
1247 | dataOut.nProfiles = int(dataOut.nProfiles/n) | |
1248 |
|
1248 | |||
1249 | dataOut.profileIndex = profileIndex |
|
1249 | dataOut.profileIndex = profileIndex | |
1250 |
|
1250 | |||
1251 | dataOut.ippSeconds *= n |
|
1251 | dataOut.ippSeconds *= n | |
1252 |
|
1252 | |||
1253 |
|
1253 | |||
1254 | class SSheightProfiles(Operation): |
|
1254 | class SSheightProfiles(Operation): | |
1255 |
|
1255 | |||
1256 | step = None |
|
1256 | step = None | |
1257 | nsamples = None |
|
1257 | nsamples = None | |
1258 | bufferShape = None |
|
1258 | bufferShape = None | |
1259 | profileShape = None |
|
1259 | profileShape = None | |
1260 | sshProfiles = None |
|
1260 | sshProfiles = None | |
1261 | profileIndex = None |
|
1261 | profileIndex = None | |
1262 |
|
1262 | |||
1263 | def __init__(self, **kwargs): |
|
1263 | def __init__(self, **kwargs): | |
1264 |
|
1264 | |||
1265 | Operation.__init__(self, **kwargs) |
|
1265 | Operation.__init__(self, **kwargs) | |
1266 | self.isConfig = False |
|
1266 | self.isConfig = False | |
1267 |
|
1267 | |||
1268 | def setup(self,dataOut ,step = None , nsamples = None): |
|
1268 | def setup(self,dataOut ,step = None , nsamples = None): | |
1269 |
|
1269 | |||
1270 | if step == None and nsamples == None: |
|
1270 | if step == None and nsamples == None: | |
1271 | raise ValueError, "step or nheights should be specified ..." |
|
1271 | raise ValueError, "step or nheights should be specified ..." | |
1272 |
|
1272 | |||
1273 | self.step = step |
|
1273 | self.step = step | |
1274 | self.nsamples = nsamples |
|
1274 | self.nsamples = nsamples | |
1275 | self.__nChannels = dataOut.nChannels |
|
1275 | self.__nChannels = dataOut.nChannels | |
1276 | self.__nProfiles = dataOut.nProfiles |
|
1276 | self.__nProfiles = dataOut.nProfiles | |
1277 | self.__nHeis = dataOut.nHeights |
|
1277 | self.__nHeis = dataOut.nHeights | |
1278 | shape = dataOut.data.shape #nchannels, nprofiles, nsamples |
|
1278 | shape = dataOut.data.shape #nchannels, nprofiles, nsamples | |
1279 | print "input nChannels",self.__nChannels |
|
1279 | print "input nChannels",self.__nChannels | |
1280 | print "input nProfiles",self.__nProfiles |
|
1280 | print "input nProfiles",self.__nProfiles | |
1281 | print "input nHeis",self.__nHeis |
|
1281 | print "input nHeis",self.__nHeis | |
1282 | print "input Shape",shape |
|
1282 | print "input Shape",shape | |
1283 |
|
1283 | |||
1284 |
|
1284 | |||
1285 |
|
1285 | |||
1286 | residue = (shape[1] - self.nsamples) % self.step |
|
1286 | residue = (shape[1] - self.nsamples) % self.step | |
1287 | if residue != 0: |
|
1287 | if residue != 0: | |
1288 | print "The residue is %d, step=%d should be multiple of %d to avoid loss of %d samples"%(residue,step,shape[1] - self.nsamples,residue) |
|
1288 | print "The residue is %d, step=%d should be multiple of %d to avoid loss of %d samples"%(residue,step,shape[1] - self.nsamples,residue) | |
1289 |
|
1289 | |||
1290 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1290 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1291 | numberProfile = self.nsamples |
|
1291 | numberProfile = self.nsamples | |
1292 | numberSamples = (shape[1] - self.nsamples)/self.step |
|
1292 | numberSamples = (shape[1] - self.nsamples)/self.step | |
1293 |
|
1293 | |||
1294 | print "new numberProfile",numberProfile |
|
1294 | print "new numberProfile",numberProfile | |
1295 | print "new numberSamples",numberSamples |
|
1295 | print "new numberSamples",numberSamples | |
1296 |
|
1296 | |||
1297 | print "New number of profile: %d, number of height: %d, Resolution %f Km"%(numberProfile,numberSamples,deltaHeight*self.step) |
|
1297 | print "New number of profile: %d, number of height: %d, Resolution %f Km"%(numberProfile,numberSamples,deltaHeight*self.step) | |
1298 |
|
1298 | |||
1299 | self.bufferShape = shape[0], numberSamples, numberProfile # nchannels, nsamples , nprofiles |
|
1299 | self.bufferShape = shape[0], numberSamples, numberProfile # nchannels, nsamples , nprofiles | |
1300 | self.profileShape = shape[0], numberProfile, numberSamples # nchannels, nprofiles, nsamples |
|
1300 | self.profileShape = shape[0], numberProfile, numberSamples # nchannels, nprofiles, nsamples | |
1301 |
|
1301 | |||
1302 | self.buffer = numpy.zeros(self.bufferShape , dtype=numpy.complex) |
|
1302 | self.buffer = numpy.zeros(self.bufferShape , dtype=numpy.complex) | |
1303 | self.sshProfiles = numpy.zeros(self.profileShape, dtype=numpy.complex) |
|
1303 | self.sshProfiles = numpy.zeros(self.profileShape, dtype=numpy.complex) | |
1304 |
|
1304 | |||
1305 | def run(self, dataOut, step, nsamples): |
|
1305 | def run(self, dataOut, step, nsamples): | |
1306 |
|
1306 | |||
1307 | dataOut.flagNoData = True |
|
1307 | dataOut.flagNoData = True | |
1308 | dataOut.flagDataAsBlock = False |
|
1308 | dataOut.flagDataAsBlock = False | |
1309 | profileIndex = None |
|
1309 | profileIndex = None | |
1310 |
|
1310 | |||
1311 |
|
1311 | |||
1312 | if not self.isConfig: |
|
1312 | if not self.isConfig: | |
1313 | self.setup(dataOut, step=step , nsamples=nsamples) |
|
1313 | self.setup(dataOut, step=step , nsamples=nsamples) | |
1314 | self.isConfig = True |
|
1314 | self.isConfig = True | |
1315 |
|
1315 | |||
1316 | for i in range(self.buffer.shape[1]): |
|
1316 | for i in range(self.buffer.shape[1]): | |
1317 | #self.buffer[:,i] = numpy.flip(dataOut.data[:,i*self.step:i*self.step + self.nsamples]) |
|
1317 | #self.buffer[:,i] = numpy.flip(dataOut.data[:,i*self.step:i*self.step + self.nsamples]) | |
1318 | self.buffer[:,i] = dataOut.data[:,i*self.step:i*self.step + self.nsamples] |
|
1318 | self.buffer[:,i] = dataOut.data[:,i*self.step:i*self.step + self.nsamples] | |
1319 | #self.buffer[:,j,self.__nHeis-j*self.step - self.nheights:self.__nHeis-j*self.step] = numpy.flip(dataOut.data[:,j*self.step:j*self.step + self.nheights]) |
|
1319 | #self.buffer[:,j,self.__nHeis-j*self.step - self.nheights:self.__nHeis-j*self.step] = numpy.flip(dataOut.data[:,j*self.step:j*self.step + self.nheights]) | |
1320 |
|
1320 | |||
1321 | for j in range(self.buffer.shape[0]): |
|
1321 | for j in range(self.buffer.shape[0]): | |
1322 | self.sshProfiles[j] = numpy.transpose(self.buffer[j]) |
|
1322 | self.sshProfiles[j] = numpy.transpose(self.buffer[j]) | |
1323 |
|
1323 | |||
1324 | profileIndex = self.nsamples |
|
1324 | profileIndex = self.nsamples | |
1325 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1325 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1326 | ippSeconds = (deltaHeight*1.0e-6)/(0.15) |
|
1326 | ippSeconds = (deltaHeight*1.0e-6)/(0.15) | |
1327 | #print "ippSeconds",ippSeconds |
|
1327 | #print "ippSeconds",ippSeconds | |
1328 | try: |
|
1328 | try: | |
1329 | if dataOut.concat_m is not None: |
|
1329 | if dataOut.concat_m is not None: | |
1330 | ippSeconds= ippSeconds/float(dataOut.concat_m) |
|
1330 | ippSeconds= ippSeconds/float(dataOut.concat_m) | |
1331 | #print "Profile concat %d"%dataOut.concat_m |
|
1331 | #print "Profile concat %d"%dataOut.concat_m | |
1332 | except: |
|
1332 | except: | |
1333 | pass |
|
1333 | pass | |
1334 |
|
1334 | |||
1335 | dataOut.data = self.sshProfiles |
|
1335 | dataOut.data = self.sshProfiles | |
1336 | dataOut.flagNoData = False |
|
1336 | dataOut.flagNoData = False | |
1337 | dataOut.heightList = numpy.arange(self.buffer.shape[1]) *self.step*deltaHeight + dataOut.heightList[0] |
|
1337 | dataOut.heightList = numpy.arange(self.buffer.shape[1]) *self.step*deltaHeight + dataOut.heightList[0] | |
1338 | dataOut.nProfiles = int(dataOut.nProfiles*self.nsamples) |
|
1338 | dataOut.nProfiles = int(dataOut.nProfiles*self.nsamples) | |
1339 | dataOut.profileIndex = profileIndex |
|
1339 | dataOut.profileIndex = profileIndex | |
1340 | dataOut.flagDataAsBlock = True |
|
1340 | dataOut.flagDataAsBlock = True | |
1341 | dataOut.ippSeconds = ippSeconds |
|
1341 | dataOut.ippSeconds = ippSeconds | |
1342 | dataOut.step = self.step |
|
1342 | dataOut.step = self.step | |
1343 |
|
1343 | |||
1344 | class voltACFLags(Operation): |
|
1344 | class voltACFLags(Operation): | |
1345 |
|
1345 | |||
1346 | data_acf = None |
|
1346 | data_acf = None | |
1347 | lags = None |
|
1347 | lags = None | |
1348 | mode = None |
|
1348 | mode = None | |
1349 | fullBuffer = None |
|
1349 | fullBuffer = None | |
1350 | pairsList = None |
|
1350 | pairsList = None | |
1351 | tmp = None |
|
1351 | tmp = None | |
1352 |
|
1352 | |||
1353 | def __init__(self, **kwargs): |
|
1353 | def __init__(self, **kwargs): | |
1354 | Operation.__init__(self, **kwargs) |
|
1354 | Operation.__init__(self, **kwargs) | |
1355 | self.isConfig = False |
|
1355 | self.isConfig = False | |
1356 |
|
1356 | |||
1357 | def setup(self,dataOut ,lags = None,mode =None, fullBuffer= None ,pairsList = None,nAvg = 1): |
|
1357 | def setup(self,dataOut ,lags = None,mode =None, fullBuffer= None ,pairsList = None,nAvg = 1): | |
1358 |
|
1358 | |||
1359 | self.lags = lags |
|
1359 | self.lags = lags | |
1360 | self.mode = mode |
|
1360 | self.mode = mode | |
1361 | self.fullBuffer= fullBuffer |
|
1361 | self.fullBuffer= fullBuffer | |
1362 | self.nAvg = nAvg |
|
1362 | self.nAvg = nAvg | |
1363 | nChannels = dataOut.nChannels |
|
1363 | nChannels = dataOut.nChannels | |
1364 | nProfiles = dataOut.nProfiles |
|
1364 | nProfiles = dataOut.nProfiles | |
1365 | nHeights = dataOut.nHeights |
|
1365 | nHeights = dataOut.nHeights | |
1366 | self.__nProfiles = dataOut.nProfiles |
|
1366 | self.__nProfiles = dataOut.nProfiles | |
1367 | self.__nHeis = dataOut.nHeights |
|
1367 | self.__nHeis = dataOut.nHeights | |
1368 |
|
1368 | |||
1369 | if mode == 'time': |
|
1369 | if mode == 'time': | |
1370 | print "Mode lags equal time for default." |
|
1370 | print "Mode lags equal time for default." | |
1371 | else: |
|
1371 | else: | |
1372 | print "Mode lags equal height." |
|
1372 | print "Mode lags equal height." | |
1373 |
|
1373 | |||
1374 | if pairsList == None: |
|
1374 | if pairsList == None: | |
1375 | print "Pairs list selected by default (1,0)" |
|
1375 | print "Pairs list selected by default (1,0)" | |
1376 | pairsList = [(0,1)] |
|
1376 | pairsList = [(0,1)] | |
1377 | else: |
|
1377 | else: | |
1378 | pairList= pairsList |
|
1378 | pairList= pairsList | |
1379 |
|
1379 | |||
1380 | if lags == None: |
|
1380 | if lags == None: | |
1381 | if mode=='time': |
|
1381 | if mode=='time': | |
1382 | self.lags = numpy.arange(0,nProfiles)# -nProfiles+1, nProfiles |
|
1382 | self.lags = numpy.arange(0,nProfiles)# -nProfiles+1, nProfiles | |
1383 | print "self.lags", len(self.lags) |
|
1383 | print "self.lags", len(self.lags) | |
1384 | if mode=='height': |
|
1384 | if mode=='height': | |
1385 | self.lags = numpy.arange(0,nHeights)# -nHeights+1, nHeights |
|
1385 | self.lags = numpy.arange(0,nHeights)# -nHeights+1, nHeights | |
1386 |
|
1386 | |||
1387 | if fullBuffer: |
|
1387 | if fullBuffer: | |
1388 | self.tmp = numpy.zeros((len(pairsList), len(self.lags), nProfiles, nHeights), dtype = 'complex')*numpy.nan |
|
1388 | self.tmp = numpy.zeros((len(pairsList), len(self.lags), nProfiles, nHeights), dtype = 'complex')*numpy.nan | |
1389 | elif mode =='time': |
|
1389 | elif mode =='time': | |
1390 | self.tmp = numpy.zeros((len(pairsList), len(self.lags), nHeights),dtype='complex') |
|
1390 | self.tmp = numpy.zeros((len(pairsList), len(self.lags), nHeights),dtype='complex') | |
1391 | elif mode =='height': |
|
1391 | elif mode =='height': | |
1392 | self.tmp = numpy.zeros(len(pairsList), (len(self.lags), nProfiles),dtype='complex') |
|
1392 | self.tmp = numpy.zeros(len(pairsList), (len(self.lags), nProfiles),dtype='complex') | |
1393 |
|
1393 | |||
1394 | print "lags", len(self.lags) |
|
1394 | print "lags", len(self.lags) | |
1395 | print "mode",self.mode |
|
1395 | print "mode",self.mode | |
1396 | print "nChannels", nChannels |
|
1396 | print "nChannels", nChannels | |
1397 | print "nProfiles", nProfiles |
|
1397 | print "nProfiles", nProfiles | |
1398 | print "nHeights" , nHeights |
|
1398 | print "nHeights" , nHeights | |
1399 | print "pairsList", pairsList |
|
1399 | print "pairsList", pairsList | |
1400 | print "fullBuffer", fullBuffer |
|
1400 | print "fullBuffer", fullBuffer | |
1401 | #print "type(pairsList)",type(pairsList) |
|
1401 | #print "type(pairsList)",type(pairsList) | |
1402 | print "tmp.shape",self.tmp.shape |
|
1402 | print "tmp.shape",self.tmp.shape | |
1403 |
|
1403 | |||
1404 | def run(self, dataOut, lags =None,mode ='time',fullBuffer= False ,pairsList = None,nAvg = 1): |
|
1404 | def run(self, dataOut, lags =None,mode ='time',fullBuffer= False ,pairsList = None,nAvg = 1): | |
1405 |
|
1405 | |||
1406 | dataOut.flagNoData = True |
|
1406 | dataOut.flagNoData = True | |
1407 |
|
1407 | |||
1408 | if not self.isConfig: |
|
1408 | if not self.isConfig: | |
1409 | self.setup(dataOut, lags = lags,mode = mode, fullBuffer= fullBuffer ,pairsList = pairsList,nAvg=nAvg) |
|
1409 | self.setup(dataOut, lags = lags,mode = mode, fullBuffer= fullBuffer ,pairsList = pairsList,nAvg=nAvg) | |
1410 | self.isConfig = True |
|
1410 | self.isConfig = True | |
1411 |
|
1411 | |||
1412 | if dataOut.type == "Voltage": |
|
1412 | if dataOut.type == "Voltage": | |
1413 |
|
1413 | |||
1414 | data_pre = dataOut.data #data |
|
1414 | data_pre = dataOut.data #data | |
1415 |
|
1415 | |||
1416 |
|
1416 | |||
1417 | # Here is the loop :D |
|
1417 | # Here is the loop :D | |
1418 | for l in range(len(pairsList)): |
|
1418 | for l in range(len(pairsList)): | |
1419 | ch0 = pairsList[l][0] |
|
1419 | ch0 = pairsList[l][0] | |
1420 | ch1 = pairsList[l][1] |
|
1420 | ch1 = pairsList[l][1] | |
1421 |
|
1421 | |||
1422 | for i in range(len(self.lags)): |
|
1422 | for i in range(len(self.lags)): | |
1423 | idx = self.lags[i] |
|
1423 | idx = self.lags[i] | |
1424 | if self.mode == 'time': |
|
1424 | if self.mode == 'time': | |
1425 | acf0 = data_pre[ch0,:self.__nProfiles-idx,:]*numpy.conj(data_pre[ch1,idx:,:]) # pair,lag,height |
|
1425 | acf0 = data_pre[ch0,:self.__nProfiles-idx,:]*numpy.conj(data_pre[ch1,idx:,:]) # pair,lag,height | |
1426 | else: |
|
1426 | else: | |
1427 | acf0 = data_pre[ch0,:,:self.__nHeights-idx]*numpy.conj(data_pre[ch1,:,idx:]) # pair,lag,profile |
|
1427 | acf0 = data_pre[ch0,:,:self.__nHeights-idx]*numpy.conj(data_pre[ch1,:,idx:]) # pair,lag,profile | |
1428 |
|
1428 | |||
1429 | if self.fullBuffer: |
|
1429 | if self.fullBuffer: | |
1430 | self.tmp[l,i,:acf0.shape[0],:]= acf0 |
|
1430 | self.tmp[l,i,:acf0.shape[0],:]= acf0 | |
1431 | else: |
|
1431 | else: | |
1432 | self.tmp[l,i,:]= numpy.sum(acf0,axis=0) |
|
1432 | self.tmp[l,i,:]= numpy.sum(acf0,axis=0) | |
1433 |
|
1433 | |||
1434 | if self.fullBuffer: |
|
1434 | if self.fullBuffer: | |
1435 |
|
1435 | |||
1436 | self.tmp = numpy.sum(numpy.reshape(self.tmp,(self.tmp.shape[0],self.tmp.shape[1],self.tmp.shape[2]/self.nAvg,self.nAvg,self.tmp.shape[3])),axis=3) |
|
1436 | self.tmp = numpy.sum(numpy.reshape(self.tmp,(self.tmp.shape[0],self.tmp.shape[1],self.tmp.shape[2]/self.nAvg,self.nAvg,self.tmp.shape[3])),axis=3) | |
1437 | dataOut.nAvg = self.nAvg |
|
1437 | dataOut.nAvg = self.nAvg | |
1438 |
|
1438 | |||
1439 | if self.mode == 'time': |
|
1439 | if self.mode == 'time': | |
1440 | delta = dataOut.ippSeconds*dataOut.nCohInt |
|
1440 | delta = dataOut.ippSeconds*dataOut.nCohInt | |
1441 | else: |
|
1441 | else: | |
1442 | delta = dataOut.heightList[1] - dataOut.heightList[0] |
|
1442 | delta = dataOut.heightList[1] - dataOut.heightList[0] | |
1443 |
|
1443 | |||
1444 | shape= self.tmp.shape # mode time |
|
1444 | shape= self.tmp.shape # mode time | |
1445 | # Normalizando |
|
1445 | # Normalizando | |
1446 | for i in range(len(pairsList)): |
|
1446 | for i in range(len(pairsList)): | |
1447 | for j in range(shape[2]): |
|
1447 | for j in range(shape[2]): | |
1448 | self.tmp[i,:,j]= self.tmp[i,:,j].real / numpy.max(numpy.abs(self.tmp[i,:,j])) |
|
1448 | self.tmp[i,:,j]= self.tmp[i,:,j].real / numpy.max(numpy.abs(self.tmp[i,:,j])) | |
1449 |
|
1449 | |||
1450 |
|
1450 | |||
1451 | #import matplotlib.pyplot as plt |
|
1451 | #import matplotlib.pyplot as plt | |
1452 | #print "test",self.tmp.shape |
|
1452 | #print "test",self.tmp.shape | |
1453 | #print self.tmp[0,0,0] |
|
1453 | #print self.tmp[0,0,0] | |
1454 | #print numpy.max(numpy.abs(self.tmp[0,:,0])) |
|
1454 | #print numpy.max(numpy.abs(self.tmp[0,:,0])) | |
1455 | #acf_tmp=self.tmp[0,:,100].real/numpy.max(numpy.abs(self.tmp[0,:,100])) |
|
1455 | #acf_tmp=self.tmp[0,:,100].real/numpy.max(numpy.abs(self.tmp[0,:,100])) | |
1456 | #print acf_tmp |
|
1456 | #print acf_tmp | |
1457 | #plt.plot(acf_tmp) |
|
1457 | #plt.plot(acf_tmp) | |
1458 | #plt.show() |
|
1458 | #plt.show() | |
1459 | #import time |
|
1459 | #import time | |
1460 | #time.sleep(20) |
|
1460 | #time.sleep(20) | |
1461 |
|
1461 | |||
1462 | dataOut.data = self.tmp |
|
1462 | dataOut.data = self.tmp | |
1463 | dataOut.mode = self.mode |
|
1463 | dataOut.mode = self.mode | |
1464 | dataOut.nLags = len(self.lags) |
|
1464 | dataOut.nLags = len(self.lags) | |
|
1465 | dataOut.nProfiles = len(self.lags) | |||
1465 | dataOut.pairsList = pairsList |
|
1466 | dataOut.pairsList = pairsList | |
1466 | dataOut.nPairs = len(pairsList) |
|
1467 | dataOut.nPairs = len(pairsList) | |
1467 | dataOut.lagRange = numpy.array(self.lags)*delta |
|
1468 | dataOut.lagRange = numpy.array(self.lags)*delta | |
1468 | dataOut.flagDataAsBlock = True |
|
1469 | dataOut.flagDataAsBlock = True | |
1469 | dataOut.flagNoData = False |
|
1470 | dataOut.flagNoData = False | |
1470 |
|
1471 | |||
1471 | import time |
|
1472 | import time | |
1472 | ################################################# |
|
1473 | ################################################# | |
1473 |
|
1474 | |||
1474 | class decoPseudorandom(Operation): |
|
1475 | class decoPseudorandom(Operation): | |
1475 |
|
1476 | |||
1476 | nProfiles= 0 |
|
1477 | nProfiles= 0 | |
1477 | buffer= None |
|
1478 | buffer= None | |
1478 | isConfig = False |
|
1479 | isConfig = False | |
1479 |
|
1480 | |||
1480 | def setup(self, clen= 10000,seed= 0,Nranges= 1000,oversample=1): |
|
1481 | def setup(self, clen= 10000,seed= 0,Nranges= 1000,oversample=1): | |
1481 | #code = create_pseudo_random_code(clen=clen, seed=seed) |
|
1482 | #code = create_pseudo_random_code(clen=clen, seed=seed) | |
1482 | code= rep_seq(create_pseudo_random_code(clen=clen, seed=seed),rep=oversample) |
|
1483 | code= rep_seq(create_pseudo_random_code(clen=clen, seed=seed),rep=oversample) | |
1483 | #print ("code_rx", code.shape) |
|
1484 | #print ("code_rx", code.shape) | |
1484 | #N = int(an_len/clen) # 100 |
|
1485 | #N = int(an_len/clen) # 100 | |
1485 | B_cache = 0 |
|
1486 | B_cache = 0 | |
1486 | r_cache = 0 |
|
1487 | r_cache = 0 | |
1487 | B_cached = False |
|
1488 | B_cached = False | |
1488 | r = create_estimation_matrix(code=code, cache=True, rmax=Nranges) |
|
1489 | r = create_estimation_matrix(code=code, cache=True, rmax=Nranges) | |
1489 | #print ("code shape", code.shape) |
|
1490 | #print ("code shape", code.shape) | |
1490 | #print ("seed",seed) |
|
1491 | #print ("seed",seed) | |
1491 | #print ("Code", code[0:10]) |
|
1492 | #print ("Code", code[0:10]) | |
1492 | self.B = r['B'] |
|
1493 | self.B = r['B'] | |
1493 |
|
1494 | |||
1494 |
|
1495 | |||
1495 | def run (self,dataOut,length_code= 10000,seed= 0,Nranges= 1000,oversample=1): |
|
1496 | def run (self,dataOut,length_code= 10000,seed= 0,Nranges= 1000,oversample=1): | |
1496 | #print((dataOut.data.shape)) |
|
1497 | #print((dataOut.data.shape)) | |
1497 | if not self.isConfig: |
|
1498 | if not self.isConfig: | |
1498 | self.setup(clen= length_code,seed= seed,Nranges= Nranges,oversample=oversample) |
|
1499 | self.setup(clen= length_code,seed= seed,Nranges= Nranges,oversample=oversample) | |
1499 | self.isConfig = True |
|
1500 | self.isConfig = True | |
1500 |
|
1501 | |||
1501 | dataOut.flagNoData = True |
|
1502 | dataOut.flagNoData = True | |
1502 | data =dataOut.data |
|
1503 | data =dataOut.data | |
1503 | #print "length_CODE",length_code |
|
1504 | #print "length_CODE",length_code | |
1504 | data_shape = (data.shape[1]) |
|
1505 | data_shape = (data.shape[1]) | |
1505 | #print "data_shape",data_shape |
|
1506 | #print "data_shape",data_shape | |
1506 | n = (length_code /data_shape) |
|
1507 | n = (length_code /data_shape) | |
1507 | #print "we need this number of sample",n |
|
1508 | #print "we need this number of sample",n | |
1508 |
|
1509 | |||
1509 | if n>0 and self.buffer is None: |
|
1510 | if n>0 and self.buffer is None: | |
1510 | self.buffer = numpy.zeros([1, length_code], dtype=numpy.complex64) |
|
1511 | self.buffer = numpy.zeros([1, length_code], dtype=numpy.complex64) | |
1511 | self.buffer[0][0:data_shape] = data[0] |
|
1512 | self.buffer[0][0:data_shape] = data[0] | |
1512 | #print "FIRST CREATION",self.buffer.shape |
|
1513 | #print "FIRST CREATION",self.buffer.shape | |
1513 |
|
1514 | |||
1514 | else: |
|
1515 | else: | |
1515 | self.buffer[0][self.nProfiles*data_shape:(self.nProfiles+1)*data_shape]=data[0] |
|
1516 | self.buffer[0][self.nProfiles*data_shape:(self.nProfiles+1)*data_shape]=data[0] | |
1516 |
|
1517 | |||
1517 | #print "buffer_shape",(self.buffer.shape) |
|
1518 | #print "buffer_shape",(self.buffer.shape) | |
1518 | self.nProfiles += 1 |
|
1519 | self.nProfiles += 1 | |
1519 | #print "count",self.nProfiles |
|
1520 | #print "count",self.nProfiles | |
1520 |
|
1521 | |||
1521 | if self.nProfiles== n: |
|
1522 | if self.nProfiles== n: | |
1522 | temporal = numpy.dot(self.B, numpy.transpose(self.buffer)) |
|
1523 | temporal = numpy.dot(self.B, numpy.transpose(self.buffer)) | |
1523 | #print temporal.shape |
|
1524 | #print temporal.shape | |
1524 | #import time |
|
1525 | #import time | |
1525 | #time.sleep(40) |
|
1526 | #time.sleep(40) | |
1526 | dataOut.data=numpy.transpose(temporal) |
|
1527 | dataOut.data=numpy.transpose(temporal) | |
1527 |
|
1528 | |||
1528 | dataOut.flagNoData = False |
|
1529 | dataOut.flagNoData = False | |
1529 | self.buffer= None |
|
1530 | self.buffer= None | |
1530 | self.nProfiles = 0 |
|
1531 | self.nProfiles = 0 | |
1531 |
|
1532 | |||
1532 | # import collections |
|
1533 | # import collections | |
1533 | # from scipy.stats import mode |
|
1534 | # from scipy.stats import mode | |
1534 | # |
|
1535 | # | |
1535 | # class Synchronize(Operation): |
|
1536 | # class Synchronize(Operation): | |
1536 | # |
|
1537 | # | |
1537 | # isConfig = False |
|
1538 | # isConfig = False | |
1538 | # __profIndex = 0 |
|
1539 | # __profIndex = 0 | |
1539 | # |
|
1540 | # | |
1540 | # def __init__(self, **kwargs): |
|
1541 | # def __init__(self, **kwargs): | |
1541 | # |
|
1542 | # | |
1542 | # Operation.__init__(self, **kwargs) |
|
1543 | # Operation.__init__(self, **kwargs) | |
1543 | # # self.isConfig = False |
|
1544 | # # self.isConfig = False | |
1544 | # self.__powBuffer = None |
|
1545 | # self.__powBuffer = None | |
1545 | # self.__startIndex = 0 |
|
1546 | # self.__startIndex = 0 | |
1546 | # self.__pulseFound = False |
|
1547 | # self.__pulseFound = False | |
1547 | # |
|
1548 | # | |
1548 | # def __findTxPulse(self, dataOut, channel=0, pulse_with = None): |
|
1549 | # def __findTxPulse(self, dataOut, channel=0, pulse_with = None): | |
1549 | # |
|
1550 | # | |
1550 | # #Read data |
|
1551 | # #Read data | |
1551 | # |
|
1552 | # | |
1552 | # powerdB = dataOut.getPower(channel = channel) |
|
1553 | # powerdB = dataOut.getPower(channel = channel) | |
1553 | # noisedB = dataOut.getNoise(channel = channel)[0] |
|
1554 | # noisedB = dataOut.getNoise(channel = channel)[0] | |
1554 | # |
|
1555 | # | |
1555 | # self.__powBuffer.extend(powerdB.flatten()) |
|
1556 | # self.__powBuffer.extend(powerdB.flatten()) | |
1556 | # |
|
1557 | # | |
1557 | # dataArray = numpy.array(self.__powBuffer) |
|
1558 | # dataArray = numpy.array(self.__powBuffer) | |
1558 | # |
|
1559 | # | |
1559 | # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same") |
|
1560 | # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same") | |
1560 | # |
|
1561 | # | |
1561 | # maxValue = numpy.nanmax(filteredPower) |
|
1562 | # maxValue = numpy.nanmax(filteredPower) | |
1562 | # |
|
1563 | # | |
1563 | # if maxValue < noisedB + 10: |
|
1564 | # if maxValue < noisedB + 10: | |
1564 | # #No se encuentra ningun pulso de transmision |
|
1565 | # #No se encuentra ningun pulso de transmision | |
1565 | # return None |
|
1566 | # return None | |
1566 | # |
|
1567 | # | |
1567 | # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0] |
|
1568 | # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0] | |
1568 | # |
|
1569 | # | |
1569 | # if len(maxValuesIndex) < 2: |
|
1570 | # if len(maxValuesIndex) < 2: | |
1570 | # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX |
|
1571 | # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX | |
1571 | # return None |
|
1572 | # return None | |
1572 | # |
|
1573 | # | |
1573 | # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples |
|
1574 | # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples | |
1574 | # |
|
1575 | # | |
1575 | # #Seleccionar solo valores con un espaciamiento de nSamples |
|
1576 | # #Seleccionar solo valores con un espaciamiento de nSamples | |
1576 | # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex) |
|
1577 | # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex) | |
1577 | # |
|
1578 | # | |
1578 | # if len(pulseIndex) < 2: |
|
1579 | # if len(pulseIndex) < 2: | |
1579 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 |
|
1580 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 | |
1580 | # return None |
|
1581 | # return None | |
1581 | # |
|
1582 | # | |
1582 | # spacing = pulseIndex[1:] - pulseIndex[:-1] |
|
1583 | # spacing = pulseIndex[1:] - pulseIndex[:-1] | |
1583 | # |
|
1584 | # | |
1584 | # #remover senales que se distancien menos de 10 unidades o muestras |
|
1585 | # #remover senales que se distancien menos de 10 unidades o muestras | |
1585 | # #(No deberian existir IPP menor a 10 unidades) |
|
1586 | # #(No deberian existir IPP menor a 10 unidades) | |
1586 | # |
|
1587 | # | |
1587 | # realIndex = numpy.where(spacing > 10 )[0] |
|
1588 | # realIndex = numpy.where(spacing > 10 )[0] | |
1588 | # |
|
1589 | # | |
1589 | # if len(realIndex) < 2: |
|
1590 | # if len(realIndex) < 2: | |
1590 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 |
|
1591 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 | |
1591 | # return None |
|
1592 | # return None | |
1592 | # |
|
1593 | # | |
1593 | # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs) |
|
1594 | # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs) | |
1594 | # realPulseIndex = pulseIndex[realIndex] |
|
1595 | # realPulseIndex = pulseIndex[realIndex] | |
1595 | # |
|
1596 | # | |
1596 | # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0] |
|
1597 | # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0] | |
1597 | # |
|
1598 | # | |
1598 | # print "IPP = %d samples" %period |
|
1599 | # print "IPP = %d samples" %period | |
1599 | # |
|
1600 | # | |
1600 | # self.__newNSamples = dataOut.nHeights #int(period) |
|
1601 | # self.__newNSamples = dataOut.nHeights #int(period) | |
1601 | # self.__startIndex = int(realPulseIndex[0]) |
|
1602 | # self.__startIndex = int(realPulseIndex[0]) | |
1602 | # |
|
1603 | # | |
1603 | # return 1 |
|
1604 | # return 1 | |
1604 | # |
|
1605 | # | |
1605 | # |
|
1606 | # | |
1606 | # def setup(self, nSamples, nChannels, buffer_size = 4): |
|
1607 | # def setup(self, nSamples, nChannels, buffer_size = 4): | |
1607 | # |
|
1608 | # | |
1608 | # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float), |
|
1609 | # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float), | |
1609 | # maxlen = buffer_size*nSamples) |
|
1610 | # maxlen = buffer_size*nSamples) | |
1610 | # |
|
1611 | # | |
1611 | # bufferList = [] |
|
1612 | # bufferList = [] | |
1612 | # |
|
1613 | # | |
1613 | # for i in range(nChannels): |
|
1614 | # for i in range(nChannels): | |
1614 | # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN, |
|
1615 | # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN, | |
1615 | # maxlen = buffer_size*nSamples) |
|
1616 | # maxlen = buffer_size*nSamples) | |
1616 | # |
|
1617 | # | |
1617 | # bufferList.append(bufferByChannel) |
|
1618 | # bufferList.append(bufferByChannel) | |
1618 | # |
|
1619 | # | |
1619 | # self.__nSamples = nSamples |
|
1620 | # self.__nSamples = nSamples | |
1620 | # self.__nChannels = nChannels |
|
1621 | # self.__nChannels = nChannels | |
1621 | # self.__bufferList = bufferList |
|
1622 | # self.__bufferList = bufferList | |
1622 | # |
|
1623 | # | |
1623 | # def run(self, dataOut, channel = 0): |
|
1624 | # def run(self, dataOut, channel = 0): | |
1624 | # |
|
1625 | # | |
1625 | # if not self.isConfig: |
|
1626 | # if not self.isConfig: | |
1626 | # nSamples = dataOut.nHeights |
|
1627 | # nSamples = dataOut.nHeights | |
1627 | # nChannels = dataOut.nChannels |
|
1628 | # nChannels = dataOut.nChannels | |
1628 | # self.setup(nSamples, nChannels) |
|
1629 | # self.setup(nSamples, nChannels) | |
1629 | # self.isConfig = True |
|
1630 | # self.isConfig = True | |
1630 | # |
|
1631 | # | |
1631 | # #Append new data to internal buffer |
|
1632 | # #Append new data to internal buffer | |
1632 | # for thisChannel in range(self.__nChannels): |
|
1633 | # for thisChannel in range(self.__nChannels): | |
1633 | # bufferByChannel = self.__bufferList[thisChannel] |
|
1634 | # bufferByChannel = self.__bufferList[thisChannel] | |
1634 | # bufferByChannel.extend(dataOut.data[thisChannel]) |
|
1635 | # bufferByChannel.extend(dataOut.data[thisChannel]) | |
1635 | # |
|
1636 | # | |
1636 | # if self.__pulseFound: |
|
1637 | # if self.__pulseFound: | |
1637 | # self.__startIndex -= self.__nSamples |
|
1638 | # self.__startIndex -= self.__nSamples | |
1638 | # |
|
1639 | # | |
1639 | # #Finding Tx Pulse |
|
1640 | # #Finding Tx Pulse | |
1640 | # if not self.__pulseFound: |
|
1641 | # if not self.__pulseFound: | |
1641 | # indexFound = self.__findTxPulse(dataOut, channel) |
|
1642 | # indexFound = self.__findTxPulse(dataOut, channel) | |
1642 | # |
|
1643 | # | |
1643 | # if indexFound == None: |
|
1644 | # if indexFound == None: | |
1644 | # dataOut.flagNoData = True |
|
1645 | # dataOut.flagNoData = True | |
1645 | # return |
|
1646 | # return | |
1646 | # |
|
1647 | # | |
1647 | # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex) |
|
1648 | # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex) | |
1648 | # self.__pulseFound = True |
|
1649 | # self.__pulseFound = True | |
1649 | # self.__startIndex = indexFound |
|
1650 | # self.__startIndex = indexFound | |
1650 | # |
|
1651 | # | |
1651 | # #If pulse was found ... |
|
1652 | # #If pulse was found ... | |
1652 | # for thisChannel in range(self.__nChannels): |
|
1653 | # for thisChannel in range(self.__nChannels): | |
1653 | # bufferByChannel = self.__bufferList[thisChannel] |
|
1654 | # bufferByChannel = self.__bufferList[thisChannel] | |
1654 | # #print self.__startIndex |
|
1655 | # #print self.__startIndex | |
1655 | # x = numpy.array(bufferByChannel) |
|
1656 | # x = numpy.array(bufferByChannel) | |
1656 | # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples] |
|
1657 | # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples] | |
1657 | # |
|
1658 | # | |
1658 | # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1659 | # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1659 | # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight |
|
1660 | # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight | |
1660 | # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6 |
|
1661 | # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6 | |
1661 | # |
|
1662 | # | |
1662 | # dataOut.data = self.__arrayBuffer |
|
1663 | # dataOut.data = self.__arrayBuffer | |
1663 | # |
|
1664 | # | |
1664 | # self.__startIndex += self.__newNSamples |
|
1665 | # self.__startIndex += self.__newNSamples | |
1665 | # |
|
1666 | # | |
1666 | # return |
|
1667 | # return |
@@ -1,145 +1,145 | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | ''' |
|
2 | ''' | |
3 | Created on Jul 7, 2014 |
|
3 | Created on Jul 7, 2014 | |
4 |
|
4 | |||
5 | @author: roj-idl71 |
|
5 | @author: roj-idl71 | |
6 | ''' |
|
6 | ''' | |
7 | import os, sys |
|
7 | import os, sys | |
8 |
|
8 | |||
9 | #path = os.path.dirname(os.getcwd()) |
|
9 | #path = os.path.dirname(os.getcwd()) | |
10 | #path = os.path.join(path, 'source') |
|
10 | #path = os.path.join(path, 'source') | |
11 | #sys.path.insert(0, path) |
|
11 | #sys.path.insert(0, path) | |
12 |
|
12 | |||
13 | from schainpy.controller import Project |
|
13 | from schainpy.controller import Project | |
14 |
|
14 | |||
15 | if __name__ == '__main__': |
|
15 | if __name__ == '__main__': | |
16 |
|
16 | |||
17 | desc = "High altitude experiment SHORT " |
|
17 | desc = "High altitude experiment SHORT " | |
18 | filename = "schain.xml" |
|
18 | filename = "schain.xml" | |
19 |
dpath = '/ |
|
19 | dpath = '/media/soporte/APOLLO/hybrid'#'/home/soporte/test_avp' | |
20 | figpath = "/home/soporte/pics" |
|
20 | figpath = "/home/soporte/pics" | |
21 | remotefolder = "/home/wmaster/graficos" |
|
21 | remotefolder = "/home/wmaster/graficos" | |
22 | t=['0','24'] |
|
22 | t=['0','24'] | |
23 | db_range=['15','35'] |
|
23 | db_range=['15','35'] | |
24 | db_range=['25','45'] |
|
24 | db_range=['25','45'] | |
25 | db_range=['0','35'] |
|
25 | db_range=['0','35'] | |
26 | period=60 |
|
26 | period=60 | |
27 |
|
27 | |||
28 | controllerObj = Project() |
|
28 | controllerObj = Project() | |
29 |
|
29 | |||
30 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
30 | controllerObj.setup(id = '191', name='test01', description=desc) | |
31 |
|
31 | |||
32 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', |
|
32 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |
33 | path=dpath, |
|
33 | path=dpath, | |
34 |
startDate='2019/10/1 |
|
34 | startDate='2019/10/16', | |
35 | # startDate='2018/06/18', |
|
35 | # startDate='2018/06/18', | |
36 |
endDate='2019/10/1 |
|
36 | endDate='2019/10/16', | |
37 | # endDate='2018/06/18', |
|
37 | # endDate='2018/06/18', | |
38 |
startTime=' |
|
38 | startTime='00:00:00', | |
39 | endTime='23:59:59', |
|
39 | endTime='23:59:59', | |
40 | online=0, |
|
40 | online=0, | |
41 | walk=0, |
|
41 | walk=0, | |
42 | expLabel='', |
|
42 | expLabel='', | |
43 | delay=20) |
|
43 | delay=20) | |
44 |
|
44 | |||
45 |
|
45 | |||
46 | opObj00 = readUnitConfObj.addOperation(name='printInfo') |
|
46 | opObj00 = readUnitConfObj.addOperation(name='printInfo') | |
47 | opObj00 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
47 | opObj00 = readUnitConfObj.addOperation(name='printNumberOfBlock') | |
48 |
|
48 | |||
49 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
49 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
50 |
|
50 | |||
51 | opObj11 = procUnitConfObj1.addOperation(name='ProfileSelector', optype='other') |
|
51 | opObj11 = procUnitConfObj1.addOperation(name='ProfileSelector', optype='other') | |
52 | #opObj11.addParameter(name='profileList', value='(0, 1, 2, 3, 20, 21, 22, 23, 40, 41, 42, 43, 60, 61, 62, 63, 80, 81, 82, 83)', format='intlist') |
|
52 | #opObj11.addParameter(name='profileList', value='(0, 1, 2, 3, 20, 21, 22, 23, 40, 41, 42, 43, 60, 61, 62, 63, 80, 81, 82, 83)', format='intlist') | |
53 | opObj11.addParameter(name='rangeList', value='(0,127)', format='intlist') # (0,63),(127,149) |
|
53 | opObj11.addParameter(name='rangeList', value='(0,127)', format='intlist') # (0,63),(127,149) | |
54 |
|
54 | |||
55 | opObj11 = procUnitConfObj1.addOperation(name='selectHeights') |
|
55 | opObj11 = procUnitConfObj1.addOperation(name='selectHeights') | |
56 | opObj11.addParameter(name='minHei', value='0', format='int') |
|
56 | opObj11.addParameter(name='minHei', value='0', format='int') | |
57 | opObj11.addParameter(name='maxHei', value='3000', format='int') |
|
57 | opObj11.addParameter(name='maxHei', value='3000', format='int') | |
58 |
|
58 | |||
59 |
|
59 | |||
60 | #opObj11 = procUnitConfObj1.addOperation(name='filterByHeights') |
|
60 | #opObj11 = procUnitConfObj1.addOperation(name='filterByHeights') | |
61 | #opObj11.addParameter(name='window', value='4', format='int') |
|
61 | #opObj11.addParameter(name='window', value='4', format='int') | |
62 |
|
62 | |||
63 | # opObj11 = procUnitConfObj1.addOperation(name='deFlip') |
|
63 | # opObj11 = procUnitConfObj1.addOperation(name='deFlip') | |
64 | # opObj11.addParameter(name='channelList', value='1,3,5,7', format='intlist') |
|
64 | # opObj11.addParameter(name='channelList', value='1,3,5,7', format='intlist') | |
65 |
|
65 | |||
66 | opObj11 = procUnitConfObj1.addOperation(name='SSheightProfiles', optype='other') |
|
66 | opObj11 = procUnitConfObj1.addOperation(name='SSheightProfiles', optype='other') | |
67 | opObj11.addParameter(name='step', value='1', format='int') |
|
67 | opObj11.addParameter(name='step', value='1', format='int') | |
68 | opObj11.addParameter(name='nsamples', value='64', format='int') |
|
68 | opObj11.addParameter(name='nsamples', value='64', format='int') | |
69 |
|
69 | |||
70 |
|
70 | |||
71 | procUnitConfObj1SPC = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) |
|
71 | procUnitConfObj1SPC = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) | |
72 | procUnitConfObj1SPC.addParameter(name='nFFTPoints', value='128', format='int') |
|
72 | procUnitConfObj1SPC.addParameter(name='nFFTPoints', value='128', format='int') | |
73 | procUnitConfObj1SPC.addParameter(name='nProfiles', value='64', format='int') |
|
73 | procUnitConfObj1SPC.addParameter(name='nProfiles', value='64', format='int') | |
74 | # procUnitConfObj1SPC.addParameter(name='pairsList', value='(1,0),(3,2),(5,4),(7,6)', format='pairsList') |
|
74 | # procUnitConfObj1SPC.addParameter(name='pairsList', value='(1,0),(3,2),(5,4),(7,6)', format='pairsList') | |
75 |
|
75 | |||
76 | opObj11 = procUnitConfObj1SPC.addOperation(name='IncohInt', optype='other') |
|
76 | opObj11 = procUnitConfObj1SPC.addOperation(name='IncohInt', optype='other') | |
77 | opObj11.addParameter(name='timeInterval', value='10', format='int') |
|
77 | opObj11.addParameter(name='timeInterval', value='10', format='int') | |
78 |
|
78 | |||
79 | procUnitConfObj2SPC = controllerObj.addProcUnit(datatype='SpectraAFCProc', inputId=procUnitConfObj1SPC.getId()) |
|
79 | procUnitConfObj2SPC = controllerObj.addProcUnit(datatype='SpectraAFCProc', inputId=procUnitConfObj1SPC.getId()) | |
80 | procUnitConfObj2SPC.addParameter(name='real', value='1', format='int') |
|
80 | procUnitConfObj2SPC.addParameter(name='real', value='1', format='int') | |
81 |
|
81 | |||
82 | opObj11 = procUnitConfObj1SPC.addOperation(name='SpectraPlot', optype='other') |
|
82 | opObj11 = procUnitConfObj1SPC.addOperation(name='SpectraPlot', optype='other') | |
83 | opObj11.addParameter(name='id', value='1', format='int') |
|
83 | opObj11.addParameter(name='id', value='1', format='int') | |
84 | opObj11.addParameter(name='wintitle', value='October 2019', format='str') |
|
84 | opObj11.addParameter(name='wintitle', value='October 2019', format='str') | |
85 | #opObj11.addParameter(name='xaxis', value='time', format='str') |
|
85 | #opObj11.addParameter(name='xaxis', value='time', format='str') | |
86 |
|
86 | |||
87 | #opObj11.addParameter(name='zmin', value=db_range[0], format='int') |
|
87 | #opObj11.addParameter(name='zmin', value=db_range[0], format='int') | |
88 | #opObj11.addParameter(name='zmax', value=db_range[1], format='int') |
|
88 | #opObj11.addParameter(name='zmax', value=db_range[1], format='int') | |
89 | #opObj11.addParameter(name='ymin', value='0', format='int') |
|
89 | #opObj11.addParameter(name='ymin', value='0', format='int') | |
90 | #opObj11.addParameter(name='ymax', value='1500', format='int') |
|
90 | #opObj11.addParameter(name='ymax', value='1500', format='int') | |
91 | #opObj11.addParameter(name='xmin', value='-5', format='int') |
|
91 | #opObj11.addParameter(name='xmin', value='-5', format='int') | |
92 | #opObj11.addParameter(name='xmax', value='5', format='int') |
|
92 | #opObj11.addParameter(name='xmax', value='5', format='int') | |
93 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
93 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
94 | opObj11.addParameter(name='save', value='1', format='int') |
|
94 | opObj11.addParameter(name='save', value='1', format='int') | |
95 | opObj11.addParameter(name='figpath', value=figpath) |
|
95 | opObj11.addParameter(name='figpath', value=figpath) | |
96 |
|
96 | |||
97 | opObj11 = procUnitConfObj1SPC.addOperation(name='RTIPlot', optype='other') |
|
97 | opObj11 = procUnitConfObj1SPC.addOperation(name='RTIPlot', optype='other') | |
98 | opObj11.addParameter(name='id', value='2', format='int') |
|
98 | opObj11.addParameter(name='id', value='2', format='int') | |
99 | opObj11.addParameter(name='wintitle', value='October 2019', format='str') |
|
99 | opObj11.addParameter(name='wintitle', value='October 2019', format='str') | |
100 | opObj11.addParameter(name='xmin', value=t[0], format='float') |
|
100 | opObj11.addParameter(name='xmin', value=t[0], format='float') | |
101 | opObj11.addParameter(name='xmax', value=t[1], format='float') |
|
101 | opObj11.addParameter(name='xmax', value=t[1], format='float') | |
102 | #opObj11.addParameter(name='ymin', value='0', format='int') |
|
102 | #opObj11.addParameter(name='ymin', value='0', format='int') | |
103 | #opObj11.addParameter(name='ymax', value='1500', format='int') |
|
103 | #opObj11.addParameter(name='ymax', value='1500', format='int') | |
104 | #opObj11.addParameter(name='zmin', value=db_range[0], format='int') |
|
104 | #opObj11.addParameter(name='zmin', value=db_range[0], format='int') | |
105 | #opObj11.addParameter(name='zmax', value=db_range[1], format='int') |
|
105 | #opObj11.addParameter(name='zmax', value=db_range[1], format='int') | |
106 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
106 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
107 | opObj11.addParameter(name='save', value='1', format='int') |
|
107 | opObj11.addParameter(name='save', value='1', format='int') | |
108 | opObj11.addParameter(name='figpath', value=figpath) |
|
108 | opObj11.addParameter(name='figpath', value=figpath) | |
109 |
|
109 | |||
110 |
|
110 | |||
111 |
|
111 | |||
112 | opObj11 = procUnitConfObj2SPC.addOperation(name='ACFPlot', optype='other') |
|
112 | opObj11 = procUnitConfObj2SPC.addOperation(name='ACFPlot', optype='other') | |
113 | opObj11.addParameter(name='id', value='3', format='int') |
|
113 | opObj11.addParameter(name='id', value='3', format='int') | |
114 | opObj11.addParameter(name='wintitle', value = 'October 2019', format='str') |
|
114 | opObj11.addParameter(name='wintitle', value = 'October 2019', format='str') | |
115 | opObj11.addParameter(name='xaxis', value='time', format='str') |
|
115 | opObj11.addParameter(name='xaxis', value='time', format='str') | |
116 | opObj11.addParameter(name='channel', value='0', format='int') |
|
116 | opObj11.addParameter(name='channel', value='0', format='int') | |
117 | #opObj11.addParameter(name='nSampleList', value='(50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70)', format='intList') |
|
117 | #opObj11.addParameter(name='nSampleList', value='(50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70)', format='intList') | |
118 | opObj11.addParameter(name='resolutionFactor', value='15', format='int') |
|
118 | opObj11.addParameter(name='resolutionFactor', value='15', format='int') | |
119 | #opObj11.addParameter(name='zmin', value=0.5, format='int') |
|
119 | #opObj11.addParameter(name='zmin', value=0.5, format='int') | |
120 | #opObj11.addParameter(name='zmax', value=-0.5, format='int') |
|
120 | #opObj11.addParameter(name='zmax', value=-0.5, format='int') | |
121 | #opObj11.addParameter(name='ymin', value='0', format='int') |
|
121 | #opObj11.addParameter(name='ymin', value='0', format='int') | |
122 | #opObj11.addParameter(name='ymax', value='0.5', format='int') |
|
122 | #opObj11.addParameter(name='ymax', value='0.5', format='int') | |
123 | #opObj11.addParameter(name='xmin', value='-1.2', format='int') |
|
123 | #opObj11.addParameter(name='xmin', value='-1.2', format='int') | |
124 | #opObj11.addParameter(name='xmax', value='1.2', format='int') |
|
124 | #opObj11.addParameter(name='xmax', value='1.2', format='int') | |
125 | opObj11.addParameter(name='show', value='1', format='int') |
|
125 | opObj11.addParameter(name='show', value='1', format='int') | |
126 | opObj11.addParameter(name='save', value='1', format='int') |
|
126 | opObj11.addParameter(name='save', value='1', format='int') | |
127 | opObj11.addParameter(name='figpath', value=figpath) |
|
127 | opObj11.addParameter(name='figpath', value=figpath) | |
128 |
|
128 | |||
129 | ''' |
|
129 | ''' | |
130 | opObj11 = procUnitConfObj1SPC.addOperation(name='Noise', optype='other') |
|
130 | opObj11 = procUnitConfObj1SPC.addOperation(name='Noise', optype='other') | |
131 | opObj11.addParameter(name='id', value='3', format='int') |
|
131 | opObj11.addParameter(name='id', value='3', format='int') | |
132 | opObj11.addParameter(name='wintitle', value='Short Valley August 2019', format='str') |
|
132 | opObj11.addParameter(name='wintitle', value='Short Valley August 2019', format='str') | |
133 | opObj11.addParameter(name='xmin', value=t[0], format='float') |
|
133 | opObj11.addParameter(name='xmin', value=t[0], format='float') | |
134 | opObj11.addParameter(name='xmax', value=t[1], format='float') |
|
134 | opObj11.addParameter(name='xmax', value=t[1], format='float') | |
135 | opObj11.addParameter(name='ymin', value=db_range[0], format='int') |
|
135 | opObj11.addParameter(name='ymin', value=db_range[0], format='int') | |
136 | opObj11.addParameter(name='ymax', value=db_range[1], format='int') |
|
136 | opObj11.addParameter(name='ymax', value=db_range[1], format='int') | |
137 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
137 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
138 | opObj11.addParameter(name='save', value='1', format='int') |
|
138 | opObj11.addParameter(name='save', value='1', format='int') | |
139 | opObj11.addParameter(name='figpath', value=figpath) |
|
139 | opObj11.addParameter(name='figpath', value=figpath) | |
140 |
|
140 | |||
141 |
|
141 | |||
142 | ''' |
|
142 | ''' | |
143 |
|
143 | |||
144 |
|
144 | |||
145 | controllerObj.start() |
|
145 | controllerObj.start() |
General Comments 0
You need to be logged in to leave comments.
Login now