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