##// END OF EJS Templates
algunos cambios en roj
José Chávez -
r953:234bf6b7b969
parent child
Show More
@@ -0,0 +1,6
1 [Desktop Entry]
2 Encoding=UTF-8
3 Name=Link to
4 Type=Link
5 URL=file:///home/nanosat/schain/schainpy/utils/parameters.txt
6 Icon=text-plain
This diff has been collapsed as it changes many lines, (1160 lines changed) Show them Hide them
@@ -0,0 +1,1160
1 You should install "digital_rf_hdf5" module if you want to read USRP data
2 BeaconPhase
3 parameters = {
4 'id': 'string',
5 'wintitle': 'string',
6 'pairsList': 'pairsList',
7 'showprofile': 'boolean',
8 'xmin': 'float',
9 'xmax': 'float',
10 'ymin': 'float',
11 'ymax': 'float',
12 'hmin': 'float',
13 'hmax': 'float',
14 'timerange': 'float',
15 'save': 'boolean',
16 'figpath': 'string',
17 'figfile': 'string',
18 'show': 'boolean',
19 'ftp': 'boolean',
20 'wr_period': 'int',
21 'server': 'string',
22 'folder': 'string',
23 'username': 'string',
24 'password': 'string',
25 'ftp_wei': 'int',
26 'exp_code': 'int',
27 'sub_exp_code': 'int',
28 'plot_pos': 'int',
29 }
30
31
32 BeamSelector
33 parameters = {
34 'beam': 'string',
35 }
36
37
38 CohInt
39 parameters = {
40 'n': 'int',
41 'timeInterval': 'float',
42 'overlapping': 'boolean',
43 'byblock': 'boolean'
44 }
45
46
47 CoherenceMap
48 parameters = {
49 'id': 'string',
50 'wintitle': 'string',
51 'pairsList': 'pairsLists',
52 'showprofile': 'boolean',
53 'xmin': 'float',
54 'xmax': 'float',
55 'ymin': 'float',
56 'ymax': 'float',
57 'zmin': 'float',
58 'zmax': 'float',
59 'timerange': 'float',
60 'phase_min': 'float',
61 'phase_max': 'float',
62 'save': 'boolean',
63 'figpath': 'string',
64 'figfile': 'string',
65 'ftp': 'boolean',
66 'wr_period': 'int',
67 'coherence_cmap': 'colormap',
68 'phase_cmap': 'colormap',
69 'show': 'boolean',
70 'server': 'string',
71 'folder': 'string',
72 'username': 'string',
73 'password': 'string',
74 'ftp_wei': 'int',
75 'exp_code': 'int',
76 'sub_exp_code': 'int',
77 'plot_pos': 'int',
78 }
79
80
81 CombineProfiles
82 parameters = {
83 'n': 'int',
84 }
85
86
87 CorrectSMPhases
88 parameters = {
89 'phaseOffsets': 'pairsLists',
90 'hmin': 'float',
91 'hmax': 'float',
92 'azimuth': 'string',
93 'channelPositions': 'string',
94 }
95
96
97 CorrelationPlot
98 parameters = {
99 'id': 'string',
100 'wintitle': 'string',
101 'channelList': 'string',
102 'showprofile': 'string',
103 'xmin': 'float',
104 'xmax': 'float',
105 'ymin': 'float',
106 'ymax': 'float',
107 'zmin': 'float',
108 'zmax': 'float',
109 'save': 'boolean',
110 'figpath': 'string',
111 'figfile': 'string',
112 'show': 'boolean',
113 'ftp': 'boolean',
114 'wr_period': 'int',
115 'server': 'string',
116 'folder': 'string',
117 'username': 'string',
118 'password': 'string',
119 'ftp_wei': 'string',
120 'exp_code': 'int',
121 'sub_exp_code': 'int',
122 'plot_pos': 'int',
123 'realtime': 'string',
124 }
125
126
127 CrossSpectraPlot
128 parameters = {
129 'id': 'string',
130 'wintitle': 'string',
131 'pairsList': 'pairsLists',
132 'xmin': 'float',
133 'xmax': 'float',
134 'ymin': 'float',
135 'ymax': 'float',
136 'zmin': 'float',
137 'zmax': 'float',
138 'coh_min': 'string',
139 'coh_max': 'string',
140 'phase_min': 'string',
141 'phase_max': 'string',
142 'save': 'boolean',
143 'figpath': 'string',
144 'figfile': 'string',
145 'ftp': 'boolean',
146 'wr_period': 'int',
147 'power_cmap': 'string',
148 'coherence_cmap': 'string',
149 'phase_cmap': 'string',
150 'show': 'string',
151 'server': 'string',
152 'folder': 'string',
153 'username': 'string',
154 'password': 'string',
155 'ftp_wei': 'string',
156 'exp_code': 'int',
157 'sub_exp_code': 'int',
158 'plot_pos': 'int',
159 'xaxis': 'string',
160 }
161
162
163 Decoder
164 parameters = {
165 'code': 'string',
166 'nCode': 'string',
167 'nBaud': 'string',
168 'mode': 'string',
169 'osamp': 'string',
170 'times': 'string',
171 }
172
173
174 EWDriftsEstimation
175 parameters = {
176 'zenith': 'string',
177 'zenithCorrection': 'string',
178 }
179
180
181 EWDriftsPlot
182 parameters = {
183 'id': 'string',
184 'wintitle': 'string',
185 'channelList': 'string',
186 'xmin': 'float',
187 'xmax': 'float',
188 'ymin': 'float',
189 'ymax': 'float',
190 'zmin': 'float',
191 'zmax': 'float',
192 'zmaxVertfloat 'string',
193 'zminVertfloat 'string',
194 'zmaxZonafloattring',
195 'zminZonafloattring',
196 'timerange': 'string',
197 'SNRthresh': 'string',
198 'SNRmin': 'string',
199 'SNRmax': 'string',
200 'SNR_1': 'string',
201 'save': 'boolean',
202 'figpath': 'string',
203 'lastone': 'string',
204 'figfile': 'string',
205 'ftp': 'string',
206 'wr_period': 'int',
207 'show': 'string',
208 'server': 'string',
209 'folder': 'string',
210 'username': 'string',
211 'password': 'string',
212 'ftp_wei': 'string',
213 'exp_code': 'int',
214 'sub_exp_code': 'int',
215 'plot_pos': 'int',
216 }
217
218
219 Figure
220 parameters = {
221 : 'string',
222 }
223
224
225 FitsWriter
226 parameters = {
227 : 'string',
228 }
229
230
231 IncohInt
232 parameters = {
233 'n': 'string',
234 'timeInterval': 'string',
235 'overlapping': 'string',
236 }
237
238
239 IncohInt4SpectraHeis
240 parameters = {
241 : 'string',
242 }
243
244
245 MomentsPlot
246 parameters = {
247 'id': 'string',
248 'wintitle': 'string',
249 'channelList': 'string',
250 'showprofile': 'string',
251 'xmin': 'float',
252 'xmax': 'float',
253 'ymin': 'float',
254 'ymax': 'float',
255 'zmin': 'float',
256 'zmax': 'float',
257 'save': 'boolean',
258 'figpath': 'string',
259 'figfile': 'string',
260 'show': 'string',
261 'ftp': 'string',
262 'wr_period': 'int',
263 'server': 'string',
264 'folder': 'string',
265 'username': 'string',
266 'password': 'string',
267 'ftp_wei': 'string',
268 'exp_code': 'int',
269 'sub_exp_code': 'int',
270 'plot_pos': 'int',
271 'realtime': 'string',
272 }
273
274
275 NSMeteorDetection1Plot
276 parameters = {
277 'id': 'string',
278 'wintitle': 'string',
279 'channelList': 'string',
280 'showprofile': 'string',
281 'xmin': 'float',
282 'xmax': 'float',
283 'ymin': 'float',
284 'ymax': 'float',
285 'SNRmin': 'string',
286 'SNRmax': 'string',
287 'vmin': 'string',
288 'vmax': 'string',
289 'wmin': 'string',
290 'wmax': 'string',
291 'mode': 'string',
292 'save': 'boolean',
293 'figpath': 'string',
294 'figfile': 'string',
295 'show': 'string',
296 'ftp': 'string',
297 'wr_period': 'int',
298 'server': 'string',
299 'folder': 'string',
300 'username': 'string',
301 'password': 'string',
302 'ftp_wei': 'string',
303 'exp_code': 'int',
304 'sub_exp_code': 'int',
305 'plot_pos': 'int',
306 'realtime': 'string',
307 'xaxis': 'string',
308 }
309
310
311 NSMeteorDetection2Plot
312 parameters = {
313 'id': 'string',
314 'wintitle': 'string',
315 'channelList': 'string',
316 'showprofile': 'string',
317 'xmin': 'float',
318 'xmax': 'float',
319 'ymin': 'float',
320 'ymax': 'float',
321 'SNRmin': 'string',
322 'SNRmax': 'string',
323 'vmin': 'string',
324 'vmax': 'string',
325 'wmin': 'string',
326 'wmax': 'string',
327 'mode': 'string',
328 'save': 'boolean',
329 'figpath': 'string',
330 'figfile': 'string',
331 'show': 'string',
332 'ftp': 'string',
333 'wr_period': 'int',
334 'server': 'string',
335 'folder': 'string',
336 'username': 'string',
337 'password': 'string',
338 'ftp_wei': 'string',
339 'exp_code': 'int',
340 'sub_exp_code': 'int',
341 'plot_pos': 'int',
342 'realtime': 'string',
343 'xaxis': 'string',
344 }
345
346
347 Noise
348 parameters = {
349 'id': 'string',
350 'wintitle': 'string',
351 'channelList': 'string',
352 'showprofile': 'string',
353 'xmin': 'float',
354 'xmax': 'float',
355 'ymin': 'float',
356 'ymax': 'float',
357 'timerange': 'string',
358 'save': 'boolean',
359 'figpath': 'string',
360 'figfile': 'string',
361 'show': 'string',
362 'ftp': 'string',
363 'wr_period': 'int',
364 'server': 'string',
365 'folder': 'string',
366 'username': 'string',
367 'password': 'string',
368 'ftp_wei': 'string',
369 'exp_code': 'int',
370 'sub_exp_code': 'int',
371 'plot_pos': 'int',
372 }
373
374
375 NonSpecularMeteorDetection
376 parameters = {
377 'mode': 'string',
378 'SNRthresh': 'string',
379 'phaseDerThresh': 'string',
380 'cohThresh': 'string',
381 'allData': 'string',
382 }
383
384
385 Operation
386 parameters = {
387 'dataIn': 'string',
388 }
389
390
391 ParamWriter
392 parameters = {
393 : 'string',
394 }
395
396
397 Parameters1Plot
398 parameters = {
399 'id': 'string',
400 'wintitle': 'string',
401 'channelList': 'string',
402 'showprofile': 'string',
403 'xmin': 'float',
404 'xmax': 'float',
405 'ymin': 'float',
406 'ymax': 'float',
407 'zmin': 'float',
408 'zmax': 'float',
409 'timerange': 'string',
410 'parameterIndex': 'string',
411 'onlyPositive': 'string',
412 'SNRthresh': 'string',
413 'SNR': 'string',
414 'SNRmin': 'string',
415 'SNRmax': 'string',
416 'onlySNR': 'string',
417 'DOP': 'string',
418 'zlabel': 'string',
419 'parameterName': 'string',
420 'parameterObject': 'string',
421 'save': 'boolean',
422 'figpath': 'string',
423 'lastone': 'string',
424 'figfile': 'string',
425 'ftp': 'string',
426 'wr_period': 'int',
427 'show': 'string',
428 'server': 'string',
429 'folder': 'string',
430 'username': 'string',
431 'password': 'string',
432 'ftp_wei': 'string',
433 'exp_code': 'int',
434 'sub_exp_code': 'int',
435 'plot_pos': 'int',
436 }
437
438
439 ParametersPlot
440 parameters = {
441 'id': 'string',
442 'wintitle': 'string',
443 'channelList': 'string',
444 'paramIndex': 'string',
445 'colormap': 'string',
446 'xmin': 'float',
447 'xmax': 'float',
448 'ymin': 'float',
449 'ymax': 'float',
450 'zmin': 'float',
451 'zmax': 'float',
452 'timerange': 'string',
453 'showSNR': 'string',
454 'SNRthresh': 'string',
455 'SNRmin': 'string',
456 'SNRmax': 'string',
457 'save': 'boolean',
458 'figpath': 'string',
459 'lastone': 'string',
460 'figfile': 'string',
461 'ftp': 'string',
462 'wr_period': 'int',
463 'show': 'string',
464 'server': 'string',
465 'folder': 'string',
466 'username': 'string',
467 'password': 'string',
468 'ftp_wei': 'string',
469 'exp_code': 'int',
470 'sub_exp_code': 'int',
471 'plot_pos': 'int',
472 }
473
474
475 PhasePlot
476 parameters = {
477 'id': 'string',
478 'wintitle': 'string',
479 'pairsList': 'pairsLists',
480 'showprofile': 'string',
481 'xmin': 'float',
482 'xmax': 'float',
483 'ymin': 'float',
484 'ymax': 'float',
485 'timerange': 'string',
486 'save': 'boolean',
487 'figpath': 'string',
488 'figfile': 'string',
489 'show': 'string',
490 'ftp': 'string',
491 'wr_period': 'int',
492 'server': 'string',
493 'folder': 'string',
494 'username': 'string',
495 'password': 'string',
496 'ftp_wei': 'string',
497 'exp_code': 'int',
498 'sub_exp_code': 'int',
499 'plot_pos': 'int',
500 }
501
502
503 PlotCOHData
504 parameters = {
505 : 'string',
506 }
507
508
509 PlotCrossSpectraData
510 parameters = {
511 : 'string',
512 }
513
514
515 PlotDOPData
516 parameters = {
517 : 'string',
518 }
519
520
521 PlotData
522 parameters = {
523 : 'string',
524 }
525
526
527 PlotNoiseData
528 parameters = {
529 : 'string',
530 }
531
532
533 PlotPHASEData
534 parameters = {
535 : 'string',
536 }
537
538
539 PlotRTIData
540 parameters = {
541 : 'string',
542 }
543
544
545 PlotSNRData
546 parameters = {
547 : 'string',
548 }
549
550
551 PlotSpectraData
552 parameters = {
553 : 'string',
554 }
555
556
557 PlotSpectraMeanData
558 parameters = {
559 : 'string',
560 }
561
562
563 PlotWindProfilerData
564 parameters = {
565 : 'string',
566 }
567
568
569 PowerProfilePlot
570 parameters = {
571 'id': 'string',
572 'wintitle': 'string',
573 'channelList': 'string',
574 'xmin': 'float',
575 'xmax': 'float',
576 'ymin': 'float',
577 'ymax': 'float',
578 'save': 'boolean',
579 'figpath': 'string',
580 'figfile': 'string',
581 'show': 'string',
582 'ftp': 'string',
583 'wr_period': 'int',
584 'server': 'string',
585 'folder': 'string',
586 'username': 'string',
587 'password': 'string',
588 }
589
590
591 PrintInfo
592 parameters = {
593 : 'string',
594 }
595
596
597 ProfileConcat
598 parameters = {
599 'm': 'string',
600 }
601
602
603 ProfileSelector
604 parameters = {
605 'profileList': 'string',
606 'profileRangeList': 'string',
607 'beam': 'string',
608 'byblock': 'string',
609 'rangeList': 'string',
610 'nProfiles': 'string',
611 }
612
613
614 ProfileToChannels
615 parameters = {
616 : 'string',
617 }
618
619
620 PublishData
621 parameters = {
622 : 'string',
623 }
624
625
626 RTIPlot
627 parameters = {
628 'id': 'string',
629 'wintitle': 'string',
630 'channelList': 'string',
631 'showprofile': 'string',
632 'xmin': 'float',
633 'xmax': 'float',
634 'ymin': 'float',
635 'ymax': 'float',
636 'zmin': 'float',
637 'zmax': 'float',
638 'timerange': 'string',
639 'save': 'boolean',
640 'figpath': 'string',
641 'lastone': 'string',
642 'figfile': 'string',
643 'ftp': 'string',
644 'wr_period': 'int',
645 'show': 'string',
646 'server': 'string',
647 'folder': 'string',
648 'username': 'string',
649 'password': 'string',
650 'ftp_wei': 'string',
651 'exp_code': 'int',
652 'sub_exp_code': 'int',
653 'plot_pos': 'int',
654 }
655
656
657 RTIfromSpectraHeis
658 parameters = {
659 'id': 'string',
660 'wintitle': 'string',
661 'channelList': 'string',
662 'showprofile': 'string',
663 'xmin': 'float',
664 'xmax': 'float',
665 'ymin': 'float',
666 'ymax': 'float',
667 'timerange': 'string',
668 'save': 'boolean',
669 'figpath': 'string',
670 'figfile': 'string',
671 'ftp': 'string',
672 'wr_period': 'int',
673 'show': 'string',
674 'server': 'string',
675 'folder': 'string',
676 'username': 'string',
677 'password': 'string',
678 'ftp_wei': 'string',
679 'exp_code': 'int',
680 'sub_exp_code': 'int',
681 'plot_pos': 'int',
682 }
683
684
685 Reshaper
686 parameters = {
687 'shape': 'string',
688 'nTxs': 'string',
689 }
690
691
692 SALags
693 parameters = {
694 : 'string',
695 }
696
697
698 SMDetection
699 parameters = {
700 'hei_ref': 'string',
701 'tauindex': 'string',
702 'phaseOffsets': 'string',
703 'cohDetection': 'string',
704 'cohDet_timeStep': 'string',
705 'cohDet_thresh': 'string',
706 'noise_timeStep': 'string',
707 'noise_multiple': 'string',
708 'multDet_timeLimit': 'string',
709 'multDet_rangeLimit': 'string',
710 'phaseThresh': 'string',
711 'SNRThresh': 'string',
712 'hmin': 'string',
713 'hmax': 'string',
714 'azimuth': 'string',
715 'channelPositions': 'string',
716 }
717
718
719 SMPhaseCalibration
720 parameters = {
721 'hmin': 'string',
722 'hmax': 'string',
723 'channelPositions': 'string',
724 'nHours': 'string',
725 }
726
727
728 Scope
729 parameters = {
730 'id': 'string',
731 'wintitle': 'string',
732 'channelList': 'string',
733 'xmin': 'float',
734 'xmax': 'float',
735 'ymin': 'float',
736 'ymax': 'float',
737 'save': 'boolean',
738 'figpath': 'string',
739 'figfile': 'string',
740 'show': 'string',
741 'wr_period': 'int',
742 'ftp': 'string',
743 'server': 'string',
744 'folder': 'string',
745 'username': 'string',
746 'password': 'string',
747 'type': 'string',
748 }
749
750
751 SendByFTP
752 parameters = {
753 'ext': 'string',
754 'localfolder': 'string',
755 'remotefolder': 'string',
756 'server': 'string',
757 'username': 'string',
758 'password': 'string',
759 'period': 'string',
760 }
761
762
763 SkyMapPlot
764 parameters = {
765 'id': 'string',
766 'wintitle': 'string',
767 'channelList': 'string',
768 'showprofile': 'string',
769 'tmin': 'string',
770 'tmax': 'string',
771 'timerange': 'string',
772 'save': 'boolean',
773 'figpath': 'string',
774 'figfile': 'string',
775 'show': 'string',
776 'ftp': 'string',
777 'wr_period': 'int',
778 'server': 'string',
779 'folder': 'string',
780 'username': 'string',
781 'password': 'string',
782 'ftp_wei': 'string',
783 'exp_code': 'int',
784 'sub_exp_code': 'int',
785 'plot_pos': 'int',
786 'realtime': 'string',
787 }
788
789
790 SpectraCutPlot
791 parameters = {
792 'id': 'string',
793 'wintitle': 'string',
794 'channelList': 'string',
795 'xmin': 'float',
796 'xmax': 'float',
797 'ymin': 'float',
798 'ymax': 'float',
799 'save': 'boolean',
800 'figpath': 'string',
801 'figfile': 'string',
802 'show': 'string',
803 'ftp': 'string',
804 'wr_period': 'int',
805 'server': 'string',
806 'folder': 'string',
807 'username': 'string',
808 'password': 'string',
809 'xaxis': 'string',
810 }
811
812
813 SpectraHeisScope
814 parameters = {
815 'id': 'string',
816 'wintitle': 'string',
817 'channelList': 'string',
818 'xmin': 'float',
819 'xmax': 'float',
820 'ymin': 'float',
821 'ymax': 'float',
822 'save': 'boolean',
823 'figpath': 'string',
824 'figfile': 'string',
825 'ftp': 'string',
826 'wr_period': 'int',
827 'show': 'string',
828 'server': 'string',
829 'folder': 'string',
830 'username': 'string',
831 'password': 'string',
832 'ftp_wei': 'string',
833 'exp_code': 'int',
834 'sub_exp_code': 'int',
835 'plot_pos': 'int',
836 }
837
838
839 SpectraHeisWriter
840 parameters = {
841 : 'string',
842 }
843
844
845 SpectraPlot
846 parameters = {
847 'id': 'string',
848 'wintitle': 'string',
849 'channelList': 'string',
850 'showprofile': 'string',
851 'xmin': 'float',
852 'xmax': 'float',
853 'ymin': 'float',
854 'ymax': 'float',
855 'zmin': 'float',
856 'zmax': 'float',
857 'save': 'boolean',
858 'figpath': 'string',
859 'figfile': 'string',
860 'show': 'string',
861 'ftp': 'string',
862 'wr_period': 'int',
863 'server': 'string',
864 'folder': 'string',
865 'username': 'string',
866 'password': 'string',
867 'ftp_wei': 'string',
868 'exp_code': 'int',
869 'sub_exp_code': 'int',
870 'plot_pos': 'int',
871 'realtime': 'string',
872 'xaxis': 'string',
873 }
874
875
876 SpectraWriter
877 parameters = {
878 'path': 'string',
879 'blocksPerFile': 'string',
880 'profilesPerBlock': 'string',
881 'set': 'string',
882 'ext': 'string',
883 'datatype': 'string',
884 }
885
886
887 SpectralFitting
888 parameters = {
889 'getSNR': 'string',
890 'path': 'string',
891 'file': 'string',
892 'groupList': 'string',
893 }
894
895
896 SpectralFittingPlot
897 parameters = {
898 'id': 'string',
899 'cutHeight': 'string',
900 'fit': 'string',
901 'wintitle': 'string',
902 'channelList': 'string',
903 'showprofile': 'string',
904 'xmin': 'float',
905 'xmax': 'float',
906 'ymin': 'float',
907 'ymax': 'float',
908 'save': 'boolean',
909 'figpath': 'string',
910 'figfile': 'string',
911 'show': 'string',
912 }
913
914
915 SpectralMoments
916 parameters = {
917 : 'string',
918 }
919
920
921 SplitProfiles
922 parameters = {
923 'n': 'string',
924 }
925
926
927 USRPWriter
928 parameters = {
929 'dataIn': 'string',
930 }
931
932
933 VoltageWriter
934 parameters = {
935 'path': 'string',
936 'blocksPerFile': 'string',
937 'profilesPerBlock': 'string',
938 'set': 'string',
939 'ext': 'string',
940 'datatype': 'string',
941 }
942
943
944 WindProfiler
945 parameters = {
946 'technique': 'string',
947 }
948
949
950 WindProfilerPlot
951 parameters = {
952 'id': 'string',
953 'wintitle': 'string',
954 'channelList': 'string',
955 'showprofile': 'string',
956 'xmin': 'float',
957 'xmax': 'float',
958 'ymin': 'float',
959 'ymax': 'float',
960 'zmin': 'float',
961 'zmax': 'float',
962 'zmax_ver': 'string',
963 'zmin_ver': 'string',
964 'SNRmin': 'string',
965 'SNRmax': 'string',
966 'timerange': 'string',
967 'SNRthresh': 'string',
968 'save': 'boolean',
969 'figpath': 'string',
970 'lastone': 'string',
971 'figfile': 'string',
972 'ftp': 'string',
973 'wr_period': 'int',
974 'show': 'string',
975 'server': 'string',
976 'folder': 'string',
977 'username': 'string',
978 'password': 'string',
979 'ftp_wei': 'string',
980 'exp_code': 'int',
981 'sub_exp_code': 'int',
982 'plot_pos': 'int',
983 }
984
985
986 Writer
987 parameters = {
988 'dataIn': 'string',
989 }
990
991
992 AMISRProc
993 parameters = {
994 : 'string',
995 }
996
997
998 AMISRReader
999 parameters = {
1000 : 'string',
1001 }
1002
1003
1004 CorrelationProc
1005 parameters = {
1006 'lags': 'string',
1007 'mode': 'string',
1008 'pairsList': 'pairsLists',
1009 'fullBuffer': 'string',
1010 'nAvg': 'string',
1011 'removeDC': 'string',
1012 'splitCF': 'string',
1013 }
1014
1015
1016 FitsReader
1017 parameters = {
1018 : 'string',
1019 }
1020
1021
1022 HFReader
1023 parameters = {
1024 : 'string',
1025 }
1026
1027
1028 ParamReader
1029 parameters = {
1030 : 'string',
1031 }
1032
1033
1034 ParametersProc
1035 parameters = {
1036 : 'string',
1037 }
1038
1039
1040 ProcessingUnit
1041 parameters = {
1042 : 'string',
1043 }
1044
1045
1046 ReceiverData
1047 parameters = {
1048 : 'string',
1049 }
1050
1051
1052 SendToServer
1053 parameters = {
1054 : 'string',
1055 }
1056
1057
1058 SpectraAFCProc
1059 parameters = {
1060 'nProfiles': 'string',
1061 'nFFTPoints': 'string',
1062 'pairsList': 'pairsLists',
1063 'code': 'string',
1064 'nCode': 'string',
1065 'nBaud': 'string',
1066 }
1067
1068
1069 SpectraHeisProc
1070 parameters = {
1071 : 'string',
1072 }
1073
1074
1075 SpectraLagsProc
1076 parameters = {
1077 'nProfiles': 'string',
1078 'nFFTPoints': 'string',
1079 'pairsList': 'pairsLists',
1080 'code': 'string',
1081 'nCode': 'string',
1082 'nBaud': 'string',
1083 'codeFromHeader': 'string',
1084 'pulseIndex': 'string',
1085 }
1086
1087
1088 SpectraProc
1089 parameters = {
1090 'nProfiles': 'string',
1091 'nFFTPoints': 'string',
1092 'pairsList': 'pairsLists',
1093 'ippFactor': 'string',
1094 }
1095
1096
1097 SpectraReader
1098 parameters = {
1099 'path': 'string',
1100 'startDate': 'string',
1101 'endDate': 'string',
1102 'startTime': 'string',
1103 'endTime': 'string',
1104 'set': 'string',
1105 'expLabel': 'string',
1106 'ext': 'string',
1107 'online': 'string',
1108 'delay': 'string',
1109 'walk': 'string',
1110 'getblock': 'string',
1111 'nTxs': 'string',
1112 'realtime': 'string',
1113 'blocksize': 'string',
1114 'blocktime': 'string',
1115 'queue': 'string',
1116 'skip': 'string',
1117 'cursor': 'string',
1118 'warnings': 'string',
1119 'verbose': 'string',
1120 }
1121
1122
1123 USRPReader
1124 parameters = {
1125 : 'string',
1126 }
1127
1128
1129 VoltageProc
1130 parameters = {
1131 : 'string',
1132 }
1133
1134
1135 VoltageReader
1136 parameters = {
1137 'path': 'string',
1138 'startDate': 'string',
1139 'endDate': 'string',
1140 'startTime': 'string',
1141 'endTime': 'string',
1142 'set': 'string',
1143 'expLabel': 'string',
1144 'ext': 'string',
1145 'online': 'string',
1146 'delay': 'string',
1147 'walk': 'string',
1148 'getblock': 'string',
1149 'nTxs': 'string',
1150 'realtime': 'string',
1151 'blocksize': 'string',
1152 'blocktime': 'string',
1153 'queue': 'string',
1154 'skip': 'string',
1155 'cursor': 'string',
1156 'warnings': 'string',
1157 'verbose': 'string',
1158 }
1159
1160
@@ -0,0 +1,81
1 import schainpy
2 from schainpy.model import Operation, ProcessingUnit
3 from importlib import import_module
4 from pydoc import locate
5
6 def clean_modules(module):
7 noEndsUnder = [x for x in module if not x.endswith('__')]
8 noStartUnder = [x for x in noEndsUnder if not x.startswith('__')]
9 noFullUpper = [x for x in noStartUnder if not x.isupper()]
10 return noFullUpper
11
12 def check_module(possible, instance):
13 def check(x):
14 try:
15 instancia = locate('schainpy.model.{}'.format(x))
16 return isinstance(instancia(), instance)
17 except Exception as e:
18 return False
19 clean = clean_modules(possible)
20 return [x for x in clean if check(x)]
21
22
23 def getProcs():
24 module = dir(import_module('schainpy.model'))
25 procs = check_module(module, ProcessingUnit)
26 try:
27 procs.remove('ProcessingUnit')
28 except Exception as e:
29 pass
30 return procs
31
32 def getOperations():
33 module = dir(import_module('schainpy.model'))
34 noProcs = [x for x in module if not x.endswith('Proc')]
35 operations = check_module(noProcs, Operation)
36 try:
37 operations.remove('Operation')
38 except Exception as e:
39 pass
40 return operations
41
42 def getArgs(op):
43 module = locate('schainpy.model.{}'.format(op))
44 args = module().getAllowedArgs()
45 try:
46 args.remove('self')
47 except Exception as e:
48 pass
49 try:
50 args.remove('dataOut')
51 except Exception as e:
52 pass
53 return args
54
55 def getAll():
56 allModules = dir(import_module('schainpy.model'))
57 modules = check_module(allModules, Operation)
58 modules.extend(check_module(allModules, ProcessingUnit))
59 return modules
60
61 def formatArgs(op):
62 args = getArgs(op)
63
64 argsAsKey = ["\t'{}'".format(x) for x in args]
65 argsFormatted = ": 'string',\n".join(argsAsKey)
66
67 print op
68 print "parameters = { \n" + argsFormatted + ": 'string',\n }"
69 print '\n'
70
71
72 if __name__ == "__main__":
73 getAll()
74 [formatArgs(x) for x in getAll()]
75
76 '''
77 parameters = {
78 'id': ,
79 'wintitle': ,
80 }
81 ''' No newline at end of file
@@ -0,0 +1,1
1 You should install "digital_rf_hdf5" module if you want to read USRP data
@@ -1,188 +1,167
1 import click
1 import click
2 import schainpy
2 import schainpy
3 import subprocess
3 import subprocess
4 import os
4 import os
5 import sys
5 import sys
6 import glob
6 import glob
7 save_stdout = sys.stdout
7 save_stdout = sys.stdout
8 sys.stdout = open('trash', 'w')
8 sys.stdout = open('trash', 'w')
9 from multiprocessing import cpu_count
9 from multiprocessing import cpu_count
10 from schaincli import templates
10 from schaincli import templates
11 from schainpy import controller_api
11 from schainpy import controller_api
12 from schainpy.model import Operation, ProcessingUnit
12 from schainpy.model import Operation, ProcessingUnit
13 from schainpy.utils import log
13 from schainpy.utils import log
14 from importlib import import_module
14 from importlib import import_module
15 from pydoc import locate
15 from pydoc import locate
16 from fuzzywuzzy import process
16 from fuzzywuzzy import process
17 from schainpy.utils import paramsFinder
17 sys.stdout = save_stdout
18 sys.stdout = save_stdout
18
19
19
20
20 def print_version(ctx, param, value):
21 def print_version(ctx, param, value):
21 if not value or ctx.resilient_parsing:
22 if not value or ctx.resilient_parsing:
22 return
23 return
23 click.echo(schainpy.__version__)
24 click.echo(schainpy.__version__)
24 ctx.exit()
25 ctx.exit()
25
26
26
27
27 cliLogger = log.makelogger('schain cli')
28 cliLogger = log.makelogger('schain cli')
28 PREFIX = 'experiment'
29 PREFIX = 'experiment'
29
30
30
31
31 @click.command()
32 @click.command()
32 @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str)
33 @click.option('--version', '-v', is_flag=True, callback=print_version, help='SChain version', type=str)
33 @click.option('--xml', '-x', default=None, help='run an XML file', type=click.Path(exists=True, resolve_path=True))
34 @click.option('--xml', '-x', default=None, help='run an XML file', type=click.Path(exists=True, resolve_path=True))
34 @click.argument('command', default='run', required=True)
35 @click.argument('command', default='run', required=True)
35 @click.argument('nextcommand', default=None, required=False, type=str)
36 @click.argument('nextcommand', default=None, required=False, type=str)
36 def main(command, nextcommand, version, xml):
37 def main(command, nextcommand, version, xml):
37 """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY \n
38 """COMMAND LINE INTERFACE FOR SIGNAL CHAIN - JICAMARCA RADIO OBSERVATORY \n
38 Available commands.\n
39 Available commands.\n
39 --xml: runs a schain XML generated file\n
40 --xml: runs a schain XML generated file\n
40 run: runs any python script starting 'experiment_'\n
41 run: runs any python script starting 'experiment_'\n
41 generate: generates a template schain script\n
42 generate: generates a template schain script\n
42 search: return avilable operations, procs or arguments of the give operation/proc\n"""
43 search: return avilable operations, procs or arguments of the give operation/proc\n"""
43 if xml is not None:
44 if xml is not None:
44 runFromXML(xml)
45 runFromXML(xml)
45 elif command == 'generate':
46 elif command == 'generate':
46 generate()
47 generate()
47 elif command == 'test':
48 elif command == 'test':
48 test()
49 test()
49 elif command == 'run':
50 elif command == 'run':
50 runschain(nextcommand)
51 runschain(nextcommand)
51 elif command == 'search':
52 elif command == 'search':
52 search(nextcommand)
53 search(nextcommand)
53 else:
54 else:
54 log.error('Command {} is not defined'.format(command))
55 log.error('Command {} is not defined'.format(command))
55
56
56 def check_module(possible, instance):
57 def check_module(possible, instance):
57 def check(x):
58 def check(x):
58 try:
59 try:
59 instancia = locate('schainpy.model.{}'.format(x))
60 instancia = locate('schainpy.model.{}'.format(x))
60 return isinstance(instancia(), instance)
61 return isinstance(instancia(), instance)
61 except Exception as e:
62 except Exception as e:
62 return False
63 return False
63 clean = clean_modules(possible)
64 clean = clean_modules(possible)
64 return [x for x in clean if check(x)]
65 return [x for x in clean if check(x)]
65
66
66
67
67 def clean_modules(module):
68 def clean_modules(module):
68 noEndsUnder = [x for x in module if not x.endswith('__')]
69 noEndsUnder = [x for x in module if not x.endswith('__')]
69 noStartUnder = [x for x in noEndsUnder if not x.startswith('__')]
70 noStartUnder = [x for x in noEndsUnder if not x.startswith('__')]
70 noFullUpper = [x for x in noStartUnder if not x.isupper()]
71 noFullUpper = [x for x in noStartUnder if not x.isupper()]
71 return noFullUpper
72 return noFullUpper
72
73
73
74
74 def search(nextcommand):
75 def search(nextcommand):
75 if nextcommand is None:
76 if nextcommand is None:
76 log.error('There is no Operation/ProcessingUnit to search')
77 log.error('There is no Operation/ProcessingUnit to search')
77 elif nextcommand == 'procs':
78 elif nextcommand == 'procs':
78 module = dir(import_module('schainpy.model'))
79 procs = paramsFinder.getProcs()
79 procs = check_module(module, ProcessingUnit)
80 try:
81 procs.remove('ProcessingUnit')
82 except Exception as e:
83 pass
84 log.success('Current ProcessingUnits are:\n\033[1m{}\033[0m'.format('\n'.join(procs)))
80 log.success('Current ProcessingUnits are:\n\033[1m{}\033[0m'.format('\n'.join(procs)))
85
81
86 elif nextcommand == 'operations':
82 elif nextcommand == 'operations':
87 module = dir(import_module('schainpy.model'))
83 operations = paramsFinder.getOperations()
88 noProcs = [x for x in module if not x.endswith('Proc')]
89 operations = check_module(noProcs, Operation)
90 try:
91 operations.remove('Operation')
92 except Exception as e:
93 pass
94 log.success('Current Operations are:\n\033[1m{}\033[0m'.format('\n'.join(operations)))
84 log.success('Current Operations are:\n\033[1m{}\033[0m'.format('\n'.join(operations)))
95 else:
85 else:
96 try:
86 try:
97 module = locate('schainpy.model.{}'.format(nextcommand))
87 args = paramsFinder.getArgs(nextcommand)
98 args = module().getAllowedArgs()
99 log.warning('Use this feature with caution. It may not return all the allowed arguments')
88 log.warning('Use this feature with caution. It may not return all the allowed arguments')
100 try:
101 args.remove('self')
102 except Exception as e:
103 pass
104 try:
105 args.remove('dataOut')
106 except Exception as e:
107 pass
108 if len(args) == 0:
89 if len(args) == 0:
109 log.success('{} has no arguments'.format(nextcommand))
90 log.success('{} has no arguments'.format(nextcommand))
110 else:
91 else:
111 log.success('Showing arguments of {} are:\n\033[1m{}\033[0m'.format(nextcommand, '\n'.join(args)))
92 log.success('Showing arguments of {} are:\n\033[1m{}\033[0m'.format(nextcommand, '\n'.join(args)))
112 except Exception as e:
93 except Exception as e:
113 log.error('Module {} does not exists'.format(nextcommand))
94 log.error('Module {} does not exists'.format(nextcommand))
114 allModules = dir(import_module('schainpy.model'))
95 allModules = paramsFinder.getAll()
115 module = check_module(allModules, Operation)
96 similar = process.extractOne(nextcommand, allModules)[0]
116 module.extend(check_module(allModules, ProcessingUnit))
97 log.success('Showing {} instead'.format(similar))
117 similar = process.extractOne(nextcommand, module)[0]
118 log.success('Searching {} instead'.format(similar))
119 search(similar)
98 search(similar)
120
99
121
100
122 def runschain(nextcommand):
101 def runschain(nextcommand):
123 if nextcommand is None:
102 if nextcommand is None:
124 currentfiles = glob.glob('./{}_*.py'.format(PREFIX))
103 currentfiles = glob.glob('./{}_*.py'.format(PREFIX))
125 numberfiles = len(currentfiles)
104 numberfiles = len(currentfiles)
126 if numberfiles > 1:
105 if numberfiles > 1:
127 log.error('There is more than one file to run')
106 log.error('There is more than one file to run')
128 elif numberfiles == 1:
107 elif numberfiles == 1:
129 subprocess.call(['python ' + currentfiles[0]], shell=True)
108 subprocess.call(['python ' + currentfiles[0]], shell=True)
130 else:
109 else:
131 log.error('There is no file to run')
110 log.error('There is no file to run')
132 else:
111 else:
133 try:
112 try:
134 subprocess.call(['python ' + nextcommand], shell=True)
113 subprocess.call(['python ' + nextcommand], shell=True)
135 except Exception as e:
114 except Exception as e:
136 log.error("I cannot run the file. Does it exists?")
115 log.error("I cannot run the file. Does it exists?")
137
116
138
117
139 def basicInputs():
118 def basicInputs():
140 inputs = {}
119 inputs = {}
141 inputs['desc'] = click.prompt('Enter a description', default="A schain project", type=str)
120 inputs['desc'] = click.prompt('Enter a description', default="A schain project", type=str)
142 inputs['name'] = click.prompt('Name of the project', default="project", type=str)
121 inputs['name'] = click.prompt('Name of the project', default="project", type=str)
143 inputs['path'] = click.prompt('Data path', default=os.getcwd(), type=click.Path(exists=True, resolve_path=True))
122 inputs['path'] = click.prompt('Data path', default=os.getcwd(), type=click.Path(exists=True, resolve_path=True))
144 inputs['startDate'] = click.prompt('Start date', default='1970/01/01', type=str)
123 inputs['startDate'] = click.prompt('Start date', default='1970/01/01', type=str)
145 inputs['endDate'] = click.prompt('End date', default='2017/12/31', type=str)
124 inputs['endDate'] = click.prompt('End date', default='2017/12/31', type=str)
146 inputs['startHour'] = click.prompt('Start hour', default='00:00:00', type=str)
125 inputs['startHour'] = click.prompt('Start hour', default='00:00:00', type=str)
147 inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str)
126 inputs['endHour'] = click.prompt('End hour', default='23:59:59', type=str)
148 inputs['figpath'] = inputs['path'] + '/figs'
127 inputs['figpath'] = inputs['path'] + '/figs'
149 return inputs
128 return inputs
150
129
151
130
152 def generate():
131 def generate():
153 inputs = basicInputs()
132 inputs = basicInputs()
154 inputs['multiprocess'] = click.confirm('Is this a multiprocess script?')
133 inputs['multiprocess'] = click.confirm('Is this a multiprocess script?')
155 if inputs['multiprocess']:
134 if inputs['multiprocess']:
156 inputs['nProcess'] = click.prompt('How many process?', default=cpu_count(), type=int)
135 inputs['nProcess'] = click.prompt('How many process?', default=cpu_count(), type=int)
157 current = templates.multiprocess.format(**inputs)
136 current = templates.multiprocess.format(**inputs)
158 else:
137 else:
159 current = templates.basic.format(**inputs)
138 current = templates.basic.format(**inputs)
160 scriptname = '{}_{}.py'.format(PREFIX, inputs['name'])
139 scriptname = '{}_{}.py'.format(PREFIX, inputs['name'])
161 script = open(scriptname, 'w')
140 script = open(scriptname, 'w')
162 try:
141 try:
163 script.write(current)
142 script.write(current)
164 log.success('Script {} generated'.format(scriptname))
143 log.success('Script {} generated'.format(scriptname))
165 except Exception as e:
144 except Exception as e:
166 log.error('I cannot create the file. Do you have writing permissions?')
145 log.error('I cannot create the file. Do you have writing permissions?')
167
146
168
147
169 def test():
148 def test():
170 log.warning('testing')
149 log.warning('testing')
171
150
172
151
173 def runFromXML(filename):
152 def runFromXML(filename):
174 controller = controller_api.ControllerThread()
153 controller = controller_api.ControllerThread()
175 if not controller.readXml(filename):
154 if not controller.readXml(filename):
176 return
155 return
177
156
178 plotterObj = controller.useExternalPlotter()
157 plotterObj = controller.useExternalPlotter()
179
158
180 controller.start()
159 controller.start()
181 plotterObj.start()
160 plotterObj.start()
182
161
183 cliLogger("Finishing all processes")
162 cliLogger("Finishing all processes")
184
163
185 controller.join(5)
164 controller.join(5)
186
165
187 cliLogger("End of script")
166 cliLogger("End of script")
188 return
167 return
@@ -1,1534 +1,1595
1 '''
1 '''
2 Created on Jul 9, 2014
2 Created on Jul 9, 2014
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6 import os
6 import os
7 import datetime
7 import datetime
8 import numpy
8 import numpy
9
9
10 from figure import Figure, isRealtime, isTimeInHourRange
10 from figure import Figure, isRealtime, isTimeInHourRange
11 from plotting_codes import *
11 from plotting_codes import *
12
12
13
13 class SpectraPlot(Figure):
14 class SpectraPlot(Figure):
14
15
15 isConfig = None
16 isConfig = None
16 __nsubplots = None
17 __nsubplots = None
17
18
18 WIDTHPROF = None
19 WIDTHPROF = None
19 HEIGHTPROF = None
20 HEIGHTPROF = None
20 PREFIX = 'spc'
21 PREFIX = 'spc'
21
22
22 def __init__(self, **kwargs):
23 def __init__(self, **kwargs):
23 Figure.__init__(self, **kwargs)
24 Figure.__init__(self, **kwargs)
24 self.isConfig = False
25 self.isConfig = False
25 self.__nsubplots = 1
26 self.__nsubplots = 1
26
27
27 self.WIDTH = 250
28 self.WIDTH = 250
28 self.HEIGHT = 250
29 self.HEIGHT = 250
29 self.WIDTHPROF = 120
30 self.WIDTHPROF = 120
30 self.HEIGHTPROF = 0
31 self.HEIGHTPROF = 0
31 self.counter_imagwr = 0
32 self.counter_imagwr = 0
32
33
33 self.PLOT_CODE = SPEC_CODE
34 self.PLOT_CODE = SPEC_CODE
34
35
35 self.FTP_WEI = None
36 self.FTP_WEI = None
36 self.EXP_CODE = None
37 self.EXP_CODE = None
37 self.SUB_EXP_CODE = None
38 self.SUB_EXP_CODE = None
38 self.PLOT_POS = None
39 self.PLOT_POS = None
39
40
40 self.__xfilter_ena = False
41 self.__xfilter_ena = False
41 self.__yfilter_ena = False
42 self.__yfilter_ena = False
42
43
43 def getSubplots(self):
44 def getSubplots(self):
44
45
45 ncol = int(numpy.sqrt(self.nplots)+0.9)
46 ncol = int(numpy.sqrt(self.nplots)+0.9)
46 nrow = int(self.nplots*1./ncol + 0.9)
47 nrow = int(self.nplots*1./ncol + 0.9)
47
48
48 return nrow, ncol
49 return nrow, ncol
49
50
50 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
51 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
51
52
52 self.__showprofile = showprofile
53 self.__showprofile = showprofile
53 self.nplots = nplots
54 self.nplots = nplots
54
55
55 ncolspan = 1
56 ncolspan = 1
56 colspan = 1
57 colspan = 1
57 if showprofile:
58 if showprofile:
58 ncolspan = 3
59 ncolspan = 3
59 colspan = 2
60 colspan = 2
60 self.__nsubplots = 2
61 self.__nsubplots = 2
61
62
62 self.createFigure(id = id,
63 self.createFigure(id = id,
63 wintitle = wintitle,
64 wintitle = wintitle,
64 widthplot = self.WIDTH + self.WIDTHPROF,
65 widthplot = self.WIDTH + self.WIDTHPROF,
65 heightplot = self.HEIGHT + self.HEIGHTPROF,
66 heightplot = self.HEIGHT + self.HEIGHTPROF,
66 show=show)
67 show=show)
67
68
68 nrow, ncol = self.getSubplots()
69 nrow, ncol = self.getSubplots()
69
70
70 counter = 0
71 counter = 0
71 for y in range(nrow):
72 for y in range(nrow):
72 for x in range(ncol):
73 for x in range(ncol):
73
74
74 if counter >= self.nplots:
75 if counter >= self.nplots:
75 break
76 break
76
77
77 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
78 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
78
79
79 if showprofile:
80 if showprofile:
80 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
81 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
81
82
82 counter += 1
83 counter += 1
83
84
84 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
85 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
85 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
86 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
86 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
87 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
87 server=None, folder=None, username=None, password=None,
88 server=None, folder=None, username=None, password=None,
88 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
89 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
89 xaxis="velocity", **kwargs):
90 xaxis="velocity", **kwargs):
90
91
91 """
92 """
92
93
93 Input:
94 Input:
94 dataOut :
95 dataOut :
95 id :
96 id :
96 wintitle :
97 wintitle :
97 channelList :
98 channelList :
98 showProfile :
99 showProfile :
99 xmin : None,
100 xmin : None,
100 xmax : None,
101 xmax : None,
101 ymin : None,
102 ymin : None,
102 ymax : None,
103 ymax : None,
103 zmin : None,
104 zmin : None,
104 zmax : None
105 zmax : None
105 """
106 """
106
107
107 colormap = kwargs.get('colormap','jet')
108 colormap = kwargs.get('colormap','jet')
108
109
109 if realtime:
110 if realtime:
110 if not(isRealtime(utcdatatime = dataOut.utctime)):
111 if not(isRealtime(utcdatatime = dataOut.utctime)):
111 print 'Skipping this plot function'
112 print 'Skipping this plot function'
112 return
113 return
113
114
114 if channelList == None:
115 if channelList == None:
115 channelIndexList = dataOut.channelIndexList
116 channelIndexList = dataOut.channelIndexList
116 else:
117 else:
117 channelIndexList = []
118 channelIndexList = []
118 for channel in channelList:
119 for channel in channelList:
119 if channel not in dataOut.channelList:
120 if channel not in dataOut.channelList:
120 raise ValueError, "Channel %d is not in dataOut.channelList" %channel
121 raise ValueError, "Channel %d is not in dataOut.channelList" %channel
121 channelIndexList.append(dataOut.channelList.index(channel))
122 channelIndexList.append(dataOut.channelList.index(channel))
122
123
123 factor = dataOut.normFactor
124 factor = dataOut.normFactor
124
125
125 if xaxis == "frequency":
126 if xaxis == "frequency":
126 x = dataOut.getFreqRange(1)/1000.
127 x = dataOut.getFreqRange(1)/1000.
127 xlabel = "Frequency (kHz)"
128 xlabel = "Frequency (kHz)"
128
129
129 elif xaxis == "time":
130 elif xaxis == "time":
130 x = dataOut.getAcfRange(1)
131 x = dataOut.getAcfRange(1)
131 xlabel = "Time (ms)"
132 xlabel = "Time (ms)"
132
133
133 else:
134 else:
134 x = dataOut.getVelRange(1)
135 x = dataOut.getVelRange(1)
135 xlabel = "Velocity (m/s)"
136 xlabel = "Velocity (m/s)"
136
137
137 ylabel = "Range (Km)"
138 ylabel = "Range (Km)"
138
139
139 y = dataOut.getHeiRange()
140 y = dataOut.getHeiRange()
140
141
141 z = dataOut.data_spc/factor
142 z = dataOut.data_spc/factor
142 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
143 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
143 zdB = 10*numpy.log10(z)
144 zdB = 10*numpy.log10(z)
144
145
145 avg = numpy.average(z, axis=1)
146 avg = numpy.average(z, axis=1)
146 avgdB = 10*numpy.log10(avg)
147 avgdB = 10*numpy.log10(avg)
147
148
148 noise = dataOut.getNoise()/factor
149 noise = dataOut.getNoise()/factor
149 noisedB = 10*numpy.log10(noise)
150 noisedB = 10*numpy.log10(noise)
150
151
151 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
152 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
152 title = wintitle + " Spectra"
153 title = wintitle + " Spectra"
153 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
154 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
154 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
155 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
155
156
156 if not self.isConfig:
157 if not self.isConfig:
157
158
158 nplots = len(channelIndexList)
159 nplots = len(channelIndexList)
159
160
160 self.setup(id=id,
161 self.setup(id=id,
161 nplots=nplots,
162 nplots=nplots,
162 wintitle=wintitle,
163 wintitle=wintitle,
163 showprofile=showprofile,
164 showprofile=showprofile,
164 show=show)
165 show=show)
165
166
166 if xmin == None: xmin = numpy.nanmin(x)
167 if xmin == None: xmin = numpy.nanmin(x)
167 if xmax == None: xmax = numpy.nanmax(x)
168 if xmax == None: xmax = numpy.nanmax(x)
168 if ymin == None: ymin = numpy.nanmin(y)
169 if ymin == None: ymin = numpy.nanmin(y)
169 if ymax == None: ymax = numpy.nanmax(y)
170 if ymax == None: ymax = numpy.nanmax(y)
170 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
171 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
171 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
172 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
172
173
173 self.FTP_WEI = ftp_wei
174 self.FTP_WEI = ftp_wei
174 self.EXP_CODE = exp_code
175 self.EXP_CODE = exp_code
175 self.SUB_EXP_CODE = sub_exp_code
176 self.SUB_EXP_CODE = sub_exp_code
176 self.PLOT_POS = plot_pos
177 self.PLOT_POS = plot_pos
177
178
178 self.isConfig = True
179 self.isConfig = True
179
180
180 self.setWinTitle(title)
181 self.setWinTitle(title)
181
182
182 for i in range(self.nplots):
183 for i in range(self.nplots):
183 index = channelIndexList[i]
184 index = channelIndexList[i]
184 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
185 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
185 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime)
186 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime)
186 if len(dataOut.beam.codeList) != 0:
187 if len(dataOut.beam.codeList) != 0:
187 title = "Ch%d:%4.2fdB,%2.2f,%2.2f:%s" %(dataOut.channelList[index], noisedB[index], dataOut.beam.azimuthList[index], dataOut.beam.zenithList[index], str_datetime)
188 title = "Ch%d:%4.2fdB,%2.2f,%2.2f:%s" %(dataOut.channelList[index], noisedB[index], dataOut.beam.azimuthList[index], dataOut.beam.zenithList[index], str_datetime)
188
189
189 axes = self.axesList[i*self.__nsubplots]
190 axes = self.axesList[i*self.__nsubplots]
190 axes.pcolor(x, y, zdB[index,:,:],
191 axes.pcolor(x, y, zdB[index,:,:],
191 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
192 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
192 xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap,
193 xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap,
193 ticksize=9, cblabel='')
194 ticksize=9, cblabel='')
194
195
195 if self.__showprofile:
196 if self.__showprofile:
196 axes = self.axesList[i*self.__nsubplots +1]
197 axes = self.axesList[i*self.__nsubplots +1]
197 axes.pline(avgdB[index,:], y,
198 axes.pline(avgdB[index,:], y,
198 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
199 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
199 xlabel='dB', ylabel='', title='',
200 xlabel='dB', ylabel='', title='',
200 ytick_visible=False,
201 ytick_visible=False,
201 grid='x')
202 grid='x')
202
203
203 noiseline = numpy.repeat(noisedB[index], len(y))
204 noiseline = numpy.repeat(noisedB[index], len(y))
204 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
205 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
205
206
206 self.draw()
207 self.draw()
207
208
208 if figfile == None:
209 if figfile == None:
209 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
210 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
210 name = str_datetime
211 name = str_datetime
211 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
212 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
212 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
213 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
213 figfile = self.getFilename(name)
214 figfile = self.getFilename(name)
214
215
215 self.save(figpath=figpath,
216 self.save(figpath=figpath,
216 figfile=figfile,
217 figfile=figfile,
217 save=save,
218 save=save,
218 ftp=ftp,
219 ftp=ftp,
219 wr_period=wr_period,
220 wr_period=wr_period,
220 thisDatetime=thisDatetime)
221 thisDatetime=thisDatetime)
221
222
222 class CrossSpectraPlot(Figure):
223 class CrossSpectraPlot(Figure):
223
224
224 isConfig = None
225 isConfig = None
225 __nsubplots = None
226 __nsubplots = None
226
227
227 WIDTH = None
228 WIDTH = None
228 HEIGHT = None
229 HEIGHT = None
229 WIDTHPROF = None
230 WIDTHPROF = None
230 HEIGHTPROF = None
231 HEIGHTPROF = None
231 PREFIX = 'cspc'
232 PREFIX = 'cspc'
232
233
233 def __init__(self, **kwargs):
234 def __init__(self, **kwargs):
234 Figure.__init__(self, **kwargs)
235 Figure.__init__(self, **kwargs)
235 self.isConfig = False
236 self.isConfig = False
236 self.__nsubplots = 4
237 self.__nsubplots = 4
237 self.counter_imagwr = 0
238 self.counter_imagwr = 0
238 self.WIDTH = 250
239 self.WIDTH = 250
239 self.HEIGHT = 250
240 self.HEIGHT = 250
240 self.WIDTHPROF = 0
241 self.WIDTHPROF = 0
241 self.HEIGHTPROF = 0
242 self.HEIGHTPROF = 0
242
243
243 self.PLOT_CODE = CROSS_CODE
244 self.PLOT_CODE = CROSS_CODE
244 self.FTP_WEI = None
245 self.FTP_WEI = None
245 self.EXP_CODE = None
246 self.EXP_CODE = None
246 self.SUB_EXP_CODE = None
247 self.SUB_EXP_CODE = None
247 self.PLOT_POS = None
248 self.PLOT_POS = None
248
249
249 def getSubplots(self):
250 def getSubplots(self):
250
251
251 ncol = 4
252 ncol = 4
252 nrow = self.nplots
253 nrow = self.nplots
253
254
254 return nrow, ncol
255 return nrow, ncol
255
256
256 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
257 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
257
258
258 self.__showprofile = showprofile
259 self.__showprofile = showprofile
259 self.nplots = nplots
260 self.nplots = nplots
260
261
261 ncolspan = 1
262 ncolspan = 1
262 colspan = 1
263 colspan = 1
263
264
264 self.createFigure(id = id,
265 self.createFigure(id = id,
265 wintitle = wintitle,
266 wintitle = wintitle,
266 widthplot = self.WIDTH + self.WIDTHPROF,
267 widthplot = self.WIDTH + self.WIDTHPROF,
267 heightplot = self.HEIGHT + self.HEIGHTPROF,
268 heightplot = self.HEIGHT + self.HEIGHTPROF,
268 show=True)
269 show=True)
269
270
270 nrow, ncol = self.getSubplots()
271 nrow, ncol = self.getSubplots()
271
272
272 counter = 0
273 counter = 0
273 for y in range(nrow):
274 for y in range(nrow):
274 for x in range(ncol):
275 for x in range(ncol):
275 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
276 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
276
277
277 counter += 1
278 counter += 1
278
279
279 def run(self, dataOut, id, wintitle="", pairsList=None,
280 def run(self, dataOut, id, wintitle="", pairsList=None,
280 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
281 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
281 coh_min=None, coh_max=None, phase_min=None, phase_max=None,
282 coh_min=None, coh_max=None, phase_min=None, phase_max=None,
282 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
283 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
283 power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
284 power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
284 server=None, folder=None, username=None, password=None,
285 server=None, folder=None, username=None, password=None,
285 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0,
286 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0,
286 xaxis='frequency'):
287 xaxis='frequency'):
287
288
288 """
289 """
289
290
290 Input:
291 Input:
291 dataOut :
292 dataOut :
292 id :
293 id :
293 wintitle :
294 wintitle :
294 channelList :
295 channelList :
295 showProfile :
296 showProfile :
296 xmin : None,
297 xmin : None,
297 xmax : None,
298 xmax : None,
298 ymin : None,
299 ymin : None,
299 ymax : None,
300 ymax : None,
300 zmin : None,
301 zmin : None,
301 zmax : None
302 zmax : None
302 """
303 """
303
304
304 if pairsList == None:
305 if pairsList == None:
305 pairsIndexList = dataOut.pairsIndexList
306 pairsIndexList = dataOut.pairsIndexList
306 else:
307 else:
307 pairsIndexList = []
308 pairsIndexList = []
308 for pair in pairsList:
309 for pair in pairsList:
309 if pair not in dataOut.pairsList:
310 if pair not in dataOut.pairsList:
310 raise ValueError, "Pair %s is not in dataOut.pairsList" %str(pair)
311 raise ValueError, "Pair %s is not in dataOut.pairsList" %str(pair)
311 pairsIndexList.append(dataOut.pairsList.index(pair))
312 pairsIndexList.append(dataOut.pairsList.index(pair))
312
313
313 if not pairsIndexList:
314 if not pairsIndexList:
314 return
315 return
315
316
316 if len(pairsIndexList) > 4:
317 if len(pairsIndexList) > 4:
317 pairsIndexList = pairsIndexList[0:4]
318 pairsIndexList = pairsIndexList[0:4]
318
319
319 factor = dataOut.normFactor
320 factor = dataOut.normFactor
320 x = dataOut.getVelRange(1)
321 x = dataOut.getVelRange(1)
321 y = dataOut.getHeiRange()
322 y = dataOut.getHeiRange()
322 z = dataOut.data_spc[:,:,:]/factor
323 z = dataOut.data_spc[:,:,:]/factor
323 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
324 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
324
325
325 noise = dataOut.noise/factor
326 noise = dataOut.noise/factor
326
327
327 zdB = 10*numpy.log10(z)
328 zdB = 10*numpy.log10(z)
328 noisedB = 10*numpy.log10(noise)
329 noisedB = 10*numpy.log10(noise)
329
330
330 if coh_min == None:
331 if coh_min == None:
331 coh_min = 0.0
332 coh_min = 0.0
332 if coh_max == None:
333 if coh_max == None:
333 coh_max = 1.0
334 coh_max = 1.0
334
335
335 if phase_min == None:
336 if phase_min == None:
336 phase_min = -180
337 phase_min = -180
337 if phase_max == None:
338 if phase_max == None:
338 phase_max = 180
339 phase_max = 180
339
340
340 #thisDatetime = dataOut.datatime
341 #thisDatetime = dataOut.datatime
341 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
342 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
342 title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
343 title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
343 # xlabel = "Velocity (m/s)"
344 # xlabel = "Velocity (m/s)"
344 ylabel = "Range (Km)"
345 ylabel = "Range (Km)"
345
346
346 if xaxis == "frequency":
347 if xaxis == "frequency":
347 x = dataOut.getFreqRange(1)/1000.
348 x = dataOut.getFreqRange(1)/1000.
348 xlabel = "Frequency (kHz)"
349 xlabel = "Frequency (kHz)"
349
350
350 elif xaxis == "time":
351 elif xaxis == "time":
351 x = dataOut.getAcfRange(1)
352 x = dataOut.getAcfRange(1)
352 xlabel = "Time (ms)"
353 xlabel = "Time (ms)"
353
354
354 else:
355 else:
355 x = dataOut.getVelRange(1)
356 x = dataOut.getVelRange(1)
356 xlabel = "Velocity (m/s)"
357 xlabel = "Velocity (m/s)"
357
358
358 if not self.isConfig:
359 if not self.isConfig:
359
360
360 nplots = len(pairsIndexList)
361 nplots = len(pairsIndexList)
361
362
362 self.setup(id=id,
363 self.setup(id=id,
363 nplots=nplots,
364 nplots=nplots,
364 wintitle=wintitle,
365 wintitle=wintitle,
365 showprofile=False,
366 showprofile=False,
366 show=show)
367 show=show)
367
368
368 avg = numpy.abs(numpy.average(z, axis=1))
369 avg = numpy.abs(numpy.average(z, axis=1))
369 avgdB = 10*numpy.log10(avg)
370 avgdB = 10*numpy.log10(avg)
370
371
371 if xmin == None: xmin = numpy.nanmin(x)
372 if xmin == None: xmin = numpy.nanmin(x)
372 if xmax == None: xmax = numpy.nanmax(x)
373 if xmax == None: xmax = numpy.nanmax(x)
373 if ymin == None: ymin = numpy.nanmin(y)
374 if ymin == None: ymin = numpy.nanmin(y)
374 if ymax == None: ymax = numpy.nanmax(y)
375 if ymax == None: ymax = numpy.nanmax(y)
375 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
376 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
376 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
377 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
377
378
378 self.FTP_WEI = ftp_wei
379 self.FTP_WEI = ftp_wei
379 self.EXP_CODE = exp_code
380 self.EXP_CODE = exp_code
380 self.SUB_EXP_CODE = sub_exp_code
381 self.SUB_EXP_CODE = sub_exp_code
381 self.PLOT_POS = plot_pos
382 self.PLOT_POS = plot_pos
382
383
383 self.isConfig = True
384 self.isConfig = True
384
385
385 self.setWinTitle(title)
386 self.setWinTitle(title)
386
387
387 for i in range(self.nplots):
388 for i in range(self.nplots):
388 pair = dataOut.pairsList[pairsIndexList[i]]
389 pair = dataOut.pairsList[pairsIndexList[i]]
389
390
390 chan_index0 = dataOut.channelList.index(pair[0])
391 chan_index0 = dataOut.channelList.index(pair[0])
391 chan_index1 = dataOut.channelList.index(pair[1])
392 chan_index1 = dataOut.channelList.index(pair[1])
392
393
393 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
394 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
394 title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[chan_index0], str_datetime)
395 title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[chan_index0], str_datetime)
395 zdB = 10.*numpy.log10(dataOut.data_spc[chan_index0,:,:]/factor)
396 zdB = 10.*numpy.log10(dataOut.data_spc[chan_index0,:,:]/factor)
396 axes0 = self.axesList[i*self.__nsubplots]
397 axes0 = self.axesList[i*self.__nsubplots]
397 axes0.pcolor(x, y, zdB,
398 axes0.pcolor(x, y, zdB,
398 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
399 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
399 xlabel=xlabel, ylabel=ylabel, title=title,
400 xlabel=xlabel, ylabel=ylabel, title=title,
400 ticksize=9, colormap=power_cmap, cblabel='')
401 ticksize=9, colormap=power_cmap, cblabel='')
401
402
402 title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[chan_index1], str_datetime)
403 title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[chan_index1], str_datetime)
403 zdB = 10.*numpy.log10(dataOut.data_spc[chan_index1,:,:]/factor)
404 zdB = 10.*numpy.log10(dataOut.data_spc[chan_index1,:,:]/factor)
404 axes0 = self.axesList[i*self.__nsubplots+1]
405 axes0 = self.axesList[i*self.__nsubplots+1]
405 axes0.pcolor(x, y, zdB,
406 axes0.pcolor(x, y, zdB,
406 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
407 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
407 xlabel=xlabel, ylabel=ylabel, title=title,
408 xlabel=xlabel, ylabel=ylabel, title=title,
408 ticksize=9, colormap=power_cmap, cblabel='')
409 ticksize=9, colormap=power_cmap, cblabel='')
409
410
410 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[chan_index0,:,:]*dataOut.data_spc[chan_index1,:,:])
411 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[chan_index0,:,:]*dataOut.data_spc[chan_index1,:,:])
411 coherence = numpy.abs(coherenceComplex)
412 coherence = numpy.abs(coherenceComplex)
412 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
413 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
413 phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi
414 phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi
414
415
415 title = "Coherence Ch%d * Ch%d" %(pair[0], pair[1])
416 title = "Coherence Ch%d * Ch%d" %(pair[0], pair[1])
416 axes0 = self.axesList[i*self.__nsubplots+2]
417 axes0 = self.axesList[i*self.__nsubplots+2]
417 axes0.pcolor(x, y, coherence,
418 axes0.pcolor(x, y, coherence,
418 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=coh_min, zmax=coh_max,
419 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=coh_min, zmax=coh_max,
419 xlabel=xlabel, ylabel=ylabel, title=title,
420 xlabel=xlabel, ylabel=ylabel, title=title,
420 ticksize=9, colormap=coherence_cmap, cblabel='')
421 ticksize=9, colormap=coherence_cmap, cblabel='')
421
422
422 title = "Phase Ch%d * Ch%d" %(pair[0], pair[1])
423 title = "Phase Ch%d * Ch%d" %(pair[0], pair[1])
423 axes0 = self.axesList[i*self.__nsubplots+3]
424 axes0 = self.axesList[i*self.__nsubplots+3]
424 axes0.pcolor(x, y, phase,
425 axes0.pcolor(x, y, phase,
425 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max,
426 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max,
426 xlabel=xlabel, ylabel=ylabel, title=title,
427 xlabel=xlabel, ylabel=ylabel, title=title,
427 ticksize=9, colormap=phase_cmap, cblabel='')
428 ticksize=9, colormap=phase_cmap, cblabel='')
428
429
429
430
430
431
431 self.draw()
432 self.draw()
432
433
433 self.save(figpath=figpath,
434 self.save(figpath=figpath,
434 figfile=figfile,
435 figfile=figfile,
435 save=save,
436 save=save,
436 ftp=ftp,
437 ftp=ftp,
437 wr_period=wr_period,
438 wr_period=wr_period,
438 thisDatetime=thisDatetime)
439 thisDatetime=thisDatetime)
439
440
440
441
441 class RTIPlot(Figure):
442 class RTIPlot(Figure):
442
443
443 __isConfig = None
444 __isConfig = None
444 __nsubplots = None
445 __nsubplots = None
445
446
446 WIDTHPROF = None
447 WIDTHPROF = None
447 HEIGHTPROF = None
448 HEIGHTPROF = None
448 PREFIX = 'rti'
449 PREFIX = 'rti'
449
450
450 def __init__(self, **kwargs):
451 def __init__(self, **kwargs):
451
452
452 Figure.__init__(self, **kwargs)
453 Figure.__init__(self, **kwargs)
453 self.timerange = None
454 self.timerange = None
454 self.isConfig = False
455 self.isConfig = False
455 self.__nsubplots = 1
456 self.__nsubplots = 1
456
457
457 self.WIDTH = 800
458 self.WIDTH = 800
458 self.HEIGHT = 180
459 self.HEIGHT = 180
459 self.WIDTHPROF = 120
460 self.WIDTHPROF = 120
460 self.HEIGHTPROF = 0
461 self.HEIGHTPROF = 0
461 self.counter_imagwr = 0
462 self.counter_imagwr = 0
462
463
463 self.PLOT_CODE = RTI_CODE
464 self.PLOT_CODE = RTI_CODE
464
465
465 self.FTP_WEI = None
466 self.FTP_WEI = None
466 self.EXP_CODE = None
467 self.EXP_CODE = None
467 self.SUB_EXP_CODE = None
468 self.SUB_EXP_CODE = None
468 self.PLOT_POS = None
469 self.PLOT_POS = None
469 self.tmin = None
470 self.tmin = None
470 self.tmax = None
471 self.tmax = None
471
472
472 self.xmin = None
473 self.xmin = None
473 self.xmax = None
474 self.xmax = None
474
475
475 self.figfile = None
476 self.figfile = None
476
477
477 def getSubplots(self):
478 def getSubplots(self):
478
479
479 ncol = 1
480 ncol = 1
480 nrow = self.nplots
481 nrow = self.nplots
481
482
482 return nrow, ncol
483 return nrow, ncol
483
484
484 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
485 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
485
486
486 self.__showprofile = showprofile
487 self.__showprofile = showprofile
487 self.nplots = nplots
488 self.nplots = nplots
488
489
489 ncolspan = 1
490 ncolspan = 1
490 colspan = 1
491 colspan = 1
491 if showprofile:
492 if showprofile:
492 ncolspan = 7
493 ncolspan = 7
493 colspan = 6
494 colspan = 6
494 self.__nsubplots = 2
495 self.__nsubplots = 2
495
496
496 self.createFigure(id = id,
497 self.createFigure(id = id,
497 wintitle = wintitle,
498 wintitle = wintitle,
498 widthplot = self.WIDTH + self.WIDTHPROF,
499 widthplot = self.WIDTH + self.WIDTHPROF,
499 heightplot = self.HEIGHT + self.HEIGHTPROF,
500 heightplot = self.HEIGHT + self.HEIGHTPROF,
500 show=show)
501 show=show)
501
502
502 nrow, ncol = self.getSubplots()
503 nrow, ncol = self.getSubplots()
503
504
504 counter = 0
505 counter = 0
505 for y in range(nrow):
506 for y in range(nrow):
506 for x in range(ncol):
507 for x in range(ncol):
507
508
508 if counter >= self.nplots:
509 if counter >= self.nplots:
509 break
510 break
510
511
511 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
512 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
512
513
513 if showprofile:
514 if showprofile:
514 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
515 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
515
516
516 counter += 1
517 counter += 1
517
518
518 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
519 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
519 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
520 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
520 timerange=None,
521 timerange=None,
521 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
522 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
522 server=None, folder=None, username=None, password=None,
523 server=None, folder=None, username=None, password=None,
523 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, **kwargs):
524 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, **kwargs):
524
525
525 """
526 """
526
527
527 Input:
528 Input:
528 dataOut :
529 dataOut :
529 id :
530 id :
530 wintitle :
531 wintitle :
531 channelList :
532 channelList :
532 showProfile :
533 showProfile :
533 xmin : None,
534 xmin : None,
534 xmax : None,
535 xmax : None,
535 ymin : None,
536 ymin : None,
536 ymax : None,
537 ymax : None,
537 zmin : None,
538 zmin : None,
538 zmax : None
539 zmax : None
539 """
540 """
540
541
541 colormap = kwargs.get('colormap', 'jet')
542 colormap = kwargs.get('colormap', 'jet')
542 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
543 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
543 return
544 return
544
545
545 if channelList == None:
546 if channelList == None:
546 channelIndexList = dataOut.channelIndexList
547 channelIndexList = dataOut.channelIndexList
547 else:
548 else:
548 channelIndexList = []
549 channelIndexList = []
549 for channel in channelList:
550 for channel in channelList:
550 if channel not in dataOut.channelList:
551 if channel not in dataOut.channelList:
551 raise ValueError, "Channel %d is not in dataOut.channelList"
552 raise ValueError, "Channel %d is not in dataOut.channelList"
552 channelIndexList.append(dataOut.channelList.index(channel))
553 channelIndexList.append(dataOut.channelList.index(channel))
553
554
554 if hasattr(dataOut, 'normFactor'):
555 if hasattr(dataOut, 'normFactor'):
555 factor = dataOut.normFactor
556 factor = dataOut.normFactor
556 else:
557 else:
557 factor = 1
558 factor = 1
558
559
559 # factor = dataOut.normFactor
560 # factor = dataOut.normFactor
560 x = dataOut.getTimeRange()
561 x = dataOut.getTimeRange()
561 y = dataOut.getHeiRange()
562 y = dataOut.getHeiRange()
562
563
563 # z = dataOut.data_spc/factor
564 # z = dataOut.data_spc/factor
564 # z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
565 # z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
565 # avg = numpy.average(z, axis=1)
566 # avg = numpy.average(z, axis=1)
566 # avgdB = 10.*numpy.log10(avg)
567 # avgdB = 10.*numpy.log10(avg)
567 avgdB = dataOut.getPower()
568 avgdB = dataOut.getPower()
568
569
569 thisDatetime = dataOut.datatime
570 thisDatetime = dataOut.datatime
570 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
571 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
571 title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
572 title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
572 xlabel = ""
573 xlabel = ""
573 ylabel = "Range (Km)"
574 ylabel = "Range (Km)"
574
575
575 update_figfile = False
576 update_figfile = False
576
577
577 if dataOut.ltctime >= self.xmax:
578 if dataOut.ltctime >= self.xmax:
578 self.counter_imagwr = wr_period
579 self.counter_imagwr = wr_period
579 self.isConfig = False
580 self.isConfig = False
580 update_figfile = True
581 update_figfile = True
581
582
582 if not self.isConfig:
583 if not self.isConfig:
583
584
584 nplots = len(channelIndexList)
585 nplots = len(channelIndexList)
585
586
586 self.setup(id=id,
587 self.setup(id=id,
587 nplots=nplots,
588 nplots=nplots,
588 wintitle=wintitle,
589 wintitle=wintitle,
589 showprofile=showprofile,
590 showprofile=showprofile,
590 show=show)
591 show=show)
591
592
592 if timerange != None:
593 if timerange != None:
593 self.timerange = timerange
594 self.timerange = timerange
594
595
595 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
596 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
596
597
597 noise = dataOut.noise/factor
598 noise = dataOut.noise/factor
598 noisedB = 10*numpy.log10(noise)
599 noisedB = 10*numpy.log10(noise)
599
600
600 if ymin == None: ymin = numpy.nanmin(y)
601 if ymin == None: ymin = numpy.nanmin(y)
601 if ymax == None: ymax = numpy.nanmax(y)
602 if ymax == None: ymax = numpy.nanmax(y)
602 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
603 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
603 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
604 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
604
605
605 self.FTP_WEI = ftp_wei
606 self.FTP_WEI = ftp_wei
606 self.EXP_CODE = exp_code
607 self.EXP_CODE = exp_code
607 self.SUB_EXP_CODE = sub_exp_code
608 self.SUB_EXP_CODE = sub_exp_code
608 self.PLOT_POS = plot_pos
609 self.PLOT_POS = plot_pos
609
610
610 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
611 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
611 self.isConfig = True
612 self.isConfig = True
612 self.figfile = figfile
613 self.figfile = figfile
613 update_figfile = True
614 update_figfile = True
614
615
615 self.setWinTitle(title)
616 self.setWinTitle(title)
616
617
617 for i in range(self.nplots):
618 for i in range(self.nplots):
618 index = channelIndexList[i]
619 index = channelIndexList[i]
619 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
620 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
620 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
621 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
621 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
622 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
622 axes = self.axesList[i*self.__nsubplots]
623 axes = self.axesList[i*self.__nsubplots]
623 zdB = avgdB[index].reshape((1,-1))
624 zdB = avgdB[index].reshape((1,-1))
624 axes.pcolorbuffer(x, y, zdB,
625 axes.pcolorbuffer(x, y, zdB,
625 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
626 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
626 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
627 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
627 ticksize=9, cblabel='', cbsize="1%", colormap=colormap)
628 ticksize=9, cblabel='', cbsize="1%", colormap=colormap)
628
629
629 if self.__showprofile:
630 if self.__showprofile:
630 axes = self.axesList[i*self.__nsubplots +1]
631 axes = self.axesList[i*self.__nsubplots +1]
631 axes.pline(avgdB[index], y,
632 axes.pline(avgdB[index], y,
632 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
633 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
633 xlabel='dB', ylabel='', title='',
634 xlabel='dB', ylabel='', title='',
634 ytick_visible=False,
635 ytick_visible=False,
635 grid='x')
636 grid='x')
636
637
637 self.draw()
638 self.draw()
638
639
639 self.save(figpath=figpath,
640 self.save(figpath=figpath,
640 figfile=figfile,
641 figfile=figfile,
641 save=save,
642 save=save,
642 ftp=ftp,
643 ftp=ftp,
643 wr_period=wr_period,
644 wr_period=wr_period,
644 thisDatetime=thisDatetime,
645 thisDatetime=thisDatetime,
645 update_figfile=update_figfile)
646 update_figfile=update_figfile)
646
647
647 class CoherenceMap(Figure):
648 class CoherenceMap(Figure):
648 isConfig = None
649 isConfig = None
649 __nsubplots = None
650 __nsubplots = None
650
651
651 WIDTHPROF = None
652 WIDTHPROF = None
652 HEIGHTPROF = None
653 HEIGHTPROF = None
653 PREFIX = 'cmap'
654 PREFIX = 'cmap'
654
655
656 parameters = {
657 'id': 'string',
658 'wintitle': 'string',
659 'pairsList': 'pairsLists',
660 'showprofile': 'boolean',
661 'xmin': 'float',
662 'xmax': 'float',
663 'ymin': 'float',
664 'ymax': 'float',
665 'zmin': 'float',
666 'zmax': 'float',
667 'timerange': 'float',
668 'phase_min': 'float',
669 'phase_max': 'float',
670 'save': 'boolean',
671 'figpath': 'string',
672 'figfile': 'string',
673 'ftp': 'boolean',
674 'wr_period': 'int',
675 'coherence_cmap': 'colormap',
676 'phase_cmap': 'colormap',
677 'show': 'boolean',
678 'server': 'string',
679 'folder': 'string',
680 'username': 'string',
681 'password': 'string',
682 'ftp_wei': 'int',
683 'exp_code': 'int',
684 'sub_exp_code': 'int',
685 'plot_pos': 'int',
686 }
687
655 def __init__(self, **kwargs):
688 def __init__(self, **kwargs):
656 Figure.__init__(self, **kwargs)
689 Figure.__init__(self, **kwargs)
657 self.timerange = 2*60*60
690 self.timerange = 2*60*60
658 self.isConfig = False
691 self.isConfig = False
659 self.__nsubplots = 1
692 self.__nsubplots = 1
660
693
661 self.WIDTH = 800
694 self.WIDTH = 800
662 self.HEIGHT = 180
695 self.HEIGHT = 180
663 self.WIDTHPROF = 120
696 self.WIDTHPROF = 120
664 self.HEIGHTPROF = 0
697 self.HEIGHTPROF = 0
665 self.counter_imagwr = 0
698 self.counter_imagwr = 0
666
699
667 self.PLOT_CODE = COH_CODE
700 self.PLOT_CODE = COH_CODE
668
701
669 self.FTP_WEI = None
702 self.FTP_WEI = None
670 self.EXP_CODE = None
703 self.EXP_CODE = None
671 self.SUB_EXP_CODE = None
704 self.SUB_EXP_CODE = None
672 self.PLOT_POS = None
705 self.PLOT_POS = None
673 self.counter_imagwr = 0
706 self.counter_imagwr = 0
674
707
675 self.xmin = None
708 self.xmin = None
676 self.xmax = None
709 self.xmax = None
677
710
678 def getSubplots(self):
711 def getSubplots(self):
679 ncol = 1
712 ncol = 1
680 nrow = self.nplots*2
713 nrow = self.nplots*2
681
714
682 return nrow, ncol
715 return nrow, ncol
683
716
684 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
717 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
685 self.__showprofile = showprofile
718 self.__showprofile = showprofile
686 self.nplots = nplots
719 self.nplots = nplots
687
720
688 ncolspan = 1
721 ncolspan = 1
689 colspan = 1
722 colspan = 1
690 if showprofile:
723 if showprofile:
691 ncolspan = 7
724 ncolspan = 7
692 colspan = 6
725 colspan = 6
693 self.__nsubplots = 2
726 self.__nsubplots = 2
694
727
695 self.createFigure(id = id,
728 self.createFigure(id = id,
696 wintitle = wintitle,
729 wintitle = wintitle,
697 widthplot = self.WIDTH + self.WIDTHPROF,
730 widthplot = self.WIDTH + self.WIDTHPROF,
698 heightplot = self.HEIGHT + self.HEIGHTPROF,
731 heightplot = self.HEIGHT + self.HEIGHTPROF,
699 show=True)
732 show=True)
700
733
701 nrow, ncol = self.getSubplots()
734 nrow, ncol = self.getSubplots()
702
735
703 for y in range(nrow):
736 for y in range(nrow):
704 for x in range(ncol):
737 for x in range(ncol):
705
738
706 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
739 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
707
740
708 if showprofile:
741 if showprofile:
709 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
742 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
710
743
711 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
744 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
712 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
745 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
713 timerange=None, phase_min=None, phase_max=None,
746 timerange=None, phase_min=None, phase_max=None,
714 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
747 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
715 coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
748 coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
716 server=None, folder=None, username=None, password=None,
749 server=None, folder=None, username=None, password=None,
717 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
750 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
718
751
719 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
752 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
720 return
753 return
721
754
722 if pairsList == None:
755 if pairsList == None:
723 pairsIndexList = dataOut.pairsIndexList
756 pairsIndexList = dataOut.pairsIndexList
724 else:
757 else:
725 pairsIndexList = []
758 pairsIndexList = []
726 for pair in pairsList:
759 for pair in pairsList:
727 if pair not in dataOut.pairsList:
760 if pair not in dataOut.pairsList:
728 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
761 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
729 pairsIndexList.append(dataOut.pairsList.index(pair))
762 pairsIndexList.append(dataOut.pairsList.index(pair))
730
763
731 if pairsIndexList == []:
764 if pairsIndexList == []:
732 return
765 return
733
766
734 if len(pairsIndexList) > 4:
767 if len(pairsIndexList) > 4:
735 pairsIndexList = pairsIndexList[0:4]
768 pairsIndexList = pairsIndexList[0:4]
736
769
737 if phase_min == None:
770 if phase_min == None:
738 phase_min = -180
771 phase_min = -180
739 if phase_max == None:
772 if phase_max == None:
740 phase_max = 180
773 phase_max = 180
741
774
742 x = dataOut.getTimeRange()
775 x = dataOut.getTimeRange()
743 y = dataOut.getHeiRange()
776 y = dataOut.getHeiRange()
744
777
745 thisDatetime = dataOut.datatime
778 thisDatetime = dataOut.datatime
746
779
747 title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
780 title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
748 xlabel = ""
781 xlabel = ""
749 ylabel = "Range (Km)"
782 ylabel = "Range (Km)"
750 update_figfile = False
783 update_figfile = False
751
784
752 if not self.isConfig:
785 if not self.isConfig:
753 nplots = len(pairsIndexList)
786 nplots = len(pairsIndexList)
754 self.setup(id=id,
787 self.setup(id=id,
755 nplots=nplots,
788 nplots=nplots,
756 wintitle=wintitle,
789 wintitle=wintitle,
757 showprofile=showprofile,
790 showprofile=showprofile,
758 show=show)
791 show=show)
759
792
760 if timerange != None:
793 if timerange != None:
761 self.timerange = timerange
794 self.timerange = timerange
762
795
763 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
796 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
764
797
765 if ymin == None: ymin = numpy.nanmin(y)
798 if ymin == None: ymin = numpy.nanmin(y)
766 if ymax == None: ymax = numpy.nanmax(y)
799 if ymax == None: ymax = numpy.nanmax(y)
767 if zmin == None: zmin = 0.
800 if zmin == None: zmin = 0.
768 if zmax == None: zmax = 1.
801 if zmax == None: zmax = 1.
769
802
770 self.FTP_WEI = ftp_wei
803 self.FTP_WEI = ftp_wei
771 self.EXP_CODE = exp_code
804 self.EXP_CODE = exp_code
772 self.SUB_EXP_CODE = sub_exp_code
805 self.SUB_EXP_CODE = sub_exp_code
773 self.PLOT_POS = plot_pos
806 self.PLOT_POS = plot_pos
774
807
775 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
808 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
776
809
777 self.isConfig = True
810 self.isConfig = True
778 update_figfile = True
811 update_figfile = True
779
812
780 self.setWinTitle(title)
813 self.setWinTitle(title)
781
814
782 for i in range(self.nplots):
815 for i in range(self.nplots):
783
816
784 pair = dataOut.pairsList[pairsIndexList[i]]
817 pair = dataOut.pairsList[pairsIndexList[i]]
785
818
786 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
819 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
787 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
820 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
788 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
821 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
789
822
790
823
791 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
824 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
792 coherence = numpy.abs(avgcoherenceComplex)
825 coherence = numpy.abs(avgcoherenceComplex)
793
826
794 z = coherence.reshape((1,-1))
827 z = coherence.reshape((1,-1))
795
828
796 counter = 0
829 counter = 0
797
830
798 title = "Coherence Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
831 title = "Coherence Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
799 axes = self.axesList[i*self.__nsubplots*2]
832 axes = self.axesList[i*self.__nsubplots*2]
800 axes.pcolorbuffer(x, y, z,
833 axes.pcolorbuffer(x, y, z,
801 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
834 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
802 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
835 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
803 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
836 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
804
837
805 if self.__showprofile:
838 if self.__showprofile:
806 counter += 1
839 counter += 1
807 axes = self.axesList[i*self.__nsubplots*2 + counter]
840 axes = self.axesList[i*self.__nsubplots*2 + counter]
808 axes.pline(coherence, y,
841 axes.pline(coherence, y,
809 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
842 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
810 xlabel='', ylabel='', title='', ticksize=7,
843 xlabel='', ylabel='', title='', ticksize=7,
811 ytick_visible=False, nxticks=5,
844 ytick_visible=False, nxticks=5,
812 grid='x')
845 grid='x')
813
846
814 counter += 1
847 counter += 1
815
848
816 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
849 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
817
850
818 z = phase.reshape((1,-1))
851 z = phase.reshape((1,-1))
819
852
820 title = "Phase Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
853 title = "Phase Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
821 axes = self.axesList[i*self.__nsubplots*2 + counter]
854 axes = self.axesList[i*self.__nsubplots*2 + counter]
822 axes.pcolorbuffer(x, y, z,
855 axes.pcolorbuffer(x, y, z,
823 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max,
856 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max,
824 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
857 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
825 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
858 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
826
859
827 if self.__showprofile:
860 if self.__showprofile:
828 counter += 1
861 counter += 1
829 axes = self.axesList[i*self.__nsubplots*2 + counter]
862 axes = self.axesList[i*self.__nsubplots*2 + counter]
830 axes.pline(phase, y,
863 axes.pline(phase, y,
831 xmin=phase_min, xmax=phase_max, ymin=ymin, ymax=ymax,
864 xmin=phase_min, xmax=phase_max, ymin=ymin, ymax=ymax,
832 xlabel='', ylabel='', title='', ticksize=7,
865 xlabel='', ylabel='', title='', ticksize=7,
833 ytick_visible=False, nxticks=4,
866 ytick_visible=False, nxticks=4,
834 grid='x')
867 grid='x')
835
868
836 self.draw()
869 self.draw()
837
870
838 if dataOut.ltctime >= self.xmax:
871 if dataOut.ltctime >= self.xmax:
839 self.counter_imagwr = wr_period
872 self.counter_imagwr = wr_period
840 self.isConfig = False
873 self.isConfig = False
841 update_figfile = True
874 update_figfile = True
842
875
843 self.save(figpath=figpath,
876 self.save(figpath=figpath,
844 figfile=figfile,
877 figfile=figfile,
845 save=save,
878 save=save,
846 ftp=ftp,
879 ftp=ftp,
847 wr_period=wr_period,
880 wr_period=wr_period,
848 thisDatetime=thisDatetime,
881 thisDatetime=thisDatetime,
849 update_figfile=update_figfile)
882 update_figfile=update_figfile)
850
883
851 class PowerProfilePlot(Figure):
884 class PowerProfilePlot(Figure):
852
885
853 isConfig = None
886 isConfig = None
854 __nsubplots = None
887 __nsubplots = None
855
888
856 WIDTHPROF = None
889 WIDTHPROF = None
857 HEIGHTPROF = None
890 HEIGHTPROF = None
858 PREFIX = 'spcprofile'
891 PREFIX = 'spcprofile'
859
892
860 def __init__(self, **kwargs):
893 def __init__(self, **kwargs):
861 Figure.__init__(self, **kwargs)
894 Figure.__init__(self, **kwargs)
862 self.isConfig = False
895 self.isConfig = False
863 self.__nsubplots = 1
896 self.__nsubplots = 1
864
897
865 self.PLOT_CODE = POWER_CODE
898 self.PLOT_CODE = POWER_CODE
866
899
867 self.WIDTH = 300
900 self.WIDTH = 300
868 self.HEIGHT = 500
901 self.HEIGHT = 500
869 self.counter_imagwr = 0
902 self.counter_imagwr = 0
870
903
871 def getSubplots(self):
904 def getSubplots(self):
872 ncol = 1
905 ncol = 1
873 nrow = 1
906 nrow = 1
874
907
875 return nrow, ncol
908 return nrow, ncol
876
909
877 def setup(self, id, nplots, wintitle, show):
910 def setup(self, id, nplots, wintitle, show):
878
911
879 self.nplots = nplots
912 self.nplots = nplots
880
913
881 ncolspan = 1
914 ncolspan = 1
882 colspan = 1
915 colspan = 1
883
916
884 self.createFigure(id = id,
917 self.createFigure(id = id,
885 wintitle = wintitle,
918 wintitle = wintitle,
886 widthplot = self.WIDTH,
919 widthplot = self.WIDTH,
887 heightplot = self.HEIGHT,
920 heightplot = self.HEIGHT,
888 show=show)
921 show=show)
889
922
890 nrow, ncol = self.getSubplots()
923 nrow, ncol = self.getSubplots()
891
924
892 counter = 0
925 counter = 0
893 for y in range(nrow):
926 for y in range(nrow):
894 for x in range(ncol):
927 for x in range(ncol):
895 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
928 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
896
929
897 def run(self, dataOut, id, wintitle="", channelList=None,
930 def run(self, dataOut, id, wintitle="", channelList=None,
898 xmin=None, xmax=None, ymin=None, ymax=None,
931 xmin=None, xmax=None, ymin=None, ymax=None,
899 save=False, figpath='./', figfile=None, show=True,
932 save=False, figpath='./', figfile=None, show=True,
900 ftp=False, wr_period=1, server=None,
933 ftp=False, wr_period=1, server=None,
901 folder=None, username=None, password=None):
934 folder=None, username=None, password=None):
902
935
903
936
904 if channelList == None:
937 if channelList == None:
905 channelIndexList = dataOut.channelIndexList
938 channelIndexList = dataOut.channelIndexList
906 channelList = dataOut.channelList
939 channelList = dataOut.channelList
907 else:
940 else:
908 channelIndexList = []
941 channelIndexList = []
909 for channel in channelList:
942 for channel in channelList:
910 if channel not in dataOut.channelList:
943 if channel not in dataOut.channelList:
911 raise ValueError, "Channel %d is not in dataOut.channelList"
944 raise ValueError, "Channel %d is not in dataOut.channelList"
912 channelIndexList.append(dataOut.channelList.index(channel))
945 channelIndexList.append(dataOut.channelList.index(channel))
913
946
914 factor = dataOut.normFactor
947 factor = dataOut.normFactor
915
948
916 y = dataOut.getHeiRange()
949 y = dataOut.getHeiRange()
917
950
918 #for voltage
951 #for voltage
919 if dataOut.type == 'Voltage':
952 if dataOut.type == 'Voltage':
920 x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
953 x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
921 x = x.real
954 x = x.real
922 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
955 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
923
956
924 #for spectra
957 #for spectra
925 if dataOut.type == 'Spectra':
958 if dataOut.type == 'Spectra':
926 x = dataOut.data_spc[channelIndexList,:,:]/factor
959 x = dataOut.data_spc[channelIndexList,:,:]/factor
927 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
960 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
928 x = numpy.average(x, axis=1)
961 x = numpy.average(x, axis=1)
929
962
930
963
931 xdB = 10*numpy.log10(x)
964 xdB = 10*numpy.log10(x)
932
965
933 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
966 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
934 title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y"))
967 title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y"))
935 xlabel = "dB"
968 xlabel = "dB"
936 ylabel = "Range (Km)"
969 ylabel = "Range (Km)"
937
970
938 if not self.isConfig:
971 if not self.isConfig:
939
972
940 nplots = 1
973 nplots = 1
941
974
942 self.setup(id=id,
975 self.setup(id=id,
943 nplots=nplots,
976 nplots=nplots,
944 wintitle=wintitle,
977 wintitle=wintitle,
945 show=show)
978 show=show)
946
979
947 if ymin == None: ymin = numpy.nanmin(y)
980 if ymin == None: ymin = numpy.nanmin(y)
948 if ymax == None: ymax = numpy.nanmax(y)
981 if ymax == None: ymax = numpy.nanmax(y)
949 if xmin == None: xmin = numpy.nanmin(xdB)*0.9
982 if xmin == None: xmin = numpy.nanmin(xdB)*0.9
950 if xmax == None: xmax = numpy.nanmax(xdB)*1.1
983 if xmax == None: xmax = numpy.nanmax(xdB)*1.1
951
984
952 self.isConfig = True
985 self.isConfig = True
953
986
954 self.setWinTitle(title)
987 self.setWinTitle(title)
955
988
956 title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
989 title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
957 axes = self.axesList[0]
990 axes = self.axesList[0]
958
991
959 legendlabels = ["channel %d"%x for x in channelList]
992 legendlabels = ["channel %d"%x for x in channelList]
960 axes.pmultiline(xdB, y,
993 axes.pmultiline(xdB, y,
961 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
994 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
962 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
995 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
963 ytick_visible=True, nxticks=5,
996 ytick_visible=True, nxticks=5,
964 grid='x')
997 grid='x')
965
998
966 self.draw()
999 self.draw()
967
1000
968 self.save(figpath=figpath,
1001 self.save(figpath=figpath,
969 figfile=figfile,
1002 figfile=figfile,
970 save=save,
1003 save=save,
971 ftp=ftp,
1004 ftp=ftp,
972 wr_period=wr_period,
1005 wr_period=wr_period,
973 thisDatetime=thisDatetime)
1006 thisDatetime=thisDatetime)
974
1007
975 class SpectraCutPlot(Figure):
1008 class SpectraCutPlot(Figure):
976
1009
977 isConfig = None
1010 isConfig = None
978 __nsubplots = None
1011 __nsubplots = None
979
1012
980 WIDTHPROF = None
1013 WIDTHPROF = None
981 HEIGHTPROF = None
1014 HEIGHTPROF = None
982 PREFIX = 'spc_cut'
1015 PREFIX = 'spc_cut'
983
1016
984 def __init__(self, **kwargs):
1017 def __init__(self, **kwargs):
985 Figure.__init__(self, **kwargs)
1018 Figure.__init__(self, **kwargs)
986 self.isConfig = False
1019 self.isConfig = False
987 self.__nsubplots = 1
1020 self.__nsubplots = 1
988
1021
989 self.PLOT_CODE = POWER_CODE
1022 self.PLOT_CODE = POWER_CODE
990
1023
991 self.WIDTH = 700
1024 self.WIDTH = 700
992 self.HEIGHT = 500
1025 self.HEIGHT = 500
993 self.counter_imagwr = 0
1026 self.counter_imagwr = 0
994
1027
995 def getSubplots(self):
1028 def getSubplots(self):
996 ncol = 1
1029 ncol = 1
997 nrow = 1
1030 nrow = 1
998
1031
999 return nrow, ncol
1032 return nrow, ncol
1000
1033
1001 def setup(self, id, nplots, wintitle, show):
1034 def setup(self, id, nplots, wintitle, show):
1002
1035
1003 self.nplots = nplots
1036 self.nplots = nplots
1004
1037
1005 ncolspan = 1
1038 ncolspan = 1
1006 colspan = 1
1039 colspan = 1
1007
1040
1008 self.createFigure(id = id,
1041 self.createFigure(id = id,
1009 wintitle = wintitle,
1042 wintitle = wintitle,
1010 widthplot = self.WIDTH,
1043 widthplot = self.WIDTH,
1011 heightplot = self.HEIGHT,
1044 heightplot = self.HEIGHT,
1012 show=show)
1045 show=show)
1013
1046
1014 nrow, ncol = self.getSubplots()
1047 nrow, ncol = self.getSubplots()
1015
1048
1016 counter = 0
1049 counter = 0
1017 for y in range(nrow):
1050 for y in range(nrow):
1018 for x in range(ncol):
1051 for x in range(ncol):
1019 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1052 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1020
1053
1021 def run(self, dataOut, id, wintitle="", channelList=None,
1054 def run(self, dataOut, id, wintitle="", channelList=None,
1022 xmin=None, xmax=None, ymin=None, ymax=None,
1055 xmin=None, xmax=None, ymin=None, ymax=None,
1023 save=False, figpath='./', figfile=None, show=True,
1056 save=False, figpath='./', figfile=None, show=True,
1024 ftp=False, wr_period=1, server=None,
1057 ftp=False, wr_period=1, server=None,
1025 folder=None, username=None, password=None,
1058 folder=None, username=None, password=None,
1026 xaxis="frequency"):
1059 xaxis="frequency"):
1027
1060
1028
1061
1029 if channelList == None:
1062 if channelList == None:
1030 channelIndexList = dataOut.channelIndexList
1063 channelIndexList = dataOut.channelIndexList
1031 channelList = dataOut.channelList
1064 channelList = dataOut.channelList
1032 else:
1065 else:
1033 channelIndexList = []
1066 channelIndexList = []
1034 for channel in channelList:
1067 for channel in channelList:
1035 if channel not in dataOut.channelList:
1068 if channel not in dataOut.channelList:
1036 raise ValueError, "Channel %d is not in dataOut.channelList"
1069 raise ValueError, "Channel %d is not in dataOut.channelList"
1037 channelIndexList.append(dataOut.channelList.index(channel))
1070 channelIndexList.append(dataOut.channelList.index(channel))
1038
1071
1039 factor = dataOut.normFactor
1072 factor = dataOut.normFactor
1040
1073
1041 y = dataOut.getHeiRange()
1074 y = dataOut.getHeiRange()
1042
1075
1043 z = dataOut.data_spc/factor
1076 z = dataOut.data_spc/factor
1044 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1077 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1045
1078
1046 hei_index = numpy.arange(25)*3 + 20
1079 hei_index = numpy.arange(25)*3 + 20
1047
1080
1048 if xaxis == "frequency":
1081 if xaxis == "frequency":
1049 x = dataOut.getFreqRange()/1000.
1082 x = dataOut.getFreqRange()/1000.
1050 zdB = 10*numpy.log10(z[0,:,hei_index])
1083 zdB = 10*numpy.log10(z[0,:,hei_index])
1051 xlabel = "Frequency (kHz)"
1084 xlabel = "Frequency (kHz)"
1052 ylabel = "Power (dB)"
1085 ylabel = "Power (dB)"
1053
1086
1054 elif xaxis == "time":
1087 elif xaxis == "time":
1055 x = dataOut.getAcfRange()
1088 x = dataOut.getAcfRange()
1056 zdB = z[0,:,hei_index]
1089 zdB = z[0,:,hei_index]
1057 xlabel = "Time (ms)"
1090 xlabel = "Time (ms)"
1058 ylabel = "ACF"
1091 ylabel = "ACF"
1059
1092
1060 else:
1093 else:
1061 x = dataOut.getVelRange()
1094 x = dataOut.getVelRange()
1062 zdB = 10*numpy.log10(z[0,:,hei_index])
1095 zdB = 10*numpy.log10(z[0,:,hei_index])
1063 xlabel = "Velocity (m/s)"
1096 xlabel = "Velocity (m/s)"
1064 ylabel = "Power (dB)"
1097 ylabel = "Power (dB)"
1065
1098
1066 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1099 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1067 title = wintitle + " Range Cuts %s" %(thisDatetime.strftime("%d-%b-%Y"))
1100 title = wintitle + " Range Cuts %s" %(thisDatetime.strftime("%d-%b-%Y"))
1068
1101
1069 if not self.isConfig:
1102 if not self.isConfig:
1070
1103
1071 nplots = 1
1104 nplots = 1
1072
1105
1073 self.setup(id=id,
1106 self.setup(id=id,
1074 nplots=nplots,
1107 nplots=nplots,
1075 wintitle=wintitle,
1108 wintitle=wintitle,
1076 show=show)
1109 show=show)
1077
1110
1078 if xmin == None: xmin = numpy.nanmin(x)*0.9
1111 if xmin == None: xmin = numpy.nanmin(x)*0.9
1079 if xmax == None: xmax = numpy.nanmax(x)*1.1
1112 if xmax == None: xmax = numpy.nanmax(x)*1.1
1080 if ymin == None: ymin = numpy.nanmin(zdB)
1113 if ymin == None: ymin = numpy.nanmin(zdB)
1081 if ymax == None: ymax = numpy.nanmax(zdB)
1114 if ymax == None: ymax = numpy.nanmax(zdB)
1082
1115
1083 self.isConfig = True
1116 self.isConfig = True
1084
1117
1085 self.setWinTitle(title)
1118 self.setWinTitle(title)
1086
1119
1087 title = "Spectra Cuts: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1120 title = "Spectra Cuts: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1088 axes = self.axesList[0]
1121 axes = self.axesList[0]
1089
1122
1090 legendlabels = ["Range = %dKm" %y[i] for i in hei_index]
1123 legendlabels = ["Range = %dKm" %y[i] for i in hei_index]
1091
1124
1092 axes.pmultilineyaxis( x, zdB,
1125 axes.pmultilineyaxis( x, zdB,
1093 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1126 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1094 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
1127 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
1095 ytick_visible=True, nxticks=5,
1128 ytick_visible=True, nxticks=5,
1096 grid='x')
1129 grid='x')
1097
1130
1098 self.draw()
1131 self.draw()
1099
1132
1100 self.save(figpath=figpath,
1133 self.save(figpath=figpath,
1101 figfile=figfile,
1134 figfile=figfile,
1102 save=save,
1135 save=save,
1103 ftp=ftp,
1136 ftp=ftp,
1104 wr_period=wr_period,
1137 wr_period=wr_period,
1105 thisDatetime=thisDatetime)
1138 thisDatetime=thisDatetime)
1106
1139
1107 class Noise(Figure):
1140 class Noise(Figure):
1108
1141
1109 isConfig = None
1142 isConfig = None
1110 __nsubplots = None
1143 __nsubplots = None
1111
1144
1112 PREFIX = 'noise'
1145 PREFIX = 'noise'
1113
1146
1114 def __init__(self, **kwargs):
1147 def __init__(self, **kwargs):
1115 Figure.__init__(self, **kwargs)
1148 Figure.__init__(self, **kwargs)
1116 self.timerange = 24*60*60
1149 self.timerange = 24*60*60
1117 self.isConfig = False
1150 self.isConfig = False
1118 self.__nsubplots = 1
1151 self.__nsubplots = 1
1119 self.counter_imagwr = 0
1152 self.counter_imagwr = 0
1120 self.WIDTH = 800
1153 self.WIDTH = 800
1121 self.HEIGHT = 400
1154 self.HEIGHT = 400
1122 self.WIDTHPROF = 120
1155 self.WIDTHPROF = 120
1123 self.HEIGHTPROF = 0
1156 self.HEIGHTPROF = 0
1124 self.xdata = None
1157 self.xdata = None
1125 self.ydata = None
1158 self.ydata = None
1126
1159
1127 self.PLOT_CODE = NOISE_CODE
1160 self.PLOT_CODE = NOISE_CODE
1128
1161
1129 self.FTP_WEI = None
1162 self.FTP_WEI = None
1130 self.EXP_CODE = None
1163 self.EXP_CODE = None
1131 self.SUB_EXP_CODE = None
1164 self.SUB_EXP_CODE = None
1132 self.PLOT_POS = None
1165 self.PLOT_POS = None
1133 self.figfile = None
1166 self.figfile = None
1134
1167
1135 self.xmin = None
1168 self.xmin = None
1136 self.xmax = None
1169 self.xmax = None
1137
1170
1138 def getSubplots(self):
1171 def getSubplots(self):
1139
1172
1140 ncol = 1
1173 ncol = 1
1141 nrow = 1
1174 nrow = 1
1142
1175
1143 return nrow, ncol
1176 return nrow, ncol
1144
1177
1145 def openfile(self, filename):
1178 def openfile(self, filename):
1146 dirname = os.path.dirname(filename)
1179 dirname = os.path.dirname(filename)
1147
1180
1148 if not os.path.exists(dirname):
1181 if not os.path.exists(dirname):
1149 os.mkdir(dirname)
1182 os.mkdir(dirname)
1150
1183
1151 f = open(filename,'w+')
1184 f = open(filename,'w+')
1152 f.write('\n\n')
1185 f.write('\n\n')
1153 f.write('JICAMARCA RADIO OBSERVATORY - Noise \n')
1186 f.write('JICAMARCA RADIO OBSERVATORY - Noise \n')
1154 f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' )
1187 f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' )
1155 f.close()
1188 f.close()
1156
1189
1157 def save_data(self, filename_phase, data, data_datetime):
1190 def save_data(self, filename_phase, data, data_datetime):
1158
1191
1159 f=open(filename_phase,'a')
1192 f=open(filename_phase,'a')
1160
1193
1161 timetuple_data = data_datetime.timetuple()
1194 timetuple_data = data_datetime.timetuple()
1162 day = str(timetuple_data.tm_mday)
1195 day = str(timetuple_data.tm_mday)
1163 month = str(timetuple_data.tm_mon)
1196 month = str(timetuple_data.tm_mon)
1164 year = str(timetuple_data.tm_year)
1197 year = str(timetuple_data.tm_year)
1165 hour = str(timetuple_data.tm_hour)
1198 hour = str(timetuple_data.tm_hour)
1166 minute = str(timetuple_data.tm_min)
1199 minute = str(timetuple_data.tm_min)
1167 second = str(timetuple_data.tm_sec)
1200 second = str(timetuple_data.tm_sec)
1168
1201
1169 data_msg = ''
1202 data_msg = ''
1170 for i in range(len(data)):
1203 for i in range(len(data)):
1171 data_msg += str(data[i]) + ' '
1204 data_msg += str(data[i]) + ' '
1172
1205
1173 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' ' + data_msg + '\n')
1206 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' ' + data_msg + '\n')
1174 f.close()
1207 f.close()
1175
1208
1176
1209
1177 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1210 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1178
1211
1179 self.__showprofile = showprofile
1212 self.__showprofile = showprofile
1180 self.nplots = nplots
1213 self.nplots = nplots
1181
1214
1182 ncolspan = 7
1215 ncolspan = 7
1183 colspan = 6
1216 colspan = 6
1184 self.__nsubplots = 2
1217 self.__nsubplots = 2
1185
1218
1186 self.createFigure(id = id,
1219 self.createFigure(id = id,
1187 wintitle = wintitle,
1220 wintitle = wintitle,
1188 widthplot = self.WIDTH+self.WIDTHPROF,
1221 widthplot = self.WIDTH+self.WIDTHPROF,
1189 heightplot = self.HEIGHT+self.HEIGHTPROF,
1222 heightplot = self.HEIGHT+self.HEIGHTPROF,
1190 show=show)
1223 show=show)
1191
1224
1192 nrow, ncol = self.getSubplots()
1225 nrow, ncol = self.getSubplots()
1193
1226
1194 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1227 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1195
1228
1196
1229
1197 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
1230 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
1198 xmin=None, xmax=None, ymin=None, ymax=None,
1231 xmin=None, xmax=None, ymin=None, ymax=None,
1199 timerange=None,
1232 timerange=None,
1200 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1233 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1201 server=None, folder=None, username=None, password=None,
1234 server=None, folder=None, username=None, password=None,
1202 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1235 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1203
1236
1204 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1237 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1205 return
1238 return
1206
1239
1207 if channelList == None:
1240 if channelList == None:
1208 channelIndexList = dataOut.channelIndexList
1241 channelIndexList = dataOut.channelIndexList
1209 channelList = dataOut.channelList
1242 channelList = dataOut.channelList
1210 else:
1243 else:
1211 channelIndexList = []
1244 channelIndexList = []
1212 for channel in channelList:
1245 for channel in channelList:
1213 if channel not in dataOut.channelList:
1246 if channel not in dataOut.channelList:
1214 raise ValueError, "Channel %d is not in dataOut.channelList"
1247 raise ValueError, "Channel %d is not in dataOut.channelList"
1215 channelIndexList.append(dataOut.channelList.index(channel))
1248 channelIndexList.append(dataOut.channelList.index(channel))
1216
1249
1217 x = dataOut.getTimeRange()
1250 x = dataOut.getTimeRange()
1218 #y = dataOut.getHeiRange()
1251 #y = dataOut.getHeiRange()
1219 factor = dataOut.normFactor
1252 factor = dataOut.normFactor
1220 noise = dataOut.noise[channelIndexList]/factor
1253 noise = dataOut.noise[channelIndexList]/factor
1221 noisedB = 10*numpy.log10(noise)
1254 noisedB = 10*numpy.log10(noise)
1222
1255
1223 thisDatetime = dataOut.datatime
1256 thisDatetime = dataOut.datatime
1224
1257
1225 title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1258 title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1226 xlabel = ""
1259 xlabel = ""
1227 ylabel = "Intensity (dB)"
1260 ylabel = "Intensity (dB)"
1228 update_figfile = False
1261 update_figfile = False
1229
1262
1230 if not self.isConfig:
1263 if not self.isConfig:
1231
1264
1232 nplots = 1
1265 nplots = 1
1233
1266
1234 self.setup(id=id,
1267 self.setup(id=id,
1235 nplots=nplots,
1268 nplots=nplots,
1236 wintitle=wintitle,
1269 wintitle=wintitle,
1237 showprofile=showprofile,
1270 showprofile=showprofile,
1238 show=show)
1271 show=show)
1239
1272
1240 if timerange != None:
1273 if timerange != None:
1241 self.timerange = timerange
1274 self.timerange = timerange
1242
1275
1243 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1276 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1244
1277
1245 if ymin == None: ymin = numpy.floor(numpy.nanmin(noisedB)) - 10.0
1278 if ymin == None: ymin = numpy.floor(numpy.nanmin(noisedB)) - 10.0
1246 if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0
1279 if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0
1247
1280
1248 self.FTP_WEI = ftp_wei
1281 self.FTP_WEI = ftp_wei
1249 self.EXP_CODE = exp_code
1282 self.EXP_CODE = exp_code
1250 self.SUB_EXP_CODE = sub_exp_code
1283 self.SUB_EXP_CODE = sub_exp_code
1251 self.PLOT_POS = plot_pos
1284 self.PLOT_POS = plot_pos
1252
1285
1253
1286
1254 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1287 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1255 self.isConfig = True
1288 self.isConfig = True
1256 self.figfile = figfile
1289 self.figfile = figfile
1257 self.xdata = numpy.array([])
1290 self.xdata = numpy.array([])
1258 self.ydata = numpy.array([])
1291 self.ydata = numpy.array([])
1259
1292
1260 update_figfile = True
1293 update_figfile = True
1261
1294
1262 #open file beacon phase
1295 #open file beacon phase
1263 path = '%s%03d' %(self.PREFIX, self.id)
1296 path = '%s%03d' %(self.PREFIX, self.id)
1264 noise_file = os.path.join(path,'%s.txt'%self.name)
1297 noise_file = os.path.join(path,'%s.txt'%self.name)
1265 self.filename_noise = os.path.join(figpath,noise_file)
1298 self.filename_noise = os.path.join(figpath,noise_file)
1266
1299
1267 self.setWinTitle(title)
1300 self.setWinTitle(title)
1268
1301
1269 title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1302 title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1270
1303
1271 legendlabels = ["channel %d"%(idchannel) for idchannel in channelList]
1304 legendlabels = ["channel %d"%(idchannel) for idchannel in channelList]
1272 axes = self.axesList[0]
1305 axes = self.axesList[0]
1273
1306
1274 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1307 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1275
1308
1276 if len(self.ydata)==0:
1309 if len(self.ydata)==0:
1277 self.ydata = noisedB.reshape(-1,1)
1310 self.ydata = noisedB.reshape(-1,1)
1278 else:
1311 else:
1279 self.ydata = numpy.hstack((self.ydata, noisedB.reshape(-1,1)))
1312 self.ydata = numpy.hstack((self.ydata, noisedB.reshape(-1,1)))
1280
1313
1281
1314
1282 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1315 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1283 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1316 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1284 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1317 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1285 XAxisAsTime=True, grid='both'
1318 XAxisAsTime=True, grid='both'
1286 )
1319 )
1287
1320
1288 self.draw()
1321 self.draw()
1289
1322
1290 if dataOut.ltctime >= self.xmax:
1323 if dataOut.ltctime >= self.xmax:
1291 self.counter_imagwr = wr_period
1324 self.counter_imagwr = wr_period
1292 self.isConfig = False
1325 self.isConfig = False
1293 update_figfile = True
1326 update_figfile = True
1294
1327
1295 self.save(figpath=figpath,
1328 self.save(figpath=figpath,
1296 figfile=figfile,
1329 figfile=figfile,
1297 save=save,
1330 save=save,
1298 ftp=ftp,
1331 ftp=ftp,
1299 wr_period=wr_period,
1332 wr_period=wr_period,
1300 thisDatetime=thisDatetime,
1333 thisDatetime=thisDatetime,
1301 update_figfile=update_figfile)
1334 update_figfile=update_figfile)
1302
1335
1303 #store data beacon phase
1336 #store data beacon phase
1304 if save:
1337 if save:
1305 self.save_data(self.filename_noise, noisedB, thisDatetime)
1338 self.save_data(self.filename_noise, noisedB, thisDatetime)
1306
1339
1307 class BeaconPhase(Figure):
1340 class BeaconPhase(Figure):
1308
1341
1309 __isConfig = None
1342 __isConfig = None
1310 __nsubplots = None
1343 __nsubplots = None
1311
1344
1312 PREFIX = 'beacon_phase'
1345 PREFIX = 'beacon_phase'
1346
1347 parameters = {
1348 'id': 'string',
1349 'wintitle': 'string',
1350 'pairsList': 'pairsList',
1351 'showprofile': 'boolean',
1352 'xmin': 'float',
1353 'xmax': 'float',
1354 'ymin': 'float',
1355 'ymax': 'float',
1356 'hmin': 'float',
1357 'hmax': 'float',
1358 'timerange': 'float',
1359 'save': 'boolean',
1360 'figpath': 'string',
1361 'figfile': 'string',
1362 'show': 'boolean',
1363 'ftp': 'string',
1364 'wr_period': 'int',
1365 'server': 'string',
1366 'folder': 'string',
1367 'username': 'string',
1368 'password': 'string',
1369 'ftp_wei': 'int',
1370 'exp_code': 'int',
1371 'sub_exp_code': 'int',
1372 'plot_pos': 'int',
1373 }
1313
1374
1314 def __init__(self, **kwargs):
1375 def __init__(self, **kwargs):
1315 Figure.__init__(self, **kwargs)
1376 Figure.__init__(self, **kwargs)
1316 self.timerange = 24*60*60
1377 self.timerange = 24*60*60
1317 self.isConfig = False
1378 self.isConfig = False
1318 self.__nsubplots = 1
1379 self.__nsubplots = 1
1319 self.counter_imagwr = 0
1380 self.counter_imagwr = 0
1320 self.WIDTH = 800
1381 self.WIDTH = 800
1321 self.HEIGHT = 400
1382 self.HEIGHT = 400
1322 self.WIDTHPROF = 120
1383 self.WIDTHPROF = 120
1323 self.HEIGHTPROF = 0
1384 self.HEIGHTPROF = 0
1324 self.xdata = None
1385 self.xdata = None
1325 self.ydata = None
1386 self.ydata = None
1326
1387
1327 self.PLOT_CODE = BEACON_CODE
1388 self.PLOT_CODE = BEACON_CODE
1328
1389
1329 self.FTP_WEI = None
1390 self.FTP_WEI = None
1330 self.EXP_CODE = None
1391 self.EXP_CODE = None
1331 self.SUB_EXP_CODE = None
1392 self.SUB_EXP_CODE = None
1332 self.PLOT_POS = None
1393 self.PLOT_POS = None
1333
1394
1334 self.filename_phase = None
1395 self.filename_phase = None
1335
1396
1336 self.figfile = None
1397 self.figfile = None
1337
1398
1338 self.xmin = None
1399 self.xmin = None
1339 self.xmax = None
1400 self.xmax = None
1340
1401
1341 def getSubplots(self):
1402 def getSubplots(self):
1342
1403
1343 ncol = 1
1404 ncol = 1
1344 nrow = 1
1405 nrow = 1
1345
1406
1346 return nrow, ncol
1407 return nrow, ncol
1347
1408
1348 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1409 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1349
1410
1350 self.__showprofile = showprofile
1411 self.__showprofile = showprofile
1351 self.nplots = nplots
1412 self.nplots = nplots
1352
1413
1353 ncolspan = 7
1414 ncolspan = 7
1354 colspan = 6
1415 colspan = 6
1355 self.__nsubplots = 2
1416 self.__nsubplots = 2
1356
1417
1357 self.createFigure(id = id,
1418 self.createFigure(id = id,
1358 wintitle = wintitle,
1419 wintitle = wintitle,
1359 widthplot = self.WIDTH+self.WIDTHPROF,
1420 widthplot = self.WIDTH+self.WIDTHPROF,
1360 heightplot = self.HEIGHT+self.HEIGHTPROF,
1421 heightplot = self.HEIGHT+self.HEIGHTPROF,
1361 show=show)
1422 show=show)
1362
1423
1363 nrow, ncol = self.getSubplots()
1424 nrow, ncol = self.getSubplots()
1364
1425
1365 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1426 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1366
1427
1367 def save_phase(self, filename_phase):
1428 def save_phase(self, filename_phase):
1368 f = open(filename_phase,'w+')
1429 f = open(filename_phase,'w+')
1369 f.write('\n\n')
1430 f.write('\n\n')
1370 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
1431 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
1371 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' )
1432 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' )
1372 f.close()
1433 f.close()
1373
1434
1374 def save_data(self, filename_phase, data, data_datetime):
1435 def save_data(self, filename_phase, data, data_datetime):
1375 f=open(filename_phase,'a')
1436 f=open(filename_phase,'a')
1376 timetuple_data = data_datetime.timetuple()
1437 timetuple_data = data_datetime.timetuple()
1377 day = str(timetuple_data.tm_mday)
1438 day = str(timetuple_data.tm_mday)
1378 month = str(timetuple_data.tm_mon)
1439 month = str(timetuple_data.tm_mon)
1379 year = str(timetuple_data.tm_year)
1440 year = str(timetuple_data.tm_year)
1380 hour = str(timetuple_data.tm_hour)
1441 hour = str(timetuple_data.tm_hour)
1381 minute = str(timetuple_data.tm_min)
1442 minute = str(timetuple_data.tm_min)
1382 second = str(timetuple_data.tm_sec)
1443 second = str(timetuple_data.tm_sec)
1383 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n')
1444 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n')
1384 f.close()
1445 f.close()
1385
1446
1386
1447
1387 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1448 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1388 xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None,
1449 xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None,
1389 timerange=None,
1450 timerange=None,
1390 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1451 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1391 server=None, folder=None, username=None, password=None,
1452 server=None, folder=None, username=None, password=None,
1392 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1453 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1393
1454
1394 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1455 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1395 return
1456 return
1396
1457
1397 if pairsList == None:
1458 if pairsList == None:
1398 pairsIndexList = dataOut.pairsIndexList[:10]
1459 pairsIndexList = dataOut.pairsIndexList[:10]
1399 else:
1460 else:
1400 pairsIndexList = []
1461 pairsIndexList = []
1401 for pair in pairsList:
1462 for pair in pairsList:
1402 if pair not in dataOut.pairsList:
1463 if pair not in dataOut.pairsList:
1403 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
1464 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
1404 pairsIndexList.append(dataOut.pairsList.index(pair))
1465 pairsIndexList.append(dataOut.pairsList.index(pair))
1405
1466
1406 if pairsIndexList == []:
1467 if pairsIndexList == []:
1407 return
1468 return
1408
1469
1409 # if len(pairsIndexList) > 4:
1470 # if len(pairsIndexList) > 4:
1410 # pairsIndexList = pairsIndexList[0:4]
1471 # pairsIndexList = pairsIndexList[0:4]
1411
1472
1412 hmin_index = None
1473 hmin_index = None
1413 hmax_index = None
1474 hmax_index = None
1414
1475
1415 if hmin != None and hmax != None:
1476 if hmin != None and hmax != None:
1416 indexes = numpy.arange(dataOut.nHeights)
1477 indexes = numpy.arange(dataOut.nHeights)
1417 hmin_list = indexes[dataOut.heightList >= hmin]
1478 hmin_list = indexes[dataOut.heightList >= hmin]
1418 hmax_list = indexes[dataOut.heightList <= hmax]
1479 hmax_list = indexes[dataOut.heightList <= hmax]
1419
1480
1420 if hmin_list.any():
1481 if hmin_list.any():
1421 hmin_index = hmin_list[0]
1482 hmin_index = hmin_list[0]
1422
1483
1423 if hmax_list.any():
1484 if hmax_list.any():
1424 hmax_index = hmax_list[-1]+1
1485 hmax_index = hmax_list[-1]+1
1425
1486
1426 x = dataOut.getTimeRange()
1487 x = dataOut.getTimeRange()
1427 #y = dataOut.getHeiRange()
1488 #y = dataOut.getHeiRange()
1428
1489
1429
1490
1430 thisDatetime = dataOut.datatime
1491 thisDatetime = dataOut.datatime
1431
1492
1432 title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1493 title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1433 xlabel = "Local Time"
1494 xlabel = "Local Time"
1434 ylabel = "Phase (degrees)"
1495 ylabel = "Phase (degrees)"
1435
1496
1436 update_figfile = False
1497 update_figfile = False
1437
1498
1438 nplots = len(pairsIndexList)
1499 nplots = len(pairsIndexList)
1439 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1500 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1440 phase_beacon = numpy.zeros(len(pairsIndexList))
1501 phase_beacon = numpy.zeros(len(pairsIndexList))
1441 for i in range(nplots):
1502 for i in range(nplots):
1442 pair = dataOut.pairsList[pairsIndexList[i]]
1503 pair = dataOut.pairsList[pairsIndexList[i]]
1443 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0)
1504 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0)
1444 powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0)
1505 powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0)
1445 powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0)
1506 powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0)
1446 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
1507 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
1447 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1508 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1448
1509
1449 #print "Phase %d%d" %(pair[0], pair[1])
1510 #print "Phase %d%d" %(pair[0], pair[1])
1450 #print phase[dataOut.beacon_heiIndexList]
1511 #print phase[dataOut.beacon_heiIndexList]
1451
1512
1452 if dataOut.beacon_heiIndexList:
1513 if dataOut.beacon_heiIndexList:
1453 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1514 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1454 else:
1515 else:
1455 phase_beacon[i] = numpy.average(phase)
1516 phase_beacon[i] = numpy.average(phase)
1456
1517
1457 if not self.isConfig:
1518 if not self.isConfig:
1458
1519
1459 nplots = len(pairsIndexList)
1520 nplots = len(pairsIndexList)
1460
1521
1461 self.setup(id=id,
1522 self.setup(id=id,
1462 nplots=nplots,
1523 nplots=nplots,
1463 wintitle=wintitle,
1524 wintitle=wintitle,
1464 showprofile=showprofile,
1525 showprofile=showprofile,
1465 show=show)
1526 show=show)
1466
1527
1467 if timerange != None:
1528 if timerange != None:
1468 self.timerange = timerange
1529 self.timerange = timerange
1469
1530
1470 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1531 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1471
1532
1472 if ymin == None: ymin = 0
1533 if ymin == None: ymin = 0
1473 if ymax == None: ymax = 360
1534 if ymax == None: ymax = 360
1474
1535
1475 self.FTP_WEI = ftp_wei
1536 self.FTP_WEI = ftp_wei
1476 self.EXP_CODE = exp_code
1537 self.EXP_CODE = exp_code
1477 self.SUB_EXP_CODE = sub_exp_code
1538 self.SUB_EXP_CODE = sub_exp_code
1478 self.PLOT_POS = plot_pos
1539 self.PLOT_POS = plot_pos
1479
1540
1480 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1541 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1481 self.isConfig = True
1542 self.isConfig = True
1482 self.figfile = figfile
1543 self.figfile = figfile
1483 self.xdata = numpy.array([])
1544 self.xdata = numpy.array([])
1484 self.ydata = numpy.array([])
1545 self.ydata = numpy.array([])
1485
1546
1486 update_figfile = True
1547 update_figfile = True
1487
1548
1488 #open file beacon phase
1549 #open file beacon phase
1489 path = '%s%03d' %(self.PREFIX, self.id)
1550 path = '%s%03d' %(self.PREFIX, self.id)
1490 beacon_file = os.path.join(path,'%s.txt'%self.name)
1551 beacon_file = os.path.join(path,'%s.txt'%self.name)
1491 self.filename_phase = os.path.join(figpath,beacon_file)
1552 self.filename_phase = os.path.join(figpath,beacon_file)
1492 #self.save_phase(self.filename_phase)
1553 #self.save_phase(self.filename_phase)
1493
1554
1494
1555
1495 #store data beacon phase
1556 #store data beacon phase
1496 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1557 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1497
1558
1498 self.setWinTitle(title)
1559 self.setWinTitle(title)
1499
1560
1500
1561
1501 title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1562 title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1502
1563
1503 legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList]
1564 legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList]
1504
1565
1505 axes = self.axesList[0]
1566 axes = self.axesList[0]
1506
1567
1507 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1568 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1508
1569
1509 if len(self.ydata)==0:
1570 if len(self.ydata)==0:
1510 self.ydata = phase_beacon.reshape(-1,1)
1571 self.ydata = phase_beacon.reshape(-1,1)
1511 else:
1572 else:
1512 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1573 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1513
1574
1514
1575
1515 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1576 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1516 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1577 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1517 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1578 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1518 XAxisAsTime=True, grid='both'
1579 XAxisAsTime=True, grid='both'
1519 )
1580 )
1520
1581
1521 self.draw()
1582 self.draw()
1522
1583
1523 if dataOut.ltctime >= self.xmax:
1584 if dataOut.ltctime >= self.xmax:
1524 self.counter_imagwr = wr_period
1585 self.counter_imagwr = wr_period
1525 self.isConfig = False
1586 self.isConfig = False
1526 update_figfile = True
1587 update_figfile = True
1527
1588
1528 self.save(figpath=figpath,
1589 self.save(figpath=figpath,
1529 figfile=figfile,
1590 figfile=figfile,
1530 save=save,
1591 save=save,
1531 ftp=ftp,
1592 ftp=ftp,
1532 wr_period=wr_period,
1593 wr_period=wr_period,
1533 thisDatetime=thisDatetime,
1594 thisDatetime=thisDatetime,
1534 update_figfile=update_figfile)
1595 update_figfile=update_figfile)
@@ -1,141 +1,144
1 '''
1 '''
2 @author: Daniel Suarez
2 @author: Daniel Suarez
3 '''
3 '''
4 import numpy
4 import numpy
5 from jroproc_base import ProcessingUnit, Operation
5 from jroproc_base import ProcessingUnit, Operation
6 from schainpy.model.data.jroamisr import AMISR
6 from schainpy.model.data.jroamisr import AMISR
7
7
8 class AMISRProc(ProcessingUnit):
8 class AMISRProc(ProcessingUnit):
9 def __init__(self):
9 def __init__(self):
10 ProcessingUnit.__init__(self)
10 ProcessingUnit.__init__(self)
11 self.objectDict = {}
11 self.objectDict = {}
12 self.dataOut = AMISR()
12 self.dataOut = AMISR()
13
13
14 def run(self):
14 def run(self):
15 if self.dataIn.type == 'AMISR':
15 if self.dataIn.type == 'AMISR':
16 self.dataOut.copy(self.dataIn)
16 self.dataOut.copy(self.dataIn)
17
17
18
18
19 class PrintInfo(Operation):
19 class PrintInfo(Operation):
20 def __init__(self):
20 def __init__(self):
21 self.__isPrinted = False
21 self.__isPrinted = False
22
22
23 def run(self, dataOut):
23 def run(self, dataOut):
24
24
25 if not self.__isPrinted:
25 if not self.__isPrinted:
26 print 'Number of Records by File: %d'%dataOut.nRecords
26 print 'Number of Records by File: %d'%dataOut.nRecords
27 print 'Number of Pulses: %d'%dataOut.nProfiles
27 print 'Number of Pulses: %d'%dataOut.nProfiles
28 print 'Number of Pulses by Frame: %d'%dataOut.npulseByFrame
28 print 'Number of Pulses by Frame: %d'%dataOut.npulseByFrame
29 print 'Number of Samples by Pulse: %d'%len(dataOut.heightList)
29 print 'Number of Samples by Pulse: %d'%len(dataOut.heightList)
30 print 'Ipp Seconds: %f'%dataOut.ippSeconds
30 print 'Ipp Seconds: %f'%dataOut.ippSeconds
31 print 'Number of Beams: %d'%dataOut.nBeams
31 print 'Number of Beams: %d'%dataOut.nBeams
32 print 'BeamCodes:'
32 print 'BeamCodes:'
33 beamStrList = ['Beam %d -> Code=%d, azimuth=%2.2f, zenith=%2.2f, gain=%2.2f'%(k,v[0],v[1],v[2],v[3]) for k,v in dataOut.beamCodeDict.items()]
33 beamStrList = ['Beam %d -> Code=%d, azimuth=%2.2f, zenith=%2.2f, gain=%2.2f'%(k,v[0],v[1],v[2],v[3]) for k,v in dataOut.beamCodeDict.items()]
34 for b in beamStrList:
34 for b in beamStrList:
35 print b
35 print b
36 self.__isPrinted = True
36 self.__isPrinted = True
37
37
38 return
38 return
39
39
40
40
41 class BeamSelector(Operation):
41 class BeamSelector(Operation):
42 profileIndex = None
42 profileIndex = None
43 nProfiles = None
43 nProfiles = None
44 parameters = {
45 'beam': 'string',
46 }
44
47
45 def __init__(self):
48 def __init__(self):
46
49
47 self.profileIndex = 0
50 self.profileIndex = 0
48 self.__isConfig = False
51 self.__isConfig = False
49
52
50 def incIndex(self):
53 def incIndex(self):
51 self.profileIndex += 1
54 self.profileIndex += 1
52
55
53 if self.profileIndex >= self.nProfiles:
56 if self.profileIndex >= self.nProfiles:
54 self.profileIndex = 0
57 self.profileIndex = 0
55
58
56 def isProfileInRange(self, minIndex, maxIndex):
59 def isProfileInRange(self, minIndex, maxIndex):
57
60
58 if self.profileIndex < minIndex:
61 if self.profileIndex < minIndex:
59 return False
62 return False
60
63
61 if self.profileIndex > maxIndex:
64 if self.profileIndex > maxIndex:
62 return False
65 return False
63
66
64 return True
67 return True
65
68
66 def isProfileInList(self, profileList):
69 def isProfileInList(self, profileList):
67
70
68 if self.profileIndex not in profileList:
71 if self.profileIndex not in profileList:
69 return False
72 return False
70
73
71 return True
74 return True
72
75
73 def run(self, dataOut, beam=None):
76 def run(self, dataOut, beam=None):
74
77
75 dataOut.flagNoData = True
78 dataOut.flagNoData = True
76
79
77 if not(self.__isConfig):
80 if not(self.__isConfig):
78
81
79 self.nProfiles = dataOut.nProfiles
82 self.nProfiles = dataOut.nProfiles
80 self.profileIndex = dataOut.profileIndex
83 self.profileIndex = dataOut.profileIndex
81 self.__isConfig = True
84 self.__isConfig = True
82
85
83 if beam != None:
86 if beam != None:
84 if self.isProfileInList(dataOut.beamRangeDict[beam]):
87 if self.isProfileInList(dataOut.beamRangeDict[beam]):
85 beamInfo = dataOut.beamCodeDict[beam]
88 beamInfo = dataOut.beamCodeDict[beam]
86 dataOut.azimuth = beamInfo[1]
89 dataOut.azimuth = beamInfo[1]
87 dataOut.zenith = beamInfo[2]
90 dataOut.zenith = beamInfo[2]
88 dataOut.gain = beamInfo[3]
91 dataOut.gain = beamInfo[3]
89 dataOut.flagNoData = False
92 dataOut.flagNoData = False
90
93
91 self.incIndex()
94 self.incIndex()
92 return 1
95 return 1
93
96
94 else:
97 else:
95 raise ValueError, "BeamSelector needs beam value"
98 raise ValueError, "BeamSelector needs beam value"
96
99
97 return 0
100 return 0
98
101
99 class ProfileToChannels(Operation):
102 class ProfileToChannels(Operation):
100
103
101 def __init__(self):
104 def __init__(self):
102 self.__isConfig = False
105 self.__isConfig = False
103 self.__counter_chan = 0
106 self.__counter_chan = 0
104 self.buffer = None
107 self.buffer = None
105
108
106 def isProfileInList(self, profileList):
109 def isProfileInList(self, profileList):
107
110
108 if self.profileIndex not in profileList:
111 if self.profileIndex not in profileList:
109 return False
112 return False
110
113
111 return True
114 return True
112
115
113 def run(self, dataOut):
116 def run(self, dataOut):
114
117
115 dataOut.flagNoData = True
118 dataOut.flagNoData = True
116
119
117 if not(self.__isConfig):
120 if not(self.__isConfig):
118 nchannels = len(dataOut.beamRangeDict.keys())
121 nchannels = len(dataOut.beamRangeDict.keys())
119 nsamples = dataOut.nHeights
122 nsamples = dataOut.nHeights
120 self.buffer = numpy.zeros((nchannels, nsamples), dtype = 'complex128')
123 self.buffer = numpy.zeros((nchannels, nsamples), dtype = 'complex128')
121 dataOut.beam.codeList = [dataOut.beamCodeDict[x][0] for x in range(nchannels)]
124 dataOut.beam.codeList = [dataOut.beamCodeDict[x][0] for x in range(nchannels)]
122 dataOut.beam.azimuthList = [dataOut.beamCodeDict[x][1] for x in range(nchannels)]
125 dataOut.beam.azimuthList = [dataOut.beamCodeDict[x][1] for x in range(nchannels)]
123 dataOut.beam.zenithList = [dataOut.beamCodeDict[x][2] for x in range(nchannels)]
126 dataOut.beam.zenithList = [dataOut.beamCodeDict[x][2] for x in range(nchannels)]
124 self.__isConfig = True
127 self.__isConfig = True
125
128
126 for i in range(self.buffer.shape[0]):
129 for i in range(self.buffer.shape[0]):
127 if dataOut.profileIndex in dataOut.beamRangeDict[i]:
130 if dataOut.profileIndex in dataOut.beamRangeDict[i]:
128 self.buffer[i,:] = dataOut.data
131 self.buffer[i,:] = dataOut.data
129 break
132 break
130
133
131
134
132 self.__counter_chan += 1
135 self.__counter_chan += 1
133
136
134 if self.__counter_chan >= self.buffer.shape[0]:
137 if self.__counter_chan >= self.buffer.shape[0]:
135 self.__counter_chan = 0
138 self.__counter_chan = 0
136 dataOut.data = self.buffer.copy()
139 dataOut.data = self.buffer.copy()
137 dataOut.channelList = range(self.buffer.shape[0])
140 dataOut.channelList = range(self.buffer.shape[0])
138 self.__isConfig = False
141 self.__isConfig = False
139 dataOut.flagNoData = False
142 dataOut.flagNoData = False
140 pass
143 pass
141 No newline at end of file
144
@@ -1,1283 +1,1290
1 import sys
1 import sys
2 import numpy
2 import numpy
3 from scipy import interpolate
3 from scipy import interpolate
4
4
5 from jroproc_base import ProcessingUnit, Operation
5 from jroproc_base import ProcessingUnit, Operation
6 from schainpy.model.data.jrodata import Voltage
6 from schainpy.model.data.jrodata import Voltage
7
7
8 class VoltageProc(ProcessingUnit):
8 class VoltageProc(ProcessingUnit):
9
9
10
10
11 def __init__(self, **kwargs):
11 def __init__(self, **kwargs):
12
12
13 ProcessingUnit.__init__(self, **kwargs)
13 ProcessingUnit.__init__(self, **kwargs)
14
14
15 # self.objectDict = {}
15 # self.objectDict = {}
16 self.dataOut = Voltage()
16 self.dataOut = Voltage()
17 self.flip = 1
17 self.flip = 1
18
18
19 def run(self):
19 def run(self):
20 if self.dataIn.type == 'AMISR':
20 if self.dataIn.type == 'AMISR':
21 self.__updateObjFromAmisrInput()
21 self.__updateObjFromAmisrInput()
22
22
23 if self.dataIn.type == 'Voltage':
23 if self.dataIn.type == 'Voltage':
24 self.dataOut.copy(self.dataIn)
24 self.dataOut.copy(self.dataIn)
25
25
26 # self.dataOut.copy(self.dataIn)
26 # self.dataOut.copy(self.dataIn)
27
27
28 def __updateObjFromAmisrInput(self):
28 def __updateObjFromAmisrInput(self):
29
29
30 self.dataOut.timeZone = self.dataIn.timeZone
30 self.dataOut.timeZone = self.dataIn.timeZone
31 self.dataOut.dstFlag = self.dataIn.dstFlag
31 self.dataOut.dstFlag = self.dataIn.dstFlag
32 self.dataOut.errorCount = self.dataIn.errorCount
32 self.dataOut.errorCount = self.dataIn.errorCount
33 self.dataOut.useLocalTime = self.dataIn.useLocalTime
33 self.dataOut.useLocalTime = self.dataIn.useLocalTime
34
34
35 self.dataOut.flagNoData = self.dataIn.flagNoData
35 self.dataOut.flagNoData = self.dataIn.flagNoData
36 self.dataOut.data = self.dataIn.data
36 self.dataOut.data = self.dataIn.data
37 self.dataOut.utctime = self.dataIn.utctime
37 self.dataOut.utctime = self.dataIn.utctime
38 self.dataOut.channelList = self.dataIn.channelList
38 self.dataOut.channelList = self.dataIn.channelList
39 # self.dataOut.timeInterval = self.dataIn.timeInterval
39 # self.dataOut.timeInterval = self.dataIn.timeInterval
40 self.dataOut.heightList = self.dataIn.heightList
40 self.dataOut.heightList = self.dataIn.heightList
41 self.dataOut.nProfiles = self.dataIn.nProfiles
41 self.dataOut.nProfiles = self.dataIn.nProfiles
42
42
43 self.dataOut.nCohInt = self.dataIn.nCohInt
43 self.dataOut.nCohInt = self.dataIn.nCohInt
44 self.dataOut.ippSeconds = self.dataIn.ippSeconds
44 self.dataOut.ippSeconds = self.dataIn.ippSeconds
45 self.dataOut.frequency = self.dataIn.frequency
45 self.dataOut.frequency = self.dataIn.frequency
46
46
47 self.dataOut.azimuth = self.dataIn.azimuth
47 self.dataOut.azimuth = self.dataIn.azimuth
48 self.dataOut.zenith = self.dataIn.zenith
48 self.dataOut.zenith = self.dataIn.zenith
49
49
50 self.dataOut.beam.codeList = self.dataIn.beam.codeList
50 self.dataOut.beam.codeList = self.dataIn.beam.codeList
51 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
51 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
52 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
52 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
53 #
53 #
54 # pass#
54 # pass#
55 #
55 #
56 # def init(self):
56 # def init(self):
57 #
57 #
58 #
58 #
59 # if self.dataIn.type == 'AMISR':
59 # if self.dataIn.type == 'AMISR':
60 # self.__updateObjFromAmisrInput()
60 # self.__updateObjFromAmisrInput()
61 #
61 #
62 # if self.dataIn.type == 'Voltage':
62 # if self.dataIn.type == 'Voltage':
63 # self.dataOut.copy(self.dataIn)
63 # self.dataOut.copy(self.dataIn)
64 # # No necesita copiar en cada init() los atributos de dataIn
64 # # No necesita copiar en cada init() los atributos de dataIn
65 # # la copia deberia hacerse por cada nuevo bloque de datos
65 # # la copia deberia hacerse por cada nuevo bloque de datos
66
66
67 def selectChannels(self, channelList):
67 def selectChannels(self, channelList):
68
68
69 channelIndexList = []
69 channelIndexList = []
70
70
71 for channel in channelList:
71 for channel in channelList:
72 if channel not in self.dataOut.channelList:
72 if channel not in self.dataOut.channelList:
73 raise ValueError, "Channel %d is not in %s" %(channel, str(self.dataOut.channelList))
73 raise ValueError, "Channel %d is not in %s" %(channel, str(self.dataOut.channelList))
74
74
75 index = self.dataOut.channelList.index(channel)
75 index = self.dataOut.channelList.index(channel)
76 channelIndexList.append(index)
76 channelIndexList.append(index)
77
77
78 self.selectChannelsByIndex(channelIndexList)
78 self.selectChannelsByIndex(channelIndexList)
79
79
80 def selectChannelsByIndex(self, channelIndexList):
80 def selectChannelsByIndex(self, channelIndexList):
81 """
81 """
82 Selecciona un bloque de datos en base a canales segun el channelIndexList
82 Selecciona un bloque de datos en base a canales segun el channelIndexList
83
83
84 Input:
84 Input:
85 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
85 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
86
86
87 Affected:
87 Affected:
88 self.dataOut.data
88 self.dataOut.data
89 self.dataOut.channelIndexList
89 self.dataOut.channelIndexList
90 self.dataOut.nChannels
90 self.dataOut.nChannels
91 self.dataOut.m_ProcessingHeader.totalSpectra
91 self.dataOut.m_ProcessingHeader.totalSpectra
92 self.dataOut.systemHeaderObj.numChannels
92 self.dataOut.systemHeaderObj.numChannels
93 self.dataOut.m_ProcessingHeader.blockSize
93 self.dataOut.m_ProcessingHeader.blockSize
94
94
95 Return:
95 Return:
96 None
96 None
97 """
97 """
98
98
99 for channelIndex in channelIndexList:
99 for channelIndex in channelIndexList:
100 if channelIndex not in self.dataOut.channelIndexList:
100 if channelIndex not in self.dataOut.channelIndexList:
101 print channelIndexList
101 print channelIndexList
102 raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex
102 raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex
103
103
104 if self.dataOut.flagDataAsBlock:
104 if self.dataOut.flagDataAsBlock:
105 """
105 """
106 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
106 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
107 """
107 """
108 data = self.dataOut.data[channelIndexList,:,:]
108 data = self.dataOut.data[channelIndexList,:,:]
109 else:
109 else:
110 data = self.dataOut.data[channelIndexList,:]
110 data = self.dataOut.data[channelIndexList,:]
111
111
112 self.dataOut.data = data
112 self.dataOut.data = data
113 self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList]
113 self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList]
114 # self.dataOut.nChannels = nChannels
114 # self.dataOut.nChannels = nChannels
115
115
116 return 1
116 return 1
117
117
118 def selectHeights(self, minHei=None, maxHei=None):
118 def selectHeights(self, minHei=None, maxHei=None):
119 """
119 """
120 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
120 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
121 minHei <= height <= maxHei
121 minHei <= height <= maxHei
122
122
123 Input:
123 Input:
124 minHei : valor minimo de altura a considerar
124 minHei : valor minimo de altura a considerar
125 maxHei : valor maximo de altura a considerar
125 maxHei : valor maximo de altura a considerar
126
126
127 Affected:
127 Affected:
128 Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex
128 Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex
129
129
130 Return:
130 Return:
131 1 si el metodo se ejecuto con exito caso contrario devuelve 0
131 1 si el metodo se ejecuto con exito caso contrario devuelve 0
132 """
132 """
133
133
134 if minHei == None:
134 if minHei == None:
135 minHei = self.dataOut.heightList[0]
135 minHei = self.dataOut.heightList[0]
136
136
137 if maxHei == None:
137 if maxHei == None:
138 maxHei = self.dataOut.heightList[-1]
138 maxHei = self.dataOut.heightList[-1]
139
139
140 if (minHei < self.dataOut.heightList[0]):
140 if (minHei < self.dataOut.heightList[0]):
141 minHei = self.dataOut.heightList[0]
141 minHei = self.dataOut.heightList[0]
142
142
143 if (maxHei > self.dataOut.heightList[-1]):
143 if (maxHei > self.dataOut.heightList[-1]):
144 maxHei = self.dataOut.heightList[-1]
144 maxHei = self.dataOut.heightList[-1]
145
145
146 minIndex = 0
146 minIndex = 0
147 maxIndex = 0
147 maxIndex = 0
148 heights = self.dataOut.heightList
148 heights = self.dataOut.heightList
149
149
150 inda = numpy.where(heights >= minHei)
150 inda = numpy.where(heights >= minHei)
151 indb = numpy.where(heights <= maxHei)
151 indb = numpy.where(heights <= maxHei)
152
152
153 try:
153 try:
154 minIndex = inda[0][0]
154 minIndex = inda[0][0]
155 except:
155 except:
156 minIndex = 0
156 minIndex = 0
157
157
158 try:
158 try:
159 maxIndex = indb[0][-1]
159 maxIndex = indb[0][-1]
160 except:
160 except:
161 maxIndex = len(heights)
161 maxIndex = len(heights)
162
162
163 self.selectHeightsByIndex(minIndex, maxIndex)
163 self.selectHeightsByIndex(minIndex, maxIndex)
164
164
165 return 1
165 return 1
166
166
167
167
168 def selectHeightsByIndex(self, minIndex, maxIndex):
168 def selectHeightsByIndex(self, minIndex, maxIndex):
169 """
169 """
170 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
170 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
171 minIndex <= index <= maxIndex
171 minIndex <= index <= maxIndex
172
172
173 Input:
173 Input:
174 minIndex : valor de indice minimo de altura a considerar
174 minIndex : valor de indice minimo de altura a considerar
175 maxIndex : valor de indice maximo de altura a considerar
175 maxIndex : valor de indice maximo de altura a considerar
176
176
177 Affected:
177 Affected:
178 self.dataOut.data
178 self.dataOut.data
179 self.dataOut.heightList
179 self.dataOut.heightList
180
180
181 Return:
181 Return:
182 1 si el metodo se ejecuto con exito caso contrario devuelve 0
182 1 si el metodo se ejecuto con exito caso contrario devuelve 0
183 """
183 """
184
184
185 if (minIndex < 0) or (minIndex > maxIndex):
185 if (minIndex < 0) or (minIndex > maxIndex):
186 raise ValueError, "Height index range (%d,%d) is not valid" % (minIndex, maxIndex)
186 raise ValueError, "Height index range (%d,%d) is not valid" % (minIndex, maxIndex)
187
187
188 if (maxIndex >= self.dataOut.nHeights):
188 if (maxIndex >= self.dataOut.nHeights):
189 maxIndex = self.dataOut.nHeights
189 maxIndex = self.dataOut.nHeights
190
190
191 #voltage
191 #voltage
192 if self.dataOut.flagDataAsBlock:
192 if self.dataOut.flagDataAsBlock:
193 """
193 """
194 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
194 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
195 """
195 """
196 data = self.dataOut.data[:,:, minIndex:maxIndex]
196 data = self.dataOut.data[:,:, minIndex:maxIndex]
197 else:
197 else:
198 data = self.dataOut.data[:, minIndex:maxIndex]
198 data = self.dataOut.data[:, minIndex:maxIndex]
199
199
200 # firstHeight = self.dataOut.heightList[minIndex]
200 # firstHeight = self.dataOut.heightList[minIndex]
201
201
202 self.dataOut.data = data
202 self.dataOut.data = data
203 self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex]
203 self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex]
204
204
205 if self.dataOut.nHeights <= 1:
205 if self.dataOut.nHeights <= 1:
206 raise ValueError, "selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights)
206 raise ValueError, "selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights)
207
207
208 return 1
208 return 1
209
209
210
210
211 def filterByHeights(self, window):
211 def filterByHeights(self, window):
212
212
213 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
213 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
214
214
215 if window == None:
215 if window == None:
216 window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight
216 window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight
217
217
218 newdelta = deltaHeight * window
218 newdelta = deltaHeight * window
219 r = self.dataOut.nHeights % window
219 r = self.dataOut.nHeights % window
220 newheights = (self.dataOut.nHeights-r)/window
220 newheights = (self.dataOut.nHeights-r)/window
221
221
222 if newheights <= 1:
222 if newheights <= 1:
223 raise ValueError, "filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window)
223 raise ValueError, "filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window)
224
224
225 if self.dataOut.flagDataAsBlock:
225 if self.dataOut.flagDataAsBlock:
226 """
226 """
227 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
227 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
228 """
228 """
229 buffer = self.dataOut.data[:, :, 0:self.dataOut.nHeights-r]
229 buffer = self.dataOut.data[:, :, 0:self.dataOut.nHeights-r]
230 buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nProfiles,self.dataOut.nHeights/window,window)
230 buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nProfiles,self.dataOut.nHeights/window,window)
231 buffer = numpy.sum(buffer,3)
231 buffer = numpy.sum(buffer,3)
232
232
233 else:
233 else:
234 buffer = self.dataOut.data[:,0:self.dataOut.nHeights-r]
234 buffer = self.dataOut.data[:,0:self.dataOut.nHeights-r]
235 buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nHeights/window,window)
235 buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nHeights/window,window)
236 buffer = numpy.sum(buffer,2)
236 buffer = numpy.sum(buffer,2)
237
237
238 self.dataOut.data = buffer
238 self.dataOut.data = buffer
239 self.dataOut.heightList = self.dataOut.heightList[0] + numpy.arange( newheights )*newdelta
239 self.dataOut.heightList = self.dataOut.heightList[0] + numpy.arange( newheights )*newdelta
240 self.dataOut.windowOfFilter = window
240 self.dataOut.windowOfFilter = window
241
241
242 def setH0(self, h0, deltaHeight = None):
242 def setH0(self, h0, deltaHeight = None):
243
243
244 if not deltaHeight:
244 if not deltaHeight:
245 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
245 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
246
246
247 nHeights = self.dataOut.nHeights
247 nHeights = self.dataOut.nHeights
248
248
249 newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight
249 newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight
250
250
251 self.dataOut.heightList = newHeiRange
251 self.dataOut.heightList = newHeiRange
252
252
253 def deFlip(self, channelList = []):
253 def deFlip(self, channelList = []):
254
254
255 data = self.dataOut.data.copy()
255 data = self.dataOut.data.copy()
256
256
257 if self.dataOut.flagDataAsBlock:
257 if self.dataOut.flagDataAsBlock:
258 flip = self.flip
258 flip = self.flip
259 profileList = range(self.dataOut.nProfiles)
259 profileList = range(self.dataOut.nProfiles)
260
260
261 if not channelList:
261 if not channelList:
262 for thisProfile in profileList:
262 for thisProfile in profileList:
263 data[:,thisProfile,:] = data[:,thisProfile,:]*flip
263 data[:,thisProfile,:] = data[:,thisProfile,:]*flip
264 flip *= -1.0
264 flip *= -1.0
265 else:
265 else:
266 for thisChannel in channelList:
266 for thisChannel in channelList:
267 if thisChannel not in self.dataOut.channelList:
267 if thisChannel not in self.dataOut.channelList:
268 continue
268 continue
269
269
270 for thisProfile in profileList:
270 for thisProfile in profileList:
271 data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip
271 data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip
272 flip *= -1.0
272 flip *= -1.0
273
273
274 self.flip = flip
274 self.flip = flip
275
275
276 else:
276 else:
277 if not channelList:
277 if not channelList:
278 data[:,:] = data[:,:]*self.flip
278 data[:,:] = data[:,:]*self.flip
279 else:
279 else:
280 for thisChannel in channelList:
280 for thisChannel in channelList:
281 if thisChannel not in self.dataOut.channelList:
281 if thisChannel not in self.dataOut.channelList:
282 continue
282 continue
283
283
284 data[thisChannel,:] = data[thisChannel,:]*self.flip
284 data[thisChannel,:] = data[thisChannel,:]*self.flip
285
285
286 self.flip *= -1.
286 self.flip *= -1.
287
287
288 self.dataOut.data = data
288 self.dataOut.data = data
289
289
290 def setRadarFrequency(self, frequency=None):
290 def setRadarFrequency(self, frequency=None):
291
291
292 if frequency != None:
292 if frequency != None:
293 self.dataOut.frequency = frequency
293 self.dataOut.frequency = frequency
294
294
295 return 1
295 return 1
296
296
297 def interpolateHeights(self, topLim, botLim):
297 def interpolateHeights(self, topLim, botLim):
298 #69 al 72 para julia
298 #69 al 72 para julia
299 #82-84 para meteoros
299 #82-84 para meteoros
300 if len(numpy.shape(self.dataOut.data))==2:
300 if len(numpy.shape(self.dataOut.data))==2:
301 sampInterp = (self.dataOut.data[:,botLim-1] + self.dataOut.data[:,topLim+1])/2
301 sampInterp = (self.dataOut.data[:,botLim-1] + self.dataOut.data[:,topLim+1])/2
302 sampInterp = numpy.transpose(numpy.tile(sampInterp,(topLim-botLim + 1,1)))
302 sampInterp = numpy.transpose(numpy.tile(sampInterp,(topLim-botLim + 1,1)))
303 #self.dataOut.data[:,botLim:limSup+1] = sampInterp
303 #self.dataOut.data[:,botLim:limSup+1] = sampInterp
304 self.dataOut.data[:,botLim:topLim+1] = sampInterp
304 self.dataOut.data[:,botLim:topLim+1] = sampInterp
305 else:
305 else:
306 nHeights = self.dataOut.data.shape[2]
306 nHeights = self.dataOut.data.shape[2]
307 x = numpy.hstack((numpy.arange(botLim),numpy.arange(topLim+1,nHeights)))
307 x = numpy.hstack((numpy.arange(botLim),numpy.arange(topLim+1,nHeights)))
308 y = self.dataOut.data[:,:,range(botLim)+range(topLim+1,nHeights)]
308 y = self.dataOut.data[:,:,range(botLim)+range(topLim+1,nHeights)]
309 f = interpolate.interp1d(x, y, axis = 2)
309 f = interpolate.interp1d(x, y, axis = 2)
310 xnew = numpy.arange(botLim,topLim+1)
310 xnew = numpy.arange(botLim,topLim+1)
311 ynew = f(xnew)
311 ynew = f(xnew)
312
312
313 self.dataOut.data[:,:,botLim:topLim+1] = ynew
313 self.dataOut.data[:,:,botLim:topLim+1] = ynew
314
314
315 # import collections
315 # import collections
316
316
317 class CohInt(Operation):
317 class CohInt(Operation):
318
318
319 isConfig = False
319 isConfig = False
320
320
321 __profIndex = 0
321 __profIndex = 0
322 __withOverapping = False
322 __withOverapping = False
323
323
324 __byTime = False
324 __byTime = False
325 __initime = None
325 __initime = None
326 __lastdatatime = None
326 __lastdatatime = None
327 __integrationtime = None
327 __integrationtime = None
328
328
329 __buffer = None
329 __buffer = None
330
330
331 __dataReady = False
331 __dataReady = False
332
332
333 n = None
333 n = None
334
334
335 parameters = {
336 'n': 'int',
337 'timeInterval':'float',
338 'overlapping': 'boolean',
339 'byblock': 'boolean'
340 }
335
341
336 def __init__(self, **kwargs):
342 def __init__(self, **kwargs):
337
343
338 Operation.__init__(self, **kwargs)
344 Operation.__init__(self, **kwargs)
339
345
340 # self.isConfig = False
346 # self.isConfig = False
341
347
342 def setup(self, n=None, timeInterval=None, overlapping=False, byblock=False):
348 def setup(self, n=None, timeInterval=None, overlapping=False, byblock=False):
343 """
349 """
344 Set the parameters of the integration class.
350 Set the parameters of the integration class.
345
351
346 Inputs:
352 Inputs:
347
353
348 n : Number of coherent integrations
354 n : Number of coherent integrations
349 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
355 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
350 overlapping :
356 overlapping :
351
352 """
357 """
353
358
354 self.__initime = None
359 self.__initime = None
355 self.__lastdatatime = 0
360 self.__lastdatatime = 0
356 self.__buffer = None
361 self.__buffer = None
357 self.__dataReady = False
362 self.__dataReady = False
358 self.byblock = byblock
363 self.byblock = byblock
359
364
360 if n == None and timeInterval == None:
365 if n == None and timeInterval == None:
361 raise ValueError, "n or timeInterval should be specified ..."
366 raise ValueError, "n or timeInterval should be specified ..."
362
367
363 if n != None:
368 if n != None:
364 self.n = n
369 self.n = n
365 self.__byTime = False
370 self.__byTime = False
366 else:
371 else:
367 self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line
372 self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line
368 self.n = 9999
373 self.n = 9999
369 self.__byTime = True
374 self.__byTime = True
370
375
371 if overlapping:
376 if overlapping:
372 self.__withOverapping = True
377 self.__withOverapping = True
373 self.__buffer = None
378 self.__buffer = None
374 else:
379 else:
375 self.__withOverapping = False
380 self.__withOverapping = False
376 self.__buffer = 0
381 self.__buffer = 0
377
382
378 self.__profIndex = 0
383 self.__profIndex = 0
379
384
380 def putData(self, data):
385 def putData(self, data):
381
386
382 """
387 """
383 Add a profile to the __buffer and increase in one the __profileIndex
388 Add a profile to the __buffer and increase in one the __profileIndex
384
389
385 """
390 """
386
391
387 if not self.__withOverapping:
392 if not self.__withOverapping:
388 self.__buffer += data.copy()
393 self.__buffer += data.copy()
389 self.__profIndex += 1
394 self.__profIndex += 1
390 return
395 return
391
396
392 #Overlapping data
397 #Overlapping data
393 nChannels, nHeis = data.shape
398 nChannels, nHeis = data.shape
394 data = numpy.reshape(data, (1, nChannels, nHeis))
399 data = numpy.reshape(data, (1, nChannels, nHeis))
395
400
396 #If the buffer is empty then it takes the data value
401 #If the buffer is empty then it takes the data value
397 if self.__buffer is None:
402 if self.__buffer is None:
398 self.__buffer = data
403 self.__buffer = data
399 self.__profIndex += 1
404 self.__profIndex += 1
400 return
405 return
401
406
402 #If the buffer length is lower than n then stakcing the data value
407 #If the buffer length is lower than n then stakcing the data value
403 if self.__profIndex < self.n:
408 if self.__profIndex < self.n:
404 self.__buffer = numpy.vstack((self.__buffer, data))
409 self.__buffer = numpy.vstack((self.__buffer, data))
405 self.__profIndex += 1
410 self.__profIndex += 1
406 return
411 return
407
412
408 #If the buffer length is equal to n then replacing the last buffer value with the data value
413 #If the buffer length is equal to n then replacing the last buffer value with the data value
409 self.__buffer = numpy.roll(self.__buffer, -1, axis=0)
414 self.__buffer = numpy.roll(self.__buffer, -1, axis=0)
410 self.__buffer[self.n-1] = data
415 self.__buffer[self.n-1] = data
411 self.__profIndex = self.n
416 self.__profIndex = self.n
412 return
417 return
413
418
414
419
415 def pushData(self):
420 def pushData(self):
416 """
421 """
417 Return the sum of the last profiles and the profiles used in the sum.
422 Return the sum of the last profiles and the profiles used in the sum.
418
423
419 Affected:
424 Affected:
420
425
421 self.__profileIndex
426 self.__profileIndex
422
427
423 """
428 """
424
429
425 if not self.__withOverapping:
430 if not self.__withOverapping:
426 data = self.__buffer
431 data = self.__buffer
427 n = self.__profIndex
432 n = self.__profIndex
428
433
429 self.__buffer = 0
434 self.__buffer = 0
430 self.__profIndex = 0
435 self.__profIndex = 0
431
436
432 return data, n
437 return data, n
433
438
434 #Integration with Overlapping
439 #Integration with Overlapping
435 data = numpy.sum(self.__buffer, axis=0)
440 data = numpy.sum(self.__buffer, axis=0)
436 n = self.__profIndex
441 n = self.__profIndex
437
442
438 return data, n
443 return data, n
439
444
440 def byProfiles(self, data):
445 def byProfiles(self, data):
441
446
442 self.__dataReady = False
447 self.__dataReady = False
443 avgdata = None
448 avgdata = None
444 # n = None
449 # n = None
445
450
446 self.putData(data)
451 self.putData(data)
447
452
448 if self.__profIndex == self.n:
453 if self.__profIndex == self.n:
449
454
450 avgdata, n = self.pushData()
455 avgdata, n = self.pushData()
451 self.__dataReady = True
456 self.__dataReady = True
452
457
453 return avgdata
458 return avgdata
454
459
455 def byTime(self, data, datatime):
460 def byTime(self, data, datatime):
456
461
457 self.__dataReady = False
462 self.__dataReady = False
458 avgdata = None
463 avgdata = None
459 n = None
464 n = None
460
465
461 self.putData(data)
466 self.putData(data)
462
467
463 if (datatime - self.__initime) >= self.__integrationtime:
468 if (datatime - self.__initime) >= self.__integrationtime:
464 avgdata, n = self.pushData()
469 avgdata, n = self.pushData()
465 self.n = n
470 self.n = n
466 self.__dataReady = True
471 self.__dataReady = True
467
472
468 return avgdata
473 return avgdata
469
474
470 def integrate(self, data, datatime=None):
475 def integrate(self, data, datatime=None):
471
476
472 if self.__initime == None:
477 if self.__initime == None:
473 self.__initime = datatime
478 self.__initime = datatime
474
479
475 if self.__byTime:
480 if self.__byTime:
476 avgdata = self.byTime(data, datatime)
481 avgdata = self.byTime(data, datatime)
477 else:
482 else:
478 avgdata = self.byProfiles(data)
483 avgdata = self.byProfiles(data)
479
484
480
485
481 self.__lastdatatime = datatime
486 self.__lastdatatime = datatime
482
487
483 if avgdata is None:
488 if avgdata is None:
484 return None, None
489 return None, None
485
490
486 avgdatatime = self.__initime
491 avgdatatime = self.__initime
487
492
488 deltatime = datatime -self.__lastdatatime
493 deltatime = datatime -self.__lastdatatime
489
494
490 if not self.__withOverapping:
495 if not self.__withOverapping:
491 self.__initime = datatime
496 self.__initime = datatime
492 else:
497 else:
493 self.__initime += deltatime
498 self.__initime += deltatime
494
499
495 return avgdata, avgdatatime
500 return avgdata, avgdatatime
496
501
497 def integrateByBlock(self, dataOut):
502 def integrateByBlock(self, dataOut):
498
503
499 times = int(dataOut.data.shape[1]/self.n)
504 times = int(dataOut.data.shape[1]/self.n)
500 avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex)
505 avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex)
501
506
502 id_min = 0
507 id_min = 0
503 id_max = self.n
508 id_max = self.n
504
509
505 for i in range(times):
510 for i in range(times):
506 junk = dataOut.data[:,id_min:id_max,:]
511 junk = dataOut.data[:,id_min:id_max,:]
507 avgdata[:,i,:] = junk.sum(axis=1)
512 avgdata[:,i,:] = junk.sum(axis=1)
508 id_min += self.n
513 id_min += self.n
509 id_max += self.n
514 id_max += self.n
510
515
511 timeInterval = dataOut.ippSeconds*self.n
516 timeInterval = dataOut.ippSeconds*self.n
512 avgdatatime = (times - 1) * timeInterval + dataOut.utctime
517 avgdatatime = (times - 1) * timeInterval + dataOut.utctime
513 self.__dataReady = True
518 self.__dataReady = True
514 return avgdata, avgdatatime
519 return avgdata, avgdatatime
515
520
516 def run(self, dataOut, **kwargs):
521 def run(self, dataOut, n=None, timeInterval=None, overlapping=False, byblock=False):
517
522
518 if not self.isConfig:
523 if not self.isConfig:
519 self.setup(**kwargs)
524 self.setup(n=n, timeInterval=timeInterval, overlapping=overlapping, byblock=byblock)
520 self.isConfig = True
525 self.isConfig = True
521
526
522 if dataOut.flagDataAsBlock:
527 if dataOut.flagDataAsBlock:
523 """
528 """
524 Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis]
529 Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis]
525 """
530 """
526 avgdata, avgdatatime = self.integrateByBlock(dataOut)
531 avgdata, avgdatatime = self.integrateByBlock(dataOut)
527 dataOut.nProfiles /= self.n
532 dataOut.nProfiles /= self.n
528 else:
533 else:
529 avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime)
534 avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime)
530
535
531 # dataOut.timeInterval *= n
536 # dataOut.timeInterval *= n
532 dataOut.flagNoData = True
537 dataOut.flagNoData = True
533
538
534 if self.__dataReady:
539 if self.__dataReady:
535 dataOut.data = avgdata
540 dataOut.data = avgdata
536 dataOut.nCohInt *= self.n
541 dataOut.nCohInt *= self.n
537 dataOut.utctime = avgdatatime
542 dataOut.utctime = avgdatatime
538 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt
543 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt
539 dataOut.flagNoData = False
544 dataOut.flagNoData = False
540
545
541 class Decoder(Operation):
546 class Decoder(Operation):
542
547
543 isConfig = False
548 isConfig = False
544 __profIndex = 0
549 __profIndex = 0
545
550
546 code = None
551 code = None
547
552
548 nCode = None
553 nCode = None
549 nBaud = None
554 nBaud = None
550
555
551
556
552 def __init__(self, **kwargs):
557 def __init__(self, **kwargs):
553
558
554 Operation.__init__(self, **kwargs)
559 Operation.__init__(self, **kwargs)
555
560
556 self.times = None
561 self.times = None
557 self.osamp = None
562 self.osamp = None
558 # self.__setValues = False
563 # self.__setValues = False
559 self.isConfig = False
564 self.isConfig = False
560
565
561 def setup(self, code, osamp, dataOut):
566 def setup(self, code, osamp, dataOut):
562
567
563 self.__profIndex = 0
568 self.__profIndex = 0
564
569
565 self.code = code
570 self.code = code
566
571
567 self.nCode = len(code)
572 self.nCode = len(code)
568 self.nBaud = len(code[0])
573 self.nBaud = len(code[0])
569
574
570 if (osamp != None) and (osamp >1):
575 if (osamp != None) and (osamp >1):
571 self.osamp = osamp
576 self.osamp = osamp
572 self.code = numpy.repeat(code, repeats=self.osamp, axis=1)
577 self.code = numpy.repeat(code, repeats=self.osamp, axis=1)
573 self.nBaud = self.nBaud*self.osamp
578 self.nBaud = self.nBaud*self.osamp
574
579
575 self.__nChannels = dataOut.nChannels
580 self.__nChannels = dataOut.nChannels
576 self.__nProfiles = dataOut.nProfiles
581 self.__nProfiles = dataOut.nProfiles
577 self.__nHeis = dataOut.nHeights
582 self.__nHeis = dataOut.nHeights
578
583
579 if self.__nHeis < self.nBaud:
584 if self.__nHeis < self.nBaud:
580 raise ValueError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
585 raise ValueError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
581
586
582 #Frequency
587 #Frequency
583 __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex)
588 __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex)
584
589
585 __codeBuffer[:,0:self.nBaud] = self.code
590 __codeBuffer[:,0:self.nBaud] = self.code
586
591
587 self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1))
592 self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1))
588
593
589 if dataOut.flagDataAsBlock:
594 if dataOut.flagDataAsBlock:
590
595
591 self.ndatadec = self.__nHeis #- self.nBaud + 1
596 self.ndatadec = self.__nHeis #- self.nBaud + 1
592
597
593 self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex)
598 self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex)
594
599
595 else:
600 else:
596
601
597 #Time
602 #Time
598 self.ndatadec = self.__nHeis #- self.nBaud + 1
603 self.ndatadec = self.__nHeis #- self.nBaud + 1
599
604
600 self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex)
605 self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex)
601
606
602 def __convolutionInFreq(self, data):
607 def __convolutionInFreq(self, data):
603
608
604 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
609 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
605
610
606 fft_data = numpy.fft.fft(data, axis=1)
611 fft_data = numpy.fft.fft(data, axis=1)
607
612
608 conv = fft_data*fft_code
613 conv = fft_data*fft_code
609
614
610 data = numpy.fft.ifft(conv,axis=1)
615 data = numpy.fft.ifft(conv,axis=1)
611
616
612 return data
617 return data
613
618
614 def __convolutionInFreqOpt(self, data):
619 def __convolutionInFreqOpt(self, data):
615
620
616 raise NotImplementedError
621 raise NotImplementedError
617
622
618 def __convolutionInTime(self, data):
623 def __convolutionInTime(self, data):
619
624
620 code = self.code[self.__profIndex]
625 code = self.code[self.__profIndex]
621
626
622 for i in range(self.__nChannels):
627 for i in range(self.__nChannels):
623 self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='full')[self.nBaud-1:]
628 self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='full')[self.nBaud-1:]
624
629
625 return self.datadecTime
630 return self.datadecTime
626
631
627 def __convolutionByBlockInTime(self, data):
632 def __convolutionByBlockInTime(self, data):
628
633
629 repetitions = self.__nProfiles / self.nCode
634 repetitions = self.__nProfiles / self.nCode
630
635
631 junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize))
636 junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize))
632 junk = junk.flatten()
637 junk = junk.flatten()
633 code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud))
638 code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud))
634
639
635 for i in range(self.__nChannels):
640 for i in range(self.__nChannels):
636 for j in range(self.__nProfiles):
641 for j in range(self.__nProfiles):
637 self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:]
642 self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:]
638
643
639 return self.datadecTime
644 return self.datadecTime
640
645
641 def __convolutionByBlockInFreq(self, data):
646 def __convolutionByBlockInFreq(self, data):
642
647
643 raise NotImplementedError, "Decoder by frequency fro Blocks not implemented"
648 raise NotImplementedError, "Decoder by frequency fro Blocks not implemented"
644
649
645
650
646 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
651 fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
647
652
648 fft_data = numpy.fft.fft(data, axis=2)
653 fft_data = numpy.fft.fft(data, axis=2)
649
654
650 conv = fft_data*fft_code
655 conv = fft_data*fft_code
651
656
652 data = numpy.fft.ifft(conv,axis=2)
657 data = numpy.fft.ifft(conv,axis=2)
653
658
654 return data
659 return data
655
660
656 def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None):
661 def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None):
657
662
658 if dataOut.flagDecodeData:
663 if dataOut.flagDecodeData:
659 print "This data is already decoded, recoding again ..."
664 print "This data is already decoded, recoding again ..."
660
665
661 if not self.isConfig:
666 if not self.isConfig:
662
667
663 if code is None:
668 if code is None:
664 if dataOut.code is None:
669 if dataOut.code is None:
665 raise ValueError, "Code could not be read from %s instance. Enter a value in Code parameter" %dataOut.type
670 raise ValueError, "Code could not be read from %s instance. Enter a value in Code parameter" %dataOut.type
666
671
667 code = dataOut.code
672 code = dataOut.code
668 else:
673 else:
669 code = numpy.array(code).reshape(nCode,nBaud)
674 code = numpy.array(code).reshape(nCode,nBaud)
670
675
671 self.setup(code, osamp, dataOut)
676 self.setup(code, osamp, dataOut)
672
677
673 self.isConfig = True
678 self.isConfig = True
674
679
675 if mode == 3:
680 if mode == 3:
676 sys.stderr.write("Decoder Warning: mode=%d is not valid, using mode=0\n" %mode)
681 sys.stderr.write("Decoder Warning: mode=%d is not valid, using mode=0\n" %mode)
677
682
678 if times != None:
683 if times != None:
679 sys.stderr.write("Decoder Warning: Argument 'times' in not used anymore\n")
684 sys.stderr.write("Decoder Warning: Argument 'times' in not used anymore\n")
680
685
681 if self.code is None:
686 if self.code is None:
682 print "Fail decoding: Code is not defined."
687 print "Fail decoding: Code is not defined."
683 return
688 return
684
689
685 datadec = None
690 datadec = None
686 if mode == 3:
691 if mode == 3:
687 mode = 0
692 mode = 0
688
693
689 if dataOut.flagDataAsBlock:
694 if dataOut.flagDataAsBlock:
690 """
695 """
691 Decoding when data have been read as block,
696 Decoding when data have been read as block,
692 """
697 """
693
698
694 if mode == 0:
699 if mode == 0:
695 datadec = self.__convolutionByBlockInTime(dataOut.data)
700 datadec = self.__convolutionByBlockInTime(dataOut.data)
696 if mode == 1:
701 if mode == 1:
697 datadec = self.__convolutionByBlockInFreq(dataOut.data)
702 datadec = self.__convolutionByBlockInFreq(dataOut.data)
698 else:
703 else:
699 """
704 """
700 Decoding when data have been read profile by profile
705 Decoding when data have been read profile by profile
701 """
706 """
702 if mode == 0:
707 if mode == 0:
703 datadec = self.__convolutionInTime(dataOut.data)
708 datadec = self.__convolutionInTime(dataOut.data)
704
709
705 if mode == 1:
710 if mode == 1:
706 datadec = self.__convolutionInFreq(dataOut.data)
711 datadec = self.__convolutionInFreq(dataOut.data)
707
712
708 if mode == 2:
713 if mode == 2:
709 datadec = self.__convolutionInFreqOpt(dataOut.data)
714 datadec = self.__convolutionInFreqOpt(dataOut.data)
710
715
711 if datadec is None:
716 if datadec is None:
712 raise ValueError, "Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode
717 raise ValueError, "Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode
713
718
714 dataOut.code = self.code
719 dataOut.code = self.code
715 dataOut.nCode = self.nCode
720 dataOut.nCode = self.nCode
716 dataOut.nBaud = self.nBaud
721 dataOut.nBaud = self.nBaud
717
722
718 dataOut.data = datadec
723 dataOut.data = datadec
719
724
720 dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]]
725 dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]]
721
726
722 dataOut.flagDecodeData = True #asumo q la data esta decodificada
727 dataOut.flagDecodeData = True #asumo q la data esta decodificada
723
728
724 if self.__profIndex == self.nCode-1:
729 if self.__profIndex == self.nCode-1:
725 self.__profIndex = 0
730 self.__profIndex = 0
726 return 1
731 return 1
727
732
728 self.__profIndex += 1
733 self.__profIndex += 1
729
734
730 return 1
735 return 1
731 # dataOut.flagDeflipData = True #asumo q la data no esta sin flip
736 # dataOut.flagDeflipData = True #asumo q la data no esta sin flip
732
737
733
738
734 class ProfileConcat(Operation):
739 class ProfileConcat(Operation):
735
740
736 isConfig = False
741 isConfig = False
737 buffer = None
742 buffer = None
738
743
739 def __init__(self, **kwargs):
744 def __init__(self, **kwargs):
740
745
741 Operation.__init__(self, **kwargs)
746 Operation.__init__(self, **kwargs)
742 self.profileIndex = 0
747 self.profileIndex = 0
743
748
744 def reset(self):
749 def reset(self):
745 self.buffer = numpy.zeros_like(self.buffer)
750 self.buffer = numpy.zeros_like(self.buffer)
746 self.start_index = 0
751 self.start_index = 0
747 self.times = 1
752 self.times = 1
748
753
749 def setup(self, data, m, n=1):
754 def setup(self, data, m, n=1):
750 self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0]))
755 self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0]))
751 self.nHeights = data.shape[1]#.nHeights
756 self.nHeights = data.shape[1]#.nHeights
752 self.start_index = 0
757 self.start_index = 0
753 self.times = 1
758 self.times = 1
754
759
755 def concat(self, data):
760 def concat(self, data):
756
761
757 self.buffer[:,self.start_index:self.nHeights*self.times] = data.copy()
762 self.buffer[:,self.start_index:self.nHeights*self.times] = data.copy()
758 self.start_index = self.start_index + self.nHeights
763 self.start_index = self.start_index + self.nHeights
759
764
760 def run(self, dataOut, m):
765 def run(self, dataOut, m):
761
766
762 dataOut.flagNoData = True
767 dataOut.flagNoData = True
763
768
764 if not self.isConfig:
769 if not self.isConfig:
765 self.setup(dataOut.data, m, 1)
770 self.setup(dataOut.data, m, 1)
766 self.isConfig = True
771 self.isConfig = True
767
772
768 if dataOut.flagDataAsBlock:
773 if dataOut.flagDataAsBlock:
769 raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False"
774 raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False"
770
775
771 else:
776 else:
772 self.concat(dataOut.data)
777 self.concat(dataOut.data)
773 self.times += 1
778 self.times += 1
774 if self.times > m:
779 if self.times > m:
775 dataOut.data = self.buffer
780 dataOut.data = self.buffer
776 self.reset()
781 self.reset()
777 dataOut.flagNoData = False
782 dataOut.flagNoData = False
778 # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas
783 # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas
779 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
784 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
780 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m
785 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m
781 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight)
786 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight)
782 dataOut.ippSeconds *= m
787 dataOut.ippSeconds *= m
783
788
784 class ProfileSelector(Operation):
789 class ProfileSelector(Operation):
785
790
786 profileIndex = None
791 profileIndex = None
787 # Tamanho total de los perfiles
792 # Tamanho total de los perfiles
788 nProfiles = None
793 nProfiles = None
789
794
790 def __init__(self, **kwargs):
795 def __init__(self, **kwargs):
791
796
792 Operation.__init__(self, **kwargs)
797 Operation.__init__(self, **kwargs)
793 self.profileIndex = 0
798 self.profileIndex = 0
794
799
795 def incProfileIndex(self):
800 def incProfileIndex(self):
796
801
797 self.profileIndex += 1
802 self.profileIndex += 1
798
803
799 if self.profileIndex >= self.nProfiles:
804 if self.profileIndex >= self.nProfiles:
800 self.profileIndex = 0
805 self.profileIndex = 0
801
806
802 def isThisProfileInRange(self, profileIndex, minIndex, maxIndex):
807 def isThisProfileInRange(self, profileIndex, minIndex, maxIndex):
803
808
804 if profileIndex < minIndex:
809 if profileIndex < minIndex:
805 return False
810 return False
806
811
807 if profileIndex > maxIndex:
812 if profileIndex > maxIndex:
808 return False
813 return False
809
814
810 return True
815 return True
811
816
812 def isThisProfileInList(self, profileIndex, profileList):
817 def isThisProfileInList(self, profileIndex, profileList):
813
818
814 if profileIndex not in profileList:
819 if profileIndex not in profileList:
815 return False
820 return False
816
821
817 return True
822 return True
818
823
819 def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None):
824 def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None):
820
825
821 """
826 """
822 ProfileSelector:
827 ProfileSelector:
823
828
824 Inputs:
829 Inputs:
825 profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8)
830 profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8)
826
831
827 profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30)
832 profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30)
828
833
829 rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256))
834 rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256))
830
835
831 """
836 """
832
837
833 if rangeList is not None:
838 if rangeList is not None:
834 if type(rangeList[0]) not in (tuple, list):
839 if type(rangeList[0]) not in (tuple, list):
835 rangeList = [rangeList]
840 rangeList = [rangeList]
836
841
837 dataOut.flagNoData = True
842 dataOut.flagNoData = True
838
843
839 if dataOut.flagDataAsBlock:
844 if dataOut.flagDataAsBlock:
840 """
845 """
841 data dimension = [nChannels, nProfiles, nHeis]
846 data dimension = [nChannels, nProfiles, nHeis]
842 """
847 """
843 if profileList != None:
848 if profileList != None:
844 dataOut.data = dataOut.data[:,profileList,:]
849 dataOut.data = dataOut.data[:,profileList,:]
845
850
846 if profileRangeList != None:
851 if profileRangeList != None:
847 minIndex = profileRangeList[0]
852 minIndex = profileRangeList[0]
848 maxIndex = profileRangeList[1]
853 maxIndex = profileRangeList[1]
849 profileList = range(minIndex, maxIndex+1)
854 profileList = range(minIndex, maxIndex+1)
850
855
851 dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:]
856 dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:]
852
857
853 if rangeList != None:
858 if rangeList != None:
854
859
855 profileList = []
860 profileList = []
856
861
857 for thisRange in rangeList:
862 for thisRange in rangeList:
858 minIndex = thisRange[0]
863 minIndex = thisRange[0]
859 maxIndex = thisRange[1]
864 maxIndex = thisRange[1]
860
865
861 profileList.extend(range(minIndex, maxIndex+1))
866 profileList.extend(range(minIndex, maxIndex+1))
862
867
863 dataOut.data = dataOut.data[:,profileList,:]
868 dataOut.data = dataOut.data[:,profileList,:]
864
869
865 dataOut.nProfiles = len(profileList)
870 dataOut.nProfiles = len(profileList)
866 dataOut.profileIndex = dataOut.nProfiles - 1
871 dataOut.profileIndex = dataOut.nProfiles - 1
867 dataOut.flagNoData = False
872 dataOut.flagNoData = False
868
873
869 return True
874 return True
870
875
871 """
876 """
872 data dimension = [nChannels, nHeis]
877 data dimension = [nChannels, nHeis]
873 """
878 """
874
879
875 if profileList != None:
880 if profileList != None:
876
881
877 if self.isThisProfileInList(dataOut.profileIndex, profileList):
882 if self.isThisProfileInList(dataOut.profileIndex, profileList):
878
883
879 self.nProfiles = len(profileList)
884 self.nProfiles = len(profileList)
880 dataOut.nProfiles = self.nProfiles
885 dataOut.nProfiles = self.nProfiles
881 dataOut.profileIndex = self.profileIndex
886 dataOut.profileIndex = self.profileIndex
882 dataOut.flagNoData = False
887 dataOut.flagNoData = False
883
888
884 self.incProfileIndex()
889 self.incProfileIndex()
885 return True
890 return True
886
891
887 if profileRangeList != None:
892 if profileRangeList != None:
888
893
889 minIndex = profileRangeList[0]
894 minIndex = profileRangeList[0]
890 maxIndex = profileRangeList[1]
895 maxIndex = profileRangeList[1]
891
896
892 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
897 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
893
898
894 self.nProfiles = maxIndex - minIndex + 1
899 self.nProfiles = maxIndex - minIndex + 1
895 dataOut.nProfiles = self.nProfiles
900 dataOut.nProfiles = self.nProfiles
896 dataOut.profileIndex = self.profileIndex
901 dataOut.profileIndex = self.profileIndex
897 dataOut.flagNoData = False
902 dataOut.flagNoData = False
898
903
899 self.incProfileIndex()
904 self.incProfileIndex()
900 return True
905 return True
901
906
902 if rangeList != None:
907 if rangeList != None:
903
908
904 nProfiles = 0
909 nProfiles = 0
905
910
906 for thisRange in rangeList:
911 for thisRange in rangeList:
907 minIndex = thisRange[0]
912 minIndex = thisRange[0]
908 maxIndex = thisRange[1]
913 maxIndex = thisRange[1]
909
914
910 nProfiles += maxIndex - minIndex + 1
915 nProfiles += maxIndex - minIndex + 1
911
916
912 for thisRange in rangeList:
917 for thisRange in rangeList:
913
918
914 minIndex = thisRange[0]
919 minIndex = thisRange[0]
915 maxIndex = thisRange[1]
920 maxIndex = thisRange[1]
916
921
917 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
922 if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex):
918
923
919 self.nProfiles = nProfiles
924 self.nProfiles = nProfiles
920 dataOut.nProfiles = self.nProfiles
925 dataOut.nProfiles = self.nProfiles
921 dataOut.profileIndex = self.profileIndex
926 dataOut.profileIndex = self.profileIndex
922 dataOut.flagNoData = False
927 dataOut.flagNoData = False
923
928
924 self.incProfileIndex()
929 self.incProfileIndex()
925
930
926 break
931 break
927
932
928 return True
933 return True
929
934
930
935
931 if beam != None: #beam is only for AMISR data
936 if beam != None: #beam is only for AMISR data
932 if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]):
937 if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]):
933 dataOut.flagNoData = False
938 dataOut.flagNoData = False
934 dataOut.profileIndex = self.profileIndex
939 dataOut.profileIndex = self.profileIndex
935
940
936 self.incProfileIndex()
941 self.incProfileIndex()
937
942
938 return True
943 return True
939
944
940 raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter"
945 raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter"
941
946
942 return False
947 return False
943
948
944 class Reshaper(Operation):
949 class Reshaper(Operation):
945
950
946 def __init__(self, **kwargs):
951 def __init__(self, **kwargs):
947
952
948 Operation.__init__(self, **kwargs)
953 Operation.__init__(self, **kwargs)
949
954
950 self.__buffer = None
955 self.__buffer = None
951 self.__nitems = 0
956 self.__nitems = 0
952
957
953 def __appendProfile(self, dataOut, nTxs):
958 def __appendProfile(self, dataOut, nTxs):
954
959
955 if self.__buffer is None:
960 if self.__buffer is None:
956 shape = (dataOut.nChannels, int(dataOut.nHeights/nTxs) )
961 shape = (dataOut.nChannels, int(dataOut.nHeights/nTxs) )
957 self.__buffer = numpy.empty(shape, dtype = dataOut.data.dtype)
962 self.__buffer = numpy.empty(shape, dtype = dataOut.data.dtype)
958
963
959 ini = dataOut.nHeights * self.__nitems
964 ini = dataOut.nHeights * self.__nitems
960 end = ini + dataOut.nHeights
965 end = ini + dataOut.nHeights
961
966
962 self.__buffer[:, ini:end] = dataOut.data
967 self.__buffer[:, ini:end] = dataOut.data
963
968
964 self.__nitems += 1
969 self.__nitems += 1
965
970
966 return int(self.__nitems*nTxs)
971 return int(self.__nitems*nTxs)
967
972
968 def __getBuffer(self):
973 def __getBuffer(self):
969
974
970 if self.__nitems == int(1./self.__nTxs):
975 if self.__nitems == int(1./self.__nTxs):
971
976
972 self.__nitems = 0
977 self.__nitems = 0
973
978
974 return self.__buffer.copy()
979 return self.__buffer.copy()
975
980
976 return None
981 return None
977
982
978 def __checkInputs(self, dataOut, shape, nTxs):
983 def __checkInputs(self, dataOut, shape, nTxs):
979
984
980 if shape is None and nTxs is None:
985 if shape is None and nTxs is None:
981 raise ValueError, "Reshaper: shape of factor should be defined"
986 raise ValueError, "Reshaper: shape of factor should be defined"
982
987
983 if nTxs:
988 if nTxs:
984 if nTxs < 0:
989 if nTxs < 0:
985 raise ValueError, "nTxs should be greater than 0"
990 raise ValueError, "nTxs should be greater than 0"
986
991
987 if nTxs < 1 and dataOut.nProfiles % (1./nTxs) != 0:
992 if nTxs < 1 and dataOut.nProfiles % (1./nTxs) != 0:
988 raise ValueError, "nProfiles= %d is not divisibled by (1./nTxs) = %f" %(dataOut.nProfiles, (1./nTxs))
993 raise ValueError, "nProfiles= %d is not divisibled by (1./nTxs) = %f" %(dataOut.nProfiles, (1./nTxs))
989
994
990 shape = [dataOut.nChannels, dataOut.nProfiles*nTxs, dataOut.nHeights/nTxs]
995 shape = [dataOut.nChannels, dataOut.nProfiles*nTxs, dataOut.nHeights/nTxs]
991
996
992 return shape, nTxs
997 return shape, nTxs
993
998
994 if len(shape) != 2 and len(shape) != 3:
999 if len(shape) != 2 and len(shape) != 3:
995 raise ValueError, "shape dimension should be equal to 2 or 3. shape = (nProfiles, nHeis) or (nChannels, nProfiles, nHeis). Actually shape = (%d, %d, %d)" %(dataOut.nChannels, dataOut.nProfiles, dataOut.nHeights)
1000 raise ValueError, "shape dimension should be equal to 2 or 3. shape = (nProfiles, nHeis) or (nChannels, nProfiles, nHeis). Actually shape = (%d, %d, %d)" %(dataOut.nChannels, dataOut.nProfiles, dataOut.nHeights)
996
1001
997 if len(shape) == 2:
1002 if len(shape) == 2:
998 shape_tuple = [dataOut.nChannels]
1003 shape_tuple = [dataOut.nChannels]
999 shape_tuple.extend(shape)
1004 shape_tuple.extend(shape)
1000 else:
1005 else:
1001 shape_tuple = list(shape)
1006 shape_tuple = list(shape)
1002
1007
1003 nTxs = 1.0*shape_tuple[1]/dataOut.nProfiles
1008 nTxs = 1.0*shape_tuple[1]/dataOut.nProfiles
1004
1009
1005 return shape_tuple, nTxs
1010 return shape_tuple, nTxs
1006
1011
1007 def run(self, dataOut, shape=None, nTxs=None):
1012 def run(self, dataOut, shape=None, nTxs=None):
1008
1013
1009 shape_tuple, self.__nTxs = self.__checkInputs(dataOut, shape, nTxs)
1014 shape_tuple, self.__nTxs = self.__checkInputs(dataOut, shape, nTxs)
1010
1015
1011 dataOut.flagNoData = True
1016 dataOut.flagNoData = True
1012 profileIndex = None
1017 profileIndex = None
1013
1018
1014 if dataOut.flagDataAsBlock:
1019 if dataOut.flagDataAsBlock:
1015
1020
1016 dataOut.data = numpy.reshape(dataOut.data, shape_tuple)
1021 dataOut.data = numpy.reshape(dataOut.data, shape_tuple)
1017 dataOut.flagNoData = False
1022 dataOut.flagNoData = False
1018
1023
1019 profileIndex = int(dataOut.nProfiles*self.__nTxs) - 1
1024 profileIndex = int(dataOut.nProfiles*self.__nTxs) - 1
1020
1025
1021 else:
1026 else:
1022
1027
1023 if self.__nTxs < 1:
1028 if self.__nTxs < 1:
1024
1029
1025 self.__appendProfile(dataOut, self.__nTxs)
1030 self.__appendProfile(dataOut, self.__nTxs)
1026 new_data = self.__getBuffer()
1031 new_data = self.__getBuffer()
1027
1032
1028 if new_data is not None:
1033 if new_data is not None:
1029 dataOut.data = new_data
1034 dataOut.data = new_data
1030 dataOut.flagNoData = False
1035 dataOut.flagNoData = False
1031
1036
1032 profileIndex = dataOut.profileIndex*nTxs
1037 profileIndex = dataOut.profileIndex*nTxs
1033
1038
1034 else:
1039 else:
1035 raise ValueError, "nTxs should be greater than 0 and lower than 1, or use VoltageReader(..., getblock=True)"
1040 raise ValueError, "nTxs should be greater than 0 and lower than 1, or use VoltageReader(..., getblock=True)"
1036
1041
1037 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1042 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1038
1043
1039 dataOut.heightList = numpy.arange(dataOut.nHeights/self.__nTxs) * deltaHeight + dataOut.heightList[0]
1044 dataOut.heightList = numpy.arange(dataOut.nHeights/self.__nTxs) * deltaHeight + dataOut.heightList[0]
1040
1045
1041 dataOut.nProfiles = int(dataOut.nProfiles*self.__nTxs)
1046 dataOut.nProfiles = int(dataOut.nProfiles*self.__nTxs)
1042
1047
1043 dataOut.profileIndex = profileIndex
1048 dataOut.profileIndex = profileIndex
1044
1049
1045 dataOut.ippSeconds /= self.__nTxs
1050 dataOut.ippSeconds /= self.__nTxs
1046
1051
1047 class SplitProfiles(Operation):
1052 class SplitProfiles(Operation):
1048
1053
1049 def __init__(self, **kwargs):
1054 def __init__(self, **kwargs):
1050
1055
1051 Operation.__init__(self, **kwargs)
1056 Operation.__init__(self, **kwargs)
1052
1057
1053 def run(self, dataOut, n):
1058 def run(self, dataOut, n):
1054
1059
1055 dataOut.flagNoData = True
1060 dataOut.flagNoData = True
1056 profileIndex = None
1061 profileIndex = None
1057
1062
1058 if dataOut.flagDataAsBlock:
1063 if dataOut.flagDataAsBlock:
1059
1064
1060 #nchannels, nprofiles, nsamples
1065 #nchannels, nprofiles, nsamples
1061 shape = dataOut.data.shape
1066 shape = dataOut.data.shape
1062
1067
1063 if shape[2] % n != 0:
1068 if shape[2] % n != 0:
1064 raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[2])
1069 raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[2])
1065
1070
1066 new_shape = shape[0], shape[1]*n, shape[2]/n
1071 new_shape = shape[0], shape[1]*n, shape[2]/n
1067
1072
1068 dataOut.data = numpy.reshape(dataOut.data, new_shape)
1073 dataOut.data = numpy.reshape(dataOut.data, new_shape)
1069 dataOut.flagNoData = False
1074 dataOut.flagNoData = False
1070
1075
1071 profileIndex = int(dataOut.nProfiles/n) - 1
1076 profileIndex = int(dataOut.nProfiles/n) - 1
1072
1077
1073 else:
1078 else:
1074
1079
1075 raise ValueError, "Could not split the data when is read Profile by Profile. Use VoltageReader(..., getblock=True)"
1080 raise ValueError, "Could not split the data when is read Profile by Profile. Use VoltageReader(..., getblock=True)"
1076
1081
1077 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1082 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1078
1083
1079 dataOut.heightList = numpy.arange(dataOut.nHeights/n) * deltaHeight + dataOut.heightList[0]
1084 dataOut.heightList = numpy.arange(dataOut.nHeights/n) * deltaHeight + dataOut.heightList[0]
1080
1085
1081 dataOut.nProfiles = int(dataOut.nProfiles*n)
1086 dataOut.nProfiles = int(dataOut.nProfiles*n)
1082
1087
1083 dataOut.profileIndex = profileIndex
1088 dataOut.profileIndex = profileIndex
1084
1089
1085 dataOut.ippSeconds /= n
1090 dataOut.ippSeconds /= n
1086
1091
1087 class CombineProfiles(Operation):
1092 class CombineProfiles(Operation):
1088
1093 parameters = {
1094 'n': 'int',
1095 }
1089 def __init__(self, **kwargs):
1096 def __init__(self, **kwargs):
1090
1097
1091 Operation.__init__(self, **kwargs)
1098 Operation.__init__(self, **kwargs)
1092
1099
1093 self.__remData = None
1100 self.__remData = None
1094 self.__profileIndex = 0
1101 self.__profileIndex = 0
1095
1102
1096 def run(self, dataOut, n):
1103 def run(self, dataOut, n):
1097
1104
1098 dataOut.flagNoData = True
1105 dataOut.flagNoData = True
1099 profileIndex = None
1106 profileIndex = None
1100
1107
1101 if dataOut.flagDataAsBlock:
1108 if dataOut.flagDataAsBlock:
1102
1109
1103 #nchannels, nprofiles, nsamples
1110 #nchannels, nprofiles, nsamples
1104 shape = dataOut.data.shape
1111 shape = dataOut.data.shape
1105 new_shape = shape[0], shape[1]/n, shape[2]*n
1112 new_shape = shape[0], shape[1]/n, shape[2]*n
1106
1113
1107 if shape[1] % n != 0:
1114 if shape[1] % n != 0:
1108 raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[1])
1115 raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[1])
1109
1116
1110 dataOut.data = numpy.reshape(dataOut.data, new_shape)
1117 dataOut.data = numpy.reshape(dataOut.data, new_shape)
1111 dataOut.flagNoData = False
1118 dataOut.flagNoData = False
1112
1119
1113 profileIndex = int(dataOut.nProfiles*n) - 1
1120 profileIndex = int(dataOut.nProfiles*n) - 1
1114
1121
1115 else:
1122 else:
1116
1123
1117 #nchannels, nsamples
1124 #nchannels, nsamples
1118 if self.__remData is None:
1125 if self.__remData is None:
1119 newData = dataOut.data
1126 newData = dataOut.data
1120 else:
1127 else:
1121 newData = numpy.concatenate((self.__remData, dataOut.data), axis=1)
1128 newData = numpy.concatenate((self.__remData, dataOut.data), axis=1)
1122
1129
1123 self.__profileIndex += 1
1130 self.__profileIndex += 1
1124
1131
1125 if self.__profileIndex < n:
1132 if self.__profileIndex < n:
1126 self.__remData = newData
1133 self.__remData = newData
1127 #continue
1134 #continue
1128 return
1135 return
1129
1136
1130 self.__profileIndex = 0
1137 self.__profileIndex = 0
1131 self.__remData = None
1138 self.__remData = None
1132
1139
1133 dataOut.data = newData
1140 dataOut.data = newData
1134 dataOut.flagNoData = False
1141 dataOut.flagNoData = False
1135
1142
1136 profileIndex = dataOut.profileIndex/n
1143 profileIndex = dataOut.profileIndex/n
1137
1144
1138
1145
1139 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1146 deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1140
1147
1141 dataOut.heightList = numpy.arange(dataOut.nHeights*n) * deltaHeight + dataOut.heightList[0]
1148 dataOut.heightList = numpy.arange(dataOut.nHeights*n) * deltaHeight + dataOut.heightList[0]
1142
1149
1143 dataOut.nProfiles = int(dataOut.nProfiles/n)
1150 dataOut.nProfiles = int(dataOut.nProfiles/n)
1144
1151
1145 dataOut.profileIndex = profileIndex
1152 dataOut.profileIndex = profileIndex
1146
1153
1147 dataOut.ippSeconds *= n
1154 dataOut.ippSeconds *= n
1148
1155
1149 # import collections
1156 # import collections
1150 # from scipy.stats import mode
1157 # from scipy.stats import mode
1151 #
1158 #
1152 # class Synchronize(Operation):
1159 # class Synchronize(Operation):
1153 #
1160 #
1154 # isConfig = False
1161 # isConfig = False
1155 # __profIndex = 0
1162 # __profIndex = 0
1156 #
1163 #
1157 # def __init__(self, **kwargs):
1164 # def __init__(self, **kwargs):
1158 #
1165 #
1159 # Operation.__init__(self, **kwargs)
1166 # Operation.__init__(self, **kwargs)
1160 # # self.isConfig = False
1167 # # self.isConfig = False
1161 # self.__powBuffer = None
1168 # self.__powBuffer = None
1162 # self.__startIndex = 0
1169 # self.__startIndex = 0
1163 # self.__pulseFound = False
1170 # self.__pulseFound = False
1164 #
1171 #
1165 # def __findTxPulse(self, dataOut, channel=0, pulse_with = None):
1172 # def __findTxPulse(self, dataOut, channel=0, pulse_with = None):
1166 #
1173 #
1167 # #Read data
1174 # #Read data
1168 #
1175 #
1169 # powerdB = dataOut.getPower(channel = channel)
1176 # powerdB = dataOut.getPower(channel = channel)
1170 # noisedB = dataOut.getNoise(channel = channel)[0]
1177 # noisedB = dataOut.getNoise(channel = channel)[0]
1171 #
1178 #
1172 # self.__powBuffer.extend(powerdB.flatten())
1179 # self.__powBuffer.extend(powerdB.flatten())
1173 #
1180 #
1174 # dataArray = numpy.array(self.__powBuffer)
1181 # dataArray = numpy.array(self.__powBuffer)
1175 #
1182 #
1176 # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same")
1183 # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same")
1177 #
1184 #
1178 # maxValue = numpy.nanmax(filteredPower)
1185 # maxValue = numpy.nanmax(filteredPower)
1179 #
1186 #
1180 # if maxValue < noisedB + 10:
1187 # if maxValue < noisedB + 10:
1181 # #No se encuentra ningun pulso de transmision
1188 # #No se encuentra ningun pulso de transmision
1182 # return None
1189 # return None
1183 #
1190 #
1184 # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0]
1191 # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0]
1185 #
1192 #
1186 # if len(maxValuesIndex) < 2:
1193 # if len(maxValuesIndex) < 2:
1187 # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX
1194 # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX
1188 # return None
1195 # return None
1189 #
1196 #
1190 # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples
1197 # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples
1191 #
1198 #
1192 # #Seleccionar solo valores con un espaciamiento de nSamples
1199 # #Seleccionar solo valores con un espaciamiento de nSamples
1193 # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex)
1200 # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex)
1194 #
1201 #
1195 # if len(pulseIndex) < 2:
1202 # if len(pulseIndex) < 2:
1196 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1203 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1197 # return None
1204 # return None
1198 #
1205 #
1199 # spacing = pulseIndex[1:] - pulseIndex[:-1]
1206 # spacing = pulseIndex[1:] - pulseIndex[:-1]
1200 #
1207 #
1201 # #remover senales que se distancien menos de 10 unidades o muestras
1208 # #remover senales que se distancien menos de 10 unidades o muestras
1202 # #(No deberian existir IPP menor a 10 unidades)
1209 # #(No deberian existir IPP menor a 10 unidades)
1203 #
1210 #
1204 # realIndex = numpy.where(spacing > 10 )[0]
1211 # realIndex = numpy.where(spacing > 10 )[0]
1205 #
1212 #
1206 # if len(realIndex) < 2:
1213 # if len(realIndex) < 2:
1207 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1214 # #Solo se encontro un pulso de transmision con ancho mayor a 1
1208 # return None
1215 # return None
1209 #
1216 #
1210 # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs)
1217 # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs)
1211 # realPulseIndex = pulseIndex[realIndex]
1218 # realPulseIndex = pulseIndex[realIndex]
1212 #
1219 #
1213 # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0]
1220 # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0]
1214 #
1221 #
1215 # print "IPP = %d samples" %period
1222 # print "IPP = %d samples" %period
1216 #
1223 #
1217 # self.__newNSamples = dataOut.nHeights #int(period)
1224 # self.__newNSamples = dataOut.nHeights #int(period)
1218 # self.__startIndex = int(realPulseIndex[0])
1225 # self.__startIndex = int(realPulseIndex[0])
1219 #
1226 #
1220 # return 1
1227 # return 1
1221 #
1228 #
1222 #
1229 #
1223 # def setup(self, nSamples, nChannels, buffer_size = 4):
1230 # def setup(self, nSamples, nChannels, buffer_size = 4):
1224 #
1231 #
1225 # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float),
1232 # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float),
1226 # maxlen = buffer_size*nSamples)
1233 # maxlen = buffer_size*nSamples)
1227 #
1234 #
1228 # bufferList = []
1235 # bufferList = []
1229 #
1236 #
1230 # for i in range(nChannels):
1237 # for i in range(nChannels):
1231 # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN,
1238 # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN,
1232 # maxlen = buffer_size*nSamples)
1239 # maxlen = buffer_size*nSamples)
1233 #
1240 #
1234 # bufferList.append(bufferByChannel)
1241 # bufferList.append(bufferByChannel)
1235 #
1242 #
1236 # self.__nSamples = nSamples
1243 # self.__nSamples = nSamples
1237 # self.__nChannels = nChannels
1244 # self.__nChannels = nChannels
1238 # self.__bufferList = bufferList
1245 # self.__bufferList = bufferList
1239 #
1246 #
1240 # def run(self, dataOut, channel = 0):
1247 # def run(self, dataOut, channel = 0):
1241 #
1248 #
1242 # if not self.isConfig:
1249 # if not self.isConfig:
1243 # nSamples = dataOut.nHeights
1250 # nSamples = dataOut.nHeights
1244 # nChannels = dataOut.nChannels
1251 # nChannels = dataOut.nChannels
1245 # self.setup(nSamples, nChannels)
1252 # self.setup(nSamples, nChannels)
1246 # self.isConfig = True
1253 # self.isConfig = True
1247 #
1254 #
1248 # #Append new data to internal buffer
1255 # #Append new data to internal buffer
1249 # for thisChannel in range(self.__nChannels):
1256 # for thisChannel in range(self.__nChannels):
1250 # bufferByChannel = self.__bufferList[thisChannel]
1257 # bufferByChannel = self.__bufferList[thisChannel]
1251 # bufferByChannel.extend(dataOut.data[thisChannel])
1258 # bufferByChannel.extend(dataOut.data[thisChannel])
1252 #
1259 #
1253 # if self.__pulseFound:
1260 # if self.__pulseFound:
1254 # self.__startIndex -= self.__nSamples
1261 # self.__startIndex -= self.__nSamples
1255 #
1262 #
1256 # #Finding Tx Pulse
1263 # #Finding Tx Pulse
1257 # if not self.__pulseFound:
1264 # if not self.__pulseFound:
1258 # indexFound = self.__findTxPulse(dataOut, channel)
1265 # indexFound = self.__findTxPulse(dataOut, channel)
1259 #
1266 #
1260 # if indexFound == None:
1267 # if indexFound == None:
1261 # dataOut.flagNoData = True
1268 # dataOut.flagNoData = True
1262 # return
1269 # return
1263 #
1270 #
1264 # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex)
1271 # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex)
1265 # self.__pulseFound = True
1272 # self.__pulseFound = True
1266 # self.__startIndex = indexFound
1273 # self.__startIndex = indexFound
1267 #
1274 #
1268 # #If pulse was found ...
1275 # #If pulse was found ...
1269 # for thisChannel in range(self.__nChannels):
1276 # for thisChannel in range(self.__nChannels):
1270 # bufferByChannel = self.__bufferList[thisChannel]
1277 # bufferByChannel = self.__bufferList[thisChannel]
1271 # #print self.__startIndex
1278 # #print self.__startIndex
1272 # x = numpy.array(bufferByChannel)
1279 # x = numpy.array(bufferByChannel)
1273 # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples]
1280 # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples]
1274 #
1281 #
1275 # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1282 # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0]
1276 # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight
1283 # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight
1277 # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6
1284 # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6
1278 #
1285 #
1279 # dataOut.data = self.__arrayBuffer
1286 # dataOut.data = self.__arrayBuffer
1280 #
1287 #
1281 # self.__startIndex += self.__newNSamples
1288 # self.__startIndex += self.__newNSamples
1282 #
1289 #
1283 # return
1290 # return
@@ -1,97 +1,94
1 import argparse
1 import argparse
2
2
3 from schainpy.controller import Project, multiSchain
3 from schainpy.controller import Project, multiSchain
4
4
5 desc = "HF_EXAMPLE"
5 desc = "HF_EXAMPLE"
6
6
7 def fiber(cursor, skip, q, dt):
7 def fiber(cursor, skip, q, dt):
8
8
9 controllerObj = Project()
9 controllerObj = Project()
10
10
11 controllerObj.setup(id='191', name='test01', description=desc)
11 controllerObj.setup(id='191', name='test01', description=desc)
12
12
13 readUnitConfObj = controllerObj.addReadUnit(datatype='SpectraReader',
13 readUnitConfObj = controllerObj.addReadUnit(datatype='SpectraReader',
14 path='/home/nanosat/data/julia',
14 path='/home/nanosat/data/julia',
15 startDate=dt,
15 startDate=dt,
16 endDate=dt,
16 endDate=dt,
17 startTime="00:00:00",
17 startTime="00:00:00",
18 endTime="23:59:59",
18 endTime="23:59:59",
19 online=0,
19 online=0,
20 #set=1426485881,
20 #set=1426485881,
21 delay=10,
21 delay=10,
22 walk=1,
22 walk=1,
23 queue=q,
23 queue=q,
24 cursor=cursor,
24 cursor=cursor,
25 skip=skip,
25 skip=skip,
26 #timezone=-5*3600
26 #timezone=-5*3600
27 )
27 )
28
28
29 # #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
29 # #opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
30 #
30 #
31 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
31 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
32 # procUnitConfObj2.addParameter(name='nipp', value='5', format='int')
32 # procUnitConfObj2.addParameter(name='nipp', value='5', format='int')
33
33
34 # procUnitConfObj3 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=readUnitConfObj.getId())
34 # procUnitConfObj3 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=readUnitConfObj.getId())
35 # opObj11 = procUnitConfObj3.addOperation(name='SpectralMoments', optype='other')
35 # opObj11 = procUnitConfObj3.addOperation(name='SpectralMoments', optype='other')
36
36
37 #
37 #
38 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
38 opObj11 = procUnitConfObj2.addOperation(name='RTIPlot', optype='other')
39 # opObj11.addParameter(name='id', value='1000', format='int')
39 opObj11.addParameter(name='id', value='1000', format='int')
40 # opObj11.addParameter(name='wintitle', value='HF_Jicamarca_Spc', format='str')
40 opObj11.addParameter(name='wintitle', value='HF_Jicamarca_Spc', format='str')
41 # opObj11.addParameter(name='channelList', value='0', format='intlist')
41 opObj11.addParameter(name='xmin', value='0', format='int')
42 # opObj11.addParameter(name='zmin', value='-120', format='float')
42 opObj11.addParameter(name='xmax', value='24', format='int')
43 # opObj11.addParameter(name='zmax', value='-70', format='float')
44 # opObj11.addParameter(name='save', value='1', format='int')
45 # opObj11.addParameter(name='figpath', value=figpath, format='str')
46
43
47 # opObj11 = procUnitConfObj3.addOperation(name='Parameters1Plot', optype='other')
44 # opObj11 = procUnitConfObj3.addOperation(name='Parameters1Plot', optype='other')
48 # opObj11.addParameter(name='channelList', value='0', format='intList')
45 # opObj11.addParameter(name='channelList', value='0', format='intList')
49 #
46 #
50 # opObj11.addParameter(name='id', value='2000', format='int')
47 # opObj11.addParameter(name='id', value='2000', format='int')
51 # # opObj11.addParameter(name='colormap', value='0', format='bool')
48 # # opObj11.addParameter(name='colormap', value='0', format='bool')
52 # opObj11.addParameter(name='onlySNR', value='1', format='bool')
49 # opObj11.addParameter(name='onlySNR', value='1', format='bool')
53 # opObj11.addParameter(name='DOP', value='0', format='bool')
50 # opObj11.addParameter(name='DOP', value='0', format='bool')
54 # opObj11.addParameter(name='showSNR', value='1', format='bool')
51 # opObj11.addParameter(name='showSNR', value='1', format='bool')
55 # opObj11.addParameter(name='SNRthresh', value='0', format='int')
52 # opObj11.addParameter(name='SNRthresh', value='0', format='int')
56 # opObj11.addParameter(name='SNRmin', value='-10', format='int')
53 # opObj11.addParameter(name='SNRmin', value='-10', format='int')
57 # opObj11.addParameter(name='SNRmax', value='30', format='int')
54 # opObj11.addParameter(name='SNRmax', value='30', format='int')
58
55
59 # opObj11.addParameter(name='showSNR', value='1', format='int')
56 # opObj11.addParameter(name='showSNR', value='1', format='int')
60 # # opObj11.addParameter(name='channelList', value='0', format='intlist')
57 # # opObj11.addParameter(name='channelList', value='0', format='intlist')
61 # # opObj11.addParameter(name='xmin', value='0', format='float')
58 # # opObj11.addParameter(name='xmin', value='0', format='float')
62 # opObj11.addParameter(name='xmin', value='0', format='float')
59 # opObj11.addParameter(name='xmin', value='0', format='float')
63 # opObj11.addParameter(name='xmax', value='24', format='float')
60 # opObj11.addParameter(name='xmax', value='24', format='float')
64
61
65 # opObj11.addParameter(name='zmin', value='-110', format='float')
62 # opObj11.addParameter(name='zmin', value='-110', format='float')
66 # opObj11.addParameter(name='zmax', value='-70', format='float')
63 # opObj11.addParameter(name='zmax', value='-70', format='float')
67 # opObj11.addParameter(name='save', value='0', format='int')
64 # opObj11.addParameter(name='save', value='0', format='int')
68 # # opObj11.addParameter(name='figpath', value='/tmp/', format='str')
65 # # opObj11.addParameter(name='figpath', value='/tmp/', format='str')
69 #
66 #
70 opObj12 = procUnitConfObj2.addOperation(name='PublishData', optype='other')
67 # opObj12 = procUnitConfObj2.addOperation(name='PublishData', optype='other')
71 opObj12.addParameter(name='zeromq', value=1, format='int')
68 # opObj12.addParameter(name='zeromq', value=1, format='int')
72 # opObj12.addParameter(name='server', value='tcp://10.10.10.82:7000', format='str')
69 # opObj12.addParameter(name='server', value='tcp://10.10.10.82:7000', format='str')
73
70
74
71
75 # opObj13 = procUnitConfObj3.addOperation(name='PublishData', optype='other')
72 # opObj13 = procUnitConfObj3.addOperation(name='PublishData', optype='other')
76 # opObj13.addParameter(name='zeromq', value=1, format='int')
73 # opObj13.addParameter(name='zeromq', value=1, format='int')
77 # opObj13.addParameter(name='server', value="juanca", format='str')
74 # opObj13.addParameter(name='server', value="juanca", format='str')
78
75
79 # opObj12.addParameter(name='delay', value=1, format='int')
76 # opObj12.addParameter(name='delay', value=1, format='int')
80
77
81
78
82 # print "Escribiendo el archivo XML"
79 # print "Escribiendo el archivo XML"
83 # controllerObj.writeXml(filename)
80 # controllerObj.writeXml(filename)
84 # print "Leyendo el archivo XML"
81 # print "Leyendo el archivo XML"
85 # controllerObj.readXml(filename)
82 # controllerObj.readXml(filename)
86
83
87
84
88 # timeit.timeit('controllerObj.run()', number=2)
85 # timeit.timeit('controllerObj.run()', number=2)
89
86
90 controllerObj.start()
87 controllerObj.start()
91
88
92
89
93 if __name__ == '__main__':
90 if __name__ == '__main__':
94 parser = argparse.ArgumentParser(description='Set number of parallel processes')
91 parser = argparse.ArgumentParser(description='Set number of parallel processes')
95 parser.add_argument('--nProcess', default=1, type=int)
92 parser.add_argument('--nProcess', default=1, type=int)
96 args = parser.parse_args()
93 args = parser.parse_args()
97 multiSchain(fiber, nProcess=args.nProcess, startDate='2016/08/19', endDate='2016/08/19')
94 multiSchain(fiber, nProcess=args.nProcess, startDate='2016/08/19', endDate='2016/08/19')
General Comments 0
You need to be logged in to leave comments. Login now