@@ -1,861 +1,876 | |||
|
1 | 1 | ''' |
|
2 | 2 | |
|
3 | 3 | $Author: murco $ |
|
4 | 4 | $Id: JROHeaderIO.py 151 2012-10-31 19:00:51Z murco $ |
|
5 | 5 | ''' |
|
6 | 6 | import sys |
|
7 | 7 | import numpy |
|
8 | 8 | import copy |
|
9 | 9 | import datetime |
|
10 | 10 | import inspect |
|
11 | 11 | |
|
12 | 12 | SPEED_OF_LIGHT = 299792458 |
|
13 | 13 | SPEED_OF_LIGHT = 3e8 |
|
14 | 14 | |
|
15 | 15 | BASIC_STRUCTURE = numpy.dtype([ |
|
16 | 16 | ('nSize','<u4'), |
|
17 | 17 | ('nVersion','<u2'), |
|
18 | 18 | ('nDataBlockId','<u4'), |
|
19 | 19 | ('nUtime','<u4'), |
|
20 | 20 | ('nMilsec','<u2'), |
|
21 | 21 | ('nTimezone','<i2'), |
|
22 | 22 | ('nDstflag','<i2'), |
|
23 | 23 | ('nErrorCount','<u4') |
|
24 | 24 | ]) |
|
25 | 25 | |
|
26 | 26 | SYSTEM_STRUCTURE = numpy.dtype([ |
|
27 | 27 | ('nSize','<u4'), |
|
28 | 28 | ('nNumSamples','<u4'), |
|
29 | 29 | ('nNumProfiles','<u4'), |
|
30 | 30 | ('nNumChannels','<u4'), |
|
31 | 31 | ('nADCResolution','<u4'), |
|
32 | 32 | ('nPCDIOBusWidth','<u4'), |
|
33 | 33 | ]) |
|
34 | 34 | |
|
35 | 35 | RADAR_STRUCTURE = numpy.dtype([ |
|
36 | 36 | ('nSize','<u4'), |
|
37 | 37 | ('nExpType','<u4'), |
|
38 | 38 | ('nNTx','<u4'), |
|
39 | 39 | ('fIpp','<f4'), |
|
40 | 40 | ('fTxA','<f4'), |
|
41 | 41 | ('fTxB','<f4'), |
|
42 | 42 | ('nNumWindows','<u4'), |
|
43 | 43 | ('nNumTaus','<u4'), |
|
44 | 44 | ('nCodeType','<u4'), |
|
45 | 45 | ('nLine6Function','<u4'), |
|
46 | 46 | ('nLine5Function','<u4'), |
|
47 | 47 | ('fClock','<f4'), |
|
48 | 48 | ('nPrePulseBefore','<u4'), |
|
49 | 49 | ('nPrePulseAfter','<u4'), |
|
50 | 50 | ('sRangeIPP','<a20'), |
|
51 | 51 | ('sRangeTxA','<a20'), |
|
52 | 52 | ('sRangeTxB','<a20'), |
|
53 | 53 | ]) |
|
54 | 54 | |
|
55 | 55 | SAMPLING_STRUCTURE = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) |
|
56 | 56 | |
|
57 | 57 | |
|
58 | 58 | PROCESSING_STRUCTURE = numpy.dtype([ |
|
59 | 59 | ('nSize','<u4'), |
|
60 | 60 | ('nDataType','<u4'), |
|
61 | 61 | ('nSizeOfDataBlock','<u4'), |
|
62 | 62 | ('nProfilesperBlock','<u4'), |
|
63 | 63 | ('nDataBlocksperFile','<u4'), |
|
64 | 64 | ('nNumWindows','<u4'), |
|
65 | 65 | ('nProcessFlags','<u4'), |
|
66 | 66 | ('nCoherentIntegrations','<u4'), |
|
67 | 67 | ('nIncoherentIntegrations','<u4'), |
|
68 | 68 | ('nTotalSpectra','<u4') |
|
69 | 69 | ]) |
|
70 | 70 | |
|
71 | 71 | class Header(object): |
|
72 | 72 | |
|
73 | 73 | def __init__(self): |
|
74 | 74 | raise NotImplementedError |
|
75 | 75 | |
|
76 | 76 | def copy(self): |
|
77 | 77 | return copy.deepcopy(self) |
|
78 | 78 | |
|
79 | 79 | def read(self): |
|
80 | 80 | |
|
81 | 81 | raise NotImplementedError |
|
82 | 82 | |
|
83 | 83 | def write(self): |
|
84 | 84 | |
|
85 | 85 | raise NotImplementedError |
|
86 | 86 | |
|
87 | 87 | def getAllowedArgs(self): |
|
88 |
|
|
|
88 | args = inspect.getargspec(self.__init__).args | |
|
89 | try: | |
|
90 | args.remove('self') | |
|
91 | except: | |
|
92 | pass | |
|
93 | return args | |
|
94 | ||
|
95 | def getAsDict(self): | |
|
96 | args = self.getAllowedArgs() | |
|
97 | asDict = {} | |
|
98 | for x in args: | |
|
99 | asDict[x] = self[x] | |
|
100 | return asDict | |
|
89 | 101 | |
|
102 | def __getitem__(self, name): | |
|
103 | return getattr(self, name) | |
|
104 | ||
|
90 | 105 | def printInfo(self): |
|
91 | 106 | |
|
92 | 107 | message = "#"*50 + "\n" |
|
93 | 108 | message += self.__class__.__name__.upper() + "\n" |
|
94 | 109 | message += "#"*50 + "\n" |
|
95 | 110 | |
|
96 | 111 | keyList = self.__dict__.keys() |
|
97 | 112 | keyList.sort() |
|
98 | 113 | |
|
99 | 114 | for key in keyList: |
|
100 | 115 | message += "%s = %s" %(key, self.__dict__[key]) + "\n" |
|
101 | 116 | |
|
102 | 117 | if "size" not in keyList: |
|
103 | 118 | attr = getattr(self, "size") |
|
104 | 119 | |
|
105 | 120 | if attr: |
|
106 | 121 | message += "%s = %s" %("size", attr) + "\n" |
|
107 | 122 | |
|
108 | 123 | print message |
|
109 | 124 | |
|
110 | 125 | class BasicHeader(Header): |
|
111 | 126 | |
|
112 | 127 | size = None |
|
113 | 128 | version = None |
|
114 | 129 | dataBlock = None |
|
115 | 130 | utc = None |
|
116 | 131 | ltc = None |
|
117 | 132 | miliSecond = None |
|
118 | 133 | timeZone = None |
|
119 | 134 | dstFlag = None |
|
120 | 135 | errorCount = None |
|
121 | 136 | datatime = None |
|
122 | 137 | structure = BASIC_STRUCTURE |
|
123 | 138 | __LOCALTIME = None |
|
124 | 139 | |
|
125 | 140 | def __init__(self, useLocalTime=True): |
|
126 | 141 | |
|
127 | 142 | self.size = 24 |
|
128 | 143 | self.version = 0 |
|
129 | 144 | self.dataBlock = 0 |
|
130 | 145 | self.utc = 0 |
|
131 | 146 | self.miliSecond = 0 |
|
132 | 147 | self.timeZone = 0 |
|
133 | 148 | self.dstFlag = 0 |
|
134 | 149 | self.errorCount = 0 |
|
135 | 150 | |
|
136 | 151 | self.useLocalTime = useLocalTime |
|
137 | 152 | |
|
138 | 153 | def read(self, fp): |
|
139 | 154 | |
|
140 | 155 | self.length = 0 |
|
141 | 156 | try: |
|
142 | 157 | if hasattr(fp, 'read'): |
|
143 | 158 | header = numpy.fromfile(fp, BASIC_STRUCTURE,1) |
|
144 | 159 | else: |
|
145 | 160 | header = numpy.fromstring(fp, BASIC_STRUCTURE,1) |
|
146 | 161 | except Exception, e: |
|
147 | 162 | print "BasicHeader: " |
|
148 | 163 | print e |
|
149 | 164 | return 0 |
|
150 | 165 | |
|
151 | 166 | self.size = int(header['nSize'][0]) |
|
152 | 167 | self.version = int(header['nVersion'][0]) |
|
153 | 168 | self.dataBlock = int(header['nDataBlockId'][0]) |
|
154 | 169 | self.utc = int(header['nUtime'][0]) |
|
155 | 170 | self.miliSecond = int(header['nMilsec'][0]) |
|
156 | 171 | self.timeZone = int(header['nTimezone'][0]) |
|
157 | 172 | self.dstFlag = int(header['nDstflag'][0]) |
|
158 | 173 | self.errorCount = int(header['nErrorCount'][0]) |
|
159 | 174 | |
|
160 | 175 | if self.size < 24: |
|
161 | 176 | return 0 |
|
162 | 177 | |
|
163 | 178 | self.length = header.nbytes |
|
164 | 179 | return 1 |
|
165 | 180 | |
|
166 | 181 | def write(self, fp): |
|
167 | 182 | |
|
168 | 183 | headerTuple = (self.size,self.version,self.dataBlock,self.utc,self.miliSecond,self.timeZone,self.dstFlag,self.errorCount) |
|
169 | 184 | header = numpy.array(headerTuple, BASIC_STRUCTURE) |
|
170 | 185 | header.tofile(fp) |
|
171 | 186 | |
|
172 | 187 | return 1 |
|
173 | 188 | |
|
174 | 189 | def get_ltc(self): |
|
175 | 190 | |
|
176 | 191 | return self.utc - self.timeZone*60 |
|
177 | 192 | |
|
178 | 193 | def set_ltc(self, value): |
|
179 | 194 | |
|
180 | 195 | self.utc = value + self.timeZone*60 |
|
181 | 196 | |
|
182 | 197 | def get_datatime(self): |
|
183 | 198 | |
|
184 | 199 | return datetime.datetime.utcfromtimestamp(self.ltc) |
|
185 | 200 | |
|
186 | 201 | ltc = property(get_ltc, set_ltc) |
|
187 | 202 | datatime = property(get_datatime) |
|
188 | 203 | |
|
189 | 204 | class SystemHeader(Header): |
|
190 | 205 | |
|
191 | 206 | size = None |
|
192 | 207 | nSamples = None |
|
193 | 208 | nProfiles = None |
|
194 | 209 | nChannels = None |
|
195 | 210 | adcResolution = None |
|
196 | 211 | pciDioBusWidth = None |
|
197 | 212 | structure = SYSTEM_STRUCTURE |
|
198 | 213 | |
|
199 | def __init__(self, nSamples=0, nProfiles=0, nChannels=0, adcResolution=14, pciDioBusWith=0): | |
|
214 | def __init__(self, nSamples=0, nProfiles=0, nChannels=0, adcResolution=14, pciDioBusWidth=0): | |
|
200 | 215 | |
|
201 | 216 | self.size = 24 |
|
202 | 217 | self.nSamples = nSamples |
|
203 | 218 | self.nProfiles = nProfiles |
|
204 | 219 | self.nChannels = nChannels |
|
205 | 220 | self.adcResolution = adcResolution |
|
206 | self.pciDioBusWidth = pciDioBusWith | |
|
221 | self.pciDioBusWidth = pciDioBusWidth | |
|
207 | 222 | |
|
208 | 223 | def read(self, fp): |
|
209 | 224 | self.length = 0 |
|
210 | 225 | try: |
|
211 | 226 | startFp = fp.tell() |
|
212 | 227 | except Exception, e: |
|
213 | 228 | startFp = None |
|
214 | 229 | pass |
|
215 | 230 | |
|
216 | 231 | try: |
|
217 | 232 | if hasattr(fp, 'read'): |
|
218 | 233 | header = numpy.fromfile(fp, SYSTEM_STRUCTURE,1) |
|
219 | 234 | else: |
|
220 | 235 | header = numpy.fromstring(fp, SYSTEM_STRUCTURE,1) |
|
221 | 236 | except Exception, e: |
|
222 | 237 | print "System Header: " + str(e) |
|
223 | 238 | return 0 |
|
224 | 239 | |
|
225 | 240 | self.size = header['nSize'][0] |
|
226 | 241 | self.nSamples = header['nNumSamples'][0] |
|
227 | 242 | self.nProfiles = header['nNumProfiles'][0] |
|
228 | 243 | self.nChannels = header['nNumChannels'][0] |
|
229 | 244 | self.adcResolution = header['nADCResolution'][0] |
|
230 | 245 | self.pciDioBusWidth = header['nPCDIOBusWidth'][0] |
|
231 | 246 | |
|
232 | 247 | |
|
233 | 248 | if startFp is not None: |
|
234 | 249 | endFp = self.size + startFp |
|
235 | 250 | |
|
236 | 251 | if fp.tell() > endFp: |
|
237 | 252 | sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp.name) |
|
238 | 253 | return 0 |
|
239 | 254 | |
|
240 | 255 | if fp.tell() < endFp: |
|
241 | 256 | sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp.name) |
|
242 | 257 | return 0 |
|
243 | 258 | |
|
244 | 259 | self.length = header.nbytes |
|
245 | 260 | return 1 |
|
246 | 261 | |
|
247 | 262 | def write(self, fp): |
|
248 | 263 | |
|
249 | 264 | headerTuple = (self.size,self.nSamples,self.nProfiles,self.nChannels,self.adcResolution,self.pciDioBusWidth) |
|
250 | 265 | header = numpy.array(headerTuple,SYSTEM_STRUCTURE) |
|
251 | 266 | header.tofile(fp) |
|
252 | 267 | |
|
253 | 268 | return 1 |
|
254 | 269 | |
|
255 | 270 | class RadarControllerHeader(Header): |
|
256 | 271 | |
|
257 | 272 | expType = None |
|
258 | 273 | nTx = None |
|
259 | 274 | ipp = None |
|
260 | 275 | txA = None |
|
261 | 276 | txB = None |
|
262 | 277 | nWindows = None |
|
263 | 278 | numTaus = None |
|
264 | 279 | codeType = None |
|
265 | 280 | line6Function = None |
|
266 | 281 | line5Function = None |
|
267 | 282 | fClock = None |
|
268 | 283 | prePulseBefore = None |
|
269 |
prePulse |
|
|
284 | prePulseAfter = None | |
|
270 | 285 | rangeIpp = None |
|
271 | 286 | rangeTxA = None |
|
272 | 287 | rangeTxB = None |
|
273 | 288 | structure = RADAR_STRUCTURE |
|
274 | 289 | __size = None |
|
275 | 290 | |
|
276 | 291 | def __init__(self, expType=2, nTx=1, |
|
277 |
ipp |
|
|
292 | ipp=None, txA=0, txB=0, | |
|
278 | 293 | nWindows=None, nHeights=None, firstHeight=None, deltaHeight=None, |
|
279 | 294 | numTaus=0, line6Function=0, line5Function=0, fClock=None, |
|
280 | 295 | prePulseBefore=0, prePulseAfter=0, |
|
281 | 296 | codeType=0, nCode=0, nBaud=0, code=None, |
|
282 | 297 | flip1=0, flip2=0): |
|
283 | 298 | |
|
284 | 299 | # self.size = 116 |
|
285 | 300 | self.expType = expType |
|
286 | 301 | self.nTx = nTx |
|
287 |
self.ipp = ipp |
|
|
302 | self.ipp = ipp | |
|
288 | 303 | self.txA = txA |
|
289 | 304 | self.txB = txB |
|
290 |
self.rangeIpp = ipp |
|
|
305 | self.rangeIpp = ipp | |
|
291 | 306 | self.rangeTxA = txA |
|
292 | 307 | self.rangeTxB = txB |
|
293 | 308 | |
|
294 | 309 | self.nWindows = nWindows |
|
295 | 310 | self.numTaus = numTaus |
|
296 | 311 | self.codeType = codeType |
|
297 | 312 | self.line6Function = line6Function |
|
298 | 313 | self.line5Function = line5Function |
|
299 | 314 | self.fClock = fClock |
|
300 | 315 | self.prePulseBefore = prePulseBefore |
|
301 |
self.prePulse |
|
|
316 | self.prePulseAfter = prePulseAfter | |
|
302 | 317 | |
|
303 | 318 | self.nHeights = nHeights |
|
304 | 319 | self.firstHeight = firstHeight |
|
305 | 320 | self.deltaHeight = deltaHeight |
|
306 | 321 | self.samplesWin = nHeights |
|
307 | 322 | |
|
308 | 323 | self.nCode = nCode |
|
309 | 324 | self.nBaud = nBaud |
|
310 | 325 | self.code = code |
|
311 | 326 | self.flip1 = flip1 |
|
312 | 327 | self.flip2 = flip2 |
|
313 | 328 | |
|
314 | 329 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 |
|
315 | 330 | # self.dynamic = numpy.array([],numpy.dtype('byte')) |
|
316 | 331 | |
|
317 | 332 | if self.fClock is None and self.deltaHeight is not None: |
|
318 | 333 | self.fClock = 0.15/(deltaHeight*1e-6) #0.15Km / (height * 1u) |
|
319 | 334 | |
|
320 | 335 | def read(self, fp): |
|
321 | 336 | self.length = 0 |
|
322 | 337 | try: |
|
323 | 338 | startFp = fp.tell() |
|
324 | 339 | except Exception, e: |
|
325 | 340 | startFp = None |
|
326 | 341 | pass |
|
327 | 342 | |
|
328 | 343 | try: |
|
329 | 344 | if hasattr(fp, 'read'): |
|
330 | 345 | header = numpy.fromfile(fp, RADAR_STRUCTURE,1) |
|
331 | 346 | else: |
|
332 | 347 | header = numpy.fromstring(fp, RADAR_STRUCTURE,1) |
|
333 | 348 | self.length += header.nbytes |
|
334 | 349 | except Exception, e: |
|
335 | 350 | print "RadarControllerHeader: " + str(e) |
|
336 | 351 | return 0 |
|
337 | 352 | |
|
338 | 353 | size = int(header['nSize'][0]) |
|
339 | 354 | self.expType = int(header['nExpType'][0]) |
|
340 | 355 | self.nTx = int(header['nNTx'][0]) |
|
341 | 356 | self.ipp = float(header['fIpp'][0]) |
|
342 | 357 | self.txA = float(header['fTxA'][0]) |
|
343 | 358 | self.txB = float(header['fTxB'][0]) |
|
344 | 359 | self.nWindows = int(header['nNumWindows'][0]) |
|
345 | 360 | self.numTaus = int(header['nNumTaus'][0]) |
|
346 | 361 | self.codeType = int(header['nCodeType'][0]) |
|
347 | 362 | self.line6Function = int(header['nLine6Function'][0]) |
|
348 | 363 | self.line5Function = int(header['nLine5Function'][0]) |
|
349 | 364 | self.fClock = float(header['fClock'][0]) |
|
350 | 365 | self.prePulseBefore = int(header['nPrePulseBefore'][0]) |
|
351 |
self.prePulse |
|
|
366 | self.prePulseAfter = int(header['nPrePulseAfter'][0]) | |
|
352 | 367 | self.rangeIpp = header['sRangeIPP'][0] |
|
353 | 368 | self.rangeTxA = header['sRangeTxA'][0] |
|
354 | 369 | self.rangeTxB = header['sRangeTxB'][0] |
|
355 | 370 | |
|
356 | 371 | try: |
|
357 | 372 | if hasattr(fp, 'read'): |
|
358 | 373 | samplingWindow = numpy.fromfile(fp, SAMPLING_STRUCTURE, self.nWindows) |
|
359 | 374 | else: |
|
360 | 375 | samplingWindow = numpy.fromstring(fp[self.length:], SAMPLING_STRUCTURE, self.nWindows) |
|
361 | 376 | self.length += samplingWindow.nbytes |
|
362 | 377 | except Exception, e: |
|
363 | 378 | print "RadarControllerHeader: " + str(e) |
|
364 | 379 | return 0 |
|
365 | 380 | self.nHeights = int(numpy.sum(samplingWindow['nsa'])) |
|
366 | 381 | self.firstHeight = samplingWindow['h0'] |
|
367 | 382 | self.deltaHeight = samplingWindow['dh'] |
|
368 | 383 | self.samplesWin = samplingWindow['nsa'] |
|
369 | 384 | |
|
370 | 385 | |
|
371 | 386 | |
|
372 | 387 | try: |
|
373 | 388 | if hasattr(fp, 'read'): |
|
374 | 389 | self.Taus = numpy.fromfile(fp, '<f4', self.numTaus) |
|
375 | 390 | else: |
|
376 | 391 | self.Taus = numpy.fromstring(fp[self.length:], '<f4', self.numTaus) |
|
377 | 392 | self.length += self.Taus.nbytes |
|
378 | 393 | except Exception, e: |
|
379 | 394 | print "RadarControllerHeader: " + str(e) |
|
380 | 395 | return 0 |
|
381 | 396 | |
|
382 | 397 | |
|
383 | 398 | |
|
384 | 399 | self.code_size = 0 |
|
385 | 400 | if self.codeType != 0: |
|
386 | 401 | |
|
387 | 402 | try: |
|
388 | 403 | if hasattr(fp, 'read'): |
|
389 | 404 | self.nCode = numpy.fromfile(fp, '<u4', 1) |
|
390 | 405 | self.length += self.nCode.nbytes |
|
391 | 406 | self.nBaud = numpy.fromfile(fp, '<u4', 1) |
|
392 | 407 | self.length += self.nBaud.nbytes |
|
393 | 408 | else: |
|
394 | 409 | self.nCode = numpy.fromstring(fp[self.length:], '<u4', 1)[0] |
|
395 | 410 | self.length += self.nCode.nbytes |
|
396 | 411 | self.nBaud = numpy.fromstring(fp[self.length:], '<u4', 1)[0] |
|
397 | 412 | self.length += self.nBaud.nbytes |
|
398 | 413 | except Exception, e: |
|
399 | 414 | print "RadarControllerHeader: " + str(e) |
|
400 | 415 | return 0 |
|
401 | 416 | code = numpy.empty([self.nCode,self.nBaud],dtype='i1') |
|
402 | 417 | |
|
403 | 418 | for ic in range(self.nCode): |
|
404 | 419 | try: |
|
405 | 420 | if hasattr(fp, 'read'): |
|
406 | 421 | temp = numpy.fromfile(fp,'u4', int(numpy.ceil(self.nBaud/32.))) |
|
407 | 422 | else: |
|
408 | 423 | temp = numpy.fromstring(fp,'u4', int(numpy.ceil(self.nBaud/32.))) |
|
409 | 424 | self.length += temp.nbytes |
|
410 | 425 | except Exception, e: |
|
411 | 426 | print "RadarControllerHeader: " + str(e) |
|
412 | 427 | return 0 |
|
413 | 428 | |
|
414 | 429 | for ib in range(self.nBaud-1,-1,-1): |
|
415 | 430 | code[ic,ib] = temp[ib/32]%2 |
|
416 | 431 | temp[ib/32] = temp[ib/32]/2 |
|
417 | 432 | |
|
418 | 433 | self.code = 2.0*code - 1.0 |
|
419 | 434 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 |
|
420 | 435 | |
|
421 | 436 | # if self.line5Function == RCfunction.FLIP: |
|
422 | 437 | # self.flip1 = numpy.fromfile(fp,'<u4',1) |
|
423 | 438 | # |
|
424 | 439 | # if self.line6Function == RCfunction.FLIP: |
|
425 | 440 | # self.flip2 = numpy.fromfile(fp,'<u4',1) |
|
426 | 441 | if startFp is not None: |
|
427 | 442 | endFp = size + startFp |
|
428 | 443 | |
|
429 | 444 | if fp.tell() != endFp: |
|
430 | 445 | # fp.seek(endFp) |
|
431 | 446 | print "%s: Radar Controller Header size is not consistent: from data [%d] != from header field [%d]" %(fp.name, fp.tell()-startFp, size) |
|
432 | 447 | # return 0 |
|
433 | 448 | |
|
434 | 449 | if fp.tell() > endFp: |
|
435 | 450 | sys.stderr.write("Warning %s: Size value read from Radar Controller header is lower than it has to be\n" %fp.name) |
|
436 | 451 | # return 0 |
|
437 | 452 | |
|
438 | 453 | if fp.tell() < endFp: |
|
439 | 454 | sys.stderr.write("Warning %s: Size value read from Radar Controller header is greater than it has to be\n" %fp.name) |
|
440 | 455 | |
|
441 | 456 | |
|
442 | 457 | return 1 |
|
443 | 458 | |
|
444 | 459 | def write(self, fp): |
|
445 | 460 | |
|
446 | 461 | headerTuple = (self.size, |
|
447 | 462 | self.expType, |
|
448 | 463 | self.nTx, |
|
449 | 464 | self.ipp, |
|
450 | 465 | self.txA, |
|
451 | 466 | self.txB, |
|
452 | 467 | self.nWindows, |
|
453 | 468 | self.numTaus, |
|
454 | 469 | self.codeType, |
|
455 | 470 | self.line6Function, |
|
456 | 471 | self.line5Function, |
|
457 | 472 | self.fClock, |
|
458 | 473 | self.prePulseBefore, |
|
459 |
self.prePulse |
|
|
474 | self.prePulseAfter, | |
|
460 | 475 | self.rangeIpp, |
|
461 | 476 | self.rangeTxA, |
|
462 | 477 | self.rangeTxB) |
|
463 | 478 | |
|
464 | 479 | header = numpy.array(headerTuple,RADAR_STRUCTURE) |
|
465 | 480 | header.tofile(fp) |
|
466 | 481 | |
|
467 | 482 | sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) |
|
468 | 483 | samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE) |
|
469 | 484 | samplingWindow.tofile(fp) |
|
470 | 485 | |
|
471 | 486 | if self.numTaus > 0: |
|
472 | 487 | self.Taus.tofile(fp) |
|
473 | 488 | |
|
474 | 489 | if self.codeType !=0: |
|
475 | 490 | nCode = numpy.array(self.nCode, '<u4') |
|
476 | 491 | nCode.tofile(fp) |
|
477 | 492 | nBaud = numpy.array(self.nBaud, '<u4') |
|
478 | 493 | nBaud.tofile(fp) |
|
479 | 494 | code1 = (self.code + 1.0)/2. |
|
480 | 495 | |
|
481 | 496 | for ic in range(self.nCode): |
|
482 | 497 | tempx = numpy.zeros(numpy.ceil(self.nBaud/32.)) |
|
483 | 498 | start = 0 |
|
484 | 499 | end = 32 |
|
485 | 500 | for i in range(len(tempx)): |
|
486 | 501 | code_selected = code1[ic,start:end] |
|
487 | 502 | for j in range(len(code_selected)-1,-1,-1): |
|
488 | 503 | if code_selected[j] == 1: |
|
489 | 504 | tempx[i] = tempx[i] + 2**(len(code_selected)-1-j) |
|
490 | 505 | start = start + 32 |
|
491 | 506 | end = end + 32 |
|
492 | 507 | |
|
493 | 508 | tempx = tempx.astype('u4') |
|
494 | 509 | tempx.tofile(fp) |
|
495 | 510 | |
|
496 | 511 | # if self.line5Function == RCfunction.FLIP: |
|
497 | 512 | # self.flip1.tofile(fp) |
|
498 | 513 | # |
|
499 | 514 | # if self.line6Function == RCfunction.FLIP: |
|
500 | 515 | # self.flip2.tofile(fp) |
|
501 | 516 | |
|
502 | 517 | return 1 |
|
503 | 518 | |
|
504 | 519 | def get_ippSeconds(self): |
|
505 | 520 | ''' |
|
506 | 521 | ''' |
|
507 | 522 | ippSeconds = 2.0 * 1000 * self.ipp / SPEED_OF_LIGHT |
|
508 | 523 | |
|
509 | 524 | return ippSeconds |
|
510 | 525 | |
|
511 | 526 | def set_ippSeconds(self, ippSeconds): |
|
512 | 527 | ''' |
|
513 | 528 | ''' |
|
514 | 529 | |
|
515 | 530 | self.ipp = ippSeconds * SPEED_OF_LIGHT / (2.0*1000) |
|
516 | 531 | |
|
517 | 532 | return |
|
518 | 533 | |
|
519 | 534 | def get_size(self): |
|
520 | 535 | |
|
521 | 536 | self.__size = 116 + 12*self.nWindows + 4*self.numTaus |
|
522 | 537 | |
|
523 | 538 | if self.codeType != 0: |
|
524 | 539 | self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.) |
|
525 | 540 | |
|
526 | 541 | return self.__size |
|
527 | 542 | |
|
528 | 543 | def set_size(self, value): |
|
529 | 544 | |
|
530 | 545 | raise IOError, "size is a property and it cannot be set, just read" |
|
531 | 546 | |
|
532 | 547 | return |
|
533 | 548 | |
|
534 | 549 | ippSeconds = property(get_ippSeconds, set_ippSeconds) |
|
535 | 550 | size = property(get_size, set_size) |
|
536 | 551 | |
|
537 | 552 | class ProcessingHeader(Header): |
|
538 | 553 | |
|
539 | 554 | # size = None |
|
540 | 555 | dtype = None |
|
541 | 556 | blockSize = None |
|
542 | 557 | profilesPerBlock = None |
|
543 | 558 | dataBlocksPerFile = None |
|
544 | 559 | nWindows = None |
|
545 | 560 | processFlags = None |
|
546 | 561 | nCohInt = None |
|
547 | 562 | nIncohInt = None |
|
548 | 563 | totalSpectra = None |
|
549 | 564 | structure = PROCESSING_STRUCTURE |
|
550 | 565 | flag_dc = None |
|
551 | 566 | flag_cspc = None |
|
552 | 567 | |
|
553 | 568 | def __init__(self, dtype=0, blockSize=0, profilesPerBlock=0, dataBlocksPerFile=0, nWindows=0,processFlags=0, nCohInt=0, |
|
554 | 569 | nIncohInt=0, totalSpectra=0, nHeights=0, firstHeight=0, deltaHeight=0, samplesWin=0, spectraComb=0, nCode=0, |
|
555 | 570 | code=0, nBaud=None, shif_fft=False, flag_dc=False, flag_cspc=False, flag_decode=False, flag_deflip=False |
|
556 | 571 | ): |
|
557 | 572 | |
|
558 | 573 | # self.size = 0 |
|
559 | 574 | self.dtype = dtype |
|
560 | 575 | self.blockSize = blockSize |
|
561 | 576 | self.profilesPerBlock = 0 |
|
562 | 577 | self.dataBlocksPerFile = 0 |
|
563 | 578 | self.nWindows = 0 |
|
564 | 579 | self.processFlags = 0 |
|
565 | 580 | self.nCohInt = 0 |
|
566 | 581 | self.nIncohInt = 0 |
|
567 | 582 | self.totalSpectra = 0 |
|
568 | 583 | |
|
569 | 584 | self.nHeights = 0 |
|
570 | 585 | self.firstHeight = 0 |
|
571 | 586 | self.deltaHeight = 0 |
|
572 | 587 | self.samplesWin = 0 |
|
573 | 588 | self.spectraComb = 0 |
|
574 | 589 | self.nCode = None |
|
575 | 590 | self.code = None |
|
576 | 591 | self.nBaud = None |
|
577 | 592 | |
|
578 | 593 | self.shif_fft = False |
|
579 | 594 | self.flag_dc = False |
|
580 | 595 | self.flag_cspc = False |
|
581 | 596 | self.flag_decode = False |
|
582 | 597 | self.flag_deflip = False |
|
583 | 598 | self.length = 0 |
|
584 | 599 | |
|
585 | 600 | def read(self, fp): |
|
586 | 601 | self.length = 0 |
|
587 | 602 | try: |
|
588 | 603 | startFp = fp.tell() |
|
589 | 604 | except Exception, e: |
|
590 | 605 | startFp = None |
|
591 | 606 | pass |
|
592 | 607 | |
|
593 | 608 | try: |
|
594 | 609 | if hasattr(fp, 'read'): |
|
595 | 610 | header = numpy.fromfile(fp, PROCESSING_STRUCTURE, 1) |
|
596 | 611 | else: |
|
597 | 612 | header = numpy.fromstring(fp, PROCESSING_STRUCTURE, 1) |
|
598 | 613 | self.length += header.nbytes |
|
599 | 614 | except Exception, e: |
|
600 | 615 | print "ProcessingHeader: " + str(e) |
|
601 | 616 | return 0 |
|
602 | 617 | |
|
603 | 618 | size = int(header['nSize'][0]) |
|
604 | 619 | self.dtype = int(header['nDataType'][0]) |
|
605 | 620 | self.blockSize = int(header['nSizeOfDataBlock'][0]) |
|
606 | 621 | self.profilesPerBlock = int(header['nProfilesperBlock'][0]) |
|
607 | 622 | self.dataBlocksPerFile = int(header['nDataBlocksperFile'][0]) |
|
608 | 623 | self.nWindows = int(header['nNumWindows'][0]) |
|
609 | 624 | self.processFlags = header['nProcessFlags'] |
|
610 | 625 | self.nCohInt = int(header['nCoherentIntegrations'][0]) |
|
611 | 626 | self.nIncohInt = int(header['nIncoherentIntegrations'][0]) |
|
612 | 627 | self.totalSpectra = int(header['nTotalSpectra'][0]) |
|
613 | 628 | |
|
614 | 629 | try: |
|
615 | 630 | if hasattr(fp, 'read'): |
|
616 | 631 | samplingWindow = numpy.fromfile(fp, SAMPLING_STRUCTURE, self.nWindows) |
|
617 | 632 | else: |
|
618 | 633 | samplingWindow = numpy.fromstring(fp[self.length:], SAMPLING_STRUCTURE, self.nWindows) |
|
619 | 634 | self.length += samplingWindow.nbytes |
|
620 | 635 | except Exception, e: |
|
621 | 636 | print "ProcessingHeader: " + str(e) |
|
622 | 637 | return 0 |
|
623 | 638 | |
|
624 | 639 | self.nHeights = int(numpy.sum(samplingWindow['nsa'])) |
|
625 | 640 | self.firstHeight = float(samplingWindow['h0'][0]) |
|
626 | 641 | self.deltaHeight = float(samplingWindow['dh'][0]) |
|
627 | 642 | self.samplesWin = samplingWindow['nsa'][0] |
|
628 | 643 | |
|
629 | 644 | |
|
630 | 645 | try: |
|
631 | 646 | if hasattr(fp, 'read'): |
|
632 | 647 | self.spectraComb = numpy.fromfile(fp, 'u1', 2*self.totalSpectra) |
|
633 | 648 | else: |
|
634 | 649 | self.spectraComb = numpy.fromstring(fp[self.length:], 'u1', 2*self.totalSpectra) |
|
635 | 650 | self.length += self.spectraComb.nbytes |
|
636 | 651 | except Exception, e: |
|
637 | 652 | print "ProcessingHeader: " + str(e) |
|
638 | 653 | return 0 |
|
639 | 654 | |
|
640 | 655 | if ((self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE) == PROCFLAG.DEFINE_PROCESS_CODE): |
|
641 | 656 | self.nCode = int(numpy.fromfile(fp,'<u4',1)) |
|
642 | 657 | self.nBaud = int(numpy.fromfile(fp,'<u4',1)) |
|
643 | 658 | self.code = numpy.fromfile(fp,'<f4',self.nCode*self.nBaud).reshape(self.nCode,self.nBaud) |
|
644 | 659 | |
|
645 | 660 | if ((self.processFlags & PROCFLAG.EXP_NAME_ESP) == PROCFLAG.EXP_NAME_ESP): |
|
646 | 661 | exp_name_len = int(numpy.fromfile(fp,'<u4',1)) |
|
647 | 662 | exp_name = numpy.fromfile(fp,'u1',exp_name_len+1) |
|
648 | 663 | |
|
649 | 664 | if ((self.processFlags & PROCFLAG.SHIFT_FFT_DATA) == PROCFLAG.SHIFT_FFT_DATA): |
|
650 | 665 | self.shif_fft = True |
|
651 | 666 | else: |
|
652 | 667 | self.shif_fft = False |
|
653 | 668 | |
|
654 | 669 | if ((self.processFlags & PROCFLAG.SAVE_CHANNELS_DC) == PROCFLAG.SAVE_CHANNELS_DC): |
|
655 | 670 | self.flag_dc = True |
|
656 | 671 | else: |
|
657 | 672 | self.flag_dc = False |
|
658 | 673 | |
|
659 | 674 | if ((self.processFlags & PROCFLAG.DECODE_DATA) == PROCFLAG.DECODE_DATA): |
|
660 | 675 | self.flag_decode = True |
|
661 | 676 | else: |
|
662 | 677 | self.flag_decode = False |
|
663 | 678 | |
|
664 | 679 | if ((self.processFlags & PROCFLAG.DEFLIP_DATA) == PROCFLAG.DEFLIP_DATA): |
|
665 | 680 | self.flag_deflip = True |
|
666 | 681 | else: |
|
667 | 682 | self.flag_deflip = False |
|
668 | 683 | |
|
669 | 684 | nChannels = 0 |
|
670 | 685 | nPairs = 0 |
|
671 | 686 | pairList = [] |
|
672 | 687 | |
|
673 | 688 | for i in range( 0, self.totalSpectra*2, 2 ): |
|
674 | 689 | if self.spectraComb[i] == self.spectraComb[i+1]: |
|
675 | 690 | nChannels = nChannels + 1 #par de canales iguales |
|
676 | 691 | else: |
|
677 | 692 | nPairs = nPairs + 1 #par de canales diferentes |
|
678 | 693 | pairList.append( (self.spectraComb[i], self.spectraComb[i+1]) ) |
|
679 | 694 | |
|
680 | 695 | self.flag_cspc = False |
|
681 | 696 | if nPairs > 0: |
|
682 | 697 | self.flag_cspc = True |
|
683 | 698 | |
|
684 | 699 | |
|
685 | 700 | |
|
686 | 701 | if startFp is not None: |
|
687 | 702 | endFp = size + startFp |
|
688 | 703 | if fp.tell() > endFp: |
|
689 | 704 | sys.stderr.write("Warning: Processing header size is lower than it has to be") |
|
690 | 705 | return 0 |
|
691 | 706 | |
|
692 | 707 | if fp.tell() < endFp: |
|
693 | 708 | sys.stderr.write("Warning: Processing header size is greater than it is considered") |
|
694 | 709 | |
|
695 | 710 | return 1 |
|
696 | 711 | |
|
697 | 712 | def write(self, fp): |
|
698 | 713 | #Clear DEFINE_PROCESS_CODE |
|
699 | 714 | self.processFlags = self.processFlags & (~PROCFLAG.DEFINE_PROCESS_CODE) |
|
700 | 715 | |
|
701 | 716 | headerTuple = (self.size, |
|
702 | 717 | self.dtype, |
|
703 | 718 | self.blockSize, |
|
704 | 719 | self.profilesPerBlock, |
|
705 | 720 | self.dataBlocksPerFile, |
|
706 | 721 | self.nWindows, |
|
707 | 722 | self.processFlags, |
|
708 | 723 | self.nCohInt, |
|
709 | 724 | self.nIncohInt, |
|
710 | 725 | self.totalSpectra) |
|
711 | 726 | |
|
712 | 727 | header = numpy.array(headerTuple,PROCESSING_STRUCTURE) |
|
713 | 728 | header.tofile(fp) |
|
714 | 729 | |
|
715 | 730 | if self.nWindows != 0: |
|
716 | 731 | sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) |
|
717 | 732 | samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE) |
|
718 | 733 | samplingWindow.tofile(fp) |
|
719 | 734 | |
|
720 | 735 | if self.totalSpectra != 0: |
|
721 | 736 | # spectraComb = numpy.array([],numpy.dtype('u1')) |
|
722 | 737 | spectraComb = self.spectraComb |
|
723 | 738 | spectraComb.tofile(fp) |
|
724 | 739 | |
|
725 | 740 | # if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: |
|
726 | 741 | # nCode = numpy.array([self.nCode], numpy.dtype('u4')) #Probar con un dato que almacene codigo, hasta el momento no se hizo la prueba |
|
727 | 742 | # nCode.tofile(fp) |
|
728 | 743 | # |
|
729 | 744 | # nBaud = numpy.array([self.nBaud], numpy.dtype('u4')) |
|
730 | 745 | # nBaud.tofile(fp) |
|
731 | 746 | # |
|
732 | 747 | # code = self.code.reshape(self.nCode*self.nBaud) |
|
733 | 748 | # code = code.astype(numpy.dtype('<f4')) |
|
734 | 749 | # code.tofile(fp) |
|
735 | 750 | |
|
736 | 751 | return 1 |
|
737 | 752 | |
|
738 | 753 | def get_size(self): |
|
739 | 754 | |
|
740 | 755 | self.__size = 40 + 12*self.nWindows + 2*self.totalSpectra |
|
741 | 756 | |
|
742 | 757 | # if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: |
|
743 | 758 | # self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.) |
|
744 | 759 | # self.__size += 4 + 4 + 4 * self.nCode * self.nBaud |
|
745 | 760 | |
|
746 | 761 | return self.__size |
|
747 | 762 | |
|
748 | 763 | def set_size(self, value): |
|
749 | 764 | |
|
750 | 765 | raise IOError, "size is a property and it cannot be set, just read" |
|
751 | 766 | |
|
752 | 767 | return |
|
753 | 768 | |
|
754 | 769 | size = property(get_size, set_size) |
|
755 | 770 | |
|
756 | 771 | class RCfunction: |
|
757 | 772 | NONE=0 |
|
758 | 773 | FLIP=1 |
|
759 | 774 | CODE=2 |
|
760 | 775 | SAMPLING=3 |
|
761 | 776 | LIN6DIV256=4 |
|
762 | 777 | SYNCHRO=5 |
|
763 | 778 | |
|
764 | 779 | class nCodeType: |
|
765 | 780 | NONE=0 |
|
766 | 781 | USERDEFINE=1 |
|
767 | 782 | BARKER2=2 |
|
768 | 783 | BARKER3=3 |
|
769 | 784 | BARKER4=4 |
|
770 | 785 | BARKER5=5 |
|
771 | 786 | BARKER7=6 |
|
772 | 787 | BARKER11=7 |
|
773 | 788 | BARKER13=8 |
|
774 | 789 | AC128=9 |
|
775 | 790 | COMPLEMENTARYCODE2=10 |
|
776 | 791 | COMPLEMENTARYCODE4=11 |
|
777 | 792 | COMPLEMENTARYCODE8=12 |
|
778 | 793 | COMPLEMENTARYCODE16=13 |
|
779 | 794 | COMPLEMENTARYCODE32=14 |
|
780 | 795 | COMPLEMENTARYCODE64=15 |
|
781 | 796 | COMPLEMENTARYCODE128=16 |
|
782 | 797 | CODE_BINARY28=17 |
|
783 | 798 | |
|
784 | 799 | class PROCFLAG: |
|
785 | 800 | |
|
786 | 801 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
|
787 | 802 | DECODE_DATA = numpy.uint32(0x00000002) |
|
788 | 803 | SPECTRA_CALC = numpy.uint32(0x00000004) |
|
789 | 804 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) |
|
790 | 805 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) |
|
791 | 806 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) |
|
792 | 807 | |
|
793 | 808 | DATATYPE_CHAR = numpy.uint32(0x00000040) |
|
794 | 809 | DATATYPE_SHORT = numpy.uint32(0x00000080) |
|
795 | 810 | DATATYPE_LONG = numpy.uint32(0x00000100) |
|
796 | 811 | DATATYPE_INT64 = numpy.uint32(0x00000200) |
|
797 | 812 | DATATYPE_FLOAT = numpy.uint32(0x00000400) |
|
798 | 813 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) |
|
799 | 814 | |
|
800 | 815 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) |
|
801 | 816 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) |
|
802 | 817 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) |
|
803 | 818 | |
|
804 | 819 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) |
|
805 | 820 | DEFLIP_DATA = numpy.uint32(0x00010000) |
|
806 | 821 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) |
|
807 | 822 | |
|
808 | 823 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) |
|
809 | 824 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) |
|
810 | 825 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) |
|
811 | 826 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) |
|
812 | 827 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) |
|
813 | 828 | |
|
814 | 829 | EXP_NAME_ESP = numpy.uint32(0x00200000) |
|
815 | 830 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) |
|
816 | 831 | |
|
817 | 832 | OPERATION_MASK = numpy.uint32(0x0000003F) |
|
818 | 833 | DATATYPE_MASK = numpy.uint32(0x00000FC0) |
|
819 | 834 | DATAARRANGE_MASK = numpy.uint32(0x00007000) |
|
820 | 835 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) |
|
821 | 836 | |
|
822 | 837 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
823 | 838 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
824 | 839 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
825 | 840 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
826 | 841 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
827 | 842 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
828 | 843 | |
|
829 | 844 | NUMPY_DTYPE_LIST = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] |
|
830 | 845 | |
|
831 | 846 | PROCFLAG_DTYPE_LIST = [PROCFLAG.DATATYPE_CHAR, |
|
832 | 847 | PROCFLAG.DATATYPE_SHORT, |
|
833 | 848 | PROCFLAG.DATATYPE_LONG, |
|
834 | 849 | PROCFLAG.DATATYPE_INT64, |
|
835 | 850 | PROCFLAG.DATATYPE_FLOAT, |
|
836 | 851 | PROCFLAG.DATATYPE_DOUBLE] |
|
837 | 852 | |
|
838 | 853 | DTYPE_WIDTH = [1, 2, 4, 8, 4, 8] |
|
839 | 854 | |
|
840 | 855 | def get_dtype_index(numpy_dtype): |
|
841 | 856 | |
|
842 | 857 | index = None |
|
843 | 858 | |
|
844 | 859 | for i in range(len(NUMPY_DTYPE_LIST)): |
|
845 | 860 | if numpy_dtype == NUMPY_DTYPE_LIST[i]: |
|
846 | 861 | index = i |
|
847 | 862 | break |
|
848 | 863 | |
|
849 | 864 | return index |
|
850 | 865 | |
|
851 | 866 | def get_numpy_dtype(index): |
|
852 | 867 | |
|
853 | 868 | return NUMPY_DTYPE_LIST[index] |
|
854 | 869 | |
|
855 | 870 | def get_procflag_dtype(index): |
|
856 | 871 | |
|
857 | 872 | return PROCFLAG_DTYPE_LIST[index] |
|
858 | 873 | |
|
859 | 874 | def get_dtype_width(index): |
|
860 | 875 | |
|
861 | 876 | return DTYPE_WIDTH[index] No newline at end of file |
@@ -1,653 +1,661 | |||
|
1 | 1 | |
|
2 | 2 | ''' |
|
3 | 3 | Created on Jul 3, 2014 |
|
4 | 4 | |
|
5 | 5 | @author: roj-idl71 |
|
6 | 6 | ''' |
|
7 | 7 | import os |
|
8 | 8 | import datetime |
|
9 | 9 | import numpy |
|
10 | from profilehooks import coverage | |
|
10 | from profilehooks import coverage, profile | |
|
11 | 11 | from fractions import Fraction |
|
12 | 12 | |
|
13 | 13 | try: |
|
14 | 14 | from gevent import sleep |
|
15 | 15 | except: |
|
16 | 16 | from time import sleep |
|
17 | 17 | |
|
18 | 18 | from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader |
|
19 | 19 | from schainpy.model.data.jrodata import Voltage |
|
20 | 20 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
21 | ||
|
21 | from time import time | |
|
22 | import cPickle | |
|
22 | 23 | try: |
|
23 | 24 | import digital_rf |
|
24 | 25 | except: |
|
25 | 26 | print 'You should install "digital_rf" module if you want to read Digital RF data' |
|
26 | 27 | |
|
27 | 28 | class DigitalRFReader(ProcessingUnit): |
|
28 | 29 | ''' |
|
29 | 30 | classdocs |
|
30 | 31 | ''' |
|
31 | 32 | |
|
32 | 33 | def __init__(self, **kwargs): |
|
33 | 34 | ''' |
|
34 | 35 | Constructor |
|
35 | 36 | ''' |
|
36 | 37 | |
|
37 | 38 | ProcessingUnit.__init__(self, **kwargs) |
|
38 | 39 | |
|
39 | 40 | self.dataOut = Voltage() |
|
40 | 41 | self.__printInfo = True |
|
41 | 42 | self.__flagDiscontinuousBlock = False |
|
42 | 43 | self.__bufferIndex = 9999999 |
|
43 | ||
|
44 | 44 | self.__ippKm = None |
|
45 | 45 | self.__codeType = 0 |
|
46 | 46 | self.__nCode = None |
|
47 | 47 | self.__nBaud = None |
|
48 | 48 | self.__code = None |
|
49 | 49 | |
|
50 | 50 | def __getCurrentSecond(self): |
|
51 | 51 | |
|
52 | 52 | return self.__thisUnixSample/self.__sample_rate |
|
53 | 53 | |
|
54 | 54 | thisSecond = property(__getCurrentSecond, "I'm the 'thisSecond' property.") |
|
55 | 55 | |
|
56 | 56 | def __setFileHeader(self): |
|
57 | 57 | ''' |
|
58 | 58 | In this method will be initialized every parameter of dataOut object (header, no data) |
|
59 | 59 | ''' |
|
60 | 60 | ippSeconds = 1.0*self.__nSamples/self.__sample_rate |
|
61 | 61 | |
|
62 | nProfiles = 1.0/ippSeconds #Number of profiles in one second | |
|
62 | nProfiles = 1.0/ippSeconds # Number of profiles in one second | |
|
63 | 63 | |
|
64 |
self.dataOut.radarControllerHeaderObj = RadarControllerHeader( |
|
|
65 | txA=0, | |
|
66 | txB=0, | |
|
67 | nWindows=1, | |
|
68 | nHeights=self.__nSamples, | |
|
69 | firstHeight=self.__firstHeigth, | |
|
70 | deltaHeight=self.__deltaHeigth, | |
|
71 | codeType=self.__codeType, | |
|
72 | nCode=self.__nCode, nBaud=self.__nBaud, | |
|
73 | code = self.__code) | |
|
64 | self.dataOut.radarControllerHeaderObj = RadarControllerHeader(self.__radarControllerHeader) | |
|
74 | 65 | |
|
75 |
self.dataOut.systemHeaderObj = SystemHeader( |
|
|
76 | nProfiles=nProfiles, | |
|
77 | nChannels=len(self.__channelList), | |
|
78 | adcResolution=14) | |
|
66 | self.dataOut.systemHeaderObj = SystemHeader(self.__systemHeader) | |
|
79 | 67 | |
|
80 | 68 | self.dataOut.type = "Voltage" |
|
81 | 69 | |
|
82 | 70 | self.dataOut.data = None |
|
83 | 71 | |
|
84 |
self.dataOut.dtype = |
|
|
72 | self.dataOut.dtype = self.dtype | |
|
85 | 73 | |
|
86 |
|
|
|
74 | # self.dataOut.nChannels = 0 | |
|
87 | 75 | |
|
88 |
|
|
|
76 | # self.dataOut.nHeights = 0 | |
|
89 | 77 | |
|
90 | 78 | self.dataOut.nProfiles = nProfiles |
|
91 | 79 | |
|
92 | 80 | self.dataOut.heightList = self.__firstHeigth + numpy.arange(self.__nSamples, dtype = numpy.float)*self.__deltaHeigth |
|
93 | 81 | |
|
94 | 82 | self.dataOut.channelList = self.__channelList |
|
95 | 83 | |
|
96 | 84 | self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights() |
|
97 | 85 | |
|
98 |
|
|
|
86 | # self.dataOut.channelIndexList = None | |
|
99 | 87 | |
|
100 | 88 | self.dataOut.flagNoData = True |
|
101 | ||
|
102 | #Set to TRUE if the data is discontinuous | |
|
89 | self.dataOut.flagDataAsBlock = False | |
|
90 | # Set to TRUE if the data is discontinuous | |
|
103 | 91 | self.dataOut.flagDiscontinuousBlock = False |
|
104 | 92 | |
|
105 | 93 | self.dataOut.utctime = None |
|
106 | 94 | |
|
107 | self.dataOut.timeZone = self.__timezone/60 #timezone like jroheader, difference in minutes between UTC and localtime | |
|
95 | self.dataOut.timeZone = self.__timezone/60 # timezone like jroheader, difference in minutes between UTC and localtime | |
|
108 | 96 | |
|
109 | 97 | self.dataOut.dstFlag = 0 |
|
110 | 98 | |
|
111 | 99 | self.dataOut.errorCount = 0 |
|
112 | 100 | |
|
113 | 101 | self.dataOut.nCohInt = 1 |
|
114 | 102 | |
|
115 | self.dataOut.flagDecodeData = False #asumo que la data esta decodificada | |
|
103 | self.dataOut.flagDecodeData = False # asumo que la data esta decodificada | |
|
116 | 104 | |
|
117 | self.dataOut.flagDeflipData = False #asumo que la data esta sin flip | |
|
105 | self.dataOut.flagDeflipData = False # asumo que la data esta sin flip | |
|
118 | 106 | |
|
119 | 107 | self.dataOut.flagShiftFFT = False |
|
120 | 108 | |
|
121 | 109 | self.dataOut.ippSeconds = ippSeconds |
|
122 | 110 | |
|
123 | #Time interval between profiles | |
|
124 | #self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt | |
|
111 | # Time interval between profiles | |
|
112 | # self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt | |
|
125 | 113 | |
|
126 | 114 | self.dataOut.frequency = self.__frequency |
|
127 | 115 | |
|
128 | 116 | self.dataOut.realtime = self.__online |
|
129 | 117 | |
|
130 | 118 | def findDatafiles(self, path, startDate=None, endDate=None): |
|
131 | 119 | |
|
132 | 120 | if not os.path.isdir(path): |
|
133 | 121 | return [] |
|
134 | 122 | |
|
135 | 123 | try: |
|
136 | 124 | digitalReadObj = digital_rf.DigitalRFReader(path, load_all_metadata=True) |
|
137 | 125 | except: |
|
138 | 126 | digitalReadObj = digital_rf.DigitalRFReader(path) |
|
139 | 127 | |
|
140 | 128 | channelNameList = digitalReadObj.get_channels() |
|
141 | 129 | |
|
142 | 130 | if not channelNameList: |
|
143 | 131 | return [] |
|
144 | 132 | |
|
145 | 133 | metadata_dict = digitalReadObj.get_rf_file_metadata(channelNameList[0]) |
|
146 | 134 | |
|
147 | 135 | sample_rate = metadata_dict['sample_rate'][0] |
|
148 | 136 | |
|
149 | 137 | this_metadata_file = digitalReadObj.get_metadata(channelNameList[0]) |
|
150 | 138 | |
|
151 | 139 | try: |
|
152 | 140 | timezone = this_metadata_file['timezone'].value |
|
153 | 141 | except: |
|
154 | 142 | timezone = 0 |
|
155 | 143 | |
|
156 | 144 | startUTCSecond, endUTCSecond = digitalReadObj.get_bounds(channelNameList[0])/sample_rate - timezone |
|
157 | 145 | |
|
158 | 146 | startDatetime = datetime.datetime.utcfromtimestamp(startUTCSecond) |
|
159 | 147 | endDatatime = datetime.datetime.utcfromtimestamp(endUTCSecond) |
|
160 | 148 | |
|
161 | 149 | if not startDate: |
|
162 | 150 | startDate = startDatetime.date() |
|
163 | 151 | |
|
164 | 152 | if not endDate: |
|
165 | 153 | endDate = endDatatime.date() |
|
166 | 154 | |
|
167 | 155 | dateList = [] |
|
168 | 156 | |
|
169 | 157 | thisDatetime = startDatetime |
|
170 | 158 | |
|
171 | 159 | while(thisDatetime<=endDatatime): |
|
172 | 160 | |
|
173 | 161 | thisDate = thisDatetime.date() |
|
174 | 162 | |
|
175 | 163 | if thisDate < startDate: |
|
176 | 164 | continue |
|
177 | 165 | |
|
178 | 166 | if thisDate > endDate: |
|
179 | 167 | break |
|
180 | 168 | |
|
181 | 169 | dateList.append(thisDate) |
|
182 | 170 | thisDatetime += datetime.timedelta(1) |
|
183 | 171 | |
|
184 | 172 | return dateList |
|
185 | 173 | |
|
186 | 174 | def setup(self, path = None, |
|
187 | 175 | startDate = None, |
|
188 | 176 | endDate = None, |
|
189 | 177 | startTime = datetime.time(0,0,0), |
|
190 | 178 | endTime = datetime.time(23,59,59), |
|
191 | 179 | channelList = None, |
|
192 | 180 | nSamples = None, |
|
193 | 181 | ippKm = 60, |
|
194 | 182 | online = False, |
|
195 | 183 | delay = 60, |
|
196 | 184 | buffer_size = 1024, |
|
197 | 185 | **kwargs): |
|
198 | 186 | ''' |
|
199 | 187 | In this method we should set all initial parameters. |
|
200 | 188 | |
|
201 | 189 | Inputs: |
|
202 | 190 | path |
|
203 | 191 | startDate |
|
204 | 192 | endDate |
|
205 | 193 | startTime |
|
206 | 194 | endTime |
|
207 | 195 | set |
|
208 | 196 | expLabel |
|
209 | 197 | ext |
|
210 | 198 | online |
|
211 | 199 | delay |
|
212 | 200 | ''' |
|
213 | 201 | |
|
214 | 202 | if not os.path.isdir(path): |
|
215 | 203 | raise ValueError, "[Reading] Directory %s does not exist" %path |
|
216 | 204 | |
|
217 | 205 | try: |
|
218 | 206 | self.digitalReadObj = digital_rf.DigitalRFReader(path, load_all_metadata=True) |
|
219 | 207 | except: |
|
220 | 208 | self.digitalReadObj = digital_rf.DigitalRFReader(path) |
|
221 | 209 | |
|
222 | 210 | channelNameList = self.digitalReadObj.get_channels() |
|
223 | 211 | |
|
224 | 212 | if not channelNameList: |
|
225 | 213 | raise ValueError, "[Reading] Directory %s does not have any files" %path |
|
226 | 214 | |
|
227 | 215 | if not channelList: |
|
228 | 216 | channelList = range(len(channelNameList)) |
|
229 | 217 | |
|
218 | ||
|
230 | 219 | ########## Reading metadata ###################### |
|
231 | 220 | |
|
232 |
|
|
|
221 | top_properties = self.digitalReadObj.get_properties(channelNameList[channelList[0]]) | |
|
233 | 222 | |
|
234 |
self.__sample_rate = |
|
|
235 |
|
|
|
223 | self.__sample_rate = 1.0 * top_properties['sample_rate_numerator'] / top_properties['sample_rate_denominator'] | |
|
224 | # self.__samples_per_file = top_properties['samples_per_file'][0] | |
|
236 | 225 | self.__deltaHeigth = 1e6*0.15/self.__sample_rate ## why 0.15? |
|
237 | 226 | |
|
238 | 227 | this_metadata_file = self.digitalReadObj.get_digital_metadata(channelNameList[channelList[0]]) |
|
239 | 228 | metadata_bounds = this_metadata_file.get_bounds() |
|
240 | self.fixed_metadata_dict = this_metadata_file.read(metadata_bounds[0])[metadata_bounds[0]] ##GET FIRST HEADER | |
|
229 | self.fixed_metadata_dict = this_metadata_file.read(metadata_bounds[0])[metadata_bounds[0]] ## GET FIRST HEADER | |
|
230 | self.__processingHeader = self.fixed_metadata_dict['processingHeader'] | |
|
231 | self.__radarControllerHeader = self.fixed_metadata_dict['radarControllerHeader'] | |
|
232 | self.__systemHeader = self.fixed_metadata_dict['systemHeader'] | |
|
233 | self.dtype = cPickle.loads(self.fixed_metadata_dict['dtype']) | |
|
241 | 234 | |
|
242 | 235 | self.__frequency = None |
|
236 | ||
|
243 | 237 | try: |
|
244 | 238 | self.__frequency = self.fixed_metadata_dict['frequency'] |
|
245 | 239 | except: |
|
246 | 240 | self.__frequency = None |
|
247 | 241 | |
|
248 | 242 | try: |
|
249 | 243 | self.__timezone = self.fixed_metadata_dict['timezone'] |
|
250 | 244 | except: |
|
251 | 245 | self.__timezone = 0 |
|
252 | 246 | |
|
247 | ||
|
248 | try: | |
|
249 | nSamples = self.__systemHeader['nSamples'] | |
|
250 | except: | |
|
251 | nSamples = None | |
|
252 | ||
|
253 | 253 | self.__firstHeigth = 0 |
|
254 | 254 | |
|
255 | 255 | try: |
|
256 |
codeType = self. |
|
|
256 | codeType = self.__radarControllerHeader['codeType'] | |
|
257 | 257 | except: |
|
258 | 258 | codeType = 0 |
|
259 | 259 | |
|
260 | 260 | nCode = 1 |
|
261 | 261 | nBaud = 1 |
|
262 | 262 | code = numpy.ones((nCode, nBaud), dtype=numpy.int) |
|
263 | 263 | |
|
264 | 264 | if codeType: |
|
265 |
nCode = self. |
|
|
266 |
nBaud = self. |
|
|
267 |
code = self. |
|
|
268 | ||
|
265 | nCode = self.__radarControllerHeader['nCode'] | |
|
266 | nBaud = self.__radarControllerHeader['nBaud'] | |
|
267 | code = self.__radarControllerHeader['code'] | |
|
268 | ||
|
269 | 269 | if not ippKm: |
|
270 | 270 | try: |
|
271 | #seconds to km | |
|
272 |
ippKm = 1e6*0.15*self. |
|
|
271 | # seconds to km | |
|
272 | ippKm = 1e6*0.15*self.__radarControllerHeader['ipp'] | |
|
273 | 273 | except: |
|
274 | 274 | ippKm = None |
|
275 | 275 | #################################################### |
|
276 | 276 | startUTCSecond = None |
|
277 | 277 | endUTCSecond = None |
|
278 | 278 | |
|
279 | 279 | if startDate: |
|
280 | 280 | startDatetime = datetime.datetime.combine(startDate, startTime) |
|
281 | 281 | startUTCSecond = (startDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone |
|
282 | 282 | |
|
283 | 283 | if endDate: |
|
284 | 284 | endDatetime = datetime.datetime.combine(endDate, endTime) |
|
285 | 285 | endUTCSecond = (endDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone |
|
286 | 286 | |
|
287 | 287 | start_index, end_index = self.digitalReadObj.get_bounds(channelNameList[channelList[0]]) |
|
288 | 288 | |
|
289 | 289 | if not startUTCSecond: |
|
290 | 290 | startUTCSecond = start_index/self.__sample_rate |
|
291 | 291 | |
|
292 | 292 | if start_index > startUTCSecond*self.__sample_rate: |
|
293 | 293 | startUTCSecond = start_index/self.__sample_rate |
|
294 | 294 | |
|
295 | 295 | if not endUTCSecond: |
|
296 | 296 | endUTCSecond = end_index/self.__sample_rate |
|
297 | 297 | |
|
298 | 298 | if end_index < endUTCSecond*self.__sample_rate: |
|
299 | 299 | endUTCSecond = end_index/self.__sample_rate |
|
300 | 300 | |
|
301 | 301 | if not nSamples: |
|
302 | 302 | if not ippKm: |
|
303 | 303 | raise ValueError, "[Reading] nSamples or ippKm should be defined" |
|
304 | 304 | nSamples = int(ippKm / (1e6*0.15/self.__sample_rate)) |
|
305 | 305 | |
|
306 | 306 | channelBoundList = [] |
|
307 | 307 | channelNameListFiltered = [] |
|
308 | 308 | |
|
309 | 309 | for thisIndexChannel in channelList: |
|
310 | 310 | thisChannelName = channelNameList[thisIndexChannel] |
|
311 | 311 | start_index, end_index = self.digitalReadObj.get_bounds(thisChannelName) |
|
312 | 312 | channelBoundList.append((start_index, end_index)) |
|
313 | 313 | channelNameListFiltered.append(thisChannelName) |
|
314 | 314 | |
|
315 | 315 | self.profileIndex = 0 |
|
316 | ||
|
316 | self.i= 0 | |
|
317 | 317 | self.__delay = delay |
|
318 | 318 | self.__ippKm = ippKm |
|
319 | 319 | self.__codeType = codeType |
|
320 | 320 | self.__nCode = nCode |
|
321 | 321 | self.__nBaud = nBaud |
|
322 | 322 | self.__code = code |
|
323 | 323 | |
|
324 | 324 | self.__datapath = path |
|
325 | 325 | self.__online = online |
|
326 | 326 | self.__channelList = channelList |
|
327 | 327 | self.__channelNameList = channelNameListFiltered |
|
328 | 328 | self.__channelBoundList = channelBoundList |
|
329 | 329 | self.__nSamples = nSamples |
|
330 |
self.__samples_to_read = long( |
|
|
330 | self.__samples_to_read = long(nSamples) # FIJO: AHORA 40 | |
|
331 | 331 | self.__nChannels = len(self.__channelList) |
|
332 | 332 | |
|
333 | 333 | self.__startUTCSecond = startUTCSecond |
|
334 | 334 | self.__endUTCSecond = endUTCSecond |
|
335 | 335 | |
|
336 | self.__timeInterval = 1.0 * self.__samples_to_read/self.__sample_rate #Time interval | |
|
336 | self.__timeInterval = 1.0 * self.__samples_to_read/self.__sample_rate # Time interval | |
|
337 | 337 | |
|
338 | 338 | if online: |
|
339 |
|
|
|
339 | # self.__thisUnixSample = int(endUTCSecond*self.__sample_rate - 4*self.__samples_to_read) | |
|
340 | 340 | startUTCSecond = numpy.floor(endUTCSecond) |
|
341 | 341 | |
|
342 | self.__thisUnixSample = long(startUTCSecond*self.__sample_rate) - self.__samples_to_read ##por que en el otro metodo lo primero q se hace es sumar samplestoread | |
|
342 | self.__thisUnixSample = long(startUTCSecond*self.__sample_rate) - self.__samples_to_read ## por que en el otro metodo lo primero q se hace es sumar samplestoread | |
|
343 | 343 | |
|
344 | 344 | self.__data_buffer = numpy.zeros((self.__nChannels, self.__samples_to_read), dtype = numpy.complex) |
|
345 | 345 | |
|
346 | 346 | self.__setFileHeader() |
|
347 | 347 | self.isConfig = True |
|
348 | 348 | |
|
349 | 349 | print "[Reading] Digital RF Data was found from %s to %s " %( |
|
350 | 350 | datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
351 | 351 | datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
352 | 352 | ) |
|
353 | 353 | |
|
354 | 354 | print "[Reading] Starting process from %s to %s" %(datetime.datetime.utcfromtimestamp(startUTCSecond - self.__timezone), |
|
355 | 355 | datetime.datetime.utcfromtimestamp(endUTCSecond - self.__timezone) |
|
356 | 356 | ) |
|
357 | 357 | |
|
358 | 358 | def __reload(self): |
|
359 | 359 | |
|
360 | 360 | # print "%s not in range [%s, %s]" %( |
|
361 | 361 | # datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), |
|
362 | 362 | # datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
363 | 363 | # datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
364 | 364 | # ) |
|
365 | 365 | print "[Reading] reloading metadata ..." |
|
366 | 366 | |
|
367 | 367 | try: |
|
368 | 368 | self.digitalReadObj.reload(complete_update=True) |
|
369 | 369 | except: |
|
370 | 370 | self.digitalReadObj.reload() |
|
371 | 371 | |
|
372 | 372 | start_index, end_index = self.digitalReadObj.get_bounds(self.__channelNameList[self.__channelList[0]]) |
|
373 | 373 | |
|
374 | 374 | if start_index > self.__startUTCSecond*self.__sample_rate: |
|
375 | 375 | self.__startUTCSecond = 1.0*start_index/self.__sample_rate |
|
376 | 376 | |
|
377 | 377 | if end_index > self.__endUTCSecond*self.__sample_rate: |
|
378 | 378 | self.__endUTCSecond = 1.0*end_index/self.__sample_rate |
|
379 | 379 | |
|
380 | 380 | print "[Reading] New timerange found [%s, %s] " %( |
|
381 | 381 | datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
382 | 382 | datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
383 | 383 | ) |
|
384 | 384 | |
|
385 | 385 | return True |
|
386 | 386 | |
|
387 | 387 | return False |
|
388 | 388 | |
|
389 | 389 | def __readNextBlock(self, seconds=30, volt_scale = 1): |
|
390 | 390 | ''' |
|
391 | 391 | ''' |
|
392 | 392 | |
|
393 | #Set the next data | |
|
393 | # Set the next data | |
|
394 | 394 | self.__flagDiscontinuousBlock = False |
|
395 | 395 | self.__thisUnixSample += self.__samples_to_read |
|
396 | 396 | |
|
397 | 397 | if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate: |
|
398 | 398 | print "[Reading] There are no more data into selected time-range" |
|
399 | 399 | if self.__online: |
|
400 | 400 | self.__reload() |
|
401 | 401 | else: |
|
402 | 402 | return False |
|
403 | 403 | |
|
404 | 404 | if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate: |
|
405 | 405 | return False |
|
406 | 406 | self.__thisUnixSample -= self.__samples_to_read |
|
407 | 407 | |
|
408 | 408 | indexChannel = 0 |
|
409 | 409 | |
|
410 | 410 | dataOk = False |
|
411 | ||
|
412 | 411 | for thisChannelName in self.__channelNameList: ##TODO VARIOS CHANNELS? |
|
413 | ||
|
414 | 412 | try: |
|
415 | 413 | result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample, |
|
416 | 414 | self.__samples_to_read, |
|
417 | 415 | thisChannelName) |
|
418 | 416 | except IOError, e: |
|
419 | 417 | #read next profile |
|
420 | 418 | self.__flagDiscontinuousBlock = True |
|
421 | 419 | print "[Reading] %s" %datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), e |
|
422 | 420 | break |
|
423 | 421 | |
|
424 | 422 | if result.shape[0] != self.__samples_to_read: |
|
425 | 423 | self.__flagDiscontinuousBlock = True |
|
426 | 424 | print "[Reading] %s: Too few samples were found, just %d/%d samples" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), |
|
427 | 425 | result.shape[0], |
|
428 | 426 | self.__samples_to_read) |
|
429 | 427 | break |
|
430 | 428 | |
|
431 | 429 | self.__data_buffer[indexChannel,:] = result*volt_scale |
|
432 | 430 | |
|
433 | 431 | indexChannel += 1 |
|
434 | 432 | |
|
435 | 433 | dataOk = True |
|
436 | ||
|
434 | ||
|
437 | 435 | self.__utctime = self.__thisUnixSample/self.__sample_rate |
|
438 | 436 | |
|
439 | 437 | if not dataOk: |
|
440 | 438 | return False |
|
441 | 439 | |
|
442 | 440 | print "[Reading] %s: %d samples <> %f sec" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), |
|
443 | 441 | self.__samples_to_read, |
|
444 | 442 | self.__timeInterval) |
|
445 | 443 | |
|
446 | 444 | self.__bufferIndex = 0 |
|
447 | 445 | |
|
448 | 446 | return True |
|
449 | 447 | |
|
450 | 448 | def __isBufferEmpty(self): |
|
451 | 449 | return self.__bufferIndex > self.__samples_to_read - self.__nSamples #40960 - 40 |
|
452 | 450 | |
|
453 | 451 | def getData(self, seconds=30, nTries=5): |
|
454 | 452 | |
|
455 | 453 | ''' |
|
456 | 454 | This method gets the data from files and put the data into the dataOut object |
|
457 | 455 | |
|
458 | 456 | In addition, increase el the buffer counter in one. |
|
459 | 457 | |
|
460 | 458 | Return: |
|
461 | 459 | data : retorna un perfil de voltages (alturas * canales) copiados desde el |
|
462 | 460 | buffer. Si no hay mas archivos a leer retorna None. |
|
463 | 461 | |
|
464 | 462 | Affected: |
|
465 | 463 | self.dataOut |
|
466 | 464 | self.profileIndex |
|
467 | 465 | self.flagDiscontinuousBlock |
|
468 | 466 | self.flagIsNewBlock |
|
469 | 467 | ''' |
|
470 | 468 | |
|
471 | 469 | err_counter = 0 |
|
472 | 470 | self.dataOut.flagNoData = True |
|
473 | 471 | |
|
474 | 472 | if self.__isBufferEmpty(): |
|
475 | ||
|
476 | 473 | self.__flagDiscontinuousBlock = False |
|
477 | 474 | |
|
478 | 475 | while True: |
|
479 | 476 | if self.__readNextBlock(): |
|
480 | 477 | break |
|
481 | 478 | if self.__thisUnixSample > self.__endUTCSecond*self.__sample_rate: |
|
482 | 479 | return False |
|
483 | 480 | |
|
484 | 481 | if self.__flagDiscontinuousBlock: |
|
485 | 482 | print '[Reading] discontinuous block found ... continue with the next block' |
|
486 | 483 | continue |
|
487 | 484 | |
|
488 | 485 | if not self.__online: |
|
489 | 486 | return False |
|
490 | 487 | |
|
491 | 488 | err_counter += 1 |
|
492 | 489 | if err_counter > nTries: |
|
493 | 490 | return False |
|
494 | 491 | |
|
495 | 492 | print '[Reading] waiting %d seconds to read a new block' %seconds |
|
496 | 493 | sleep(seconds) |
|
497 | 494 | |
|
498 | 495 | self.dataOut.data = self.__data_buffer[:,self.__bufferIndex:self.__bufferIndex+self.__nSamples] |
|
499 | 496 | self.dataOut.utctime = (self.__thisUnixSample + self.__bufferIndex)/self.__sample_rate |
|
500 | 497 | self.dataOut.flagNoData = False |
|
501 | 498 | self.dataOut.flagDiscontinuousBlock = self.__flagDiscontinuousBlock |
|
502 | 499 | self.dataOut.profileIndex = self.profileIndex |
|
503 | 500 | |
|
504 | 501 | self.__bufferIndex += self.__nSamples |
|
505 | 502 | self.profileIndex += 1 |
|
506 | 503 | |
|
507 | 504 | if self.profileIndex == self.dataOut.nProfiles: |
|
508 | 505 | self.profileIndex = 0 |
|
509 | 506 | |
|
510 | 507 | return True |
|
511 | 508 | |
|
512 | 509 | def printInfo(self): |
|
513 | 510 | ''' |
|
514 | 511 | ''' |
|
515 | 512 | if self.__printInfo == False: |
|
516 | 513 | return |
|
517 | 514 | |
|
518 |
|
|
|
519 |
|
|
|
515 | # self.systemHeaderObj.printInfo() | |
|
516 | # self.radarControllerHeaderObj.printInfo() | |
|
520 | 517 | |
|
521 | 518 | self.__printInfo = False |
|
522 | 519 | |
|
523 | 520 | def printNumberOfBlock(self): |
|
524 | 521 | ''' |
|
525 | 522 | ''' |
|
526 | 523 | return |
|
527 | #print self.profileIndex | |
|
524 | # print self.profileIndex | |
|
528 | 525 | |
|
526 | ##@profile | |
|
529 | 527 | def run(self, **kwargs): |
|
530 | 528 | ''' |
|
531 | 529 | This method will be called many times so here you should put all your code |
|
532 | 530 | ''' |
|
533 | ||
|
531 | ||
|
534 | 532 | if not self.isConfig: |
|
535 | 533 | self.setup(**kwargs) |
|
536 | ||
|
534 | print self.dataOut.dtype | |
|
535 | self.i = self.i+1 | |
|
537 | 536 | self.getData(seconds=self.__delay) |
|
538 | 537 | |
|
539 | 538 | return |
|
540 | 539 | |
|
541 | 540 | class DigitalRFWriter(Operation): |
|
542 | 541 | ''' |
|
543 | 542 | classdocs |
|
544 | 543 | ''' |
|
545 | 544 | |
|
546 | 545 | def __init__(self, **kwargs): |
|
547 | 546 | ''' |
|
548 | 547 | Constructor |
|
549 | 548 | ''' |
|
550 | 549 | Operation.__init__(self, **kwargs) |
|
550 | self.metadata_dict = {} | |
|
551 | 551 | self.dataOut = None |
|
552 | 552 | |
|
553 | def setup(self, dataOut, path, set=0, metadataFile='metadata', ext='.h5'): | |
|
553 | def setup(self, dataOut, path, frequency, set=0, metadataFile='metadata', ext='.h5'): | |
|
554 | 554 | ''' |
|
555 | 555 | In this method we should set all initial parameters. |
|
556 | ||
|
557 | 556 | Input: |
|
558 |
dataOut |
|
|
559 | ||
|
557 | dataOut: Input data will also be outputa data | |
|
560 | 558 | ''' |
|
561 | ||
|
559 | self.metadata_dict['frequency'] = frequency | |
|
560 | self.metadata_dict['timezone'] = -5 * 60 * 60 | |
|
561 | self.metadata_dict['dtype'] = cPickle.dumps(dataOut.dtype) | |
|
562 | ||
|
562 | 563 | self.__ippSeconds = dataOut.ippSeconds |
|
563 | 564 | self.__deltaH = dataOut.getDeltaH() |
|
564 | 565 | self.__sample_rate = 1e6*0.15/self.__deltaH |
|
565 | 566 | self.__dtype = dataOut.dtype |
|
566 | 567 | if len(dataOut.dtype) == 2: |
|
567 | 568 | self.__dtype = dataOut.dtype[0] |
|
568 | 569 | self.__nSamples = dataOut.systemHeaderObj.nSamples |
|
569 | 570 | self.__nProfiles = dataOut.nProfiles |
|
570 | 571 | self.__blocks_per_file = dataOut.processingHeaderObj.dataBlocksPerFile |
|
571 | 572 | self.arr_data = arr_data = numpy.ones((self.__nSamples, 1), dtype=[('r', self.__dtype), ('i', self.__dtype)]) |
|
572 | 573 | |
|
573 |
file_cadence_millisecs = long(1.0 * self.__blocks_per_file * self.__nProfiles * self.__nSamples / self.__sample_rate * 1000 |
|
|
574 | sub_cadence_secs = file_cadence_millisecs | |
|
574 | file_cadence_millisecs = long(1.0 * self.__blocks_per_file * self.__nProfiles * self.__nSamples / self.__sample_rate) * 1000 | |
|
575 | sub_cadence_secs = file_cadence_millisecs / 500 | |
|
575 | 576 | |
|
576 |
|
|
|
577 |
|
|
|
577 | print file_cadence_millisecs | |
|
578 | print sub_cadence_secs | |
|
578 | 579 | |
|
579 | 580 | sample_rate_fraction = Fraction(self.__sample_rate).limit_denominator() |
|
580 | 581 | sample_rate_numerator = long(sample_rate_fraction.numerator) |
|
581 | 582 | sample_rate_denominator = long(sample_rate_fraction.denominator) |
|
582 | 583 | start_global_index = dataOut.utctime * self.__sample_rate |
|
583 | 584 | |
|
584 | 585 | uuid = 'prueba' |
|
585 | 586 | compression_level = 1 |
|
586 | 587 | checksum = False |
|
587 | 588 | is_complex = True |
|
588 | 589 | num_subchannels = 1 |
|
589 | 590 | is_continuous = True |
|
590 | 591 | marching_periods = False |
|
591 | 592 | |
|
592 |
self.digitalWriteObj = digital_rf.DigitalRFWriter(path, self.__dtype, |
|
|
593 |
|
|
|
593 | self.digitalWriteObj = digital_rf.DigitalRFWriter(path, self.__dtype, 100, | |
|
594 | 1000, start_global_index, | |
|
594 | 595 | sample_rate_numerator, sample_rate_denominator, uuid, compression_level, checksum, |
|
595 | 596 | is_complex, num_subchannels, is_continuous, marching_periods) |
|
596 | 597 | |
|
597 | 598 | metadata_dir = os.path.join(path, 'metadata') |
|
598 | 599 | os.system('mkdir %s' % (metadata_dir)) |
|
599 | 600 | |
|
600 |
self.digitalMetadataWriteObj = digital_rf.DigitalMetadataWriter(metadata_dir, |
|
|
601 | self.digitalMetadataWriteObj = digital_rf.DigitalMetadataWriter(metadata_dir, 100, 1, ##236, file_cadence_millisecs / 1000 | |
|
601 | 602 | sample_rate_numerator, sample_rate_denominator, |
|
602 | 603 | metadataFile) |
|
603 | 604 | |
|
604 | 605 | |
|
605 | 606 | self.isConfig = True |
|
606 | 607 | self.currentSample = 0 |
|
607 | 608 | return |
|
609 | ||
|
610 | def writeMetadata(self): | |
|
611 | print '[Writing] - Writing metadata' | |
|
612 | start_idx = self.__sample_rate * self.dataOut.utctime | |
|
613 | ||
|
614 | self.metadata_dict['processingHeader'] = self.dataOut.processingHeaderObj.getAsDict() | |
|
615 | self.metadata_dict['radarControllerHeader'] = self.dataOut.radarControllerHeaderObj.getAsDict() | |
|
616 | self.metadata_dict['systemHeader'] = self.dataOut.systemHeaderObj.getAsDict() | |
|
617 | self.digitalMetadataWriteObj.write(start_idx, self.metadata_dict) | |
|
618 | return | |
|
608 | 619 | |
|
609 | @coverage | |
|
610 | def run(self, dataOut, path=None, **kwargs): | |
|
620 | ||
|
621 | def writeData(self): | |
|
622 | for i in range(self.dataOut.systemHeaderObj.nSamples): | |
|
623 | self.arr_data[i]['r'] = self.dataOut.data[0][i].real | |
|
624 | self.arr_data[i]['i'] = self.dataOut.data[0][i].imag | |
|
625 | self.digitalWriteObj.rf_write(self.arr_data) | |
|
626 | return | |
|
627 | ||
|
628 | def run(self, dataOut, frequency=49.92e6, path=None, **kwargs): | |
|
611 | 629 | ''' |
|
612 | 630 | This method will be called many times so here you should put all your code |
|
613 | ||
|
614 | 631 | Inputs: |
|
615 | ||
|
616 | dataOut : object with the data | |
|
617 | ||
|
632 | dataOut: object with the data | |
|
618 | 633 | ''' |
|
619 | #print dataOut.__dict__ | |
|
634 | # print dataOut.__dict__ | |
|
620 | 635 | self.dataOut = dataOut |
|
621 | ||
|
622 | 636 | if not self.isConfig: |
|
623 | self.setup(dataOut, path, **kwargs) | |
|
624 | ||
|
625 | samples = len(self.dataOut.data[0]) | |
|
637 | self.setup(dataOut, path, frequency, **kwargs) | |
|
626 | 638 | |
|
627 | for i in range(samples): | |
|
628 | self.arr_data[i]['r'] = dataOut.data[0][i].real | |
|
629 | self.arr_data[i]['i'] = dataOut.data[0][i].imag | |
|
630 | self.digitalWriteObj.rf_write(self.arr_data) | |
|
631 | start_idx = self.__sample_rate * dataOut.utctime | |
|
632 | metadata_dict = {} | |
|
633 | metadata_dict['frequency'] = 49.92e6 | |
|
634 | metadata_dict['blablabla'] = 49.92e6 | |
|
639 | self.writeData() | |
|
640 | ||
|
635 | 641 | self.currentSample += 1 |
|
636 | if self.dataOut.flagDataAsBlock: | |
|
637 | self.digitalMetadataWriteObj.write(start_idx, metadata_dict) | |
|
638 | elif self.currentSample == 1: | |
|
639 | print '[Writing] - Writing metadata' | |
|
640 | self.digitalMetadataWriteObj.write(start_idx, metadata_dict) | |
|
642 | if self.dataOut.flagDataAsBlock or self.currentSample == 1: | |
|
643 | self.writeMetadata() | |
|
641 | 644 | if self.currentSample == self.__nProfiles: self.currentSample = 0 |
|
645 | ||
|
642 | 646 | def close(self): |
|
643 | 647 | print '[Writing] - Closing files ' |
|
644 | self.digitalWriteObj.close() | |
|
645 | #raise | |
|
648 | try: | |
|
649 | self.digitalWriteObj.close() | |
|
650 | except: | |
|
651 | pass | |
|
652 | ||
|
653 | # raise | |
|
646 | 654 | if __name__ == '__main__': |
|
647 | 655 | |
|
648 | 656 | readObj = DigitalRFReader() |
|
649 | 657 | |
|
650 | 658 | while True: |
|
651 | 659 | readObj.run(path='/home/jchavez/jicamarca/mocked_data/') |
|
652 |
|
|
|
653 | #readObj.printNumberOfBlock() | |
|
660 | # readObj.printInfo() | |
|
661 | # readObj.printNumberOfBlock() |
@@ -1,1 +1,1 | |||
|
1 | <Project description="Segundo Test" id="191" name="test01"><ReadUnit datatype="VoltageReader" id="1911" inputId="0" name="VoltageReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="VoltageReader" /><Parameter format="str" id="191112" name="path" value="/home/jchavez/jicamarca/jro_data/rawdata" /><Parameter format="date" id="191113" name="startDate" value="2010/10/28" /><Parameter format="date" id="191114" name="endDate" value="2017/10/28" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="online" value="0" /><Parameter format="int" id="191119" name="walk" value="0" /></Operation><Operation id="19112" name="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="VoltageProc" id="1912" inputId="1911" name="VoltageProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="DigitalRFWriter" priority="2" type="other"><Parameter format="str" id="191221" name="path" value="/home/jchavez/jicamarca/mocked_data/voltage" /></Operation></ProcUnit></Project> No newline at end of file | |
|
1 | <Project description="Testing USRP data reader" id="191" name="test01"><ReadUnit datatype="DigitalRF" id="1911" inputId="0" name="DigitalRFReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="DigitalRF" /><Parameter format="str" id="191112" name="path" value="/home/jchavez/jicamarca/mocked_data" /><Parameter format="date" id="191113" name="startDate" value="2000/07/03" /><Parameter format="date" id="191114" name="endDate" value="2017/07/03" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="Voltage" id="1912" inputId="1911" name="VoltageProc"><Operation id="19121" name="run" priority="1" type="self" /></ProcUnit></Project> No newline at end of file |
@@ -1,118 +1,117 | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | ''' |
|
3 | 3 | Created on Jul 7, 2014 |
|
4 | 4 | |
|
5 | 5 | @author: roj-idl71 |
|
6 | 6 | ''' |
|
7 | 7 | import os, sys |
|
8 | 8 | |
|
9 | 9 | from schainpy.controller import Project |
|
10 | 10 | |
|
11 | 11 | def main(): |
|
12 | 12 | |
|
13 | 13 | desc = "Testing USRP data reader" |
|
14 | 14 | filename = "schain.xml" |
|
15 | 15 | figpath = "./" |
|
16 | 16 | remotefolder = "/home/wmaster/graficos" |
|
17 | 17 | |
|
18 | 18 | #this controller object save all user configuration and then execute each module |
|
19 | 19 | #with their parameters. |
|
20 | 20 | controllerObj = Project() |
|
21 | 21 | |
|
22 | 22 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
23 | 23 | |
|
24 | 24 | #Creating a reader object with its parameters |
|
25 | 25 | #schainpy.model.io.jroIO_usrp.USRPReader.setup() |
|
26 | 26 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRF', |
|
27 | 27 | path='/home/jchavez/jicamarca/mocked_data/', |
|
28 | 28 | startDate='2000/07/03', |
|
29 | 29 | endDate='2017/07/03', |
|
30 | 30 | startTime='00:00:00', |
|
31 | 31 | endTime='23:59:59', |
|
32 |
online=0 |
|
|
33 | ippKm = 60) | |
|
32 | online=0) | |
|
34 | 33 | |
|
35 | 34 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', |
|
36 | 35 | inputId=readUnitConfObj.getId()) |
|
37 | 36 | |
|
38 | 37 | # opObj10 = procUnitConfObj0.addOperation(name='selectHeights') |
|
39 | 38 | # opObj10.addParameter(name='minHei', value='0', format='float') |
|
40 | 39 | # opObj10.addParameter(name='maxHei', value='8', format='float') |
|
41 | 40 | |
|
42 | 41 | # opObj10 = procUnitConfObj0.addOperation(name='setH0') |
|
43 | 42 | # opObj10.addParameter(name='h0', value='5.4', format='float') |
|
44 | 43 | |
|
45 | 44 | # opObj10 = procUnitConfObj0.addOperation(name='Decoder', optype='external') |
|
46 | 45 | # opObj10.addParameter(name='code', value='1,-1', format='intlist') |
|
47 | 46 | # opObj10.addParameter(name='nCode', value='2', format='float') |
|
48 | 47 | # opObj10.addParameter(name='nBaud', value='1', format='float') |
|
49 | 48 | |
|
50 | opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external') | |
|
51 | opObj10.addParameter(name='n', value='1', format='float') | |
|
49 | # opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external') | |
|
50 | # opObj10.addParameter(name='n', value='1', format='float') | |
|
52 | 51 | |
|
53 | opObj11 = procUnitConfObj0.addOperation(name='Scope', optype='external') | |
|
54 | opObj11.addParameter(name='id', value='121', format='int') | |
|
55 | opObj11.addParameter(name='wintitle', value='Scope', format='str') | |
|
52 | # opObj11 = procUnitConfObj0.addOperation(name='Scope', optype='external') | |
|
53 | # opObj11.addParameter(name='id', value='121', format='int') | |
|
54 | # opObj11.addParameter(name='wintitle', value='Scope', format='str') | |
|
56 | 55 | |
|
57 | 56 | # procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', |
|
58 | 57 | # inputId=procUnitConfObj0.getId()) |
|
59 | 58 | |
|
60 | 59 | # #Creating a processing object with its parameters |
|
61 | 60 | # #schainpy.model.proc.jroproc_spectra.SpectraProc.run() |
|
62 | 61 | # #If you need to add more parameters can use the "addParameter method" |
|
63 | 62 | # procUnitConfObj1.addParameter(name='nFFTPoints', value='8', format='int') |
|
64 | 63 | # procUnitConfObj1.addParameter(name='pairsList', value='(0,1)', format='pairslist') |
|
65 | 64 | |
|
66 | 65 | # opObj10 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') |
|
67 | 66 | # opObj10.addParameter(name='n', value='2', format='float') |
|
68 | 67 | # |
|
69 | 68 | #Using internal methods |
|
70 | 69 | #schainpy.model.proc.jroproc_spectra.SpectraProc.selectChannels() |
|
71 | 70 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
72 | 71 | # opObj10.addParameter(name='channelList', value='0,1', format='intlist') |
|
73 | 72 | |
|
74 | 73 | #Using internal methods |
|
75 | 74 | #schainpy.model.proc.jroproc_spectra.SpectraProc.selectHeights() |
|
76 | 75 | # opObj10 = procUnitConfObj1.addOperation(name='selectHeights') |
|
77 | 76 | # opObj10.addParameter(name='minHei', value='90', format='float') |
|
78 | 77 | # opObj10.addParameter(name='maxHei', value='180', format='float') |
|
79 | 78 | |
|
80 | 79 | #Using external methods (new modules) |
|
81 | 80 | # #schainpy.model.proc.jroproc_spectra.IncohInt.setup() |
|
82 | 81 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') |
|
83 | 82 | # opObj12.addParameter(name='n', value='1', format='int') |
|
84 | 83 | |
|
85 | 84 | #Using external methods (new modules) |
|
86 | 85 | #schainpy.model.graphics.jroplot_spectra.SpectraPlot.setup() |
|
87 | 86 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
88 | 87 | # opObj11.addParameter(name='id', value='11', format='int') |
|
89 | 88 | # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') |
|
90 | 89 | # opObj11.addParameter(name='zmin', value='0', format='int') |
|
91 | 90 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
92 | 91 | # opObj11.addParameter(name='save', value='1', format='int') |
|
93 | 92 | # opObj11.addParameter(name='xmin', value='-20', format='float') |
|
94 | 93 | # opObj11.addParameter(name='xmax', value='20', format='float') |
|
95 | 94 | |
|
96 | 95 | #Using external methods (new modules) |
|
97 | 96 | #schainpy.model.graphics.jroplot_spectra.RTIPlot.setup() |
|
98 | 97 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
99 | 98 | # opObj11.addParameter(name='id', value='30', format='int') |
|
100 | 99 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') |
|
101 | 100 | # # opObj11.addParameter(name='zmin', value='0', format='int') |
|
102 | 101 | # # opObj11.addParameter(name='zmax', value='90', format='int') |
|
103 | 102 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
104 | 103 | # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int') |
|
105 | 104 | # opObj11.addParameter(name='xmin', value='19.5', format='float') |
|
106 | 105 | # opObj11.addParameter(name='xmax', value='20', format='float') |
|
107 | 106 | |
|
108 | 107 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other') |
|
109 | 108 | # opObj11.addParameter(name='id', value='3', format='int') |
|
110 | 109 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') |
|
111 | 110 | # opObj11.addParameter(name='zmin', value='30', format='int') |
|
112 | 111 | # opObj11.addParameter(name='zmax', value='120', format='int') |
|
113 | 112 | # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairslist') |
|
114 | 113 | |
|
115 | 114 | controllerObj.start() |
|
116 | 115 | |
|
117 | 116 | if __name__ == '__main__': |
|
118 | 117 | main() |
General Comments 0
You need to be logged in to leave comments.
Login now