This diff has been collapsed as it changes many lines, (656 lines changed) Show them Hide them | |||||
@@ -0,0 +1,656 | |||||
|
1 | import numpy | |||
|
2 | import time | |||
|
3 | import os | |||
|
4 | import h5py | |||
|
5 | import re | |||
|
6 | ||||
|
7 | from model.data.jrodata import * | |||
|
8 | from model.proc.jroproc_base import ProcessingUnit, Operation | |||
|
9 | from model.io.jroIO_base import * | |||
|
10 | ||||
|
11 | ||||
|
12 | class HDF5Reader(ProcessingUnit): | |||
|
13 | ||||
|
14 | ext = ".hdf5" | |||
|
15 | ||||
|
16 | optchar = "D" | |||
|
17 | ||||
|
18 | timezone = None | |||
|
19 | ||||
|
20 | fileIndex = None | |||
|
21 | ||||
|
22 | blockIndex = None | |||
|
23 | ||||
|
24 | path = None | |||
|
25 | ||||
|
26 | #Hdf5 File | |||
|
27 | ||||
|
28 | fpMetadata = None | |||
|
29 | ||||
|
30 | listMetaname = None | |||
|
31 | ||||
|
32 | listMetadata = None | |||
|
33 | ||||
|
34 | fp = None | |||
|
35 | ||||
|
36 | #dataOut reconstruction | |||
|
37 | ||||
|
38 | ||||
|
39 | dataOut = None | |||
|
40 | ||||
|
41 | nChannels = None #Dimension 0 | |||
|
42 | ||||
|
43 | nPoints = None #Dimension 1, number of Points or Parameters | |||
|
44 | ||||
|
45 | nSamples = None #Dimension 2, number of samples or ranges | |||
|
46 | ||||
|
47 | ||||
|
48 | def __init__(self): | |||
|
49 | ||||
|
50 | return | |||
|
51 | ||||
|
52 | def setup(self,path=None, | |||
|
53 | startDate=None, | |||
|
54 | endDate=None, | |||
|
55 | startTime=datetime.time(0,0,0), | |||
|
56 | endTime=datetime.time(23,59,59), | |||
|
57 | walk=True, | |||
|
58 | timezone='ut', | |||
|
59 | all=0, | |||
|
60 | online=False, | |||
|
61 | ext=None): | |||
|
62 | ||||
|
63 | if ext==None: | |||
|
64 | ext = self.ext | |||
|
65 | self.timezone = timezone | |||
|
66 | # self.all = all | |||
|
67 | # self.online = online | |||
|
68 | self.path = path | |||
|
69 | ||||
|
70 | ||||
|
71 | if not(online): | |||
|
72 | #Busqueda de archivos offline | |||
|
73 | self.__searchFilesOffline(path, startDate, endDate, ext, startTime, endTime, walk) | |||
|
74 | else: | |||
|
75 | self.__searchFilesOnline(path, walk) | |||
|
76 | ||||
|
77 | if not(self.filenameList): | |||
|
78 | print "There is no files into the folder: %s"%(path) | |||
|
79 | sys.exit(-1) | |||
|
80 | ||||
|
81 | # self.__getExpParameters() | |||
|
82 | ||||
|
83 | self.fileIndex = -1 | |||
|
84 | ||||
|
85 | self.__setNextFileOffline() | |||
|
86 | ||||
|
87 | self.__readMetadata() | |||
|
88 | ||||
|
89 | self.blockIndex = 0 | |||
|
90 | ||||
|
91 | return | |||
|
92 | ||||
|
93 | def __searchFilesOffline(self, | |||
|
94 | path, | |||
|
95 | startDate, | |||
|
96 | endDate, | |||
|
97 | ext, | |||
|
98 | startTime=datetime.time(0,0,0), | |||
|
99 | endTime=datetime.time(23,59,59), | |||
|
100 | walk=True): | |||
|
101 | ||||
|
102 | # self.__setParameters(path, startDate, endDate, startTime, endTime, walk) | |||
|
103 | # | |||
|
104 | # self.__checkPath() | |||
|
105 | # | |||
|
106 | # self.__findDataForDates() | |||
|
107 | # | |||
|
108 | # self.__selectDataForTimes() | |||
|
109 | # | |||
|
110 | # for i in range(len(self.filenameList)): | |||
|
111 | # print "%s" %(self.filenameList[i]) | |||
|
112 | ||||
|
113 | pathList = [] | |||
|
114 | ||||
|
115 | if not walk: | |||
|
116 | #pathList.append(path) | |||
|
117 | multi_path = path.split(',') | |||
|
118 | for single_path in multi_path: | |||
|
119 | pathList.append(single_path) | |||
|
120 | ||||
|
121 | else: | |||
|
122 | #dirList = [] | |||
|
123 | multi_path = path.split(',') | |||
|
124 | for single_path in multi_path: | |||
|
125 | dirList = [] | |||
|
126 | for thisPath in os.listdir(single_path): | |||
|
127 | if not os.path.isdir(os.path.join(single_path,thisPath)): | |||
|
128 | continue | |||
|
129 | if not isDoyFolder(thisPath): | |||
|
130 | continue | |||
|
131 | ||||
|
132 | dirList.append(thisPath) | |||
|
133 | ||||
|
134 | if not(dirList): | |||
|
135 | return None, None | |||
|
136 | ||||
|
137 | thisDate = startDate | |||
|
138 | ||||
|
139 | while(thisDate <= endDate): | |||
|
140 | year = thisDate.timetuple().tm_year | |||
|
141 | doy = thisDate.timetuple().tm_yday | |||
|
142 | ||||
|
143 | matchlist = fnmatch.filter(dirList, '?' + '%4.4d%3.3d' % (year,doy) + '*') | |||
|
144 | if len(matchlist) == 0: | |||
|
145 | thisDate += datetime.timedelta(1) | |||
|
146 | continue | |||
|
147 | for match in matchlist: | |||
|
148 | pathList.append(os.path.join(single_path,match)) | |||
|
149 | ||||
|
150 | thisDate += datetime.timedelta(1) | |||
|
151 | ||||
|
152 | if pathList == []: | |||
|
153 | print "Any folder was found for the date range: %s-%s" %(startDate, endDate) | |||
|
154 | return None, None | |||
|
155 | ||||
|
156 | print "%d folder(s) was(were) found for the date range: %s - %s" %(len(pathList), startDate, endDate) | |||
|
157 | ||||
|
158 | filenameList = [] | |||
|
159 | datetimeList = [] | |||
|
160 | pathDict = {} | |||
|
161 | filenameList_to_sort = [] | |||
|
162 | ||||
|
163 | for i in range(len(pathList)): | |||
|
164 | ||||
|
165 | thisPath = pathList[i] | |||
|
166 | ||||
|
167 | fileList = glob.glob1(thisPath, "*%s" %ext) | |||
|
168 | fileList.sort() | |||
|
169 | pathDict.setdefault(fileList[0]) | |||
|
170 | pathDict[fileList[0]] = i | |||
|
171 | filenameList_to_sort.append(fileList[0]) | |||
|
172 | ||||
|
173 | filenameList_to_sort.sort() | |||
|
174 | ||||
|
175 | for file in filenameList_to_sort: | |||
|
176 | thisPath = pathList[pathDict[file]] | |||
|
177 | ||||
|
178 | fileList = glob.glob1(thisPath, "*%s" %ext) | |||
|
179 | fileList.sort() | |||
|
180 | ||||
|
181 | for file in fileList: | |||
|
182 | ||||
|
183 | filename = os.path.join(thisPath,file) | |||
|
184 | thisDatetime = self.__isFileinThisTime(filename, startTime, endTime) | |||
|
185 | ||||
|
186 | if not(thisDatetime): | |||
|
187 | continue | |||
|
188 | ||||
|
189 | filenameList.append(filename) | |||
|
190 | datetimeList.append(thisDatetime) | |||
|
191 | ||||
|
192 | if not(filenameList): | |||
|
193 | print "Any file was found for the time range %s - %s" %(startTime, endTime) | |||
|
194 | return None, None | |||
|
195 | ||||
|
196 | print "%d file(s) was(were) found for the time range: %s - %s" %(len(filenameList), startTime, endTime) | |||
|
197 | ||||
|
198 | ||||
|
199 | for i in range(len(filenameList)): | |||
|
200 | print "%s -> [%s]" %(filenameList[i], datetimeList[i].ctime()) | |||
|
201 | ||||
|
202 | self.filenameList = filenameList | |||
|
203 | self.datetimeList = datetimeList | |||
|
204 | ||||
|
205 | return pathList, filenameList | |||
|
206 | ||||
|
207 | def __isFileinThisTime(self, filename, startTime, endTime): | |||
|
208 | """ | |||
|
209 | Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado. | |||
|
210 | ||||
|
211 | Inputs: | |||
|
212 | filename : nombre completo del archivo de datos en formato Jicamarca (.r) | |||
|
213 | ||||
|
214 | startTime : tiempo inicial del rango seleccionado en formato datetime.time | |||
|
215 | ||||
|
216 | endTime : tiempo final del rango seleccionado en formato datetime.time | |||
|
217 | ||||
|
218 | Return: | |||
|
219 | Boolean : Retorna True si el archivo de datos contiene datos en el rango de | |||
|
220 | fecha especificado, de lo contrario retorna False. | |||
|
221 | ||||
|
222 | Excepciones: | |||
|
223 | Si el archivo no existe o no puede ser abierto | |||
|
224 | Si la cabecera no puede ser leida. | |||
|
225 | ||||
|
226 | """ | |||
|
227 | ||||
|
228 | ||||
|
229 | try: | |||
|
230 | fp = fp = h5py.File(filename,'r') | |||
|
231 | except IOError: | |||
|
232 | traceback.print_exc() | |||
|
233 | raise IOError, "The file %s can't be opened" %(filename) | |||
|
234 | ||||
|
235 | grp = fp['Data'] | |||
|
236 | time = grp['time'] | |||
|
237 | time0 = time[:][0] | |||
|
238 | ||||
|
239 | fp.close() | |||
|
240 | ||||
|
241 | thisDatetime = datetime.datetime.utcfromtimestamp(time0) | |||
|
242 | ||||
|
243 | if self.timezone == 'lt': | |||
|
244 | thisDatetime = thisDatetime - datetime.timedelta(minutes = 300) | |||
|
245 | ||||
|
246 | thisTime = thisDatetime.time() | |||
|
247 | ||||
|
248 | if not ((startTime <= thisTime) and (endTime > thisTime)): | |||
|
249 | return None | |||
|
250 | ||||
|
251 | return thisDatetime | |||
|
252 | ||||
|
253 | def __checkPath(self): | |||
|
254 | if os.path.exists(self.path): | |||
|
255 | self.status = 1 | |||
|
256 | else: | |||
|
257 | self.status = 0 | |||
|
258 | print 'Path:%s does not exists'%self.path | |||
|
259 | ||||
|
260 | return | |||
|
261 | ||||
|
262 | def __setNextFileOffline(self): | |||
|
263 | idFile = self.fileIndex | |||
|
264 | idFile += 1 | |||
|
265 | ||||
|
266 | if not(idFile < len(self.filenameList)): | |||
|
267 | self.flagNoMoreFiles = 1 | |||
|
268 | print "No more Files" | |||
|
269 | return 0 | |||
|
270 | ||||
|
271 | filename = self.filenameList[idFile] | |||
|
272 | ||||
|
273 | filePointer = h5py.File(filename,'r') | |||
|
274 | ||||
|
275 | self.flagIsNewFile = 1 | |||
|
276 | self.fileIndex = idFile | |||
|
277 | self.filename = filename | |||
|
278 | ||||
|
279 | self.fp = filePointer | |||
|
280 | ||||
|
281 | print "Setting the file: %s"%self.filename | |||
|
282 | ||||
|
283 | self.__readMetadata() | |||
|
284 | ||||
|
285 | return 1 | |||
|
286 | ||||
|
287 | def __readMetadata(self): | |||
|
288 | grp = self.fp['Data'] | |||
|
289 | self.pathMeta = os.path.join(self.path, grp.attrs['metadata']) | |||
|
290 | filePointer = h5py.File(self.pathMeta,'r') | |||
|
291 | groupPointer = filePointer['Metadata'] | |||
|
292 | ||||
|
293 | listMetaname = [] | |||
|
294 | listMetadata = [] | |||
|
295 | for item in groupPointer.items(): | |||
|
296 | name = item[0] | |||
|
297 | ||||
|
298 | if name=='data shape': | |||
|
299 | self.nSamples = 1 | |||
|
300 | self.nPoints = 1 | |||
|
301 | self.nChannels = 1 | |||
|
302 | else: | |||
|
303 | data = groupPointer[name][:] | |||
|
304 | listMetaname.append(name) | |||
|
305 | listMetadata.append(data) | |||
|
306 | ||||
|
307 | if name=='type': | |||
|
308 | self.__initDataOut(name) | |||
|
309 | ||||
|
310 | filePointer.close() | |||
|
311 | ||||
|
312 | self.listMetadata = listMetaname | |||
|
313 | self.listMetadata = listMetadata | |||
|
314 | ||||
|
315 | return | |||
|
316 | ||||
|
317 | def __initDataOut(self, type): | |||
|
318 | ||||
|
319 | if 'type'=='Parameters': | |||
|
320 | self.dataOut = Parameters() | |||
|
321 | elif 'type'=='Spectra': | |||
|
322 | self.dataOut = Spectra() | |||
|
323 | elif 'type'=='Voltage': | |||
|
324 | self.dataOut = Voltage() | |||
|
325 | elif 'type'=='Correlation': | |||
|
326 | self.dataOut = Correlation() | |||
|
327 | ||||
|
328 | return | |||
|
329 | ||||
|
330 | def __setDataOut(self): | |||
|
331 | listMetadata = self.listMetadata | |||
|
332 | listMetaname = self.listMetaname | |||
|
333 | listDataname = self.listDataname | |||
|
334 | listData = self.listData | |||
|
335 | ||||
|
336 | blockIndex = self.blockIndex | |||
|
337 | ||||
|
338 | for i in range(len(listMetadata)): | |||
|
339 | setattr(self.dataOut,listMetaname[i],listMetadata[i]) | |||
|
340 | ||||
|
341 | for j in range(len(listData)): | |||
|
342 | setattr(self.dataOut,listDataname[j][blockIndex,:],listData[j][blockIndex,:]) | |||
|
343 | ||||
|
344 | return | |||
|
345 | ||||
|
346 | def getData(self): | |||
|
347 | ||||
|
348 | if self.flagNoMoreFiles: | |||
|
349 | self.dataOut.flagNoData = True | |||
|
350 | print 'Process finished' | |||
|
351 | return 0 | |||
|
352 | ||||
|
353 | if self.__hasNotDataInBuffer(): | |||
|
354 | self.__setNextFile() | |||
|
355 | ||||
|
356 | ||||
|
357 | if self.datablock == None: # setear esta condicion cuando no hayan datos por leers | |||
|
358 | self.dataOut.flagNoData = True | |||
|
359 | return 0 | |||
|
360 | ||||
|
361 | self.__setDataOut() | |||
|
362 | self.dataOut.flagNoData = False | |||
|
363 | ||||
|
364 | self.blockIndex += 1 | |||
|
365 | ||||
|
366 | return self.dataOut.data | |||
|
367 | ||||
|
368 | def run(self, **kwargs): | |||
|
369 | ||||
|
370 | if not(self.isConfig): | |||
|
371 | self.setup(**kwargs) | |||
|
372 | self.setObjProperties() | |||
|
373 | self.isConfig = True | |||
|
374 | ||||
|
375 | self.getData() | |||
|
376 | ||||
|
377 | return | |||
|
378 | ||||
|
379 | class HDF5Writer(Operation): | |||
|
380 | ||||
|
381 | ext = ".hdf5" | |||
|
382 | ||||
|
383 | optchar = "D" | |||
|
384 | ||||
|
385 | metaoptchar = "M" | |||
|
386 | ||||
|
387 | metaFile = None | |||
|
388 | ||||
|
389 | path = None | |||
|
390 | ||||
|
391 | setFile = None | |||
|
392 | ||||
|
393 | fp = None | |||
|
394 | ||||
|
395 | grp = None | |||
|
396 | ||||
|
397 | ds = None | |||
|
398 | ||||
|
399 | firsttime = True | |||
|
400 | ||||
|
401 | #Configurations | |||
|
402 | ||||
|
403 | blocksPerFile = None | |||
|
404 | ||||
|
405 | blockIndex = None | |||
|
406 | ||||
|
407 | dataOut = None | |||
|
408 | ||||
|
409 | #Data Arrays | |||
|
410 | ||||
|
411 | dataList = None | |||
|
412 | ||||
|
413 | metadataList = None | |||
|
414 | ||||
|
415 | dataDim = None | |||
|
416 | ||||
|
417 | def __init__(self): | |||
|
418 | ||||
|
419 | Operation.__init__(self) | |||
|
420 | self.isConfig = False | |||
|
421 | return | |||
|
422 | ||||
|
423 | ||||
|
424 | def setup(self, dataOut, **kwargs): | |||
|
425 | ||||
|
426 | self.path = kwargs['path'] | |||
|
427 | ||||
|
428 | if kwargs.has_key('ext'): | |||
|
429 | self.ext = kwargs['ext'] | |||
|
430 | else: | |||
|
431 | self.blocksPerFile = 10 | |||
|
432 | ||||
|
433 | if kwargs.has_key('blocksPerFile'): | |||
|
434 | self.blocksPerFile = kwargs['blocksPerFile'] | |||
|
435 | else: | |||
|
436 | self.blocksPerFile = 10 | |||
|
437 | ||||
|
438 | self.dataOut = dataOut | |||
|
439 | ||||
|
440 | self.metadataList = ['inputUnit','abscissaRange','heightRange'] | |||
|
441 | ||||
|
442 | self.dataList = ['data_param', 'data_error', 'data_SNR'] | |||
|
443 | ||||
|
444 | self.dataDim = numpy.zeros((len(self.dataList),3)) | |||
|
445 | ||||
|
446 | for i in range(len(self.dataList)): | |||
|
447 | ||||
|
448 | dataDim = getattr(self.dataOut, self.dataList[i]).shape | |||
|
449 | ||||
|
450 | if len(dataDim) == 3: | |||
|
451 | self.dataDim[i,:] = numpy.array(dataDim) | |||
|
452 | else: | |||
|
453 | self.dataDim[i,:-1] = numpy.array(dataDim) | |||
|
454 | self.dataDim[i,-1] = numpy.nan | |||
|
455 | ||||
|
456 | self.blockIndex = 0 | |||
|
457 | ||||
|
458 | return | |||
|
459 | ||||
|
460 | def putMetadata(self): | |||
|
461 | ||||
|
462 | fp = self.createMetadataFile() | |||
|
463 | self.writeMetadata(fp) | |||
|
464 | fp.close() | |||
|
465 | return | |||
|
466 | ||||
|
467 | def createMetadataFile(self): | |||
|
468 | ext = self.ext | |||
|
469 | path = self.path | |||
|
470 | setFile = self.setFile | |||
|
471 | ||||
|
472 | timeTuple = time.localtime(self.dataOut.utctime) | |||
|
473 | subfolder = '' | |||
|
474 | ||||
|
475 | fullpath = os.path.join( path, subfolder ) | |||
|
476 | if not( os.path.exists(fullpath) ): | |||
|
477 | os.mkdir(fullpath) | |||
|
478 | setFile = -1 #inicializo mi contador de seteo | |||
|
479 | else: | |||
|
480 | filesList = os.listdir( fullpath ) | |||
|
481 | if len( filesList ) > 0: | |||
|
482 | filesList = sorted( filesList, key=str.lower ) | |||
|
483 | filen = filesList[-1] | |||
|
484 | # el filename debera tener el siguiente formato | |||
|
485 | # 0 1234 567 89A BCDE (hex) | |||
|
486 | # x YYYY DDD SSS .ext | |||
|
487 | if isNumber( filen[8:11] ): | |||
|
488 | setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file | |||
|
489 | else: | |||
|
490 | setFile = -1 | |||
|
491 | else: | |||
|
492 | setFile = -1 #inicializo mi contador de seteo | |||
|
493 | ||||
|
494 | setFile += 1 | |||
|
495 | ||||
|
496 | file = '%s%4.4d%3.3d%3.3d%s' % (self.metaoptchar, | |||
|
497 | timeTuple.tm_year, | |||
|
498 | timeTuple.tm_yday, | |||
|
499 | setFile, | |||
|
500 | ext ) | |||
|
501 | ||||
|
502 | filename = os.path.join( path, subfolder, file ) | |||
|
503 | self.metaFile = file | |||
|
504 | #Setting HDF5 File | |||
|
505 | fp = h5py.File(filename,'w') | |||
|
506 | ||||
|
507 | return fp | |||
|
508 | ||||
|
509 | def writeMetadata(self, fp): | |||
|
510 | ||||
|
511 | grp = fp.create_group("Metadata") | |||
|
512 | ||||
|
513 | for i in range(len(self.metadataList)): | |||
|
514 | grp.create_dataset(self.metadataList[i], data=getattr(self.dataOut, self.metadataList[i])) | |||
|
515 | return | |||
|
516 | ||||
|
517 | def setNextFile(self): | |||
|
518 | ||||
|
519 | ext = self.ext | |||
|
520 | path = self.path | |||
|
521 | setFile = self.setFile | |||
|
522 | ||||
|
523 | if self.fp != None: | |||
|
524 | self.fp.close() | |||
|
525 | ||||
|
526 | timeTuple = time.localtime(self.dataOut.utctime) | |||
|
527 | subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday) | |||
|
528 | ||||
|
529 | fullpath = os.path.join( path, subfolder ) | |||
|
530 | if not( os.path.exists(fullpath) ): | |||
|
531 | os.mkdir(fullpath) | |||
|
532 | setFile = -1 #inicializo mi contador de seteo | |||
|
533 | else: | |||
|
534 | filesList = os.listdir( fullpath ) | |||
|
535 | if len( filesList ) > 0: | |||
|
536 | filesList = sorted( filesList, key=str.lower ) | |||
|
537 | filen = filesList[-1] | |||
|
538 | # el filename debera tener el siguiente formato | |||
|
539 | # 0 1234 567 89A BCDE (hex) | |||
|
540 | # x YYYY DDD SSS .ext | |||
|
541 | if isNumber( filen[8:11] ): | |||
|
542 | setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file | |||
|
543 | else: | |||
|
544 | setFile = -1 | |||
|
545 | else: | |||
|
546 | setFile = -1 #inicializo mi contador de seteo | |||
|
547 | ||||
|
548 | setFile += 1 | |||
|
549 | ||||
|
550 | file = '%s%4.4d%3.3d%3.3d%s' % (self.optchar, | |||
|
551 | timeTuple.tm_year, | |||
|
552 | timeTuple.tm_yday, | |||
|
553 | setFile, | |||
|
554 | ext ) | |||
|
555 | ||||
|
556 | filename = os.path.join( path, subfolder, file ) | |||
|
557 | ||||
|
558 | #Setting HDF5 File | |||
|
559 | fp = h5py.File(filename,'w') | |||
|
560 | grp = fp.create_group("Data") | |||
|
561 | grp.attrs['metadata'] = self.metaFile | |||
|
562 | ||||
|
563 | ||||
|
564 | ||||
|
565 | ds = [] | |||
|
566 | data = [] | |||
|
567 | ||||
|
568 | for i in range(len(self.dataList)): | |||
|
569 | ||||
|
570 | grp0 = grp.create_group(self.dataList[i]) | |||
|
571 | ||||
|
572 | for j in range(int(self.dataDim[i,0])): | |||
|
573 | tableName = "channel" + str(j) | |||
|
574 | ||||
|
575 | if not(numpy.isnan(self.dataDim[i,2])): | |||
|
576 | ds0 = grp0.create_dataset(tableName, (1,1,1) , chunks = True) | |||
|
577 | else: | |||
|
578 | ds0 = grp0.create_dataset(tableName, (1,1) , chunks = True) | |||
|
579 | ||||
|
580 | ds.append(ds0) | |||
|
581 | data.append([]) | |||
|
582 | ||||
|
583 | ds0 = grp.create_dataset("time", (1,) , chunks = True) | |||
|
584 | ds.append(ds0) | |||
|
585 | data.append([]) | |||
|
586 | ||||
|
587 | #Saving variables | |||
|
588 | print 'Writing the file: %s'%filename | |||
|
589 | self.fp = fp | |||
|
590 | self.grp = grp | |||
|
591 | self.ds = ds | |||
|
592 | self.data = data | |||
|
593 | ||||
|
594 | self.setFile = setFile | |||
|
595 | self.firsttime = True | |||
|
596 | self.blockIndex = 0 | |||
|
597 | return | |||
|
598 | ||||
|
599 | def putData(self): | |||
|
600 | self.setBlock() | |||
|
601 | self.writeBlock() | |||
|
602 | ||||
|
603 | if self.blockIndex == self.blocksPerFile: | |||
|
604 | self.setNextFile() | |||
|
605 | return | |||
|
606 | ||||
|
607 | def setBlock(self): | |||
|
608 | ||||
|
609 | #Creating Arrays | |||
|
610 | data = self.data | |||
|
611 | ind = 0 | |||
|
612 | for i in range(len(self.dataList)): | |||
|
613 | dataAux = getattr(self.dataOut,self.dataList[i]) | |||
|
614 | ||||
|
615 | for j in range(int(self.dataDim[i,0])): | |||
|
616 | data[ind] = dataAux[j,:] | |||
|
617 | if not(numpy.isnan(self.dataDim[i,2])): | |||
|
618 | data[ind] = data[ind].reshape((data[ind].shape[0],data[ind].shape[1],1)) | |||
|
619 | if not self.firsttime: | |||
|
620 | data[ind] = numpy.dstack((self.ds[ind][:], data[ind])) | |||
|
621 | else: | |||
|
622 | data[ind] = data[ind].reshape((1,data[ind].shape[0])) | |||
|
623 | if not self.firsttime: | |||
|
624 | data[ind] = numpy.vstack((self.ds[ind][:], data[ind])) | |||
|
625 | ind += 1 | |||
|
626 | ||||
|
627 | data[ind] = numpy.array([self.dataOut.utctime]) | |||
|
628 | if not self.firsttime: | |||
|
629 | self.data[ind] = numpy.hstack((self.ds[ind][:], self.data[ind])) | |||
|
630 | self.data = data | |||
|
631 | ||||
|
632 | return | |||
|
633 | ||||
|
634 | def writeBlock(self): | |||
|
635 | ||||
|
636 | for i in range(len(self.ds)): | |||
|
637 | self.ds[i].shape = self.data[i].shape | |||
|
638 | self.ds[i][:] = self.data[i] | |||
|
639 | ||||
|
640 | self.blockIndex += 1 | |||
|
641 | ||||
|
642 | self.grp['blocksPerFile'] = self.blockIndex | |||
|
643 | ||||
|
644 | self.firsttime = False | |||
|
645 | return | |||
|
646 | ||||
|
647 | def run(self, dataOut, **kwargs): | |||
|
648 | if not(self.isConfig): | |||
|
649 | self.setup(dataOut, **kwargs) | |||
|
650 | self.isConfig = True | |||
|
651 | self.putMetadata() | |||
|
652 | self.setNextFile() | |||
|
653 | ||||
|
654 | self.putData() | |||
|
655 | return | |||
|
656 |
@@ -0,0 +1,65 | |||||
|
1 | # DIAS 19 Y 20 FEB 2014 | |||
|
2 | # Comprobacion de Resultados DBS con SA | |||
|
3 | ||||
|
4 | import os, sys | |||
|
5 | ||||
|
6 | path = os.path.split(os.getcwd())[0] | |||
|
7 | sys.path.append(path) | |||
|
8 | ||||
|
9 | from controller import * | |||
|
10 | ||||
|
11 | desc = "DBS Experiment Test" | |||
|
12 | filename = "DBStest.xml" | |||
|
13 | ||||
|
14 | controllerObj = Project() | |||
|
15 | ||||
|
16 | controllerObj.setup(id = '191', name='test01', description=desc) | |||
|
17 | ||||
|
18 | #Experimentos | |||
|
19 | ||||
|
20 | path = "/home/soporte/Data/drifts/HDF5" | |||
|
21 | pathFigure = '/home/soporte/workspace/Graficos/drifts/prueba' | |||
|
22 | pathFile = '/home/soporte/Data/drifts/HDF5' | |||
|
23 | ||||
|
24 | xmin = 0 | |||
|
25 | xmax = 24 | |||
|
26 | #------------------------------------------------------------------------------------------------ | |||
|
27 | readUnitConfObj = controllerObj.addReadUnit(datatype='HDF5Reader', | |||
|
28 | path=path, | |||
|
29 | startDate='2012/09/06', | |||
|
30 | endDate='2012/09/06', | |||
|
31 | startTime='00:00:00', | |||
|
32 | endTime='23:59:59', | |||
|
33 | timezone='lt', | |||
|
34 | walk=1) | |||
|
35 | ||||
|
36 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=readUnitConfObj.getId()) | |||
|
37 | #-------------------------------------------------------------------------------------------------- | |||
|
38 | ||||
|
39 | opObj11 = procUnitConfObj0.addOperation(name='EWDriftsEstimation', optype='other') | |||
|
40 | opObj11.addParameter(name='zenith', value='-3.80208,3.10658', format='floatlist') | |||
|
41 | opObj11.addParameter(name='zenithCorrection', value='0.183201', format='float') | |||
|
42 | ||||
|
43 | opObj23 = procUnitConfObj0.addOperation(name='EWDriftsPlot', optype='other') | |||
|
44 | opObj23.addParameter(name='id', value='4', format='int') | |||
|
45 | opObj23.addParameter(name='wintitle', value='EW Drifts', format='str') | |||
|
46 | opObj23.addParameter(name='save', value='1', format='bool') | |||
|
47 | opObj23.addParameter(name='figpath', value = pathFigure, format='str') | |||
|
48 | opObj23.addParameter(name='zminZonal', value='-150', format='int') | |||
|
49 | opObj23.addParameter(name='zmaxZonal', value='150', format='int') | |||
|
50 | opObj23.addParameter(name='zminVertical', value='-30', format='float') | |||
|
51 | opObj23.addParameter(name='zmaxVertical', value='30', format='float') | |||
|
52 | opObj23.addParameter(name='SNR_1', value='1', format='bool') | |||
|
53 | opObj23.addParameter(name='SNRmax', value='5', format='int') | |||
|
54 | # opObj23.addParameter(name='SNRthresh', value='-50', format='float') | |||
|
55 | opObj23.addParameter(name='xmin', value=xmin, format='float') | |||
|
56 | opObj23.addParameter(name='xmax', value=xmax, format='float') | |||
|
57 | #-------------------------------------------------------------------------------------------------- | |||
|
58 | print "Escribiendo el archivo XML" | |||
|
59 | controllerObj.writeXml(filename) | |||
|
60 | print "Leyendo el archivo XML" | |||
|
61 | controllerObj.readXml(filename) | |||
|
62 | ||||
|
63 | controllerObj.createObjects() | |||
|
64 | controllerObj.connectObjects() | |||
|
65 | controllerObj.run() No newline at end of file |
@@ -1,746 +1,756 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on September , 2012 |
|
2 | Created on September , 2012 | |
3 | @author: |
|
3 | @author: | |
4 | ''' |
|
4 | ''' | |
5 | from xml.etree.ElementTree import Element, SubElement, ElementTree |
|
5 | from xml.etree.ElementTree import Element, SubElement, ElementTree | |
6 | from xml.etree import ElementTree as ET |
|
6 | from xml.etree import ElementTree as ET | |
7 | from xml.dom import minidom |
|
7 | from xml.dom import minidom | |
8 |
|
8 | |||
9 | import datetime |
|
9 | import datetime | |
10 | from model import * |
|
10 | from model import * | |
11 |
|
11 | |||
|
12 | import ast | |||
|
13 | ||||
12 | def prettify(elem): |
|
14 | def prettify(elem): | |
13 | """Return a pretty-printed XML string for the Element. |
|
15 | """Return a pretty-printed XML string for the Element. | |
14 | """ |
|
16 | """ | |
15 | rough_string = ET.tostring(elem, 'utf-8') |
|
17 | rough_string = ET.tostring(elem, 'utf-8') | |
16 | reparsed = minidom.parseString(rough_string) |
|
18 | reparsed = minidom.parseString(rough_string) | |
17 | return reparsed.toprettyxml(indent=" ") |
|
19 | return reparsed.toprettyxml(indent=" ") | |
18 |
|
20 | |||
19 | class ParameterConf(): |
|
21 | class ParameterConf(): | |
20 |
|
22 | |||
21 | id = None |
|
23 | id = None | |
22 | name = None |
|
24 | name = None | |
23 | value = None |
|
25 | value = None | |
24 | format = None |
|
26 | format = None | |
25 |
|
27 | |||
26 | __value = None |
|
28 | __value = None | |
27 |
|
29 | |||
28 | ELEMENTNAME = 'Parameter' |
|
30 | ELEMENTNAME = 'Parameter' | |
29 |
|
31 | |||
30 | def __init__(self): |
|
32 | def __init__(self): | |
31 |
|
33 | |||
32 | self.format = 'str' |
|
34 | self.format = 'str' | |
33 |
|
35 | |||
34 | def getElementName(self): |
|
36 | def getElementName(self): | |
35 |
|
37 | |||
36 | return self.ELEMENTNAME |
|
38 | return self.ELEMENTNAME | |
37 |
|
39 | |||
38 | def getValue(self): |
|
40 | def getValue(self): | |
39 |
|
41 | |||
40 | if self.__value != None: |
|
42 | if self.__value != None: | |
41 |
|
43 | |||
42 | return self.__value |
|
44 | return self.__value | |
43 |
|
45 | |||
44 | value = self.value |
|
46 | value = self.value | |
45 |
|
47 | |||
46 | if self.format == 'list': |
|
48 | if self.format == 'list': | |
47 | strList = value.split(',') |
|
49 | strList = value.split(',') | |
48 | return strList |
|
50 | return strList | |
49 |
|
51 | |||
50 | if self.format == 'intlist': |
|
52 | if self.format == 'intlist': | |
51 | strList = value.split(',') |
|
53 | strList = value.split(',') | |
52 | intList = [int(x) for x in strList] |
|
54 | intList = [int(x) for x in strList] | |
53 | return intList |
|
55 | return intList | |
54 |
|
56 | |||
55 | if self.format == 'floatlist': |
|
57 | if self.format == 'floatlist': | |
56 | strList = value.split(',') |
|
58 | strList = value.split(',') | |
57 | floatList = [float(x) for x in strList] |
|
59 | floatList = [float(x) for x in strList] | |
58 | return floatList |
|
60 | return floatList | |
59 |
|
61 | |||
60 | if self.format == 'date': |
|
62 | if self.format == 'date': | |
61 | strList = value.split('/') |
|
63 | strList = value.split('/') | |
62 | intList = [int(x) for x in strList] |
|
64 | intList = [int(x) for x in strList] | |
63 | date = datetime.date(intList[0], intList[1], intList[2]) |
|
65 | date = datetime.date(intList[0], intList[1], intList[2]) | |
64 | return date |
|
66 | return date | |
65 |
|
67 | |||
66 | if self.format == 'time': |
|
68 | if self.format == 'time': | |
67 | strList = value.split(':') |
|
69 | strList = value.split(':') | |
68 | intList = [int(x) for x in strList] |
|
70 | intList = [int(x) for x in strList] | |
69 | time = datetime.time(intList[0], intList[1], intList[2]) |
|
71 | time = datetime.time(intList[0], intList[1], intList[2]) | |
70 | return time |
|
72 | return time | |
71 |
|
73 | |||
72 | if self.format == 'bool': |
|
74 | if self.format == 'bool': | |
73 | value = int(value) |
|
75 | value = int(value) | |
74 |
|
76 | |||
75 | if self.format == 'pairsList': |
|
77 | if self.format == 'pairsList': | |
76 | """ |
|
78 | """ | |
77 | Example: |
|
79 | Example: | |
78 | value = (0,1),(1,2) |
|
80 | value = (0,1),(1,2) | |
79 | """ |
|
81 | """ | |
80 |
|
82 | |||
81 | value = value.replace('(', '') |
|
83 | value = value.replace('(', '') | |
82 | value = value.replace(')', '') |
|
84 | value = value.replace(')', '') | |
83 |
|
85 | |||
84 | strList = value.split(',') |
|
86 | strList = value.split(',') | |
85 | intList = [int(item) for item in strList] |
|
87 | intList = [int(item) for item in strList] | |
86 | pairList = [] |
|
88 | pairList = [] | |
87 | for i in range(len(intList)/2): |
|
89 | for i in range(len(intList)/2): | |
88 | pairList.append((intList[i*2], intList[i*2 + 1])) |
|
90 | pairList.append((intList[i*2], intList[i*2 + 1])) | |
89 |
|
91 | |||
90 | return pairList |
|
92 | return pairList | |
91 |
|
93 | |||
|
94 | if self.format == 'multiList': | |||
|
95 | """ | |||
|
96 | Example: | |||
|
97 | value = (0,1,2),(3,4,5) | |||
|
98 | """ | |||
|
99 | multiList = ast.literal_eval(value) | |||
|
100 | return multiList | |||
|
101 | ||||
92 | func = eval(self.format) |
|
102 | func = eval(self.format) | |
93 |
|
103 | |||
94 | self.__value = func(value) |
|
104 | self.__value = func(value) | |
95 |
|
105 | |||
96 | return self.__value |
|
106 | return self.__value | |
97 |
|
107 | |||
98 | def setup(self, id, name, value, format='str'): |
|
108 | def setup(self, id, name, value, format='str'): | |
99 |
|
109 | |||
100 | self.id = id |
|
110 | self.id = id | |
101 | self.name = name |
|
111 | self.name = name | |
102 | self.value = str(value) |
|
112 | self.value = str(value) | |
103 | self.format = format |
|
113 | self.format = format | |
104 |
|
114 | |||
105 | def makeXml(self, opElement): |
|
115 | def makeXml(self, opElement): | |
106 |
|
116 | |||
107 | parmElement = SubElement(opElement, self.ELEMENTNAME) |
|
117 | parmElement = SubElement(opElement, self.ELEMENTNAME) | |
108 | parmElement.set('id', str(self.id)) |
|
118 | parmElement.set('id', str(self.id)) | |
109 | parmElement.set('name', self.name) |
|
119 | parmElement.set('name', self.name) | |
110 | parmElement.set('value', self.value) |
|
120 | parmElement.set('value', self.value) | |
111 | parmElement.set('format', self.format) |
|
121 | parmElement.set('format', self.format) | |
112 |
|
122 | |||
113 | def readXml(self, parmElement): |
|
123 | def readXml(self, parmElement): | |
114 |
|
124 | |||
115 | self.id = parmElement.get('id') |
|
125 | self.id = parmElement.get('id') | |
116 | self.name = parmElement.get('name') |
|
126 | self.name = parmElement.get('name') | |
117 | self.value = parmElement.get('value') |
|
127 | self.value = parmElement.get('value') | |
118 | self.format = parmElement.get('format') |
|
128 | self.format = parmElement.get('format') | |
119 |
|
129 | |||
120 | def printattr(self): |
|
130 | def printattr(self): | |
121 |
|
131 | |||
122 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) |
|
132 | print "Parameter[%s]: name = %s, value = %s, format = %s" %(self.id, self.name, self.value, self.format) | |
123 |
|
133 | |||
124 | class OperationConf(): |
|
134 | class OperationConf(): | |
125 |
|
135 | |||
126 | id = None |
|
136 | id = None | |
127 | name = None |
|
137 | name = None | |
128 | priority = None |
|
138 | priority = None | |
129 | type = None |
|
139 | type = None | |
130 |
|
140 | |||
131 | parmConfObjList = [] |
|
141 | parmConfObjList = [] | |
132 |
|
142 | |||
133 | ELEMENTNAME = 'Operation' |
|
143 | ELEMENTNAME = 'Operation' | |
134 |
|
144 | |||
135 | def __init__(self): |
|
145 | def __init__(self): | |
136 |
|
146 | |||
137 | id = 0 |
|
147 | id = 0 | |
138 | name = None |
|
148 | name = None | |
139 | priority = None |
|
149 | priority = None | |
140 | type = 'self' |
|
150 | type = 'self' | |
141 |
|
151 | |||
142 |
|
152 | |||
143 | def __getNewId(self): |
|
153 | def __getNewId(self): | |
144 |
|
154 | |||
145 | return int(self.id)*10 + len(self.parmConfObjList) + 1 |
|
155 | return int(self.id)*10 + len(self.parmConfObjList) + 1 | |
146 |
|
156 | |||
147 | def getElementName(self): |
|
157 | def getElementName(self): | |
148 |
|
158 | |||
149 | return self.ELEMENTNAME |
|
159 | return self.ELEMENTNAME | |
150 |
|
160 | |||
151 | def getParameterObjList(self): |
|
161 | def getParameterObjList(self): | |
152 |
|
162 | |||
153 | return self.parmConfObjList |
|
163 | return self.parmConfObjList | |
154 |
|
164 | |||
155 | def setup(self, id, name, priority, type): |
|
165 | def setup(self, id, name, priority, type): | |
156 |
|
166 | |||
157 | self.id = id |
|
167 | self.id = id | |
158 | self.name = name |
|
168 | self.name = name | |
159 | self.type = type |
|
169 | self.type = type | |
160 | self.priority = priority |
|
170 | self.priority = priority | |
161 |
|
171 | |||
162 | self.parmConfObjList = [] |
|
172 | self.parmConfObjList = [] | |
163 |
|
173 | |||
164 | def addParameter(self, name, value, format='str'): |
|
174 | def addParameter(self, name, value, format='str'): | |
165 |
|
175 | |||
166 | id = self.__getNewId() |
|
176 | id = self.__getNewId() | |
167 |
|
177 | |||
168 | parmConfObj = ParameterConf() |
|
178 | parmConfObj = ParameterConf() | |
169 | parmConfObj.setup(id, name, value, format) |
|
179 | parmConfObj.setup(id, name, value, format) | |
170 |
|
180 | |||
171 | self.parmConfObjList.append(parmConfObj) |
|
181 | self.parmConfObjList.append(parmConfObj) | |
172 |
|
182 | |||
173 | return parmConfObj |
|
183 | return parmConfObj | |
174 |
|
184 | |||
175 | def makeXml(self, upElement): |
|
185 | def makeXml(self, upElement): | |
176 |
|
186 | |||
177 | opElement = SubElement(upElement, self.ELEMENTNAME) |
|
187 | opElement = SubElement(upElement, self.ELEMENTNAME) | |
178 | opElement.set('id', str(self.id)) |
|
188 | opElement.set('id', str(self.id)) | |
179 | opElement.set('name', self.name) |
|
189 | opElement.set('name', self.name) | |
180 | opElement.set('type', self.type) |
|
190 | opElement.set('type', self.type) | |
181 | opElement.set('priority', str(self.priority)) |
|
191 | opElement.set('priority', str(self.priority)) | |
182 |
|
192 | |||
183 | for parmConfObj in self.parmConfObjList: |
|
193 | for parmConfObj in self.parmConfObjList: | |
184 | parmConfObj.makeXml(opElement) |
|
194 | parmConfObj.makeXml(opElement) | |
185 |
|
195 | |||
186 | def readXml(self, opElement): |
|
196 | def readXml(self, opElement): | |
187 |
|
197 | |||
188 | self.id = opElement.get('id') |
|
198 | self.id = opElement.get('id') | |
189 | self.name = opElement.get('name') |
|
199 | self.name = opElement.get('name') | |
190 | self.type = opElement.get('type') |
|
200 | self.type = opElement.get('type') | |
191 | self.priority = opElement.get('priority') |
|
201 | self.priority = opElement.get('priority') | |
192 |
|
202 | |||
193 | self.parmConfObjList = [] |
|
203 | self.parmConfObjList = [] | |
194 |
|
204 | |||
195 | parmElementList = opElement.getiterator(ParameterConf().getElementName()) |
|
205 | parmElementList = opElement.getiterator(ParameterConf().getElementName()) | |
196 |
|
206 | |||
197 | for parmElement in parmElementList: |
|
207 | for parmElement in parmElementList: | |
198 | parmConfObj = ParameterConf() |
|
208 | parmConfObj = ParameterConf() | |
199 | parmConfObj.readXml(parmElement) |
|
209 | parmConfObj.readXml(parmElement) | |
200 | self.parmConfObjList.append(parmConfObj) |
|
210 | self.parmConfObjList.append(parmConfObj) | |
201 |
|
211 | |||
202 | def printattr(self): |
|
212 | def printattr(self): | |
203 |
|
213 | |||
204 | print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME, |
|
214 | print "%s[%s]: name = %s, type = %s, priority = %s" %(self.ELEMENTNAME, | |
205 | self.id, |
|
215 | self.id, | |
206 | self.name, |
|
216 | self.name, | |
207 | self.type, |
|
217 | self.type, | |
208 | self.priority) |
|
218 | self.priority) | |
209 |
|
219 | |||
210 | for parmConfObj in self.parmConfObjList: |
|
220 | for parmConfObj in self.parmConfObjList: | |
211 | parmConfObj.printattr() |
|
221 | parmConfObj.printattr() | |
212 |
|
222 | |||
213 | def createObject(self): |
|
223 | def createObject(self): | |
214 |
|
224 | |||
215 | if self.type == 'self': |
|
225 | if self.type == 'self': | |
216 | raise ValueError, "This operation type cannot be created" |
|
226 | raise ValueError, "This operation type cannot be created" | |
217 |
|
227 | |||
218 | if self.type == 'external' or self.type == 'other': |
|
228 | if self.type == 'external' or self.type == 'other': | |
219 | className = eval(self.name) |
|
229 | className = eval(self.name) | |
220 | opObj = className() |
|
230 | opObj = className() | |
221 |
|
231 | |||
222 | return opObj |
|
232 | return opObj | |
223 |
|
233 | |||
224 | class ProcUnitConf(): |
|
234 | class ProcUnitConf(): | |
225 |
|
235 | |||
226 | id = None |
|
236 | id = None | |
227 | name = None |
|
237 | name = None | |
228 | datatype = None |
|
238 | datatype = None | |
229 | inputId = None |
|
239 | inputId = None | |
230 |
|
240 | |||
231 | opConfObjList = [] |
|
241 | opConfObjList = [] | |
232 |
|
242 | |||
233 | procUnitObj = None |
|
243 | procUnitObj = None | |
234 | opObjList = [] |
|
244 | opObjList = [] | |
235 |
|
245 | |||
236 | ELEMENTNAME = 'ProcUnit' |
|
246 | ELEMENTNAME = 'ProcUnit' | |
237 |
|
247 | |||
238 | def __init__(self): |
|
248 | def __init__(self): | |
239 |
|
249 | |||
240 | self.id = None |
|
250 | self.id = None | |
241 | self.datatype = None |
|
251 | self.datatype = None | |
242 | self.name = None |
|
252 | self.name = None | |
243 | self.inputId = None |
|
253 | self.inputId = None | |
244 |
|
254 | |||
245 | self.opConfObjList = [] |
|
255 | self.opConfObjList = [] | |
246 |
|
256 | |||
247 | self.procUnitObj = None |
|
257 | self.procUnitObj = None | |
248 | self.opObjDict = {} |
|
258 | self.opObjDict = {} | |
249 |
|
259 | |||
250 | def __getPriority(self): |
|
260 | def __getPriority(self): | |
251 |
|
261 | |||
252 | return len(self.opConfObjList)+1 |
|
262 | return len(self.opConfObjList)+1 | |
253 |
|
263 | |||
254 | def __getNewId(self): |
|
264 | def __getNewId(self): | |
255 |
|
265 | |||
256 | return int(self.id)*10 + len(self.opConfObjList) + 1 |
|
266 | return int(self.id)*10 + len(self.opConfObjList) + 1 | |
257 |
|
267 | |||
258 | def getElementName(self): |
|
268 | def getElementName(self): | |
259 |
|
269 | |||
260 | return self.ELEMENTNAME |
|
270 | return self.ELEMENTNAME | |
261 |
|
271 | |||
262 | def getId(self): |
|
272 | def getId(self): | |
263 |
|
273 | |||
264 | return str(self.id) |
|
274 | return str(self.id) | |
265 |
|
275 | |||
266 | def getInputId(self): |
|
276 | def getInputId(self): | |
267 |
|
277 | |||
268 | return str(self.inputId) |
|
278 | return str(self.inputId) | |
269 |
|
279 | |||
270 | def getOperationObjList(self): |
|
280 | def getOperationObjList(self): | |
271 |
|
281 | |||
272 | return self.opConfObjList |
|
282 | return self.opConfObjList | |
273 |
|
283 | |||
274 | def getProcUnitObj(self): |
|
284 | def getProcUnitObj(self): | |
275 |
|
285 | |||
276 | return self.procUnitObj |
|
286 | return self.procUnitObj | |
277 |
|
287 | |||
278 | def setup(self, id, name, datatype, inputId): |
|
288 | def setup(self, id, name, datatype, inputId): | |
279 |
|
289 | |||
280 | self.id = id |
|
290 | self.id = id | |
281 | self.name = name |
|
291 | self.name = name | |
282 | self.datatype = datatype |
|
292 | self.datatype = datatype | |
283 | self.inputId = inputId |
|
293 | self.inputId = inputId | |
284 |
|
294 | |||
285 | self.opConfObjList = [] |
|
295 | self.opConfObjList = [] | |
286 |
|
296 | |||
287 | self.addOperation(name='run', optype='self') |
|
297 | self.addOperation(name='run', optype='self') | |
288 |
|
298 | |||
289 | def addParameter(self, **kwargs): |
|
299 | def addParameter(self, **kwargs): | |
290 |
|
300 | |||
291 | opObj = self.opConfObjList[0] |
|
301 | opObj = self.opConfObjList[0] | |
292 |
|
302 | |||
293 | opObj.addParameter(**kwargs) |
|
303 | opObj.addParameter(**kwargs) | |
294 |
|
304 | |||
295 | return opObj |
|
305 | return opObj | |
296 |
|
306 | |||
297 | def addOperation(self, name, optype='self'): |
|
307 | def addOperation(self, name, optype='self'): | |
298 |
|
308 | |||
299 | id = self.__getNewId() |
|
309 | id = self.__getNewId() | |
300 | priority = self.__getPriority() |
|
310 | priority = self.__getPriority() | |
301 |
|
311 | |||
302 | opConfObj = OperationConf() |
|
312 | opConfObj = OperationConf() | |
303 | opConfObj.setup(id, name=name, priority=priority, type=optype) |
|
313 | opConfObj.setup(id, name=name, priority=priority, type=optype) | |
304 |
|
314 | |||
305 | self.opConfObjList.append(opConfObj) |
|
315 | self.opConfObjList.append(opConfObj) | |
306 |
|
316 | |||
307 | return opConfObj |
|
317 | return opConfObj | |
308 |
|
318 | |||
309 | def makeXml(self, procUnitElement): |
|
319 | def makeXml(self, procUnitElement): | |
310 |
|
320 | |||
311 | upElement = SubElement(procUnitElement, self.ELEMENTNAME) |
|
321 | upElement = SubElement(procUnitElement, self.ELEMENTNAME) | |
312 | upElement.set('id', str(self.id)) |
|
322 | upElement.set('id', str(self.id)) | |
313 | upElement.set('name', self.name) |
|
323 | upElement.set('name', self.name) | |
314 | upElement.set('datatype', self.datatype) |
|
324 | upElement.set('datatype', self.datatype) | |
315 | upElement.set('inputId', str(self.inputId)) |
|
325 | upElement.set('inputId', str(self.inputId)) | |
316 |
|
326 | |||
317 | for opConfObj in self.opConfObjList: |
|
327 | for opConfObj in self.opConfObjList: | |
318 | opConfObj.makeXml(upElement) |
|
328 | opConfObj.makeXml(upElement) | |
319 |
|
329 | |||
320 | def readXml(self, upElement): |
|
330 | def readXml(self, upElement): | |
321 |
|
331 | |||
322 | self.id = upElement.get('id') |
|
332 | self.id = upElement.get('id') | |
323 | self.name = upElement.get('name') |
|
333 | self.name = upElement.get('name') | |
324 | self.datatype = upElement.get('datatype') |
|
334 | self.datatype = upElement.get('datatype') | |
325 | self.inputId = upElement.get('inputId') |
|
335 | self.inputId = upElement.get('inputId') | |
326 |
|
336 | |||
327 | self.opConfObjList = [] |
|
337 | self.opConfObjList = [] | |
328 |
|
338 | |||
329 | opElementList = upElement.getiterator(OperationConf().getElementName()) |
|
339 | opElementList = upElement.getiterator(OperationConf().getElementName()) | |
330 |
|
340 | |||
331 | for opElement in opElementList: |
|
341 | for opElement in opElementList: | |
332 | opConfObj = OperationConf() |
|
342 | opConfObj = OperationConf() | |
333 | opConfObj.readXml(opElement) |
|
343 | opConfObj.readXml(opElement) | |
334 | self.opConfObjList.append(opConfObj) |
|
344 | self.opConfObjList.append(opConfObj) | |
335 |
|
345 | |||
336 | def printattr(self): |
|
346 | def printattr(self): | |
337 |
|
347 | |||
338 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, |
|
348 | print "%s[%s]: name = %s, datatype = %s, inputId = %s" %(self.ELEMENTNAME, | |
339 | self.id, |
|
349 | self.id, | |
340 | self.name, |
|
350 | self.name, | |
341 | self.datatype, |
|
351 | self.datatype, | |
342 | self.inputId) |
|
352 | self.inputId) | |
343 |
|
353 | |||
344 | for opConfObj in self.opConfObjList: |
|
354 | for opConfObj in self.opConfObjList: | |
345 | opConfObj.printattr() |
|
355 | opConfObj.printattr() | |
346 |
|
356 | |||
347 | def createObjects(self): |
|
357 | def createObjects(self): | |
348 |
|
358 | |||
349 | className = eval(self.name) |
|
359 | className = eval(self.name) | |
350 | procUnitObj = className() |
|
360 | procUnitObj = className() | |
351 |
|
361 | |||
352 | for opConfObj in self.opConfObjList: |
|
362 | for opConfObj in self.opConfObjList: | |
353 |
|
363 | |||
354 | if opConfObj.type == 'self': |
|
364 | if opConfObj.type == 'self': | |
355 | continue |
|
365 | continue | |
356 |
|
366 | |||
357 | opObj = opConfObj.createObject() |
|
367 | opObj = opConfObj.createObject() | |
358 |
|
368 | |||
359 | self.opObjDict[opConfObj.id] = opObj |
|
369 | self.opObjDict[opConfObj.id] = opObj | |
360 | procUnitObj.addOperation(opObj, opConfObj.id) |
|
370 | procUnitObj.addOperation(opObj, opConfObj.id) | |
361 |
|
371 | |||
362 | self.procUnitObj = procUnitObj |
|
372 | self.procUnitObj = procUnitObj | |
363 |
|
373 | |||
364 | return procUnitObj |
|
374 | return procUnitObj | |
365 |
|
375 | |||
366 | def run(self): |
|
376 | def run(self): | |
367 |
|
377 | |||
368 | finalSts = False |
|
378 | finalSts = False | |
369 |
|
379 | |||
370 | for opConfObj in self.opConfObjList: |
|
380 | for opConfObj in self.opConfObjList: | |
371 |
|
381 | |||
372 | kwargs = {} |
|
382 | kwargs = {} | |
373 | for parmConfObj in opConfObj.getParameterObjList(): |
|
383 | for parmConfObj in opConfObj.getParameterObjList(): | |
374 | kwargs[parmConfObj.name] = parmConfObj.getValue() |
|
384 | kwargs[parmConfObj.name] = parmConfObj.getValue() | |
375 |
|
385 | |||
376 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) |
|
386 | #print "\tRunning the '%s' operation with %s" %(opConfObj.name, opConfObj.id) | |
377 | sts = self.procUnitObj.call(opType = opConfObj.type, |
|
387 | sts = self.procUnitObj.call(opType = opConfObj.type, | |
378 | opName = opConfObj.name, |
|
388 | opName = opConfObj.name, | |
379 | opId = opConfObj.id, |
|
389 | opId = opConfObj.id, | |
380 | **kwargs) |
|
390 | **kwargs) | |
381 | finalSts = finalSts or sts |
|
391 | finalSts = finalSts or sts | |
382 |
|
392 | |||
383 | return finalSts |
|
393 | return finalSts | |
384 |
|
394 | |||
385 | class ReadUnitConf(ProcUnitConf): |
|
395 | class ReadUnitConf(ProcUnitConf): | |
386 |
|
396 | |||
387 | path = None |
|
397 | path = None | |
388 | startDate = None |
|
398 | startDate = None | |
389 | endDate = None |
|
399 | endDate = None | |
390 | startTime = None |
|
400 | startTime = None | |
391 | endTime = None |
|
401 | endTime = None | |
392 |
|
402 | |||
393 | ELEMENTNAME = 'ReadUnit' |
|
403 | ELEMENTNAME = 'ReadUnit' | |
394 |
|
404 | |||
395 | def __init__(self): |
|
405 | def __init__(self): | |
396 |
|
406 | |||
397 | self.id = None |
|
407 | self.id = None | |
398 | self.datatype = None |
|
408 | self.datatype = None | |
399 | self.name = None |
|
409 | self.name = None | |
400 | self.inputId = 0 |
|
410 | self.inputId = 0 | |
401 |
|
411 | |||
402 | self.opConfObjList = [] |
|
412 | self.opConfObjList = [] | |
403 | self.opObjList = [] |
|
413 | self.opObjList = [] | |
404 |
|
414 | |||
405 | def getElementName(self): |
|
415 | def getElementName(self): | |
406 |
|
416 | |||
407 | return self.ELEMENTNAME |
|
417 | return self.ELEMENTNAME | |
408 |
|
418 | |||
409 | def setup(self, id, name, datatype, path="", startDate="", endDate="", startTime="", endTime="", **kwargs): |
|
419 | def setup(self, id, name, datatype, path="", startDate="", endDate="", startTime="", endTime="", **kwargs): | |
410 |
|
420 | |||
411 | self.id = id |
|
421 | self.id = id | |
412 | self.name = name |
|
422 | self.name = name | |
413 | self.datatype = datatype |
|
423 | self.datatype = datatype | |
414 |
|
424 | |||
415 | self.path = path |
|
425 | self.path = path | |
416 | self.startDate = startDate |
|
426 | self.startDate = startDate | |
417 | self.endDate = endDate |
|
427 | self.endDate = endDate | |
418 | self.startTime = startTime |
|
428 | self.startTime = startTime | |
419 | self.endTime = endTime |
|
429 | self.endTime = endTime | |
420 |
|
430 | |||
421 | self.addRunOperation(**kwargs) |
|
431 | self.addRunOperation(**kwargs) | |
422 |
|
432 | |||
423 | def addRunOperation(self, **kwargs): |
|
433 | def addRunOperation(self, **kwargs): | |
424 |
|
434 | |||
425 | opObj = self.addOperation(name = 'run', optype = 'self') |
|
435 | opObj = self.addOperation(name = 'run', optype = 'self') | |
426 |
|
436 | |||
427 | opObj.addParameter(name='path' , value=self.path, format='str') |
|
437 | opObj.addParameter(name='path' , value=self.path, format='str') | |
428 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') |
|
438 | opObj.addParameter(name='startDate' , value=self.startDate, format='date') | |
429 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') |
|
439 | opObj.addParameter(name='endDate' , value=self.endDate, format='date') | |
430 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') |
|
440 | opObj.addParameter(name='startTime' , value=self.startTime, format='time') | |
431 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') |
|
441 | opObj.addParameter(name='endTime' , value=self.endTime, format='time') | |
432 |
|
442 | |||
433 | for key, value in kwargs.items(): |
|
443 | for key, value in kwargs.items(): | |
434 | opObj.addParameter(name=key, value=value, format=type(value).__name__) |
|
444 | opObj.addParameter(name=key, value=value, format=type(value).__name__) | |
435 |
|
445 | |||
436 | return opObj |
|
446 | return opObj | |
437 |
|
447 | |||
438 |
|
448 | |||
439 | class Project(): |
|
449 | class Project(): | |
440 |
|
450 | |||
441 | id = None |
|
451 | id = None | |
442 | name = None |
|
452 | name = None | |
443 | description = None |
|
453 | description = None | |
444 | # readUnitConfObjList = None |
|
454 | # readUnitConfObjList = None | |
445 | procUnitConfObjDict = None |
|
455 | procUnitConfObjDict = None | |
446 |
|
456 | |||
447 | ELEMENTNAME = 'Project' |
|
457 | ELEMENTNAME = 'Project' | |
448 |
|
458 | |||
449 | def __init__(self): |
|
459 | def __init__(self): | |
450 |
|
460 | |||
451 | self.id = None |
|
461 | self.id = None | |
452 | self.name = None |
|
462 | self.name = None | |
453 | self.description = None |
|
463 | self.description = None | |
454 |
|
464 | |||
455 | # self.readUnitConfObjList = [] |
|
465 | # self.readUnitConfObjList = [] | |
456 | self.procUnitConfObjDict = {} |
|
466 | self.procUnitConfObjDict = {} | |
457 |
|
467 | |||
458 | def __getNewId(self): |
|
468 | def __getNewId(self): | |
459 |
|
469 | |||
460 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 |
|
470 | id = int(self.id)*10 + len(self.procUnitConfObjDict) + 1 | |
461 |
|
471 | |||
462 | return str(id) |
|
472 | return str(id) | |
463 |
|
473 | |||
464 | def getElementName(self): |
|
474 | def getElementName(self): | |
465 |
|
475 | |||
466 | return self.ELEMENTNAME |
|
476 | return self.ELEMENTNAME | |
467 |
|
477 | |||
468 | def setup(self, id, name, description): |
|
478 | def setup(self, id, name, description): | |
469 |
|
479 | |||
470 | self.id = id |
|
480 | self.id = id | |
471 | self.name = name |
|
481 | self.name = name | |
472 | self.description = description |
|
482 | self.description = description | |
473 |
|
483 | |||
474 | def addReadUnit(self, datatype, **kwargs): |
|
484 | def addReadUnit(self, datatype, **kwargs): | |
475 |
|
485 | |||
476 | id = self.__getNewId() |
|
486 | id = self.__getNewId() | |
477 | name = '%s' %(datatype) |
|
487 | name = '%s' %(datatype) | |
478 |
|
488 | |||
479 | readUnitConfObj = ReadUnitConf() |
|
489 | readUnitConfObj = ReadUnitConf() | |
480 | readUnitConfObj.setup(id, name, datatype, **kwargs) |
|
490 | readUnitConfObj.setup(id, name, datatype, **kwargs) | |
481 |
|
491 | |||
482 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
492 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
483 |
|
493 | |||
484 | return readUnitConfObj |
|
494 | return readUnitConfObj | |
485 |
|
495 | |||
486 | def addProcUnit(self, datatype, inputId): |
|
496 | def addProcUnit(self, datatype, inputId): | |
487 |
|
497 | |||
488 | id = self.__getNewId() |
|
498 | id = self.__getNewId() | |
489 | name = '%s' %(datatype) |
|
499 | name = '%s' %(datatype) | |
490 |
|
500 | |||
491 | procUnitConfObj = ProcUnitConf() |
|
501 | procUnitConfObj = ProcUnitConf() | |
492 | procUnitConfObj.setup(id, name, datatype, inputId) |
|
502 | procUnitConfObj.setup(id, name, datatype, inputId) | |
493 |
|
503 | |||
494 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
504 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
495 |
|
505 | |||
496 | return procUnitConfObj |
|
506 | return procUnitConfObj | |
497 |
|
507 | |||
498 | def makeXml(self): |
|
508 | def makeXml(self): | |
499 |
|
509 | |||
500 | projectElement = Element('Project') |
|
510 | projectElement = Element('Project') | |
501 | projectElement.set('id', str(self.id)) |
|
511 | projectElement.set('id', str(self.id)) | |
502 | projectElement.set('name', self.name) |
|
512 | projectElement.set('name', self.name) | |
503 | projectElement.set('description', self.description) |
|
513 | projectElement.set('description', self.description) | |
504 |
|
514 | |||
505 | # for readUnitConfObj in self.readUnitConfObjList: |
|
515 | # for readUnitConfObj in self.readUnitConfObjList: | |
506 | # readUnitConfObj.makeXml(projectElement) |
|
516 | # readUnitConfObj.makeXml(projectElement) | |
507 |
|
517 | |||
508 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
518 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
509 | procUnitConfObj.makeXml(projectElement) |
|
519 | procUnitConfObj.makeXml(projectElement) | |
510 |
|
520 | |||
511 | self.projectElement = projectElement |
|
521 | self.projectElement = projectElement | |
512 |
|
522 | |||
513 | def writeXml(self, filename): |
|
523 | def writeXml(self, filename): | |
514 |
|
524 | |||
515 | self.makeXml() |
|
525 | self.makeXml() | |
516 |
|
526 | |||
517 | print prettify(self.projectElement) |
|
527 | print prettify(self.projectElement) | |
518 |
|
528 | |||
519 | ElementTree(self.projectElement).write(filename, method='xml') |
|
529 | ElementTree(self.projectElement).write(filename, method='xml') | |
520 |
|
530 | |||
521 | def readXml(self, filename): |
|
531 | def readXml(self, filename): | |
522 |
|
532 | |||
523 | #tree = ET.parse(filename) |
|
533 | #tree = ET.parse(filename) | |
524 | self.projectElement = None |
|
534 | self.projectElement = None | |
525 | # self.readUnitConfObjList = [] |
|
535 | # self.readUnitConfObjList = [] | |
526 | self.procUnitConfObjDict = {} |
|
536 | self.procUnitConfObjDict = {} | |
527 |
|
537 | |||
528 | self.projectElement = ElementTree().parse(filename) |
|
538 | self.projectElement = ElementTree().parse(filename) | |
529 |
|
539 | |||
530 | self.project = self.projectElement.tag |
|
540 | self.project = self.projectElement.tag | |
531 |
|
541 | |||
532 | self.id = self.projectElement.get('id') |
|
542 | self.id = self.projectElement.get('id') | |
533 | self.name = self.projectElement.get('name') |
|
543 | self.name = self.projectElement.get('name') | |
534 | self.description = self.projectElement.get('description') |
|
544 | self.description = self.projectElement.get('description') | |
535 |
|
545 | |||
536 | readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName()) |
|
546 | readUnitElementList = self.projectElement.getiterator(ReadUnitConf().getElementName()) | |
537 |
|
547 | |||
538 | for readUnitElement in readUnitElementList: |
|
548 | for readUnitElement in readUnitElementList: | |
539 | readUnitConfObj = ReadUnitConf() |
|
549 | readUnitConfObj = ReadUnitConf() | |
540 | readUnitConfObj.readXml(readUnitElement) |
|
550 | readUnitConfObj.readXml(readUnitElement) | |
541 |
|
551 | |||
542 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
552 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
543 |
|
553 | |||
544 | procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName()) |
|
554 | procUnitElementList = self.projectElement.getiterator(ProcUnitConf().getElementName()) | |
545 |
|
555 | |||
546 | for procUnitElement in procUnitElementList: |
|
556 | for procUnitElement in procUnitElementList: | |
547 | procUnitConfObj = ProcUnitConf() |
|
557 | procUnitConfObj = ProcUnitConf() | |
548 | procUnitConfObj.readXml(procUnitElement) |
|
558 | procUnitConfObj.readXml(procUnitElement) | |
549 |
|
559 | |||
550 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
560 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
551 |
|
561 | |||
552 | def printattr(self): |
|
562 | def printattr(self): | |
553 |
|
563 | |||
554 | print "Project[%s]: name = %s, description = %s" %(self.id, |
|
564 | print "Project[%s]: name = %s, description = %s" %(self.id, | |
555 | self.name, |
|
565 | self.name, | |
556 | self.description) |
|
566 | self.description) | |
557 |
|
567 | |||
558 | # for readUnitConfObj in self.readUnitConfObjList: |
|
568 | # for readUnitConfObj in self.readUnitConfObjList: | |
559 | # readUnitConfObj.printattr() |
|
569 | # readUnitConfObj.printattr() | |
560 |
|
570 | |||
561 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
571 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
562 | procUnitConfObj.printattr() |
|
572 | procUnitConfObj.printattr() | |
563 |
|
573 | |||
564 | def createObjects(self): |
|
574 | def createObjects(self): | |
565 |
|
575 | |||
566 | # for readUnitConfObj in self.readUnitConfObjList: |
|
576 | # for readUnitConfObj in self.readUnitConfObjList: | |
567 | # readUnitConfObj.createObjects() |
|
577 | # readUnitConfObj.createObjects() | |
568 |
|
578 | |||
569 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
579 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
570 | procUnitConfObj.createObjects() |
|
580 | procUnitConfObj.createObjects() | |
571 |
|
581 | |||
572 | def __connect(self, objIN, thisObj): |
|
582 | def __connect(self, objIN, thisObj): | |
573 |
|
583 | |||
574 | thisObj.setInput(objIN.getOutputObj()) |
|
584 | thisObj.setInput(objIN.getOutputObj()) | |
575 |
|
585 | |||
576 | def connectObjects(self): |
|
586 | def connectObjects(self): | |
577 |
|
587 | |||
578 | for thisPUConfObj in self.procUnitConfObjDict.values(): |
|
588 | for thisPUConfObj in self.procUnitConfObjDict.values(): | |
579 |
|
589 | |||
580 | inputId = thisPUConfObj.getInputId() |
|
590 | inputId = thisPUConfObj.getInputId() | |
581 |
|
591 | |||
582 | if int(inputId) == 0: |
|
592 | if int(inputId) == 0: | |
583 | continue |
|
593 | continue | |
584 |
|
594 | |||
585 | #Get input object |
|
595 | #Get input object | |
586 | puConfINObj = self.procUnitConfObjDict[inputId] |
|
596 | puConfINObj = self.procUnitConfObjDict[inputId] | |
587 | puObjIN = puConfINObj.getProcUnitObj() |
|
597 | puObjIN = puConfINObj.getProcUnitObj() | |
588 |
|
598 | |||
589 | #Get current object |
|
599 | #Get current object | |
590 | thisPUObj = thisPUConfObj.getProcUnitObj() |
|
600 | thisPUObj = thisPUConfObj.getProcUnitObj() | |
591 |
|
601 | |||
592 | self.__connect(puObjIN, thisPUObj) |
|
602 | self.__connect(puObjIN, thisPUObj) | |
593 |
|
603 | |||
594 | def run(self): |
|
604 | def run(self): | |
595 |
|
605 | |||
596 | # for readUnitConfObj in self.readUnitConfObjList: |
|
606 | # for readUnitConfObj in self.readUnitConfObjList: | |
597 | # readUnitConfObj.run() |
|
607 | # readUnitConfObj.run() | |
598 |
|
608 | |||
599 | while(True): |
|
609 | while(True): | |
600 |
|
610 | |||
601 | finalSts = False |
|
611 | finalSts = False | |
602 |
|
612 | |||
603 | for procUnitConfObj in self.procUnitConfObjDict.values(): |
|
613 | for procUnitConfObj in self.procUnitConfObjDict.values(): | |
604 | #print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) |
|
614 | #print "Running the '%s' process with %s" %(procUnitConfObj.name, procUnitConfObj.id) | |
605 | sts = procUnitConfObj.run() |
|
615 | sts = procUnitConfObj.run() | |
606 | finalSts = finalSts or sts |
|
616 | finalSts = finalSts or sts | |
607 |
|
617 | |||
608 | #If every process unit finished so end process |
|
618 | #If every process unit finished so end process | |
609 | if not(finalSts): |
|
619 | if not(finalSts): | |
610 | print "Every process units have finished" |
|
620 | print "Every process units have finished" | |
611 | break |
|
621 | break | |
612 |
|
622 | |||
613 | if __name__ == '__main__': |
|
623 | if __name__ == '__main__': | |
614 |
|
624 | |||
615 | desc = "Segundo Test" |
|
625 | desc = "Segundo Test" | |
616 | filename = "schain.xml" |
|
626 | filename = "schain.xml" | |
617 |
|
627 | |||
618 | controllerObj = Project() |
|
628 | controllerObj = Project() | |
619 |
|
629 | |||
620 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
630 | controllerObj.setup(id = '191', name='test01', description=desc) | |
621 |
|
631 | |||
622 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', |
|
632 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |
623 | path='data/rawdata/', |
|
633 | path='data/rawdata/', | |
624 | startDate='2011/01/01', |
|
634 | startDate='2011/01/01', | |
625 | endDate='2012/12/31', |
|
635 | endDate='2012/12/31', | |
626 | startTime='00:00:00', |
|
636 | startTime='00:00:00', | |
627 | endTime='23:59:59', |
|
637 | endTime='23:59:59', | |
628 | online=1, |
|
638 | online=1, | |
629 | walk=1) |
|
639 | walk=1) | |
630 |
|
640 | |||
631 | # opObj00 = readUnitConfObj.addOperation(name='printInfo') |
|
641 | # opObj00 = readUnitConfObj.addOperation(name='printInfo') | |
632 |
|
642 | |||
633 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
643 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
634 |
|
644 | |||
635 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') |
|
645 | opObj10 = procUnitConfObj0.addOperation(name='selectChannels') | |
636 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') |
|
646 | opObj10.addParameter(name='channelList', value='3,4,5', format='intlist') | |
637 |
|
647 | |||
638 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') |
|
648 | opObj10 = procUnitConfObj0.addOperation(name='selectHeights') | |
639 | opObj10.addParameter(name='minHei', value='90', format='float') |
|
649 | opObj10.addParameter(name='minHei', value='90', format='float') | |
640 | opObj10.addParameter(name='maxHei', value='180', format='float') |
|
650 | opObj10.addParameter(name='maxHei', value='180', format='float') | |
641 |
|
651 | |||
642 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external') |
|
652 | opObj12 = procUnitConfObj0.addOperation(name='CohInt', optype='external') | |
643 | opObj12.addParameter(name='n', value='10', format='int') |
|
653 | opObj12.addParameter(name='n', value='10', format='int') | |
644 |
|
654 | |||
645 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) |
|
655 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |
646 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') |
|
656 | procUnitConfObj1.addParameter(name='nFFTPoints', value='32', format='int') | |
647 | # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='') |
|
657 | # procUnitConfObj1.addParameter(name='pairList', value='(0,1),(0,2),(1,2)', format='') | |
648 |
|
658 | |||
649 |
|
659 | |||
650 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
660 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
651 | opObj11.addParameter(name='idfigure', value='1', format='int') |
|
661 | opObj11.addParameter(name='idfigure', value='1', format='int') | |
652 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') |
|
662 | opObj11.addParameter(name='wintitle', value='SpectraPlot0', format='str') | |
653 | opObj11.addParameter(name='zmin', value='40', format='int') |
|
663 | opObj11.addParameter(name='zmin', value='40', format='int') | |
654 | opObj11.addParameter(name='zmax', value='90', format='int') |
|
664 | opObj11.addParameter(name='zmax', value='90', format='int') | |
655 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
665 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
656 |
|
666 | |||
657 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='external') |
|
667 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='external') | |
658 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
668 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
659 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') |
|
669 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') | |
660 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
670 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
661 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
671 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
662 |
|
672 | |||
663 |
|
673 | |||
664 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Voltage', inputId=procUnitConfObj0.getId()) |
|
674 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Voltage', inputId=procUnitConfObj0.getId()) | |
665 | # |
|
675 | # | |
666 | # opObj12 = procUnitConfObj2.addOperation(name='CohInt', optype='external') |
|
676 | # opObj12 = procUnitConfObj2.addOperation(name='CohInt', optype='external') | |
667 | # opObj12.addParameter(name='n', value='2', format='int') |
|
677 | # opObj12.addParameter(name='n', value='2', format='int') | |
668 | # opObj12.addParameter(name='overlapping', value='1', format='int') |
|
678 | # opObj12.addParameter(name='overlapping', value='1', format='int') | |
669 | # |
|
679 | # | |
670 | # procUnitConfObj3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj2.getId()) |
|
680 | # procUnitConfObj3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj2.getId()) | |
671 | # procUnitConfObj3.addParameter(name='nFFTPoints', value='32', format='int') |
|
681 | # procUnitConfObj3.addParameter(name='nFFTPoints', value='32', format='int') | |
672 | # |
|
682 | # | |
673 | # opObj11 = procUnitConfObj3.addOperation(name='SpectraPlot', optype='external') |
|
683 | # opObj11 = procUnitConfObj3.addOperation(name='SpectraPlot', optype='external') | |
674 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
684 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
675 | # opObj11.addParameter(name='wintitle', value='SpectraPlot1', format='str') |
|
685 | # opObj11.addParameter(name='wintitle', value='SpectraPlot1', format='str') | |
676 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
686 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
677 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
687 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
678 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
688 | # opObj11.addParameter(name='showprofile', value='1', format='int') | |
679 |
|
689 | |||
680 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='external') |
|
690 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='external') | |
681 | # opObj11.addParameter(name='idfigure', value='10', format='int') |
|
691 | # opObj11.addParameter(name='idfigure', value='10', format='int') | |
682 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') |
|
692 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') | |
683 | ## opObj11.addParameter(name='xmin', value='21', format='float') |
|
693 | ## opObj11.addParameter(name='xmin', value='21', format='float') | |
684 | ## opObj11.addParameter(name='xmax', value='22', format='float') |
|
694 | ## opObj11.addParameter(name='xmax', value='22', format='float') | |
685 | # opObj11.addParameter(name='zmin', value='40', format='int') |
|
695 | # opObj11.addParameter(name='zmin', value='40', format='int') | |
686 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
696 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
687 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
697 | # opObj11.addParameter(name='showprofile', value='1', format='int') | |
688 | # opObj11.addParameter(name='timerange', value=str(60), format='int') |
|
698 | # opObj11.addParameter(name='timerange', value=str(60), format='int') | |
689 |
|
699 | |||
690 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
700 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') | |
691 | # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist') |
|
701 | # opObj10.addParameter(name='channelList', value='0,2,4,6', format='intlist') | |
692 | # |
|
702 | # | |
693 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') |
|
703 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') | |
694 | # opObj12.addParameter(name='n', value='2', format='int') |
|
704 | # opObj12.addParameter(name='n', value='2', format='int') | |
695 | # |
|
705 | # | |
696 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
706 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
697 | # opObj11.addParameter(name='idfigure', value='2', format='int') |
|
707 | # opObj11.addParameter(name='idfigure', value='2', format='int') | |
698 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') |
|
708 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') | |
699 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
709 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
700 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
710 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
701 | # |
|
711 | # | |
702 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
712 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') | |
703 | # opObj10.addParameter(name='channelList', value='2,6', format='intlist') |
|
713 | # opObj10.addParameter(name='channelList', value='2,6', format='intlist') | |
704 | # |
|
714 | # | |
705 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') |
|
715 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') | |
706 | # opObj12.addParameter(name='n', value='2', format='int') |
|
716 | # opObj12.addParameter(name='n', value='2', format='int') | |
707 | # |
|
717 | # | |
708 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
718 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
709 | # opObj11.addParameter(name='idfigure', value='3', format='int') |
|
719 | # opObj11.addParameter(name='idfigure', value='3', format='int') | |
710 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') |
|
720 | # opObj11.addParameter(name='wintitle', value='SpectraPlot10', format='str') | |
711 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
721 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
712 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
722 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
713 |
|
723 | |||
714 |
|
724 | |||
715 | # opObj12 = procUnitConfObj1.addOperation(name='decoder') |
|
725 | # opObj12 = procUnitConfObj1.addOperation(name='decoder') | |
716 | # opObj12.addParameter(name='ncode', value='2', format='int') |
|
726 | # opObj12.addParameter(name='ncode', value='2', format='int') | |
717 | # opObj12.addParameter(name='nbauds', value='8', format='int') |
|
727 | # opObj12.addParameter(name='nbauds', value='8', format='int') | |
718 | # opObj12.addParameter(name='code0', value='001110011', format='int') |
|
728 | # opObj12.addParameter(name='code0', value='001110011', format='int') | |
719 | # opObj12.addParameter(name='code1', value='001110011', format='int') |
|
729 | # opObj12.addParameter(name='code1', value='001110011', format='int') | |
720 |
|
730 | |||
721 |
|
731 | |||
722 |
|
732 | |||
723 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) |
|
733 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) | |
724 | # |
|
734 | # | |
725 | # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='external') |
|
735 | # opObj21 = procUnitConfObj2.addOperation(name='IncohInt', optype='external') | |
726 | # opObj21.addParameter(name='n', value='2', format='int') |
|
736 | # opObj21.addParameter(name='n', value='2', format='int') | |
727 | # |
|
737 | # | |
728 | # opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='external') |
|
738 | # opObj11 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='external') | |
729 | # opObj11.addParameter(name='idfigure', value='4', format='int') |
|
739 | # opObj11.addParameter(name='idfigure', value='4', format='int') | |
730 | # opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str') |
|
740 | # opObj11.addParameter(name='wintitle', value='SpectraPlot OBJ 2', format='str') | |
731 | # opObj11.addParameter(name='zmin', value='70', format='int') |
|
741 | # opObj11.addParameter(name='zmin', value='70', format='int') | |
732 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
742 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
733 |
|
743 | |||
734 | print "Escribiendo el archivo XML" |
|
744 | print "Escribiendo el archivo XML" | |
735 |
|
745 | |||
736 | controllerObj.writeXml(filename) |
|
746 | controllerObj.writeXml(filename) | |
737 |
|
747 | |||
738 | print "Leyendo el archivo XML" |
|
748 | print "Leyendo el archivo XML" | |
739 | controllerObj.readXml(filename) |
|
749 | controllerObj.readXml(filename) | |
740 | #controllerObj.printattr() |
|
750 | #controllerObj.printattr() | |
741 |
|
751 | |||
742 | controllerObj.createObjects() |
|
752 | controllerObj.createObjects() | |
743 | controllerObj.connectObjects() |
|
753 | controllerObj.connectObjects() | |
744 | controllerObj.run() |
|
754 | controllerObj.run() | |
745 |
|
755 | |||
746 | No newline at end of file |
|
756 |
@@ -1,983 +1,983 | |||||
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 |
|
12 | |||
13 | def getNumpyDtype(dataTypeCode): |
|
13 | def getNumpyDtype(dataTypeCode): | |
14 |
|
14 | |||
15 | if dataTypeCode == 0: |
|
15 | if dataTypeCode == 0: | |
16 | numpyDtype = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
16 | numpyDtype = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
17 | elif dataTypeCode == 1: |
|
17 | elif dataTypeCode == 1: | |
18 | numpyDtype = numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
18 | numpyDtype = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
19 | elif dataTypeCode == 2: |
|
19 | elif dataTypeCode == 2: | |
20 | numpyDtype = numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
20 | numpyDtype = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
21 | elif dataTypeCode == 3: |
|
21 | elif dataTypeCode == 3: | |
22 | numpyDtype = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
22 | numpyDtype = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
23 | elif dataTypeCode == 4: |
|
23 | elif dataTypeCode == 4: | |
24 | numpyDtype = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
24 | numpyDtype = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
25 | elif dataTypeCode == 5: |
|
25 | elif dataTypeCode == 5: | |
26 | numpyDtype = numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
26 | numpyDtype = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
27 | else: |
|
27 | else: | |
28 | raise ValueError, 'dataTypeCode was not defined' |
|
28 | raise ValueError, 'dataTypeCode was not defined' | |
29 |
|
29 | |||
30 | return numpyDtype |
|
30 | return numpyDtype | |
31 |
|
31 | |||
32 | def getDataTypeCode(numpyDtype): |
|
32 | def getDataTypeCode(numpyDtype): | |
33 |
|
33 | |||
34 | if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]): |
|
34 | if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]): | |
35 | datatype = 0 |
|
35 | datatype = 0 | |
36 | elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]): |
|
36 | elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]): | |
37 | datatype = 1 |
|
37 | datatype = 1 | |
38 | elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]): |
|
38 | elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]): | |
39 | datatype = 2 |
|
39 | datatype = 2 | |
40 | elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]): |
|
40 | elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]): | |
41 | datatype = 3 |
|
41 | datatype = 3 | |
42 | elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]): |
|
42 | elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]): | |
43 | datatype = 4 |
|
43 | datatype = 4 | |
44 | elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]): |
|
44 | elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]): | |
45 | datatype = 5 |
|
45 | datatype = 5 | |
46 | else: |
|
46 | else: | |
47 | datatype = None |
|
47 | datatype = None | |
48 |
|
48 | |||
49 | return datatype |
|
49 | return datatype | |
50 |
|
50 | |||
51 | def hildebrand_sekhon(data, navg): |
|
51 | def hildebrand_sekhon(data, navg): | |
52 |
|
52 | |||
53 | data = data.copy() |
|
53 | data = data.copy() | |
54 |
|
54 | |||
55 | sortdata = numpy.sort(data,axis=None) |
|
55 | sortdata = numpy.sort(data,axis=None) | |
56 | lenOfData = len(sortdata) |
|
56 | lenOfData = len(sortdata) | |
57 | nums_min = lenOfData/10 |
|
57 | nums_min = lenOfData/10 | |
58 |
|
58 | |||
59 | if (lenOfData/10) > 2: |
|
59 | if (lenOfData/10) > 2: | |
60 | nums_min = lenOfData/10 |
|
60 | nums_min = lenOfData/10 | |
61 | else: |
|
61 | else: | |
62 | nums_min = 2 |
|
62 | nums_min = 2 | |
63 |
|
63 | |||
64 | sump = 0. |
|
64 | sump = 0. | |
65 |
|
65 | |||
66 | sumq = 0. |
|
66 | sumq = 0. | |
67 |
|
67 | |||
68 | j = 0 |
|
68 | j = 0 | |
69 |
|
69 | |||
70 | cont = 1 |
|
70 | cont = 1 | |
71 |
|
71 | |||
72 | while((cont==1)and(j<lenOfData)): |
|
72 | while((cont==1)and(j<lenOfData)): | |
73 |
|
73 | |||
74 | sump += sortdata[j] |
|
74 | sump += sortdata[j] | |
75 |
|
75 | |||
76 | sumq += sortdata[j]**2 |
|
76 | sumq += sortdata[j]**2 | |
77 |
|
77 | |||
78 | j += 1 |
|
78 | j += 1 | |
79 |
|
79 | |||
80 | if j > nums_min: |
|
80 | if j > nums_min: | |
81 | rtest = float(j)/(j-1) + 1.0/navg |
|
81 | rtest = float(j)/(j-1) + 1.0/navg | |
82 | if ((sumq*j) > (rtest*sump**2)): |
|
82 | if ((sumq*j) > (rtest*sump**2)): | |
83 | j = j - 1 |
|
83 | j = j - 1 | |
84 | sump = sump - sortdata[j] |
|
84 | sump = sump - sortdata[j] | |
85 | sumq = sumq - sortdata[j]**2 |
|
85 | sumq = sumq - sortdata[j]**2 | |
86 | cont = 0 |
|
86 | cont = 0 | |
87 |
|
87 | |||
88 | lnoise = sump /j |
|
88 | lnoise = sump /j | |
89 | stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1)) |
|
89 | stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1)) | |
90 | return lnoise |
|
90 | return lnoise | |
91 |
|
91 | |||
92 | class Beam: |
|
92 | class Beam: | |
93 | def __init__(self): |
|
93 | def __init__(self): | |
94 | self.codeList = [] |
|
94 | self.codeList = [] | |
95 | self.azimuthList = [] |
|
95 | self.azimuthList = [] | |
96 | self.zenithList = [] |
|
96 | self.zenithList = [] | |
97 |
|
97 | |||
98 | class GenericData(object): |
|
98 | class GenericData(object): | |
99 |
|
99 | |||
100 | flagNoData = True |
|
100 | flagNoData = True | |
101 |
|
101 | |||
102 | def __init__(self): |
|
102 | def __init__(self): | |
103 |
|
103 | |||
104 | raise ValueError, "This class has not been implemented" |
|
104 | raise ValueError, "This class has not been implemented" | |
105 |
|
105 | |||
106 | def copy(self, inputObj=None): |
|
106 | def copy(self, inputObj=None): | |
107 |
|
107 | |||
108 | if inputObj == None: |
|
108 | if inputObj == None: | |
109 | return copy.deepcopy(self) |
|
109 | return copy.deepcopy(self) | |
110 |
|
110 | |||
111 | for key in inputObj.__dict__.keys(): |
|
111 | for key in inputObj.__dict__.keys(): | |
112 | self.__dict__[key] = inputObj.__dict__[key] |
|
112 | self.__dict__[key] = inputObj.__dict__[key] | |
113 |
|
113 | |||
114 | def deepcopy(self): |
|
114 | def deepcopy(self): | |
115 |
|
115 | |||
116 | return copy.deepcopy(self) |
|
116 | return copy.deepcopy(self) | |
117 |
|
117 | |||
118 | def isEmpty(self): |
|
118 | def isEmpty(self): | |
119 |
|
119 | |||
120 | return self.flagNoData |
|
120 | return self.flagNoData | |
121 |
|
121 | |||
122 | class JROData(GenericData): |
|
122 | class JROData(GenericData): | |
123 |
|
123 | |||
124 | # m_BasicHeader = BasicHeader() |
|
124 | # m_BasicHeader = BasicHeader() | |
125 | # m_ProcessingHeader = ProcessingHeader() |
|
125 | # m_ProcessingHeader = ProcessingHeader() | |
126 |
|
126 | |||
127 | systemHeaderObj = SystemHeader() |
|
127 | systemHeaderObj = SystemHeader() | |
128 |
|
128 | |||
129 | radarControllerHeaderObj = RadarControllerHeader() |
|
129 | radarControllerHeaderObj = RadarControllerHeader() | |
130 |
|
130 | |||
131 | # data = None |
|
131 | # data = None | |
132 |
|
132 | |||
133 | type = None |
|
133 | type = None | |
134 |
|
134 | |||
135 | datatype = None #dtype but in string |
|
135 | datatype = None #dtype but in string | |
136 |
|
136 | |||
137 | # dtype = None |
|
137 | # dtype = None | |
138 |
|
138 | |||
139 | # nChannels = None |
|
139 | # nChannels = None | |
140 |
|
140 | |||
141 | # nHeights = None |
|
141 | # nHeights = None | |
142 |
|
142 | |||
143 | nProfiles = None |
|
143 | nProfiles = None | |
144 |
|
144 | |||
145 | heightList = None |
|
145 | heightList = None | |
146 |
|
146 | |||
147 | channelList = None |
|
147 | channelList = None | |
148 |
|
148 | |||
149 | flagTimeBlock = False |
|
149 | flagTimeBlock = False | |
150 |
|
150 | |||
151 | useLocalTime = False |
|
151 | useLocalTime = False | |
152 |
|
152 | |||
153 | utctime = None |
|
153 | utctime = None | |
154 |
|
154 | |||
155 | timeZone = None |
|
155 | timeZone = None | |
156 |
|
156 | |||
157 | dstFlag = None |
|
157 | dstFlag = None | |
158 |
|
158 | |||
159 | errorCount = None |
|
159 | errorCount = None | |
160 |
|
160 | |||
161 | blocksize = None |
|
161 | blocksize = None | |
162 |
|
162 | |||
163 | nCode = None |
|
163 | nCode = None | |
164 |
|
164 | |||
165 | nBaud = None |
|
165 | nBaud = None | |
166 |
|
166 | |||
167 | code = None |
|
167 | code = None | |
168 |
|
168 | |||
169 | flagDecodeData = False #asumo q la data no esta decodificada |
|
169 | flagDecodeData = False #asumo q la data no esta decodificada | |
170 |
|
170 | |||
171 | flagDeflipData = False #asumo q la data no esta sin flip |
|
171 | flagDeflipData = False #asumo q la data no esta sin flip | |
172 |
|
172 | |||
173 | flagShiftFFT = False |
|
173 | flagShiftFFT = False | |
174 |
|
174 | |||
175 | # ippSeconds = None |
|
175 | # ippSeconds = None | |
176 |
|
176 | |||
177 | timeInterval = None |
|
177 | timeInterval = None | |
178 |
|
178 | |||
179 | nCohInt = None |
|
179 | nCohInt = None | |
180 |
|
180 | |||
181 | noise = None |
|
181 | noise = None | |
182 |
|
182 | |||
183 | windowOfFilter = 1 |
|
183 | windowOfFilter = 1 | |
184 |
|
184 | |||
185 | #Speed of ligth |
|
185 | #Speed of ligth | |
186 | C = 3e8 |
|
186 | C = 3e8 | |
187 |
|
187 | |||
188 | frequency = 49.92e6 |
|
188 | frequency = 49.92e6 | |
189 |
|
189 | |||
190 | realtime = False |
|
190 | realtime = False | |
191 |
|
191 | |||
192 | beacon_heiIndexList = None |
|
192 | beacon_heiIndexList = None | |
193 |
|
193 | |||
194 | last_block = None |
|
194 | last_block = None | |
195 |
|
195 | |||
196 | blocknow = None |
|
196 | blocknow = None | |
197 |
|
197 | |||
198 | azimuth = None |
|
198 | azimuth = None | |
199 |
|
199 | |||
200 | zenith = None |
|
200 | zenith = None | |
201 |
|
201 | |||
202 | beam = Beam() |
|
202 | beam = Beam() | |
203 |
|
203 | |||
204 | def __init__(self): |
|
204 | def __init__(self): | |
205 |
|
205 | |||
206 | raise ValueError, "This class has not been implemented" |
|
206 | raise ValueError, "This class has not been implemented" | |
207 |
|
207 | |||
208 | def getNoise(self): |
|
208 | def getNoise(self): | |
209 |
|
209 | |||
210 | raise ValueError, "Not implemented" |
|
210 | raise ValueError, "Not implemented" | |
211 |
|
211 | |||
212 | def getNChannels(self): |
|
212 | def getNChannels(self): | |
213 |
|
213 | |||
214 | return len(self.channelList) |
|
214 | return len(self.channelList) | |
215 |
|
215 | |||
216 | def getChannelIndexList(self): |
|
216 | def getChannelIndexList(self): | |
217 |
|
217 | |||
218 | return range(self.nChannels) |
|
218 | return range(self.nChannels) | |
219 |
|
219 | |||
220 | def getNHeights(self): |
|
220 | def getNHeights(self): | |
221 |
|
221 | |||
222 | return len(self.heightList) |
|
222 | return len(self.heightList) | |
223 |
|
223 | |||
224 | def getHeiRange(self, extrapoints=0): |
|
224 | def getHeiRange(self, extrapoints=0): | |
225 |
|
225 | |||
226 | heis = self.heightList |
|
226 | heis = self.heightList | |
227 | # deltah = self.heightList[1] - self.heightList[0] |
|
227 | # deltah = self.heightList[1] - self.heightList[0] | |
228 | # |
|
228 | # | |
229 | # heis.append(self.heightList[-1]) |
|
229 | # heis.append(self.heightList[-1]) | |
230 |
|
230 | |||
231 | return heis |
|
231 | return heis | |
232 |
|
232 | |||
233 | def getltctime(self): |
|
233 | def getltctime(self): | |
234 |
|
234 | |||
235 | if self.useLocalTime: |
|
235 | if self.useLocalTime: | |
236 | return self.utctime - self.timeZone*60 |
|
236 | return self.utctime - self.timeZone*60 | |
237 |
|
237 | |||
238 | return self.utctime |
|
238 | return self.utctime | |
239 |
|
239 | |||
240 | def getDatatime(self): |
|
240 | def getDatatime(self): | |
241 |
|
241 | |||
242 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
242 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) | |
243 | return datatimeValue |
|
243 | return datatimeValue | |
244 |
|
244 | |||
245 | def getTimeRange(self): |
|
245 | def getTimeRange(self): | |
246 |
|
246 | |||
247 | datatime = [] |
|
247 | datatime = [] | |
248 |
|
248 | |||
249 | datatime.append(self.ltctime) |
|
249 | datatime.append(self.ltctime) | |
250 | datatime.append(self.ltctime + self.timeInterval) |
|
250 | datatime.append(self.ltctime + self.timeInterval) | |
251 |
|
251 | |||
252 | datatime = numpy.array(datatime) |
|
252 | datatime = numpy.array(datatime) | |
253 |
|
253 | |||
254 | return datatime |
|
254 | return datatime | |
255 |
|
255 | |||
256 | def getFmax(self): |
|
256 | def getFmax(self): | |
257 |
|
257 | |||
258 | PRF = 1./(self.ippSeconds * self.nCohInt) |
|
258 | PRF = 1./(self.ippSeconds * self.nCohInt) | |
259 |
|
259 | |||
260 | fmax = PRF/2. |
|
260 | fmax = PRF/2. | |
261 |
|
261 | |||
262 | return fmax |
|
262 | return fmax | |
263 |
|
263 | |||
264 | def getVmax(self): |
|
264 | def getVmax(self): | |
265 |
|
265 | |||
266 | _lambda = self.C/self.frequency |
|
266 | _lambda = self.C/self.frequency | |
267 |
|
267 | |||
268 | vmax = self.getFmax() * _lambda |
|
268 | vmax = self.getFmax() * _lambda | |
269 |
|
269 | |||
270 | return vmax |
|
270 | return vmax | |
271 |
|
271 | |||
272 | def get_ippSeconds(self): |
|
272 | def get_ippSeconds(self): | |
273 | ''' |
|
273 | ''' | |
274 | ''' |
|
274 | ''' | |
275 | return self.radarControllerHeaderObj.ippSeconds |
|
275 | return self.radarControllerHeaderObj.ippSeconds | |
276 |
|
276 | |||
277 | def set_ippSeconds(self, ippSeconds): |
|
277 | def set_ippSeconds(self, ippSeconds): | |
278 | ''' |
|
278 | ''' | |
279 | ''' |
|
279 | ''' | |
280 |
|
280 | |||
281 | self.radarControllerHeaderObj.ippSeconds = ippSeconds |
|
281 | self.radarControllerHeaderObj.ippSeconds = ippSeconds | |
282 |
|
282 | |||
283 | return |
|
283 | return | |
284 |
|
284 | |||
285 | def get_dtype(self): |
|
285 | def get_dtype(self): | |
286 | ''' |
|
286 | ''' | |
287 | ''' |
|
287 | ''' | |
288 | return getNumpyDtype(self.datatype) |
|
288 | return getNumpyDtype(self.datatype) | |
289 |
|
289 | |||
290 | def set_dtype(self, numpyDtype): |
|
290 | def set_dtype(self, numpyDtype): | |
291 | ''' |
|
291 | ''' | |
292 | ''' |
|
292 | ''' | |
293 |
|
293 | |||
294 | self.datatype = getDataTypeCode(numpyDtype) |
|
294 | self.datatype = getDataTypeCode(numpyDtype) | |
295 |
|
295 | |||
296 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
296 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
297 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
297 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") | |
298 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
298 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
299 | #noise = property(getNoise, "I'm the 'nHeights' property.") |
|
299 | #noise = property(getNoise, "I'm the 'nHeights' property.") | |
300 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
300 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
301 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
301 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
302 | ippSeconds = property(get_ippSeconds, set_ippSeconds) |
|
302 | ippSeconds = property(get_ippSeconds, set_ippSeconds) | |
303 | dtype = property(get_dtype, set_dtype) |
|
303 | dtype = property(get_dtype, set_dtype) | |
304 |
|
304 | |||
305 | class Voltage(JROData): |
|
305 | class Voltage(JROData): | |
306 |
|
306 | |||
307 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
307 | #data es un numpy array de 2 dmensiones (canales, alturas) | |
308 | data = None |
|
308 | data = None | |
309 |
|
309 | |||
310 | def __init__(self): |
|
310 | def __init__(self): | |
311 | ''' |
|
311 | ''' | |
312 | Constructor |
|
312 | Constructor | |
313 | ''' |
|
313 | ''' | |
314 |
|
314 | |||
315 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
315 | self.radarControllerHeaderObj = RadarControllerHeader() | |
316 |
|
316 | |||
317 | self.systemHeaderObj = SystemHeader() |
|
317 | self.systemHeaderObj = SystemHeader() | |
318 |
|
318 | |||
319 | self.type = "Voltage" |
|
319 | self.type = "Voltage" | |
320 |
|
320 | |||
321 | self.data = None |
|
321 | self.data = None | |
322 |
|
322 | |||
323 | # self.dtype = None |
|
323 | # self.dtype = None | |
324 |
|
324 | |||
325 | # self.nChannels = 0 |
|
325 | # self.nChannels = 0 | |
326 |
|
326 | |||
327 | # self.nHeights = 0 |
|
327 | # self.nHeights = 0 | |
328 |
|
328 | |||
329 | self.nProfiles = None |
|
329 | self.nProfiles = None | |
330 |
|
330 | |||
331 | self.heightList = None |
|
331 | self.heightList = None | |
332 |
|
332 | |||
333 | self.channelList = None |
|
333 | self.channelList = None | |
334 |
|
334 | |||
335 | # self.channelIndexList = None |
|
335 | # self.channelIndexList = None | |
336 |
|
336 | |||
337 | self.flagNoData = True |
|
337 | self.flagNoData = True | |
338 |
|
338 | |||
339 | self.flagTimeBlock = False |
|
339 | self.flagTimeBlock = False | |
340 |
|
340 | |||
341 | self.utctime = None |
|
341 | self.utctime = None | |
342 |
|
342 | |||
343 | self.timeZone = None |
|
343 | self.timeZone = None | |
344 |
|
344 | |||
345 | self.dstFlag = None |
|
345 | self.dstFlag = None | |
346 |
|
346 | |||
347 | self.errorCount = None |
|
347 | self.errorCount = None | |
348 |
|
348 | |||
349 | self.nCohInt = None |
|
349 | self.nCohInt = None | |
350 |
|
350 | |||
351 | self.blocksize = None |
|
351 | self.blocksize = None | |
352 |
|
352 | |||
353 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
353 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
354 |
|
354 | |||
355 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
355 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
356 |
|
356 | |||
357 | self.flagShiftFFT = False |
|
357 | self.flagShiftFFT = False | |
358 |
|
358 | |||
359 |
|
359 | |||
360 | def getNoisebyHildebrand(self): |
|
360 | def getNoisebyHildebrand(self): | |
361 | """ |
|
361 | """ | |
362 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
362 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
363 |
|
363 | |||
364 | Return: |
|
364 | Return: | |
365 | noiselevel |
|
365 | noiselevel | |
366 | """ |
|
366 | """ | |
367 |
|
367 | |||
368 | for channel in range(self.nChannels): |
|
368 | for channel in range(self.nChannels): | |
369 | daux = self.data_spc[channel,:,:] |
|
369 | daux = self.data_spc[channel,:,:] | |
370 | self.noise[channel] = hildebrand_sekhon(daux, self.nCohInt) |
|
370 | self.noise[channel] = hildebrand_sekhon(daux, self.nCohInt) | |
371 |
|
371 | |||
372 | return self.noise |
|
372 | return self.noise | |
373 |
|
373 | |||
374 | def getNoise(self, type = 1): |
|
374 | def getNoise(self, type = 1): | |
375 |
|
375 | |||
376 | self.noise = numpy.zeros(self.nChannels) |
|
376 | self.noise = numpy.zeros(self.nChannels) | |
377 |
|
377 | |||
378 | if type == 1: |
|
378 | if type == 1: | |
379 | noise = self.getNoisebyHildebrand() |
|
379 | noise = self.getNoisebyHildebrand() | |
380 |
|
380 | |||
381 | return 10*numpy.log10(noise) |
|
381 | return 10*numpy.log10(noise) | |
382 |
|
382 | |||
383 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
383 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
384 |
|
384 | |||
385 | class Spectra(JROData): |
|
385 | class Spectra(JROData): | |
386 |
|
386 | |||
387 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) |
|
387 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) | |
388 | data_spc = None |
|
388 | data_spc = None | |
389 |
|
389 | |||
390 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) |
|
390 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) | |
391 | data_cspc = None |
|
391 | data_cspc = None | |
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_dc = None |
|
394 | data_dc = None | |
395 |
|
395 | |||
396 | nFFTPoints = None |
|
396 | nFFTPoints = None | |
397 |
|
397 | |||
398 | # nPairs = None |
|
398 | # nPairs = None | |
399 |
|
399 | |||
400 | pairsList = None |
|
400 | pairsList = None | |
401 |
|
401 | |||
402 | nIncohInt = None |
|
402 | nIncohInt = None | |
403 |
|
403 | |||
404 | wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia |
|
404 | wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia | |
405 |
|
405 | |||
406 | nCohInt = None #se requiere para determinar el valor de timeInterval |
|
406 | nCohInt = None #se requiere para determinar el valor de timeInterval | |
407 |
|
407 | |||
408 | ippFactor = None |
|
408 | ippFactor = None | |
409 |
|
409 | |||
410 | def __init__(self): |
|
410 | def __init__(self): | |
411 | ''' |
|
411 | ''' | |
412 | Constructor |
|
412 | Constructor | |
413 | ''' |
|
413 | ''' | |
414 |
|
414 | |||
415 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
415 | self.radarControllerHeaderObj = RadarControllerHeader() | |
416 |
|
416 | |||
417 | self.systemHeaderObj = SystemHeader() |
|
417 | self.systemHeaderObj = SystemHeader() | |
418 |
|
418 | |||
419 | self.type = "Spectra" |
|
419 | self.type = "Spectra" | |
420 |
|
420 | |||
421 | # self.data = None |
|
421 | # self.data = None | |
422 |
|
422 | |||
423 | # self.dtype = None |
|
423 | # self.dtype = None | |
424 |
|
424 | |||
425 | # self.nChannels = 0 |
|
425 | # self.nChannels = 0 | |
426 |
|
426 | |||
427 | # self.nHeights = 0 |
|
427 | # self.nHeights = 0 | |
428 |
|
428 | |||
429 | self.nProfiles = None |
|
429 | self.nProfiles = None | |
430 |
|
430 | |||
431 | self.heightList = None |
|
431 | self.heightList = None | |
432 |
|
432 | |||
433 | self.channelList = None |
|
433 | self.channelList = None | |
434 |
|
434 | |||
435 | # self.channelIndexList = None |
|
435 | # self.channelIndexList = None | |
436 |
|
436 | |||
437 | self.pairsList = None |
|
437 | self.pairsList = None | |
438 |
|
438 | |||
439 | self.flagNoData = True |
|
439 | self.flagNoData = True | |
440 |
|
440 | |||
441 | self.flagTimeBlock = False |
|
441 | self.flagTimeBlock = False | |
442 |
|
442 | |||
443 | self.utctime = None |
|
443 | self.utctime = None | |
444 |
|
444 | |||
445 | self.nCohInt = None |
|
445 | self.nCohInt = None | |
446 |
|
446 | |||
447 | self.nIncohInt = None |
|
447 | self.nIncohInt = None | |
448 |
|
448 | |||
449 | self.blocksize = None |
|
449 | self.blocksize = None | |
450 |
|
450 | |||
451 | self.nFFTPoints = None |
|
451 | self.nFFTPoints = None | |
452 |
|
452 | |||
453 | self.wavelength = None |
|
453 | self.wavelength = None | |
454 |
|
454 | |||
455 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
455 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
456 |
|
456 | |||
457 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
457 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
458 |
|
458 | |||
459 | self.flagShiftFFT = False |
|
459 | self.flagShiftFFT = False | |
460 |
|
460 | |||
461 | self.ippFactor = 1 |
|
461 | self.ippFactor = 1 | |
462 |
|
462 | |||
463 | #self.noise = None |
|
463 | #self.noise = None | |
464 |
|
464 | |||
465 | self.beacon_heiIndexList = [] |
|
465 | self.beacon_heiIndexList = [] | |
466 |
|
466 | |||
467 | self.noise_estimation = None |
|
467 | self.noise_estimation = None | |
468 |
|
468 | |||
469 |
|
469 | |||
470 | def getNoisebyHildebrand(self): |
|
470 | def getNoisebyHildebrand(self): | |
471 | """ |
|
471 | """ | |
472 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
472 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
473 |
|
473 | |||
474 | Return: |
|
474 | Return: | |
475 | noiselevel |
|
475 | noiselevel | |
476 | """ |
|
476 | """ | |
477 |
|
477 | |||
478 | noise = numpy.zeros(self.nChannels) |
|
478 | noise = numpy.zeros(self.nChannels) | |
479 | for channel in range(self.nChannels): |
|
479 | for channel in range(self.nChannels): | |
480 | daux = self.data_spc[channel,:,:] |
|
480 | daux = self.data_spc[channel,:,:] | |
481 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) |
|
481 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) | |
482 |
|
482 | |||
483 | return noise |
|
483 | return noise | |
484 |
|
484 | |||
485 | def getNoise(self): |
|
485 | def getNoise(self): | |
486 | if self.noise_estimation != None: |
|
486 | if self.noise_estimation != None: | |
487 | return self.noise_estimation #this was estimated by getNoise Operation defined in jroproc_spectra.py |
|
487 | return self.noise_estimation #this was estimated by getNoise Operation defined in jroproc_spectra.py | |
488 | else: |
|
488 | else: | |
489 | noise = self.getNoisebyHildebrand() |
|
489 | noise = self.getNoisebyHildebrand() | |
490 | return noise |
|
490 | return noise | |
491 |
|
491 | |||
492 |
|
492 | |||
493 | def getFreqRange(self, extrapoints=0): |
|
493 | def getFreqRange(self, extrapoints=0): | |
494 |
|
494 | |||
495 | deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor) |
|
495 | deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor) | |
496 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 |
|
496 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 | |
497 |
|
497 | |||
498 | return freqrange |
|
498 | return freqrange | |
499 |
|
499 | |||
500 | def getVelRange(self, extrapoints=0): |
|
500 | def getVelRange(self, extrapoints=0): | |
501 |
|
501 | |||
502 | deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor) |
|
502 | deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor) | |
503 | velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2 |
|
503 | velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2 | |
504 |
|
504 | |||
505 | return velrange |
|
505 | return velrange | |
506 |
|
506 | |||
507 | def getNPairs(self): |
|
507 | def getNPairs(self): | |
508 |
|
508 | |||
509 | return len(self.pairsList) |
|
509 | return len(self.pairsList) | |
510 |
|
510 | |||
511 | def getPairsIndexList(self): |
|
511 | def getPairsIndexList(self): | |
512 |
|
512 | |||
513 | return range(self.nPairs) |
|
513 | return range(self.nPairs) | |
514 |
|
514 | |||
515 | def getNormFactor(self): |
|
515 | def getNormFactor(self): | |
516 | pwcode = 1 |
|
516 | pwcode = 1 | |
517 | if self.flagDecodeData: |
|
517 | if self.flagDecodeData: | |
518 | pwcode = numpy.sum(self.code[0]**2) |
|
518 | pwcode = numpy.sum(self.code[0]**2) | |
519 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter |
|
519 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
520 | normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter |
|
520 | normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
521 |
|
521 | |||
522 | return normFactor |
|
522 | return normFactor | |
523 |
|
523 | |||
524 | def getFlagCspc(self): |
|
524 | def getFlagCspc(self): | |
525 |
|
525 | |||
526 | if self.data_cspc == None: |
|
526 | if self.data_cspc == None: | |
527 | return True |
|
527 | return True | |
528 |
|
528 | |||
529 | return False |
|
529 | return False | |
530 |
|
530 | |||
531 | def getFlagDc(self): |
|
531 | def getFlagDc(self): | |
532 |
|
532 | |||
533 | if self.data_dc == None: |
|
533 | if self.data_dc == None: | |
534 | return True |
|
534 | return True | |
535 |
|
535 | |||
536 | return False |
|
536 | return False | |
537 |
|
537 | |||
538 | nPairs = property(getNPairs, "I'm the 'nPairs' property.") |
|
538 | nPairs = property(getNPairs, "I'm the 'nPairs' property.") | |
539 | pairsIndexList = property(getPairsIndexList, "I'm the 'pairsIndexList' property.") |
|
539 | pairsIndexList = property(getPairsIndexList, "I'm the 'pairsIndexList' property.") | |
540 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") |
|
540 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") | |
541 | flag_cspc = property(getFlagCspc) |
|
541 | flag_cspc = property(getFlagCspc) | |
542 | flag_dc = property(getFlagDc) |
|
542 | flag_dc = property(getFlagDc) | |
543 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
543 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
544 |
|
544 | |||
545 | class SpectraHeis(Spectra): |
|
545 | class SpectraHeis(Spectra): | |
546 |
|
546 | |||
547 | data_spc = None |
|
547 | data_spc = None | |
548 |
|
548 | |||
549 | data_cspc = None |
|
549 | data_cspc = None | |
550 |
|
550 | |||
551 | data_dc = None |
|
551 | data_dc = None | |
552 |
|
552 | |||
553 | nFFTPoints = None |
|
553 | nFFTPoints = None | |
554 |
|
554 | |||
555 | # nPairs = None |
|
555 | # nPairs = None | |
556 |
|
556 | |||
557 | pairsList = None |
|
557 | pairsList = None | |
558 |
|
558 | |||
559 | nIncohInt = None |
|
559 | nIncohInt = None | |
560 |
|
560 | |||
561 | def __init__(self): |
|
561 | def __init__(self): | |
562 |
|
562 | |||
563 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
563 | self.radarControllerHeaderObj = RadarControllerHeader() | |
564 |
|
564 | |||
565 | self.systemHeaderObj = SystemHeader() |
|
565 | self.systemHeaderObj = SystemHeader() | |
566 |
|
566 | |||
567 | self.type = "SpectraHeis" |
|
567 | self.type = "SpectraHeis" | |
568 |
|
568 | |||
569 | # self.dtype = None |
|
569 | # self.dtype = None | |
570 |
|
570 | |||
571 | # self.nChannels = 0 |
|
571 | # self.nChannels = 0 | |
572 |
|
572 | |||
573 | # self.nHeights = 0 |
|
573 | # self.nHeights = 0 | |
574 |
|
574 | |||
575 | self.nProfiles = None |
|
575 | self.nProfiles = None | |
576 |
|
576 | |||
577 | self.heightList = None |
|
577 | self.heightList = None | |
578 |
|
578 | |||
579 | self.channelList = None |
|
579 | self.channelList = None | |
580 |
|
580 | |||
581 | # self.channelIndexList = None |
|
581 | # self.channelIndexList = None | |
582 |
|
582 | |||
583 | self.flagNoData = True |
|
583 | self.flagNoData = True | |
584 |
|
584 | |||
585 | self.flagTimeBlock = False |
|
585 | self.flagTimeBlock = False | |
586 |
|
586 | |||
587 | # self.nPairs = 0 |
|
587 | # self.nPairs = 0 | |
588 |
|
588 | |||
589 | self.utctime = None |
|
589 | self.utctime = None | |
590 |
|
590 | |||
591 | self.blocksize = None |
|
591 | self.blocksize = None | |
592 |
|
592 | |||
593 | def getNormFactor(self): |
|
593 | def getNormFactor(self): | |
594 | pwcode = 1 |
|
594 | pwcode = 1 | |
595 | if self.flagDecodeData: |
|
595 | if self.flagDecodeData: | |
596 | pwcode = numpy.sum(self.code[0]**2) |
|
596 | pwcode = numpy.sum(self.code[0]**2) | |
597 |
|
597 | |||
598 | normFactor = self.nIncohInt*self.nCohInt*pwcode |
|
598 | normFactor = self.nIncohInt*self.nCohInt*pwcode | |
599 |
|
599 | |||
600 | return normFactor |
|
600 | return normFactor | |
601 |
|
601 | |||
602 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") |
|
602 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") | |
603 |
|
603 | |||
604 | class Fits: |
|
604 | class Fits: | |
605 |
|
605 | |||
606 | heightList = None |
|
606 | heightList = None | |
607 |
|
607 | |||
608 | channelList = None |
|
608 | channelList = None | |
609 |
|
609 | |||
610 | flagNoData = True |
|
610 | flagNoData = True | |
611 |
|
611 | |||
612 | flagTimeBlock = False |
|
612 | flagTimeBlock = False | |
613 |
|
613 | |||
614 | useLocalTime = False |
|
614 | useLocalTime = False | |
615 |
|
615 | |||
616 | utctime = None |
|
616 | utctime = None | |
617 |
|
617 | |||
618 | timeZone = None |
|
618 | timeZone = None | |
619 |
|
619 | |||
620 | # ippSeconds = None |
|
620 | # ippSeconds = None | |
621 |
|
621 | |||
622 | timeInterval = None |
|
622 | timeInterval = None | |
623 |
|
623 | |||
624 | nCohInt = None |
|
624 | nCohInt = None | |
625 |
|
625 | |||
626 | nIncohInt = None |
|
626 | nIncohInt = None | |
627 |
|
627 | |||
628 | noise = None |
|
628 | noise = None | |
629 |
|
629 | |||
630 | windowOfFilter = 1 |
|
630 | windowOfFilter = 1 | |
631 |
|
631 | |||
632 | #Speed of ligth |
|
632 | #Speed of ligth | |
633 | C = 3e8 |
|
633 | C = 3e8 | |
634 |
|
634 | |||
635 | frequency = 49.92e6 |
|
635 | frequency = 49.92e6 | |
636 |
|
636 | |||
637 | realtime = False |
|
637 | realtime = False | |
638 |
|
638 | |||
639 |
|
639 | |||
640 | def __init__(self): |
|
640 | def __init__(self): | |
641 |
|
641 | |||
642 | self.type = "Fits" |
|
642 | self.type = "Fits" | |
643 |
|
643 | |||
644 | self.nProfiles = None |
|
644 | self.nProfiles = None | |
645 |
|
645 | |||
646 | self.heightList = None |
|
646 | self.heightList = None | |
647 |
|
647 | |||
648 | self.channelList = None |
|
648 | self.channelList = None | |
649 |
|
649 | |||
650 | # self.channelIndexList = None |
|
650 | # self.channelIndexList = None | |
651 |
|
651 | |||
652 | self.flagNoData = True |
|
652 | self.flagNoData = True | |
653 |
|
653 | |||
654 | self.utctime = None |
|
654 | self.utctime = None | |
655 |
|
655 | |||
656 | self.nCohInt = None |
|
656 | self.nCohInt = None | |
657 |
|
657 | |||
658 | self.nIncohInt = None |
|
658 | self.nIncohInt = None | |
659 |
|
659 | |||
660 | self.useLocalTime = True |
|
660 | self.useLocalTime = True | |
661 |
|
661 | |||
662 | # self.utctime = None |
|
662 | # self.utctime = None | |
663 | # self.timeZone = None |
|
663 | # self.timeZone = None | |
664 | # self.ltctime = None |
|
664 | # self.ltctime = None | |
665 | # self.timeInterval = None |
|
665 | # self.timeInterval = None | |
666 | # self.header = None |
|
666 | # self.header = None | |
667 | # self.data_header = None |
|
667 | # self.data_header = None | |
668 | # self.data = None |
|
668 | # self.data = None | |
669 | # self.datatime = None |
|
669 | # self.datatime = None | |
670 | # self.flagNoData = False |
|
670 | # self.flagNoData = False | |
671 | # self.expName = '' |
|
671 | # self.expName = '' | |
672 | # self.nChannels = None |
|
672 | # self.nChannels = None | |
673 | # self.nSamples = None |
|
673 | # self.nSamples = None | |
674 | # self.dataBlocksPerFile = None |
|
674 | # self.dataBlocksPerFile = None | |
675 | # self.comments = '' |
|
675 | # self.comments = '' | |
676 | # |
|
676 | # | |
677 |
|
677 | |||
678 |
|
678 | |||
679 | def getltctime(self): |
|
679 | def getltctime(self): | |
680 |
|
680 | |||
681 | if self.useLocalTime: |
|
681 | if self.useLocalTime: | |
682 | return self.utctime - self.timeZone*60 |
|
682 | return self.utctime - self.timeZone*60 | |
683 |
|
683 | |||
684 | return self.utctime |
|
684 | return self.utctime | |
685 |
|
685 | |||
686 | def getDatatime(self): |
|
686 | def getDatatime(self): | |
687 |
|
687 | |||
688 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
688 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) | |
689 | return datatime |
|
689 | return datatime | |
690 |
|
690 | |||
691 | def getTimeRange(self): |
|
691 | def getTimeRange(self): | |
692 |
|
692 | |||
693 | datatime = [] |
|
693 | datatime = [] | |
694 |
|
694 | |||
695 | datatime.append(self.ltctime) |
|
695 | datatime.append(self.ltctime) | |
696 | datatime.append(self.ltctime + self.timeInterval) |
|
696 | datatime.append(self.ltctime + self.timeInterval) | |
697 |
|
697 | |||
698 | datatime = numpy.array(datatime) |
|
698 | datatime = numpy.array(datatime) | |
699 |
|
699 | |||
700 | return datatime |
|
700 | return datatime | |
701 |
|
701 | |||
702 | def getHeiRange(self): |
|
702 | def getHeiRange(self): | |
703 |
|
703 | |||
704 | heis = self.heightList |
|
704 | heis = self.heightList | |
705 |
|
705 | |||
706 | return heis |
|
706 | return heis | |
707 |
|
707 | |||
708 | def isEmpty(self): |
|
708 | def isEmpty(self): | |
709 |
|
709 | |||
710 | return self.flagNoData |
|
710 | return self.flagNoData | |
711 |
|
711 | |||
712 | def getNHeights(self): |
|
712 | def getNHeights(self): | |
713 |
|
713 | |||
714 | return len(self.heightList) |
|
714 | return len(self.heightList) | |
715 |
|
715 | |||
716 | def getNChannels(self): |
|
716 | def getNChannels(self): | |
717 |
|
717 | |||
718 | return len(self.channelList) |
|
718 | return len(self.channelList) | |
719 |
|
719 | |||
720 | def getChannelIndexList(self): |
|
720 | def getChannelIndexList(self): | |
721 |
|
721 | |||
722 | return range(self.nChannels) |
|
722 | return range(self.nChannels) | |
723 |
|
723 | |||
724 | def getNoise(self, type = 1): |
|
724 | def getNoise(self, type = 1): | |
725 |
|
725 | |||
726 | self.noise = numpy.zeros(self.nChannels) |
|
726 | self.noise = numpy.zeros(self.nChannels) | |
727 |
|
727 | |||
728 | if type == 1: |
|
728 | if type == 1: | |
729 | noise = self.getNoisebyHildebrand() |
|
729 | noise = self.getNoisebyHildebrand() | |
730 |
|
730 | |||
731 | if type == 2: |
|
731 | if type == 2: | |
732 | noise = self.getNoisebySort() |
|
732 | noise = self.getNoisebySort() | |
733 |
|
733 | |||
734 | if type == 3: |
|
734 | if type == 3: | |
735 | noise = self.getNoisebyWindow() |
|
735 | noise = self.getNoisebyWindow() | |
736 |
|
736 | |||
737 | return noise |
|
737 | return noise | |
738 |
|
738 | |||
739 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
739 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
740 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
740 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
741 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
741 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
742 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
742 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") | |
743 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
743 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
744 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
744 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
745 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
745 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
746 |
|
746 | |||
747 | class Correlation(JROData): |
|
747 | class Correlation(JROData): | |
748 |
|
748 | |||
749 | noise = None |
|
749 | noise = None | |
750 |
|
750 | |||
751 | SNR = None |
|
751 | SNR = None | |
752 |
|
752 | |||
753 | pairsAutoCorr = None #Pairs of Autocorrelation |
|
753 | pairsAutoCorr = None #Pairs of Autocorrelation | |
754 |
|
754 | |||
755 | #-------------------------------------------------- |
|
755 | #-------------------------------------------------- | |
756 |
|
756 | |||
757 | data_corr = None |
|
757 | data_corr = None | |
758 |
|
758 | |||
759 | data_volt = None |
|
759 | data_volt = None | |
760 |
|
760 | |||
761 | lagT = None # each element value is a profileIndex |
|
761 | lagT = None # each element value is a profileIndex | |
762 |
|
762 | |||
763 | lagR = None # each element value is in km |
|
763 | lagR = None # each element value is in km | |
764 |
|
764 | |||
765 | pairsList = None |
|
765 | pairsList = None | |
766 |
|
766 | |||
767 | calculateVelocity = None |
|
767 | calculateVelocity = None | |
768 |
|
768 | |||
769 | nPoints = None |
|
769 | nPoints = None | |
770 |
|
770 | |||
771 | nAvg = None |
|
771 | nAvg = None | |
772 |
|
772 | |||
773 | bufferSize = None |
|
773 | bufferSize = None | |
774 |
|
774 | |||
775 | def __init__(self): |
|
775 | def __init__(self): | |
776 | ''' |
|
776 | ''' | |
777 | Constructor |
|
777 | Constructor | |
778 | ''' |
|
778 | ''' | |
779 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
779 | self.radarControllerHeaderObj = RadarControllerHeader() | |
780 |
|
780 | |||
781 | self.systemHeaderObj = SystemHeader() |
|
781 | self.systemHeaderObj = SystemHeader() | |
782 |
|
782 | |||
783 | self.type = "Correlation" |
|
783 | self.type = "Correlation" | |
784 |
|
784 | |||
785 | self.data = None |
|
785 | self.data = None | |
786 |
|
786 | |||
787 | self.dtype = None |
|
787 | self.dtype = None | |
788 |
|
788 | |||
789 | self.nProfiles = None |
|
789 | self.nProfiles = None | |
790 |
|
790 | |||
791 | self.heightList = None |
|
791 | self.heightList = None | |
792 |
|
792 | |||
793 | self.channelList = None |
|
793 | self.channelList = None | |
794 |
|
794 | |||
795 | self.flagNoData = True |
|
795 | self.flagNoData = True | |
796 |
|
796 | |||
797 | self.flagTimeBlock = False |
|
797 | self.flagTimeBlock = False | |
798 |
|
798 | |||
799 | self.utctime = None |
|
799 | self.utctime = None | |
800 |
|
800 | |||
801 | self.timeZone = None |
|
801 | self.timeZone = None | |
802 |
|
802 | |||
803 | self.dstFlag = None |
|
803 | self.dstFlag = None | |
804 |
|
804 | |||
805 | self.errorCount = None |
|
805 | self.errorCount = None | |
806 |
|
806 | |||
807 | self.blocksize = None |
|
807 | self.blocksize = None | |
808 |
|
808 | |||
809 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
809 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
810 |
|
810 | |||
811 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
811 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
812 |
|
812 | |||
813 | self.pairsList = None |
|
813 | self.pairsList = None | |
814 |
|
814 | |||
815 | self.nPoints = None |
|
815 | self.nPoints = None | |
816 |
|
816 | |||
817 | def getLagTRange(self, extrapoints=0): |
|
817 | def getLagTRange(self, extrapoints=0): | |
818 |
|
818 | |||
819 | lagTRange = self.lagT |
|
819 | lagTRange = self.lagT | |
820 | diff = lagTRange[1] - lagTRange[0] |
|
820 | diff = lagTRange[1] - lagTRange[0] | |
821 | extra = numpy.arange(1,extrapoints + 1)*diff + lagTRange[-1] |
|
821 | extra = numpy.arange(1,extrapoints + 1)*diff + lagTRange[-1] | |
822 | lagTRange = numpy.hstack((lagTRange, extra)) |
|
822 | lagTRange = numpy.hstack((lagTRange, extra)) | |
823 |
|
823 | |||
824 | return lagTRange |
|
824 | return lagTRange | |
825 |
|
825 | |||
826 | def getLagRRange(self, extrapoints=0): |
|
826 | def getLagRRange(self, extrapoints=0): | |
827 |
|
827 | |||
828 | return self.lagR |
|
828 | return self.lagR | |
829 |
|
829 | |||
830 | def getPairsList(self): |
|
830 | def getPairsList(self): | |
831 |
|
831 | |||
832 | return self.pairsList |
|
832 | return self.pairsList | |
833 |
|
833 | |||
834 | def getCalculateVelocity(self): |
|
834 | def getCalculateVelocity(self): | |
835 |
|
835 | |||
836 | return self.calculateVelocity |
|
836 | return self.calculateVelocity | |
837 |
|
837 | |||
838 | def getNPoints(self): |
|
838 | def getNPoints(self): | |
839 |
|
839 | |||
840 | return self.nPoints |
|
840 | return self.nPoints | |
841 |
|
841 | |||
842 | def getNAvg(self): |
|
842 | def getNAvg(self): | |
843 |
|
843 | |||
844 | return self.nAvg |
|
844 | return self.nAvg | |
845 |
|
845 | |||
846 | def getBufferSize(self): |
|
846 | def getBufferSize(self): | |
847 |
|
847 | |||
848 | return self.bufferSize |
|
848 | return self.bufferSize | |
849 |
|
849 | |||
850 | def getPairsAutoCorr(self): |
|
850 | def getPairsAutoCorr(self): | |
851 | pairsList = self.pairsList |
|
851 | pairsList = self.pairsList | |
852 | pairsAutoCorr = numpy.zeros(self.nChannels, dtype = 'int')*numpy.nan |
|
852 | pairsAutoCorr = numpy.zeros(self.nChannels, dtype = 'int')*numpy.nan | |
853 |
|
853 | |||
854 | for l in range(len(pairsList)): |
|
854 | for l in range(len(pairsList)): | |
855 | firstChannel = pairsList[l][0] |
|
855 | firstChannel = pairsList[l][0] | |
856 | secondChannel = pairsList[l][1] |
|
856 | secondChannel = pairsList[l][1] | |
857 |
|
857 | |||
858 | #Obteniendo pares de Autocorrelacion |
|
858 | #Obteniendo pares de Autocorrelacion | |
859 | if firstChannel == secondChannel: |
|
859 | if firstChannel == secondChannel: | |
860 | pairsAutoCorr[firstChannel] = int(l) |
|
860 | pairsAutoCorr[firstChannel] = int(l) | |
861 |
|
861 | |||
862 | pairsAutoCorr = pairsAutoCorr.astype(int) |
|
862 | pairsAutoCorr = pairsAutoCorr.astype(int) | |
863 |
|
863 | |||
864 | return pairsAutoCorr |
|
864 | return pairsAutoCorr | |
865 |
|
865 | |||
866 | def getNoise(self, mode = 2): |
|
866 | def getNoise(self, mode = 2): | |
867 |
|
867 | |||
868 | indR = numpy.where(self.lagR == 0)[0][0] |
|
868 | indR = numpy.where(self.lagR == 0)[0][0] | |
869 | indT = numpy.where(self.lagT == 0)[0][0] |
|
869 | indT = numpy.where(self.lagT == 0)[0][0] | |
870 |
|
870 | |||
871 | jspectra0 = self.data_corr[:,:,indR,:] |
|
871 | jspectra0 = self.data_corr[:,:,indR,:] | |
872 | jspectra = copy.copy(jspectra0) |
|
872 | jspectra = copy.copy(jspectra0) | |
873 |
|
873 | |||
874 | num_chan = jspectra.shape[0] |
|
874 | num_chan = jspectra.shape[0] | |
875 | num_hei = jspectra.shape[2] |
|
875 | num_hei = jspectra.shape[2] | |
876 |
|
876 | |||
877 | freq_dc = jspectra.shape[1]/2 |
|
877 | freq_dc = jspectra.shape[1]/2 | |
878 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc |
|
878 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc | |
879 |
|
879 | |||
880 | if ind_vel[0]<0: |
|
880 | if ind_vel[0]<0: | |
881 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof |
|
881 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof | |
882 |
|
882 | |||
883 | if mode == 1: |
|
883 | if mode == 1: | |
884 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION |
|
884 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION | |
885 |
|
885 | |||
886 | if mode == 2: |
|
886 | if mode == 2: | |
887 |
|
887 | |||
888 | vel = numpy.array([-2,-1,1,2]) |
|
888 | vel = numpy.array([-2,-1,1,2]) | |
889 | xx = numpy.zeros([4,4]) |
|
889 | xx = numpy.zeros([4,4]) | |
890 |
|
890 | |||
891 | for fil in range(4): |
|
891 | for fil in range(4): | |
892 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) |
|
892 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) | |
893 |
|
893 | |||
894 | xx_inv = numpy.linalg.inv(xx) |
|
894 | xx_inv = numpy.linalg.inv(xx) | |
895 | xx_aux = xx_inv[0,:] |
|
895 | xx_aux = xx_inv[0,:] | |
896 |
|
896 | |||
897 | for ich in range(num_chan): |
|
897 | for ich in range(num_chan): | |
898 | yy = jspectra[ich,ind_vel,:] |
|
898 | yy = jspectra[ich,ind_vel,:] | |
899 | jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy) |
|
899 | jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy) | |
900 |
|
900 | |||
901 | junkid = jspectra[ich,freq_dc,:]<=0 |
|
901 | junkid = jspectra[ich,freq_dc,:]<=0 | |
902 | cjunkid = sum(junkid) |
|
902 | cjunkid = sum(junkid) | |
903 |
|
903 | |||
904 | if cjunkid.any(): |
|
904 | if cjunkid.any(): | |
905 | jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2 |
|
905 | jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2 | |
906 |
|
906 | |||
907 | noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:] |
|
907 | noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:] | |
908 |
|
908 | |||
909 | return noise |
|
909 | return noise | |
910 |
|
910 | |||
911 | # pairsList = property(getPairsList, "I'm the 'pairsList' property.") |
|
911 | # pairsList = property(getPairsList, "I'm the 'pairsList' property.") | |
912 | # nPoints = property(getNPoints, "I'm the 'nPoints' property.") |
|
912 | # nPoints = property(getNPoints, "I'm the 'nPoints' property.") | |
913 | calculateVelocity = property(getCalculateVelocity, "I'm the 'calculateVelocity' property.") |
|
913 | calculateVelocity = property(getCalculateVelocity, "I'm the 'calculateVelocity' property.") | |
914 | nAvg = property(getNAvg, "I'm the 'nAvg' property.") |
|
914 | nAvg = property(getNAvg, "I'm the 'nAvg' property.") | |
915 | bufferSize = property(getBufferSize, "I'm the 'bufferSize' property.") |
|
915 | bufferSize = property(getBufferSize, "I'm the 'bufferSize' property.") | |
916 |
|
916 | |||
917 |
|
917 | |||
918 | class Parameters(JROData): |
|
918 | class Parameters(JROData): | |
919 |
|
919 | |||
920 | #Information from previous data |
|
920 | #Information from previous data | |
921 |
|
921 | |||
922 | inputUnit = None #Type of data to be processed |
|
922 | inputUnit = None #Type of data to be processed | |
923 |
|
923 | |||
924 | operation = None #Type of operation to parametrize |
|
924 | operation = None #Type of operation to parametrize | |
925 |
|
925 | |||
926 | normFactor = None #Normalization Factor |
|
926 | normFactor = None #Normalization Factor | |
927 |
|
927 | |||
928 | groupList = None #List of Pairs, Groups, etc |
|
928 | groupList = None #List of Pairs, Groups, etc | |
929 |
|
929 | |||
930 | #Parameters |
|
930 | #Parameters | |
931 |
|
931 | |||
932 | data_param = None #Parameters obtained |
|
932 | data_param = None #Parameters obtained | |
933 |
|
933 | |||
934 | data_pre = None #Data Pre Parametrization |
|
934 | data_pre = None #Data Pre Parametrization | |
935 |
|
935 | |||
|
936 | data_SNR = None #Signal to Noise Ratio | |||
|
937 | ||||
936 | heightRange = None #Heights |
|
938 | heightRange = None #Heights | |
937 |
|
939 | |||
938 | abscissaRange = None #Abscissa, can be velocities, lags or time |
|
940 | abscissaRange = None #Abscissa, can be velocities, lags or time | |
939 |
|
941 | |||
940 | noise = None #Noise Potency |
|
942 | noise = None #Noise Potency | |
941 |
|
943 | |||
942 | SNR = None #Signal to Noise Ratio |
|
|||
943 |
|
||||
944 | initUtcTime = None #Initial UTC time |
|
944 | initUtcTime = None #Initial UTC time | |
945 |
|
945 | |||
946 | paramInterval = None #Time interval to calculate Parameters in seconds |
|
946 | paramInterval = None #Time interval to calculate Parameters in seconds | |
947 |
|
947 | |||
948 | #Fitting |
|
948 | #Fitting | |
949 |
|
949 | |||
950 | constants = None |
|
950 | data_error = None #Error of the estimation | |
951 |
|
951 | |||
952 |
|
|
952 | constants = None | |
953 |
|
953 | |||
954 | library = None |
|
954 | library = None | |
955 |
|
955 | |||
956 | #Output signal |
|
956 | #Output signal | |
957 |
|
957 | |||
958 | outputInterval = None #Time interval to calculate output signal in seconds |
|
958 | outputInterval = None #Time interval to calculate output signal in seconds | |
959 |
|
959 | |||
960 | data_output = None #Out signal |
|
960 | data_output = None #Out signal | |
961 |
|
961 | |||
962 |
|
962 | |||
963 |
|
963 | |||
964 | def __init__(self): |
|
964 | def __init__(self): | |
965 | ''' |
|
965 | ''' | |
966 | Constructor |
|
966 | Constructor | |
967 | ''' |
|
967 | ''' | |
968 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
968 | self.radarControllerHeaderObj = RadarControllerHeader() | |
969 |
|
969 | |||
970 | self.systemHeaderObj = SystemHeader() |
|
970 | self.systemHeaderObj = SystemHeader() | |
971 |
|
971 | |||
972 | self.type = "Parameters" |
|
972 | self.type = "Parameters" | |
973 |
|
973 | |||
974 | def getTimeRange1(self): |
|
974 | def getTimeRange1(self): | |
975 |
|
975 | |||
976 | datatime = [] |
|
976 | datatime = [] | |
977 |
|
977 | |||
978 | datatime.append(self.initUtcTime) |
|
978 | datatime.append(self.initUtcTime) | |
979 | datatime.append(self.initUtcTime + self.outputInterval - 1) |
|
979 | datatime.append(self.initUtcTime + self.outputInterval - 1) | |
980 |
|
980 | |||
981 | datatime = numpy.array(datatime) |
|
981 | datatime = numpy.array(datatime) | |
982 |
|
982 | |||
983 | return datatime |
|
983 | return datatime |
@@ -1,1178 +1,1178 | |||||
1 | import os |
|
1 | import os | |
2 | import datetime |
|
2 | import datetime | |
3 | import numpy |
|
3 | import numpy | |
4 |
|
4 | |||
5 | from figure import Figure, isRealtime |
|
5 | from figure import Figure, isRealtime | |
6 |
|
6 | |||
7 | class MomentsPlot(Figure): |
|
7 | class MomentsPlot(Figure): | |
8 |
|
8 | |||
9 | isConfig = None |
|
9 | isConfig = None | |
10 | __nsubplots = None |
|
10 | __nsubplots = None | |
11 |
|
11 | |||
12 | WIDTHPROF = None |
|
12 | WIDTHPROF = None | |
13 | HEIGHTPROF = None |
|
13 | HEIGHTPROF = None | |
14 | PREFIX = 'prm' |
|
14 | PREFIX = 'prm' | |
15 |
|
15 | |||
16 | def __init__(self): |
|
16 | def __init__(self): | |
17 |
|
17 | |||
18 | self.isConfig = False |
|
18 | self.isConfig = False | |
19 | self.__nsubplots = 1 |
|
19 | self.__nsubplots = 1 | |
20 |
|
20 | |||
21 | self.WIDTH = 280 |
|
21 | self.WIDTH = 280 | |
22 | self.HEIGHT = 250 |
|
22 | self.HEIGHT = 250 | |
23 | self.WIDTHPROF = 120 |
|
23 | self.WIDTHPROF = 120 | |
24 | self.HEIGHTPROF = 0 |
|
24 | self.HEIGHTPROF = 0 | |
25 | self.counter_imagwr = 0 |
|
25 | self.counter_imagwr = 0 | |
26 |
|
26 | |||
27 | self.PLOT_CODE = 1 |
|
27 | self.PLOT_CODE = 1 | |
28 | self.FTP_WEI = None |
|
28 | self.FTP_WEI = None | |
29 | self.EXP_CODE = None |
|
29 | self.EXP_CODE = None | |
30 | self.SUB_EXP_CODE = None |
|
30 | self.SUB_EXP_CODE = None | |
31 | self.PLOT_POS = None |
|
31 | self.PLOT_POS = None | |
32 |
|
32 | |||
33 | def getSubplots(self): |
|
33 | def getSubplots(self): | |
34 |
|
34 | |||
35 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
35 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
36 | nrow = int(self.nplots*1./ncol + 0.9) |
|
36 | nrow = int(self.nplots*1./ncol + 0.9) | |
37 |
|
37 | |||
38 | return nrow, ncol |
|
38 | return nrow, ncol | |
39 |
|
39 | |||
40 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
40 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
41 |
|
41 | |||
42 | self.__showprofile = showprofile |
|
42 | self.__showprofile = showprofile | |
43 | self.nplots = nplots |
|
43 | self.nplots = nplots | |
44 |
|
44 | |||
45 | ncolspan = 1 |
|
45 | ncolspan = 1 | |
46 | colspan = 1 |
|
46 | colspan = 1 | |
47 | if showprofile: |
|
47 | if showprofile: | |
48 | ncolspan = 3 |
|
48 | ncolspan = 3 | |
49 | colspan = 2 |
|
49 | colspan = 2 | |
50 | self.__nsubplots = 2 |
|
50 | self.__nsubplots = 2 | |
51 |
|
51 | |||
52 | self.createFigure(id = id, |
|
52 | self.createFigure(id = id, | |
53 | wintitle = wintitle, |
|
53 | wintitle = wintitle, | |
54 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
54 | widthplot = self.WIDTH + self.WIDTHPROF, | |
55 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
55 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
56 | show=show) |
|
56 | show=show) | |
57 |
|
57 | |||
58 | nrow, ncol = self.getSubplots() |
|
58 | nrow, ncol = self.getSubplots() | |
59 |
|
59 | |||
60 | counter = 0 |
|
60 | counter = 0 | |
61 | for y in range(nrow): |
|
61 | for y in range(nrow): | |
62 | for x in range(ncol): |
|
62 | for x in range(ncol): | |
63 |
|
63 | |||
64 | if counter >= self.nplots: |
|
64 | if counter >= self.nplots: | |
65 | break |
|
65 | break | |
66 |
|
66 | |||
67 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
67 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
68 |
|
68 | |||
69 | if showprofile: |
|
69 | if showprofile: | |
70 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
70 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
71 |
|
71 | |||
72 | counter += 1 |
|
72 | counter += 1 | |
73 |
|
73 | |||
74 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, |
|
74 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | |
75 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
75 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
76 | save=False, figpath='', figfile=None, show=True, ftp=False, wr_period=1, |
|
76 | save=False, figpath='', figfile=None, show=True, ftp=False, wr_period=1, | |
77 | server=None, folder=None, username=None, password=None, |
|
77 | server=None, folder=None, username=None, password=None, | |
78 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): |
|
78 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): | |
79 |
|
79 | |||
80 | """ |
|
80 | """ | |
81 |
|
81 | |||
82 | Input: |
|
82 | Input: | |
83 | dataOut : |
|
83 | dataOut : | |
84 | id : |
|
84 | id : | |
85 | wintitle : |
|
85 | wintitle : | |
86 | channelList : |
|
86 | channelList : | |
87 | showProfile : |
|
87 | showProfile : | |
88 | xmin : None, |
|
88 | xmin : None, | |
89 | xmax : None, |
|
89 | xmax : None, | |
90 | ymin : None, |
|
90 | ymin : None, | |
91 | ymax : None, |
|
91 | ymax : None, | |
92 | zmin : None, |
|
92 | zmin : None, | |
93 | zmax : None |
|
93 | zmax : None | |
94 | """ |
|
94 | """ | |
95 |
|
95 | |||
96 | if dataOut.flagNoData: |
|
96 | if dataOut.flagNoData: | |
97 | return None |
|
97 | return None | |
98 |
|
98 | |||
99 | if realtime: |
|
99 | if realtime: | |
100 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
100 | if not(isRealtime(utcdatatime = dataOut.utctime)): | |
101 | print 'Skipping this plot function' |
|
101 | print 'Skipping this plot function' | |
102 | return |
|
102 | return | |
103 |
|
103 | |||
104 | if channelList == None: |
|
104 | if channelList == None: | |
105 | channelIndexList = dataOut.channelIndexList |
|
105 | channelIndexList = dataOut.channelIndexList | |
106 | else: |
|
106 | else: | |
107 | channelIndexList = [] |
|
107 | channelIndexList = [] | |
108 | for channel in channelList: |
|
108 | for channel in channelList: | |
109 | if channel not in dataOut.channelList: |
|
109 | if channel not in dataOut.channelList: | |
110 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
110 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
111 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
111 | channelIndexList.append(dataOut.channelList.index(channel)) | |
112 |
|
112 | |||
113 | factor = dataOut.normFactor |
|
113 | factor = dataOut.normFactor | |
114 | x = dataOut.abscissaRange |
|
114 | x = dataOut.abscissaRange | |
115 | y = dataOut.heightRange |
|
115 | y = dataOut.heightRange | |
116 |
|
116 | |||
117 | z = dataOut.data_pre[channelIndexList,:,:]/factor |
|
117 | z = dataOut.data_pre[channelIndexList,:,:]/factor | |
118 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
118 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
119 | avg = numpy.average(z, axis=1) |
|
119 | avg = numpy.average(z, axis=1) | |
120 | noise = dataOut.noise/factor |
|
120 | noise = dataOut.noise/factor | |
121 |
|
121 | |||
122 | zdB = 10*numpy.log10(z) |
|
122 | zdB = 10*numpy.log10(z) | |
123 | avgdB = 10*numpy.log10(avg) |
|
123 | avgdB = 10*numpy.log10(avg) | |
124 | noisedB = 10*numpy.log10(noise) |
|
124 | noisedB = 10*numpy.log10(noise) | |
125 |
|
125 | |||
126 | #thisDatetime = dataOut.datatime |
|
126 | #thisDatetime = dataOut.datatime | |
127 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
127 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
128 | title = wintitle + " Parameters" |
|
128 | title = wintitle + " Parameters" | |
129 | xlabel = "Velocity (m/s)" |
|
129 | xlabel = "Velocity (m/s)" | |
130 | ylabel = "Range (Km)" |
|
130 | ylabel = "Range (Km)" | |
131 |
|
131 | |||
132 | if not self.isConfig: |
|
132 | if not self.isConfig: | |
133 |
|
133 | |||
134 | nplots = len(channelIndexList) |
|
134 | nplots = len(channelIndexList) | |
135 |
|
135 | |||
136 | self.setup(id=id, |
|
136 | self.setup(id=id, | |
137 | nplots=nplots, |
|
137 | nplots=nplots, | |
138 | wintitle=wintitle, |
|
138 | wintitle=wintitle, | |
139 | showprofile=showprofile, |
|
139 | showprofile=showprofile, | |
140 | show=show) |
|
140 | show=show) | |
141 |
|
141 | |||
142 | if xmin == None: xmin = numpy.nanmin(x) |
|
142 | if xmin == None: xmin = numpy.nanmin(x) | |
143 | if xmax == None: xmax = numpy.nanmax(x) |
|
143 | if xmax == None: xmax = numpy.nanmax(x) | |
144 | if ymin == None: ymin = numpy.nanmin(y) |
|
144 | if ymin == None: ymin = numpy.nanmin(y) | |
145 | if ymax == None: ymax = numpy.nanmax(y) |
|
145 | if ymax == None: ymax = numpy.nanmax(y) | |
146 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
146 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
147 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
147 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
148 |
|
148 | |||
149 | self.FTP_WEI = ftp_wei |
|
149 | self.FTP_WEI = ftp_wei | |
150 | self.EXP_CODE = exp_code |
|
150 | self.EXP_CODE = exp_code | |
151 | self.SUB_EXP_CODE = sub_exp_code |
|
151 | self.SUB_EXP_CODE = sub_exp_code | |
152 | self.PLOT_POS = plot_pos |
|
152 | self.PLOT_POS = plot_pos | |
153 |
|
153 | |||
154 | self.isConfig = True |
|
154 | self.isConfig = True | |
155 |
|
155 | |||
156 | self.setWinTitle(title) |
|
156 | self.setWinTitle(title) | |
157 |
|
157 | |||
158 | for i in range(self.nplots): |
|
158 | for i in range(self.nplots): | |
159 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
159 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
160 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i]+1, noisedB[i], str_datetime) |
|
160 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i]+1, noisedB[i], str_datetime) | |
161 | axes = self.axesList[i*self.__nsubplots] |
|
161 | axes = self.axesList[i*self.__nsubplots] | |
162 | axes.pcolor(x, y, zdB[i,:,:], |
|
162 | axes.pcolor(x, y, zdB[i,:,:], | |
163 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
163 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
164 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
164 | xlabel=xlabel, ylabel=ylabel, title=title, | |
165 | ticksize=9, cblabel='') |
|
165 | ticksize=9, cblabel='') | |
166 | #Mean Line |
|
166 | #Mean Line | |
167 | mean = dataOut.data_param[i, 1, :] |
|
167 | mean = dataOut.data_param[i, 1, :] | |
168 | axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1) |
|
168 | axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1) | |
169 |
|
169 | |||
170 | if self.__showprofile: |
|
170 | if self.__showprofile: | |
171 | axes = self.axesList[i*self.__nsubplots +1] |
|
171 | axes = self.axesList[i*self.__nsubplots +1] | |
172 | axes.pline(avgdB[i], y, |
|
172 | axes.pline(avgdB[i], y, | |
173 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
173 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
174 | xlabel='dB', ylabel='', title='', |
|
174 | xlabel='dB', ylabel='', title='', | |
175 | ytick_visible=False, |
|
175 | ytick_visible=False, | |
176 | grid='x') |
|
176 | grid='x') | |
177 |
|
177 | |||
178 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
178 | noiseline = numpy.repeat(noisedB[i], len(y)) | |
179 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
179 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
180 |
|
180 | |||
181 | self.draw() |
|
181 | self.draw() | |
182 |
|
182 | |||
183 | if figfile == None: |
|
183 | if figfile == None: | |
184 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
184 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
185 | figfile = self.getFilename(name = str_datetime) |
|
185 | figfile = self.getFilename(name = str_datetime) | |
186 |
|
186 | |||
187 | if figpath != '': |
|
187 | if figpath != '': | |
188 | self.counter_imagwr += 1 |
|
188 | self.counter_imagwr += 1 | |
189 | if (self.counter_imagwr>=wr_period): |
|
189 | if (self.counter_imagwr>=wr_period): | |
190 | # store png plot to local folder |
|
190 | # store png plot to local folder | |
191 | self.saveFigure(figpath, figfile) |
|
191 | self.saveFigure(figpath, figfile) | |
192 | # store png plot to FTP server according to RT-Web format |
|
192 | # store png plot to FTP server according to RT-Web format | |
193 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
193 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
194 | ftp_filename = os.path.join(figpath, name) |
|
194 | ftp_filename = os.path.join(figpath, name) | |
195 | self.saveFigure(figpath, ftp_filename) |
|
195 | self.saveFigure(figpath, ftp_filename) | |
196 | self.counter_imagwr = 0 |
|
196 | self.counter_imagwr = 0 | |
197 |
|
197 | |||
198 | class SkyMapPlot(Figure): |
|
198 | class SkyMapPlot(Figure): | |
199 |
|
199 | |||
200 | __isConfig = None |
|
200 | __isConfig = None | |
201 | __nsubplots = None |
|
201 | __nsubplots = None | |
202 |
|
202 | |||
203 | WIDTHPROF = None |
|
203 | WIDTHPROF = None | |
204 | HEIGHTPROF = None |
|
204 | HEIGHTPROF = None | |
205 | PREFIX = 'prm' |
|
205 | PREFIX = 'prm' | |
206 |
|
206 | |||
207 | def __init__(self): |
|
207 | def __init__(self): | |
208 |
|
208 | |||
209 | self.__isConfig = False |
|
209 | self.__isConfig = False | |
210 | self.__nsubplots = 1 |
|
210 | self.__nsubplots = 1 | |
211 |
|
211 | |||
212 | # self.WIDTH = 280 |
|
212 | # self.WIDTH = 280 | |
213 | # self.HEIGHT = 250 |
|
213 | # self.HEIGHT = 250 | |
214 | self.WIDTH = 600 |
|
214 | self.WIDTH = 600 | |
215 | self.HEIGHT = 600 |
|
215 | self.HEIGHT = 600 | |
216 | self.WIDTHPROF = 120 |
|
216 | self.WIDTHPROF = 120 | |
217 | self.HEIGHTPROF = 0 |
|
217 | self.HEIGHTPROF = 0 | |
218 | self.counter_imagwr = 0 |
|
218 | self.counter_imagwr = 0 | |
219 |
|
219 | |||
220 | self.PLOT_CODE = 1 |
|
220 | self.PLOT_CODE = 1 | |
221 | self.FTP_WEI = None |
|
221 | self.FTP_WEI = None | |
222 | self.EXP_CODE = None |
|
222 | self.EXP_CODE = None | |
223 | self.SUB_EXP_CODE = None |
|
223 | self.SUB_EXP_CODE = None | |
224 | self.PLOT_POS = None |
|
224 | self.PLOT_POS = None | |
225 |
|
225 | |||
226 | def getSubplots(self): |
|
226 | def getSubplots(self): | |
227 |
|
227 | |||
228 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
228 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
229 | nrow = int(self.nplots*1./ncol + 0.9) |
|
229 | nrow = int(self.nplots*1./ncol + 0.9) | |
230 |
|
230 | |||
231 | return nrow, ncol |
|
231 | return nrow, ncol | |
232 |
|
232 | |||
233 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): |
|
233 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): | |
234 |
|
234 | |||
235 | self.__showprofile = showprofile |
|
235 | self.__showprofile = showprofile | |
236 | self.nplots = nplots |
|
236 | self.nplots = nplots | |
237 |
|
237 | |||
238 | ncolspan = 1 |
|
238 | ncolspan = 1 | |
239 | colspan = 1 |
|
239 | colspan = 1 | |
240 |
|
240 | |||
241 | self.createFigure(id = id, |
|
241 | self.createFigure(id = id, | |
242 | wintitle = wintitle, |
|
242 | wintitle = wintitle, | |
243 | widthplot = self.WIDTH, #+ self.WIDTHPROF, |
|
243 | widthplot = self.WIDTH, #+ self.WIDTHPROF, | |
244 | heightplot = self.HEIGHT,# + self.HEIGHTPROF, |
|
244 | heightplot = self.HEIGHT,# + self.HEIGHTPROF, | |
245 | show=show) |
|
245 | show=show) | |
246 |
|
246 | |||
247 | nrow, ncol = 1,1 |
|
247 | nrow, ncol = 1,1 | |
248 | counter = 0 |
|
248 | counter = 0 | |
249 | x = 0 |
|
249 | x = 0 | |
250 | y = 0 |
|
250 | y = 0 | |
251 | self.addAxes(1, 1, 0, 0, 1, 1, True) |
|
251 | self.addAxes(1, 1, 0, 0, 1, 1, True) | |
252 |
|
252 | |||
253 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, |
|
253 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, | |
254 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
254 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
255 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
255 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
256 | server=None, folder=None, username=None, password=None, |
|
256 | server=None, folder=None, username=None, password=None, | |
257 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): |
|
257 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): | |
258 |
|
258 | |||
259 | """ |
|
259 | """ | |
260 |
|
260 | |||
261 | Input: |
|
261 | Input: | |
262 | dataOut : |
|
262 | dataOut : | |
263 | id : |
|
263 | id : | |
264 | wintitle : |
|
264 | wintitle : | |
265 | channelList : |
|
265 | channelList : | |
266 | showProfile : |
|
266 | showProfile : | |
267 | xmin : None, |
|
267 | xmin : None, | |
268 | xmax : None, |
|
268 | xmax : None, | |
269 | ymin : None, |
|
269 | ymin : None, | |
270 | ymax : None, |
|
270 | ymax : None, | |
271 | zmin : None, |
|
271 | zmin : None, | |
272 | zmax : None |
|
272 | zmax : None | |
273 | """ |
|
273 | """ | |
274 |
|
274 | |||
275 | arrayParameters = dataOut.data_param |
|
275 | arrayParameters = dataOut.data_param | |
276 | error = arrayParameters[:,-1] |
|
276 | error = arrayParameters[:,-1] | |
277 | indValid = numpy.where(error == 0)[0] |
|
277 | indValid = numpy.where(error == 0)[0] | |
278 | finalMeteor = arrayParameters[indValid,:] |
|
278 | finalMeteor = arrayParameters[indValid,:] | |
279 | finalAzimuth = finalMeteor[:,4] |
|
279 | finalAzimuth = finalMeteor[:,4] | |
280 | finalZenith = finalMeteor[:,5] |
|
280 | finalZenith = finalMeteor[:,5] | |
281 |
|
281 | |||
282 | x = finalAzimuth*numpy.pi/180 |
|
282 | x = finalAzimuth*numpy.pi/180 | |
283 | y = finalZenith |
|
283 | y = finalZenith | |
284 |
|
284 | |||
285 |
|
285 | |||
286 | #thisDatetime = dataOut.datatime |
|
286 | #thisDatetime = dataOut.datatime | |
287 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
287 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
288 | title = wintitle + " Parameters" |
|
288 | title = wintitle + " Parameters" | |
289 | xlabel = "Zonal Zenith Angle (deg) " |
|
289 | xlabel = "Zonal Zenith Angle (deg) " | |
290 | ylabel = "Meridional Zenith Angle (deg)" |
|
290 | ylabel = "Meridional Zenith Angle (deg)" | |
291 |
|
291 | |||
292 | if not self.__isConfig: |
|
292 | if not self.__isConfig: | |
293 |
|
293 | |||
294 | nplots = 1 |
|
294 | nplots = 1 | |
295 |
|
295 | |||
296 | self.setup(id=id, |
|
296 | self.setup(id=id, | |
297 | nplots=nplots, |
|
297 | nplots=nplots, | |
298 | wintitle=wintitle, |
|
298 | wintitle=wintitle, | |
299 | showprofile=showprofile, |
|
299 | showprofile=showprofile, | |
300 | show=show) |
|
300 | show=show) | |
301 |
|
301 | |||
302 | self.FTP_WEI = ftp_wei |
|
302 | self.FTP_WEI = ftp_wei | |
303 | self.EXP_CODE = exp_code |
|
303 | self.EXP_CODE = exp_code | |
304 | self.SUB_EXP_CODE = sub_exp_code |
|
304 | self.SUB_EXP_CODE = sub_exp_code | |
305 | self.PLOT_POS = plot_pos |
|
305 | self.PLOT_POS = plot_pos | |
306 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
306 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
307 | self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
307 | self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
308 | self.__isConfig = True |
|
308 | self.__isConfig = True | |
309 |
|
309 | |||
310 | self.setWinTitle(title) |
|
310 | self.setWinTitle(title) | |
311 |
|
311 | |||
312 | i = 0 |
|
312 | i = 0 | |
313 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
313 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
314 |
|
314 | |||
315 | axes = self.axesList[i*self.__nsubplots] |
|
315 | axes = self.axesList[i*self.__nsubplots] | |
316 | nevents = axes.x_buffer.shape[0] + x.shape[0] |
|
316 | nevents = axes.x_buffer.shape[0] + x.shape[0] | |
317 | title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents) |
|
317 | title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents) | |
318 | axes.polar(x, y, |
|
318 | axes.polar(x, y, | |
319 | title=title, xlabel=xlabel, ylabel=ylabel, |
|
319 | title=title, xlabel=xlabel, ylabel=ylabel, | |
320 | ticksize=9, cblabel='') |
|
320 | ticksize=9, cblabel='') | |
321 |
|
321 | |||
322 | self.draw() |
|
322 | self.draw() | |
323 |
|
323 | |||
324 | if save: |
|
324 | if save: | |
325 |
|
325 | |||
326 | self.counter_imagwr += 1 |
|
326 | self.counter_imagwr += 1 | |
327 | if (self.counter_imagwr==wr_period): |
|
327 | if (self.counter_imagwr==wr_period): | |
328 |
|
328 | |||
329 | if figfile == None: |
|
329 | if figfile == None: | |
330 | figfile = self.getFilename(name = self.name) |
|
330 | figfile = self.getFilename(name = self.name) | |
331 | self.saveFigure(figpath, figfile) |
|
331 | self.saveFigure(figpath, figfile) | |
332 |
|
332 | |||
333 | if ftp: |
|
333 | if ftp: | |
334 | #provisionalmente envia archivos en el formato de la web en tiempo real |
|
334 | #provisionalmente envia archivos en el formato de la web en tiempo real | |
335 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
335 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
336 | path = '%s%03d' %(self.PREFIX, self.id) |
|
336 | path = '%s%03d' %(self.PREFIX, self.id) | |
337 | ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
337 | ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
338 | self.saveFigure(figpath, ftp_file) |
|
338 | self.saveFigure(figpath, ftp_file) | |
339 | ftp_filename = os.path.join(figpath,ftp_file) |
|
339 | ftp_filename = os.path.join(figpath,ftp_file) | |
340 |
|
340 | |||
341 |
|
341 | |||
342 | try: |
|
342 | try: | |
343 | self.sendByFTP(ftp_filename, server, folder, username, password) |
|
343 | self.sendByFTP(ftp_filename, server, folder, username, password) | |
344 | except: |
|
344 | except: | |
345 | self.counter_imagwr = 0 |
|
345 | self.counter_imagwr = 0 | |
346 | raise ValueError, 'Error FTP' |
|
346 | raise ValueError, 'Error FTP' | |
347 |
|
347 | |||
348 | self.counter_imagwr = 0 |
|
348 | self.counter_imagwr = 0 | |
349 |
|
349 | |||
350 |
|
350 | |||
351 | class WindProfilerPlot(Figure): |
|
351 | class WindProfilerPlot(Figure): | |
352 |
|
352 | |||
353 | __isConfig = None |
|
353 | __isConfig = None | |
354 | __nsubplots = None |
|
354 | __nsubplots = None | |
355 |
|
355 | |||
356 | WIDTHPROF = None |
|
356 | WIDTHPROF = None | |
357 | HEIGHTPROF = None |
|
357 | HEIGHTPROF = None | |
358 | PREFIX = 'wind' |
|
358 | PREFIX = 'wind' | |
359 |
|
359 | |||
360 | def __init__(self): |
|
360 | def __init__(self): | |
361 |
|
361 | |||
362 | self.timerange = 2*60*60 |
|
362 | self.timerange = 2*60*60 | |
363 | self.__isConfig = False |
|
363 | self.__isConfig = False | |
364 | self.__nsubplots = 1 |
|
364 | self.__nsubplots = 1 | |
365 |
|
365 | |||
366 | self.WIDTH = 800 |
|
366 | self.WIDTH = 800 | |
367 | self.HEIGHT = 150 |
|
367 | self.HEIGHT = 150 | |
368 | self.WIDTHPROF = 120 |
|
368 | self.WIDTHPROF = 120 | |
369 | self.HEIGHTPROF = 0 |
|
369 | self.HEIGHTPROF = 0 | |
370 | self.counter_imagwr = 0 |
|
370 | self.counter_imagwr = 0 | |
371 |
|
371 | |||
372 | self.PLOT_CODE = 0 |
|
372 | self.PLOT_CODE = 0 | |
373 | self.FTP_WEI = None |
|
373 | self.FTP_WEI = None | |
374 | self.EXP_CODE = None |
|
374 | self.EXP_CODE = None | |
375 | self.SUB_EXP_CODE = None |
|
375 | self.SUB_EXP_CODE = None | |
376 | self.PLOT_POS = None |
|
376 | self.PLOT_POS = None | |
377 | self.tmin = None |
|
377 | self.tmin = None | |
378 | self.tmax = None |
|
378 | self.tmax = None | |
379 |
|
379 | |||
380 | self.xmin = None |
|
380 | self.xmin = None | |
381 | self.xmax = None |
|
381 | self.xmax = None | |
382 |
|
382 | |||
383 | self.figfile = None |
|
383 | self.figfile = None | |
384 |
|
384 | |||
385 | def getSubplots(self): |
|
385 | def getSubplots(self): | |
386 |
|
386 | |||
387 | ncol = 1 |
|
387 | ncol = 1 | |
388 | nrow = self.nplots |
|
388 | nrow = self.nplots | |
389 |
|
389 | |||
390 | return nrow, ncol |
|
390 | return nrow, ncol | |
391 |
|
391 | |||
392 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
392 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
393 |
|
393 | |||
394 | self.__showprofile = showprofile |
|
394 | self.__showprofile = showprofile | |
395 | self.nplots = nplots |
|
395 | self.nplots = nplots | |
396 |
|
396 | |||
397 | ncolspan = 1 |
|
397 | ncolspan = 1 | |
398 | colspan = 1 |
|
398 | colspan = 1 | |
399 |
|
399 | |||
400 | self.createFigure(id = id, |
|
400 | self.createFigure(id = id, | |
401 | wintitle = wintitle, |
|
401 | wintitle = wintitle, | |
402 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
402 | widthplot = self.WIDTH + self.WIDTHPROF, | |
403 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
403 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
404 | show=show) |
|
404 | show=show) | |
405 |
|
405 | |||
406 | nrow, ncol = self.getSubplots() |
|
406 | nrow, ncol = self.getSubplots() | |
407 |
|
407 | |||
408 | counter = 0 |
|
408 | counter = 0 | |
409 | for y in range(nrow): |
|
409 | for y in range(nrow): | |
410 | if counter >= self.nplots: |
|
410 | if counter >= self.nplots: | |
411 | break |
|
411 | break | |
412 |
|
412 | |||
413 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) |
|
413 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) | |
414 | counter += 1 |
|
414 | counter += 1 | |
415 |
|
415 | |||
416 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
416 | def run(self, dataOut, id, wintitle="", channelList=None, | |
417 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
417 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
418 | zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None, |
|
418 | zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None, | |
419 | timerange=None, SNRthresh = None, |
|
419 | timerange=None, SNRthresh = None, | |
420 | save=False, figpath='', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
420 | save=False, figpath='', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
421 | server=None, folder=None, username=None, password=None, |
|
421 | server=None, folder=None, username=None, password=None, | |
422 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
422 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
423 | """ |
|
423 | """ | |
424 |
|
424 | |||
425 | Input: |
|
425 | Input: | |
426 | dataOut : |
|
426 | dataOut : | |
427 | id : |
|
427 | id : | |
428 | wintitle : |
|
428 | wintitle : | |
429 | channelList : |
|
429 | channelList : | |
430 | showProfile : |
|
430 | showProfile : | |
431 | xmin : None, |
|
431 | xmin : None, | |
432 | xmax : None, |
|
432 | xmax : None, | |
433 | ymin : None, |
|
433 | ymin : None, | |
434 | ymax : None, |
|
434 | ymax : None, | |
435 | zmin : None, |
|
435 | zmin : None, | |
436 | zmax : None |
|
436 | zmax : None | |
437 | """ |
|
437 | """ | |
438 |
|
438 | |||
439 | if channelList == None: |
|
439 | if channelList == None: | |
440 | channelIndexList = dataOut.channelIndexList |
|
440 | channelIndexList = dataOut.channelIndexList | |
441 | else: |
|
441 | else: | |
442 | channelIndexList = [] |
|
442 | channelIndexList = [] | |
443 | for channel in channelList: |
|
443 | for channel in channelList: | |
444 | if channel not in dataOut.channelList: |
|
444 | if channel not in dataOut.channelList: | |
445 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
445 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
446 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
446 | channelIndexList.append(dataOut.channelList.index(channel)) | |
447 |
|
447 | |||
448 | if timerange != None: |
|
448 | if timerange != None: | |
449 | self.timerange = timerange |
|
449 | self.timerange = timerange | |
450 |
|
450 | |||
451 | tmin = None |
|
451 | tmin = None | |
452 | tmax = None |
|
452 | tmax = None | |
453 |
|
453 | |||
454 | x = dataOut.getTimeRange1() |
|
454 | x = dataOut.getTimeRange1() | |
455 | # y = dataOut.heightRange |
|
455 | # y = dataOut.heightRange | |
456 | y = dataOut.heightRange |
|
456 | y = dataOut.heightRange | |
457 |
|
457 | |||
458 | z = dataOut.data_output.copy() |
|
458 | z = dataOut.data_output.copy() | |
459 | nplots = z.shape[0] #Number of wind dimensions estimated |
|
459 | nplots = z.shape[0] #Number of wind dimensions estimated | |
460 | nplotsw = nplots |
|
460 | nplotsw = nplots | |
461 |
|
461 | |||
462 | #If there is a SNR function defined |
|
462 | #If there is a SNR function defined | |
463 | if dataOut.SNR != None: |
|
463 | if dataOut.data_SNR != None: | |
464 | nplots += 1 |
|
464 | nplots += 1 | |
465 | SNR = dataOut.SNR |
|
465 | SNR = dataOut.data_SNR | |
466 | SNRavg = numpy.average(SNR, axis=0) |
|
466 | SNRavg = numpy.average(SNR, axis=0) | |
467 |
|
467 | |||
468 | SNRdB = 10*numpy.log10(SNR) |
|
468 | SNRdB = 10*numpy.log10(SNR) | |
469 | SNRavgdB = 10*numpy.log10(SNRavg) |
|
469 | SNRavgdB = 10*numpy.log10(SNRavg) | |
470 |
|
470 | |||
471 | if SNRthresh == None: SNRthresh = -5.0 |
|
471 | if SNRthresh == None: SNRthresh = -5.0 | |
472 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] |
|
472 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] | |
473 |
|
473 | |||
474 | for i in range(nplotsw): |
|
474 | for i in range(nplotsw): | |
475 | z[i,ind] = numpy.nan |
|
475 | z[i,ind] = numpy.nan | |
476 |
|
476 | |||
477 |
|
477 | |||
478 | showprofile = False |
|
478 | showprofile = False | |
479 | # thisDatetime = dataOut.datatime |
|
479 | # thisDatetime = dataOut.datatime | |
480 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
480 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
481 | title = wintitle + "Wind" |
|
481 | title = wintitle + "Wind" | |
482 | xlabel = "" |
|
482 | xlabel = "" | |
483 | ylabel = "Range (Km)" |
|
483 | ylabel = "Range (Km)" | |
484 |
|
484 | |||
485 | if not self.__isConfig: |
|
485 | if not self.__isConfig: | |
486 |
|
486 | |||
487 | self.setup(id=id, |
|
487 | self.setup(id=id, | |
488 | nplots=nplots, |
|
488 | nplots=nplots, | |
489 | wintitle=wintitle, |
|
489 | wintitle=wintitle, | |
490 | showprofile=showprofile, |
|
490 | showprofile=showprofile, | |
491 | show=show) |
|
491 | show=show) | |
492 |
|
492 | |||
493 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
493 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
494 |
|
494 | |||
495 | if ymin == None: ymin = numpy.nanmin(y) |
|
495 | if ymin == None: ymin = numpy.nanmin(y) | |
496 | if ymax == None: ymax = numpy.nanmax(y) |
|
496 | if ymax == None: ymax = numpy.nanmax(y) | |
497 |
|
497 | |||
498 | if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:])) |
|
498 | if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:])) | |
499 | #if numpy.isnan(zmax): zmax = 50 |
|
499 | #if numpy.isnan(zmax): zmax = 50 | |
500 | if zmin == None: zmin = -zmax |
|
500 | if zmin == None: zmin = -zmax | |
501 |
|
501 | |||
502 | if nplotsw == 3: |
|
502 | if nplotsw == 3: | |
503 | if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:])) |
|
503 | if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:])) | |
504 | if zmin_ver == None: zmin_ver = -zmax_ver |
|
504 | if zmin_ver == None: zmin_ver = -zmax_ver | |
505 |
|
505 | |||
506 | if dataOut.SNR != None: |
|
506 | if dataOut.data_SNR != None: | |
507 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) |
|
507 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) | |
508 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) |
|
508 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) | |
509 |
|
509 | |||
510 | self.FTP_WEI = ftp_wei |
|
510 | self.FTP_WEI = ftp_wei | |
511 | self.EXP_CODE = exp_code |
|
511 | self.EXP_CODE = exp_code | |
512 | self.SUB_EXP_CODE = sub_exp_code |
|
512 | self.SUB_EXP_CODE = sub_exp_code | |
513 | self.PLOT_POS = plot_pos |
|
513 | self.PLOT_POS = plot_pos | |
514 |
|
514 | |||
515 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
515 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
516 | self.__isConfig = True |
|
516 | self.__isConfig = True | |
517 |
|
517 | |||
518 |
|
518 | |||
519 | self.setWinTitle(title) |
|
519 | self.setWinTitle(title) | |
520 |
|
520 | |||
521 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
521 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
522 | x[1] = self.xmax |
|
522 | x[1] = self.xmax | |
523 |
|
523 | |||
524 | strWind = ['Zonal', 'Meridional', 'Vertical'] |
|
524 | strWind = ['Zonal', 'Meridional', 'Vertical'] | |
525 | strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] |
|
525 | strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] | |
526 | zmaxVector = [zmax, zmax, zmax_ver] |
|
526 | zmaxVector = [zmax, zmax, zmax_ver] | |
527 | zminVector = [zmin, zmin, zmin_ver] |
|
527 | zminVector = [zmin, zmin, zmin_ver] | |
528 | windFactor = [1,1,100] |
|
528 | windFactor = [1,1,100] | |
529 |
|
529 | |||
530 | for i in range(nplotsw): |
|
530 | for i in range(nplotsw): | |
531 |
|
531 | |||
532 | title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
532 | title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
533 | axes = self.axesList[i*self.__nsubplots] |
|
533 | axes = self.axesList[i*self.__nsubplots] | |
534 |
|
534 | |||
535 | z1 = z[i,:].reshape((1,-1))*windFactor[i] |
|
535 | z1 = z[i,:].reshape((1,-1))*windFactor[i] | |
536 |
|
536 | |||
537 | axes.pcolorbuffer(x, y, z1, |
|
537 | axes.pcolorbuffer(x, y, z1, | |
538 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], |
|
538 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], | |
539 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
539 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
540 | ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" ) |
|
540 | ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" ) | |
541 |
|
541 | |||
542 | if dataOut.SNR != None: |
|
542 | if dataOut.data_SNR != None: | |
543 | i += 1 |
|
543 | i += 1 | |
544 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
544 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
545 | axes = self.axesList[i*self.__nsubplots] |
|
545 | axes = self.axesList[i*self.__nsubplots] | |
546 |
|
546 | |||
547 | SNRavgdB = SNRavgdB.reshape((1,-1)) |
|
547 | SNRavgdB = SNRavgdB.reshape((1,-1)) | |
548 |
|
548 | |||
549 | axes.pcolorbuffer(x, y, SNRavgdB, |
|
549 | axes.pcolorbuffer(x, y, SNRavgdB, | |
550 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
550 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
551 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
551 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
552 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") |
|
552 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") | |
553 |
|
553 | |||
554 | self.draw() |
|
554 | self.draw() | |
555 |
|
555 | |||
556 | if self.figfile == None: |
|
556 | if self.figfile == None: | |
557 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
557 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
558 | self.figfile = self.getFilename(name = str_datetime) |
|
558 | self.figfile = self.getFilename(name = str_datetime) | |
559 |
|
559 | |||
560 | if figpath != '': |
|
560 | if figpath != '': | |
561 |
|
561 | |||
562 | self.counter_imagwr += 1 |
|
562 | self.counter_imagwr += 1 | |
563 | if (self.counter_imagwr>=wr_period): |
|
563 | if (self.counter_imagwr>=wr_period): | |
564 | # store png plot to local folder |
|
564 | # store png plot to local folder | |
565 | self.saveFigure(figpath, self.figfile) |
|
565 | self.saveFigure(figpath, self.figfile) | |
566 | # store png plot to FTP server according to RT-Web format |
|
566 | # store png plot to FTP server according to RT-Web format | |
567 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
567 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
568 | ftp_filename = os.path.join(figpath, name) |
|
568 | ftp_filename = os.path.join(figpath, name) | |
569 | self.saveFigure(figpath, ftp_filename) |
|
569 | self.saveFigure(figpath, ftp_filename) | |
570 |
|
570 | |||
571 | self.counter_imagwr = 0 |
|
571 | self.counter_imagwr = 0 | |
572 |
|
572 | |||
573 | if x[1] >= self.axesList[0].xmax: |
|
573 | if x[1] >= self.axesList[0].xmax: | |
574 | self.counter_imagwr = wr_period |
|
574 | self.counter_imagwr = wr_period | |
575 | self.__isConfig = False |
|
575 | self.__isConfig = False | |
576 | self.figfile = None |
|
576 | self.figfile = None | |
577 |
|
577 | |||
578 |
|
578 | |||
579 | class ParametersPlot(Figure): |
|
579 | class ParametersPlot(Figure): | |
580 |
|
580 | |||
581 | __isConfig = None |
|
581 | __isConfig = None | |
582 | __nsubplots = None |
|
582 | __nsubplots = None | |
583 |
|
583 | |||
584 | WIDTHPROF = None |
|
584 | WIDTHPROF = None | |
585 | HEIGHTPROF = None |
|
585 | HEIGHTPROF = None | |
586 | PREFIX = 'prm' |
|
586 | PREFIX = 'prm' | |
587 |
|
587 | |||
588 | def __init__(self): |
|
588 | def __init__(self): | |
589 |
|
589 | |||
590 | self.timerange = 2*60*60 |
|
590 | self.timerange = 2*60*60 | |
591 | self.__isConfig = False |
|
591 | self.__isConfig = False | |
592 | self.__nsubplots = 1 |
|
592 | self.__nsubplots = 1 | |
593 |
|
593 | |||
594 | self.WIDTH = 800 |
|
594 | self.WIDTH = 800 | |
595 | self.HEIGHT = 150 |
|
595 | self.HEIGHT = 150 | |
596 | self.WIDTHPROF = 120 |
|
596 | self.WIDTHPROF = 120 | |
597 | self.HEIGHTPROF = 0 |
|
597 | self.HEIGHTPROF = 0 | |
598 | self.counter_imagwr = 0 |
|
598 | self.counter_imagwr = 0 | |
599 |
|
599 | |||
600 | self.PLOT_CODE = 0 |
|
600 | self.PLOT_CODE = 0 | |
601 | self.FTP_WEI = None |
|
601 | self.FTP_WEI = None | |
602 | self.EXP_CODE = None |
|
602 | self.EXP_CODE = None | |
603 | self.SUB_EXP_CODE = None |
|
603 | self.SUB_EXP_CODE = None | |
604 | self.PLOT_POS = None |
|
604 | self.PLOT_POS = None | |
605 | self.tmin = None |
|
605 | self.tmin = None | |
606 | self.tmax = None |
|
606 | self.tmax = None | |
607 |
|
607 | |||
608 | self.xmin = None |
|
608 | self.xmin = None | |
609 | self.xmax = None |
|
609 | self.xmax = None | |
610 |
|
610 | |||
611 | self.figfile = None |
|
611 | self.figfile = None | |
612 |
|
612 | |||
613 | def getSubplots(self): |
|
613 | def getSubplots(self): | |
614 |
|
614 | |||
615 | ncol = 1 |
|
615 | ncol = 1 | |
616 | nrow = self.nplots |
|
616 | nrow = self.nplots | |
617 |
|
617 | |||
618 | return nrow, ncol |
|
618 | return nrow, ncol | |
619 |
|
619 | |||
620 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
620 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
621 |
|
621 | |||
622 | self.__showprofile = showprofile |
|
622 | self.__showprofile = showprofile | |
623 | self.nplots = nplots |
|
623 | self.nplots = nplots | |
624 |
|
624 | |||
625 | ncolspan = 1 |
|
625 | ncolspan = 1 | |
626 | colspan = 1 |
|
626 | colspan = 1 | |
627 |
|
627 | |||
628 | self.createFigure(id = id, |
|
628 | self.createFigure(id = id, | |
629 | wintitle = wintitle, |
|
629 | wintitle = wintitle, | |
630 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
630 | widthplot = self.WIDTH + self.WIDTHPROF, | |
631 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
631 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
632 | show=show) |
|
632 | show=show) | |
633 |
|
633 | |||
634 | nrow, ncol = self.getSubplots() |
|
634 | nrow, ncol = self.getSubplots() | |
635 |
|
635 | |||
636 | counter = 0 |
|
636 | counter = 0 | |
637 | for y in range(nrow): |
|
637 | for y in range(nrow): | |
638 | for x in range(ncol): |
|
638 | for x in range(ncol): | |
639 |
|
639 | |||
640 | if counter >= self.nplots: |
|
640 | if counter >= self.nplots: | |
641 | break |
|
641 | break | |
642 |
|
642 | |||
643 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
643 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
644 |
|
644 | |||
645 | if showprofile: |
|
645 | if showprofile: | |
646 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
646 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
647 |
|
647 | |||
648 | counter += 1 |
|
648 | counter += 1 | |
649 |
|
649 | |||
650 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, |
|
650 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, | |
651 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None, |
|
651 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None, | |
652 | SNRmin = None, SNRmax = None, SNRthresh = None, paramIndex = None, onlyPositive = False, |
|
652 | SNRmin = None, SNRmax = None, SNRthresh = None, paramIndex = None, onlyPositive = False, | |
653 | zlabel = "", parameterName = "", |
|
653 | zlabel = "", parameterName = "", | |
654 | save=False, figpath='', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
654 | save=False, figpath='', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
655 | server=None, folder=None, username=None, password=None, |
|
655 | server=None, folder=None, username=None, password=None, | |
656 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
656 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
657 |
|
657 | |||
658 | """ |
|
658 | """ | |
659 |
|
659 | |||
660 | Input: |
|
660 | Input: | |
661 | dataOut : |
|
661 | dataOut : | |
662 | id : |
|
662 | id : | |
663 | wintitle : |
|
663 | wintitle : | |
664 | channelList : |
|
664 | channelList : | |
665 | showProfile : |
|
665 | showProfile : | |
666 | xmin : None, |
|
666 | xmin : None, | |
667 | xmax : None, |
|
667 | xmax : None, | |
668 | ymin : None, |
|
668 | ymin : None, | |
669 | ymax : None, |
|
669 | ymax : None, | |
670 | zmin : None, |
|
670 | zmin : None, | |
671 | zmax : None |
|
671 | zmax : None | |
672 | """ |
|
672 | """ | |
673 |
|
673 | |||
674 | if channelList == None: |
|
674 | if channelList == None: | |
675 | channelIndexList = dataOut.channelIndexList |
|
675 | channelIndexList = dataOut.channelIndexList | |
676 | else: |
|
676 | else: | |
677 | channelIndexList = [] |
|
677 | channelIndexList = [] | |
678 | for channel in channelList: |
|
678 | for channel in channelList: | |
679 | if channel not in dataOut.channelList: |
|
679 | if channel not in dataOut.channelList: | |
680 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
680 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
681 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
681 | channelIndexList.append(dataOut.channelList.index(channel)) | |
682 |
|
682 | |||
683 | if timerange != None: |
|
683 | if timerange != None: | |
684 | self.timerange = timerange |
|
684 | self.timerange = timerange | |
685 |
|
685 | |||
686 | #tmin = None |
|
686 | #tmin = None | |
687 | #tmax = None |
|
687 | #tmax = None | |
688 | if paramIndex == None: |
|
688 | if paramIndex == None: | |
689 | paramIndex = 1 |
|
689 | paramIndex = 1 | |
690 | x = dataOut.getTimeRange1() |
|
690 | x = dataOut.getTimeRange1() | |
691 | y = dataOut.heightRange |
|
691 | y = dataOut.heightRange | |
692 | z = dataOut.data_param[channelIndexList,paramIndex,:].copy() |
|
692 | z = dataOut.data_param[channelIndexList,paramIndex,:].copy() | |
693 |
|
693 | |||
694 | zRange = dataOut.abscissaRange |
|
694 | zRange = dataOut.abscissaRange | |
695 | nplots = z.shape[0] #Number of wind dimensions estimated |
|
695 | nplots = z.shape[0] #Number of wind dimensions estimated | |
696 | # thisDatetime = dataOut.datatime |
|
696 | # thisDatetime = dataOut.datatime | |
697 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
697 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
698 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
698 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
699 | xlabel = "" |
|
699 | xlabel = "" | |
700 | ylabel = "Range (Km)" |
|
700 | ylabel = "Range (Km)" | |
701 |
|
701 | |||
702 | if onlyPositive: |
|
702 | if onlyPositive: | |
703 | colormap = "jet" |
|
703 | colormap = "jet" | |
704 | zmin = 0 |
|
704 | zmin = 0 | |
705 | else: colormap = "RdBu_r" |
|
705 | else: colormap = "RdBu_r" | |
706 |
|
706 | |||
707 | if not self.__isConfig: |
|
707 | if not self.__isConfig: | |
708 |
|
708 | |||
709 | self.setup(id=id, |
|
709 | self.setup(id=id, | |
710 | nplots=nplots, |
|
710 | nplots=nplots, | |
711 | wintitle=wintitle, |
|
711 | wintitle=wintitle, | |
712 | showprofile=showprofile, |
|
712 | showprofile=showprofile, | |
713 | show=show) |
|
713 | show=show) | |
714 |
|
714 | |||
715 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
715 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
716 |
|
716 | |||
717 | if ymin == None: ymin = numpy.nanmin(y) |
|
717 | if ymin == None: ymin = numpy.nanmin(y) | |
718 | if ymax == None: ymax = numpy.nanmax(y) |
|
718 | if ymax == None: ymax = numpy.nanmax(y) | |
719 | if zmin == None: zmin = numpy.nanmin(zRange) |
|
719 | if zmin == None: zmin = numpy.nanmin(zRange) | |
720 | if zmax == None: zmax = numpy.nanmax(zRange) |
|
720 | if zmax == None: zmax = numpy.nanmax(zRange) | |
721 |
|
721 | |||
722 | if dataOut.SNR != None: |
|
722 | if dataOut.data_SNR != None: | |
723 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) |
|
723 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) | |
724 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) |
|
724 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) | |
725 |
|
725 | |||
726 | self.FTP_WEI = ftp_wei |
|
726 | self.FTP_WEI = ftp_wei | |
727 | self.EXP_CODE = exp_code |
|
727 | self.EXP_CODE = exp_code | |
728 | self.SUB_EXP_CODE = sub_exp_code |
|
728 | self.SUB_EXP_CODE = sub_exp_code | |
729 | self.PLOT_POS = plot_pos |
|
729 | self.PLOT_POS = plot_pos | |
730 |
|
730 | |||
731 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
731 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
732 | self.__isConfig = True |
|
732 | self.__isConfig = True | |
733 | self.figfile = figfile |
|
733 | self.figfile = figfile | |
734 |
|
734 | |||
735 | self.setWinTitle(title) |
|
735 | self.setWinTitle(title) | |
736 |
|
736 | |||
737 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
737 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
738 | x[1] = self.xmax |
|
738 | x[1] = self.xmax | |
739 |
|
739 | |||
740 | for i in range(nplots): |
|
740 | for i in range(nplots): | |
741 | title = "%s Channel %d: %s" %(parameterName, dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
741 | title = "%s Channel %d: %s" %(parameterName, dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
742 |
|
742 | |||
743 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
743 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
744 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
744 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
745 | axes = self.axesList[i*self.__nsubplots] |
|
745 | axes = self.axesList[i*self.__nsubplots] | |
746 | z1 = z[i,:].reshape((1,-1)) |
|
746 | z1 = z[i,:].reshape((1,-1)) | |
747 | axes.pcolorbuffer(x, y, z1, |
|
747 | axes.pcolorbuffer(x, y, z1, | |
748 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
748 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
749 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, |
|
749 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, | |
750 | ticksize=9, cblabel=zlabel, cbsize="1%") |
|
750 | ticksize=9, cblabel=zlabel, cbsize="1%") | |
751 |
|
751 | |||
752 | self.draw() |
|
752 | self.draw() | |
753 |
|
753 | |||
754 | if self.figfile == None: |
|
754 | if self.figfile == None: | |
755 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
755 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
756 | self.figfile = self.getFilename(name = str_datetime) |
|
756 | self.figfile = self.getFilename(name = str_datetime) | |
757 |
|
757 | |||
758 | if figpath != '': |
|
758 | if figpath != '': | |
759 |
|
759 | |||
760 | self.counter_imagwr += 1 |
|
760 | self.counter_imagwr += 1 | |
761 | if (self.counter_imagwr>=wr_period): |
|
761 | if (self.counter_imagwr>=wr_period): | |
762 | # store png plot to local folder |
|
762 | # store png plot to local folder | |
763 | self.saveFigure(figpath, self.figfile) |
|
763 | self.saveFigure(figpath, self.figfile) | |
764 | # store png plot to FTP server according to RT-Web format |
|
764 | # store png plot to FTP server according to RT-Web format | |
765 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
765 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
766 | ftp_filename = os.path.join(figpath, name) |
|
766 | ftp_filename = os.path.join(figpath, name) | |
767 | self.saveFigure(figpath, ftp_filename) |
|
767 | self.saveFigure(figpath, ftp_filename) | |
768 |
|
768 | |||
769 | self.counter_imagwr = 0 |
|
769 | self.counter_imagwr = 0 | |
770 |
|
770 | |||
771 | if x[1] >= self.axesList[0].xmax: |
|
771 | if x[1] >= self.axesList[0].xmax: | |
772 | self.counter_imagwr = wr_period |
|
772 | self.counter_imagwr = wr_period | |
773 | self.__isConfig = False |
|
773 | self.__isConfig = False | |
774 | self.figfile = None |
|
774 | self.figfile = None | |
775 |
|
775 | |||
776 |
|
776 | |||
777 | class SpectralFittingPlot(Figure): |
|
777 | class SpectralFittingPlot(Figure): | |
778 |
|
778 | |||
779 | __isConfig = None |
|
779 | __isConfig = None | |
780 | __nsubplots = None |
|
780 | __nsubplots = None | |
781 |
|
781 | |||
782 | WIDTHPROF = None |
|
782 | WIDTHPROF = None | |
783 | HEIGHTPROF = None |
|
783 | HEIGHTPROF = None | |
784 | PREFIX = 'prm' |
|
784 | PREFIX = 'prm' | |
785 |
|
785 | |||
786 |
|
786 | |||
787 | N = None |
|
787 | N = None | |
788 | ippSeconds = None |
|
788 | ippSeconds = None | |
789 |
|
789 | |||
790 | def __init__(self): |
|
790 | def __init__(self): | |
791 | self.__isConfig = False |
|
791 | self.__isConfig = False | |
792 | self.__nsubplots = 1 |
|
792 | self.__nsubplots = 1 | |
793 |
|
793 | |||
794 | self.WIDTH = 450 |
|
794 | self.WIDTH = 450 | |
795 | self.HEIGHT = 250 |
|
795 | self.HEIGHT = 250 | |
796 | self.WIDTHPROF = 0 |
|
796 | self.WIDTHPROF = 0 | |
797 | self.HEIGHTPROF = 0 |
|
797 | self.HEIGHTPROF = 0 | |
798 |
|
798 | |||
799 | def getSubplots(self): |
|
799 | def getSubplots(self): | |
800 |
|
800 | |||
801 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
801 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
802 | nrow = int(self.nplots*1./ncol + 0.9) |
|
802 | nrow = int(self.nplots*1./ncol + 0.9) | |
803 |
|
803 | |||
804 | return nrow, ncol |
|
804 | return nrow, ncol | |
805 |
|
805 | |||
806 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): |
|
806 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): | |
807 |
|
807 | |||
808 | showprofile = False |
|
808 | showprofile = False | |
809 | self.__showprofile = showprofile |
|
809 | self.__showprofile = showprofile | |
810 | self.nplots = nplots |
|
810 | self.nplots = nplots | |
811 |
|
811 | |||
812 | ncolspan = 5 |
|
812 | ncolspan = 5 | |
813 | colspan = 4 |
|
813 | colspan = 4 | |
814 | if showprofile: |
|
814 | if showprofile: | |
815 | ncolspan = 5 |
|
815 | ncolspan = 5 | |
816 | colspan = 4 |
|
816 | colspan = 4 | |
817 | self.__nsubplots = 2 |
|
817 | self.__nsubplots = 2 | |
818 |
|
818 | |||
819 | self.createFigure(id = id, |
|
819 | self.createFigure(id = id, | |
820 | wintitle = wintitle, |
|
820 | wintitle = wintitle, | |
821 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
821 | widthplot = self.WIDTH + self.WIDTHPROF, | |
822 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
822 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
823 | show=show) |
|
823 | show=show) | |
824 |
|
824 | |||
825 | nrow, ncol = self.getSubplots() |
|
825 | nrow, ncol = self.getSubplots() | |
826 |
|
826 | |||
827 | counter = 0 |
|
827 | counter = 0 | |
828 | for y in range(nrow): |
|
828 | for y in range(nrow): | |
829 | for x in range(ncol): |
|
829 | for x in range(ncol): | |
830 |
|
830 | |||
831 | if counter >= self.nplots: |
|
831 | if counter >= self.nplots: | |
832 | break |
|
832 | break | |
833 |
|
833 | |||
834 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
834 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
835 |
|
835 | |||
836 | if showprofile: |
|
836 | if showprofile: | |
837 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
837 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
838 |
|
838 | |||
839 | counter += 1 |
|
839 | counter += 1 | |
840 |
|
840 | |||
841 | def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True, |
|
841 | def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True, | |
842 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
842 | xmin=None, xmax=None, ymin=None, ymax=None, | |
843 | save=False, figpath='./', figfile=None, show=True): |
|
843 | save=False, figpath='./', figfile=None, show=True): | |
844 |
|
844 | |||
845 | """ |
|
845 | """ | |
846 |
|
846 | |||
847 | Input: |
|
847 | Input: | |
848 | dataOut : |
|
848 | dataOut : | |
849 | id : |
|
849 | id : | |
850 | wintitle : |
|
850 | wintitle : | |
851 | channelList : |
|
851 | channelList : | |
852 | showProfile : |
|
852 | showProfile : | |
853 | xmin : None, |
|
853 | xmin : None, | |
854 | xmax : None, |
|
854 | xmax : None, | |
855 | zmin : None, |
|
855 | zmin : None, | |
856 | zmax : None |
|
856 | zmax : None | |
857 | """ |
|
857 | """ | |
858 |
|
858 | |||
859 | if cutHeight==None: |
|
859 | if cutHeight==None: | |
860 | h=270 |
|
860 | h=270 | |
861 | heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin() |
|
861 | heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin() | |
862 | cutHeight = dataOut.heightList[heightindex] |
|
862 | cutHeight = dataOut.heightList[heightindex] | |
863 |
|
863 | |||
864 | factor = dataOut.normFactor |
|
864 | factor = dataOut.normFactor | |
865 | x = dataOut.abscissaRange[:-1] |
|
865 | x = dataOut.abscissaRange[:-1] | |
866 | #y = dataOut.getHeiRange() |
|
866 | #y = dataOut.getHeiRange() | |
867 |
|
867 | |||
868 | z = dataOut.data_pre[:,:,heightindex]/factor |
|
868 | z = dataOut.data_pre[:,:,heightindex]/factor | |
869 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
869 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
870 | avg = numpy.average(z, axis=1) |
|
870 | avg = numpy.average(z, axis=1) | |
871 | listChannels = z.shape[0] |
|
871 | listChannels = z.shape[0] | |
872 |
|
872 | |||
873 | #Reconstruct Function |
|
873 | #Reconstruct Function | |
874 | if fit==True: |
|
874 | if fit==True: | |
875 | groupArray = dataOut.groupList |
|
875 | groupArray = dataOut.groupList | |
876 | listChannels = groupArray.reshape((groupArray.size)) |
|
876 | listChannels = groupArray.reshape((groupArray.size)) | |
877 | listChannels.sort() |
|
877 | listChannels.sort() | |
878 | spcFitLine = numpy.zeros(z.shape) |
|
878 | spcFitLine = numpy.zeros(z.shape) | |
879 | constants = dataOut.constants |
|
879 | constants = dataOut.constants | |
880 |
|
880 | |||
881 | nGroups = groupArray.shape[0] |
|
881 | nGroups = groupArray.shape[0] | |
882 | nChannels = groupArray.shape[1] |
|
882 | nChannels = groupArray.shape[1] | |
883 | nProfiles = z.shape[1] |
|
883 | nProfiles = z.shape[1] | |
884 |
|
884 | |||
885 | for f in range(nGroups): |
|
885 | for f in range(nGroups): | |
886 | groupChann = groupArray[f,:] |
|
886 | groupChann = groupArray[f,:] | |
887 | p = dataOut.data_param[f,:,heightindex] |
|
887 | p = dataOut.data_param[f,:,heightindex] | |
888 | # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167]) |
|
888 | # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167]) | |
889 | fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles |
|
889 | fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles | |
890 | fitLineAux = fitLineAux.reshape((nChannels,nProfiles)) |
|
890 | fitLineAux = fitLineAux.reshape((nChannels,nProfiles)) | |
891 | spcFitLine[groupChann,:] = fitLineAux |
|
891 | spcFitLine[groupChann,:] = fitLineAux | |
892 | # spcFitLine = spcFitLine/factor |
|
892 | # spcFitLine = spcFitLine/factor | |
893 |
|
893 | |||
894 | z = z[listChannels,:] |
|
894 | z = z[listChannels,:] | |
895 | spcFitLine = spcFitLine[listChannels,:] |
|
895 | spcFitLine = spcFitLine[listChannels,:] | |
896 | spcFitLinedB = 10*numpy.log10(spcFitLine) |
|
896 | spcFitLinedB = 10*numpy.log10(spcFitLine) | |
897 |
|
897 | |||
898 | zdB = 10*numpy.log10(z) |
|
898 | zdB = 10*numpy.log10(z) | |
899 | #thisDatetime = dataOut.datatime |
|
899 | #thisDatetime = dataOut.datatime | |
900 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
900 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
901 | title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
901 | title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
902 | xlabel = "Velocity (m/s)" |
|
902 | xlabel = "Velocity (m/s)" | |
903 | ylabel = "Spectrum" |
|
903 | ylabel = "Spectrum" | |
904 |
|
904 | |||
905 | if not self.__isConfig: |
|
905 | if not self.__isConfig: | |
906 |
|
906 | |||
907 | nplots = listChannels.size |
|
907 | nplots = listChannels.size | |
908 |
|
908 | |||
909 | self.setup(id=id, |
|
909 | self.setup(id=id, | |
910 | nplots=nplots, |
|
910 | nplots=nplots, | |
911 | wintitle=wintitle, |
|
911 | wintitle=wintitle, | |
912 | showprofile=showprofile, |
|
912 | showprofile=showprofile, | |
913 | show=show) |
|
913 | show=show) | |
914 |
|
914 | |||
915 | if xmin == None: xmin = numpy.nanmin(x) |
|
915 | if xmin == None: xmin = numpy.nanmin(x) | |
916 | if xmax == None: xmax = numpy.nanmax(x) |
|
916 | if xmax == None: xmax = numpy.nanmax(x) | |
917 | if ymin == None: ymin = numpy.nanmin(zdB) |
|
917 | if ymin == None: ymin = numpy.nanmin(zdB) | |
918 | if ymax == None: ymax = numpy.nanmax(zdB)+2 |
|
918 | if ymax == None: ymax = numpy.nanmax(zdB)+2 | |
919 |
|
919 | |||
920 | self.__isConfig = True |
|
920 | self.__isConfig = True | |
921 |
|
921 | |||
922 | self.setWinTitle(title) |
|
922 | self.setWinTitle(title) | |
923 | for i in range(self.nplots): |
|
923 | for i in range(self.nplots): | |
924 | # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i]) |
|
924 | # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i]) | |
925 | title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i]+1) |
|
925 | title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i]+1) | |
926 | axes = self.axesList[i*self.__nsubplots] |
|
926 | axes = self.axesList[i*self.__nsubplots] | |
927 | if fit == False: |
|
927 | if fit == False: | |
928 | axes.pline(x, zdB[i,:], |
|
928 | axes.pline(x, zdB[i,:], | |
929 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
929 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
930 | xlabel=xlabel, ylabel=ylabel, title=title |
|
930 | xlabel=xlabel, ylabel=ylabel, title=title | |
931 | ) |
|
931 | ) | |
932 | if fit == True: |
|
932 | if fit == True: | |
933 | fitline=spcFitLinedB[i,:] |
|
933 | fitline=spcFitLinedB[i,:] | |
934 | y=numpy.vstack([zdB[i,:],fitline] ) |
|
934 | y=numpy.vstack([zdB[i,:],fitline] ) | |
935 | legendlabels=['Data','Fitting'] |
|
935 | legendlabels=['Data','Fitting'] | |
936 | axes.pmultilineyaxis(x, y, |
|
936 | axes.pmultilineyaxis(x, y, | |
937 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
937 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
938 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
938 | xlabel=xlabel, ylabel=ylabel, title=title, | |
939 | legendlabels=legendlabels, marker=None, |
|
939 | legendlabels=legendlabels, marker=None, | |
940 | linestyle='solid', grid='both') |
|
940 | linestyle='solid', grid='both') | |
941 |
|
941 | |||
942 | self.draw() |
|
942 | self.draw() | |
943 |
|
943 | |||
944 | if save: |
|
944 | if save: | |
945 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
945 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
946 | if figfile == None: |
|
946 | if figfile == None: | |
947 | figfile = self.getFilename(name = date) |
|
947 | figfile = self.getFilename(name = date) | |
948 |
|
948 | |||
949 | self.saveFigure(figpath, figfile) |
|
949 | self.saveFigure(figpath, figfile) | |
950 |
|
950 | |||
951 |
|
951 | |||
952 | class EWDriftsPlot(Figure): |
|
952 | class EWDriftsPlot(Figure): | |
953 |
|
953 | |||
954 | __isConfig = None |
|
954 | __isConfig = None | |
955 | __nsubplots = None |
|
955 | __nsubplots = None | |
956 |
|
956 | |||
957 | WIDTHPROF = None |
|
957 | WIDTHPROF = None | |
958 | HEIGHTPROF = None |
|
958 | HEIGHTPROF = None | |
959 | PREFIX = 'drift' |
|
959 | PREFIX = 'drift' | |
960 |
|
960 | |||
961 | def __init__(self): |
|
961 | def __init__(self): | |
962 |
|
962 | |||
963 | self.timerange = 2*60*60 |
|
963 | self.timerange = 2*60*60 | |
964 | self.isConfig = False |
|
964 | self.isConfig = False | |
965 | self.__nsubplots = 1 |
|
965 | self.__nsubplots = 1 | |
966 |
|
966 | |||
967 | self.WIDTH = 800 |
|
967 | self.WIDTH = 800 | |
968 | self.HEIGHT = 150 |
|
968 | self.HEIGHT = 150 | |
969 | self.WIDTHPROF = 120 |
|
969 | self.WIDTHPROF = 120 | |
970 | self.HEIGHTPROF = 0 |
|
970 | self.HEIGHTPROF = 0 | |
971 | self.counter_imagwr = 0 |
|
971 | self.counter_imagwr = 0 | |
972 |
|
972 | |||
973 | self.PLOT_CODE = 0 |
|
973 | self.PLOT_CODE = 0 | |
974 | self.FTP_WEI = None |
|
974 | self.FTP_WEI = None | |
975 | self.EXP_CODE = None |
|
975 | self.EXP_CODE = None | |
976 | self.SUB_EXP_CODE = None |
|
976 | self.SUB_EXP_CODE = None | |
977 | self.PLOT_POS = None |
|
977 | self.PLOT_POS = None | |
978 | self.tmin = None |
|
978 | self.tmin = None | |
979 | self.tmax = None |
|
979 | self.tmax = None | |
980 |
|
980 | |||
981 | self.xmin = None |
|
981 | self.xmin = None | |
982 | self.xmax = None |
|
982 | self.xmax = None | |
983 |
|
983 | |||
984 | self.figfile = None |
|
984 | self.figfile = None | |
985 |
|
985 | |||
986 | def getSubplots(self): |
|
986 | def getSubplots(self): | |
987 |
|
987 | |||
988 | ncol = 1 |
|
988 | ncol = 1 | |
989 | nrow = self.nplots |
|
989 | nrow = self.nplots | |
990 |
|
990 | |||
991 | return nrow, ncol |
|
991 | return nrow, ncol | |
992 |
|
992 | |||
993 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
993 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
994 |
|
994 | |||
995 | self.__showprofile = showprofile |
|
995 | self.__showprofile = showprofile | |
996 | self.nplots = nplots |
|
996 | self.nplots = nplots | |
997 |
|
997 | |||
998 | ncolspan = 1 |
|
998 | ncolspan = 1 | |
999 | colspan = 1 |
|
999 | colspan = 1 | |
1000 |
|
1000 | |||
1001 | self.createFigure(id = id, |
|
1001 | self.createFigure(id = id, | |
1002 | wintitle = wintitle, |
|
1002 | wintitle = wintitle, | |
1003 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1003 | widthplot = self.WIDTH + self.WIDTHPROF, | |
1004 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1004 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
1005 | show=show) |
|
1005 | show=show) | |
1006 |
|
1006 | |||
1007 | nrow, ncol = self.getSubplots() |
|
1007 | nrow, ncol = self.getSubplots() | |
1008 |
|
1008 | |||
1009 | counter = 0 |
|
1009 | counter = 0 | |
1010 | for y in range(nrow): |
|
1010 | for y in range(nrow): | |
1011 | if counter >= self.nplots: |
|
1011 | if counter >= self.nplots: | |
1012 | break |
|
1012 | break | |
1013 |
|
1013 | |||
1014 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) |
|
1014 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) | |
1015 | counter += 1 |
|
1015 | counter += 1 | |
1016 |
|
1016 | |||
1017 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
1017 | def run(self, dataOut, id, wintitle="", channelList=None, | |
1018 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
1018 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
1019 | zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None, |
|
1019 | zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None, | |
1020 | timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False, |
|
1020 | timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False, | |
1021 | save=False, figpath='', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
1021 | save=False, figpath='', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
1022 | server=None, folder=None, username=None, password=None, |
|
1022 | server=None, folder=None, username=None, password=None, | |
1023 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1023 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1024 | """ |
|
1024 | """ | |
1025 |
|
1025 | |||
1026 | Input: |
|
1026 | Input: | |
1027 | dataOut : |
|
1027 | dataOut : | |
1028 | id : |
|
1028 | id : | |
1029 | wintitle : |
|
1029 | wintitle : | |
1030 | channelList : |
|
1030 | channelList : | |
1031 | showProfile : |
|
1031 | showProfile : | |
1032 | xmin : None, |
|
1032 | xmin : None, | |
1033 | xmax : None, |
|
1033 | xmax : None, | |
1034 | ymin : None, |
|
1034 | ymin : None, | |
1035 | ymax : None, |
|
1035 | ymax : None, | |
1036 | zmin : None, |
|
1036 | zmin : None, | |
1037 | zmax : None |
|
1037 | zmax : None | |
1038 | """ |
|
1038 | """ | |
1039 |
|
1039 | |||
1040 | if channelList == None: |
|
1040 | if channelList == None: | |
1041 | channelIndexList = dataOut.channelIndexList |
|
1041 | channelIndexList = dataOut.channelIndexList | |
1042 | else: |
|
1042 | else: | |
1043 | channelIndexList = [] |
|
1043 | channelIndexList = [] | |
1044 | for channel in channelList: |
|
1044 | for channel in channelList: | |
1045 | if channel not in dataOut.channelList: |
|
1045 | if channel not in dataOut.channelList: | |
1046 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1046 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1047 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1047 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1048 |
|
1048 | |||
1049 | if timerange != None: |
|
1049 | if timerange != None: | |
1050 | self.timerange = timerange |
|
1050 | self.timerange = timerange | |
1051 |
|
1051 | |||
1052 | tmin = None |
|
1052 | tmin = None | |
1053 | tmax = None |
|
1053 | tmax = None | |
1054 |
|
1054 | |||
1055 | x = dataOut.getTimeRange1() |
|
1055 | x = dataOut.getTimeRange1() | |
1056 | # y = dataOut.heightRange |
|
1056 | # y = dataOut.heightRange | |
1057 | y = dataOut.heightList |
|
1057 | y = dataOut.heightList | |
1058 |
|
1058 | |||
1059 | z = dataOut.data_output |
|
1059 | z = dataOut.data_output | |
1060 | nplots = z.shape[0] #Number of wind dimensions estimated |
|
1060 | nplots = z.shape[0] #Number of wind dimensions estimated | |
1061 | nplotsw = nplots |
|
1061 | nplotsw = nplots | |
1062 |
|
1062 | |||
1063 | #If there is a SNR function defined |
|
1063 | #If there is a SNR function defined | |
1064 | if dataOut.SNR != None: |
|
1064 | if dataOut.data_SNR != None: | |
1065 | nplots += 1 |
|
1065 | nplots += 1 | |
1066 | SNR = dataOut.SNR |
|
1066 | SNR = dataOut.data_SNR | |
1067 |
|
1067 | |||
1068 | if SNR_1: |
|
1068 | if SNR_1: | |
1069 | SNR += 1 |
|
1069 | SNR += 1 | |
1070 |
|
1070 | |||
1071 | SNRavg = numpy.average(SNR, axis=0) |
|
1071 | SNRavg = numpy.average(SNR, axis=0) | |
1072 |
|
1072 | |||
1073 | SNRdB = 10*numpy.log10(SNR) |
|
1073 | SNRdB = 10*numpy.log10(SNR) | |
1074 | SNRavgdB = 10*numpy.log10(SNRavg) |
|
1074 | SNRavgdB = 10*numpy.log10(SNRavg) | |
1075 |
|
1075 | |||
1076 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] |
|
1076 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] | |
1077 |
|
1077 | |||
1078 | for i in range(nplotsw): |
|
1078 | for i in range(nplotsw): | |
1079 | z[i,ind] = numpy.nan |
|
1079 | z[i,ind] = numpy.nan | |
1080 |
|
1080 | |||
1081 |
|
1081 | |||
1082 | showprofile = False |
|
1082 | showprofile = False | |
1083 | # thisDatetime = dataOut.datatime |
|
1083 | # thisDatetime = dataOut.datatime | |
1084 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1084 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
1085 | title = wintitle + " EW Drifts" |
|
1085 | title = wintitle + " EW Drifts" | |
1086 | xlabel = "" |
|
1086 | xlabel = "" | |
1087 | ylabel = "Height (Km)" |
|
1087 | ylabel = "Height (Km)" | |
1088 |
|
1088 | |||
1089 | if not self.__isConfig: |
|
1089 | if not self.__isConfig: | |
1090 |
|
1090 | |||
1091 | self.setup(id=id, |
|
1091 | self.setup(id=id, | |
1092 | nplots=nplots, |
|
1092 | nplots=nplots, | |
1093 | wintitle=wintitle, |
|
1093 | wintitle=wintitle, | |
1094 | showprofile=showprofile, |
|
1094 | showprofile=showprofile, | |
1095 | show=show) |
|
1095 | show=show) | |
1096 |
|
1096 | |||
1097 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1097 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1098 |
|
1098 | |||
1099 | if ymin == None: ymin = numpy.nanmin(y) |
|
1099 | if ymin == None: ymin = numpy.nanmin(y) | |
1100 | if ymax == None: ymax = numpy.nanmax(y) |
|
1100 | if ymax == None: ymax = numpy.nanmax(y) | |
1101 |
|
1101 | |||
1102 | if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:])) |
|
1102 | if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:])) | |
1103 | if zminZonal == None: zminZonal = -zmaxZonal |
|
1103 | if zminZonal == None: zminZonal = -zmaxZonal | |
1104 | if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:])) |
|
1104 | if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:])) | |
1105 | if zminVertical == None: zminVertical = -zmaxVertical |
|
1105 | if zminVertical == None: zminVertical = -zmaxVertical | |
1106 |
|
1106 | |||
1107 | if dataOut.SNR != None: |
|
1107 | if dataOut.data_SNR != None: | |
1108 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) |
|
1108 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) | |
1109 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) |
|
1109 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) | |
1110 |
|
1110 | |||
1111 | self.FTP_WEI = ftp_wei |
|
1111 | self.FTP_WEI = ftp_wei | |
1112 | self.EXP_CODE = exp_code |
|
1112 | self.EXP_CODE = exp_code | |
1113 | self.SUB_EXP_CODE = sub_exp_code |
|
1113 | self.SUB_EXP_CODE = sub_exp_code | |
1114 | self.PLOT_POS = plot_pos |
|
1114 | self.PLOT_POS = plot_pos | |
1115 |
|
1115 | |||
1116 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1116 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1117 | self.__isConfig = True |
|
1117 | self.__isConfig = True | |
1118 |
|
1118 | |||
1119 |
|
1119 | |||
1120 | self.setWinTitle(title) |
|
1120 | self.setWinTitle(title) | |
1121 |
|
1121 | |||
1122 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
1122 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
1123 | x[1] = self.xmax |
|
1123 | x[1] = self.xmax | |
1124 |
|
1124 | |||
1125 | strWind = ['Zonal','Vertical'] |
|
1125 | strWind = ['Zonal','Vertical'] | |
1126 | strCb = 'Velocity (m/s)' |
|
1126 | strCb = 'Velocity (m/s)' | |
1127 | zmaxVector = [zmaxZonal, zmaxVertical] |
|
1127 | zmaxVector = [zmaxZonal, zmaxVertical] | |
1128 | zminVector = [zminZonal, zminVertical] |
|
1128 | zminVector = [zminZonal, zminVertical] | |
1129 |
|
1129 | |||
1130 | for i in range(nplotsw): |
|
1130 | for i in range(nplotsw): | |
1131 |
|
1131 | |||
1132 | title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1132 | title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1133 | axes = self.axesList[i*self.__nsubplots] |
|
1133 | axes = self.axesList[i*self.__nsubplots] | |
1134 |
|
1134 | |||
1135 | z1 = z[i,:].reshape((1,-1)) |
|
1135 | z1 = z[i,:].reshape((1,-1)) | |
1136 |
|
1136 | |||
1137 | axes.pcolorbuffer(x, y, z1, |
|
1137 | axes.pcolorbuffer(x, y, z1, | |
1138 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], |
|
1138 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], | |
1139 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1139 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1140 | ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r") |
|
1140 | ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r") | |
1141 |
|
1141 | |||
1142 | if dataOut.SNR != None: |
|
1142 | if dataOut.data_SNR != None: | |
1143 | i += 1 |
|
1143 | i += 1 | |
1144 | if SNR_1: |
|
1144 | if SNR_1: | |
1145 | title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1145 | title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1146 | else: |
|
1146 | else: | |
1147 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1147 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1148 | axes = self.axesList[i*self.__nsubplots] |
|
1148 | axes = self.axesList[i*self.__nsubplots] | |
1149 | SNRavgdB = SNRavgdB.reshape((1,-1)) |
|
1149 | SNRavgdB = SNRavgdB.reshape((1,-1)) | |
1150 |
|
1150 | |||
1151 | axes.pcolorbuffer(x, y, SNRavgdB, |
|
1151 | axes.pcolorbuffer(x, y, SNRavgdB, | |
1152 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
1152 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
1153 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1153 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1154 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") |
|
1154 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") | |
1155 |
|
1155 | |||
1156 | self.draw() |
|
1156 | self.draw() | |
1157 |
|
1157 | |||
1158 | if self.figfile == None: |
|
1158 | if self.figfile == None: | |
1159 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1159 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1160 | self.figfile = self.getFilename(name = str_datetime) |
|
1160 | self.figfile = self.getFilename(name = str_datetime) | |
1161 |
|
1161 | |||
1162 | if figpath != '': |
|
1162 | if figpath != '': | |
1163 |
|
1163 | |||
1164 | self.counter_imagwr += 1 |
|
1164 | self.counter_imagwr += 1 | |
1165 | if (self.counter_imagwr>=wr_period): |
|
1165 | if (self.counter_imagwr>=wr_period): | |
1166 | # store png plot to local folder |
|
1166 | # store png plot to local folder | |
1167 | self.saveFigure(figpath, self.figfile) |
|
1167 | self.saveFigure(figpath, self.figfile) | |
1168 | # store png plot to FTP server according to RT-Web format |
|
1168 | # store png plot to FTP server according to RT-Web format | |
1169 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
1169 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
1170 | ftp_filename = os.path.join(figpath, name) |
|
1170 | ftp_filename = os.path.join(figpath, name) | |
1171 | self.saveFigure(figpath, ftp_filename) |
|
1171 | self.saveFigure(figpath, ftp_filename) | |
1172 |
|
1172 | |||
1173 | self.counter_imagwr = 0 |
|
1173 | self.counter_imagwr = 0 | |
1174 |
|
1174 | |||
1175 | if x[1] >= self.axesList[0].xmax: |
|
1175 | if x[1] >= self.axesList[0].xmax: | |
1176 | self.counter_imagwr = wr_period |
|
1176 | self.counter_imagwr = wr_period | |
1177 | self.__isConfig = False |
|
1177 | self.__isConfig = False | |
1178 | self.figfile = None No newline at end of file |
|
1178 | self.figfile = None |
@@ -1,4 +1,5 | |||||
1 | from jroIO_voltage import * |
|
1 | from jroIO_voltage import * | |
2 | from jroIO_spectra import * |
|
2 | from jroIO_spectra import * | |
3 | from jroIO_heispectra import * |
|
3 | from jroIO_heispectra import * | |
4 | from jroIO_amisr import * No newline at end of file |
|
4 | from jroIO_amisr import * | |
|
5 | from jroIO_HDF5 import * No newline at end of file |
@@ -1,1749 +1,1754 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import math |
|
2 | import math | |
3 | from scipy import optimize |
|
3 | from scipy import optimize | |
4 | from scipy import interpolate |
|
4 | from scipy import interpolate | |
5 | from scipy import signal |
|
5 | from scipy import signal | |
6 | from scipy import stats |
|
6 | from scipy import stats | |
7 | import re |
|
7 | import re | |
8 | import datetime |
|
8 | import datetime | |
9 | import copy |
|
9 | import copy | |
10 | import sys |
|
10 | import sys | |
11 | import importlib |
|
11 | import importlib | |
12 | import itertools |
|
12 | import itertools | |
13 |
|
13 | |||
14 | from jroproc_base import ProcessingUnit, Operation |
|
14 | from jroproc_base import ProcessingUnit, Operation | |
15 | from model.data.jrodata import Parameters |
|
15 | from model.data.jrodata import Parameters | |
16 |
|
16 | |||
17 |
|
17 | |||
18 | class ParametersProc(ProcessingUnit): |
|
18 | class ParametersProc(ProcessingUnit): | |
19 |
|
19 | |||
20 | nSeconds = None |
|
20 | nSeconds = None | |
21 |
|
21 | |||
22 | def __init__(self): |
|
22 | def __init__(self): | |
23 | ProcessingUnit.__init__(self) |
|
23 | ProcessingUnit.__init__(self) | |
24 |
|
24 | |||
25 | self.objectDict = {} |
|
25 | self.objectDict = {} | |
26 | self.buffer = None |
|
26 | self.buffer = None | |
27 | self.firstdatatime = None |
|
27 | self.firstdatatime = None | |
28 | self.profIndex = 0 |
|
28 | self.profIndex = 0 | |
29 | self.dataOut = Parameters() |
|
29 | self.dataOut = Parameters() | |
30 |
|
30 | |||
31 | def __updateObjFromInput(self): |
|
31 | def __updateObjFromInput(self): | |
32 |
|
32 | |||
33 | self.dataOut.inputUnit = self.dataIn.type |
|
33 | self.dataOut.inputUnit = self.dataIn.type | |
34 |
|
34 | |||
35 | self.dataOut.timeZone = self.dataIn.timeZone |
|
35 | self.dataOut.timeZone = self.dataIn.timeZone | |
36 | self.dataOut.dstFlag = self.dataIn.dstFlag |
|
36 | self.dataOut.dstFlag = self.dataIn.dstFlag | |
37 | self.dataOut.errorCount = self.dataIn.errorCount |
|
37 | self.dataOut.errorCount = self.dataIn.errorCount | |
38 | self.dataOut.useLocalTime = self.dataIn.useLocalTime |
|
38 | self.dataOut.useLocalTime = self.dataIn.useLocalTime | |
39 |
|
39 | |||
40 | self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy() |
|
40 | self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy() | |
41 | self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy() |
|
41 | self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy() | |
42 | self.dataOut.channelList = self.dataIn.channelList |
|
42 | self.dataOut.channelList = self.dataIn.channelList | |
43 | self.dataOut.heightList = self.dataIn.heightList |
|
43 | self.dataOut.heightList = self.dataIn.heightList | |
44 | self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
44 | self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
45 | # self.dataOut.nHeights = self.dataIn.nHeights |
|
45 | # self.dataOut.nHeights = self.dataIn.nHeights | |
46 | # self.dataOut.nChannels = self.dataIn.nChannels |
|
46 | # self.dataOut.nChannels = self.dataIn.nChannels | |
47 | self.dataOut.nBaud = self.dataIn.nBaud |
|
47 | self.dataOut.nBaud = self.dataIn.nBaud | |
48 | self.dataOut.nCode = self.dataIn.nCode |
|
48 | self.dataOut.nCode = self.dataIn.nCode | |
49 | self.dataOut.code = self.dataIn.code |
|
49 | self.dataOut.code = self.dataIn.code | |
50 | # self.dataOut.nProfiles = self.dataOut.nFFTPoints |
|
50 | # self.dataOut.nProfiles = self.dataOut.nFFTPoints | |
51 | self.dataOut.flagTimeBlock = self.dataIn.flagTimeBlock |
|
51 | self.dataOut.flagTimeBlock = self.dataIn.flagTimeBlock | |
52 | self.dataOut.utctime = self.firstdatatime |
|
52 | self.dataOut.utctime = self.firstdatatime | |
53 | self.dataOut.flagDecodeData = self.dataIn.flagDecodeData #asumo q la data esta decodificada |
|
53 | self.dataOut.flagDecodeData = self.dataIn.flagDecodeData #asumo q la data esta decodificada | |
54 | self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip |
|
54 | self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip | |
55 | # self.dataOut.nCohInt = self.dataIn.nCohInt |
|
55 | # self.dataOut.nCohInt = self.dataIn.nCohInt | |
56 | # self.dataOut.nIncohInt = 1 |
|
56 | # self.dataOut.nIncohInt = 1 | |
57 | self.dataOut.ippSeconds = self.dataIn.ippSeconds |
|
57 | self.dataOut.ippSeconds = self.dataIn.ippSeconds | |
58 | # self.dataOut.windowOfFilter = self.dataIn.windowOfFilter |
|
58 | # self.dataOut.windowOfFilter = self.dataIn.windowOfFilter | |
59 | self.dataOut.timeInterval = self.dataIn.timeInterval |
|
59 | self.dataOut.timeInterval = self.dataIn.timeInterval | |
60 | self.dataOut.heightRange = self.dataIn.getHeiRange() |
|
60 | self.dataOut.heightRange = self.dataIn.getHeiRange() | |
61 | self.dataOut.frequency = self.dataIn.frequency |
|
61 | self.dataOut.frequency = self.dataIn.frequency | |
62 |
|
62 | |||
63 | def run(self, nSeconds = None, nProfiles = None): |
|
63 | def run(self, nSeconds = None, nProfiles = None): | |
64 |
|
64 | |||
65 |
|
65 | |||
66 |
|
66 | |||
67 | if self.firstdatatime == None: |
|
67 | if self.firstdatatime == None: | |
68 | self.firstdatatime = self.dataIn.utctime |
|
68 | self.firstdatatime = self.dataIn.utctime | |
69 |
|
69 | |||
70 | #---------------------- Voltage Data --------------------------- |
|
70 | #---------------------- Voltage Data --------------------------- | |
71 |
|
71 | |||
72 | if self.dataIn.type == "Voltage": |
|
72 | if self.dataIn.type == "Voltage": | |
73 | self.dataOut.flagNoData = True |
|
73 | self.dataOut.flagNoData = True | |
74 | if nSeconds != None: |
|
74 | if nSeconds != None: | |
75 | self.nSeconds = nSeconds |
|
75 | self.nSeconds = nSeconds | |
76 | self.nProfiles= int(numpy.floor(nSeconds/(self.dataIn.ippSeconds*self.dataIn.nCohInt))) |
|
76 | self.nProfiles= int(numpy.floor(nSeconds/(self.dataIn.ippSeconds*self.dataIn.nCohInt))) | |
77 |
|
77 | |||
78 | if self.buffer == None: |
|
78 | if self.buffer == None: | |
79 | self.buffer = numpy.zeros((self.dataIn.nChannels, |
|
79 | self.buffer = numpy.zeros((self.dataIn.nChannels, | |
80 | self.nProfiles, |
|
80 | self.nProfiles, | |
81 | self.dataIn.nHeights), |
|
81 | self.dataIn.nHeights), | |
82 | dtype='complex') |
|
82 | dtype='complex') | |
83 |
|
83 | |||
84 | self.buffer[:,self.profIndex,:] = self.dataIn.data.copy() |
|
84 | self.buffer[:,self.profIndex,:] = self.dataIn.data.copy() | |
85 | self.profIndex += 1 |
|
85 | self.profIndex += 1 | |
86 |
|
86 | |||
87 | if self.profIndex == self.nProfiles: |
|
87 | if self.profIndex == self.nProfiles: | |
88 |
|
88 | |||
89 | self.__updateObjFromInput() |
|
89 | self.__updateObjFromInput() | |
90 | self.dataOut.data_pre = self.buffer.copy() |
|
90 | self.dataOut.data_pre = self.buffer.copy() | |
91 | self.dataOut.paramInterval = nSeconds |
|
91 | self.dataOut.paramInterval = nSeconds | |
92 | self.dataOut.flagNoData = False |
|
92 | self.dataOut.flagNoData = False | |
93 |
|
93 | |||
94 | self.buffer = None |
|
94 | self.buffer = None | |
95 | self.firstdatatime = None |
|
95 | self.firstdatatime = None | |
96 | self.profIndex = 0 |
|
96 | self.profIndex = 0 | |
97 | return |
|
97 | return | |
98 |
|
98 | |||
99 | #---------------------- Spectra Data --------------------------- |
|
99 | #---------------------- Spectra Data --------------------------- | |
100 |
|
100 | |||
101 | if self.dataIn.type == "Spectra": |
|
101 | if self.dataIn.type == "Spectra": | |
102 | self.dataOut.data_pre = self.dataIn.data_spc.copy() |
|
102 | self.dataOut.data_pre = self.dataIn.data_spc.copy() | |
103 | self.dataOut.abscissaRange = self.dataIn.getVelRange(1) |
|
103 | self.dataOut.abscissaRange = self.dataIn.getVelRange(1) | |
104 | self.dataOut.noise = self.dataIn.getNoise() |
|
104 | self.dataOut.noise = self.dataIn.getNoise() | |
105 | self.dataOut.normFactor = self.dataIn.normFactor |
|
105 | self.dataOut.normFactor = self.dataIn.normFactor | |
106 | self.dataOut.flagNoData = False |
|
106 | self.dataOut.flagNoData = False | |
107 |
|
107 | |||
108 | #---------------------- Correlation Data --------------------------- |
|
108 | #---------------------- Correlation Data --------------------------- | |
109 |
|
109 | |||
110 | if self.dataIn.type == "Correlation": |
|
110 | if self.dataIn.type == "Correlation": | |
111 | lagRRange = self.dataIn.lagR |
|
111 | lagRRange = self.dataIn.lagR | |
112 | indR = numpy.where(lagRRange == 0)[0][0] |
|
112 | indR = numpy.where(lagRRange == 0)[0][0] | |
113 |
|
113 | |||
114 | self.dataOut.data_pre = self.dataIn.data_corr.copy()[:,:,indR,:] |
|
114 | self.dataOut.data_pre = self.dataIn.data_corr.copy()[:,:,indR,:] | |
115 | self.dataOut.abscissaRange = self.dataIn.getLagTRange(1) |
|
115 | self.dataOut.abscissaRange = self.dataIn.getLagTRange(1) | |
116 | self.dataOut.noise = self.dataIn.noise |
|
116 | self.dataOut.noise = self.dataIn.noise | |
117 | self.dataOut.normFactor = self.dataIn.normFactor |
|
117 | self.dataOut.normFactor = self.dataIn.normFactor | |
118 | self.dataOut.SNR = self.dataIn.SNR |
|
118 | self.dataOut.data_SNR = self.dataIn.SNR | |
119 | self.dataOut.groupList = self.dataIn.pairsList |
|
119 | self.dataOut.groupList = self.dataIn.pairsList | |
120 | self.dataOut.flagNoData = False |
|
120 | self.dataOut.flagNoData = False | |
121 |
|
121 | |||
122 |
|
122 | |||
123 | self.__updateObjFromInput() |
|
123 | self.__updateObjFromInput() | |
124 | self.firstdatatime = None |
|
124 | self.firstdatatime = None | |
125 | self.dataOut.initUtcTime = self.dataIn.ltctime |
|
125 | self.dataOut.initUtcTime = self.dataIn.ltctime | |
126 | self.dataOut.outputInterval = self.dataIn.timeInterval |
|
126 | self.dataOut.outputInterval = self.dataIn.timeInterval | |
127 |
|
127 | |||
128 | #------------------- Get Moments ---------------------------------- |
|
128 | #------------------- Get Moments ---------------------------------- | |
129 | def GetMoments(self, channelList = None): |
|
129 | def GetMoments(self, channelList = None): | |
130 | ''' |
|
130 | ''' | |
131 | Function GetMoments() |
|
131 | Function GetMoments() | |
132 |
|
132 | |||
133 | Input: |
|
133 | Input: | |
134 | channelList : simple channel list to select e.g. [2,3,7] |
|
134 | channelList : simple channel list to select e.g. [2,3,7] | |
135 | self.dataOut.data_pre |
|
135 | self.dataOut.data_pre | |
136 | self.dataOut.abscissaRange |
|
136 | self.dataOut.abscissaRange | |
137 | self.dataOut.noise |
|
137 | self.dataOut.noise | |
138 |
|
138 | |||
139 | Affected: |
|
139 | Affected: | |
140 | self.dataOut.data_param |
|
140 | self.dataOut.data_param | |
141 | self.dataOut.SNR |
|
141 | self.dataOut.data_SNR | |
142 |
|
142 | |||
143 | ''' |
|
143 | ''' | |
144 | data = self.dataOut.data_pre |
|
144 | data = self.dataOut.data_pre | |
145 | absc = self.dataOut.abscissaRange[:-1] |
|
145 | absc = self.dataOut.abscissaRange[:-1] | |
146 | noise = self.dataOut.noise |
|
146 | noise = self.dataOut.noise | |
147 |
|
147 | |||
148 | data_param = numpy.zeros((data.shape[0], 4, data.shape[2])) |
|
148 | data_param = numpy.zeros((data.shape[0], 4, data.shape[2])) | |
149 |
|
149 | |||
150 | if channelList== None: |
|
150 | if channelList== None: | |
151 | channelList = self.dataIn.channelList |
|
151 | channelList = self.dataIn.channelList | |
152 | self.dataOut.channelList = channelList |
|
152 | self.dataOut.channelList = channelList | |
153 |
|
153 | |||
154 | for ind in channelList: |
|
154 | for ind in channelList: | |
155 | data_param[ind,:,:] = self.__calculateMoments(data[ind,:,:], absc, noise[ind]) |
|
155 | data_param[ind,:,:] = self.__calculateMoments(data[ind,:,:], absc, noise[ind]) | |
156 |
|
156 | |||
157 | self.dataOut.data_param = data_param[:,1:,:] |
|
157 | self.dataOut.data_param = data_param[:,1:,:] | |
158 | self.dataOut.SNR = data_param[:,0] |
|
158 | self.dataOut.data_SNR = data_param[:,0] | |
159 | return |
|
159 | return | |
160 |
|
160 | |||
161 | def __calculateMoments(self, oldspec, oldfreq, n0, nicoh = None, graph = None, smooth = None, type1 = None, fwindow = None, snrth = None, dc = None, aliasing = None, oldfd = None, wwauto = None): |
|
161 | def __calculateMoments(self, oldspec, oldfreq, n0, nicoh = None, graph = None, smooth = None, type1 = None, fwindow = None, snrth = None, dc = None, aliasing = None, oldfd = None, wwauto = None): | |
162 |
|
162 | |||
163 | if (nicoh == None): nicoh = 1 |
|
163 | if (nicoh == None): nicoh = 1 | |
164 | if (graph == None): graph = 0 |
|
164 | if (graph == None): graph = 0 | |
165 | if (smooth == None): smooth = 0 |
|
165 | if (smooth == None): smooth = 0 | |
166 | elif (self.smooth < 3): smooth = 0 |
|
166 | elif (self.smooth < 3): smooth = 0 | |
167 |
|
167 | |||
168 | if (type1 == None): type1 = 0 |
|
168 | if (type1 == None): type1 = 0 | |
169 | if (fwindow == None): fwindow = numpy.zeros(oldfreq.size) + 1 |
|
169 | if (fwindow == None): fwindow = numpy.zeros(oldfreq.size) + 1 | |
170 | if (snrth == None): snrth = -3 |
|
170 | if (snrth == None): snrth = -3 | |
171 | if (dc == None): dc = 0 |
|
171 | if (dc == None): dc = 0 | |
172 | if (aliasing == None): aliasing = 0 |
|
172 | if (aliasing == None): aliasing = 0 | |
173 | if (oldfd == None): oldfd = 0 |
|
173 | if (oldfd == None): oldfd = 0 | |
174 | if (wwauto == None): wwauto = 0 |
|
174 | if (wwauto == None): wwauto = 0 | |
175 |
|
175 | |||
176 | if (n0 < 1.e-20): n0 = 1.e-20 |
|
176 | if (n0 < 1.e-20): n0 = 1.e-20 | |
177 |
|
177 | |||
178 | freq = oldfreq |
|
178 | freq = oldfreq | |
179 | vec_power = numpy.zeros(oldspec.shape[1]) |
|
179 | vec_power = numpy.zeros(oldspec.shape[1]) | |
180 | vec_fd = numpy.zeros(oldspec.shape[1]) |
|
180 | vec_fd = numpy.zeros(oldspec.shape[1]) | |
181 | vec_w = numpy.zeros(oldspec.shape[1]) |
|
181 | vec_w = numpy.zeros(oldspec.shape[1]) | |
182 | vec_snr = numpy.zeros(oldspec.shape[1]) |
|
182 | vec_snr = numpy.zeros(oldspec.shape[1]) | |
183 |
|
183 | |||
184 | for ind in range(oldspec.shape[1]): |
|
184 | for ind in range(oldspec.shape[1]): | |
185 |
|
185 | |||
186 | spec = oldspec[:,ind] |
|
186 | spec = oldspec[:,ind] | |
187 | aux = spec*fwindow |
|
187 | aux = spec*fwindow | |
188 | max_spec = aux.max() |
|
188 | max_spec = aux.max() | |
189 | m = list(aux).index(max_spec) |
|
189 | m = list(aux).index(max_spec) | |
190 |
|
190 | |||
191 | #Smooth |
|
191 | #Smooth | |
192 | if (smooth == 0): spec2 = spec |
|
192 | if (smooth == 0): spec2 = spec | |
193 | else: spec2 = scipy.ndimage.filters.uniform_filter1d(spec,size=smooth) |
|
193 | else: spec2 = scipy.ndimage.filters.uniform_filter1d(spec,size=smooth) | |
194 |
|
194 | |||
195 | # Calculo de Momentos |
|
195 | # Calculo de Momentos | |
196 | bb = spec2[range(m,spec2.size)] |
|
196 | bb = spec2[range(m,spec2.size)] | |
197 | bb = (bb<n0).nonzero() |
|
197 | bb = (bb<n0).nonzero() | |
198 | bb = bb[0] |
|
198 | bb = bb[0] | |
199 |
|
199 | |||
200 | ss = spec2[range(0,m + 1)] |
|
200 | ss = spec2[range(0,m + 1)] | |
201 | ss = (ss<n0).nonzero() |
|
201 | ss = (ss<n0).nonzero() | |
202 | ss = ss[0] |
|
202 | ss = ss[0] | |
203 |
|
203 | |||
204 | if (bb.size == 0): |
|
204 | if (bb.size == 0): | |
205 | bb0 = spec.size - 1 - m |
|
205 | bb0 = spec.size - 1 - m | |
206 | else: |
|
206 | else: | |
207 | bb0 = bb[0] - 1 |
|
207 | bb0 = bb[0] - 1 | |
208 | if (bb0 < 0): |
|
208 | if (bb0 < 0): | |
209 | bb0 = 0 |
|
209 | bb0 = 0 | |
210 |
|
210 | |||
211 | if (ss.size == 0): ss1 = 1 |
|
211 | if (ss.size == 0): ss1 = 1 | |
212 | else: ss1 = max(ss) + 1 |
|
212 | else: ss1 = max(ss) + 1 | |
213 |
|
213 | |||
214 | if (ss1 > m): ss1 = m |
|
214 | if (ss1 > m): ss1 = m | |
215 |
|
215 | |||
216 | valid = numpy.asarray(range(int(m + bb0 - ss1 + 1))) + ss1 |
|
216 | valid = numpy.asarray(range(int(m + bb0 - ss1 + 1))) + ss1 | |
217 | power = ((spec2[valid] - n0)*fwindow[valid]).sum() |
|
217 | power = ((spec2[valid] - n0)*fwindow[valid]).sum() | |
218 | fd = ((spec2[valid]- n0)*freq[valid]*fwindow[valid]).sum()/power |
|
218 | fd = ((spec2[valid]- n0)*freq[valid]*fwindow[valid]).sum()/power | |
219 | w = math.sqrt(((spec2[valid] - n0)*fwindow[valid]*(freq[valid]- fd)**2).sum()/power) |
|
219 | w = math.sqrt(((spec2[valid] - n0)*fwindow[valid]*(freq[valid]- fd)**2).sum()/power) | |
220 | snr = (spec2.mean()-n0)/n0 |
|
220 | snr = (spec2.mean()-n0)/n0 | |
221 |
|
221 | |||
222 | if (snr < 1.e-20) : |
|
222 | if (snr < 1.e-20) : | |
223 | snr = 1.e-20 |
|
223 | snr = 1.e-20 | |
224 |
|
224 | |||
225 | vec_power[ind] = power |
|
225 | vec_power[ind] = power | |
226 | vec_fd[ind] = fd |
|
226 | vec_fd[ind] = fd | |
227 | vec_w[ind] = w |
|
227 | vec_w[ind] = w | |
228 | vec_snr[ind] = snr |
|
228 | vec_snr[ind] = snr | |
229 |
|
229 | |||
230 | moments = numpy.vstack((vec_snr, vec_power, vec_fd, vec_w)) |
|
230 | moments = numpy.vstack((vec_snr, vec_power, vec_fd, vec_w)) | |
231 | return moments |
|
231 | return moments | |
232 |
|
232 | |||
233 | #------------------- Get Lags ---------------------------------- |
|
233 | #------------------- Get Lags ---------------------------------- | |
234 |
|
234 | |||
235 | def GetLags(self): |
|
235 | def GetLags(self): | |
236 | ''' |
|
236 | ''' | |
237 | Function GetMoments() |
|
237 | Function GetMoments() | |
238 |
|
238 | |||
239 | Input: |
|
239 | Input: | |
240 | self.dataOut.data_pre |
|
240 | self.dataOut.data_pre | |
241 | self.dataOut.abscissaRange |
|
241 | self.dataOut.abscissaRange | |
242 | self.dataOut.noise |
|
242 | self.dataOut.noise | |
243 | self.dataOut.normFactor |
|
243 | self.dataOut.normFactor | |
244 | self.dataOut.SNR |
|
244 | self.dataOut.data_SNR | |
245 | self.dataOut.groupList |
|
245 | self.dataOut.groupList | |
246 | self.dataOut.nChannels |
|
246 | self.dataOut.nChannels | |
247 |
|
247 | |||
248 | Affected: |
|
248 | Affected: | |
249 | self.dataOut.data_param |
|
249 | self.dataOut.data_param | |
250 |
|
250 | |||
251 | ''' |
|
251 | ''' | |
252 | data = self.dataOut.data_pre |
|
252 | data = self.dataOut.data_pre | |
253 | normFactor = self.dataOut.normFactor |
|
253 | normFactor = self.dataOut.normFactor | |
254 | nHeights = self.dataOut.nHeights |
|
254 | nHeights = self.dataOut.nHeights | |
255 | absc = self.dataOut.abscissaRange[:-1] |
|
255 | absc = self.dataOut.abscissaRange[:-1] | |
256 | noise = self.dataOut.noise |
|
256 | noise = self.dataOut.noise | |
257 | SNR = self.dataOut.SNR |
|
257 | SNR = self.dataOut.data_SNR | |
258 | pairsList = self.dataOut.groupList |
|
258 | pairsList = self.dataOut.groupList | |
259 | nChannels = self.dataOut.nChannels |
|
259 | nChannels = self.dataOut.nChannels | |
260 | pairsAutoCorr, pairsCrossCorr = self.__getPairsAutoCorr(pairsList, nChannels) |
|
260 | pairsAutoCorr, pairsCrossCorr = self.__getPairsAutoCorr(pairsList, nChannels) | |
261 | self.dataOut.data_param = numpy.zeros((len(pairsCrossCorr)*2 + 1, nHeights)) |
|
261 | self.dataOut.data_param = numpy.zeros((len(pairsCrossCorr)*2 + 1, nHeights)) | |
262 |
|
262 | |||
263 | dataNorm = numpy.abs(data) |
|
263 | dataNorm = numpy.abs(data) | |
264 | for l in range(len(pairsList)): |
|
264 | for l in range(len(pairsList)): | |
265 | dataNorm[l,:,:] = dataNorm[l,:,:]/normFactor[l,:] |
|
265 | dataNorm[l,:,:] = dataNorm[l,:,:]/normFactor[l,:] | |
266 |
|
266 | |||
267 | self.dataOut.data_param[:-1,:] = self.__calculateTaus(dataNorm, pairsCrossCorr, pairsAutoCorr, absc) |
|
267 | self.dataOut.data_param[:-1,:] = self.__calculateTaus(dataNorm, pairsCrossCorr, pairsAutoCorr, absc) | |
268 | self.dataOut.data_param[-1,:] = self.__calculateLag1Phase(data, pairsAutoCorr, absc) |
|
268 | self.dataOut.data_param[-1,:] = self.__calculateLag1Phase(data, pairsAutoCorr, absc) | |
269 | return |
|
269 | return | |
270 |
|
270 | |||
271 | def __getPairsAutoCorr(self, pairsList, nChannels): |
|
271 | def __getPairsAutoCorr(self, pairsList, nChannels): | |
272 |
|
272 | |||
273 | pairsAutoCorr = numpy.zeros(nChannels, dtype = 'int')*numpy.nan |
|
273 | pairsAutoCorr = numpy.zeros(nChannels, dtype = 'int')*numpy.nan | |
274 |
|
274 | |||
275 | for l in range(len(pairsList)): |
|
275 | for l in range(len(pairsList)): | |
276 | firstChannel = pairsList[l][0] |
|
276 | firstChannel = pairsList[l][0] | |
277 | secondChannel = pairsList[l][1] |
|
277 | secondChannel = pairsList[l][1] | |
278 |
|
278 | |||
279 | #Obteniendo pares de Autocorrelacion |
|
279 | #Obteniendo pares de Autocorrelacion | |
280 | if firstChannel == secondChannel: |
|
280 | if firstChannel == secondChannel: | |
281 | pairsAutoCorr[firstChannel] = int(l) |
|
281 | pairsAutoCorr[firstChannel] = int(l) | |
282 |
|
282 | |||
283 | pairsAutoCorr = pairsAutoCorr.astype(int) |
|
283 | pairsAutoCorr = pairsAutoCorr.astype(int) | |
284 |
|
284 | |||
285 | pairsCrossCorr = range(len(pairsList)) |
|
285 | pairsCrossCorr = range(len(pairsList)) | |
286 | pairsCrossCorr = numpy.delete(pairsCrossCorr,pairsAutoCorr) |
|
286 | pairsCrossCorr = numpy.delete(pairsCrossCorr,pairsAutoCorr) | |
287 |
|
287 | |||
288 | return pairsAutoCorr, pairsCrossCorr |
|
288 | return pairsAutoCorr, pairsCrossCorr | |
289 |
|
289 | |||
290 | def __calculateTaus(self, data, pairsCrossCorr, pairsAutoCorr, lagTRange): |
|
290 | def __calculateTaus(self, data, pairsCrossCorr, pairsAutoCorr, lagTRange): | |
291 |
|
291 | |||
292 | Pt0 = data.shape[1]/2 |
|
292 | Pt0 = data.shape[1]/2 | |
293 | #Funcion de Autocorrelacion |
|
293 | #Funcion de Autocorrelacion | |
294 | dataAutoCorr = stats.nanmean(data[pairsAutoCorr,:,:], axis = 0) |
|
294 | dataAutoCorr = stats.nanmean(data[pairsAutoCorr,:,:], axis = 0) | |
295 |
|
295 | |||
296 | #Obtencion Indice de TauCross |
|
296 | #Obtencion Indice de TauCross | |
297 | indCross = data[pairsCrossCorr,:,:].argmax(axis = 1) |
|
297 | indCross = data[pairsCrossCorr,:,:].argmax(axis = 1) | |
298 | #Obtencion Indice de TauAuto |
|
298 | #Obtencion Indice de TauAuto | |
299 | indAuto = numpy.zeros(indCross.shape,dtype = 'int') |
|
299 | indAuto = numpy.zeros(indCross.shape,dtype = 'int') | |
300 | CCValue = data[pairsCrossCorr,Pt0,:] |
|
300 | CCValue = data[pairsCrossCorr,Pt0,:] | |
301 | for i in range(pairsCrossCorr.size): |
|
301 | for i in range(pairsCrossCorr.size): | |
302 | indAuto[i,:] = numpy.abs(dataAutoCorr - CCValue[i,:]).argmin(axis = 0) |
|
302 | indAuto[i,:] = numpy.abs(dataAutoCorr - CCValue[i,:]).argmin(axis = 0) | |
303 |
|
303 | |||
304 | #Obtencion de TauCross y TauAuto |
|
304 | #Obtencion de TauCross y TauAuto | |
305 | tauCross = lagTRange[indCross] |
|
305 | tauCross = lagTRange[indCross] | |
306 | tauAuto = lagTRange[indAuto] |
|
306 | tauAuto = lagTRange[indAuto] | |
307 |
|
307 | |||
308 | Nan1, Nan2 = numpy.where(tauCross == lagTRange[0]) |
|
308 | Nan1, Nan2 = numpy.where(tauCross == lagTRange[0]) | |
309 |
|
309 | |||
310 | tauCross[Nan1,Nan2] = numpy.nan |
|
310 | tauCross[Nan1,Nan2] = numpy.nan | |
311 | tauAuto[Nan1,Nan2] = numpy.nan |
|
311 | tauAuto[Nan1,Nan2] = numpy.nan | |
312 | tau = numpy.vstack((tauCross,tauAuto)) |
|
312 | tau = numpy.vstack((tauCross,tauAuto)) | |
313 |
|
313 | |||
314 | return tau |
|
314 | return tau | |
315 |
|
315 | |||
316 | def __calculateLag1Phase(self, data, pairs, lagTRange): |
|
316 | def __calculateLag1Phase(self, data, pairs, lagTRange): | |
317 | data1 = stats.nanmean(data[pairs,:,:], axis = 0) |
|
317 | data1 = stats.nanmean(data[pairs,:,:], axis = 0) | |
318 | lag1 = numpy.where(lagTRange == 0)[0][0] + 1 |
|
318 | lag1 = numpy.where(lagTRange == 0)[0][0] + 1 | |
319 |
|
319 | |||
320 | phase = numpy.angle(data1[lag1,:]) |
|
320 | phase = numpy.angle(data1[lag1,:]) | |
321 |
|
321 | |||
322 | return phase |
|
322 | return phase | |
323 | #------------------- Detect Meteors ------------------------------ |
|
323 | #------------------- Detect Meteors ------------------------------ | |
324 |
|
324 | |||
325 | def DetectMeteors(self, hei_ref = None, tauindex = 0, |
|
325 | def DetectMeteors(self, hei_ref = None, tauindex = 0, | |
326 | predefinedPhaseShifts = None, centerReceiverIndex = 2, |
|
326 | predefinedPhaseShifts = None, centerReceiverIndex = 2, | |
327 | cohDetection = False, cohDet_timeStep = 1, cohDet_thresh = 25, |
|
327 | cohDetection = False, cohDet_timeStep = 1, cohDet_thresh = 25, | |
328 | noise_timeStep = 4, noise_multiple = 4, |
|
328 | noise_timeStep = 4, noise_multiple = 4, | |
329 | multDet_timeLimit = 1, multDet_rangeLimit = 3, |
|
329 | multDet_timeLimit = 1, multDet_rangeLimit = 3, | |
330 | phaseThresh = 20, SNRThresh = 8, |
|
330 | phaseThresh = 20, SNRThresh = 8, | |
331 | hmin = 70, hmax=110, azimuth = 0) : |
|
331 | hmin = 70, hmax=110, azimuth = 0) : | |
332 |
|
332 | |||
333 | ''' |
|
333 | ''' | |
334 | Function DetectMeteors() |
|
334 | Function DetectMeteors() | |
335 | Project developed with paper: |
|
335 | Project developed with paper: | |
336 | HOLDSWORTH ET AL. 2004 |
|
336 | HOLDSWORTH ET AL. 2004 | |
337 |
|
337 | |||
338 | Input: |
|
338 | Input: | |
339 | self.dataOut.data_pre |
|
339 | self.dataOut.data_pre | |
340 |
|
340 | |||
341 | centerReceiverIndex: From the channels, which is the center receiver |
|
341 | centerReceiverIndex: From the channels, which is the center receiver | |
342 |
|
342 | |||
343 | hei_ref: Height reference for the Beacon signal extraction |
|
343 | hei_ref: Height reference for the Beacon signal extraction | |
344 | tauindex: |
|
344 | tauindex: | |
345 | predefinedPhaseShifts: Predefined phase offset for the voltge signals |
|
345 | predefinedPhaseShifts: Predefined phase offset for the voltge signals | |
346 |
|
346 | |||
347 | cohDetection: Whether to user Coherent detection or not |
|
347 | cohDetection: Whether to user Coherent detection or not | |
348 | cohDet_timeStep: Coherent Detection calculation time step |
|
348 | cohDet_timeStep: Coherent Detection calculation time step | |
349 | cohDet_thresh: Coherent Detection phase threshold to correct phases |
|
349 | cohDet_thresh: Coherent Detection phase threshold to correct phases | |
350 |
|
350 | |||
351 | noise_timeStep: Noise calculation time step |
|
351 | noise_timeStep: Noise calculation time step | |
352 | noise_multiple: Noise multiple to define signal threshold |
|
352 | noise_multiple: Noise multiple to define signal threshold | |
353 |
|
353 | |||
354 | multDet_timeLimit: Multiple Detection Removal time limit in seconds |
|
354 | multDet_timeLimit: Multiple Detection Removal time limit in seconds | |
355 | multDet_rangeLimit: Multiple Detection Removal range limit in km |
|
355 | multDet_rangeLimit: Multiple Detection Removal range limit in km | |
356 |
|
356 | |||
357 | phaseThresh: Maximum phase difference between receiver to be consider a meteor |
|
357 | phaseThresh: Maximum phase difference between receiver to be consider a meteor | |
358 | SNRThresh: Minimum SNR threshold of the meteor signal to be consider a meteor |
|
358 | SNRThresh: Minimum SNR threshold of the meteor signal to be consider a meteor | |
359 |
|
359 | |||
360 | hmin: Minimum Height of the meteor to use it in the further wind estimations |
|
360 | hmin: Minimum Height of the meteor to use it in the further wind estimations | |
361 | hmax: Maximum Height of the meteor to use it in the further wind estimations |
|
361 | hmax: Maximum Height of the meteor to use it in the further wind estimations | |
362 | azimuth: Azimuth angle correction |
|
362 | azimuth: Azimuth angle correction | |
363 |
|
363 | |||
364 | Affected: |
|
364 | Affected: | |
365 | self.dataOut.data_param |
|
365 | self.dataOut.data_param | |
366 |
|
366 | |||
367 | Rejection Criteria (Errors): |
|
367 | Rejection Criteria (Errors): | |
368 | 0: No error; analysis OK |
|
368 | 0: No error; analysis OK | |
369 | 1: SNR < SNR threshold |
|
369 | 1: SNR < SNR threshold | |
370 | 2: angle of arrival (AOA) ambiguously determined |
|
370 | 2: angle of arrival (AOA) ambiguously determined | |
371 | 3: AOA estimate not feasible |
|
371 | 3: AOA estimate not feasible | |
372 | 4: Large difference in AOAs obtained from different antenna baselines |
|
372 | 4: Large difference in AOAs obtained from different antenna baselines | |
373 | 5: echo at start or end of time series |
|
373 | 5: echo at start or end of time series | |
374 | 6: echo less than 5 examples long; too short for analysis |
|
374 | 6: echo less than 5 examples long; too short for analysis | |
375 | 7: echo rise exceeds 0.3s |
|
375 | 7: echo rise exceeds 0.3s | |
376 | 8: echo decay time less than twice rise time |
|
376 | 8: echo decay time less than twice rise time | |
377 | 9: large power level before echo |
|
377 | 9: large power level before echo | |
378 | 10: large power level after echo |
|
378 | 10: large power level after echo | |
379 | 11: poor fit to amplitude for estimation of decay time |
|
379 | 11: poor fit to amplitude for estimation of decay time | |
380 | 12: poor fit to CCF phase variation for estimation of radial drift velocity |
|
380 | 12: poor fit to CCF phase variation for estimation of radial drift velocity | |
381 | 13: height unresolvable echo: not valid height within 70 to 110 km |
|
381 | 13: height unresolvable echo: not valid height within 70 to 110 km | |
382 | 14: height ambiguous echo: more then one possible height within 70 to 110 km |
|
382 | 14: height ambiguous echo: more then one possible height within 70 to 110 km | |
383 | 15: radial drift velocity or projected horizontal velocity exceeds 200 m/s |
|
383 | 15: radial drift velocity or projected horizontal velocity exceeds 200 m/s | |
384 | 16: oscilatory echo, indicating event most likely not an underdense echo |
|
384 | 16: oscilatory echo, indicating event most likely not an underdense echo | |
385 |
|
385 | |||
386 | 17: phase difference in meteor Reestimation |
|
386 | 17: phase difference in meteor Reestimation | |
387 |
|
387 | |||
388 | Data Storage: |
|
388 | Data Storage: | |
389 | Meteors for Wind Estimation (8): |
|
389 | Meteors for Wind Estimation (8): | |
390 | Day Hour | Range Height |
|
390 | Day Hour | Range Height | |
391 | Azimuth Zenith errorCosDir |
|
391 | Azimuth Zenith errorCosDir | |
392 | VelRad errorVelRad |
|
392 | VelRad errorVelRad | |
393 | TypeError |
|
393 | TypeError | |
394 |
|
394 | |||
395 | ''' |
|
395 | ''' | |
396 | #Get Beacon signal |
|
396 | #Get Beacon signal | |
397 | newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex]) |
|
397 | newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex]) | |
398 |
|
398 | |||
399 | if hei_ref != None: |
|
399 | if hei_ref != None: | |
400 | newheis = numpy.where(self.dataOut.heightList>hei_ref) |
|
400 | newheis = numpy.where(self.dataOut.heightList>hei_ref) | |
401 |
|
401 | |||
402 | heiRang = self.dataOut.getHeiRange() |
|
402 | heiRang = self.dataOut.getHeiRange() | |
403 | #Pairs List |
|
403 | #Pairs List | |
404 | pairslist = [] |
|
404 | pairslist = [] | |
405 | nChannel = self.dataOut.nChannels |
|
405 | nChannel = self.dataOut.nChannels | |
406 | for i in range(nChannel): |
|
406 | for i in range(nChannel): | |
407 | if i != centerReceiverIndex: |
|
407 | if i != centerReceiverIndex: | |
408 | pairslist.append((centerReceiverIndex,i)) |
|
408 | pairslist.append((centerReceiverIndex,i)) | |
409 |
|
409 | |||
410 | #****************REMOVING HARDWARE PHASE DIFFERENCES*************** |
|
410 | #****************REMOVING HARDWARE PHASE DIFFERENCES*************** | |
411 | # see if the user put in pre defined phase shifts |
|
411 | # see if the user put in pre defined phase shifts | |
412 | voltsPShift = self.dataOut.data_pre.copy() |
|
412 | voltsPShift = self.dataOut.data_pre.copy() | |
413 |
|
413 | |||
414 | if predefinedPhaseShifts != None: |
|
414 | if predefinedPhaseShifts != None: | |
415 | hardwarePhaseShifts = numpy.array(predefinedPhaseShifts)*numpy.pi/180 |
|
415 | hardwarePhaseShifts = numpy.array(predefinedPhaseShifts)*numpy.pi/180 | |
416 | else: |
|
416 | else: | |
417 | #get hardware phase shifts using beacon signal |
|
417 | #get hardware phase shifts using beacon signal | |
418 | hardwarePhaseShifts = self.__getHardwarePhaseDiff(self.dataOut.data_pre, pairslist, newheis, 10) |
|
418 | hardwarePhaseShifts = self.__getHardwarePhaseDiff(self.dataOut.data_pre, pairslist, newheis, 10) | |
419 | hardwarePhaseShifts = numpy.insert(hardwarePhaseShifts,centerReceiverIndex,0) |
|
419 | hardwarePhaseShifts = numpy.insert(hardwarePhaseShifts,centerReceiverIndex,0) | |
420 |
|
420 | |||
421 | voltsPShift = numpy.zeros((self.dataOut.data_pre.shape[0],self.dataOut.data_pre.shape[1],self.dataOut.data_pre.shape[2]), dtype = 'complex') |
|
421 | voltsPShift = numpy.zeros((self.dataOut.data_pre.shape[0],self.dataOut.data_pre.shape[1],self.dataOut.data_pre.shape[2]), dtype = 'complex') | |
422 | for i in range(self.dataOut.data_pre.shape[0]): |
|
422 | for i in range(self.dataOut.data_pre.shape[0]): | |
423 | voltsPShift[i,:,:] = self.__shiftPhase(self.dataOut.data_pre[i,:,:], hardwarePhaseShifts[i]) |
|
423 | voltsPShift[i,:,:] = self.__shiftPhase(self.dataOut.data_pre[i,:,:], hardwarePhaseShifts[i]) | |
424 | #******************END OF REMOVING HARDWARE PHASE DIFFERENCES********* |
|
424 | #******************END OF REMOVING HARDWARE PHASE DIFFERENCES********* | |
425 |
|
425 | |||
426 | #Remove DC |
|
426 | #Remove DC | |
427 | voltsDC = numpy.mean(voltsPShift,1) |
|
427 | voltsDC = numpy.mean(voltsPShift,1) | |
428 | voltsDC = numpy.mean(voltsDC,1) |
|
428 | voltsDC = numpy.mean(voltsDC,1) | |
429 | for i in range(voltsDC.shape[0]): |
|
429 | for i in range(voltsDC.shape[0]): | |
430 | voltsPShift[i] = voltsPShift[i] - voltsDC[i] |
|
430 | voltsPShift[i] = voltsPShift[i] - voltsDC[i] | |
431 |
|
431 | |||
432 | #Don't considerate last heights, theyre used to calculate Hardware Phase Shift |
|
432 | #Don't considerate last heights, theyre used to calculate Hardware Phase Shift | |
433 | voltsPShift = voltsPShift[:,:,:newheis[0][0]] |
|
433 | voltsPShift = voltsPShift[:,:,:newheis[0][0]] | |
434 |
|
434 | |||
435 | #************ FIND POWER OF DATA W/COH OR NON COH DETECTION (3.4) ********** |
|
435 | #************ FIND POWER OF DATA W/COH OR NON COH DETECTION (3.4) ********** | |
436 | #Coherent Detection |
|
436 | #Coherent Detection | |
437 | if cohDetection: |
|
437 | if cohDetection: | |
438 | #use coherent detection to get the net power |
|
438 | #use coherent detection to get the net power | |
439 | cohDet_thresh = cohDet_thresh*numpy.pi/180 |
|
439 | cohDet_thresh = cohDet_thresh*numpy.pi/180 | |
440 | voltsPShift = self.__coherentDetection(voltsPShift, cohDet_timeStep, self.dataOut.timeInterval, pairslist, cohDet_thresh) |
|
440 | voltsPShift = self.__coherentDetection(voltsPShift, cohDet_timeStep, self.dataOut.timeInterval, pairslist, cohDet_thresh) | |
441 |
|
441 | |||
442 | #Non-coherent detection! |
|
442 | #Non-coherent detection! | |
443 | powerNet = numpy.nansum(numpy.abs(voltsPShift[:,:,:])**2,0) |
|
443 | powerNet = numpy.nansum(numpy.abs(voltsPShift[:,:,:])**2,0) | |
444 | #********** END OF COH/NON-COH POWER CALCULATION********************** |
|
444 | #********** END OF COH/NON-COH POWER CALCULATION********************** | |
445 |
|
445 | |||
446 | #********** FIND THE NOISE LEVEL AND POSSIBLE METEORS **************** |
|
446 | #********** FIND THE NOISE LEVEL AND POSSIBLE METEORS **************** | |
447 | #Get noise |
|
447 | #Get noise | |
448 | noise, noise1 = self.__getNoise(powerNet, noise_timeStep, self.dataOut.timeInterval) |
|
448 | noise, noise1 = self.__getNoise(powerNet, noise_timeStep, self.dataOut.timeInterval) | |
449 | # noise = self.getNoise1(powerNet, noise_timeStep, self.dataOut.timeInterval) |
|
449 | # noise = self.getNoise1(powerNet, noise_timeStep, self.dataOut.timeInterval) | |
450 | #Get signal threshold |
|
450 | #Get signal threshold | |
451 | signalThresh = noise_multiple*noise |
|
451 | signalThresh = noise_multiple*noise | |
452 | #Meteor echoes detection |
|
452 | #Meteor echoes detection | |
453 | listMeteors = self.__findMeteors(powerNet, signalThresh) |
|
453 | listMeteors = self.__findMeteors(powerNet, signalThresh) | |
454 | #******* END OF NOISE LEVEL AND POSSIBLE METEORS CACULATION ********** |
|
454 | #******* END OF NOISE LEVEL AND POSSIBLE METEORS CACULATION ********** | |
455 |
|
455 | |||
456 | #************** REMOVE MULTIPLE DETECTIONS (3.5) *************************** |
|
456 | #************** REMOVE MULTIPLE DETECTIONS (3.5) *************************** | |
457 | #Parameters |
|
457 | #Parameters | |
458 | heiRange = self.dataOut.getHeiRange() |
|
458 | heiRange = self.dataOut.getHeiRange() | |
459 | rangeInterval = heiRange[1] - heiRange[0] |
|
459 | rangeInterval = heiRange[1] - heiRange[0] | |
460 | rangeLimit = multDet_rangeLimit/rangeInterval |
|
460 | rangeLimit = multDet_rangeLimit/rangeInterval | |
461 | timeLimit = multDet_timeLimit/self.dataOut.timeInterval |
|
461 | timeLimit = multDet_timeLimit/self.dataOut.timeInterval | |
462 | #Multiple detection removals |
|
462 | #Multiple detection removals | |
463 | listMeteors1 = self.__removeMultipleDetections(listMeteors, rangeLimit, timeLimit) |
|
463 | listMeteors1 = self.__removeMultipleDetections(listMeteors, rangeLimit, timeLimit) | |
464 | #************ END OF REMOVE MULTIPLE DETECTIONS ********************** |
|
464 | #************ END OF REMOVE MULTIPLE DETECTIONS ********************** | |
465 |
|
465 | |||
466 | #********************* METEOR REESTIMATION (3.7, 3.8, 3.9, 3.10) ******************** |
|
466 | #********************* METEOR REESTIMATION (3.7, 3.8, 3.9, 3.10) ******************** | |
467 | #Parameters |
|
467 | #Parameters | |
468 | phaseThresh = phaseThresh*numpy.pi/180 |
|
468 | phaseThresh = phaseThresh*numpy.pi/180 | |
469 | thresh = [phaseThresh, noise_multiple, SNRThresh] |
|
469 | thresh = [phaseThresh, noise_multiple, SNRThresh] | |
470 | #Meteor reestimation (Errors N 1, 6, 12, 17) |
|
470 | #Meteor reestimation (Errors N 1, 6, 12, 17) | |
471 | listMeteors2, listMeteorsPower, listMeteorsVolts = self.__meteorReestimation(listMeteors1, voltsPShift, pairslist, thresh, noise, self.dataOut.timeInterval, self.dataOut.frequency) |
|
471 | listMeteors2, listMeteorsPower, listMeteorsVolts = self.__meteorReestimation(listMeteors1, voltsPShift, pairslist, thresh, noise, self.dataOut.timeInterval, self.dataOut.frequency) | |
472 | # listMeteors2, listMeteorsPower, listMeteorsVolts = self.meteorReestimation3(listMeteors2, listMeteorsPower, listMeteorsVolts, voltsPShift, pairslist, thresh, noise) |
|
472 | # listMeteors2, listMeteorsPower, listMeteorsVolts = self.meteorReestimation3(listMeteors2, listMeteorsPower, listMeteorsVolts, voltsPShift, pairslist, thresh, noise) | |
473 | #Estimation of decay times (Errors N 7, 8, 11) |
|
473 | #Estimation of decay times (Errors N 7, 8, 11) | |
474 | listMeteors3 = self.__estimateDecayTime(listMeteors2, listMeteorsPower, self.dataOut.timeInterval, self.dataOut.frequency) |
|
474 | listMeteors3 = self.__estimateDecayTime(listMeteors2, listMeteorsPower, self.dataOut.timeInterval, self.dataOut.frequency) | |
475 | #******************* END OF METEOR REESTIMATION ******************* |
|
475 | #******************* END OF METEOR REESTIMATION ******************* | |
476 |
|
476 | |||
477 | #********************* METEOR PARAMETERS CALCULATION (3.11, 3.12, 3.13) ************************** |
|
477 | #********************* METEOR PARAMETERS CALCULATION (3.11, 3.12, 3.13) ************************** | |
478 | #Calculating Radial Velocity (Error N 15) |
|
478 | #Calculating Radial Velocity (Error N 15) | |
479 | radialStdThresh = 10 |
|
479 | radialStdThresh = 10 | |
480 | listMeteors4 = self.__getRadialVelocity(listMeteors3, listMeteorsVolts, radialStdThresh, pairslist, self.dataOut.timeInterval) |
|
480 | listMeteors4 = self.__getRadialVelocity(listMeteors3, listMeteorsVolts, radialStdThresh, pairslist, self.dataOut.timeInterval) | |
481 |
|
481 | |||
482 | if len(listMeteors4) > 0: |
|
482 | if len(listMeteors4) > 0: | |
483 | #Setting New Array |
|
483 | #Setting New Array | |
484 | date = repr(self.dataOut.datatime) |
|
484 | date = repr(self.dataOut.datatime) | |
485 | arrayMeteors4, arrayParameters = self.__setNewArrays(listMeteors4, date, heiRang) |
|
485 | arrayMeteors4, arrayParameters = self.__setNewArrays(listMeteors4, date, heiRang) | |
486 |
|
486 | |||
487 | #Calculate AOA (Error N 3, 4) |
|
487 | #Calculate AOA (Error N 3, 4) | |
488 | #JONES ET AL. 1998 |
|
488 | #JONES ET AL. 1998 | |
489 | AOAthresh = numpy.pi/8 |
|
489 | AOAthresh = numpy.pi/8 | |
490 | error = arrayParameters[:,-1] |
|
490 | error = arrayParameters[:,-1] | |
491 | phases = -arrayMeteors4[:,9:13] |
|
491 | phases = -arrayMeteors4[:,9:13] | |
492 | pairsList = [] |
|
492 | pairsList = [] | |
493 | pairsList.append((0,3)) |
|
493 | pairsList.append((0,3)) | |
494 | pairsList.append((1,2)) |
|
494 | pairsList.append((1,2)) | |
495 | arrayParameters[:,4:7], arrayParameters[:,-1] = self.__getAOA(phases, pairsList, error, AOAthresh, azimuth) |
|
495 | arrayParameters[:,4:7], arrayParameters[:,-1] = self.__getAOA(phases, pairsList, error, AOAthresh, azimuth) | |
496 |
|
496 | |||
497 | #Calculate Heights (Error N 13 and 14) |
|
497 | #Calculate Heights (Error N 13 and 14) | |
498 | error = arrayParameters[:,-1] |
|
498 | error = arrayParameters[:,-1] | |
499 | Ranges = arrayParameters[:,2] |
|
499 | Ranges = arrayParameters[:,2] | |
500 | zenith = arrayParameters[:,5] |
|
500 | zenith = arrayParameters[:,5] | |
501 | arrayParameters[:,3], arrayParameters[:,-1] = self.__getHeights(Ranges, zenith, error, hmin, hmax) |
|
501 | arrayParameters[:,3], arrayParameters[:,-1] = self.__getHeights(Ranges, zenith, error, hmin, hmax) | |
502 | #********************* END OF PARAMETERS CALCULATION ************************** |
|
502 | #********************* END OF PARAMETERS CALCULATION ************************** | |
503 |
|
503 | |||
504 | #***************************+ SAVE DATA IN HDF5 FORMAT ********************** |
|
504 | #***************************+ SAVE DATA IN HDF5 FORMAT ********************** | |
505 | self.dataOut.data_param = arrayParameters |
|
505 | self.dataOut.data_param = arrayParameters | |
506 |
|
506 | |||
507 | return |
|
507 | return | |
508 |
|
508 | |||
509 | def __getHardwarePhaseDiff(self, voltage0, pairslist, newheis, n): |
|
509 | def __getHardwarePhaseDiff(self, voltage0, pairslist, newheis, n): | |
510 |
|
510 | |||
511 | minIndex = min(newheis[0]) |
|
511 | minIndex = min(newheis[0]) | |
512 | maxIndex = max(newheis[0]) |
|
512 | maxIndex = max(newheis[0]) | |
513 |
|
513 | |||
514 | voltage = voltage0[:,:,minIndex:maxIndex+1] |
|
514 | voltage = voltage0[:,:,minIndex:maxIndex+1] | |
515 | nLength = voltage.shape[1]/n |
|
515 | nLength = voltage.shape[1]/n | |
516 | nMin = 0 |
|
516 | nMin = 0 | |
517 | nMax = 0 |
|
517 | nMax = 0 | |
518 | phaseOffset = numpy.zeros((len(pairslist),n)) |
|
518 | phaseOffset = numpy.zeros((len(pairslist),n)) | |
519 |
|
519 | |||
520 | for i in range(n): |
|
520 | for i in range(n): | |
521 | nMax += nLength |
|
521 | nMax += nLength | |
522 | phaseCCF = -numpy.angle(self.__calculateCCF(voltage[:,nMin:nMax,:], pairslist, [0])) |
|
522 | phaseCCF = -numpy.angle(self.__calculateCCF(voltage[:,nMin:nMax,:], pairslist, [0])) | |
523 | phaseCCF = numpy.mean(phaseCCF, axis = 2) |
|
523 | phaseCCF = numpy.mean(phaseCCF, axis = 2) | |
524 | phaseOffset[:,i] = phaseCCF.transpose() |
|
524 | phaseOffset[:,i] = phaseCCF.transpose() | |
525 | nMin = nMax |
|
525 | nMin = nMax | |
526 | # phaseDiff, phaseArrival = self.estimatePhaseDifference(voltage, pairslist) |
|
526 | # phaseDiff, phaseArrival = self.estimatePhaseDifference(voltage, pairslist) | |
527 |
|
527 | |||
528 | #Remove Outliers |
|
528 | #Remove Outliers | |
529 | factor = 2 |
|
529 | factor = 2 | |
530 | wt = phaseOffset - signal.medfilt(phaseOffset,(1,5)) |
|
530 | wt = phaseOffset - signal.medfilt(phaseOffset,(1,5)) | |
531 | dw = numpy.std(wt,axis = 1) |
|
531 | dw = numpy.std(wt,axis = 1) | |
532 | dw = dw.reshape((dw.size,1)) |
|
532 | dw = dw.reshape((dw.size,1)) | |
533 | ind = numpy.where(numpy.logical_or(wt>dw*factor,wt<-dw*factor)) |
|
533 | ind = numpy.where(numpy.logical_or(wt>dw*factor,wt<-dw*factor)) | |
534 | phaseOffset[ind] = numpy.nan |
|
534 | phaseOffset[ind] = numpy.nan | |
535 | phaseOffset = stats.nanmean(phaseOffset, axis=1) |
|
535 | phaseOffset = stats.nanmean(phaseOffset, axis=1) | |
536 |
|
536 | |||
537 | return phaseOffset |
|
537 | return phaseOffset | |
538 |
|
538 | |||
539 | def __shiftPhase(self, data, phaseShift): |
|
539 | def __shiftPhase(self, data, phaseShift): | |
540 | #this will shift the phase of a complex number |
|
540 | #this will shift the phase of a complex number | |
541 | dataShifted = numpy.abs(data) * numpy.exp((numpy.angle(data)+phaseShift)*1j) |
|
541 | dataShifted = numpy.abs(data) * numpy.exp((numpy.angle(data)+phaseShift)*1j) | |
542 | return dataShifted |
|
542 | return dataShifted | |
543 |
|
543 | |||
544 | def __estimatePhaseDifference(self, array, pairslist): |
|
544 | def __estimatePhaseDifference(self, array, pairslist): | |
545 | nChannel = array.shape[0] |
|
545 | nChannel = array.shape[0] | |
546 | nHeights = array.shape[2] |
|
546 | nHeights = array.shape[2] | |
547 | numPairs = len(pairslist) |
|
547 | numPairs = len(pairslist) | |
548 | # phaseCCF = numpy.zeros((nChannel, 5, nHeights)) |
|
548 | # phaseCCF = numpy.zeros((nChannel, 5, nHeights)) | |
549 | phaseCCF = numpy.angle(self.__calculateCCF(array, pairslist, [-2,-1,0,1,2])) |
|
549 | phaseCCF = numpy.angle(self.__calculateCCF(array, pairslist, [-2,-1,0,1,2])) | |
550 |
|
550 | |||
551 | #Correct phases |
|
551 | #Correct phases | |
552 | derPhaseCCF = phaseCCF[:,1:,:] - phaseCCF[:,0:-1,:] |
|
552 | derPhaseCCF = phaseCCF[:,1:,:] - phaseCCF[:,0:-1,:] | |
553 | indDer = numpy.where(numpy.abs(derPhaseCCF) > numpy.pi) |
|
553 | indDer = numpy.where(numpy.abs(derPhaseCCF) > numpy.pi) | |
554 |
|
554 | |||
555 | if indDer[0].shape[0] > 0: |
|
555 | if indDer[0].shape[0] > 0: | |
556 | for i in range(indDer[0].shape[0]): |
|
556 | for i in range(indDer[0].shape[0]): | |
557 | signo = -numpy.sign(derPhaseCCF[indDer[0][i],indDer[1][i],indDer[2][i]]) |
|
557 | signo = -numpy.sign(derPhaseCCF[indDer[0][i],indDer[1][i],indDer[2][i]]) | |
558 | phaseCCF[indDer[0][i],indDer[1][i]+1:,:] += signo*2*numpy.pi |
|
558 | phaseCCF[indDer[0][i],indDer[1][i]+1:,:] += signo*2*numpy.pi | |
559 |
|
559 | |||
560 | # for j in range(numSides): |
|
560 | # for j in range(numSides): | |
561 | # phaseCCFAux = self.calculateCCF(arrayCenter, arraySides[j,:,:], [-2,1,0,1,2]) |
|
561 | # phaseCCFAux = self.calculateCCF(arrayCenter, arraySides[j,:,:], [-2,1,0,1,2]) | |
562 | # phaseCCF[j,:,:] = numpy.angle(phaseCCFAux) |
|
562 | # phaseCCF[j,:,:] = numpy.angle(phaseCCFAux) | |
563 | # |
|
563 | # | |
564 | #Linear |
|
564 | #Linear | |
565 | phaseInt = numpy.zeros((numPairs,1)) |
|
565 | phaseInt = numpy.zeros((numPairs,1)) | |
566 | angAllCCF = phaseCCF[:,[0,1,3,4],0] |
|
566 | angAllCCF = phaseCCF[:,[0,1,3,4],0] | |
567 | for j in range(numPairs): |
|
567 | for j in range(numPairs): | |
568 | fit = stats.linregress([-2,-1,1,2],angAllCCF[j,:]) |
|
568 | fit = stats.linregress([-2,-1,1,2],angAllCCF[j,:]) | |
569 | phaseInt[j] = fit[1] |
|
569 | phaseInt[j] = fit[1] | |
570 | #Phase Differences |
|
570 | #Phase Differences | |
571 | phaseDiff = phaseInt - phaseCCF[:,2,:] |
|
571 | phaseDiff = phaseInt - phaseCCF[:,2,:] | |
572 | phaseArrival = phaseInt.reshape(phaseInt.size) |
|
572 | phaseArrival = phaseInt.reshape(phaseInt.size) | |
573 |
|
573 | |||
574 | #Dealias |
|
574 | #Dealias | |
575 | indAlias = numpy.where(phaseArrival > numpy.pi) |
|
575 | indAlias = numpy.where(phaseArrival > numpy.pi) | |
576 | phaseArrival[indAlias] -= 2*numpy.pi |
|
576 | phaseArrival[indAlias] -= 2*numpy.pi | |
577 | indAlias = numpy.where(phaseArrival < -numpy.pi) |
|
577 | indAlias = numpy.where(phaseArrival < -numpy.pi) | |
578 | phaseArrival[indAlias] += 2*numpy.pi |
|
578 | phaseArrival[indAlias] += 2*numpy.pi | |
579 |
|
579 | |||
580 | return phaseDiff, phaseArrival |
|
580 | return phaseDiff, phaseArrival | |
581 |
|
581 | |||
582 | def __coherentDetection(self, volts, timeSegment, timeInterval, pairslist, thresh): |
|
582 | def __coherentDetection(self, volts, timeSegment, timeInterval, pairslist, thresh): | |
583 | #this function will run the coherent detection used in Holdworth et al. 2004 and return the net power |
|
583 | #this function will run the coherent detection used in Holdworth et al. 2004 and return the net power | |
584 | #find the phase shifts of each channel over 1 second intervals |
|
584 | #find the phase shifts of each channel over 1 second intervals | |
585 | #only look at ranges below the beacon signal |
|
585 | #only look at ranges below the beacon signal | |
586 | numProfPerBlock = numpy.ceil(timeSegment/timeInterval) |
|
586 | numProfPerBlock = numpy.ceil(timeSegment/timeInterval) | |
587 | numBlocks = int(volts.shape[1]/numProfPerBlock) |
|
587 | numBlocks = int(volts.shape[1]/numProfPerBlock) | |
588 | numHeights = volts.shape[2] |
|
588 | numHeights = volts.shape[2] | |
589 | nChannel = volts.shape[0] |
|
589 | nChannel = volts.shape[0] | |
590 | voltsCohDet = volts.copy() |
|
590 | voltsCohDet = volts.copy() | |
591 |
|
591 | |||
592 | pairsarray = numpy.array(pairslist) |
|
592 | pairsarray = numpy.array(pairslist) | |
593 | indSides = pairsarray[:,1] |
|
593 | indSides = pairsarray[:,1] | |
594 | # indSides = numpy.array(range(nChannel)) |
|
594 | # indSides = numpy.array(range(nChannel)) | |
595 | # indSides = numpy.delete(indSides, indCenter) |
|
595 | # indSides = numpy.delete(indSides, indCenter) | |
596 | # |
|
596 | # | |
597 | # listCenter = numpy.array_split(volts[indCenter,:,:], numBlocks, 0) |
|
597 | # listCenter = numpy.array_split(volts[indCenter,:,:], numBlocks, 0) | |
598 | listBlocks = numpy.array_split(volts, numBlocks, 1) |
|
598 | listBlocks = numpy.array_split(volts, numBlocks, 1) | |
599 |
|
599 | |||
600 | startInd = 0 |
|
600 | startInd = 0 | |
601 | endInd = 0 |
|
601 | endInd = 0 | |
602 |
|
602 | |||
603 | for i in range(numBlocks): |
|
603 | for i in range(numBlocks): | |
604 | startInd = endInd |
|
604 | startInd = endInd | |
605 | endInd = endInd + listBlocks[i].shape[1] |
|
605 | endInd = endInd + listBlocks[i].shape[1] | |
606 |
|
606 | |||
607 | arrayBlock = listBlocks[i] |
|
607 | arrayBlock = listBlocks[i] | |
608 | # arrayBlockCenter = listCenter[i] |
|
608 | # arrayBlockCenter = listCenter[i] | |
609 |
|
609 | |||
610 | #Estimate the Phase Difference |
|
610 | #Estimate the Phase Difference | |
611 | phaseDiff, aux = self.__estimatePhaseDifference(arrayBlock, pairslist) |
|
611 | phaseDiff, aux = self.__estimatePhaseDifference(arrayBlock, pairslist) | |
612 | #Phase Difference RMS |
|
612 | #Phase Difference RMS | |
613 | arrayPhaseRMS = numpy.abs(phaseDiff) |
|
613 | arrayPhaseRMS = numpy.abs(phaseDiff) | |
614 | phaseRMSaux = numpy.sum(arrayPhaseRMS < thresh,0) |
|
614 | phaseRMSaux = numpy.sum(arrayPhaseRMS < thresh,0) | |
615 | indPhase = numpy.where(phaseRMSaux==4) |
|
615 | indPhase = numpy.where(phaseRMSaux==4) | |
616 | #Shifting |
|
616 | #Shifting | |
617 | if indPhase[0].shape[0] > 0: |
|
617 | if indPhase[0].shape[0] > 0: | |
618 | for j in range(indSides.size): |
|
618 | for j in range(indSides.size): | |
619 | arrayBlock[indSides[j],:,indPhase] = self.__shiftPhase(arrayBlock[indSides[j],:,indPhase], phaseDiff[j,indPhase].transpose()) |
|
619 | arrayBlock[indSides[j],:,indPhase] = self.__shiftPhase(arrayBlock[indSides[j],:,indPhase], phaseDiff[j,indPhase].transpose()) | |
620 | voltsCohDet[:,startInd:endInd,:] = arrayBlock |
|
620 | voltsCohDet[:,startInd:endInd,:] = arrayBlock | |
621 |
|
621 | |||
622 | return voltsCohDet |
|
622 | return voltsCohDet | |
623 |
|
623 | |||
624 | def __calculateCCF(self, volts, pairslist ,laglist): |
|
624 | def __calculateCCF(self, volts, pairslist ,laglist): | |
625 |
|
625 | |||
626 | nHeights = volts.shape[2] |
|
626 | nHeights = volts.shape[2] | |
627 | nPoints = volts.shape[1] |
|
627 | nPoints = volts.shape[1] | |
628 | voltsCCF = numpy.zeros((len(pairslist), len(laglist), nHeights),dtype = 'complex') |
|
628 | voltsCCF = numpy.zeros((len(pairslist), len(laglist), nHeights),dtype = 'complex') | |
629 |
|
629 | |||
630 | for i in range(len(pairslist)): |
|
630 | for i in range(len(pairslist)): | |
631 | volts1 = volts[pairslist[i][0]] |
|
631 | volts1 = volts[pairslist[i][0]] | |
632 | volts2 = volts[pairslist[i][1]] |
|
632 | volts2 = volts[pairslist[i][1]] | |
633 |
|
633 | |||
634 | for t in range(len(laglist)): |
|
634 | for t in range(len(laglist)): | |
635 | idxT = laglist[t] |
|
635 | idxT = laglist[t] | |
636 | if idxT >= 0: |
|
636 | if idxT >= 0: | |
637 | vStacked = numpy.vstack((volts2[idxT:,:], |
|
637 | vStacked = numpy.vstack((volts2[idxT:,:], | |
638 | numpy.zeros((idxT, nHeights),dtype='complex'))) |
|
638 | numpy.zeros((idxT, nHeights),dtype='complex'))) | |
639 | else: |
|
639 | else: | |
640 | vStacked = numpy.vstack((numpy.zeros((-idxT, nHeights),dtype='complex'), |
|
640 | vStacked = numpy.vstack((numpy.zeros((-idxT, nHeights),dtype='complex'), | |
641 | volts2[:(nPoints + idxT),:])) |
|
641 | volts2[:(nPoints + idxT),:])) | |
642 | voltsCCF[i,t,:] = numpy.sum((numpy.conjugate(volts1)*vStacked),axis=0) |
|
642 | voltsCCF[i,t,:] = numpy.sum((numpy.conjugate(volts1)*vStacked),axis=0) | |
643 |
|
643 | |||
644 | vStacked = None |
|
644 | vStacked = None | |
645 | return voltsCCF |
|
645 | return voltsCCF | |
646 |
|
646 | |||
647 | def __getNoise(self, power, timeSegment, timeInterval): |
|
647 | def __getNoise(self, power, timeSegment, timeInterval): | |
648 | numProfPerBlock = numpy.ceil(timeSegment/timeInterval) |
|
648 | numProfPerBlock = numpy.ceil(timeSegment/timeInterval) | |
649 | numBlocks = int(power.shape[0]/numProfPerBlock) |
|
649 | numBlocks = int(power.shape[0]/numProfPerBlock) | |
650 | numHeights = power.shape[1] |
|
650 | numHeights = power.shape[1] | |
651 |
|
651 | |||
652 | listPower = numpy.array_split(power, numBlocks, 0) |
|
652 | listPower = numpy.array_split(power, numBlocks, 0) | |
653 | noise = numpy.zeros((power.shape[0], power.shape[1])) |
|
653 | noise = numpy.zeros((power.shape[0], power.shape[1])) | |
654 | noise1 = numpy.zeros((power.shape[0], power.shape[1])) |
|
654 | noise1 = numpy.zeros((power.shape[0], power.shape[1])) | |
655 |
|
655 | |||
656 | startInd = 0 |
|
656 | startInd = 0 | |
657 | endInd = 0 |
|
657 | endInd = 0 | |
658 |
|
658 | |||
659 | for i in range(numBlocks): #split por canal |
|
659 | for i in range(numBlocks): #split por canal | |
660 | startInd = endInd |
|
660 | startInd = endInd | |
661 | endInd = endInd + listPower[i].shape[0] |
|
661 | endInd = endInd + listPower[i].shape[0] | |
662 |
|
662 | |||
663 | arrayBlock = listPower[i] |
|
663 | arrayBlock = listPower[i] | |
664 | noiseAux = numpy.mean(arrayBlock, 0) |
|
664 | noiseAux = numpy.mean(arrayBlock, 0) | |
665 | # noiseAux = numpy.median(noiseAux) |
|
665 | # noiseAux = numpy.median(noiseAux) | |
666 | # noiseAux = numpy.mean(arrayBlock) |
|
666 | # noiseAux = numpy.mean(arrayBlock) | |
667 | noise[startInd:endInd,:] = noise[startInd:endInd,:] + noiseAux |
|
667 | noise[startInd:endInd,:] = noise[startInd:endInd,:] + noiseAux | |
668 |
|
668 | |||
669 | noiseAux1 = numpy.mean(arrayBlock) |
|
669 | noiseAux1 = numpy.mean(arrayBlock) | |
670 | noise1[startInd:endInd,:] = noise1[startInd:endInd,:] + noiseAux1 |
|
670 | noise1[startInd:endInd,:] = noise1[startInd:endInd,:] + noiseAux1 | |
671 |
|
671 | |||
672 | return noise, noise1 |
|
672 | return noise, noise1 | |
673 |
|
673 | |||
674 | def __findMeteors(self, power, thresh): |
|
674 | def __findMeteors(self, power, thresh): | |
675 | nProf = power.shape[0] |
|
675 | nProf = power.shape[0] | |
676 | nHeights = power.shape[1] |
|
676 | nHeights = power.shape[1] | |
677 | listMeteors = [] |
|
677 | listMeteors = [] | |
678 |
|
678 | |||
679 | for i in range(nHeights): |
|
679 | for i in range(nHeights): | |
680 | powerAux = power[:,i] |
|
680 | powerAux = power[:,i] | |
681 | threshAux = thresh[:,i] |
|
681 | threshAux = thresh[:,i] | |
682 |
|
682 | |||
683 | indUPthresh = numpy.where(powerAux > threshAux)[0] |
|
683 | indUPthresh = numpy.where(powerAux > threshAux)[0] | |
684 | indDNthresh = numpy.where(powerAux <= threshAux)[0] |
|
684 | indDNthresh = numpy.where(powerAux <= threshAux)[0] | |
685 |
|
685 | |||
686 | j = 0 |
|
686 | j = 0 | |
687 |
|
687 | |||
688 | while (j < indUPthresh.size - 2): |
|
688 | while (j < indUPthresh.size - 2): | |
689 | if (indUPthresh[j + 2] == indUPthresh[j] + 2): |
|
689 | if (indUPthresh[j + 2] == indUPthresh[j] + 2): | |
690 | indDNAux = numpy.where(indDNthresh > indUPthresh[j]) |
|
690 | indDNAux = numpy.where(indDNthresh > indUPthresh[j]) | |
691 | indDNthresh = indDNthresh[indDNAux] |
|
691 | indDNthresh = indDNthresh[indDNAux] | |
692 |
|
692 | |||
693 | if (indDNthresh.size > 0): |
|
693 | if (indDNthresh.size > 0): | |
694 | indEnd = indDNthresh[0] - 1 |
|
694 | indEnd = indDNthresh[0] - 1 | |
695 | indInit = indUPthresh[j] |
|
695 | indInit = indUPthresh[j] | |
696 |
|
696 | |||
697 | meteor = powerAux[indInit:indEnd + 1] |
|
697 | meteor = powerAux[indInit:indEnd + 1] | |
698 | indPeak = meteor.argmax() + indInit |
|
698 | indPeak = meteor.argmax() + indInit | |
699 | FLA = sum(numpy.conj(meteor)*numpy.hstack((meteor[1:],0))) |
|
699 | FLA = sum(numpy.conj(meteor)*numpy.hstack((meteor[1:],0))) | |
700 |
|
700 | |||
701 | listMeteors.append(numpy.array([i,indInit,indPeak,indEnd,FLA])) #CHEQUEAR!!!!! |
|
701 | listMeteors.append(numpy.array([i,indInit,indPeak,indEnd,FLA])) #CHEQUEAR!!!!! | |
702 | j = numpy.where(indUPthresh == indEnd)[0] + 1 |
|
702 | j = numpy.where(indUPthresh == indEnd)[0] + 1 | |
703 | else: j+=1 |
|
703 | else: j+=1 | |
704 | else: j+=1 |
|
704 | else: j+=1 | |
705 |
|
705 | |||
706 | return listMeteors |
|
706 | return listMeteors | |
707 |
|
707 | |||
708 | def __removeMultipleDetections(self,listMeteors, rangeLimit, timeLimit): |
|
708 | def __removeMultipleDetections(self,listMeteors, rangeLimit, timeLimit): | |
709 |
|
709 | |||
710 | arrayMeteors = numpy.asarray(listMeteors) |
|
710 | arrayMeteors = numpy.asarray(listMeteors) | |
711 | listMeteors1 = [] |
|
711 | listMeteors1 = [] | |
712 |
|
712 | |||
713 | while arrayMeteors.shape[0] > 0: |
|
713 | while arrayMeteors.shape[0] > 0: | |
714 | FLAs = arrayMeteors[:,4] |
|
714 | FLAs = arrayMeteors[:,4] | |
715 | maxFLA = FLAs.argmax() |
|
715 | maxFLA = FLAs.argmax() | |
716 | listMeteors1.append(arrayMeteors[maxFLA,:]) |
|
716 | listMeteors1.append(arrayMeteors[maxFLA,:]) | |
717 |
|
717 | |||
718 | MeteorInitTime = arrayMeteors[maxFLA,1] |
|
718 | MeteorInitTime = arrayMeteors[maxFLA,1] | |
719 | MeteorEndTime = arrayMeteors[maxFLA,3] |
|
719 | MeteorEndTime = arrayMeteors[maxFLA,3] | |
720 | MeteorHeight = arrayMeteors[maxFLA,0] |
|
720 | MeteorHeight = arrayMeteors[maxFLA,0] | |
721 |
|
721 | |||
722 | #Check neighborhood |
|
722 | #Check neighborhood | |
723 | maxHeightIndex = MeteorHeight + rangeLimit |
|
723 | maxHeightIndex = MeteorHeight + rangeLimit | |
724 | minHeightIndex = MeteorHeight - rangeLimit |
|
724 | minHeightIndex = MeteorHeight - rangeLimit | |
725 | minTimeIndex = MeteorInitTime - timeLimit |
|
725 | minTimeIndex = MeteorInitTime - timeLimit | |
726 | maxTimeIndex = MeteorEndTime + timeLimit |
|
726 | maxTimeIndex = MeteorEndTime + timeLimit | |
727 |
|
727 | |||
728 | #Check Heights |
|
728 | #Check Heights | |
729 | indHeight = numpy.logical_and(arrayMeteors[:,0] >= minHeightIndex, arrayMeteors[:,0] <= maxHeightIndex) |
|
729 | indHeight = numpy.logical_and(arrayMeteors[:,0] >= minHeightIndex, arrayMeteors[:,0] <= maxHeightIndex) | |
730 | indTime = numpy.logical_and(arrayMeteors[:,3] >= minTimeIndex, arrayMeteors[:,1] <= maxTimeIndex) |
|
730 | indTime = numpy.logical_and(arrayMeteors[:,3] >= minTimeIndex, arrayMeteors[:,1] <= maxTimeIndex) | |
731 | indBoth = numpy.where(numpy.logical_and(indTime,indHeight)) |
|
731 | indBoth = numpy.where(numpy.logical_and(indTime,indHeight)) | |
732 |
|
732 | |||
733 | arrayMeteors = numpy.delete(arrayMeteors, indBoth, axis = 0) |
|
733 | arrayMeteors = numpy.delete(arrayMeteors, indBoth, axis = 0) | |
734 |
|
734 | |||
735 | return listMeteors1 |
|
735 | return listMeteors1 | |
736 |
|
736 | |||
737 | def __meteorReestimation(self, listMeteors, volts, pairslist, thresh, noise, timeInterval,frequency): |
|
737 | def __meteorReestimation(self, listMeteors, volts, pairslist, thresh, noise, timeInterval,frequency): | |
738 | numHeights = volts.shape[2] |
|
738 | numHeights = volts.shape[2] | |
739 | nChannel = volts.shape[0] |
|
739 | nChannel = volts.shape[0] | |
740 |
|
740 | |||
741 | thresholdPhase = thresh[0] |
|
741 | thresholdPhase = thresh[0] | |
742 | thresholdNoise = thresh[1] |
|
742 | thresholdNoise = thresh[1] | |
743 | thresholdDB = float(thresh[2]) |
|
743 | thresholdDB = float(thresh[2]) | |
744 |
|
744 | |||
745 | thresholdDB1 = 10**(thresholdDB/10) |
|
745 | thresholdDB1 = 10**(thresholdDB/10) | |
746 | pairsarray = numpy.array(pairslist) |
|
746 | pairsarray = numpy.array(pairslist) | |
747 | indSides = pairsarray[:,1] |
|
747 | indSides = pairsarray[:,1] | |
748 |
|
748 | |||
749 | pairslist1 = list(pairslist) |
|
749 | pairslist1 = list(pairslist) | |
750 | pairslist1.append((0,1)) |
|
750 | pairslist1.append((0,1)) | |
751 | pairslist1.append((3,4)) |
|
751 | pairslist1.append((3,4)) | |
752 |
|
752 | |||
753 | listMeteors1 = [] |
|
753 | listMeteors1 = [] | |
754 | listPowerSeries = [] |
|
754 | listPowerSeries = [] | |
755 | listVoltageSeries = [] |
|
755 | listVoltageSeries = [] | |
756 | #volts has the war data |
|
756 | #volts has the war data | |
757 |
|
757 | |||
758 | if frequency == 30e6: |
|
758 | if frequency == 30e6: | |
759 | timeLag = 45*10**-3 |
|
759 | timeLag = 45*10**-3 | |
760 | else: |
|
760 | else: | |
761 | timeLag = 15*10**-3 |
|
761 | timeLag = 15*10**-3 | |
762 | lag = numpy.ceil(timeLag/timeInterval) |
|
762 | lag = numpy.ceil(timeLag/timeInterval) | |
763 |
|
763 | |||
764 | for i in range(len(listMeteors)): |
|
764 | for i in range(len(listMeteors)): | |
765 |
|
765 | |||
766 | ###################### 3.6 - 3.7 PARAMETERS REESTIMATION ######################### |
|
766 | ###################### 3.6 - 3.7 PARAMETERS REESTIMATION ######################### | |
767 | meteorAux = numpy.zeros(16) |
|
767 | meteorAux = numpy.zeros(16) | |
768 |
|
768 | |||
769 | #Loading meteor Data (mHeight, mStart, mPeak, mEnd) |
|
769 | #Loading meteor Data (mHeight, mStart, mPeak, mEnd) | |
770 | mHeight = listMeteors[i][0] |
|
770 | mHeight = listMeteors[i][0] | |
771 | mStart = listMeteors[i][1] |
|
771 | mStart = listMeteors[i][1] | |
772 | mPeak = listMeteors[i][2] |
|
772 | mPeak = listMeteors[i][2] | |
773 | mEnd = listMeteors[i][3] |
|
773 | mEnd = listMeteors[i][3] | |
774 |
|
774 | |||
775 | #get the volt data between the start and end times of the meteor |
|
775 | #get the volt data between the start and end times of the meteor | |
776 | meteorVolts = volts[:,mStart:mEnd+1,mHeight] |
|
776 | meteorVolts = volts[:,mStart:mEnd+1,mHeight] | |
777 | meteorVolts = meteorVolts.reshape(meteorVolts.shape[0], meteorVolts.shape[1], 1) |
|
777 | meteorVolts = meteorVolts.reshape(meteorVolts.shape[0], meteorVolts.shape[1], 1) | |
778 |
|
778 | |||
779 | #3.6. Phase Difference estimation |
|
779 | #3.6. Phase Difference estimation | |
780 | phaseDiff, aux = self.__estimatePhaseDifference(meteorVolts, pairslist) |
|
780 | phaseDiff, aux = self.__estimatePhaseDifference(meteorVolts, pairslist) | |
781 |
|
781 | |||
782 | #3.7. Phase difference removal & meteor start, peak and end times reestimated |
|
782 | #3.7. Phase difference removal & meteor start, peak and end times reestimated | |
783 | #meteorVolts0.- all Channels, all Profiles |
|
783 | #meteorVolts0.- all Channels, all Profiles | |
784 | meteorVolts0 = volts[:,:,mHeight] |
|
784 | meteorVolts0 = volts[:,:,mHeight] | |
785 | meteorThresh = noise[:,mHeight]*thresholdNoise |
|
785 | meteorThresh = noise[:,mHeight]*thresholdNoise | |
786 | meteorNoise = noise[:,mHeight] |
|
786 | meteorNoise = noise[:,mHeight] | |
787 | meteorVolts0[indSides,:] = self.__shiftPhase(meteorVolts0[indSides,:], phaseDiff) #Phase Shifting |
|
787 | meteorVolts0[indSides,:] = self.__shiftPhase(meteorVolts0[indSides,:], phaseDiff) #Phase Shifting | |
788 | powerNet0 = numpy.nansum(numpy.abs(meteorVolts0)**2, axis = 0) #Power |
|
788 | powerNet0 = numpy.nansum(numpy.abs(meteorVolts0)**2, axis = 0) #Power | |
789 |
|
789 | |||
790 | #Times reestimation |
|
790 | #Times reestimation | |
791 | mStart1 = numpy.where(powerNet0[:mPeak] < meteorThresh[:mPeak])[0] |
|
791 | mStart1 = numpy.where(powerNet0[:mPeak] < meteorThresh[:mPeak])[0] | |
792 | if mStart1.size > 0: |
|
792 | if mStart1.size > 0: | |
793 | mStart1 = mStart1[-1] + 1 |
|
793 | mStart1 = mStart1[-1] + 1 | |
794 |
|
794 | |||
795 | else: |
|
795 | else: | |
796 | mStart1 = mPeak |
|
796 | mStart1 = mPeak | |
797 |
|
797 | |||
798 | mEnd1 = numpy.where(powerNet0[mPeak:] < meteorThresh[mPeak:])[0][0] + mPeak - 1 |
|
798 | mEnd1 = numpy.where(powerNet0[mPeak:] < meteorThresh[mPeak:])[0][0] + mPeak - 1 | |
799 | mEndDecayTime1 = numpy.where(powerNet0[mPeak:] < meteorNoise[mPeak:])[0] |
|
799 | mEndDecayTime1 = numpy.where(powerNet0[mPeak:] < meteorNoise[mPeak:])[0] | |
800 | if mEndDecayTime1.size == 0: |
|
800 | if mEndDecayTime1.size == 0: | |
801 | mEndDecayTime1 = powerNet0.size |
|
801 | mEndDecayTime1 = powerNet0.size | |
802 | else: |
|
802 | else: | |
803 | mEndDecayTime1 = mEndDecayTime1[0] + mPeak - 1 |
|
803 | mEndDecayTime1 = mEndDecayTime1[0] + mPeak - 1 | |
804 | # mPeak1 = meteorVolts0[mStart1:mEnd1 + 1].argmax() |
|
804 | # mPeak1 = meteorVolts0[mStart1:mEnd1 + 1].argmax() | |
805 |
|
805 | |||
806 | #meteorVolts1.- all Channels, from start to end |
|
806 | #meteorVolts1.- all Channels, from start to end | |
807 | meteorVolts1 = meteorVolts0[:,mStart1:mEnd1 + 1] |
|
807 | meteorVolts1 = meteorVolts0[:,mStart1:mEnd1 + 1] | |
808 | meteorVolts2 = meteorVolts0[:,mPeak + lag:mEnd1 + 1] |
|
808 | meteorVolts2 = meteorVolts0[:,mPeak + lag:mEnd1 + 1] | |
809 | if meteorVolts2.shape[1] == 0: |
|
809 | if meteorVolts2.shape[1] == 0: | |
810 | meteorVolts2 = meteorVolts0[:,mPeak:mEnd1 + 1] |
|
810 | meteorVolts2 = meteorVolts0[:,mPeak:mEnd1 + 1] | |
811 | meteorVolts1 = meteorVolts1.reshape(meteorVolts1.shape[0], meteorVolts1.shape[1], 1) |
|
811 | meteorVolts1 = meteorVolts1.reshape(meteorVolts1.shape[0], meteorVolts1.shape[1], 1) | |
812 | meteorVolts2 = meteorVolts2.reshape(meteorVolts2.shape[0], meteorVolts2.shape[1], 1) |
|
812 | meteorVolts2 = meteorVolts2.reshape(meteorVolts2.shape[0], meteorVolts2.shape[1], 1) | |
813 | ##################### END PARAMETERS REESTIMATION ######################### |
|
813 | ##################### END PARAMETERS REESTIMATION ######################### | |
814 |
|
814 | |||
815 | ##################### 3.8 PHASE DIFFERENCE REESTIMATION ######################## |
|
815 | ##################### 3.8 PHASE DIFFERENCE REESTIMATION ######################## | |
816 | # if mEnd1 - mStart1 > 4: #Error Number 6: echo less than 5 samples long; too short for analysis |
|
816 | # if mEnd1 - mStart1 > 4: #Error Number 6: echo less than 5 samples long; too short for analysis | |
817 | if meteorVolts2.shape[1] > 0: |
|
817 | if meteorVolts2.shape[1] > 0: | |
818 | #Phase Difference re-estimation |
|
818 | #Phase Difference re-estimation | |
819 | phaseDiff1, phaseDiffint = self.__estimatePhaseDifference(meteorVolts2, pairslist1) #Phase Difference Estimation |
|
819 | phaseDiff1, phaseDiffint = self.__estimatePhaseDifference(meteorVolts2, pairslist1) #Phase Difference Estimation | |
820 | # phaseDiff1, phaseDiffint = self.estimatePhaseDifference(meteorVolts2, pairslist) |
|
820 | # phaseDiff1, phaseDiffint = self.estimatePhaseDifference(meteorVolts2, pairslist) | |
821 | meteorVolts2 = meteorVolts2.reshape(meteorVolts2.shape[0], meteorVolts2.shape[1]) |
|
821 | meteorVolts2 = meteorVolts2.reshape(meteorVolts2.shape[0], meteorVolts2.shape[1]) | |
822 | phaseDiff11 = numpy.reshape(phaseDiff1, (phaseDiff1.shape[0],1)) |
|
822 | phaseDiff11 = numpy.reshape(phaseDiff1, (phaseDiff1.shape[0],1)) | |
823 | meteorVolts2[indSides,:] = self.__shiftPhase(meteorVolts2[indSides,:], phaseDiff11[0:4]) #Phase Shifting |
|
823 | meteorVolts2[indSides,:] = self.__shiftPhase(meteorVolts2[indSides,:], phaseDiff11[0:4]) #Phase Shifting | |
824 |
|
824 | |||
825 | #Phase Difference RMS |
|
825 | #Phase Difference RMS | |
826 | phaseRMS1 = numpy.sqrt(numpy.mean(numpy.square(phaseDiff1))) |
|
826 | phaseRMS1 = numpy.sqrt(numpy.mean(numpy.square(phaseDiff1))) | |
827 | powerNet1 = numpy.nansum(numpy.abs(meteorVolts1[:,:])**2,0) |
|
827 | powerNet1 = numpy.nansum(numpy.abs(meteorVolts1[:,:])**2,0) | |
828 | #Data from Meteor |
|
828 | #Data from Meteor | |
829 | mPeak1 = powerNet1.argmax() + mStart1 |
|
829 | mPeak1 = powerNet1.argmax() + mStart1 | |
830 | mPeakPower1 = powerNet1.max() |
|
830 | mPeakPower1 = powerNet1.max() | |
831 | noiseAux = sum(noise[mStart1:mEnd1 + 1,mHeight]) |
|
831 | noiseAux = sum(noise[mStart1:mEnd1 + 1,mHeight]) | |
832 | mSNR1 = (sum(powerNet1)-noiseAux)/noiseAux |
|
832 | mSNR1 = (sum(powerNet1)-noiseAux)/noiseAux | |
833 | Meteor1 = numpy.array([mHeight, mStart1, mPeak1, mEnd1, mPeakPower1, mSNR1, phaseRMS1]) |
|
833 | Meteor1 = numpy.array([mHeight, mStart1, mPeak1, mEnd1, mPeakPower1, mSNR1, phaseRMS1]) | |
834 | Meteor1 = numpy.hstack((Meteor1,phaseDiffint)) |
|
834 | Meteor1 = numpy.hstack((Meteor1,phaseDiffint)) | |
835 | PowerSeries = powerNet0[mStart1:mEndDecayTime1 + 1] |
|
835 | PowerSeries = powerNet0[mStart1:mEndDecayTime1 + 1] | |
836 | #Vectorize |
|
836 | #Vectorize | |
837 | meteorAux[0:7] = [mHeight, mStart1, mPeak1, mEnd1, mPeakPower1, mSNR1, phaseRMS1] |
|
837 | meteorAux[0:7] = [mHeight, mStart1, mPeak1, mEnd1, mPeakPower1, mSNR1, phaseRMS1] | |
838 | meteorAux[7:11] = phaseDiffint[0:4] |
|
838 | meteorAux[7:11] = phaseDiffint[0:4] | |
839 |
|
839 | |||
840 | #Rejection Criterions |
|
840 | #Rejection Criterions | |
841 | if phaseRMS1 > thresholdPhase: #Error Number 17: Phase variation |
|
841 | if phaseRMS1 > thresholdPhase: #Error Number 17: Phase variation | |
842 | meteorAux[-1] = 17 |
|
842 | meteorAux[-1] = 17 | |
843 | elif mSNR1 < thresholdDB1: #Error Number 1: SNR < threshold dB |
|
843 | elif mSNR1 < thresholdDB1: #Error Number 1: SNR < threshold dB | |
844 | meteorAux[-1] = 1 |
|
844 | meteorAux[-1] = 1 | |
845 |
|
845 | |||
846 |
|
846 | |||
847 | else: |
|
847 | else: | |
848 | meteorAux[0:4] = [mHeight, mStart, mPeak, mEnd] |
|
848 | meteorAux[0:4] = [mHeight, mStart, mPeak, mEnd] | |
849 | meteorAux[-1] = 6 #Error Number 6: echo less than 5 samples long; too short for analysis |
|
849 | meteorAux[-1] = 6 #Error Number 6: echo less than 5 samples long; too short for analysis | |
850 | PowerSeries = 0 |
|
850 | PowerSeries = 0 | |
851 |
|
851 | |||
852 | listMeteors1.append(meteorAux) |
|
852 | listMeteors1.append(meteorAux) | |
853 | listPowerSeries.append(PowerSeries) |
|
853 | listPowerSeries.append(PowerSeries) | |
854 | listVoltageSeries.append(meteorVolts1) |
|
854 | listVoltageSeries.append(meteorVolts1) | |
855 |
|
855 | |||
856 | return listMeteors1, listPowerSeries, listVoltageSeries |
|
856 | return listMeteors1, listPowerSeries, listVoltageSeries | |
857 |
|
857 | |||
858 | def __estimateDecayTime(self, listMeteors, listPower, timeInterval, frequency): |
|
858 | def __estimateDecayTime(self, listMeteors, listPower, timeInterval, frequency): | |
859 |
|
859 | |||
860 | threshError = 10 |
|
860 | threshError = 10 | |
861 | #Depending if it is 30 or 50 MHz |
|
861 | #Depending if it is 30 or 50 MHz | |
862 | if frequency == 30e6: |
|
862 | if frequency == 30e6: | |
863 | timeLag = 45*10**-3 |
|
863 | timeLag = 45*10**-3 | |
864 | else: |
|
864 | else: | |
865 | timeLag = 15*10**-3 |
|
865 | timeLag = 15*10**-3 | |
866 | lag = numpy.ceil(timeLag/timeInterval) |
|
866 | lag = numpy.ceil(timeLag/timeInterval) | |
867 |
|
867 | |||
868 | listMeteors1 = [] |
|
868 | listMeteors1 = [] | |
869 |
|
869 | |||
870 | for i in range(len(listMeteors)): |
|
870 | for i in range(len(listMeteors)): | |
871 | meteorPower = listPower[i] |
|
871 | meteorPower = listPower[i] | |
872 | meteorAux = listMeteors[i] |
|
872 | meteorAux = listMeteors[i] | |
873 |
|
873 | |||
874 | if meteorAux[-1] == 0: |
|
874 | if meteorAux[-1] == 0: | |
875 |
|
875 | |||
876 | try: |
|
876 | try: | |
877 | indmax = meteorPower.argmax() |
|
877 | indmax = meteorPower.argmax() | |
878 | indlag = indmax + lag |
|
878 | indlag = indmax + lag | |
879 |
|
879 | |||
880 | y = meteorPower[indlag:] |
|
880 | y = meteorPower[indlag:] | |
881 | x = numpy.arange(0, y.size)*timeLag |
|
881 | x = numpy.arange(0, y.size)*timeLag | |
882 |
|
882 | |||
883 | #first guess |
|
883 | #first guess | |
884 | a = y[0] |
|
884 | a = y[0] | |
885 | tau = timeLag |
|
885 | tau = timeLag | |
886 | #exponential fit |
|
886 | #exponential fit | |
887 | popt, pcov = optimize.curve_fit(self.__exponential_function, x, y, p0 = [a, tau]) |
|
887 | popt, pcov = optimize.curve_fit(self.__exponential_function, x, y, p0 = [a, tau]) | |
888 | y1 = self.__exponential_function(x, *popt) |
|
888 | y1 = self.__exponential_function(x, *popt) | |
889 | #error estimation |
|
889 | #error estimation | |
890 | error = sum((y - y1)**2)/(numpy.var(y)*(y.size - popt.size)) |
|
890 | error = sum((y - y1)**2)/(numpy.var(y)*(y.size - popt.size)) | |
891 |
|
891 | |||
892 | decayTime = popt[1] |
|
892 | decayTime = popt[1] | |
893 | riseTime = indmax*timeInterval |
|
893 | riseTime = indmax*timeInterval | |
894 | meteorAux[11:13] = [decayTime, error] |
|
894 | meteorAux[11:13] = [decayTime, error] | |
895 |
|
895 | |||
896 | #Table items 7, 8 and 11 |
|
896 | #Table items 7, 8 and 11 | |
897 | if (riseTime > 0.3): #Number 7: Echo rise exceeds 0.3s |
|
897 | if (riseTime > 0.3): #Number 7: Echo rise exceeds 0.3s | |
898 | meteorAux[-1] = 7 |
|
898 | meteorAux[-1] = 7 | |
899 | elif (decayTime < 2*riseTime) : #Number 8: Echo decay time less than than twice rise time |
|
899 | elif (decayTime < 2*riseTime) : #Number 8: Echo decay time less than than twice rise time | |
900 | meteorAux[-1] = 8 |
|
900 | meteorAux[-1] = 8 | |
901 | if (error > threshError): #Number 11: Poor fit to amplitude for estimation of decay time |
|
901 | if (error > threshError): #Number 11: Poor fit to amplitude for estimation of decay time | |
902 | meteorAux[-1] = 11 |
|
902 | meteorAux[-1] = 11 | |
903 |
|
903 | |||
904 |
|
904 | |||
905 | except: |
|
905 | except: | |
906 | meteorAux[-1] = 11 |
|
906 | meteorAux[-1] = 11 | |
907 |
|
907 | |||
908 |
|
908 | |||
909 | listMeteors1.append(meteorAux) |
|
909 | listMeteors1.append(meteorAux) | |
910 |
|
910 | |||
911 | return listMeteors1 |
|
911 | return listMeteors1 | |
912 |
|
912 | |||
913 | #Exponential Function |
|
913 | #Exponential Function | |
914 |
|
914 | |||
915 | def __exponential_function(self, x, a, tau): |
|
915 | def __exponential_function(self, x, a, tau): | |
916 | y = a*numpy.exp(-x/tau) |
|
916 | y = a*numpy.exp(-x/tau) | |
917 | return y |
|
917 | return y | |
918 |
|
918 | |||
919 | def __getRadialVelocity(self, listMeteors, listVolts, radialStdThresh, pairslist, timeInterval): |
|
919 | def __getRadialVelocity(self, listMeteors, listVolts, radialStdThresh, pairslist, timeInterval): | |
920 |
|
920 | |||
921 | pairslist1 = list(pairslist) |
|
921 | pairslist1 = list(pairslist) | |
922 | pairslist1.append((0,1)) |
|
922 | pairslist1.append((0,1)) | |
923 | pairslist1.append((3,4)) |
|
923 | pairslist1.append((3,4)) | |
924 | numPairs = len(pairslist1) |
|
924 | numPairs = len(pairslist1) | |
925 | #Time Lag |
|
925 | #Time Lag | |
926 | timeLag = 45*10**-3 |
|
926 | timeLag = 45*10**-3 | |
927 | c = 3e8 |
|
927 | c = 3e8 | |
928 | lag = numpy.ceil(timeLag/timeInterval) |
|
928 | lag = numpy.ceil(timeLag/timeInterval) | |
929 | freq = 30e6 |
|
929 | freq = 30e6 | |
930 |
|
930 | |||
931 | listMeteors1 = [] |
|
931 | listMeteors1 = [] | |
932 |
|
932 | |||
933 | for i in range(len(listMeteors)): |
|
933 | for i in range(len(listMeteors)): | |
934 | meteor = listMeteors[i] |
|
934 | meteor = listMeteors[i] | |
935 | meteorAux = numpy.hstack((meteor[:-1], 0, 0, meteor[-1])) |
|
935 | meteorAux = numpy.hstack((meteor[:-1], 0, 0, meteor[-1])) | |
936 | if meteor[-1] == 0: |
|
936 | if meteor[-1] == 0: | |
937 | mStart = listMeteors[i][1] |
|
937 | mStart = listMeteors[i][1] | |
938 | mPeak = listMeteors[i][2] |
|
938 | mPeak = listMeteors[i][2] | |
939 | mLag = mPeak - mStart + lag |
|
939 | mLag = mPeak - mStart + lag | |
940 |
|
940 | |||
941 | #get the volt data between the start and end times of the meteor |
|
941 | #get the volt data between the start and end times of the meteor | |
942 | meteorVolts = listVolts[i] |
|
942 | meteorVolts = listVolts[i] | |
943 | meteorVolts = meteorVolts.reshape(meteorVolts.shape[0], meteorVolts.shape[1], 1) |
|
943 | meteorVolts = meteorVolts.reshape(meteorVolts.shape[0], meteorVolts.shape[1], 1) | |
944 |
|
944 | |||
945 | #Get CCF |
|
945 | #Get CCF | |
946 | allCCFs = self.__calculateCCF(meteorVolts, pairslist1, [-2,-1,0,1,2]) |
|
946 | allCCFs = self.__calculateCCF(meteorVolts, pairslist1, [-2,-1,0,1,2]) | |
947 |
|
947 | |||
948 | #Method 2 |
|
948 | #Method 2 | |
949 | slopes = numpy.zeros(numPairs) |
|
949 | slopes = numpy.zeros(numPairs) | |
950 | time = numpy.array([-2,-1,1,2])*timeInterval |
|
950 | time = numpy.array([-2,-1,1,2])*timeInterval | |
951 | angAllCCF = numpy.angle(allCCFs[:,[0,1,3,4],0]) |
|
951 | angAllCCF = numpy.angle(allCCFs[:,[0,1,3,4],0]) | |
952 |
|
952 | |||
953 | #Correct phases |
|
953 | #Correct phases | |
954 | derPhaseCCF = angAllCCF[:,1:] - angAllCCF[:,0:-1] |
|
954 | derPhaseCCF = angAllCCF[:,1:] - angAllCCF[:,0:-1] | |
955 | indDer = numpy.where(numpy.abs(derPhaseCCF) > numpy.pi) |
|
955 | indDer = numpy.where(numpy.abs(derPhaseCCF) > numpy.pi) | |
956 |
|
956 | |||
957 | if indDer[0].shape[0] > 0: |
|
957 | if indDer[0].shape[0] > 0: | |
958 | for i in range(indDer[0].shape[0]): |
|
958 | for i in range(indDer[0].shape[0]): | |
959 | signo = -numpy.sign(derPhaseCCF[indDer[0][i],indDer[1][i]]) |
|
959 | signo = -numpy.sign(derPhaseCCF[indDer[0][i],indDer[1][i]]) | |
960 | angAllCCF[indDer[0][i],indDer[1][i]+1:] += signo*2*numpy.pi |
|
960 | angAllCCF[indDer[0][i],indDer[1][i]+1:] += signo*2*numpy.pi | |
961 |
|
961 | |||
962 | # fit = scipy.stats.linregress(numpy.array([-2,-1,1,2])*timeInterval, numpy.array([phaseLagN2s[i],phaseLagN1s[i],phaseLag1s[i],phaseLag2s[i]])) |
|
962 | # fit = scipy.stats.linregress(numpy.array([-2,-1,1,2])*timeInterval, numpy.array([phaseLagN2s[i],phaseLagN1s[i],phaseLag1s[i],phaseLag2s[i]])) | |
963 | for j in range(numPairs): |
|
963 | for j in range(numPairs): | |
964 | fit = stats.linregress(time, angAllCCF[j,:]) |
|
964 | fit = stats.linregress(time, angAllCCF[j,:]) | |
965 | slopes[j] = fit[0] |
|
965 | slopes[j] = fit[0] | |
966 |
|
966 | |||
967 | #Remove Outlier |
|
967 | #Remove Outlier | |
968 | # indOut = numpy.argmax(numpy.abs(slopes - numpy.mean(slopes))) |
|
968 | # indOut = numpy.argmax(numpy.abs(slopes - numpy.mean(slopes))) | |
969 | # slopes = numpy.delete(slopes,indOut) |
|
969 | # slopes = numpy.delete(slopes,indOut) | |
970 | # indOut = numpy.argmax(numpy.abs(slopes - numpy.mean(slopes))) |
|
970 | # indOut = numpy.argmax(numpy.abs(slopes - numpy.mean(slopes))) | |
971 | # slopes = numpy.delete(slopes,indOut) |
|
971 | # slopes = numpy.delete(slopes,indOut) | |
972 |
|
972 | |||
973 | radialVelocity = -numpy.mean(slopes)*(0.25/numpy.pi)*(c/freq) |
|
973 | radialVelocity = -numpy.mean(slopes)*(0.25/numpy.pi)*(c/freq) | |
974 | radialError = numpy.std(slopes)*(0.25/numpy.pi)*(c/freq) |
|
974 | radialError = numpy.std(slopes)*(0.25/numpy.pi)*(c/freq) | |
975 | meteorAux[-2] = radialError |
|
975 | meteorAux[-2] = radialError | |
976 | meteorAux[-3] = radialVelocity |
|
976 | meteorAux[-3] = radialVelocity | |
977 |
|
977 | |||
978 | #Setting Error |
|
978 | #Setting Error | |
979 | #Number 15: Radial Drift velocity or projected horizontal velocity exceeds 200 m/s |
|
979 | #Number 15: Radial Drift velocity or projected horizontal velocity exceeds 200 m/s | |
980 | if numpy.abs(radialVelocity) > 200: |
|
980 | if numpy.abs(radialVelocity) > 200: | |
981 | meteorAux[-1] = 15 |
|
981 | meteorAux[-1] = 15 | |
982 | #Number 12: Poor fit to CCF variation for estimation of radial drift velocity |
|
982 | #Number 12: Poor fit to CCF variation for estimation of radial drift velocity | |
983 | elif radialError > radialStdThresh: |
|
983 | elif radialError > radialStdThresh: | |
984 | meteorAux[-1] = 12 |
|
984 | meteorAux[-1] = 12 | |
985 |
|
985 | |||
986 | listMeteors1.append(meteorAux) |
|
986 | listMeteors1.append(meteorAux) | |
987 | return listMeteors1 |
|
987 | return listMeteors1 | |
988 |
|
988 | |||
989 | def __setNewArrays(self, listMeteors, date, heiRang): |
|
989 | def __setNewArrays(self, listMeteors, date, heiRang): | |
990 |
|
990 | |||
991 | #New arrays |
|
991 | #New arrays | |
992 | arrayMeteors = numpy.array(listMeteors) |
|
992 | arrayMeteors = numpy.array(listMeteors) | |
993 | arrayParameters = numpy.zeros((len(listMeteors),10)) |
|
993 | arrayParameters = numpy.zeros((len(listMeteors),10)) | |
994 |
|
994 | |||
995 | #Date inclusion |
|
995 | #Date inclusion | |
996 | date = re.findall(r'\((.*?)\)', date) |
|
996 | date = re.findall(r'\((.*?)\)', date) | |
997 | date = date[0].split(',') |
|
997 | date = date[0].split(',') | |
998 | date = map(int, date) |
|
998 | date = map(int, date) | |
999 | date = [date[0]*10000 + date[1]*100 + date[2], date[3]*10000 + date[4]*100 + date[5]] |
|
999 | date = [date[0]*10000 + date[1]*100 + date[2], date[3]*10000 + date[4]*100 + date[5]] | |
1000 | arrayDate = numpy.tile(date, (len(listMeteors), 1)) |
|
1000 | arrayDate = numpy.tile(date, (len(listMeteors), 1)) | |
1001 |
|
1001 | |||
1002 | #Meteor array |
|
1002 | #Meteor array | |
1003 | arrayMeteors[:,0] = heiRang[arrayMeteors[:,0].astype(int)] |
|
1003 | arrayMeteors[:,0] = heiRang[arrayMeteors[:,0].astype(int)] | |
1004 | arrayMeteors = numpy.hstack((arrayDate, arrayMeteors)) |
|
1004 | arrayMeteors = numpy.hstack((arrayDate, arrayMeteors)) | |
1005 |
|
1005 | |||
1006 | #Parameters Array |
|
1006 | #Parameters Array | |
1007 | arrayParameters[:,0:3] = arrayMeteors[:,0:3] |
|
1007 | arrayParameters[:,0:3] = arrayMeteors[:,0:3] | |
1008 | arrayParameters[:,-3:] = arrayMeteors[:,-3:] |
|
1008 | arrayParameters[:,-3:] = arrayMeteors[:,-3:] | |
1009 |
|
1009 | |||
1010 | return arrayMeteors, arrayParameters |
|
1010 | return arrayMeteors, arrayParameters | |
1011 |
|
1011 | |||
1012 | def __getAOA(self, phases, pairsList, error, AOAthresh, azimuth): |
|
1012 | def __getAOA(self, phases, pairsList, error, AOAthresh, azimuth): | |
1013 |
|
1013 | |||
1014 | arrayAOA = numpy.zeros((phases.shape[0],3)) |
|
1014 | arrayAOA = numpy.zeros((phases.shape[0],3)) | |
1015 | cosdir0, cosdir = self.__getDirectionCosines(phases, pairsList) |
|
1015 | cosdir0, cosdir = self.__getDirectionCosines(phases, pairsList) | |
1016 |
|
1016 | |||
1017 | arrayAOA[:,:2] = self.__calculateAOA(cosdir, azimuth) |
|
1017 | arrayAOA[:,:2] = self.__calculateAOA(cosdir, azimuth) | |
1018 | cosDirError = numpy.sum(numpy.abs(cosdir0 - cosdir), axis = 1) |
|
1018 | cosDirError = numpy.sum(numpy.abs(cosdir0 - cosdir), axis = 1) | |
1019 | arrayAOA[:,2] = cosDirError |
|
1019 | arrayAOA[:,2] = cosDirError | |
1020 |
|
1020 | |||
1021 | azimuthAngle = arrayAOA[:,0] |
|
1021 | azimuthAngle = arrayAOA[:,0] | |
1022 | zenithAngle = arrayAOA[:,1] |
|
1022 | zenithAngle = arrayAOA[:,1] | |
1023 |
|
1023 | |||
1024 | #Setting Error |
|
1024 | #Setting Error | |
1025 | #Number 3: AOA not fesible |
|
1025 | #Number 3: AOA not fesible | |
1026 | indInvalid = numpy.where(numpy.logical_and((numpy.logical_or(numpy.isnan(zenithAngle), numpy.isnan(azimuthAngle))),error == 0))[0] |
|
1026 | indInvalid = numpy.where(numpy.logical_and((numpy.logical_or(numpy.isnan(zenithAngle), numpy.isnan(azimuthAngle))),error == 0))[0] | |
1027 | error[indInvalid] = 3 |
|
1027 | error[indInvalid] = 3 | |
1028 | #Number 4: Large difference in AOAs obtained from different antenna baselines |
|
1028 | #Number 4: Large difference in AOAs obtained from different antenna baselines | |
1029 | indInvalid = numpy.where(numpy.logical_and(cosDirError > AOAthresh,error == 0))[0] |
|
1029 | indInvalid = numpy.where(numpy.logical_and(cosDirError > AOAthresh,error == 0))[0] | |
1030 | error[indInvalid] = 4 |
|
1030 | error[indInvalid] = 4 | |
1031 | return arrayAOA, error |
|
1031 | return arrayAOA, error | |
1032 |
|
1032 | |||
1033 | def __getDirectionCosines(self, arrayPhase, pairsList): |
|
1033 | def __getDirectionCosines(self, arrayPhase, pairsList): | |
1034 |
|
1034 | |||
1035 | #Initializing some variables |
|
1035 | #Initializing some variables | |
1036 | ang_aux = numpy.array([-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8])*2*numpy.pi |
|
1036 | ang_aux = numpy.array([-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8])*2*numpy.pi | |
1037 | ang_aux = ang_aux.reshape(1,ang_aux.size) |
|
1037 | ang_aux = ang_aux.reshape(1,ang_aux.size) | |
1038 |
|
1038 | |||
1039 | cosdir = numpy.zeros((arrayPhase.shape[0],2)) |
|
1039 | cosdir = numpy.zeros((arrayPhase.shape[0],2)) | |
1040 | cosdir0 = numpy.zeros((arrayPhase.shape[0],2)) |
|
1040 | cosdir0 = numpy.zeros((arrayPhase.shape[0],2)) | |
1041 |
|
1041 | |||
1042 |
|
1042 | |||
1043 | for i in range(2): |
|
1043 | for i in range(2): | |
1044 | #First Estimation |
|
1044 | #First Estimation | |
1045 | phi0_aux = arrayPhase[:,pairsList[i][0]] + arrayPhase[:,pairsList[i][1]] |
|
1045 | phi0_aux = arrayPhase[:,pairsList[i][0]] + arrayPhase[:,pairsList[i][1]] | |
1046 | #Dealias |
|
1046 | #Dealias | |
1047 | indcsi = numpy.where(phi0_aux > numpy.pi) |
|
1047 | indcsi = numpy.where(phi0_aux > numpy.pi) | |
1048 | phi0_aux[indcsi] -= 2*numpy.pi |
|
1048 | phi0_aux[indcsi] -= 2*numpy.pi | |
1049 | indcsi = numpy.where(phi0_aux < -numpy.pi) |
|
1049 | indcsi = numpy.where(phi0_aux < -numpy.pi) | |
1050 | phi0_aux[indcsi] += 2*numpy.pi |
|
1050 | phi0_aux[indcsi] += 2*numpy.pi | |
1051 | #Direction Cosine 0 |
|
1051 | #Direction Cosine 0 | |
1052 | cosdir0[:,i] = -(phi0_aux)/(2*numpy.pi*0.5) |
|
1052 | cosdir0[:,i] = -(phi0_aux)/(2*numpy.pi*0.5) | |
1053 |
|
1053 | |||
1054 | #Most-Accurate Second Estimation |
|
1054 | #Most-Accurate Second Estimation | |
1055 | phi1_aux = arrayPhase[:,pairsList[i][0]] - arrayPhase[:,pairsList[i][1]] |
|
1055 | phi1_aux = arrayPhase[:,pairsList[i][0]] - arrayPhase[:,pairsList[i][1]] | |
1056 | phi1_aux = phi1_aux.reshape(phi1_aux.size,1) |
|
1056 | phi1_aux = phi1_aux.reshape(phi1_aux.size,1) | |
1057 | #Direction Cosine 1 |
|
1057 | #Direction Cosine 1 | |
1058 | cosdir1 = -(phi1_aux + ang_aux)/(2*numpy.pi*4.5) |
|
1058 | cosdir1 = -(phi1_aux + ang_aux)/(2*numpy.pi*4.5) | |
1059 |
|
1059 | |||
1060 | #Searching the correct Direction Cosine |
|
1060 | #Searching the correct Direction Cosine | |
1061 | cosdir0_aux = cosdir0[:,i] |
|
1061 | cosdir0_aux = cosdir0[:,i] | |
1062 | cosdir0_aux = cosdir0_aux.reshape(cosdir0_aux.size,1) |
|
1062 | cosdir0_aux = cosdir0_aux.reshape(cosdir0_aux.size,1) | |
1063 | #Minimum Distance |
|
1063 | #Minimum Distance | |
1064 | cosDiff = (cosdir1 - cosdir0_aux)**2 |
|
1064 | cosDiff = (cosdir1 - cosdir0_aux)**2 | |
1065 | indcos = cosDiff.argmin(axis = 1) |
|
1065 | indcos = cosDiff.argmin(axis = 1) | |
1066 | #Saving Value obtained |
|
1066 | #Saving Value obtained | |
1067 | cosdir[:,i] = cosdir1[numpy.arange(len(indcos)),indcos] |
|
1067 | cosdir[:,i] = cosdir1[numpy.arange(len(indcos)),indcos] | |
1068 |
|
1068 | |||
1069 | return cosdir0, cosdir |
|
1069 | return cosdir0, cosdir | |
1070 |
|
1070 | |||
1071 | def __calculateAOA(self, cosdir, azimuth): |
|
1071 | def __calculateAOA(self, cosdir, azimuth): | |
1072 | cosdirX = cosdir[:,0] |
|
1072 | cosdirX = cosdir[:,0] | |
1073 | cosdirY = cosdir[:,1] |
|
1073 | cosdirY = cosdir[:,1] | |
1074 |
|
1074 | |||
1075 | zenithAngle = numpy.arccos(numpy.sqrt(1 - cosdirX**2 - cosdirY**2))*180/numpy.pi |
|
1075 | zenithAngle = numpy.arccos(numpy.sqrt(1 - cosdirX**2 - cosdirY**2))*180/numpy.pi | |
1076 | azimuthAngle = numpy.arctan2(cosdirX,cosdirY)*180/numpy.pi + azimuth #0 deg north, 90 deg east |
|
1076 | azimuthAngle = numpy.arctan2(cosdirX,cosdirY)*180/numpy.pi + azimuth #0 deg north, 90 deg east | |
1077 | angles = numpy.vstack((azimuthAngle, zenithAngle)).transpose() |
|
1077 | angles = numpy.vstack((azimuthAngle, zenithAngle)).transpose() | |
1078 |
|
1078 | |||
1079 | return angles |
|
1079 | return angles | |
1080 |
|
1080 | |||
1081 | def __getHeights(self, Ranges, zenith, error, minHeight, maxHeight): |
|
1081 | def __getHeights(self, Ranges, zenith, error, minHeight, maxHeight): | |
1082 |
|
1082 | |||
1083 | Ramb = 375 #Ramb = c/(2*PRF) |
|
1083 | Ramb = 375 #Ramb = c/(2*PRF) | |
1084 | Re = 6371 #Earth Radius |
|
1084 | Re = 6371 #Earth Radius | |
1085 | heights = numpy.zeros(Ranges.shape) |
|
1085 | heights = numpy.zeros(Ranges.shape) | |
1086 |
|
1086 | |||
1087 | R_aux = numpy.array([0,1,2])*Ramb |
|
1087 | R_aux = numpy.array([0,1,2])*Ramb | |
1088 | R_aux = R_aux.reshape(1,R_aux.size) |
|
1088 | R_aux = R_aux.reshape(1,R_aux.size) | |
1089 |
|
1089 | |||
1090 | Ranges = Ranges.reshape(Ranges.size,1) |
|
1090 | Ranges = Ranges.reshape(Ranges.size,1) | |
1091 |
|
1091 | |||
1092 | Ri = Ranges + R_aux |
|
1092 | Ri = Ranges + R_aux | |
1093 | hi = numpy.sqrt(Re**2 + Ri**2 + (2*Re*numpy.cos(zenith*numpy.pi/180)*Ri.transpose()).transpose()) - Re |
|
1093 | hi = numpy.sqrt(Re**2 + Ri**2 + (2*Re*numpy.cos(zenith*numpy.pi/180)*Ri.transpose()).transpose()) - Re | |
1094 |
|
1094 | |||
1095 | #Check if there is a height between 70 and 110 km |
|
1095 | #Check if there is a height between 70 and 110 km | |
1096 | h_bool = numpy.sum(numpy.logical_and(hi > minHeight, hi < maxHeight), axis = 1) |
|
1096 | h_bool = numpy.sum(numpy.logical_and(hi > minHeight, hi < maxHeight), axis = 1) | |
1097 | ind_h = numpy.where(h_bool == 1)[0] |
|
1097 | ind_h = numpy.where(h_bool == 1)[0] | |
1098 |
|
1098 | |||
1099 | hCorr = hi[ind_h, :] |
|
1099 | hCorr = hi[ind_h, :] | |
1100 | ind_hCorr = numpy.where(numpy.logical_and(hi > minHeight, hi < maxHeight)) |
|
1100 | ind_hCorr = numpy.where(numpy.logical_and(hi > minHeight, hi < maxHeight)) | |
1101 |
|
1101 | |||
1102 | hCorr = hi[ind_hCorr] |
|
1102 | hCorr = hi[ind_hCorr] | |
1103 | heights[ind_h] = hCorr |
|
1103 | heights[ind_h] = hCorr | |
1104 |
|
1104 | |||
1105 | #Setting Error |
|
1105 | #Setting Error | |
1106 | #Number 13: Height unresolvable echo: not valid height within 70 to 110 km |
|
1106 | #Number 13: Height unresolvable echo: not valid height within 70 to 110 km | |
1107 | #Number 14: Height ambiguous echo: more than one possible height within 70 to 110 km |
|
1107 | #Number 14: Height ambiguous echo: more than one possible height within 70 to 110 km | |
1108 |
|
1108 | |||
1109 | indInvalid2 = numpy.where(numpy.logical_and(h_bool > 1, error == 0))[0] |
|
1109 | indInvalid2 = numpy.where(numpy.logical_and(h_bool > 1, error == 0))[0] | |
1110 | error[indInvalid2] = 14 |
|
1110 | error[indInvalid2] = 14 | |
1111 | indInvalid1 = numpy.where(numpy.logical_and(h_bool == 0, error == 0))[0] |
|
1111 | indInvalid1 = numpy.where(numpy.logical_and(h_bool == 0, error == 0))[0] | |
1112 | error[indInvalid1] = 13 |
|
1112 | error[indInvalid1] = 13 | |
1113 |
|
1113 | |||
1114 | return heights, error |
|
1114 | return heights, error | |
1115 |
|
1115 | |||
1116 | def SpectralFitting(self, getSNR = True, path=None, file=None, groupList=None): |
|
1116 | def SpectralFitting(self, getSNR = True, path=None, file=None, groupList=None): | |
1117 |
|
1117 | |||
1118 | ''' |
|
1118 | ''' | |
1119 | Function GetMoments() |
|
1119 | Function GetMoments() | |
1120 |
|
1120 | |||
1121 | Input: |
|
1121 | Input: | |
1122 | Output: |
|
1122 | Output: | |
1123 | Variables modified: |
|
1123 | Variables modified: | |
1124 | ''' |
|
1124 | ''' | |
1125 | if path != None: |
|
1125 | if path != None: | |
1126 | sys.path.append(path) |
|
1126 | sys.path.append(path) | |
1127 | self.dataOut.library = importlib.import_module(file) |
|
1127 | self.dataOut.library = importlib.import_module(file) | |
1128 |
|
1128 | |||
1129 | #To be inserted as a parameter |
|
1129 | #To be inserted as a parameter | |
1130 | groupArray = numpy.array(groupList) |
|
1130 | groupArray = numpy.array(groupList) | |
1131 | # groupArray = numpy.array([[0,1],[2,3]]) |
|
1131 | # groupArray = numpy.array([[0,1],[2,3]]) | |
1132 | self.dataOut.groupList = groupArray |
|
1132 | self.dataOut.groupList = groupArray | |
1133 |
|
1133 | |||
1134 | nGroups = groupArray.shape[0] |
|
1134 | nGroups = groupArray.shape[0] | |
1135 | nChannels = self.dataIn.nChannels |
|
1135 | nChannels = self.dataIn.nChannels | |
1136 | nHeights=self.dataIn.heightList.size |
|
1136 | nHeights=self.dataIn.heightList.size | |
1137 |
|
1137 | |||
1138 | #Parameters Array |
|
1138 | #Parameters Array | |
1139 | self.dataOut.data_param = None |
|
1139 | self.dataOut.data_param = None | |
1140 |
|
1140 | |||
1141 | #Set constants |
|
1141 | #Set constants | |
1142 | constants = self.dataOut.library.setConstants(self.dataIn) |
|
1142 | constants = self.dataOut.library.setConstants(self.dataIn) | |
1143 | self.dataOut.constants = constants |
|
1143 | self.dataOut.constants = constants | |
1144 | M = self.dataIn.normFactor |
|
1144 | M = self.dataIn.normFactor | |
1145 | N = self.dataIn.nFFTPoints |
|
1145 | N = self.dataIn.nFFTPoints | |
1146 | ippSeconds = self.dataIn.ippSeconds |
|
1146 | ippSeconds = self.dataIn.ippSeconds | |
1147 | K = self.dataIn.nIncohInt |
|
1147 | K = self.dataIn.nIncohInt | |
1148 | pairsArray = numpy.array(self.dataIn.pairsList) |
|
1148 | pairsArray = numpy.array(self.dataIn.pairsList) | |
1149 |
|
1149 | |||
1150 | #List of possible combinations |
|
1150 | #List of possible combinations | |
1151 | listComb = itertools.combinations(numpy.arange(groupArray.shape[1]),2) |
|
1151 | listComb = itertools.combinations(numpy.arange(groupArray.shape[1]),2) | |
1152 | indCross = numpy.zeros(len(list(listComb)), dtype = 'int') |
|
1152 | indCross = numpy.zeros(len(list(listComb)), dtype = 'int') | |
1153 |
|
1153 | |||
1154 | if getSNR: |
|
1154 | if getSNR: | |
1155 | listChannels = groupArray.reshape((groupArray.size)) |
|
1155 | listChannels = groupArray.reshape((groupArray.size)) | |
1156 | listChannels.sort() |
|
1156 | listChannels.sort() | |
1157 | noise = self.dataIn.getNoise() |
|
1157 | noise = self.dataIn.getNoise() | |
1158 | self.dataOut.SNR = self.__getSNR(self.dataIn.data_spc[listChannels,:,:], noise[listChannels]) |
|
1158 | self.dataOut.data_SNR = self.__getSNR(self.dataIn.data_spc[listChannels,:,:], noise[listChannels]) | |
1159 |
|
1159 | |||
1160 | for i in range(nGroups): |
|
1160 | for i in range(nGroups): | |
1161 | coord = groupArray[i,:] |
|
1161 | coord = groupArray[i,:] | |
1162 |
|
1162 | |||
1163 | #Input data array |
|
1163 | #Input data array | |
1164 | data = self.dataIn.data_spc[coord,:,:]/(M*N) |
|
1164 | data = self.dataIn.data_spc[coord,:,:]/(M*N) | |
1165 | data = data.reshape((data.shape[0]*data.shape[1],data.shape[2])) |
|
1165 | data = data.reshape((data.shape[0]*data.shape[1],data.shape[2])) | |
1166 |
|
1166 | |||
1167 | #Cross Spectra data array for Covariance Matrixes |
|
1167 | #Cross Spectra data array for Covariance Matrixes | |
1168 | ind = 0 |
|
1168 | ind = 0 | |
1169 | for pairs in listComb: |
|
1169 | for pairs in listComb: | |
1170 | pairsSel = numpy.array([coord[x],coord[y]]) |
|
1170 | pairsSel = numpy.array([coord[x],coord[y]]) | |
1171 | indCross[ind] = int(numpy.where(numpy.all(pairsArray == pairsSel, axis = 1))[0][0]) |
|
1171 | indCross[ind] = int(numpy.where(numpy.all(pairsArray == pairsSel, axis = 1))[0][0]) | |
1172 | ind += 1 |
|
1172 | ind += 1 | |
1173 | dataCross = self.dataIn.data_cspc[indCross,:,:]/(M*N) |
|
1173 | dataCross = self.dataIn.data_cspc[indCross,:,:]/(M*N) | |
1174 | dataCross = dataCross**2/K |
|
1174 | dataCross = dataCross**2/K | |
1175 |
|
1175 | |||
1176 | for h in range(nHeights): |
|
1176 | for h in range(nHeights): | |
1177 | # print self.dataOut.heightList[h] |
|
1177 | # print self.dataOut.heightList[h] | |
1178 |
|
1178 | |||
1179 | #Input |
|
1179 | #Input | |
1180 | d = data[:,h] |
|
1180 | d = data[:,h] | |
1181 |
|
1181 | |||
1182 | #Covariance Matrix |
|
1182 | #Covariance Matrix | |
1183 | D = numpy.diag(d**2/K) |
|
1183 | D = numpy.diag(d**2/K) | |
1184 | ind = 0 |
|
1184 | ind = 0 | |
1185 | for pairs in listComb: |
|
1185 | for pairs in listComb: | |
1186 | #Coordinates in Covariance Matrix |
|
1186 | #Coordinates in Covariance Matrix | |
1187 | x = pairs[0] |
|
1187 | x = pairs[0] | |
1188 | y = pairs[1] |
|
1188 | y = pairs[1] | |
1189 | #Channel Index |
|
1189 | #Channel Index | |
1190 | S12 = dataCross[ind,:,h] |
|
1190 | S12 = dataCross[ind,:,h] | |
1191 | D12 = numpy.diag(S12) |
|
1191 | D12 = numpy.diag(S12) | |
1192 | #Completing Covariance Matrix with Cross Spectras |
|
1192 | #Completing Covariance Matrix with Cross Spectras | |
1193 | D[x*N:(x+1)*N,y*N:(y+1)*N] = D12 |
|
1193 | D[x*N:(x+1)*N,y*N:(y+1)*N] = D12 | |
1194 | D[y*N:(y+1)*N,x*N:(x+1)*N] = D12 |
|
1194 | D[y*N:(y+1)*N,x*N:(x+1)*N] = D12 | |
1195 | ind += 1 |
|
1195 | ind += 1 | |
1196 | Dinv=numpy.linalg.inv(D) |
|
1196 | Dinv=numpy.linalg.inv(D) | |
1197 | L=numpy.linalg.cholesky(Dinv) |
|
1197 | L=numpy.linalg.cholesky(Dinv) | |
1198 | LT=L.T |
|
1198 | LT=L.T | |
1199 |
|
1199 | |||
1200 | dp = numpy.dot(LT,d) |
|
1200 | dp = numpy.dot(LT,d) | |
1201 |
|
1201 | |||
1202 | #Initial values |
|
1202 | #Initial values | |
1203 | data_spc = self.dataIn.data_spc[coord,:,h] |
|
1203 | data_spc = self.dataIn.data_spc[coord,:,h] | |
1204 | p0 = self.dataOut.library.initialValuesFunction(data_spc, constants) |
|
1204 | p0 = numpy.array(self.dataOut.library.initialValuesFunction(data_spc, constants)) | |
1205 |
|
1205 | |||
1206 |
|
|
1206 | try: | |
1207 | minp,covp,infodict,mesg,ier = optimize.leastsq(self.__residFunction,p0,args=(dp,LT,constants),full_output=True) |
|
1207 | #Least Squares | |
1208 |
|
|
1208 | minp,covp,infodict,mesg,ier = optimize.leastsq(self.__residFunction,p0,args=(dp,LT,constants),full_output=True) | |
1209 | #Chi square error |
|
1209 | # minp,covp = optimize.leastsq(self.__residFunction,p0,args=(dp,LT,constants)) | |
1210 | error0 = numpy.sum(infodict['fvec']**2)/(2*N) |
|
1210 | #Chi square error | |
1211 | # error0 = 0 |
|
1211 | error0 = numpy.sum(infodict['fvec']**2)/(2*N) | |
1212 | #Error with Jacobian |
|
1212 | #Error with Jacobian | |
1213 | error1 = self.dataOut.library.errorFunction(minp,constants,LT) |
|
1213 | error1 = self.dataOut.library.errorFunction(minp,constants,LT) | |
|
1214 | except: | |||
|
1215 | minp = p0*numpy.nan | |||
|
1216 | error0 = numpy.nan | |||
|
1217 | error1 = p0*numpy.nan | |||
|
1218 | ||||
1214 | #Save |
|
1219 | #Save | |
1215 | if self.dataOut.data_param == None: |
|
1220 | if self.dataOut.data_param == None: | |
1216 |
self.dataOut.data_param = numpy.zeros((nGroups, |
|
1221 | self.dataOut.data_param = numpy.zeros((nGroups, p0.size, nHeights))*numpy.nan | |
1217 |
self.dataOut.error = numpy.zeros((nGroups, |
|
1222 | self.dataOut.data_error = numpy.zeros((nGroups, p0.size + 1, nHeights))*numpy.nan | |
1218 |
|
1223 | |||
1219 | self.dataOut.error[i,:,h] = numpy.hstack((error0,error1)) |
|
1224 | self.dataOut.data_error[i,:,h] = numpy.hstack((error0,error1)) | |
1220 | self.dataOut.data_param[i,:,h] = minp |
|
1225 | self.dataOut.data_param[i,:,h] = minp | |
1221 | return |
|
1226 | return | |
1222 |
|
1227 | |||
1223 |
|
1228 | |||
1224 | def __residFunction(self, p, dp, LT, constants): |
|
1229 | def __residFunction(self, p, dp, LT, constants): | |
1225 |
|
1230 | |||
1226 | fm = self.dataOut.library.modelFunction(p, constants) |
|
1231 | fm = self.dataOut.library.modelFunction(p, constants) | |
1227 | fmp=numpy.dot(LT,fm) |
|
1232 | fmp=numpy.dot(LT,fm) | |
1228 |
|
1233 | |||
1229 | return dp-fmp |
|
1234 | return dp-fmp | |
1230 |
|
1235 | |||
1231 | def __getSNR(self, z, noise): |
|
1236 | def __getSNR(self, z, noise): | |
1232 |
|
1237 | |||
1233 | avg = numpy.average(z, axis=1) |
|
1238 | avg = numpy.average(z, axis=1) | |
1234 | SNR = (avg.T-noise)/noise |
|
1239 | SNR = (avg.T-noise)/noise | |
1235 | SNR = SNR.T |
|
1240 | SNR = SNR.T | |
1236 | return SNR |
|
1241 | return SNR | |
1237 |
|
1242 | |||
1238 | def __chisq(p,chindex,hindex): |
|
1243 | def __chisq(p,chindex,hindex): | |
1239 | #similar to Resid but calculates CHI**2 |
|
1244 | #similar to Resid but calculates CHI**2 | |
1240 | [LT,d,fm]=setupLTdfm(p,chindex,hindex) |
|
1245 | [LT,d,fm]=setupLTdfm(p,chindex,hindex) | |
1241 | dp=numpy.dot(LT,d) |
|
1246 | dp=numpy.dot(LT,d) | |
1242 | fmp=numpy.dot(LT,fm) |
|
1247 | fmp=numpy.dot(LT,fm) | |
1243 | chisq=numpy.dot((dp-fmp).T,(dp-fmp)) |
|
1248 | chisq=numpy.dot((dp-fmp).T,(dp-fmp)) | |
1244 | return chisq |
|
1249 | return chisq | |
1245 |
|
1250 | |||
1246 |
|
1251 | |||
1247 |
|
1252 | |||
1248 | class WindProfiler(Operation): |
|
1253 | class WindProfiler(Operation): | |
1249 |
|
1254 | |||
1250 | __isConfig = False |
|
1255 | __isConfig = False | |
1251 |
|
1256 | |||
1252 | __initime = None |
|
1257 | __initime = None | |
1253 | __lastdatatime = None |
|
1258 | __lastdatatime = None | |
1254 | __integrationtime = None |
|
1259 | __integrationtime = None | |
1255 |
|
1260 | |||
1256 | __buffer = None |
|
1261 | __buffer = None | |
1257 |
|
1262 | |||
1258 | __dataReady = False |
|
1263 | __dataReady = False | |
1259 |
|
1264 | |||
1260 | __firstdata = None |
|
1265 | __firstdata = None | |
1261 |
|
1266 | |||
1262 | n = None |
|
1267 | n = None | |
1263 |
|
1268 | |||
1264 | def __init__(self): |
|
1269 | def __init__(self): | |
1265 | Operation.__init__(self) |
|
1270 | Operation.__init__(self) | |
1266 |
|
1271 | |||
1267 | def __calculateCosDir(self, elev, azim): |
|
1272 | def __calculateCosDir(self, elev, azim): | |
1268 | zen = (90 - elev)*numpy.pi/180 |
|
1273 | zen = (90 - elev)*numpy.pi/180 | |
1269 | azim = azim*numpy.pi/180 |
|
1274 | azim = azim*numpy.pi/180 | |
1270 | cosDirX = numpy.sqrt((1-numpy.cos(zen)**2)/((1+numpy.tan(azim)**2))) |
|
1275 | cosDirX = numpy.sqrt((1-numpy.cos(zen)**2)/((1+numpy.tan(azim)**2))) | |
1271 | cosDirY = numpy.sqrt(1-numpy.cos(zen)**2-cosDirX**2) |
|
1276 | cosDirY = numpy.sqrt(1-numpy.cos(zen)**2-cosDirX**2) | |
1272 |
|
1277 | |||
1273 | signX = numpy.sign(numpy.cos(azim)) |
|
1278 | signX = numpy.sign(numpy.cos(azim)) | |
1274 | signY = numpy.sign(numpy.sin(azim)) |
|
1279 | signY = numpy.sign(numpy.sin(azim)) | |
1275 |
|
1280 | |||
1276 | cosDirX = numpy.copysign(cosDirX, signX) |
|
1281 | cosDirX = numpy.copysign(cosDirX, signX) | |
1277 | cosDirY = numpy.copysign(cosDirY, signY) |
|
1282 | cosDirY = numpy.copysign(cosDirY, signY) | |
1278 | return cosDirX, cosDirY |
|
1283 | return cosDirX, cosDirY | |
1279 |
|
1284 | |||
1280 | def __calculateAngles(self, theta_x, theta_y, azimuth): |
|
1285 | def __calculateAngles(self, theta_x, theta_y, azimuth): | |
1281 |
|
1286 | |||
1282 | dir_cosw = numpy.sqrt(1-theta_x**2-theta_y**2) |
|
1287 | dir_cosw = numpy.sqrt(1-theta_x**2-theta_y**2) | |
1283 | zenith_arr = numpy.arccos(dir_cosw) |
|
1288 | zenith_arr = numpy.arccos(dir_cosw) | |
1284 | azimuth_arr = numpy.arctan2(theta_x,theta_y) + azimuth*math.pi/180 |
|
1289 | azimuth_arr = numpy.arctan2(theta_x,theta_y) + azimuth*math.pi/180 | |
1285 |
|
1290 | |||
1286 | dir_cosu = numpy.sin(azimuth_arr)*numpy.sin(zenith_arr) |
|
1291 | dir_cosu = numpy.sin(azimuth_arr)*numpy.sin(zenith_arr) | |
1287 | dir_cosv = numpy.cos(azimuth_arr)*numpy.sin(zenith_arr) |
|
1292 | dir_cosv = numpy.cos(azimuth_arr)*numpy.sin(zenith_arr) | |
1288 |
|
1293 | |||
1289 | return azimuth_arr, zenith_arr, dir_cosu, dir_cosv, dir_cosw |
|
1294 | return azimuth_arr, zenith_arr, dir_cosu, dir_cosv, dir_cosw | |
1290 |
|
1295 | |||
1291 | def __calculateMatA(self, dir_cosu, dir_cosv, dir_cosw, horOnly): |
|
1296 | def __calculateMatA(self, dir_cosu, dir_cosv, dir_cosw, horOnly): | |
1292 |
|
1297 | |||
1293 | # |
|
1298 | # | |
1294 | if horOnly: |
|
1299 | if horOnly: | |
1295 | A = numpy.c_[dir_cosu,dir_cosv] |
|
1300 | A = numpy.c_[dir_cosu,dir_cosv] | |
1296 | else: |
|
1301 | else: | |
1297 | A = numpy.c_[dir_cosu,dir_cosv,dir_cosw] |
|
1302 | A = numpy.c_[dir_cosu,dir_cosv,dir_cosw] | |
1298 | A = numpy.asmatrix(A) |
|
1303 | A = numpy.asmatrix(A) | |
1299 | A1 = numpy.linalg.inv(A.transpose()*A)*A.transpose() |
|
1304 | A1 = numpy.linalg.inv(A.transpose()*A)*A.transpose() | |
1300 |
|
1305 | |||
1301 | return A1 |
|
1306 | return A1 | |
1302 |
|
1307 | |||
1303 | def __correctValues(self, heiRang, phi, velRadial, SNR): |
|
1308 | def __correctValues(self, heiRang, phi, velRadial, SNR): | |
1304 | listPhi = phi.tolist() |
|
1309 | listPhi = phi.tolist() | |
1305 | maxid = listPhi.index(max(listPhi)) |
|
1310 | maxid = listPhi.index(max(listPhi)) | |
1306 | minid = listPhi.index(min(listPhi)) |
|
1311 | minid = listPhi.index(min(listPhi)) | |
1307 |
|
1312 | |||
1308 | rango = range(len(phi)) |
|
1313 | rango = range(len(phi)) | |
1309 | # rango = numpy.delete(rango,maxid) |
|
1314 | # rango = numpy.delete(rango,maxid) | |
1310 |
|
1315 | |||
1311 | heiRang1 = heiRang*math.cos(phi[maxid]) |
|
1316 | heiRang1 = heiRang*math.cos(phi[maxid]) | |
1312 | heiRangAux = heiRang*math.cos(phi[minid]) |
|
1317 | heiRangAux = heiRang*math.cos(phi[minid]) | |
1313 | indOut = (heiRang1 < heiRangAux[0]).nonzero() |
|
1318 | indOut = (heiRang1 < heiRangAux[0]).nonzero() | |
1314 | heiRang1 = numpy.delete(heiRang1,indOut) |
|
1319 | heiRang1 = numpy.delete(heiRang1,indOut) | |
1315 |
|
1320 | |||
1316 | velRadial1 = numpy.zeros([len(phi),len(heiRang1)]) |
|
1321 | velRadial1 = numpy.zeros([len(phi),len(heiRang1)]) | |
1317 | SNR1 = numpy.zeros([len(phi),len(heiRang1)]) |
|
1322 | SNR1 = numpy.zeros([len(phi),len(heiRang1)]) | |
1318 |
|
1323 | |||
1319 | for i in rango: |
|
1324 | for i in rango: | |
1320 | x = heiRang*math.cos(phi[i]) |
|
1325 | x = heiRang*math.cos(phi[i]) | |
1321 | y1 = velRadial[i,:] |
|
1326 | y1 = velRadial[i,:] | |
1322 | f1 = interpolate.interp1d(x,y1,kind = 'cubic') |
|
1327 | f1 = interpolate.interp1d(x,y1,kind = 'cubic') | |
1323 |
|
1328 | |||
1324 | x1 = heiRang1 |
|
1329 | x1 = heiRang1 | |
1325 | y11 = f1(x1) |
|
1330 | y11 = f1(x1) | |
1326 |
|
1331 | |||
1327 | y2 = SNR[i,:] |
|
1332 | y2 = SNR[i,:] | |
1328 | f2 = interpolate.interp1d(x,y2,kind = 'cubic') |
|
1333 | f2 = interpolate.interp1d(x,y2,kind = 'cubic') | |
1329 | y21 = f2(x1) |
|
1334 | y21 = f2(x1) | |
1330 |
|
1335 | |||
1331 | velRadial1[i,:] = y11 |
|
1336 | velRadial1[i,:] = y11 | |
1332 | SNR1[i,:] = y21 |
|
1337 | SNR1[i,:] = y21 | |
1333 |
|
1338 | |||
1334 | return heiRang1, velRadial1, SNR1 |
|
1339 | return heiRang1, velRadial1, SNR1 | |
1335 |
|
1340 | |||
1336 | def __calculateVelUVW(self, A, velRadial): |
|
1341 | def __calculateVelUVW(self, A, velRadial): | |
1337 |
|
1342 | |||
1338 | #Operacion Matricial |
|
1343 | #Operacion Matricial | |
1339 | # velUVW = numpy.zeros((velRadial.shape[1],3)) |
|
1344 | # velUVW = numpy.zeros((velRadial.shape[1],3)) | |
1340 | # for ind in range(velRadial.shape[1]): |
|
1345 | # for ind in range(velRadial.shape[1]): | |
1341 | # velUVW[ind,:] = numpy.dot(A,velRadial[:,ind]) |
|
1346 | # velUVW[ind,:] = numpy.dot(A,velRadial[:,ind]) | |
1342 | # velUVW = velUVW.transpose() |
|
1347 | # velUVW = velUVW.transpose() | |
1343 | velUVW = numpy.zeros((A.shape[0],velRadial.shape[1])) |
|
1348 | velUVW = numpy.zeros((A.shape[0],velRadial.shape[1])) | |
1344 | velUVW[:,:] = numpy.dot(A,velRadial) |
|
1349 | velUVW[:,:] = numpy.dot(A,velRadial) | |
1345 |
|
1350 | |||
1346 |
|
1351 | |||
1347 | return velUVW |
|
1352 | return velUVW | |
1348 |
|
1353 | |||
1349 | def techniqueDBS(self, velRadial0, dirCosx, disrCosy, azimuth, correct, horizontalOnly, heiRang, SNR0): |
|
1354 | def techniqueDBS(self, velRadial0, dirCosx, disrCosy, azimuth, correct, horizontalOnly, heiRang, SNR0): | |
1350 | """ |
|
1355 | """ | |
1351 | Function that implements Doppler Beam Swinging (DBS) technique. |
|
1356 | Function that implements Doppler Beam Swinging (DBS) technique. | |
1352 |
|
1357 | |||
1353 | Input: Radial velocities, Direction cosines (x and y) of the Beam, Antenna azimuth, |
|
1358 | Input: Radial velocities, Direction cosines (x and y) of the Beam, Antenna azimuth, | |
1354 | Direction correction (if necessary), Ranges and SNR |
|
1359 | Direction correction (if necessary), Ranges and SNR | |
1355 |
|
1360 | |||
1356 | Output: Winds estimation (Zonal, Meridional and Vertical) |
|
1361 | Output: Winds estimation (Zonal, Meridional and Vertical) | |
1357 |
|
1362 | |||
1358 | Parameters affected: Winds, height range, SNR |
|
1363 | Parameters affected: Winds, height range, SNR | |
1359 | """ |
|
1364 | """ | |
1360 | azimuth_arr, zenith_arr, dir_cosu, dir_cosv, dir_cosw = self.__calculateAngles(dirCosx, disrCosy, azimuth) |
|
1365 | azimuth_arr, zenith_arr, dir_cosu, dir_cosv, dir_cosw = self.__calculateAngles(dirCosx, disrCosy, azimuth) | |
1361 | heiRang1, velRadial1, SNR1 = self.__correctValues(heiRang, zenith_arr, correct*velRadial0, SNR0) |
|
1366 | heiRang1, velRadial1, SNR1 = self.__correctValues(heiRang, zenith_arr, correct*velRadial0, SNR0) | |
1362 | A = self.__calculateMatA(dir_cosu, dir_cosv, dir_cosw, horizontalOnly) |
|
1367 | A = self.__calculateMatA(dir_cosu, dir_cosv, dir_cosw, horizontalOnly) | |
1363 |
|
1368 | |||
1364 | #Calculo de Componentes de la velocidad con DBS |
|
1369 | #Calculo de Componentes de la velocidad con DBS | |
1365 | winds = self.__calculateVelUVW(A,velRadial1) |
|
1370 | winds = self.__calculateVelUVW(A,velRadial1) | |
1366 |
|
1371 | |||
1367 | return winds, heiRang1, SNR1 |
|
1372 | return winds, heiRang1, SNR1 | |
1368 |
|
1373 | |||
1369 | def __calculateDistance(self, posx, posy, pairsCrossCorr, pairsList, pairs, azimuth = None): |
|
1374 | def __calculateDistance(self, posx, posy, pairsCrossCorr, pairsList, pairs, azimuth = None): | |
1370 |
|
1375 | |||
1371 | posx = numpy.asarray(posx) |
|
1376 | posx = numpy.asarray(posx) | |
1372 | posy = numpy.asarray(posy) |
|
1377 | posy = numpy.asarray(posy) | |
1373 |
|
1378 | |||
1374 | #Rotacion Inversa para alinear con el azimuth |
|
1379 | #Rotacion Inversa para alinear con el azimuth | |
1375 | if azimuth!= None: |
|
1380 | if azimuth!= None: | |
1376 | azimuth = azimuth*math.pi/180 |
|
1381 | azimuth = azimuth*math.pi/180 | |
1377 | posx1 = posx*math.cos(azimuth) + posy*math.sin(azimuth) |
|
1382 | posx1 = posx*math.cos(azimuth) + posy*math.sin(azimuth) | |
1378 | posy1 = -posx*math.sin(azimuth) + posy*math.cos(azimuth) |
|
1383 | posy1 = -posx*math.sin(azimuth) + posy*math.cos(azimuth) | |
1379 | else: |
|
1384 | else: | |
1380 | posx1 = posx |
|
1385 | posx1 = posx | |
1381 | posy1 = posy |
|
1386 | posy1 = posy | |
1382 |
|
1387 | |||
1383 | #Calculo de Distancias |
|
1388 | #Calculo de Distancias | |
1384 | distx = numpy.zeros(pairsCrossCorr.size) |
|
1389 | distx = numpy.zeros(pairsCrossCorr.size) | |
1385 | disty = numpy.zeros(pairsCrossCorr.size) |
|
1390 | disty = numpy.zeros(pairsCrossCorr.size) | |
1386 | dist = numpy.zeros(pairsCrossCorr.size) |
|
1391 | dist = numpy.zeros(pairsCrossCorr.size) | |
1387 | ang = numpy.zeros(pairsCrossCorr.size) |
|
1392 | ang = numpy.zeros(pairsCrossCorr.size) | |
1388 |
|
1393 | |||
1389 | for i in range(pairsCrossCorr.size): |
|
1394 | for i in range(pairsCrossCorr.size): | |
1390 | distx[i] = posx1[pairsList[pairsCrossCorr[i]][1]] - posx1[pairsList[pairsCrossCorr[i]][0]] |
|
1395 | distx[i] = posx1[pairsList[pairsCrossCorr[i]][1]] - posx1[pairsList[pairsCrossCorr[i]][0]] | |
1391 | disty[i] = posy1[pairsList[pairsCrossCorr[i]][1]] - posy1[pairsList[pairsCrossCorr[i]][0]] |
|
1396 | disty[i] = posy1[pairsList[pairsCrossCorr[i]][1]] - posy1[pairsList[pairsCrossCorr[i]][0]] | |
1392 | dist[i] = numpy.sqrt(distx[i]**2 + disty[i]**2) |
|
1397 | dist[i] = numpy.sqrt(distx[i]**2 + disty[i]**2) | |
1393 | ang[i] = numpy.arctan2(disty[i],distx[i]) |
|
1398 | ang[i] = numpy.arctan2(disty[i],distx[i]) | |
1394 | #Calculo de Matrices |
|
1399 | #Calculo de Matrices | |
1395 | nPairs = len(pairs) |
|
1400 | nPairs = len(pairs) | |
1396 | ang1 = numpy.zeros((nPairs, 2, 1)) |
|
1401 | ang1 = numpy.zeros((nPairs, 2, 1)) | |
1397 | dist1 = numpy.zeros((nPairs, 2, 1)) |
|
1402 | dist1 = numpy.zeros((nPairs, 2, 1)) | |
1398 |
|
1403 | |||
1399 | for j in range(nPairs): |
|
1404 | for j in range(nPairs): | |
1400 | dist1[j,0,0] = dist[pairs[j][0]] |
|
1405 | dist1[j,0,0] = dist[pairs[j][0]] | |
1401 | dist1[j,1,0] = dist[pairs[j][1]] |
|
1406 | dist1[j,1,0] = dist[pairs[j][1]] | |
1402 | ang1[j,0,0] = ang[pairs[j][0]] |
|
1407 | ang1[j,0,0] = ang[pairs[j][0]] | |
1403 | ang1[j,1,0] = ang[pairs[j][1]] |
|
1408 | ang1[j,1,0] = ang[pairs[j][1]] | |
1404 |
|
1409 | |||
1405 | return distx,disty, dist1,ang1 |
|
1410 | return distx,disty, dist1,ang1 | |
1406 |
|
1411 | |||
1407 | def __calculateVelVer(self, phase, lagTRange, _lambda): |
|
1412 | def __calculateVelVer(self, phase, lagTRange, _lambda): | |
1408 |
|
1413 | |||
1409 | Ts = lagTRange[1] - lagTRange[0] |
|
1414 | Ts = lagTRange[1] - lagTRange[0] | |
1410 | velW = -_lambda*phase/(4*math.pi*Ts) |
|
1415 | velW = -_lambda*phase/(4*math.pi*Ts) | |
1411 |
|
1416 | |||
1412 | return velW |
|
1417 | return velW | |
1413 |
|
1418 | |||
1414 | def __calculateVelHorDir(self, dist, tau1, tau2, ang): |
|
1419 | def __calculateVelHorDir(self, dist, tau1, tau2, ang): | |
1415 | nPairs = tau1.shape[0] |
|
1420 | nPairs = tau1.shape[0] | |
1416 | vel = numpy.zeros((nPairs,3,tau1.shape[2])) |
|
1421 | vel = numpy.zeros((nPairs,3,tau1.shape[2])) | |
1417 |
|
1422 | |||
1418 | angCos = numpy.cos(ang) |
|
1423 | angCos = numpy.cos(ang) | |
1419 | angSin = numpy.sin(ang) |
|
1424 | angSin = numpy.sin(ang) | |
1420 |
|
1425 | |||
1421 | vel0 = dist*tau1/(2*tau2**2) |
|
1426 | vel0 = dist*tau1/(2*tau2**2) | |
1422 | vel[:,0,:] = (vel0*angCos).sum(axis = 1) |
|
1427 | vel[:,0,:] = (vel0*angCos).sum(axis = 1) | |
1423 | vel[:,1,:] = (vel0*angSin).sum(axis = 1) |
|
1428 | vel[:,1,:] = (vel0*angSin).sum(axis = 1) | |
1424 |
|
1429 | |||
1425 | ind = numpy.where(numpy.isinf(vel)) |
|
1430 | ind = numpy.where(numpy.isinf(vel)) | |
1426 | vel[ind] = numpy.nan |
|
1431 | vel[ind] = numpy.nan | |
1427 |
|
1432 | |||
1428 | return vel |
|
1433 | return vel | |
1429 |
|
1434 | |||
1430 | def __getPairsAutoCorr(self, pairsList, nChannels): |
|
1435 | def __getPairsAutoCorr(self, pairsList, nChannels): | |
1431 |
|
1436 | |||
1432 | pairsAutoCorr = numpy.zeros(nChannels, dtype = 'int')*numpy.nan |
|
1437 | pairsAutoCorr = numpy.zeros(nChannels, dtype = 'int')*numpy.nan | |
1433 |
|
1438 | |||
1434 | for l in range(len(pairsList)): |
|
1439 | for l in range(len(pairsList)): | |
1435 | firstChannel = pairsList[l][0] |
|
1440 | firstChannel = pairsList[l][0] | |
1436 | secondChannel = pairsList[l][1] |
|
1441 | secondChannel = pairsList[l][1] | |
1437 |
|
1442 | |||
1438 | #Obteniendo pares de Autocorrelacion |
|
1443 | #Obteniendo pares de Autocorrelacion | |
1439 | if firstChannel == secondChannel: |
|
1444 | if firstChannel == secondChannel: | |
1440 | pairsAutoCorr[firstChannel] = int(l) |
|
1445 | pairsAutoCorr[firstChannel] = int(l) | |
1441 |
|
1446 | |||
1442 | pairsAutoCorr = pairsAutoCorr.astype(int) |
|
1447 | pairsAutoCorr = pairsAutoCorr.astype(int) | |
1443 |
|
1448 | |||
1444 | pairsCrossCorr = range(len(pairsList)) |
|
1449 | pairsCrossCorr = range(len(pairsList)) | |
1445 | pairsCrossCorr = numpy.delete(pairsCrossCorr,pairsAutoCorr) |
|
1450 | pairsCrossCorr = numpy.delete(pairsCrossCorr,pairsAutoCorr) | |
1446 |
|
1451 | |||
1447 | return pairsAutoCorr, pairsCrossCorr |
|
1452 | return pairsAutoCorr, pairsCrossCorr | |
1448 |
|
1453 | |||
1449 | def techniqueSA(self, pairsSelected, pairsList, nChannels, tau, azimuth, _lambda, position_x, position_y, lagTRange, correctFactor): |
|
1454 | def techniqueSA(self, pairsSelected, pairsList, nChannels, tau, azimuth, _lambda, position_x, position_y, lagTRange, correctFactor): | |
1450 | """ |
|
1455 | """ | |
1451 | Function that implements Spaced Antenna (SA) technique. |
|
1456 | Function that implements Spaced Antenna (SA) technique. | |
1452 |
|
1457 | |||
1453 | Input: Radial velocities, Direction cosines (x and y) of the Beam, Antenna azimuth, |
|
1458 | Input: Radial velocities, Direction cosines (x and y) of the Beam, Antenna azimuth, | |
1454 | Direction correction (if necessary), Ranges and SNR |
|
1459 | Direction correction (if necessary), Ranges and SNR | |
1455 |
|
1460 | |||
1456 | Output: Winds estimation (Zonal, Meridional and Vertical) |
|
1461 | Output: Winds estimation (Zonal, Meridional and Vertical) | |
1457 |
|
1462 | |||
1458 | Parameters affected: Winds |
|
1463 | Parameters affected: Winds | |
1459 | """ |
|
1464 | """ | |
1460 | #Cross Correlation pairs obtained |
|
1465 | #Cross Correlation pairs obtained | |
1461 | pairsAutoCorr, pairsCrossCorr = self.__getPairsAutoCorr(pairsList, nChannels) |
|
1466 | pairsAutoCorr, pairsCrossCorr = self.__getPairsAutoCorr(pairsList, nChannels) | |
1462 | pairsArray = numpy.array(pairsList)[pairsCrossCorr] |
|
1467 | pairsArray = numpy.array(pairsList)[pairsCrossCorr] | |
1463 | pairsSelArray = numpy.array(pairsSelected) |
|
1468 | pairsSelArray = numpy.array(pairsSelected) | |
1464 | pairs = [] |
|
1469 | pairs = [] | |
1465 |
|
1470 | |||
1466 | #Wind estimation pairs obtained |
|
1471 | #Wind estimation pairs obtained | |
1467 | for i in range(pairsSelArray.shape[0]/2): |
|
1472 | for i in range(pairsSelArray.shape[0]/2): | |
1468 | ind1 = numpy.where(numpy.all(pairsArray == pairsSelArray[2*i], axis = 1))[0][0] |
|
1473 | ind1 = numpy.where(numpy.all(pairsArray == pairsSelArray[2*i], axis = 1))[0][0] | |
1469 | ind2 = numpy.where(numpy.all(pairsArray == pairsSelArray[2*i + 1], axis = 1))[0][0] |
|
1474 | ind2 = numpy.where(numpy.all(pairsArray == pairsSelArray[2*i + 1], axis = 1))[0][0] | |
1470 | pairs.append((ind1,ind2)) |
|
1475 | pairs.append((ind1,ind2)) | |
1471 |
|
1476 | |||
1472 | indtau = tau.shape[0]/2 |
|
1477 | indtau = tau.shape[0]/2 | |
1473 | tau1 = tau[:indtau,:] |
|
1478 | tau1 = tau[:indtau,:] | |
1474 | tau2 = tau[indtau:-1,:] |
|
1479 | tau2 = tau[indtau:-1,:] | |
1475 | tau1 = tau1[pairs,:] |
|
1480 | tau1 = tau1[pairs,:] | |
1476 | tau2 = tau2[pairs,:] |
|
1481 | tau2 = tau2[pairs,:] | |
1477 | phase1 = tau[-1,:] |
|
1482 | phase1 = tau[-1,:] | |
1478 |
|
1483 | |||
1479 | #--------------------------------------------------------------------- |
|
1484 | #--------------------------------------------------------------------- | |
1480 | #Metodo Directo |
|
1485 | #Metodo Directo | |
1481 | distx, disty, dist, ang = self.__calculateDistance(position_x, position_y, pairsCrossCorr, pairsList, pairs,azimuth) |
|
1486 | distx, disty, dist, ang = self.__calculateDistance(position_x, position_y, pairsCrossCorr, pairsList, pairs,azimuth) | |
1482 | winds = self.__calculateVelHorDir(dist, tau1, tau2, ang) |
|
1487 | winds = self.__calculateVelHorDir(dist, tau1, tau2, ang) | |
1483 | winds = stats.nanmean(winds, axis=0) |
|
1488 | winds = stats.nanmean(winds, axis=0) | |
1484 | #--------------------------------------------------------------------- |
|
1489 | #--------------------------------------------------------------------- | |
1485 | #Metodo General |
|
1490 | #Metodo General | |
1486 | # distx, disty, dist = self.calculateDistance(position_x,position_y,pairsCrossCorr, pairsList, azimuth) |
|
1491 | # distx, disty, dist = self.calculateDistance(position_x,position_y,pairsCrossCorr, pairsList, azimuth) | |
1487 | # #Calculo Coeficientes de Funcion de Correlacion |
|
1492 | # #Calculo Coeficientes de Funcion de Correlacion | |
1488 | # F,G,A,B,H = self.calculateCoef(tau1,tau2,distx,disty,n) |
|
1493 | # F,G,A,B,H = self.calculateCoef(tau1,tau2,distx,disty,n) | |
1489 | # #Calculo de Velocidades |
|
1494 | # #Calculo de Velocidades | |
1490 | # winds = self.calculateVelUV(F,G,A,B,H) |
|
1495 | # winds = self.calculateVelUV(F,G,A,B,H) | |
1491 |
|
1496 | |||
1492 | #--------------------------------------------------------------------- |
|
1497 | #--------------------------------------------------------------------- | |
1493 | winds[2,:] = self.__calculateVelVer(phase1, lagTRange, _lambda) |
|
1498 | winds[2,:] = self.__calculateVelVer(phase1, lagTRange, _lambda) | |
1494 | winds = correctFactor*winds |
|
1499 | winds = correctFactor*winds | |
1495 | return winds |
|
1500 | return winds | |
1496 |
|
1501 | |||
1497 | def __checkTime(self, currentTime, paramInterval, outputInterval): |
|
1502 | def __checkTime(self, currentTime, paramInterval, outputInterval): | |
1498 |
|
1503 | |||
1499 | dataTime = currentTime + paramInterval |
|
1504 | dataTime = currentTime + paramInterval | |
1500 | deltaTime = dataTime - self.__initime |
|
1505 | deltaTime = dataTime - self.__initime | |
1501 |
|
1506 | |||
1502 | if deltaTime >= outputInterval or deltaTime < 0: |
|
1507 | if deltaTime >= outputInterval or deltaTime < 0: | |
1503 | self.__dataReady = True |
|
1508 | self.__dataReady = True | |
1504 | return |
|
1509 | return | |
1505 |
|
1510 | |||
1506 | def techniqueMeteors(self, arrayMeteor, meteorThresh, heightMin, heightMax): |
|
1511 | def techniqueMeteors(self, arrayMeteor, meteorThresh, heightMin, heightMax): | |
1507 | ''' |
|
1512 | ''' | |
1508 | Function that implements winds estimation technique with detected meteors. |
|
1513 | Function that implements winds estimation technique with detected meteors. | |
1509 |
|
1514 | |||
1510 | Input: Detected meteors, Minimum meteor quantity to wind estimation |
|
1515 | Input: Detected meteors, Minimum meteor quantity to wind estimation | |
1511 |
|
1516 | |||
1512 | Output: Winds estimation (Zonal and Meridional) |
|
1517 | Output: Winds estimation (Zonal and Meridional) | |
1513 |
|
1518 | |||
1514 | Parameters affected: Winds |
|
1519 | Parameters affected: Winds | |
1515 | ''' |
|
1520 | ''' | |
1516 | #Settings |
|
1521 | #Settings | |
1517 | nInt = (heightMax - heightMin)/2 |
|
1522 | nInt = (heightMax - heightMin)/2 | |
1518 | winds = numpy.zeros((2,nInt))*numpy.nan |
|
1523 | winds = numpy.zeros((2,nInt))*numpy.nan | |
1519 |
|
1524 | |||
1520 | #Filter errors |
|
1525 | #Filter errors | |
1521 | error = numpy.where(arrayMeteor[:,-1] == 0)[0] |
|
1526 | error = numpy.where(arrayMeteor[:,-1] == 0)[0] | |
1522 | finalMeteor = arrayMeteor[error,:] |
|
1527 | finalMeteor = arrayMeteor[error,:] | |
1523 |
|
1528 | |||
1524 | #Meteor Histogram |
|
1529 | #Meteor Histogram | |
1525 | finalHeights = finalMeteor[:,3] |
|
1530 | finalHeights = finalMeteor[:,3] | |
1526 | hist = numpy.histogram(finalHeights, bins = nInt, range = (heightMin,heightMax)) |
|
1531 | hist = numpy.histogram(finalHeights, bins = nInt, range = (heightMin,heightMax)) | |
1527 | nMeteorsPerI = hist[0] |
|
1532 | nMeteorsPerI = hist[0] | |
1528 | heightPerI = hist[1] |
|
1533 | heightPerI = hist[1] | |
1529 |
|
1534 | |||
1530 | #Sort of meteors |
|
1535 | #Sort of meteors | |
1531 | indSort = finalHeights.argsort() |
|
1536 | indSort = finalHeights.argsort() | |
1532 | finalMeteor2 = finalMeteor[indSort,:] |
|
1537 | finalMeteor2 = finalMeteor[indSort,:] | |
1533 |
|
1538 | |||
1534 | # Calculating winds |
|
1539 | # Calculating winds | |
1535 | ind1 = 0 |
|
1540 | ind1 = 0 | |
1536 | ind2 = 0 |
|
1541 | ind2 = 0 | |
1537 |
|
1542 | |||
1538 | for i in range(nInt): |
|
1543 | for i in range(nInt): | |
1539 | nMet = nMeteorsPerI[i] |
|
1544 | nMet = nMeteorsPerI[i] | |
1540 | ind1 = ind2 |
|
1545 | ind1 = ind2 | |
1541 | ind2 = ind1 + nMet |
|
1546 | ind2 = ind1 + nMet | |
1542 |
|
1547 | |||
1543 | meteorAux = finalMeteor2[ind1:ind2,:] |
|
1548 | meteorAux = finalMeteor2[ind1:ind2,:] | |
1544 |
|
1549 | |||
1545 | if meteorAux.shape[0] >= meteorThresh: |
|
1550 | if meteorAux.shape[0] >= meteorThresh: | |
1546 | vel = meteorAux[:, 7] |
|
1551 | vel = meteorAux[:, 7] | |
1547 | zen = meteorAux[:, 5]*numpy.pi/180 |
|
1552 | zen = meteorAux[:, 5]*numpy.pi/180 | |
1548 | azim = meteorAux[:, 4]*numpy.pi/180 |
|
1553 | azim = meteorAux[:, 4]*numpy.pi/180 | |
1549 |
|
1554 | |||
1550 | n = numpy.cos(zen) |
|
1555 | n = numpy.cos(zen) | |
1551 | # m = (1 - n**2)/(1 - numpy.tan(azim)**2) |
|
1556 | # m = (1 - n**2)/(1 - numpy.tan(azim)**2) | |
1552 | # l = m*numpy.tan(azim) |
|
1557 | # l = m*numpy.tan(azim) | |
1553 | l = numpy.sin(zen)*numpy.sin(azim) |
|
1558 | l = numpy.sin(zen)*numpy.sin(azim) | |
1554 | m = numpy.sin(zen)*numpy.cos(azim) |
|
1559 | m = numpy.sin(zen)*numpy.cos(azim) | |
1555 |
|
1560 | |||
1556 | A = numpy.vstack((l, m)).transpose() |
|
1561 | A = numpy.vstack((l, m)).transpose() | |
1557 | A1 = numpy.dot(numpy.linalg.inv( numpy.dot(A.transpose(),A) ),A.transpose()) |
|
1562 | A1 = numpy.dot(numpy.linalg.inv( numpy.dot(A.transpose(),A) ),A.transpose()) | |
1558 | windsAux = numpy.dot(A1, vel) |
|
1563 | windsAux = numpy.dot(A1, vel) | |
1559 |
|
1564 | |||
1560 | winds[0,i] = windsAux[0] |
|
1565 | winds[0,i] = windsAux[0] | |
1561 | winds[1,i] = windsAux[1] |
|
1566 | winds[1,i] = windsAux[1] | |
1562 |
|
1567 | |||
1563 | return winds, heightPerI[:-1] |
|
1568 | return winds, heightPerI[:-1] | |
1564 |
|
1569 | |||
1565 | def run(self, dataOut, technique, **kwargs): |
|
1570 | def run(self, dataOut, technique, **kwargs): | |
1566 |
|
1571 | |||
1567 | param = dataOut.data_param |
|
1572 | param = dataOut.data_param | |
1568 | if dataOut.abscissaRange != None: |
|
1573 | if dataOut.abscissaRange != None: | |
1569 | absc = dataOut.abscissaRange[:-1] |
|
1574 | absc = dataOut.abscissaRange[:-1] | |
1570 | noise = dataOut.noise |
|
1575 | noise = dataOut.noise | |
1571 | heightRange = dataOut.getHeiRange() |
|
1576 | heightRange = dataOut.getHeiRange() | |
1572 | SNR = dataOut.SNR |
|
1577 | SNR = dataOut.data_SNR | |
1573 |
|
1578 | |||
1574 | if technique == 'DBS': |
|
1579 | if technique == 'DBS': | |
1575 |
|
1580 | |||
1576 | if kwargs.has_key('dirCosx') and kwargs.has_key('dirCosy'): |
|
1581 | if kwargs.has_key('dirCosx') and kwargs.has_key('dirCosy'): | |
1577 | theta_x = numpy.array(kwargs['dirCosx']) |
|
1582 | theta_x = numpy.array(kwargs['dirCosx']) | |
1578 | theta_y = numpy.array(kwargs['dirCosy']) |
|
1583 | theta_y = numpy.array(kwargs['dirCosy']) | |
1579 | else: |
|
1584 | else: | |
1580 | elev = numpy.array(kwargs['elevation']) |
|
1585 | elev = numpy.array(kwargs['elevation']) | |
1581 | azim = numpy.array(kwargs['azimuth']) |
|
1586 | azim = numpy.array(kwargs['azimuth']) | |
1582 | theta_x, theta_y = self.__calculateCosDir(elev, azim) |
|
1587 | theta_x, theta_y = self.__calculateCosDir(elev, azim) | |
1583 | azimuth = kwargs['correctAzimuth'] |
|
1588 | azimuth = kwargs['correctAzimuth'] | |
1584 | if kwargs.has_key('horizontalOnly'): |
|
1589 | if kwargs.has_key('horizontalOnly'): | |
1585 | horizontalOnly = kwargs['horizontalOnly'] |
|
1590 | horizontalOnly = kwargs['horizontalOnly'] | |
1586 | else: horizontalOnly = False |
|
1591 | else: horizontalOnly = False | |
1587 | if kwargs.has_key('correctFactor'): |
|
1592 | if kwargs.has_key('correctFactor'): | |
1588 | correctFactor = kwargs['correctFactor'] |
|
1593 | correctFactor = kwargs['correctFactor'] | |
1589 | else: correctFactor = 1 |
|
1594 | else: correctFactor = 1 | |
1590 | if kwargs.has_key('channelList'): |
|
1595 | if kwargs.has_key('channelList'): | |
1591 | channelList = kwargs['channelList'] |
|
1596 | channelList = kwargs['channelList'] | |
1592 | if len(channelList) == 2: |
|
1597 | if len(channelList) == 2: | |
1593 | horizontalOnly = True |
|
1598 | horizontalOnly = True | |
1594 | arrayChannel = numpy.array(channelList) |
|
1599 | arrayChannel = numpy.array(channelList) | |
1595 | param = param[arrayChannel,:,:] |
|
1600 | param = param[arrayChannel,:,:] | |
1596 | theta_x = theta_x[arrayChannel] |
|
1601 | theta_x = theta_x[arrayChannel] | |
1597 | theta_y = theta_y[arrayChannel] |
|
1602 | theta_y = theta_y[arrayChannel] | |
1598 |
|
1603 | |||
1599 | velRadial0 = param[:,1,:] #Radial velocity |
|
1604 | velRadial0 = param[:,1,:] #Radial velocity | |
1600 | dataOut.data_output, dataOut.heightRange, dataOut.SNR = self.techniqueDBS(velRadial0, theta_x, theta_y, azimuth, correctFactor, horizontalOnly, heightRange, SNR) #DBS Function |
|
1605 | dataOut.data_output, dataOut.heightRange, dataOut.data_SNR = self.techniqueDBS(velRadial0, theta_x, theta_y, azimuth, correctFactor, horizontalOnly, heightRange, SNR) #DBS Function | |
1601 |
|
1606 | |||
1602 | elif technique == 'SA': |
|
1607 | elif technique == 'SA': | |
1603 |
|
1608 | |||
1604 | #Parameters |
|
1609 | #Parameters | |
1605 | position_x = kwargs['positionX'] |
|
1610 | position_x = kwargs['positionX'] | |
1606 | position_y = kwargs['positionY'] |
|
1611 | position_y = kwargs['positionY'] | |
1607 | azimuth = kwargs['azimuth'] |
|
1612 | azimuth = kwargs['azimuth'] | |
1608 |
|
1613 | |||
1609 | if kwargs.has_key('crosspairsList'): |
|
1614 | if kwargs.has_key('crosspairsList'): | |
1610 | pairs = kwargs['crosspairsList'] |
|
1615 | pairs = kwargs['crosspairsList'] | |
1611 | else: |
|
1616 | else: | |
1612 | pairs = None |
|
1617 | pairs = None | |
1613 |
|
1618 | |||
1614 | if kwargs.has_key('correctFactor'): |
|
1619 | if kwargs.has_key('correctFactor'): | |
1615 | correctFactor = kwargs['correctFactor'] |
|
1620 | correctFactor = kwargs['correctFactor'] | |
1616 | else: |
|
1621 | else: | |
1617 | correctFactor = 1 |
|
1622 | correctFactor = 1 | |
1618 |
|
1623 | |||
1619 | tau = dataOut.data_param |
|
1624 | tau = dataOut.data_param | |
1620 | _lambda = dataOut.C/dataOut.frequency |
|
1625 | _lambda = dataOut.C/dataOut.frequency | |
1621 | pairsList = dataOut.groupList |
|
1626 | pairsList = dataOut.groupList | |
1622 | nChannels = dataOut.nChannels |
|
1627 | nChannels = dataOut.nChannels | |
1623 |
|
1628 | |||
1624 | dataOut.data_output = self.techniqueSA(pairs, pairsList, nChannels, tau, azimuth, _lambda, position_x, position_y, absc, correctFactor) |
|
1629 | dataOut.data_output = self.techniqueSA(pairs, pairsList, nChannels, tau, azimuth, _lambda, position_x, position_y, absc, correctFactor) | |
1625 | dataOut.initUtcTime = dataOut.ltctime |
|
1630 | dataOut.initUtcTime = dataOut.ltctime | |
1626 | dataOut.outputInterval = dataOut.timeInterval |
|
1631 | dataOut.outputInterval = dataOut.timeInterval | |
1627 |
|
1632 | |||
1628 | elif technique == 'Meteors': |
|
1633 | elif technique == 'Meteors': | |
1629 | dataOut.flagNoData = True |
|
1634 | dataOut.flagNoData = True | |
1630 | self.__dataReady = False |
|
1635 | self.__dataReady = False | |
1631 |
|
1636 | |||
1632 | if kwargs.has_key('nHours'): |
|
1637 | if kwargs.has_key('nHours'): | |
1633 | nHours = kwargs['nHours'] |
|
1638 | nHours = kwargs['nHours'] | |
1634 | else: |
|
1639 | else: | |
1635 | nHours = 1 |
|
1640 | nHours = 1 | |
1636 |
|
1641 | |||
1637 | if kwargs.has_key('meteorsPerBin'): |
|
1642 | if kwargs.has_key('meteorsPerBin'): | |
1638 | meteorThresh = kwargs['meteorsPerBin'] |
|
1643 | meteorThresh = kwargs['meteorsPerBin'] | |
1639 | else: |
|
1644 | else: | |
1640 | meteorThresh = 6 |
|
1645 | meteorThresh = 6 | |
1641 |
|
1646 | |||
1642 | if kwargs.has_key('hmin'): |
|
1647 | if kwargs.has_key('hmin'): | |
1643 | hmin = kwargs['hmin'] |
|
1648 | hmin = kwargs['hmin'] | |
1644 | else: hmin = 70 |
|
1649 | else: hmin = 70 | |
1645 | if kwargs.has_key('hmax'): |
|
1650 | if kwargs.has_key('hmax'): | |
1646 | hmax = kwargs['hmax'] |
|
1651 | hmax = kwargs['hmax'] | |
1647 | else: hmax = 110 |
|
1652 | else: hmax = 110 | |
1648 |
|
1653 | |||
1649 | dataOut.outputInterval = nHours*3600 |
|
1654 | dataOut.outputInterval = nHours*3600 | |
1650 |
|
1655 | |||
1651 | if self.__isConfig == False: |
|
1656 | if self.__isConfig == False: | |
1652 | # self.__initime = dataOut.datatime.replace(minute = 0, second = 0, microsecond = 03) |
|
1657 | # self.__initime = dataOut.datatime.replace(minute = 0, second = 0, microsecond = 03) | |
1653 | #Get Initial LTC time |
|
1658 | #Get Initial LTC time | |
1654 | self.__initime = (dataOut.datatime.replace(minute = 0, second = 0, microsecond = 0) - datetime.datetime(1970, 1, 1)).total_seconds() |
|
1659 | self.__initime = (dataOut.datatime.replace(minute = 0, second = 0, microsecond = 0) - datetime.datetime(1970, 1, 1)).total_seconds() | |
1655 | self.__isConfig = True |
|
1660 | self.__isConfig = True | |
1656 |
|
1661 | |||
1657 | if self.__buffer == None: |
|
1662 | if self.__buffer == None: | |
1658 | self.__buffer = dataOut.data_param |
|
1663 | self.__buffer = dataOut.data_param | |
1659 | self.__firstdata = copy.copy(dataOut) |
|
1664 | self.__firstdata = copy.copy(dataOut) | |
1660 |
|
1665 | |||
1661 | else: |
|
1666 | else: | |
1662 | self.__buffer = numpy.vstack((self.__buffer, dataOut.data_param)) |
|
1667 | self.__buffer = numpy.vstack((self.__buffer, dataOut.data_param)) | |
1663 |
|
1668 | |||
1664 | self.__checkTime(dataOut.ltctime, dataOut.paramInterval, dataOut.outputInterval) #Check if the buffer is ready |
|
1669 | self.__checkTime(dataOut.ltctime, dataOut.paramInterval, dataOut.outputInterval) #Check if the buffer is ready | |
1665 |
|
1670 | |||
1666 | if self.__dataReady: |
|
1671 | if self.__dataReady: | |
1667 | dataOut.initUtcTime = self.__initime |
|
1672 | dataOut.initUtcTime = self.__initime | |
1668 | self.__initime = self.__initime + dataOut.outputInterval #to erase time offset |
|
1673 | self.__initime = self.__initime + dataOut.outputInterval #to erase time offset | |
1669 |
|
1674 | |||
1670 | dataOut.data_output, dataOut.heightRange = self.techniqueMeteors(self.__buffer, meteorThresh, hmin, hmax) |
|
1675 | dataOut.data_output, dataOut.heightRange = self.techniqueMeteors(self.__buffer, meteorThresh, hmin, hmax) | |
1671 | dataOut.flagNoData = False |
|
1676 | dataOut.flagNoData = False | |
1672 | self.__buffer = None |
|
1677 | self.__buffer = None | |
1673 |
|
1678 | |||
1674 | return |
|
1679 | return | |
1675 |
|
1680 | |||
1676 | class EWDriftsEstimation(Operation): |
|
1681 | class EWDriftsEstimation(Operation): | |
1677 |
|
1682 | |||
1678 |
|
1683 | |||
1679 | def __init__(self): |
|
1684 | def __init__(self): | |
1680 | Operation.__init__(self) |
|
1685 | Operation.__init__(self) | |
1681 |
|
1686 | |||
1682 | def __correctValues(self, heiRang, phi, velRadial, SNR): |
|
1687 | def __correctValues(self, heiRang, phi, velRadial, SNR): | |
1683 | listPhi = phi.tolist() |
|
1688 | listPhi = phi.tolist() | |
1684 | maxid = listPhi.index(max(listPhi)) |
|
1689 | maxid = listPhi.index(max(listPhi)) | |
1685 | minid = listPhi.index(min(listPhi)) |
|
1690 | minid = listPhi.index(min(listPhi)) | |
1686 |
|
1691 | |||
1687 | rango = range(len(phi)) |
|
1692 | rango = range(len(phi)) | |
1688 | # rango = numpy.delete(rango,maxid) |
|
1693 | # rango = numpy.delete(rango,maxid) | |
1689 |
|
1694 | |||
1690 | heiRang1 = heiRang*math.cos(phi[maxid]) |
|
1695 | heiRang1 = heiRang*math.cos(phi[maxid]) | |
1691 | heiRangAux = heiRang*math.cos(phi[minid]) |
|
1696 | heiRangAux = heiRang*math.cos(phi[minid]) | |
1692 | indOut = (heiRang1 < heiRangAux[0]).nonzero() |
|
1697 | indOut = (heiRang1 < heiRangAux[0]).nonzero() | |
1693 | heiRang1 = numpy.delete(heiRang1,indOut) |
|
1698 | heiRang1 = numpy.delete(heiRang1,indOut) | |
1694 |
|
1699 | |||
1695 | velRadial1 = numpy.zeros([len(phi),len(heiRang1)]) |
|
1700 | velRadial1 = numpy.zeros([len(phi),len(heiRang1)]) | |
1696 | SNR1 = numpy.zeros([len(phi),len(heiRang1)]) |
|
1701 | SNR1 = numpy.zeros([len(phi),len(heiRang1)]) | |
1697 |
|
1702 | |||
1698 | for i in rango: |
|
1703 | for i in rango: | |
1699 | x = heiRang*math.cos(phi[i]) |
|
1704 | x = heiRang*math.cos(phi[i]) | |
1700 | y1 = velRadial[i,:] |
|
1705 | y1 = velRadial[i,:] | |
1701 | f1 = interpolate.interp1d(x,y1,kind = 'cubic') |
|
1706 | f1 = interpolate.interp1d(x,y1,kind = 'cubic') | |
1702 |
|
1707 | |||
1703 | x1 = heiRang1 |
|
1708 | x1 = heiRang1 | |
1704 | y11 = f1(x1) |
|
1709 | y11 = f1(x1) | |
1705 |
|
1710 | |||
1706 | y2 = SNR[i,:] |
|
1711 | y2 = SNR[i,:] | |
1707 | f2 = interpolate.interp1d(x,y2,kind = 'cubic') |
|
1712 | f2 = interpolate.interp1d(x,y2,kind = 'cubic') | |
1708 | y21 = f2(x1) |
|
1713 | y21 = f2(x1) | |
1709 |
|
1714 | |||
1710 | velRadial1[i,:] = y11 |
|
1715 | velRadial1[i,:] = y11 | |
1711 | SNR1[i,:] = y21 |
|
1716 | SNR1[i,:] = y21 | |
1712 |
|
1717 | |||
1713 | return heiRang1, velRadial1, SNR1 |
|
1718 | return heiRang1, velRadial1, SNR1 | |
1714 |
|
1719 | |||
1715 | def run(self, dataOut, zenith, zenithCorrection): |
|
1720 | def run(self, dataOut, zenith, zenithCorrection): | |
1716 | heiRang = dataOut.heightList |
|
1721 | heiRang = dataOut.heightList | |
1717 | velRadial = dataOut.data_param[:,3,:] |
|
1722 | velRadial = dataOut.data_param[:,3,:] | |
1718 | SNR = dataOut.SNR |
|
1723 | SNR = dataOut.data_SNR | |
1719 |
|
1724 | |||
1720 | zenith = numpy.array(zenith) |
|
1725 | zenith = numpy.array(zenith) | |
1721 | zenith -= zenithCorrection |
|
1726 | zenith -= zenithCorrection | |
1722 | zenith *= numpy.pi/180 |
|
1727 | zenith *= numpy.pi/180 | |
1723 |
|
1728 | |||
1724 | heiRang1, velRadial1, SNR1 = self.__correctValues(heiRang, numpy.abs(zenith), velRadial, SNR) |
|
1729 | heiRang1, velRadial1, SNR1 = self.__correctValues(heiRang, numpy.abs(zenith), velRadial, SNR) | |
1725 |
|
1730 | |||
1726 | alp = zenith[0] |
|
1731 | alp = zenith[0] | |
1727 | bet = zenith[1] |
|
1732 | bet = zenith[1] | |
1728 |
|
1733 | |||
1729 | w_w = velRadial1[0,:] |
|
1734 | w_w = velRadial1[0,:] | |
1730 | w_e = velRadial1[1,:] |
|
1735 | w_e = velRadial1[1,:] | |
1731 |
|
1736 | |||
1732 | w = (w_w*numpy.sin(bet) - w_e*numpy.sin(alp))/(numpy.cos(alp)*numpy.sin(bet) - numpy.cos(bet)*numpy.sin(alp)) |
|
1737 | w = (w_w*numpy.sin(bet) - w_e*numpy.sin(alp))/(numpy.cos(alp)*numpy.sin(bet) - numpy.cos(bet)*numpy.sin(alp)) | |
1733 | u = (w_w*numpy.cos(bet) - w_e*numpy.cos(alp))/(numpy.sin(alp)*numpy.cos(bet) - numpy.sin(bet)*numpy.cos(alp)) |
|
1738 | u = (w_w*numpy.cos(bet) - w_e*numpy.cos(alp))/(numpy.sin(alp)*numpy.cos(bet) - numpy.sin(bet)*numpy.cos(alp)) | |
1734 |
|
1739 | |||
1735 | winds = numpy.vstack((u,w)) |
|
1740 | winds = numpy.vstack((u,w)) | |
1736 |
|
1741 | |||
1737 | dataOut.heightList = heiRang1 |
|
1742 | dataOut.heightList = heiRang1 | |
1738 | dataOut.data_output = winds |
|
1743 | dataOut.data_output = winds | |
1739 | dataOut.SNR = SNR1 |
|
1744 | dataOut.data_SNR = SNR1 | |
1740 |
|
1745 | |||
1741 | dataOut.initUtcTime = dataOut.ltctime |
|
1746 | dataOut.initUtcTime = dataOut.ltctime | |
1742 | dataOut.outputInterval = dataOut.timeInterval |
|
1747 | dataOut.outputInterval = dataOut.timeInterval | |
1743 | return |
|
1748 | return | |
1744 |
|
1749 | |||
1745 |
|
1750 | |||
1746 |
|
1751 | |||
1747 |
|
1752 | |||
1748 |
|
1753 | |||
1749 | No newline at end of file |
|
1754 |
@@ -1,135 +1,140 | |||||
1 | # DIAS 19 Y 20 FEB 2014 |
|
1 | # DIAS 19 Y 20 FEB 2014 | |
2 | # Comprobacion de Resultados DBS con SA |
|
2 | # Comprobacion de Resultados DBS con SA | |
3 |
|
3 | |||
4 | import os, sys |
|
4 | import os, sys | |
5 |
|
5 | |||
6 | path = os.path.split(os.getcwd())[0] |
|
6 | path = os.path.split(os.getcwd())[0] | |
7 | sys.path.append(path) |
|
7 | sys.path.append(path) | |
8 |
|
8 | |||
9 | from controller import * |
|
9 | from controller import * | |
10 |
|
10 | |||
11 | desc = "DBS Experiment Test" |
|
11 | desc = "DBS Experiment Test" | |
12 | filename = "DBStest.xml" |
|
12 | filename = "DBStest.xml" | |
13 |
|
13 | |||
14 | controllerObj = Project() |
|
14 | controllerObj = Project() | |
15 |
|
15 | |||
16 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
16 | controllerObj.setup(id = '191', name='test01', description=desc) | |
17 |
|
17 | |||
18 | #Experimentos |
|
18 | #Experimentos | |
19 |
|
19 | |||
20 | path = '/host/Jicamarca/EW_Drifts/d2012248' |
|
20 | path = '/host/Jicamarca/EW_Drifts/d2012248' | |
21 | pathFigure = '/home/propietario/workspace/Graficos/drifts' |
|
21 | pathFigure = '/home/propietario/workspace/Graficos/drifts' | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | path = "/home/soporte/Data/drifts" |
|
24 | path = "/home/soporte/Data/drifts" | |
25 | pathFigure = '/home/soporte/workspace/Graficos/drifts/prueba' |
|
25 | pathFigure = '/home/soporte/workspace/Graficos/drifts/prueba' | |
|
26 | pathFile = '/home/soporte/Data/drifts/HDF5' | |||
26 |
|
27 | |||
27 |
xmin = |
|
28 | xmin = 0 | |
28 |
xmax = |
|
29 | xmax = 24 | |
29 | #------------------------------------------------------------------------------------------------ |
|
30 | #------------------------------------------------------------------------------------------------ | |
30 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', |
|
31 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', | |
31 | path=path, |
|
32 | path=path, | |
32 |
startDate='2012/0 |
|
33 | startDate='2012/09/06', | |
33 |
endDate='2012/ |
|
34 | endDate='2012/09/06', | |
34 | startTime='00:00:00', |
|
35 | startTime='00:00:00', | |
35 | endTime='23:59:59', |
|
36 | endTime='23:59:59', | |
36 | online=0, |
|
37 | online=0, | |
37 | walk=1) |
|
38 | walk=1) | |
38 |
|
39 | |||
39 | opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
40 | opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') | |
40 |
|
41 | |||
41 | #-------------------------------------------------------------------------------------------------- |
|
42 | #-------------------------------------------------------------------------------------------------- | |
42 |
|
43 | |||
43 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
44 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
44 |
|
45 | |||
45 | opObj11 = procUnitConfObj0.addOperation(name='ProfileSelector', optype='other') |
|
46 | opObj11 = procUnitConfObj0.addOperation(name='ProfileSelector', optype='other') | |
46 | opObj11.addParameter(name='profileRangeList', value='0,127', format='intlist') |
|
47 | opObj11.addParameter(name='profileRangeList', value='0,127', format='intlist') | |
47 |
|
48 | |||
48 | opObj11 = procUnitConfObj0.addOperation(name='filterByHeights') |
|
49 | opObj11 = procUnitConfObj0.addOperation(name='filterByHeights') | |
49 | opObj11.addParameter(name='window', value='3', format='int') |
|
50 | opObj11.addParameter(name='window', value='3', format='int') | |
50 |
|
51 | |||
51 | opObj11 = procUnitConfObj0.addOperation(name='Decoder', optype='other') |
|
52 | opObj11 = procUnitConfObj0.addOperation(name='Decoder', optype='other') | |
52 | # opObj11.addParameter(name='code', value='1,-1', format='floatlist') |
|
53 | # opObj11.addParameter(name='code', value='1,-1', format='floatlist') | |
53 | # opObj11.addParameter(name='nCode', value='2', format='int') |
|
54 | # opObj11.addParameter(name='nCode', value='2', format='int') | |
54 | # opObj11.addParameter(name='nBaud', value='1', format='int') |
|
55 | # opObj11.addParameter(name='nBaud', value='1', format='int') | |
55 |
|
56 | |||
56 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId()) |
|
57 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId()) | |
57 | procUnitConfObj1.addParameter(name='nFFTPoints', value='128', format='int') |
|
58 | procUnitConfObj1.addParameter(name='nFFTPoints', value='128', format='int') | |
58 | procUnitConfObj1.addParameter(name='nProfiles', value='128', format='int') |
|
59 | procUnitConfObj1.addParameter(name='nProfiles', value='128', format='int') | |
59 | procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(2,3)', format='pairsList')#,(2,3) |
|
60 | procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(2,3)', format='pairsList')#,(2,3) | |
60 |
|
61 | |||
61 | opObj11 = procUnitConfObj1.addOperation(name='selectHeights') |
|
62 | opObj11 = procUnitConfObj1.addOperation(name='selectHeights') | |
62 | # # opObj11.addParameter(name='minHei', value='320.0', format='float') |
|
63 | # # opObj11.addParameter(name='minHei', value='320.0', format='float') | |
63 | # # opObj11.addParameter(name='maxHei', value='350.0', format='float') |
|
64 | # # opObj11.addParameter(name='maxHei', value='350.0', format='float') | |
64 | opObj11.addParameter(name='minHei', value='200.0', format='float') |
|
65 | opObj11.addParameter(name='minHei', value='200.0', format='float') | |
65 | opObj11.addParameter(name='maxHei', value='600.0', format='float') |
|
66 | opObj11.addParameter(name='maxHei', value='600.0', format='float') | |
66 |
|
67 | |||
67 | opObj11 = procUnitConfObj1.addOperation(name='selectChannels') |
|
68 | opObj11 = procUnitConfObj1.addOperation(name='selectChannels') | |
68 | opObj11.addParameter(name='channelList', value='0,1,2,3', format='intlist') |
|
69 | opObj11.addParameter(name='channelList', value='0,1,2,3', format='intlist') | |
69 |
|
70 | |||
70 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') |
|
71 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
71 | opObj11.addParameter(name='timeInterval', value='300.0', format='float') |
|
72 | opObj11.addParameter(name='timeInterval', value='300.0', format='float') | |
72 |
|
73 | |||
73 | opObj13 = procUnitConfObj1.addOperation(name='removeDC') |
|
74 | opObj13 = procUnitConfObj1.addOperation(name='removeDC') | |
74 |
|
75 | |||
75 | # opObj14 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
76 | # opObj14 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
76 | # opObj14.addParameter(name='id', value='1', format='int') |
|
77 | # opObj14.addParameter(name='id', value='1', format='int') | |
77 | # # opObj14.addParameter(name='wintitle', value='Con interf', format='str') |
|
78 | # # opObj14.addParameter(name='wintitle', value='Con interf', format='str') | |
78 | # opObj14.addParameter(name='save', value='1', format='bool') |
|
79 | # opObj14.addParameter(name='save', value='1', format='bool') | |
79 | # opObj14.addParameter(name='figpath', value=pathFigure, format='str') |
|
80 | # opObj14.addParameter(name='figpath', value=pathFigure, format='str') | |
80 | # # opObj14.addParameter(name='zmin', value='5', format='int') |
|
81 | # # opObj14.addParameter(name='zmin', value='5', format='int') | |
81 | # opObj14.addParameter(name='zmax', value='30', format='int') |
|
82 | # opObj14.addParameter(name='zmax', value='30', format='int') | |
82 | # |
|
83 | # | |
83 | # opObj12 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
84 | # opObj12 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |
84 | # opObj12.addParameter(name='id', value='2', format='int') |
|
85 | # opObj12.addParameter(name='id', value='2', format='int') | |
85 | # opObj12.addParameter(name='wintitle', value='RTI Plot', format='str') |
|
86 | # opObj12.addParameter(name='wintitle', value='RTI Plot', format='str') | |
86 | # opObj12.addParameter(name='save', value='1', format='bool') |
|
87 | # opObj12.addParameter(name='save', value='1', format='bool') | |
87 | # opObj12.addParameter(name='figpath', value = pathFigure, format='str') |
|
88 | # opObj12.addParameter(name='figpath', value = pathFigure, format='str') | |
88 | # opObj12.addParameter(name='xmin', value=xmin, format='float') |
|
89 | # opObj12.addParameter(name='xmin', value=xmin, format='float') | |
89 | # opObj12.addParameter(name='xmax', value=xmax, format='float') |
|
90 | # opObj12.addParameter(name='xmax', value=xmax, format='float') | |
90 | # # opObj12.addParameter(name='zmin', value='5', format='int') |
|
91 | # # opObj12.addParameter(name='zmin', value='5', format='int') | |
91 | # opObj12.addParameter(name='zmax', value='30', format='int') |
|
92 | # opObj12.addParameter(name='zmax', value='30', format='int') | |
92 |
|
93 | |||
93 | #-------------------------------------------------------------------------------------------------- |
|
94 | #-------------------------------------------------------------------------------------------------- | |
94 |
|
95 | |||
95 | procUnitConfObj2 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj1.getId()) |
|
96 | procUnitConfObj2 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj1.getId()) | |
96 | opObj20 = procUnitConfObj2.addOperation(name='SpectralFitting') |
|
97 | opObj20 = procUnitConfObj2.addOperation(name='SpectralFitting') | |
97 | opObj20.addParameter(name='path', value='/home/soporte/workspace/RemoteSystemsTempFiles', format='str') |
|
98 | opObj20.addParameter(name='path', value='/home/soporte/workspace/RemoteSystemsTempFiles', format='str') | |
98 | opObj20.addParameter(name='file', value='modelSpectralFitting', format='str') |
|
99 | opObj20.addParameter(name='file', value='modelSpectralFitting', format='str') | |
99 | opObj20.addParameter(name='groupList', value='(0,1),(2,3)',format='multiList') |
|
100 | opObj20.addParameter(name='groupList', value='(0,1),(2,3)',format='multiList') | |
100 |
|
101 | |||
101 | opObj11 = procUnitConfObj2.addOperation(name='SpectralFittingPlot', optype='other') |
|
102 | opObj11 = procUnitConfObj2.addOperation(name='SpectralFittingPlot', optype='other') | |
102 | opObj11.addParameter(name='id', value='3', format='int') |
|
103 | opObj11.addParameter(name='id', value='3', format='int') | |
103 | opObj11.addParameter(name='wintitle', value='DopplerPlot', format='str') |
|
104 | opObj11.addParameter(name='wintitle', value='DopplerPlot', format='str') | |
104 | opObj11.addParameter(name='cutHeight', value='350', format='int') |
|
105 | opObj11.addParameter(name='cutHeight', value='350', format='int') | |
105 | opObj11.addParameter(name='fit', value='1', format='int')#1--True/include fit |
|
106 | opObj11.addParameter(name='fit', value='1', format='int')#1--True/include fit | |
106 | opObj11.addParameter(name='save', value='1', format='bool') |
|
107 | opObj11.addParameter(name='save', value='1', format='bool') | |
107 | opObj11.addParameter(name='figpath', value = pathFigure, format='str') |
|
108 | opObj11.addParameter(name='figpath', value = pathFigure, format='str') | |
108 |
|
109 | |||
|
110 | opObj12 = procUnitConfObj2.addOperation(name='HDF5Writer', optype='other') | |||
|
111 | opObj12.addParameter(name='path', value=pathFile) | |||
|
112 | opObj12.addParameter(name='blocksPerFile', value='3', format='int') | |||
|
113 | ||||
109 | opObj11 = procUnitConfObj2.addOperation(name='EWDriftsEstimation', optype='other') |
|
114 | opObj11 = procUnitConfObj2.addOperation(name='EWDriftsEstimation', optype='other') | |
110 | opObj11.addParameter(name='zenith', value='-3.80208,3.10658', format='floatlist') |
|
115 | opObj11.addParameter(name='zenith', value='-3.80208,3.10658', format='floatlist') | |
111 | opObj11.addParameter(name='zenithCorrection', value='0.183201', format='float') |
|
116 | opObj11.addParameter(name='zenithCorrection', value='0.183201', format='float') | |
112 |
|
117 | |||
113 | opObj23 = procUnitConfObj2.addOperation(name='EWDriftsPlot', optype='other') |
|
118 | opObj23 = procUnitConfObj2.addOperation(name='EWDriftsPlot', optype='other') | |
114 | opObj23.addParameter(name='id', value='4', format='int') |
|
119 | opObj23.addParameter(name='id', value='4', format='int') | |
115 | opObj23.addParameter(name='wintitle', value='EW Drifts', format='str') |
|
120 | opObj23.addParameter(name='wintitle', value='EW Drifts', format='str') | |
116 | opObj23.addParameter(name='save', value='1', format='bool') |
|
121 | opObj23.addParameter(name='save', value='1', format='bool') | |
117 | opObj23.addParameter(name='figpath', value = pathFigure, format='str') |
|
122 | opObj23.addParameter(name='figpath', value = pathFigure, format='str') | |
118 | opObj23.addParameter(name='zminZonal', value='-150', format='int') |
|
123 | opObj23.addParameter(name='zminZonal', value='-150', format='int') | |
119 | opObj23.addParameter(name='zmaxZonal', value='150', format='int') |
|
124 | opObj23.addParameter(name='zmaxZonal', value='150', format='int') | |
120 | opObj23.addParameter(name='zminVertical', value='-30', format='float') |
|
125 | opObj23.addParameter(name='zminVertical', value='-30', format='float') | |
121 | opObj23.addParameter(name='zmaxVertical', value='30', format='float') |
|
126 | opObj23.addParameter(name='zmaxVertical', value='30', format='float') | |
122 | opObj23.addParameter(name='SNR_1', value='1', format='bool') |
|
127 | opObj23.addParameter(name='SNR_1', value='1', format='bool') | |
123 | opObj23.addParameter(name='SNRmax', value='5', format='int') |
|
128 | opObj23.addParameter(name='SNRmax', value='5', format='int') | |
124 | # opObj23.addParameter(name='SNRthresh', value='-50', format='float') |
|
129 | # opObj23.addParameter(name='SNRthresh', value='-50', format='float') | |
125 | opObj23.addParameter(name='xmin', value=xmin, format='float') |
|
130 | opObj23.addParameter(name='xmin', value=xmin, format='float') | |
126 | opObj23.addParameter(name='xmax', value=xmax, format='float') |
|
131 | opObj23.addParameter(name='xmax', value=xmax, format='float') | |
127 | #-------------------------------------------------------------------------------------------------- |
|
132 | #-------------------------------------------------------------------------------------------------- | |
128 | print "Escribiendo el archivo XML" |
|
133 | print "Escribiendo el archivo XML" | |
129 | controllerObj.writeXml(filename) |
|
134 | controllerObj.writeXml(filename) | |
130 | print "Leyendo el archivo XML" |
|
135 | print "Leyendo el archivo XML" | |
131 | controllerObj.readXml(filename) |
|
136 | controllerObj.readXml(filename) | |
132 |
|
137 | |||
133 | controllerObj.createObjects() |
|
138 | controllerObj.createObjects() | |
134 | controllerObj.connectObjects() |
|
139 | controllerObj.connectObjects() | |
135 | controllerObj.run() No newline at end of file |
|
140 | controllerObj.run() |
@@ -1,155 +1,169 | |||||
1 | # DIAS 19 Y 20 FEB 2014 |
|
1 | # DIAS 19 Y 20 FEB 2014 | |
2 | # Comprobacion de Resultados DBS con SA |
|
2 | # Comprobacion de Resultados DBS con SA | |
3 |
|
3 | |||
4 | import os, sys |
|
4 | import os, sys | |
5 |
|
5 | |||
6 | path = os.path.split(os.getcwd())[0] |
|
6 | path = os.path.split(os.getcwd())[0] | |
7 | sys.path.append(path) |
|
7 | sys.path.append(path) | |
8 |
|
8 | |||
9 | from controller import * |
|
9 | from controller import * | |
10 |
|
10 | |||
11 | desc = "DBS Experiment Test" |
|
11 | desc = "DBS Experiment Test" | |
12 | filename = "DBStest.xml" |
|
12 | filename = "DBStest.xml" | |
13 |
|
13 | |||
14 | controllerObj = Project() |
|
14 | controllerObj = Project() | |
15 |
|
15 | |||
16 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
16 | controllerObj.setup(id = '191', name='test01', description=desc) | |
17 |
|
17 | |||
18 | #Experimentos |
|
18 | #Experimentos | |
19 |
|
19 | |||
20 | #2014050 19 Feb 2014 |
|
20 | #2014050 19 Feb 2014 | |
21 | # path = '/home/soporte/Documents/MST_Data/DBS/d2014050' |
|
21 | # path = '/home/soporte/Documents/MST_Data/DBS/d2014050' | |
22 | # pathFigure = '/home/soporte/workspace/Graficos/DBS/d2014050p/' |
|
22 | # pathFigure = '/home/soporte/workspace/Graficos/DBS/d2014050p/' | |
23 | # xmin = '15.5' |
|
23 | # xmin = '15.5' | |
24 | # xmax = '23.99999999' |
|
24 | # xmax = '23.99999999' | |
25 | # startTime = '17:25:00' |
|
25 | # startTime = '17:25:00' | |
26 | # filehdf5 = "DBS_2014050.hdf5" |
|
26 | # filehdf5 = "DBS_2014050.hdf5" | |
27 |
|
27 | |||
28 | #2014051 20 Feb 2014 |
|
28 | #2014051 20 Feb 2014 | |
29 | path = '/home/soporte/Data/MST/DBS/d2014051' |
|
29 | path = '/home/soporte/Data/MST/DBS/d2014051' | |
30 | pathFigure = '/home/soporte/workspace/Graficos/DBS/prueba1/' |
|
30 | pathFigure = '/home/soporte/workspace/Graficos/DBS/prueba1/' | |
31 | xmin = '0' |
|
31 | xmin = '0' | |
32 | xmax = '7.5' |
|
32 | xmax = '7.5' | |
33 | startTime = '00:00:00' |
|
33 | startTime = '00:00:00' | |
34 | filehdf5 = "DBS_2014051.hdf5" |
|
34 | filehdf5 = "DBS_2014051.hdf5" | |
35 |
|
35 | |||
36 |
|
36 | |||
37 |
|
37 | |||
38 | #------------------------------------------------------------------------------------------------ |
|
38 | #------------------------------------------------------------------------------------------------ | |
39 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', |
|
39 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', | |
40 | path=path, |
|
40 | path=path, | |
41 | startDate='2014/01/31', |
|
41 | startDate='2014/01/31', | |
42 | endDate='2014/03/31', |
|
42 | endDate='2014/03/31', | |
43 | startTime=startTime, |
|
43 | startTime=startTime, | |
44 | endTime='23:59:59', |
|
44 | endTime='23:59:59', | |
45 | online=0, |
|
45 | online=0, | |
46 | delay=5, |
|
46 | delay=5, | |
47 | walk=0) |
|
47 | walk=0) | |
48 |
|
48 | |||
49 | opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
49 | opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') | |
50 |
|
50 | |||
51 |
|
51 | |||
52 | #-------------------------------------------------------------------------------------------------- |
|
52 | #-------------------------------------------------------------------------------------------------- | |
53 |
|
53 | |||
54 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
54 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
55 |
|
55 | |||
56 | opObj11 = procUnitConfObj0.addOperation(name='Decoder', optype='other') |
|
56 | opObj11 = procUnitConfObj0.addOperation(name='Decoder', optype='other') | |
57 |
|
57 | |||
58 | opObj11 = procUnitConfObj0.addOperation(name='CohInt', optype='other') |
|
58 | opObj11 = procUnitConfObj0.addOperation(name='CohInt', optype='other') | |
59 | opObj11.addParameter(name='n', value='256', format='int') |
|
59 | opObj11.addParameter(name='n', value='256', format='int') | |
60 | # opObj11.addParameter(name='n', value='16', format='int') |
|
60 | # opObj11.addParameter(name='n', value='16', format='int') | |
61 |
|
61 | |||
62 | opObj11 = procUnitConfObj0.addOperation(name='selectHeightsByIndex') |
|
62 | opObj11 = procUnitConfObj0.addOperation(name='selectHeightsByIndex') | |
63 | opObj11.addParameter(name='minIndex', value='10', format='float') |
|
63 | opObj11.addParameter(name='minIndex', value='10', format='float') | |
64 | opObj11.addParameter(name='maxIndex', value='60', format='float') |
|
64 | opObj11.addParameter(name='maxIndex', value='60', format='float') | |
65 |
|
65 | |||
66 | #--------------------------------------------------------------------------------------------------- |
|
66 | #--------------------------------------------------------------------------------------------------- | |
67 |
|
67 | |||
68 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId()) |
|
68 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId()) | |
69 | procUnitConfObj1.addParameter(name='nFFTPoints', value='64', format='int') |
|
69 | procUnitConfObj1.addParameter(name='nFFTPoints', value='64', format='int') | |
70 | procUnitConfObj1.addParameter(name='nProfiles', value='64', format='int') |
|
70 | procUnitConfObj1.addParameter(name='nProfiles', value='64', format='int') | |
71 | # procUnitConfObj1.addParameter(name='ippFactor', value='2', format='int') |
|
71 | # procUnitConfObj1.addParameter(name='ippFactor', value='2', format='int') | |
72 | procUnitConfObj1.addParameter(name='pairsList', value='(0,0),(0,1),(2,1)', format='pairsList') |
|
72 | procUnitConfObj1.addParameter(name='pairsList', value='(0,0),(0,1),(2,1)', format='pairsList') | |
73 |
|
73 | |||
74 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') |
|
74 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
75 | opObj11.addParameter(name='n', value='5', format='int') |
|
75 | opObj11.addParameter(name='n', value='5', format='int') | |
76 |
|
76 | |||
77 | opObj14 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
77 | opObj14 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
78 | opObj14.addParameter(name='id', value='1', format='int') |
|
78 | opObj14.addParameter(name='id', value='1', format='int') | |
79 | opObj14.addParameter(name='wintitle', value='Con interf', format='str') |
|
79 | opObj14.addParameter(name='wintitle', value='Con interf', format='str') | |
80 | opObj14.addParameter(name='save', value='1', format='bool') |
|
80 | opObj14.addParameter(name='save', value='1', format='bool') | |
81 | opObj14.addParameter(name='figpath', value=pathFigure, format='str') |
|
81 | opObj14.addParameter(name='figpath', value=pathFigure, format='str') | |
82 | opObj14.addParameter(name='zmin', value='5', format='int') |
|
82 | opObj14.addParameter(name='zmin', value='5', format='int') | |
83 | opObj14.addParameter(name='zmax', value='90', format='int') |
|
83 | opObj14.addParameter(name='zmax', value='90', format='int') | |
84 |
|
84 | |||
85 | opObj12 = procUnitConfObj1.addOperation(name='removeInterference') |
|
85 | opObj12 = procUnitConfObj1.addOperation(name='removeInterference') | |
86 | opObj13 = procUnitConfObj1.addOperation(name='removeDC') |
|
86 | opObj13 = procUnitConfObj1.addOperation(name='removeDC') | |
87 | opObj13.addParameter(name='mode', value='1', format='int') |
|
87 | opObj13.addParameter(name='mode', value='1', format='int') | |
88 |
|
88 | |||
89 | opObj12 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
89 | opObj12 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |
90 | opObj12.addParameter(name='id', value='2', format='int') |
|
90 | opObj12.addParameter(name='id', value='2', format='int') | |
91 | opObj12.addParameter(name='wintitle', value='RTI Plot', format='str') |
|
91 | opObj12.addParameter(name='wintitle', value='RTI Plot', format='str') | |
92 | opObj12.addParameter(name='save', value='1', format='bool') |
|
92 | opObj12.addParameter(name='save', value='1', format='bool') | |
93 | opObj12.addParameter(name='figpath', value = pathFigure, format='str') |
|
93 | opObj12.addParameter(name='figpath', value = pathFigure, format='str') | |
94 | opObj12.addParameter(name='xmin', value=xmin, format='float') |
|
94 | opObj12.addParameter(name='xmin', value=xmin, format='float') | |
95 | opObj12.addParameter(name='xmax', value=xmax, format='float') |
|
95 | opObj12.addParameter(name='xmax', value=xmax, format='float') | |
96 | opObj12.addParameter(name='zmin', value='5', format='int') |
|
96 | opObj12.addParameter(name='zmin', value='5', format='int') | |
97 | opObj12.addParameter(name='zmax', value='90', format='int') |
|
97 | opObj12.addParameter(name='zmax', value='90', format='int') | |
98 |
|
98 | |||
99 | #-------------------------------------------------------------------------------------------------- |
|
99 | #-------------------------------------------------------------------------------------------------- | |
100 |
|
100 | |||
101 | procUnitConfObj2 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj1.getId()) |
|
101 | procUnitConfObj2 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj1.getId()) | |
102 | opObj20 = procUnitConfObj2.addOperation(name='GetMoments') |
|
102 | opObj20 = procUnitConfObj2.addOperation(name='GetMoments') | |
103 |
|
103 | |||
104 | opObj21 = procUnitConfObj2.addOperation(name='MomentsPlot', optype='other') |
|
104 | opObj21 = procUnitConfObj2.addOperation(name='MomentsPlot', optype='other') | |
105 | opObj21.addParameter(name='id', value='3', format='int') |
|
105 | opObj21.addParameter(name='id', value='3', format='int') | |
106 | opObj21.addParameter(name='wintitle', value='Moments Plot', format='str') |
|
106 | opObj21.addParameter(name='wintitle', value='Moments Plot', format='str') | |
107 | opObj21.addParameter(name='save', value='1', format='bool') |
|
107 | opObj21.addParameter(name='save', value='1', format='bool') | |
108 | opObj21.addParameter(name='figpath', value=pathFigure, format='str') |
|
108 | opObj21.addParameter(name='figpath', value=pathFigure, format='str') | |
109 | opObj21.addParameter(name='zmin', value='5', format='int') |
|
109 | opObj21.addParameter(name='zmin', value='5', format='int') | |
110 | opObj21.addParameter(name='zmax', value='90', format='int') |
|
110 | opObj21.addParameter(name='zmax', value='90', format='int') | |
111 |
|
111 | |||
112 |
opObj21 = procUnitConfObj2.addOperation(name=' |
|
112 | opObj21 = procUnitConfObj2.addOperation(name='ParametersPlot', optype='other') | |
113 | opObj21.addParameter(name='id', value='5', format='int') |
|
113 | opObj21.addParameter(name='id', value='5', format='int') | |
114 | opObj21.addParameter(name='wintitle', value='Radial Velocity Plot', format='str') |
|
114 | opObj21.addParameter(name='wintitle', value='Radial Velocity Plot', format='str') | |
115 | opObj21.addParameter(name='save', value='1', format='bool') |
|
115 | opObj21.addParameter(name='save', value='1', format='bool') | |
116 | opObj21.addParameter(name='figpath', value=pathFigure, format='str') |
|
116 | opObj21.addParameter(name='figpath', value=pathFigure, format='str') | |
117 | opObj21.addParameter(name='SNRmin', value='-10', format='int') |
|
117 | opObj21.addParameter(name='SNRmin', value='-10', format='int') | |
118 | opObj21.addParameter(name='SNRmax', value='60', format='int') |
|
118 | opObj21.addParameter(name='SNRmax', value='60', format='int') | |
119 | opObj21.addParameter(name='SNRthresh', value='0', format='float') |
|
119 | opObj21.addParameter(name='SNRthresh', value='0', format='float') | |
120 | opObj21.addParameter(name='xmin', value=xmin, format='float') |
|
120 | opObj21.addParameter(name='xmin', value=xmin, format='float') | |
121 | opObj21.addParameter(name='xmax', value=xmax, format='float') |
|
121 | opObj21.addParameter(name='xmax', value=xmax, format='float') | |
|
122 | ||||
|
123 | opObj21 = procUnitConfObj2.addOperation(name='ParametersPlot', optype='other') | |||
|
124 | opObj21.addParameter(name='id', value='6', format='int') | |||
|
125 | opObj21.addParameter(name='wintitle', value='Spectral width Plot', format='str') | |||
|
126 | opObj21.addParameter(name='save', value='1', format='bool') | |||
|
127 | opObj21.addParameter(name='figpath', value=pathFigure, format='str') | |||
|
128 | opObj21.addParameter(name='SNRmin', value='-10', format='int') | |||
|
129 | opObj21.addParameter(name='SNRmax', value='60', format='int') | |||
|
130 | opObj21.addParameter(name='SNRthresh', value='0', format='float') | |||
|
131 | opObj21.addParameter(name='xmin', value=xmin, format='float') | |||
|
132 | opObj21.addParameter(name='xmax', value=xmax, format='float') | |||
|
133 | opObj21.addParameter(name='zmin', value=0, format='float') | |||
|
134 | opObj21.addParameter(name='paramIndex', value=2, format='int') | |||
|
135 | opObj21.addParameter(name='onlyPositive', value=1, format='bool') | |||
122 |
|
136 | |||
123 | opObj22 = procUnitConfObj2.addOperation(name='WindProfiler', optype='other') |
|
137 | opObj22 = procUnitConfObj2.addOperation(name='WindProfiler', optype='other') | |
124 | opObj22.addParameter(name='technique', value='DBS', format='str') |
|
138 | opObj22.addParameter(name='technique', value='DBS', format='str') | |
125 | opObj22.addParameter(name='correctAzimuth', value='51.06', format='float') |
|
139 | opObj22.addParameter(name='correctAzimuth', value='51.06', format='float') | |
126 | opObj22.addParameter(name='correctFactor', value='-1', format='float') |
|
140 | opObj22.addParameter(name='correctFactor', value='-1', format='float') | |
127 | opObj22.addParameter(name='dirCosx', value='0.041016, 0, -0.054688', format='floatlist') |
|
141 | opObj22.addParameter(name='dirCosx', value='0.041016, 0, -0.054688', format='floatlist') | |
128 | opObj22.addParameter(name='dirCosy', value='-0.041016, 0.025391, -0.023438', format='floatlist') |
|
142 | opObj22.addParameter(name='dirCosy', value='-0.041016, 0.025391, -0.023438', format='floatlist') | |
129 | # opObj22.addParameter(name='horizontalOnly', value='1', format='bool') |
|
143 | # opObj22.addParameter(name='horizontalOnly', value='1', format='bool') | |
130 | # opObj22.addParameter(name='channelList', value='1,2', format='intlist') |
|
144 | # opObj22.addParameter(name='channelList', value='1,2', format='intlist') | |
131 |
|
145 | |||
132 | opObj23 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other') |
|
146 | opObj23 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other') | |
133 | opObj23.addParameter(name='id', value='4', format='int') |
|
147 | opObj23.addParameter(name='id', value='4', format='int') | |
134 | opObj23.addParameter(name='wintitle', value='Wind Profiler', format='str') |
|
148 | opObj23.addParameter(name='wintitle', value='Wind Profiler', format='str') | |
135 | opObj23.addParameter(name='save', value='1', format='bool') |
|
149 | opObj23.addParameter(name='save', value='1', format='bool') | |
136 | opObj23.addParameter(name='figpath', value = pathFigure, format='str') |
|
150 | opObj23.addParameter(name='figpath', value = pathFigure, format='str') | |
137 | opObj23.addParameter(name='zmin', value='-10', format='int') |
|
151 | opObj23.addParameter(name='zmin', value='-10', format='int') | |
138 | opObj23.addParameter(name='zmax', value='10', format='int') |
|
152 | opObj23.addParameter(name='zmax', value='10', format='int') | |
139 | opObj23.addParameter(name='zmin_ver', value='-80', format='float') |
|
153 | opObj23.addParameter(name='zmin_ver', value='-80', format='float') | |
140 | opObj23.addParameter(name='zmax_ver', value='80', format='float') |
|
154 | opObj23.addParameter(name='zmax_ver', value='80', format='float') | |
141 | opObj23.addParameter(name='SNRmin', value='-10', format='int') |
|
155 | opObj23.addParameter(name='SNRmin', value='-10', format='int') | |
142 | opObj23.addParameter(name='SNRmax', value='60', format='int') |
|
156 | opObj23.addParameter(name='SNRmax', value='60', format='int') | |
143 | opObj23.addParameter(name='SNRthresh', value='0', format='float') |
|
157 | opObj23.addParameter(name='SNRthresh', value='0', format='float') | |
144 | opObj23.addParameter(name='xmin', value=xmin, format='float') |
|
158 | opObj23.addParameter(name='xmin', value=xmin, format='float') | |
145 | opObj23.addParameter(name='xmax', value=xmax, format='float') |
|
159 | opObj23.addParameter(name='xmax', value=xmax, format='float') | |
146 |
|
160 | |||
147 | #-------------------------------------------------------------------------------------------------- |
|
161 | #-------------------------------------------------------------------------------------------------- | |
148 | print "Escribiendo el archivo XML" |
|
162 | print "Escribiendo el archivo XML" | |
149 | controllerObj.writeXml(filename) |
|
163 | controllerObj.writeXml(filename) | |
150 | print "Leyendo el archivo XML" |
|
164 | print "Leyendo el archivo XML" | |
151 | controllerObj.readXml(filename) |
|
165 | controllerObj.readXml(filename) | |
152 |
|
166 | |||
153 | controllerObj.createObjects() |
|
167 | controllerObj.createObjects() | |
154 | controllerObj.connectObjects() |
|
168 | controllerObj.connectObjects() | |
155 | controllerObj.run() No newline at end of file |
|
169 | controllerObj.run() |
@@ -1,139 +1,139 | |||||
1 | # DIAS 19 Y 20 FEB 2014 |
|
1 | # DIAS 19 Y 20 FEB 2014 | |
2 | # Comprobacion de Resultados DBS con SA |
|
2 | # Comprobacion de Resultados DBS con SA | |
3 |
|
3 | |||
4 | import os, sys |
|
4 | import os, sys | |
5 |
|
5 | |||
6 | path = os.path.split(os.getcwd())[0] |
|
6 | path = os.path.split(os.getcwd())[0] | |
7 | sys.path.append(path) |
|
7 | sys.path.append(path) | |
8 |
|
8 | |||
9 | from controller import * |
|
9 | from controller import * | |
10 |
|
10 | |||
11 | desc = "SA Experiment Test" |
|
11 | desc = "SA Experiment Test" | |
12 | filename = "SA2014050.xml" |
|
12 | filename = "SA2014050.xml" | |
13 |
|
13 | |||
14 | controllerObj = Project() |
|
14 | controllerObj = Project() | |
15 |
|
15 | |||
16 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
16 | controllerObj.setup(id = '191', name='test01', description=desc) | |
17 |
|
17 | |||
18 |
|
18 | |||
19 | #Experimentos |
|
19 | #Experimentos | |
20 |
|
20 | |||
21 | #2014050 19 Feb 2014 |
|
21 | #2014050 19 Feb 2014 | |
22 | path = '/home/soporte/Data/MST/SA/d2014050' |
|
22 | path = '/home/soporte/Data/MST/SA/d2014050' | |
23 |
pathFigure = '/home/soporte/workspace/Graficos/SA/ |
|
23 | pathFigure = '/home/soporte/workspace/Graficos/SA/prueba1/' | |
24 | xmin = '15.5' |
|
24 | xmin = '15.5' | |
25 | xmax = '24' |
|
25 | xmax = '24' | |
26 | startTime = '15:30:00' |
|
26 | startTime = '15:30:00' | |
27 | filehdf5 = "SA_2014050.hdf5" |
|
27 | filehdf5 = "SA_2014050.hdf5" | |
28 |
|
28 | |||
29 | #2014051 20 Feb 2014 |
|
29 | #2014051 20 Feb 2014 | |
30 | # path = '/home/soporte/Data/MST/SA/d2014051' |
|
30 | # path = '/home/soporte/Data/MST/SA/d2014051' | |
31 | # pathFigure = '/home/soporte/workspace/Graficos/SA/new/' |
|
31 | # pathFigure = '/home/soporte/workspace/Graficos/SA/new/' | |
32 | # xmin = '0.0' |
|
32 | # xmin = '0.0' | |
33 | # xmax = '8.0' |
|
33 | # xmax = '8.0' | |
34 | # startTime = '00:00:00' |
|
34 | # startTime = '00:00:00' | |
35 | # filehdf5 = "SA_2014051.hdf5" |
|
35 | # filehdf5 = "SA_2014051.hdf5" | |
36 |
|
36 | |||
37 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', |
|
37 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', | |
38 | path=path, |
|
38 | path=path, | |
39 | startDate='2014/01/01', |
|
39 | startDate='2014/01/01', | |
40 | endDate='2014/03/31', |
|
40 | endDate='2014/03/31', | |
41 | startTime=startTime, |
|
41 | startTime=startTime, | |
42 | endTime='23:59:59', |
|
42 | endTime='23:59:59', | |
43 | online=0, |
|
43 | online=0, | |
44 | delay=5, |
|
44 | delay=5, | |
45 | walk=0) |
|
45 | walk=0) | |
46 |
|
46 | |||
47 | opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
47 | opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') | |
48 |
|
48 | |||
49 |
|
49 | |||
50 | #-------------------------------------------------------------------------------------------------- |
|
50 | #-------------------------------------------------------------------------------------------------- | |
51 |
|
51 | |||
52 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
52 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
53 |
|
53 | |||
54 | opObj11 = procUnitConfObj0.addOperation(name='Decoder', optype='other') |
|
54 | opObj11 = procUnitConfObj0.addOperation(name='Decoder', optype='other') | |
55 |
|
55 | |||
56 | opObj11 = procUnitConfObj0.addOperation(name='CohInt', optype='other') |
|
56 | opObj11 = procUnitConfObj0.addOperation(name='CohInt', optype='other') | |
57 | opObj11.addParameter(name='n', value='600', format='int') |
|
57 | opObj11.addParameter(name='n', value='600', format='int') | |
58 | # opObj11.addParameter(name='n', value='10', format='int') |
|
58 | # opObj11.addParameter(name='n', value='10', format='int') | |
59 |
|
59 | |||
60 | opObj11 = procUnitConfObj0.addOperation(name='selectHeightsByIndex') |
|
60 | opObj11 = procUnitConfObj0.addOperation(name='selectHeightsByIndex') | |
61 | opObj11.addParameter(name='minIndex', value='10', format='float') |
|
61 | opObj11.addParameter(name='minIndex', value='10', format='float') | |
62 | opObj11.addParameter(name='maxIndex', value='60', format='float') |
|
62 | opObj11.addParameter(name='maxIndex', value='60', format='float') | |
63 | #--------------------------------------------------------------------------------------------------- |
|
63 | #--------------------------------------------------------------------------------------------------- | |
64 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj0.getId()) |
|
64 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj0.getId()) | |
65 | # procUnitConfObj1.addParameter(name='pairsList', value='(0,0),(1,1),(2,2),(3,3),(1,0),(2,3)', format='pairsList') |
|
65 | # procUnitConfObj1.addParameter(name='pairsList', value='(0,0),(1,1),(2,2),(3,3),(1,0),(2,3)', format='pairsList') | |
66 | procUnitConfObj1.addParameter(name='pairsList', value='(0,0),(1,1),(2,2),(3,3),(0,3),(0,2),(1,3),(1,2),(0,1),(2,3)', format='pairsList') |
|
66 | procUnitConfObj1.addParameter(name='pairsList', value='(0,0),(1,1),(2,2),(3,3),(0,3),(0,2),(1,3),(1,2),(0,1),(2,3)', format='pairsList') | |
67 | procUnitConfObj1.addParameter(name='fullT', value='1', format='bool') |
|
67 | procUnitConfObj1.addParameter(name='fullT', value='1', format='bool') | |
68 | procUnitConfObj1.addParameter(name='removeDC', value='1', format='bool') |
|
68 | procUnitConfObj1.addParameter(name='removeDC', value='1', format='bool') | |
69 | #procUnitConfObj1.addParameter(name='lagT', value='0,1,2,3', format='intlist') |
|
69 | #procUnitConfObj1.addParameter(name='lagT', value='0,1,2,3', format='intlist') | |
70 |
|
70 | |||
71 | opObj12 = procUnitConfObj1.addOperation(name='CorrelationPlot', optype='other') |
|
71 | opObj12 = procUnitConfObj1.addOperation(name='CorrelationPlot', optype='other') | |
72 | opObj12.addParameter(name='id', value='1', format='int') |
|
72 | opObj12.addParameter(name='id', value='1', format='int') | |
73 | opObj12.addParameter(name='wintitle', value='CrossCorrelation Plot', format='str') |
|
73 | opObj12.addParameter(name='wintitle', value='CrossCorrelation Plot', format='str') | |
74 | opObj12.addParameter(name='save', value='1', format='bool') |
|
74 | opObj12.addParameter(name='save', value='1', format='bool') | |
75 | opObj12.addParameter(name='zmin', value='0', format='int') |
|
75 | opObj12.addParameter(name='zmin', value='0', format='int') | |
76 | opObj12.addParameter(name='zmax', value='1', format='int') |
|
76 | opObj12.addParameter(name='zmax', value='1', format='int') | |
77 | opObj12.addParameter(name='figpath', value = pathFigure, format='str') |
|
77 | opObj12.addParameter(name='figpath', value = pathFigure, format='str') | |
78 |
|
78 | |||
79 | opObj12 = procUnitConfObj1.addOperation(name='removeNoise') |
|
79 | opObj12 = procUnitConfObj1.addOperation(name='removeNoise') | |
80 | opObj12.addParameter(name='mode', value='2', format='int') |
|
80 | opObj12.addParameter(name='mode', value='2', format='int') | |
81 | opObj12 = procUnitConfObj1.addOperation(name='calculateNormFactor') |
|
81 | opObj12 = procUnitConfObj1.addOperation(name='calculateNormFactor') | |
82 |
|
82 | |||
83 | opObj12 = procUnitConfObj1.addOperation(name='CorrelationPlot', optype='other') |
|
83 | opObj12 = procUnitConfObj1.addOperation(name='CorrelationPlot', optype='other') | |
84 | opObj12.addParameter(name='id', value='2', format='int') |
|
84 | opObj12.addParameter(name='id', value='2', format='int') | |
85 | opObj12.addParameter(name='wintitle', value='CrossCorrelation Plot', format='str') |
|
85 | opObj12.addParameter(name='wintitle', value='CrossCorrelation Plot', format='str') | |
86 | opObj12.addParameter(name='save', value='1', format='bool') |
|
86 | opObj12.addParameter(name='save', value='1', format='bool') | |
87 | opObj12.addParameter(name='zmin', value='0', format='int') |
|
87 | opObj12.addParameter(name='zmin', value='0', format='int') | |
88 | opObj12.addParameter(name='zmax', value='1', format='int') |
|
88 | opObj12.addParameter(name='zmax', value='1', format='int') | |
89 | opObj12.addParameter(name='figpath', value = pathFigure, format='str') |
|
89 | opObj12.addParameter(name='figpath', value = pathFigure, format='str') | |
90 |
|
90 | |||
91 | #--------------------------------------------------------------------------------------------------- |
|
91 | #--------------------------------------------------------------------------------------------------- | |
92 | procUnitConfObj2 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj1.getId()) |
|
92 | procUnitConfObj2 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj1.getId()) | |
93 | opObj20 = procUnitConfObj2.addOperation(name='GetLags') |
|
93 | opObj20 = procUnitConfObj2.addOperation(name='GetLags') | |
94 |
|
94 | |||
95 | opObj21 = procUnitConfObj2.addOperation(name='WindProfiler', optype='other') |
|
95 | opObj21 = procUnitConfObj2.addOperation(name='WindProfiler', optype='other') | |
96 | opObj21.addParameter(name='technique', value='SA', format='str') |
|
96 | opObj21.addParameter(name='technique', value='SA', format='str') | |
97 | # opObj21.addParameter(name='correctFactor', value='-1', format='float') |
|
97 | # opObj21.addParameter(name='correctFactor', value='-1', format='float') | |
98 | opObj21.addParameter(name='positionX', value='36,0,36,0', format='floatlist') |
|
98 | opObj21.addParameter(name='positionX', value='36,0,36,0', format='floatlist') | |
99 | opObj21.addParameter(name='positionY', value='36,0,0,36', format='floatlist') |
|
99 | opObj21.addParameter(name='positionY', value='36,0,0,36', format='floatlist') | |
100 | opObj21.addParameter(name='azimuth', value='51.06', format='float') |
|
100 | opObj21.addParameter(name='azimuth', value='51.06', format='float') | |
101 | opObj21.addParameter(name='crosspairsList', value='(0,3),(0,2),(1,3),(1,2),(0,1),(2,3)', format='pairsList')#COrregir |
|
101 | opObj21.addParameter(name='crosspairsList', value='(0,3),(0,2),(1,3),(1,2),(0,1),(2,3)', format='pairsList')#COrregir | |
102 | # |
|
102 | # | |
103 | opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other') |
|
103 | opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other') | |
104 | opObj22.addParameter(name='id', value='4', format='int') |
|
104 | opObj22.addParameter(name='id', value='4', format='int') | |
105 | opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str') |
|
105 | opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str') | |
106 | opObj22.addParameter(name='save', value='1', format='bool') |
|
106 | opObj22.addParameter(name='save', value='1', format='bool') | |
107 | opObj22.addParameter(name='figpath', value = pathFigure, format='str') |
|
107 | opObj22.addParameter(name='figpath', value = pathFigure, format='str') | |
108 | opObj22.addParameter(name='zmin', value='-15', format='int') |
|
108 | opObj22.addParameter(name='zmin', value='-15', format='int') | |
109 | opObj22.addParameter(name='zmax', value='15', format='int') |
|
109 | opObj22.addParameter(name='zmax', value='15', format='int') | |
110 | opObj22.addParameter(name='zmin_ver', value='-80', format='float') |
|
110 | opObj22.addParameter(name='zmin_ver', value='-80', format='float') | |
111 | opObj22.addParameter(name='zmax_ver', value='80', format='float') |
|
111 | opObj22.addParameter(name='zmax_ver', value='80', format='float') | |
112 | opObj22.addParameter(name='SNRmin', value='-20', format='int') |
|
112 | opObj22.addParameter(name='SNRmin', value='-20', format='int') | |
113 | opObj22.addParameter(name='SNRmax', value='40', format='int') |
|
113 | opObj22.addParameter(name='SNRmax', value='40', format='int') | |
114 | opObj22.addParameter(name='SNRthresh', value='-3.5', format='float') |
|
114 | opObj22.addParameter(name='SNRthresh', value='-3.5', format='float') | |
115 | opObj22.addParameter(name='xmin', value=xmin, format='float') |
|
115 | opObj22.addParameter(name='xmin', value=xmin, format='float') | |
116 | opObj22.addParameter(name='xmax', value=xmax, format='float') |
|
116 | opObj22.addParameter(name='xmax', value=xmax, format='float') | |
117 | # #----------------------------------------------------------------------------------- |
|
117 | # #----------------------------------------------------------------------------------- | |
118 | # |
|
118 | # | |
119 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) |
|
119 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |
120 | # procUnitConfObj2.addParameter(name='nFFTPoints', value='128', format='int') |
|
120 | # procUnitConfObj2.addParameter(name='nFFTPoints', value='128', format='int') | |
121 | # procUnitConfObj2.addParameter(name='nProfiles', value='128', format='int') |
|
121 | # procUnitConfObj2.addParameter(name='nProfiles', value='128', format='int') | |
122 | # procUnitConfObj2.addParameter(name='pairsList', value='(0,0),(0,1),(2,1)', format='pairsList') |
|
122 | # procUnitConfObj2.addParameter(name='pairsList', value='(0,0),(0,1),(2,1)', format='pairsList') | |
123 | # |
|
123 | # | |
124 | # opObj22 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='other') |
|
124 | # opObj22 = procUnitConfObj2.addOperation(name='SpectraPlot', optype='other') | |
125 | # opObj22.addParameter(name='id', value='5', format='int') |
|
125 | # opObj22.addParameter(name='id', value='5', format='int') | |
126 | # opObj22.addParameter(name='wintitle', value='Spectra Plot', format='str') |
|
126 | # opObj22.addParameter(name='wintitle', value='Spectra Plot', format='str') | |
127 | # opObj22.addParameter(name='save', value='1', format='bool') |
|
127 | # opObj22.addParameter(name='save', value='1', format='bool') | |
128 | # opObj22.addParameter(name='figpath', value = pathFigure, format='str') |
|
128 | # opObj22.addParameter(name='figpath', value = pathFigure, format='str') | |
129 |
|
129 | |||
130 | #----------------------------------------------------------------------------------- |
|
130 | #----------------------------------------------------------------------------------- | |
131 |
|
131 | |||
132 | print "Escribiendo el archivo XML" |
|
132 | print "Escribiendo el archivo XML" | |
133 | controllerObj.writeXml(filename) |
|
133 | controllerObj.writeXml(filename) | |
134 | print "Leyendo el archivo XML" |
|
134 | print "Leyendo el archivo XML" | |
135 | controllerObj.readXml(filename) |
|
135 | controllerObj.readXml(filename) | |
136 |
|
136 | |||
137 | controllerObj.createObjects() |
|
137 | controllerObj.createObjects() | |
138 | controllerObj.connectObjects() |
|
138 | controllerObj.connectObjects() | |
139 | controllerObj.run() No newline at end of file |
|
139 | controllerObj.run() |
General Comments 0
You need to be logged in to leave comments.
Login now