The requested changes are too big and content was truncated. Show full diff
@@ -1,88 +1,90 | |||||
1 | basic = '''from schainpy.controller import Project |
|
1 | basic = '''from schainpy.controller import Project | |
2 |
|
2 | |||
3 | desc = "{desc}" |
|
3 | desc = "{desc}" | |
4 | project = Project() |
|
4 | project = Project() | |
5 | project.setup(id='200', name="{name}", description=desc) |
|
5 | project.setup(id='200', name="{name}", description=desc) | |
6 |
|
6 | |||
7 | voltage_reader = project.addReadUnit(datatype='VoltageReader', |
|
7 | voltage_reader = project.addReadUnit(datatype='VoltageReader', | |
8 | path="{path}", |
|
8 | path="{path}", | |
9 | startDate="{startDate}", |
|
9 | startDate="{startDate}", | |
10 | endDate="{endDate}", |
|
10 | endDate="{endDate}", | |
11 | startTime="{startHour}", |
|
11 | startTime="{startHour}", | |
12 | endTime="{endHour}", |
|
12 | endTime="{endHour}", | |
13 | online=0, |
|
13 | online=0, | |
14 | verbose=1, |
|
14 | verbose=1, | |
15 | walk=1, |
|
15 | walk=1, | |
16 | ) |
|
16 | ) | |
17 |
|
17 | |||
18 | voltage_proc = project.addProcUnit(datatype='VoltageProc', inputId=voltage_reader.getId()) |
|
18 | voltage_proc = project.addProcUnit(datatype='VoltageProc', inputId=voltage_reader.getId()) | |
19 |
|
19 | |||
20 | profile = voltage_proc.addOperation(name='ProfileSelector', optype='other') |
|
20 | profile = voltage_proc.addOperation(name='ProfileSelector', optype='other') | |
21 | profile.addParameter(name='profileRangeList', value='120,183', format='intlist') |
|
21 | profile.addParameter(name='profileRangeList', value='120,183', format='intlist') | |
22 |
|
22 | |||
23 | rti = voltage_proc.addOperation(name='RTIPlot', optype='other') |
|
23 | rti = voltage_proc.addOperation(name='RTIPlot', optype='other') | |
24 | rti.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str') |
|
24 | rti.addParameter(name='wintitle', value='Jicamarca Radio Observatory', format='str') | |
25 | rti.addParameter(name='showprofile', value='0', format='int') |
|
25 | rti.addParameter(name='showprofile', value='0', format='int') | |
26 | rti.addParameter(name='xmin', value='0', format='int') |
|
26 | rti.addParameter(name='xmin', value='0', format='int') | |
27 | rti.addParameter(name='xmax', value='24', format='int') |
|
27 | rti.addParameter(name='xmax', value='24', format='int') | |
28 | rti.addParameter(name='figpath', value="{figpath}", format='str') |
|
28 | rti.addParameter(name='figpath', value="{figpath}", format='str') | |
29 | rti.addParameter(name='wr_period', value='5', format='int') |
|
29 | rti.addParameter(name='wr_period', value='5', format='int') | |
30 | rti.addParameter(name='exp_code', value='22', format='int') |
|
30 | rti.addParameter(name='exp_code', value='22', format='int') | |
31 |
|
31 | |||
32 |
|
32 | |||
33 | controller.start() |
|
33 | controller.start() | |
34 | ''' |
|
34 | ''' | |
35 |
|
35 | |||
36 | multiprocess = '''from schainpy.controller import Project, MPProject |
|
36 | multiprocess = '''from schainpy.controller import Project, MPProject | |
37 | from time import sleep |
|
37 | from time import sleep | |
38 | desc = "{desc}" |
|
38 | desc = "{desc}" | |
39 |
|
39 | |||
40 | #################### |
|
40 | #################### | |
41 | # PLOTTER RECEIVER # |
|
41 | # PLOTTER RECEIVER # | |
42 | #################### |
|
42 | #################### | |
43 | plotter = Project() |
|
43 | plotter = Project() | |
44 | plotter.setup(id='100', name='receiver', description=desc) |
|
44 | plotter.setup(id='100', name='receiver', description=desc) | |
45 |
|
45 | |||
46 |
receiver_p |
|
46 | receiver_plot = plotter.addProcUnit(name='PlotterReceiver') | |
47 |
receiver_p |
|
47 | receiver_plot.addParameter(name='throttle', value=20, format='int') | |
|
48 | receiver_plot.addParameter(name='plottypes', value='rti', format='str') | |||
48 |
|
49 | |||
49 |
rti = receiver_p |
|
50 | rti = receiver_plot.addOperation(name='PlotRTIData', optype='other') | |
50 | rti.addParameter(name='zmin', value='-40.0', format='float') |
|
51 | rti.addParameter(name='zmin', value='-40.0', format='float') | |
51 | rti.addParameter(name='zmax', value='100.0', format='float') |
|
52 | rti.addParameter(name='zmax', value='100.0', format='float') | |
|
53 | rti.addParameter(name='decimation', value='200', format='int') | |||
52 | rti.addParameter(name='xmin', value='0.0', format='int') |
|
54 | rti.addParameter(name='xmin', value='0.0', format='int') | |
53 | rti.addParameter(name='colormap', value='jet', format='str') |
|
55 | rti.addParameter(name='colormap', value='jet', format='str') | |
54 |
|
56 | |||
55 | plotter.start() |
|
57 | plotter.start() | |
56 |
|
58 | |||
57 | sleep(2) |
|
59 | sleep(2) | |
58 |
|
60 | |||
59 | ################ |
|
61 | ################ | |
60 | # DATA EMITTER # |
|
62 | # DATA EMITTER # | |
61 | ################ |
|
63 | ################ | |
62 | project = Project() |
|
64 | project = Project() | |
63 | project.setup(id='200', name="{name}", description=desc) |
|
65 | project.setup(id='200', name="{name}", description=desc) | |
64 |
|
66 | |||
65 | spectra_reader = project.addReadUnit(datatype='SpectraReader', |
|
67 | spectra_reader = project.addReadUnit(datatype='SpectraReader', | |
66 | path="{path}", |
|
68 | path="{path}", | |
67 | startDate={startDate}, |
|
69 | startDate={startDate}, | |
68 | endDate={endDate}, |
|
70 | endDate={endDate}, | |
69 | startTime="{startHour}", |
|
71 | startTime="{startHour}", | |
70 | endTime="{endHour}", |
|
72 | endTime="{endHour}", | |
71 | online=0, |
|
73 | online=0, | |
72 | verbose=1, |
|
74 | verbose=1, | |
73 | walk=1, |
|
75 | walk=1, | |
74 | ) |
|
76 | ) | |
75 |
|
77 | |||
76 | spectra_proc = project.addProcUnit(datatype='Spectra', inputId=spectra_reader.getId()) |
|
78 | spectra_proc = project.addProcUnit(datatype='Spectra', inputId=spectra_reader.getId()) | |
77 |
|
79 | |||
78 | parameters_proc = project.addProcUnit(datatype='ParametersProc', inputId=spectra_proc.getId()) |
|
80 | parameters_proc = project.addProcUnit(datatype='ParametersProc', inputId=spectra_proc.getId()) | |
79 | moments = parameters_proc.addOperation(name='SpectralMoments', optype='other') |
|
81 | moments = parameters_proc.addOperation(name='SpectralMoments', optype='other') | |
80 |
|
82 | |||
81 | publish = parameters_proc.addOperation(name='PublishData', optype='other') |
|
83 | publish = parameters_proc.addOperation(name='PublishData', optype='other') | |
82 | publish.addParameter(name='zeromq', value=1, format='int') |
|
84 | publish.addParameter(name='zeromq', value=1, format='int') | |
83 | publish.addParameter(name='verbose', value=0, format='bool') |
|
85 | publish.addParameter(name='verbose', value=0, format='bool') | |
84 |
|
86 | |||
85 | MPProject(project, 16) |
|
87 | MPProject(project, 16) | |
86 |
|
88 | |||
87 |
|
89 | |||
88 | ''' |
|
90 | ''' |
@@ -1,109 +1,109 | |||||
1 | ## CHANGELOG: |
|
1 | ## CHANGELOG: | |
2 |
|
2 | |||
3 | ### 2.3 |
|
3 | ### 2.3 | |
4 |
* Added high order function ` |
|
4 | * Added high order function `MPProject` for multiprocessing scripts. | |
5 | * Added two new Processing Units `PublishData` and `ReceiverData` for receiving and sending dataOut through multiple ways (tcp, ipc, inproc). |
|
5 | * Added two new Processing Units `PublishData` and `ReceiverData` for receiving and sending dataOut through multiple ways (tcp, ipc, inproc). | |
6 | * Added a new graphics Processing Unit `PlotterReceiver`. It is decoupled from normal processing sequence with support for data generated by multiprocessing scripts. |
|
6 | * Added a new graphics Processing Unit `PlotterReceiver`. It is decoupled from normal processing sequence with support for data generated by multiprocessing scripts. | |
7 | * Added support for sending realtime graphic to web server. |
|
7 | * Added support for sending realtime graphic to web server. | |
8 |
* GUI command `schain` |
|
8 | * GUI command `schain` is now `schainGUI`. | |
9 | * Added a CLI tool named `schain`. |
|
9 | * Added a CLI tool named `schain`. | |
10 | * Scripts templates can be now generated with `schain generate`. |
|
10 | * Scripts templates can be now generated with `schain generate`. | |
11 | * Now it is possible to search Processing Units and Operations with `schain search [module]` to get the right name and its allowed parameters. |
|
11 | * Now it is possible to search Processing Units and Operations with `schain search [module]` to get the right name and its allowed parameters. | |
12 | * `schain xml` to run xml scripts. |
|
12 | * `schain xml` to run xml scripts. | |
13 | * Added suggestions when parameters are poorly written. |
|
13 | * Added suggestions when parameters are poorly written. | |
14 | * `Controller.start()` now runs in a different process than the process calling it. |
|
14 | * `Controller.start()` now runs in a different process than the process calling it. | |
15 | * Added `schainpy.utils.log` for log standarization. |
|
15 | * Added `schainpy.utils.log` for log standarization. | |
16 | * Running script on online mode no longer ignores date and hour. Issue #1109. |
|
16 | * Running script on online mode no longer ignores date and hour. Issue #1109. | |
17 | * Added support for receving voltage data directly from JARS (tcp, ipc). |
|
17 | * Added support for receving voltage data directly from JARS (tcp, ipc). | |
18 | * Updated README for MAC OS GUI installation. |
|
18 | * Updated README for MAC OS GUI installation. | |
19 | * Setup now installs numpy. |
|
19 | * Setup now installs numpy. | |
20 |
|
20 | |||
21 | ### 2.2.6 |
|
21 | ### 2.2.6 | |
22 | * Graphics generated by the GUI are now the same as generated by scripts. Issue #1074. |
|
22 | * Graphics generated by the GUI are now the same as generated by scripts. Issue #1074. | |
23 | * Added support for C extensions. |
|
23 | * Added support for C extensions. | |
24 | * Function `hildebrand_sehkon` optimized with a C wrapper. |
|
24 | * Function `hildebrand_sehkon` optimized with a C wrapper. | |
25 | * Numpy version updated. |
|
25 | * Numpy version updated. | |
26 | * Migration to GIT. |
|
26 | * Migration to GIT. | |
27 |
|
27 | |||
28 | ### 2.2.5: |
|
28 | ### 2.2.5: | |
29 | * splitProfiles and combineProfiles modules were added to VoltageProc and Signal Chain GUI. |
|
29 | * splitProfiles and combineProfiles modules were added to VoltageProc and Signal Chain GUI. | |
30 | * nProfiles of USRP data (hdf5) is the number of profiles thera are in one second. |
|
30 | * nProfiles of USRP data (hdf5) is the number of profiles thera are in one second. | |
31 | * jroPlotter works directly with data objects instead of dictionaries |
|
31 | * jroPlotter works directly with data objects instead of dictionaries | |
32 | * script "schain" was added to Signal Chain installer |
|
32 | * script "schain" was added to Signal Chain installer | |
33 |
|
33 | |||
34 | ### 2.2.4.1: |
|
34 | ### 2.2.4.1: | |
35 | * jroIO_usrp.py is update to read Sandra's data |
|
35 | * jroIO_usrp.py is update to read Sandra's data | |
36 | * decimation in Spectra and RTI plots is always enabled. |
|
36 | * decimation in Spectra and RTI plots is always enabled. | |
37 | * time* window option added to GUI |
|
37 | * time* window option added to GUI | |
38 |
|
38 | |||
39 | ### 2.2.4: |
|
39 | ### 2.2.4: | |
40 | * jroproc_spectra_lags.py added to schainpy |
|
40 | * jroproc_spectra_lags.py added to schainpy | |
41 | * Bug fixed in schainGUI: ProcUnit was created with the same id in some cases. |
|
41 | * Bug fixed in schainGUI: ProcUnit was created with the same id in some cases. | |
42 | * Bug fixed in jroHeaderIO: Header size validation. |
|
42 | * Bug fixed in jroHeaderIO: Header size validation. | |
43 |
|
43 | |||
44 | ### 2.2.3.1: |
|
44 | ### 2.2.3.1: | |
45 | * Filtering block by time has been added. |
|
45 | * Filtering block by time has been added. | |
46 | * Bug fixed plotting RTI, CoherenceMap and others using xmin and xmax parameters. The first day worked |
|
46 | * Bug fixed plotting RTI, CoherenceMap and others using xmin and xmax parameters. The first day worked | |
47 | properly but the next days did not. |
|
47 | properly but the next days did not. | |
48 |
|
48 | |||
49 | ### 2.2.3: |
|
49 | ### 2.2.3: | |
50 | * Bug fixed in GUI: Error getting(reading) Code value |
|
50 | * Bug fixed in GUI: Error getting(reading) Code value | |
51 | * Bug fixed in GUI: Flip option always needs channelList field |
|
51 | * Bug fixed in GUI: Flip option always needs channelList field | |
52 | * Bug fixed in jrodata: when one branch modified a value in "dataOut" (example: dataOut.code) this value |
|
52 | * Bug fixed in jrodata: when one branch modified a value in "dataOut" (example: dataOut.code) this value | |
53 | was modified for every branch (because this was a reference). It was modified in data.copy() |
|
53 | was modified for every branch (because this was a reference). It was modified in data.copy() | |
54 | * Bug fixed in jroproc_voltage.profileSelector(): rangeList replaces to profileRangeList. |
|
54 | * Bug fixed in jroproc_voltage.profileSelector(): rangeList replaces to profileRangeList. | |
55 |
|
55 | |||
56 | ### 2.2.2: |
|
56 | ### 2.2.2: | |
57 | * VoltageProc: ProfileSelector, Reshape, Decoder with nTxs!=1 and getblock=True was tested |
|
57 | * VoltageProc: ProfileSelector, Reshape, Decoder with nTxs!=1 and getblock=True was tested | |
58 | * Rawdata and testRawdata.py added to Signal Chain project |
|
58 | * Rawdata and testRawdata.py added to Signal Chain project | |
59 |
|
59 | |||
60 | ### 2.2.1: |
|
60 | ### 2.2.1: | |
61 | * Bugs fixed in GUI |
|
61 | * Bugs fixed in GUI | |
62 | * Views were improved in GUI |
|
62 | * Views were improved in GUI | |
63 | * Support to MST* ISR experiments |
|
63 | * Support to MST* ISR experiments | |
64 | * Bug fixed getting noise using hyldebrant. (minimum number of points > 20%) |
|
64 | * Bug fixed getting noise using hyldebrant. (minimum number of points > 20%) | |
65 | * handleError added to jroplotter.py |
|
65 | * handleError added to jroplotter.py | |
66 |
|
66 | |||
67 | ### 2.2.0: |
|
67 | ### 2.2.0: | |
68 | * GUI: use of external plotter |
|
68 | * GUI: use of external plotter | |
69 | * Compatible with matplotlib 1.5.0 |
|
69 | * Compatible with matplotlib 1.5.0 | |
70 |
|
70 | |||
71 | ### 2.1.5: |
|
71 | ### 2.1.5: | |
72 | * serializer module added to Signal Chain |
|
72 | * serializer module added to Signal Chain | |
73 | * jroplotter.py added to Signal Chain |
|
73 | * jroplotter.py added to Signal Chain | |
74 |
|
74 | |||
75 | ### 2.1.4.2: |
|
75 | ### 2.1.4.2: | |
76 | * A new Plotter Class was added |
|
76 | * A new Plotter Class was added | |
77 | * Project.start() does not accept filename as a parameter anymore |
|
77 | * Project.start() does not accept filename as a parameter anymore | |
78 |
|
78 | |||
79 | ### 2.1.4.1: |
|
79 | ### 2.1.4.1: | |
80 | * Send notifications when an error different to ValueError is detected |
|
80 | * Send notifications when an error different to ValueError is detected | |
81 |
|
81 | |||
82 | ### 2.1.4: |
|
82 | ### 2.1.4: | |
83 | * Sending error notifications to signal chain administrator |
|
83 | * Sending error notifications to signal chain administrator | |
84 | * Login to email server added |
|
84 | * Login to email server added | |
85 |
|
85 | |||
86 | ### 2.1.3.3: |
|
86 | ### 2.1.3.3: | |
87 | * Colored Button Icons were added to GUI |
|
87 | * Colored Button Icons were added to GUI | |
88 |
|
88 | |||
89 | ### 2.1.3.2: |
|
89 | ### 2.1.3.2: | |
90 | * GUI: user interaction enhanced |
|
90 | * GUI: user interaction enhanced | |
91 | * controller_api.py: Safe access to ControllerThead |
|
91 | * controller_api.py: Safe access to ControllerThead | |
92 |
|
92 | |||
93 | ### 2.1.3.1: |
|
93 | ### 2.1.3.1: | |
94 | * GUI: every icon were resized |
|
94 | * GUI: every icon were resized | |
95 | * jroproc_voltage.py: Print a message when "Read from code" option is selected and the code is not defined inside data file |
|
95 | * jroproc_voltage.py: Print a message when "Read from code" option is selected and the code is not defined inside data file | |
96 |
|
96 | |||
97 | ### 2.1.3: |
|
97 | ### 2.1.3: | |
98 | * jroplot_heispectra.py: SpectraHeisScope was not showing the right channels |
|
98 | * jroplot_heispectra.py: SpectraHeisScope was not showing the right channels | |
99 | * jroproc_voltage.py: Bug fixed selecting profiles (self.nProfiles took a wrong value), |
|
99 | * jroproc_voltage.py: Bug fixed selecting profiles (self.nProfiles took a wrong value), | |
100 | Bug fixed selecting heights by block (selecting profiles instead heights) |
|
100 | Bug fixed selecting heights by block (selecting profiles instead heights) | |
101 | * jroproc_voltage.py: New feature added: decoding data by block using FFT. |
|
101 | * jroproc_voltage.py: New feature added: decoding data by block using FFT. | |
102 | * jroIO_heispectra.py: Bug fixed in FitsReader. Using local Fits instance instead schainpy.mode.data.jrodata.Fits. |
|
102 | * jroIO_heispectra.py: Bug fixed in FitsReader. Using local Fits instance instead schainpy.mode.data.jrodata.Fits. | |
103 | * jroIO_heispectra.py: Channel index list does not exist. |
|
103 | * jroIO_heispectra.py: Channel index list does not exist. | |
104 |
|
104 | |||
105 | ### 2.1.2: |
|
105 | ### 2.1.2: | |
106 | * jroutils_ftp.py: Bug fixed, Any error sending file stopped the Server Thread |
|
106 | * jroutils_ftp.py: Bug fixed, Any error sending file stopped the Server Thread | |
107 | Server thread opens and closes remote server each time file list is sent |
|
107 | Server thread opens and closes remote server each time file list is sent | |
108 | * jroplot_spectra.py: Noise path was not being created when noise data is saved. |
|
108 | * jroplot_spectra.py: Noise path was not being created when noise data is saved. | |
109 | * jroIO_base.py: startTime can be greater than endTime. Example: SpreadF [18:00 * 07:00] No newline at end of file |
|
109 | * jroIO_base.py: startTime can be greater than endTime. Example: SpreadF [18:00 * 07:00] |
@@ -1,819 +1,843 | |||||
1 |
|
1 | |||
2 | import os |
|
2 | import os | |
3 | import time |
|
3 | import time | |
4 | import glob |
|
4 | import glob | |
5 | import datetime |
|
5 | import datetime | |
6 | from multiprocessing import Process |
|
6 | from multiprocessing import Process | |
7 |
|
7 | |||
8 | import zmq |
|
8 | import zmq | |
9 | import numpy |
|
9 | import numpy | |
10 | import matplotlib |
|
10 | import matplotlib | |
11 | import matplotlib.pyplot as plt |
|
11 | import matplotlib.pyplot as plt | |
12 | from mpl_toolkits.axes_grid1 import make_axes_locatable |
|
12 | from mpl_toolkits.axes_grid1 import make_axes_locatable | |
13 | from matplotlib.ticker import FuncFormatter, LinearLocator, MultipleLocator |
|
13 | from matplotlib.ticker import FuncFormatter, LinearLocator, MultipleLocator | |
14 |
|
14 | |||
15 | from schainpy.model.proc.jroproc_base import Operation |
|
15 | from schainpy.model.proc.jroproc_base import Operation | |
16 | from schainpy.utils import log |
|
16 | from schainpy.utils import log | |
17 |
|
17 | |||
18 | jet_values = matplotlib.pyplot.get_cmap("jet", 100)(numpy.arange(100))[10:90] |
|
18 | jet_values = matplotlib.pyplot.get_cmap("jet", 100)(numpy.arange(100))[10:90] | |
19 |
blu_values = matplotlib.pyplot.get_cmap( |
|
19 | blu_values = matplotlib.pyplot.get_cmap( | |
20 | ncmap = matplotlib.colors.LinearSegmentedColormap.from_list("jro", numpy.vstack((blu_values, jet_values))) |
|
20 | "seismic_r", 20)(numpy.arange(20))[10:15] | |
|
21 | ncmap = matplotlib.colors.LinearSegmentedColormap.from_list( | |||
|
22 | "jro", numpy.vstack((blu_values, jet_values))) | |||
21 | matplotlib.pyplot.register_cmap(cmap=ncmap) |
|
23 | matplotlib.pyplot.register_cmap(cmap=ncmap) | |
22 |
|
24 | |||
23 | func = lambda x, pos: '{}'.format(datetime.datetime.fromtimestamp(x).strftime('%H:%M')) |
|
|||
24 |
|
25 | |||
25 | UT1970 = datetime.datetime(1970, 1, 1) - datetime.timedelta(seconds=time.timezone) |
|
26 | def func(x, pos): return '{}'.format( | |
|
27 | datetime.datetime.fromtimestamp(x).strftime('%H:%M')) | |||
|
28 | ||||
|
29 | ||||
|
30 | UT1970 = datetime.datetime(1970, 1, 1) - \ | |||
|
31 | datetime.timedelta(seconds=time.timezone) | |||
26 |
|
32 | |||
27 | CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'RdBu_r', 'seismic')] |
|
33 | CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'RdBu_r', 'seismic')] | |
28 |
|
34 | |||
|
35 | ||||
29 | class PlotData(Operation, Process): |
|
36 | class PlotData(Operation, Process): | |
30 | ''' |
|
37 | ''' | |
31 | Base class for Schain plotting operations |
|
38 | Base class for Schain plotting operations | |
32 | ''' |
|
39 | ''' | |
33 |
|
40 | |||
34 | CODE = 'Figure' |
|
41 | CODE = 'Figure' | |
35 | colormap = 'jro' |
|
42 | colormap = 'jro' | |
36 | bgcolor = 'white' |
|
43 | bgcolor = 'white' | |
37 | CONFLATE = False |
|
44 | CONFLATE = False | |
38 | __MAXNUMX = 80 |
|
45 | __MAXNUMX = 80 | |
39 | __missing = 1E30 |
|
46 | __missing = 1E30 | |
40 |
|
47 | |||
41 | def __init__(self, **kwargs): |
|
48 | def __init__(self, **kwargs): | |
42 |
|
49 | |||
43 | Operation.__init__(self, plot=True, **kwargs) |
|
50 | Operation.__init__(self, plot=True, **kwargs) | |
44 | Process.__init__(self) |
|
51 | Process.__init__(self) | |
45 | self.kwargs['code'] = self.CODE |
|
52 | self.kwargs['code'] = self.CODE | |
46 | self.mp = False |
|
53 | self.mp = False | |
47 | self.data = None |
|
54 | self.data = None | |
48 |
self.isConfig = False |
|
55 | self.isConfig = False | |
49 | self.figures = [] |
|
56 | self.figures = [] | |
50 | self.axes = [] |
|
57 | self.axes = [] | |
51 | self.cb_axes = [] |
|
58 | self.cb_axes = [] | |
52 | self.localtime = kwargs.pop('localtime', True) |
|
59 | self.localtime = kwargs.pop('localtime', True) | |
53 | self.show = kwargs.get('show', True) |
|
60 | self.show = kwargs.get('show', True) | |
54 | self.save = kwargs.get('save', False) |
|
61 | self.save = kwargs.get('save', False) | |
55 | self.colormap = kwargs.get('colormap', self.colormap) |
|
62 | self.colormap = kwargs.get('colormap', self.colormap) | |
56 | self.colormap_coh = kwargs.get('colormap_coh', 'jet') |
|
63 | self.colormap_coh = kwargs.get('colormap_coh', 'jet') | |
57 | self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r') |
|
64 | self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r') | |
58 | self.colormaps = kwargs.get('colormaps', None) |
|
65 | self.colormaps = kwargs.get('colormaps', None) | |
59 | self.bgcolor = kwargs.get('bgcolor', self.bgcolor) |
|
66 | self.bgcolor = kwargs.get('bgcolor', self.bgcolor) | |
60 | self.showprofile = kwargs.get('showprofile', False) |
|
67 | self.showprofile = kwargs.get('showprofile', False) | |
61 | self.title = kwargs.get('wintitle', self.CODE.upper()) |
|
68 | self.title = kwargs.get('wintitle', self.CODE.upper()) | |
62 | self.cb_label = kwargs.get('cb_label', None) |
|
69 | self.cb_label = kwargs.get('cb_label', None) | |
63 | self.cb_labels = kwargs.get('cb_labels', None) |
|
70 | self.cb_labels = kwargs.get('cb_labels', None) | |
64 | self.xaxis = kwargs.get('xaxis', 'frequency') |
|
71 | self.xaxis = kwargs.get('xaxis', 'frequency') | |
65 | self.zmin = kwargs.get('zmin', None) |
|
72 | self.zmin = kwargs.get('zmin', None) | |
66 | self.zmax = kwargs.get('zmax', None) |
|
73 | self.zmax = kwargs.get('zmax', None) | |
67 | self.zlimits = kwargs.get('zlimits', None) |
|
74 | self.zlimits = kwargs.get('zlimits', None) | |
68 |
self.xmin = kwargs.get('xmin', None) |
|
75 | self.xmin = kwargs.get('xmin', None) | |
69 | self.xmax = kwargs.get('xmax', None) |
|
76 | self.xmax = kwargs.get('xmax', None) | |
70 | self.xrange = kwargs.get('xrange', 24) |
|
77 | self.xrange = kwargs.get('xrange', 24) | |
71 | self.ymin = kwargs.get('ymin', None) |
|
78 | self.ymin = kwargs.get('ymin', None) | |
72 | self.ymax = kwargs.get('ymax', None) |
|
79 | self.ymax = kwargs.get('ymax', None) | |
73 | self.xlabel = kwargs.get('xlabel', None) |
|
80 | self.xlabel = kwargs.get('xlabel', None) | |
74 |
self.__MAXNUMY = kwargs.get('decimation', 100) |
|
81 | self.__MAXNUMY = kwargs.get('decimation', 100) | |
75 | self.showSNR = kwargs.get('showSNR', False) |
|
82 | self.showSNR = kwargs.get('showSNR', False) | |
76 | self.oneFigure = kwargs.get('oneFigure', True) |
|
83 | self.oneFigure = kwargs.get('oneFigure', True) | |
77 | self.width = kwargs.get('width', None) |
|
84 | self.width = kwargs.get('width', None) | |
78 | self.height = kwargs.get('height', None) |
|
85 | self.height = kwargs.get('height', None) | |
79 | self.colorbar = kwargs.get('colorbar', True) |
|
86 | self.colorbar = kwargs.get('colorbar', True) | |
80 | self.factors = kwargs.get('factors', [1, 1, 1, 1, 1, 1, 1, 1]) |
|
87 | self.factors = kwargs.get('factors', [1, 1, 1, 1, 1, 1, 1, 1]) | |
81 | self.titles = ['' for __ in range(16)] |
|
88 | self.titles = ['' for __ in range(16)] | |
82 |
|
89 | |||
83 | def __setup(self): |
|
90 | def __setup(self): | |
84 | ''' |
|
91 | ''' | |
85 | Common setup for all figures, here figures and axes are created |
|
92 | Common setup for all figures, here figures and axes are created | |
86 | ''' |
|
93 | ''' | |
87 |
|
94 | |||
88 | self.setup() |
|
95 | self.setup() | |
89 |
|
96 | |||
90 | self.time_label = 'LT' if self.localtime else 'UTC' |
|
97 | self.time_label = 'LT' if self.localtime else 'UTC' | |
91 |
|
98 | |||
92 | if self.width is None: |
|
99 | if self.width is None: | |
93 | self.width = 8 |
|
100 | self.width = 8 | |
94 |
|
101 | |||
95 | self.figures = [] |
|
102 | self.figures = [] | |
96 | self.axes = [] |
|
103 | self.axes = [] | |
97 | self.cb_axes = [] |
|
104 | self.cb_axes = [] | |
98 | self.pf_axes = [] |
|
105 | self.pf_axes = [] | |
99 | self.cmaps = [] |
|
106 | self.cmaps = [] | |
100 |
|
107 | |||
101 | size = '15%' if self.ncols==1 else '30%' |
|
108 | size = '15%' if self.ncols == 1 else '30%' | |
102 | pad = '4%' if self.ncols==1 else '8%' |
|
109 | pad = '4%' if self.ncols == 1 else '8%' | |
103 |
|
110 | |||
104 | if self.oneFigure: |
|
111 | if self.oneFigure: | |
105 | if self.height is None: |
|
112 | if self.height is None: | |
106 | self.height = 1.4*self.nrows + 1 |
|
113 | self.height = 1.4 * self.nrows + 1 | |
107 | fig = plt.figure(figsize=(self.width, self.height), |
|
114 | fig = plt.figure(figsize=(self.width, self.height), | |
108 | edgecolor='k', |
|
115 | edgecolor='k', | |
109 | facecolor='w') |
|
116 | facecolor='w') | |
110 | self.figures.append(fig) |
|
117 | self.figures.append(fig) | |
111 |
for n in range(self.nplots): |
|
118 | for n in range(self.nplots): | |
112 | ax = fig.add_subplot(self.nrows, self.ncols, n+1) |
|
119 | ax = fig.add_subplot(self.nrows, self.ncols, n + 1) | |
113 | ax.tick_params(labelsize=8) |
|
120 | ax.tick_params(labelsize=8) | |
114 | ax.firsttime = True |
|
121 | ax.firsttime = True | |
115 | ax.index = 0 |
|
122 | ax.index = 0 | |
116 |
self.axes.append(ax) |
|
123 | self.axes.append(ax) | |
117 | if self.showprofile: |
|
124 | if self.showprofile: | |
118 | cax = self.__add_axes(ax, size=size, pad=pad) |
|
125 | cax = self.__add_axes(ax, size=size, pad=pad) | |
119 |
cax.tick_params(labelsize=8) |
|
126 | cax.tick_params(labelsize=8) | |
120 | self.pf_axes.append(cax) |
|
127 | self.pf_axes.append(cax) | |
121 | else: |
|
128 | else: | |
122 | if self.height is None: |
|
129 | if self.height is None: | |
123 | self.height = 3 |
|
130 | self.height = 3 | |
124 | for n in range(self.nplots): |
|
131 | for n in range(self.nplots): | |
125 | fig = plt.figure(figsize=(self.width, self.height), |
|
132 | fig = plt.figure(figsize=(self.width, self.height), | |
126 |
|
|
133 | edgecolor='k', | |
127 |
|
|
134 | facecolor='w') | |
128 | ax = fig.add_subplot(1, 1, 1) |
|
135 | ax = fig.add_subplot(1, 1, 1) | |
129 | ax.tick_params(labelsize=8) |
|
136 | ax.tick_params(labelsize=8) | |
130 | ax.firsttime = True |
|
137 | ax.firsttime = True | |
131 | ax.index = 0 |
|
138 | ax.index = 0 | |
132 |
self.figures.append(fig) |
|
139 | self.figures.append(fig) | |
133 | self.axes.append(ax) |
|
140 | self.axes.append(ax) | |
134 | if self.showprofile: |
|
141 | if self.showprofile: | |
135 | cax = self.__add_axes(ax, size=size, pad=pad) |
|
142 | cax = self.__add_axes(ax, size=size, pad=pad) | |
136 |
cax.tick_params(labelsize=8) |
|
143 | cax.tick_params(labelsize=8) | |
137 | self.pf_axes.append(cax) |
|
144 | self.pf_axes.append(cax) | |
138 |
|
145 | |||
139 | for n in range(self.nrows): |
|
146 | for n in range(self.nrows): | |
140 | if self.colormaps is not None: |
|
147 | if self.colormaps is not None: | |
141 |
cmap = plt.get_cmap(self.colormaps[n]) |
|
148 | cmap = plt.get_cmap(self.colormaps[n]) | |
142 | else: |
|
149 | else: | |
143 | cmap = plt.get_cmap(self.colormap) |
|
150 | cmap = plt.get_cmap(self.colormap) | |
144 | cmap.set_bad(self.bgcolor, 1.) |
|
151 | cmap.set_bad(self.bgcolor, 1.) | |
145 | self.cmaps.append(cmap) |
|
152 | self.cmaps.append(cmap) | |
146 |
|
153 | |||
147 | for fig in self.figures: |
|
154 | for fig in self.figures: | |
148 | fig.canvas.mpl_connect('key_press_event', self.event_key_press) |
|
155 | fig.canvas.mpl_connect('key_press_event', self.event_key_press) | |
149 |
|
156 | |||
150 | def event_key_press(self, event): |
|
157 | def event_key_press(self, event): | |
151 | ''' |
|
158 | ''' | |
152 | ''' |
|
159 | ''' | |
153 |
|
160 | |||
154 | for ax in self.axes: |
|
161 | for ax in self.axes: | |
155 | if ax == event.inaxes: |
|
162 | if ax == event.inaxes: | |
156 | if event.key == 'down': |
|
163 | if event.key == 'down': | |
157 | ax.index += 1 |
|
164 | ax.index += 1 | |
158 | elif event.key == 'up': |
|
165 | elif event.key == 'up': | |
159 | ax.index -= 1 |
|
166 | ax.index -= 1 | |
160 | if ax.index < 0: |
|
167 | if ax.index < 0: | |
161 |
ax.index = len(CMAPS) - 1 |
|
168 | ax.index = len(CMAPS) - 1 | |
162 | elif ax.index == len(CMAPS): |
|
169 | elif ax.index == len(CMAPS): | |
163 | ax.index = 0 |
|
170 | ax.index = 0 | |
164 | cmap = CMAPS[ax.index] |
|
171 | cmap = CMAPS[ax.index] | |
165 | ax.cbar.set_cmap(cmap) |
|
172 | ax.cbar.set_cmap(cmap) | |
166 | ax.cbar.draw_all() |
|
173 | ax.cbar.draw_all() | |
167 |
ax.plt.set_cmap(cmap) |
|
174 | ax.plt.set_cmap(cmap) | |
168 | ax.cbar.patch.figure.canvas.draw() |
|
175 | ax.cbar.patch.figure.canvas.draw() | |
169 |
|
176 | |||
170 | def __add_axes(self, ax, size='30%', pad='8%'): |
|
177 | def __add_axes(self, ax, size='30%', pad='8%'): | |
171 | ''' |
|
178 | ''' | |
172 | Add new axes to the given figure |
|
179 | Add new axes to the given figure | |
173 | ''' |
|
180 | ''' | |
174 | divider = make_axes_locatable(ax) |
|
181 | divider = make_axes_locatable(ax) | |
175 | nax = divider.new_horizontal(size=size, pad=pad) |
|
182 | nax = divider.new_horizontal(size=size, pad=pad) | |
176 |
ax.figure.add_axes(nax) |
|
183 | ax.figure.add_axes(nax) | |
177 | return nax |
|
184 | return nax | |
178 |
|
185 | |||
179 | self.setup() |
|
186 | self.setup() | |
180 |
|
187 | |||
181 | def setup(self): |
|
188 | def setup(self): | |
182 | ''' |
|
189 | ''' | |
183 | This method should be implemented in the child class, the following |
|
190 | This method should be implemented in the child class, the following | |
184 | attributes should be set: |
|
191 | attributes should be set: | |
185 |
|
192 | |||
186 | self.nrows: number of rows |
|
193 | self.nrows: number of rows | |
187 | self.ncols: number of cols |
|
194 | self.ncols: number of cols | |
188 | self.nplots: number of plots (channels or pairs) |
|
195 | self.nplots: number of plots (channels or pairs) | |
189 | self.ylabel: label for Y axes |
|
196 | self.ylabel: label for Y axes | |
190 | self.titles: list of axes title |
|
197 | self.titles: list of axes title | |
191 |
|
198 | |||
192 | ''' |
|
199 | ''' | |
193 | raise(NotImplementedError, 'Implement this method in child class') |
|
200 | raise(NotImplementedError, 'Implement this method in child class') | |
194 |
|
201 | |||
195 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): |
|
202 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): | |
196 | ''' |
|
203 | ''' | |
197 | Create a masked array for missing data |
|
204 | Create a masked array for missing data | |
198 | ''' |
|
205 | ''' | |
199 | if x_buffer.shape[0] < 2: |
|
206 | if x_buffer.shape[0] < 2: | |
200 | return x_buffer, y_buffer, z_buffer |
|
207 | return x_buffer, y_buffer, z_buffer | |
201 |
|
208 | |||
202 | deltas = x_buffer[1:] - x_buffer[0:-1] |
|
209 | deltas = x_buffer[1:] - x_buffer[0:-1] | |
203 | x_median = numpy.median(deltas) |
|
210 | x_median = numpy.median(deltas) | |
204 |
|
211 | |||
205 | index = numpy.where(deltas > 5*x_median) |
|
212 | index = numpy.where(deltas > 5 * x_median) | |
206 |
|
213 | |||
207 | if len(index[0]) != 0: |
|
214 | if len(index[0]) != 0: | |
208 | z_buffer[::, index[0], ::] = self.__missing |
|
215 | z_buffer[::, index[0], ::] = self.__missing | |
209 | z_buffer = numpy.ma.masked_inside(z_buffer, |
|
216 | z_buffer = numpy.ma.masked_inside(z_buffer, | |
210 | 0.99*self.__missing, |
|
217 | 0.99 * self.__missing, | |
211 | 1.01*self.__missing) |
|
218 | 1.01 * self.__missing) | |
212 |
|
219 | |||
213 | return x_buffer, y_buffer, z_buffer |
|
220 | return x_buffer, y_buffer, z_buffer | |
214 |
|
221 | |||
215 | def decimate(self): |
|
222 | def decimate(self): | |
216 |
|
223 | |||
217 | # dx = int(len(self.x)/self.__MAXNUMX) + 1 |
|
224 | # dx = int(len(self.x)/self.__MAXNUMX) + 1 | |
218 | dy = int(len(self.y)/self.__MAXNUMY) + 1 |
|
225 | dy = int(len(self.y) / self.__MAXNUMY) + 1 | |
219 |
|
226 | |||
220 | # x = self.x[::dx] |
|
227 | # x = self.x[::dx] | |
221 | x = self.x |
|
228 | x = self.x | |
222 | y = self.y[::dy] |
|
229 | y = self.y[::dy] | |
223 | z = self.z[::, ::, ::dy] |
|
230 | z = self.z[::, ::, ::dy] | |
224 |
|
231 | |||
225 | return x, y, z |
|
232 | return x, y, z | |
226 |
|
233 | |||
227 | def format(self): |
|
234 | def format(self): | |
228 | ''' |
|
235 | ''' | |
229 | Set min and max values, labels, ticks and titles |
|
236 | Set min and max values, labels, ticks and titles | |
230 | ''' |
|
237 | ''' | |
231 |
|
238 | |||
232 | if self.xmin is None: |
|
239 | if self.xmin is None: | |
233 | xmin = self.min_time |
|
240 | xmin = self.min_time | |
234 | else: |
|
241 | else: | |
235 | if self.xaxis is 'time': |
|
242 | if self.xaxis is 'time': | |
236 | dt = datetime.datetime.fromtimestamp(self.min_time) |
|
243 | dt = datetime.datetime.fromtimestamp(self.min_time) | |
237 | xmin = (datetime.datetime.combine(dt.date(), |
|
244 | xmin = (datetime.datetime.combine(dt.date(), | |
238 | datetime.time(int(self.xmin), 0, 0))-UT1970).total_seconds() |
|
245 | datetime.time(int(self.xmin), 0, 0)) - UT1970).total_seconds() | |
239 | else: |
|
246 | else: | |
240 | xmin = self.xmin |
|
247 | xmin = self.xmin | |
241 |
|
248 | |||
242 | if self.xmax is None: |
|
249 | if self.xmax is None: | |
243 | xmax = xmin+self.xrange*60*60 |
|
250 | xmax = xmin + self.xrange * 60 * 60 | |
244 | else: |
|
251 | else: | |
245 | if self.xaxis is 'time': |
|
252 | if self.xaxis is 'time': | |
246 | dt = datetime.datetime.fromtimestamp(self.min_time) |
|
253 | dt = datetime.datetime.fromtimestamp(self.min_time) | |
247 | xmax = (datetime.datetime.combine(dt.date(), |
|
254 | xmax = (datetime.datetime.combine(dt.date(), | |
248 | datetime.time(int(self.xmax), 0, 0))-UT1970).total_seconds() |
|
255 | datetime.time(int(self.xmax), 0, 0)) - UT1970).total_seconds() | |
249 | else: |
|
256 | else: | |
250 | xmax = self.xmax |
|
257 | xmax = self.xmax | |
251 |
|
258 | |||
252 | ymin = self.ymin if self.ymin else numpy.nanmin(self.y) |
|
259 | ymin = self.ymin if self.ymin else numpy.nanmin(self.y) | |
253 | ymax = self.ymax if self.ymax else numpy.nanmax(self.y) |
|
260 | ymax = self.ymax if self.ymax else numpy.nanmax(self.y) | |
254 |
|
||||
255 | ystep = 200 if ymax>= 800 else 100 if ymax>=400 else 50 if ymax>=200 else 20 |
|
|||
256 |
|
261 | |||
257 | for n, ax in enumerate(self.axes): |
|
262 | ystep = 200 if ymax >= 800 else 100 if ymax >= 400 else 50 if ymax >= 200 else 20 | |
|
263 | ||||
|
264 | for n, ax in enumerate(self.axes): | |||
258 | if ax.firsttime: |
|
265 | if ax.firsttime: | |
259 | ax.set_facecolor(self.bgcolor) |
|
266 | ax.set_facecolor(self.bgcolor) | |
260 | ax.yaxis.set_major_locator(MultipleLocator(ystep)) |
|
267 | ax.yaxis.set_major_locator(MultipleLocator(ystep)) | |
261 |
if self.xaxis is 'time': |
|
268 | if self.xaxis is 'time': | |
262 | ax.xaxis.set_major_formatter(FuncFormatter(func)) |
|
269 | ax.xaxis.set_major_formatter(FuncFormatter(func)) | |
263 |
ax.xaxis.set_major_locator(LinearLocator(9)) |
|
270 | ax.xaxis.set_major_locator(LinearLocator(9)) | |
264 | if self.xlabel is not None: |
|
271 | if self.xlabel is not None: | |
265 | ax.set_xlabel(self.xlabel) |
|
272 | ax.set_xlabel(self.xlabel) | |
266 |
ax.set_ylabel(self.ylabel) |
|
273 | ax.set_ylabel(self.ylabel) | |
267 | ax.firsttime = False |
|
274 | ax.firsttime = False | |
268 | if self.showprofile: |
|
275 | if self.showprofile: | |
269 | self.pf_axes[n].set_ylim(ymin, ymax) |
|
276 | self.pf_axes[n].set_ylim(ymin, ymax) | |
270 |
self.pf_axes[n].set_xlim(self.zmin, self.zmax) |
|
277 | self.pf_axes[n].set_xlim(self.zmin, self.zmax) | |
271 | self.pf_axes[n].set_xlabel('dB') |
|
278 | self.pf_axes[n].set_xlabel('dB') | |
272 | self.pf_axes[n].grid(b=True, axis='x') |
|
279 | self.pf_axes[n].grid(b=True, axis='x') | |
273 |
[tick.set_visible(False) |
|
280 | [tick.set_visible(False) | |
|
281 | for tick in self.pf_axes[n].get_yticklabels()] | |||
274 | if self.colorbar: |
|
282 | if self.colorbar: | |
275 | ax.cbar = plt.colorbar(ax.plt, ax=ax, pad=0.02, aspect=10) |
|
283 | ax.cbar = plt.colorbar(ax.plt, ax=ax, pad=0.02, aspect=10) | |
276 | ax.cbar.ax.tick_params(labelsize=8) |
|
284 | ax.cbar.ax.tick_params(labelsize=8) | |
277 | if self.cb_label: |
|
285 | if self.cb_label: | |
278 | ax.cbar.set_label(self.cb_label, size=8) |
|
286 | ax.cbar.set_label(self.cb_label, size=8) | |
279 | elif self.cb_labels: |
|
287 | elif self.cb_labels: | |
280 | ax.cbar.set_label(self.cb_labels[n], size=8) |
|
288 | ax.cbar.set_label(self.cb_labels[n], size=8) | |
281 |
|
289 | |||
282 | ax.set_title('{} - {} {}'.format( |
|
290 | ax.set_title('{} - {} {}'.format( | |
283 |
|
|
291 | self.titles[n], | |
284 |
|
|
292 | datetime.datetime.fromtimestamp( | |
285 |
self. |
|
293 | self.max_time).strftime('%H:%M:%S'), | |
|
294 | self.time_label), | |||
286 | size=8) |
|
295 | size=8) | |
287 | ax.set_xlim(xmin, xmax) |
|
296 | ax.set_xlim(xmin, xmax) | |
288 | ax.set_ylim(ymin, ymax) |
|
297 | ax.set_ylim(ymin, ymax) | |
289 |
|
298 | |||
290 | def __plot(self): |
|
299 | def __plot(self): | |
291 | ''' |
|
300 | ''' | |
292 | ''' |
|
301 | ''' | |
293 | log.success('Plotting', self.name) |
|
302 | log.success('Plotting', self.name) | |
294 |
|
303 | |||
295 | self.plot() |
|
304 | self.plot() | |
296 | self.format() |
|
305 | self.format() | |
297 |
|
306 | |||
298 | for n, fig in enumerate(self.figures): |
|
307 | for n, fig in enumerate(self.figures): | |
299 | if self.nrows == 0 or self.nplots == 0: |
|
308 | if self.nrows == 0 or self.nplots == 0: | |
300 | log.warning('No data', self.name) |
|
309 | log.warning('No data', self.name) | |
301 | continue |
|
310 | continue | |
302 | if self.show: |
|
311 | if self.show: | |
303 | fig.show() |
|
312 | fig.show() | |
304 |
|
313 | |||
305 | fig.tight_layout() |
|
314 | fig.tight_layout() | |
306 |
fig.canvas.manager.set_window_title('{} - {}'.format(self.title, |
|
315 | fig.canvas.manager.set_window_title('{} - {}'.format(self.title, | |
307 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) |
|
316 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) | |
308 | # fig.canvas.draw() |
|
317 | # fig.canvas.draw() | |
309 |
|
318 | |||
310 | if self.save and self.data.ended: |
|
319 | if self.save and self.data.ended: | |
311 | channels = range(self.nrows) |
|
320 | channels = range(self.nrows) | |
312 | if self.oneFigure: |
|
321 | if self.oneFigure: | |
313 | label = '' |
|
322 | label = '' | |
314 | else: |
|
323 | else: | |
315 | label = '_{}'.format(channels[n]) |
|
324 | label = '_{}'.format(channels[n]) | |
316 | figname = os.path.join( |
|
325 | figname = os.path.join( | |
317 | self.save, |
|
326 | self.save, | |
318 | '{}{}_{}.png'.format( |
|
327 | '{}{}_{}.png'.format( | |
319 | self.CODE, |
|
328 | self.CODE, | |
320 | label, |
|
329 | label, | |
321 |
datetime.datetime.fromtimestamp( |
|
330 | datetime.datetime.fromtimestamp( | |
|
331 | self.saveTime).strftime('%y%m%d_%H%M%S') | |||
322 | ) |
|
332 | ) | |
323 | ) |
|
333 | ) | |
324 | print 'Saving figure: {}'.format(figname) |
|
334 | print 'Saving figure: {}'.format(figname) | |
325 | fig.savefig(figname) |
|
335 | fig.savefig(figname) | |
326 |
|
336 | |||
327 | def plot(self): |
|
337 | def plot(self): | |
328 | ''' |
|
338 | ''' | |
329 | ''' |
|
339 | ''' | |
330 | raise(NotImplementedError, 'Implement this method in child class') |
|
340 | raise(NotImplementedError, 'Implement this method in child class') | |
331 |
|
341 | |||
332 | def run(self): |
|
342 | def run(self): | |
333 |
|
343 | |||
334 | log.success('Starting', self.name) |
|
344 | log.success('Starting', self.name) | |
335 |
|
345 | |||
336 | context = zmq.Context() |
|
346 | context = zmq.Context() | |
337 | receiver = context.socket(zmq.SUB) |
|
347 | receiver = context.socket(zmq.SUB) | |
338 | receiver.setsockopt(zmq.SUBSCRIBE, '') |
|
348 | receiver.setsockopt(zmq.SUBSCRIBE, '') | |
339 | receiver.setsockopt(zmq.CONFLATE, self.CONFLATE) |
|
349 | receiver.setsockopt(zmq.CONFLATE, self.CONFLATE) | |
340 |
|
350 | |||
341 | if 'server' in self.kwargs['parent']: |
|
351 | if 'server' in self.kwargs['parent']: | |
342 | receiver.connect('ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server'])) |
|
352 | receiver.connect( | |
|
353 | 'ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server'])) | |||
343 | else: |
|
354 | else: | |
344 |
receiver.connect("ipc:///tmp/zmq.plots") |
|
355 | receiver.connect("ipc:///tmp/zmq.plots") | |
345 |
|
356 | |||
346 | while True: |
|
357 | while True: | |
347 | try: |
|
358 | try: | |
348 | self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK) |
|
359 | self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK) | |
349 |
|
360 | |||
350 | if self.localtime: |
|
361 | if self.localtime: | |
351 | self.times = self.data.times - time.timezone |
|
362 | self.times = self.data.times - time.timezone | |
352 | else: |
|
363 | else: | |
353 | self.times = self.data.times |
|
364 | self.times = self.data.times | |
354 |
|
365 | |||
355 | self.min_time = self.times[0] |
|
366 | self.min_time = self.times[0] | |
356 | self.max_time = self.times[-1] |
|
367 | self.max_time = self.times[-1] | |
357 |
|
368 | |||
358 | if self.isConfig is False: |
|
369 | if self.isConfig is False: | |
359 | self.__setup() |
|
370 | self.__setup() | |
360 | self.isConfig = True |
|
371 | self.isConfig = True | |
361 |
|
372 | |||
362 | self.__plot() |
|
373 | self.__plot() | |
363 |
|
374 | |||
364 | except zmq.Again as e: |
|
375 | except zmq.Again as e: | |
365 | log.log('Waiting for data...') |
|
376 | log.log('Waiting for data...') | |
366 | if self.data: |
|
377 | if self.data: | |
367 | plt.pause(self.data.throttle) |
|
378 | plt.pause(self.data.throttle) | |
368 | else: |
|
379 | else: | |
369 | time.sleep(2) |
|
380 | time.sleep(2) | |
370 |
|
381 | |||
371 | def close(self): |
|
382 | def close(self): | |
372 | if self.data: |
|
383 | if self.data: | |
373 | self.__plot() |
|
384 | self.__plot() | |
374 |
|
385 | |||
|
386 | ||||
375 | class PlotSpectraData(PlotData): |
|
387 | class PlotSpectraData(PlotData): | |
376 | ''' |
|
388 | ''' | |
377 | Plot for Spectra data |
|
389 | Plot for Spectra data | |
378 | ''' |
|
390 | ''' | |
379 |
|
391 | |||
380 | CODE = 'spc' |
|
392 | CODE = 'spc' | |
381 |
colormap = 'jro' |
|
393 | colormap = 'jro' | |
382 |
|
394 | |||
383 | def setup(self): |
|
395 | def setup(self): | |
384 | self.nplots = len(self.data.channels) |
|
396 | self.nplots = len(self.data.channels) | |
385 | self.ncols = int(numpy.sqrt(self.nplots)+ 0.9) |
|
397 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) | |
386 | self.nrows = int((1.0*self.nplots/self.ncols) + 0.9) |
|
398 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
387 | self.width = 3.4*self.ncols |
|
399 | self.width = 3.4 * self.ncols | |
388 | self.height = 3*self.nrows |
|
400 | self.height = 3 * self.nrows | |
389 | self.cb_label = 'dB' |
|
401 | self.cb_label = 'dB' | |
390 |
if self.showprofile: |
|
402 | if self.showprofile: | |
391 | self.width += 0.8*self.ncols |
|
403 | self.width += 0.8 * self.ncols | |
392 |
|
404 | |||
393 | self.ylabel = 'Range [Km]' |
|
405 | self.ylabel = 'Range [Km]' | |
394 |
|
406 | |||
395 | def plot(self): |
|
407 | def plot(self): | |
396 | if self.xaxis == "frequency": |
|
408 | if self.xaxis == "frequency": | |
397 | x = self.data.xrange[0] |
|
409 | x = self.data.xrange[0] | |
398 | self.xlabel = "Frequency (kHz)" |
|
410 | self.xlabel = "Frequency (kHz)" | |
399 | elif self.xaxis == "time": |
|
411 | elif self.xaxis == "time": | |
400 | x = self.data.xrange[1] |
|
412 | x = self.data.xrange[1] | |
401 | self.xlabel = "Time (ms)" |
|
413 | self.xlabel = "Time (ms)" | |
402 | else: |
|
414 | else: | |
403 | x = self.data.xrange[2] |
|
415 | x = self.data.xrange[2] | |
404 | self.xlabel = "Velocity (m/s)" |
|
416 | self.xlabel = "Velocity (m/s)" | |
405 |
|
417 | |||
406 | if self.CODE == 'spc_mean': |
|
418 | if self.CODE == 'spc_mean': | |
407 | x = self.data.xrange[2] |
|
419 | x = self.data.xrange[2] | |
408 | self.xlabel = "Velocity (m/s)" |
|
420 | self.xlabel = "Velocity (m/s)" | |
409 |
|
421 | |||
410 | self.titles = [] |
|
422 | self.titles = [] | |
411 |
|
423 | |||
412 | y = self.data.heights |
|
424 | y = self.data.heights | |
413 | self.y = y |
|
425 | self.y = y | |
414 | z = self.data['spc'] |
|
426 | z = self.data['spc'] | |
415 |
|
427 | |||
416 | for n, ax in enumerate(self.axes): |
|
428 | for n, ax in enumerate(self.axes): | |
417 | noise = self.data['noise'][n][-1] |
|
429 | noise = self.data['noise'][n][-1] | |
418 | if self.CODE == 'spc_mean': |
|
430 | if self.CODE == 'spc_mean': | |
419 | mean = self.data['mean'][n][-1] |
|
431 | mean = self.data['mean'][n][-1] | |
420 | if ax.firsttime: |
|
432 | if ax.firsttime: | |
421 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
433 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
422 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
434 | self.xmin = self.xmin if self.xmin else -self.xmax | |
423 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) |
|
435 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) | |
424 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) |
|
436 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) | |
425 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
437 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
426 | vmin=self.zmin, |
|
438 | vmin=self.zmin, | |
427 | vmax=self.zmax, |
|
439 | vmax=self.zmax, | |
428 | cmap=plt.get_cmap(self.colormap) |
|
440 | cmap=plt.get_cmap(self.colormap) | |
429 |
) |
|
441 | ) | |
430 |
|
442 | |||
431 | if self.showprofile: |
|
443 | if self.showprofile: | |
432 |
ax.plt_profile= self.pf_axes[n].plot( |
|
444 | ax.plt_profile = self.pf_axes[n].plot( | |
|
445 | self.data['rti'][n][-1], y)[0] | |||
433 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, |
|
446 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, | |
434 |
|
|
447 | color="k", linestyle="dashed", lw=1)[0] | |
435 | if self.CODE == 'spc_mean': |
|
448 | if self.CODE == 'spc_mean': | |
436 | ax.plt_mean = ax.plot(mean, y, color='k')[0] |
|
449 | ax.plt_mean = ax.plot(mean, y, color='k')[0] | |
437 | else: |
|
450 | else: | |
438 | ax.plt.set_array(z[n].T.ravel()) |
|
451 | ax.plt.set_array(z[n].T.ravel()) | |
439 | if self.showprofile: |
|
452 | if self.showprofile: | |
440 | ax.plt_profile.set_data(self.data['rti'][n][-1], y) |
|
453 | ax.plt_profile.set_data(self.data['rti'][n][-1], y) | |
441 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) |
|
454 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) | |
442 | if self.CODE == 'spc_mean': |
|
455 | if self.CODE == 'spc_mean': | |
443 | ax.plt_mean.set_data(mean, y) |
|
456 | ax.plt_mean.set_data(mean, y) | |
444 |
|
457 | |||
445 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
458 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) | |
446 | self.saveTime = self.max_time |
|
459 | self.saveTime = self.max_time | |
447 |
|
460 | |||
448 |
|
461 | |||
449 | class PlotCrossSpectraData(PlotData): |
|
462 | class PlotCrossSpectraData(PlotData): | |
450 |
|
463 | |||
451 | CODE = 'cspc' |
|
464 | CODE = 'cspc' | |
452 | zmin_coh = None |
|
465 | zmin_coh = None | |
453 | zmax_coh = None |
|
466 | zmax_coh = None | |
454 | zmin_phase = None |
|
467 | zmin_phase = None | |
455 |
zmax_phase = None |
|
468 | zmax_phase = None | |
456 |
|
469 | |||
457 | def setup(self): |
|
470 | def setup(self): | |
458 |
|
471 | |||
459 | self.ncols = 4 |
|
472 | self.ncols = 4 | |
460 | self.nrows = len(self.data.pairs) |
|
473 | self.nrows = len(self.data.pairs) | |
461 | self.nplots = self.nrows*4 |
|
474 | self.nplots = self.nrows * 4 | |
462 | self.width = 3.4*self.ncols |
|
475 | self.width = 3.4 * self.ncols | |
463 | self.height = 3*self.nrows |
|
476 | self.height = 3 * self.nrows | |
464 | self.ylabel = 'Range [Km]' |
|
477 | self.ylabel = 'Range [Km]' | |
465 |
self.showprofile = False |
|
478 | self.showprofile = False | |
466 |
|
479 | |||
467 | def plot(self): |
|
480 | def plot(self): | |
468 |
|
481 | |||
469 | if self.xaxis == "frequency": |
|
482 | if self.xaxis == "frequency": | |
470 | x = self.data.xrange[0] |
|
483 | x = self.data.xrange[0] | |
471 | self.xlabel = "Frequency (kHz)" |
|
484 | self.xlabel = "Frequency (kHz)" | |
472 | elif self.xaxis == "time": |
|
485 | elif self.xaxis == "time": | |
473 | x = self.data.xrange[1] |
|
486 | x = self.data.xrange[1] | |
474 | self.xlabel = "Time (ms)" |
|
487 | self.xlabel = "Time (ms)" | |
475 | else: |
|
488 | else: | |
476 | x = self.data.xrange[2] |
|
489 | x = self.data.xrange[2] | |
477 | self.xlabel = "Velocity (m/s)" |
|
490 | self.xlabel = "Velocity (m/s)" | |
478 |
|
491 | |||
479 | self.titles = [] |
|
492 | self.titles = [] | |
480 |
|
493 | |||
481 | y = self.data.heights |
|
494 | y = self.data.heights | |
482 | self.y = y |
|
495 | self.y = y | |
483 | spc = self.data['spc'] |
|
496 | spc = self.data['spc'] | |
484 | cspc = self.data['cspc'] |
|
497 | cspc = self.data['cspc'] | |
485 |
|
498 | |||
486 | for n in range(self.nrows): |
|
499 | for n in range(self.nrows): | |
487 | noise = self.data['noise'][n][-1] |
|
500 | noise = self.data['noise'][n][-1] | |
488 | pair = self.data.pairs[n] |
|
501 | pair = self.data.pairs[n] | |
489 | ax = self.axes[4*n] |
|
502 | ax = self.axes[4 * n] | |
490 | ax3 = self.axes[4*n+3] |
|
503 | ax3 = self.axes[4 * n + 3] | |
491 | if ax.firsttime: |
|
504 | if ax.firsttime: | |
492 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
505 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
493 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
506 | self.xmin = self.xmin if self.xmin else -self.xmax | |
494 | self.zmin = self.zmin if self.zmin else numpy.nanmin(spc) |
|
507 | self.zmin = self.zmin if self.zmin else numpy.nanmin(spc) | |
495 |
self.zmax = self.zmax if self.zmax else numpy.nanmax(spc) |
|
508 | self.zmax = self.zmax if self.zmax else numpy.nanmax(spc) | |
496 | ax.plt = ax.pcolormesh(x, y, spc[pair[0]].T, |
|
509 | ax.plt = ax.pcolormesh(x, y, spc[pair[0]].T, | |
497 | vmin=self.zmin, |
|
510 | vmin=self.zmin, | |
498 | vmax=self.zmax, |
|
511 | vmax=self.zmax, | |
499 | cmap=plt.get_cmap(self.colormap) |
|
512 | cmap=plt.get_cmap(self.colormap) | |
500 |
) |
|
513 | ) | |
501 | else: |
|
514 | else: | |
502 | ax.plt.set_array(spc[pair[0]].T.ravel()) |
|
515 | ax.plt.set_array(spc[pair[0]].T.ravel()) | |
503 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
516 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) | |
504 |
|
517 | |||
505 | ax = self.axes[4*n+1] |
|
518 | ax = self.axes[4 * n + 1] | |
506 |
if ax.firsttime: |
|
519 | if ax.firsttime: | |
507 | ax.plt = ax.pcolormesh(x, y, spc[pair[1]].T, |
|
520 | ax.plt = ax.pcolormesh(x, y, spc[pair[1]].T, | |
508 | vmin=self.zmin, |
|
521 | vmin=self.zmin, | |
509 | vmax=self.zmax, |
|
522 | vmax=self.zmax, | |
510 | cmap=plt.get_cmap(self.colormap) |
|
523 | cmap=plt.get_cmap(self.colormap) | |
511 | ) |
|
524 | ) | |
512 | else: |
|
525 | else: | |
513 | ax.plt.set_array(spc[pair[1]].T.ravel()) |
|
526 | ax.plt.set_array(spc[pair[1]].T.ravel()) | |
514 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
527 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) | |
515 |
|
528 | |||
516 | out = cspc[n]/numpy.sqrt(spc[pair[0]]*spc[pair[1]]) |
|
529 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) | |
517 | coh = numpy.abs(out) |
|
530 | coh = numpy.abs(out) | |
518 | phase = numpy.arctan2(out.imag, out.real)*180/numpy.pi |
|
531 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi | |
519 |
|
532 | |||
520 | ax = self.axes[4*n+2] |
|
533 | ax = self.axes[4 * n + 2] | |
521 |
if ax.firsttime: |
|
534 | if ax.firsttime: | |
522 | ax.plt = ax.pcolormesh(x, y, coh.T, |
|
535 | ax.plt = ax.pcolormesh(x, y, coh.T, | |
523 | vmin=0, |
|
536 | vmin=0, | |
524 | vmax=1, |
|
537 | vmax=1, | |
525 | cmap=plt.get_cmap(self.colormap_coh) |
|
538 | cmap=plt.get_cmap(self.colormap_coh) | |
526 | ) |
|
539 | ) | |
527 | else: |
|
540 | else: | |
528 | ax.plt.set_array(coh.T.ravel()) |
|
541 | ax.plt.set_array(coh.T.ravel()) | |
529 | self.titles.append('Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
542 | self.titles.append( | |
|
543 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) | |||
530 |
|
544 | |||
531 | ax = self.axes[4*n+3] |
|
545 | ax = self.axes[4 * n + 3] | |
532 | if ax.firsttime: |
|
546 | if ax.firsttime: | |
533 | ax.plt = ax.pcolormesh(x, y, phase.T, |
|
547 | ax.plt = ax.pcolormesh(x, y, phase.T, | |
534 | vmin=-180, |
|
548 | vmin=-180, | |
535 | vmax=180, |
|
549 | vmax=180, | |
536 | cmap=plt.get_cmap(self.colormap_phase) |
|
550 | cmap=plt.get_cmap(self.colormap_phase) | |
537 | ) |
|
551 | ) | |
538 | else: |
|
552 | else: | |
539 | ax.plt.set_array(phase.T.ravel()) |
|
553 | ax.plt.set_array(phase.T.ravel()) | |
540 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) |
|
554 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) | |
541 |
|
555 | |||
542 | self.saveTime = self.max_time |
|
556 | self.saveTime = self.max_time | |
543 |
|
557 | |||
544 |
|
558 | |||
545 | class PlotSpectraMeanData(PlotSpectraData): |
|
559 | class PlotSpectraMeanData(PlotSpectraData): | |
546 | ''' |
|
560 | ''' | |
547 | Plot for Spectra and Mean |
|
561 | Plot for Spectra and Mean | |
548 | ''' |
|
562 | ''' | |
549 | CODE = 'spc_mean' |
|
563 | CODE = 'spc_mean' | |
550 | colormap = 'jro' |
|
564 | colormap = 'jro' | |
551 |
|
565 | |||
552 |
|
566 | |||
553 | class PlotRTIData(PlotData): |
|
567 | class PlotRTIData(PlotData): | |
554 | ''' |
|
568 | ''' | |
555 | Plot for RTI data |
|
569 | Plot for RTI data | |
556 | ''' |
|
570 | ''' | |
557 |
|
571 | |||
558 | CODE = 'rti' |
|
572 | CODE = 'rti' | |
559 | colormap = 'jro' |
|
573 | colormap = 'jro' | |
560 |
|
574 | |||
561 | def setup(self): |
|
575 | def setup(self): | |
562 | self.xaxis = 'time' |
|
576 | self.xaxis = 'time' | |
563 |
self.ncols = 1 |
|
577 | self.ncols = 1 | |
564 | self.nrows = len(self.data.channels) |
|
578 | self.nrows = len(self.data.channels) | |
565 | self.nplots = len(self.data.channels) |
|
579 | self.nplots = len(self.data.channels) | |
566 | self.ylabel = 'Range [Km]' |
|
580 | self.ylabel = 'Range [Km]' | |
567 | self.cb_label = 'dB' |
|
581 | self.cb_label = 'dB' | |
568 |
self.titles = ['{} Channel {}'.format( |
|
582 | self.titles = ['{} Channel {}'.format( | |
|
583 | self.CODE.upper(), x) for x in range(self.nrows)] | |||
569 |
|
584 | |||
570 | def plot(self): |
|
585 | def plot(self): | |
571 | self.x = self.times |
|
586 | self.x = self.times | |
572 | self.y = self.data.heights |
|
587 | self.y = self.data.heights | |
573 | self.z = self.data[self.CODE] |
|
588 | self.z = self.data[self.CODE] | |
574 | self.z = numpy.ma.masked_invalid(self.z) |
|
589 | self.z = numpy.ma.masked_invalid(self.z) | |
575 |
|
590 | |||
576 | for n, ax in enumerate(self.axes): |
|
591 | for n, ax in enumerate(self.axes): | |
577 |
x, y, z = self.fill_gaps(*self.decimate()) |
|
592 | x, y, z = self.fill_gaps(*self.decimate()) | |
578 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) |
|
593 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) | |
579 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) |
|
594 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) | |
580 |
if ax.firsttime: |
|
595 | if ax.firsttime: | |
581 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
596 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
582 | vmin=self.zmin, |
|
597 | vmin=self.zmin, | |
583 | vmax=self.zmax, |
|
598 | vmax=self.zmax, | |
584 | cmap=plt.get_cmap(self.colormap) |
|
599 | cmap=plt.get_cmap(self.colormap) | |
585 | ) |
|
600 | ) | |
586 | if self.showprofile: |
|
601 | if self.showprofile: | |
587 |
ax.plot_profile= self.pf_axes[n].plot( |
|
602 | ax.plot_profile = self.pf_axes[n].plot( | |
|
603 | self.data['rti'][n][-1], self.y)[0] | |||
588 | ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y, |
|
604 | ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y, | |
589 | color="k", linestyle="dashed", lw=1)[0] |
|
605 | color="k", linestyle="dashed", lw=1)[0] | |
590 | else: |
|
606 | else: | |
591 | ax.collections.remove(ax.collections[0]) |
|
607 | ax.collections.remove(ax.collections[0]) | |
592 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
608 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
593 | vmin=self.zmin, |
|
609 | vmin=self.zmin, | |
594 | vmax=self.zmax, |
|
610 | vmax=self.zmax, | |
595 | cmap=plt.get_cmap(self.colormap) |
|
611 | cmap=plt.get_cmap(self.colormap) | |
596 | ) |
|
612 | ) | |
597 | if self.showprofile: |
|
613 | if self.showprofile: | |
598 | ax.plot_profile.set_data(self.data['rti'][n][-1], self.y) |
|
614 | ax.plot_profile.set_data(self.data['rti'][n][-1], self.y) | |
599 |
ax.plot_noise.set_data(numpy.repeat( |
|
615 | ax.plot_noise.set_data(numpy.repeat( | |
|
616 | self.data['noise'][n][-1], len(self.y)), self.y) | |||
600 |
|
617 | |||
601 |
self.saveTime = self.min_time |
|
618 | self.saveTime = self.min_time | |
602 |
|
619 | |||
603 |
|
620 | |||
604 | class PlotCOHData(PlotRTIData): |
|
621 | class PlotCOHData(PlotRTIData): | |
605 | ''' |
|
622 | ''' | |
606 | Plot for Coherence data |
|
623 | Plot for Coherence data | |
607 | ''' |
|
624 | ''' | |
608 |
|
625 | |||
609 | CODE = 'coh' |
|
626 | CODE = 'coh' | |
610 |
|
627 | |||
611 | def setup(self): |
|
628 | def setup(self): | |
612 | self.xaxis = 'time' |
|
629 | self.xaxis = 'time' | |
613 | self.ncols = 1 |
|
630 | self.ncols = 1 | |
614 | self.nrows = len(self.data.pairs) |
|
631 | self.nrows = len(self.data.pairs) | |
615 | self.nplots = len(self.data.pairs) |
|
632 | self.nplots = len(self.data.pairs) | |
616 |
self.ylabel = 'Range [Km]' |
|
633 | self.ylabel = 'Range [Km]' | |
617 | if self.CODE == 'coh': |
|
634 | if self.CODE == 'coh': | |
618 | self.cb_label = '' |
|
635 | self.cb_label = '' | |
619 | self.titles = ['Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] |
|
636 | self.titles = [ | |
|
637 | 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] | |||
620 | else: |
|
638 | else: | |
621 | self.cb_label = 'Degrees' |
|
639 | self.cb_label = 'Degrees' | |
622 | self.titles = ['Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] |
|
640 | self.titles = [ | |
|
641 | 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] | |||
623 |
|
642 | |||
624 |
|
643 | |||
625 | class PlotPHASEData(PlotCOHData): |
|
644 | class PlotPHASEData(PlotCOHData): | |
626 | ''' |
|
645 | ''' | |
627 | Plot for Phase map data |
|
646 | Plot for Phase map data | |
628 | ''' |
|
647 | ''' | |
629 |
|
648 | |||
630 | CODE = 'phase' |
|
649 | CODE = 'phase' | |
631 | colormap = 'seismic' |
|
650 | colormap = 'seismic' | |
632 |
|
651 | |||
633 |
|
652 | |||
634 | class PlotNoiseData(PlotData): |
|
653 | class PlotNoiseData(PlotData): | |
635 | ''' |
|
654 | ''' | |
636 | Plot for noise |
|
655 | Plot for noise | |
637 | ''' |
|
656 | ''' | |
638 |
|
657 | |||
639 | CODE = 'noise' |
|
658 | CODE = 'noise' | |
640 |
|
659 | |||
641 | def setup(self): |
|
660 | def setup(self): | |
642 | self.xaxis = 'time' |
|
661 | self.xaxis = 'time' | |
643 | self.ncols = 1 |
|
662 | self.ncols = 1 | |
644 | self.nrows = 1 |
|
663 | self.nrows = 1 | |
645 | self.nplots = 1 |
|
664 | self.nplots = 1 | |
646 | self.ylabel = 'Intensity [dB]' |
|
665 | self.ylabel = 'Intensity [dB]' | |
647 | self.titles = ['Noise'] |
|
666 | self.titles = ['Noise'] | |
648 | self.colorbar = False |
|
667 | self.colorbar = False | |
649 |
|
668 | |||
650 | def plot(self): |
|
669 | def plot(self): | |
651 |
|
670 | |||
652 | x = self.times |
|
671 | x = self.times | |
653 | xmin = self.min_time |
|
672 | xmin = self.min_time | |
654 | xmax = xmin+self.xrange*60*60 |
|
673 | xmax = xmin + self.xrange * 60 * 60 | |
655 | Y = self.data[self.CODE] |
|
674 | Y = self.data[self.CODE] | |
656 |
|
675 | |||
657 | if self.axes[0].firsttime: |
|
676 | if self.axes[0].firsttime: | |
658 | for ch in self.data.channels: |
|
677 | for ch in self.data.channels: | |
659 | y = Y[ch] |
|
678 | y = Y[ch] | |
660 | self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch)) |
|
679 | self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch)) | |
661 | plt.legend() |
|
680 | plt.legend() | |
662 | else: |
|
681 | else: | |
663 | for ch in self.data.channels: |
|
682 | for ch in self.data.channels: | |
664 | y = Y[ch] |
|
683 | y = Y[ch] | |
665 | self.axes[0].lines[ch].set_data(x, y) |
|
684 | self.axes[0].lines[ch].set_data(x, y) | |
666 |
|
685 | |||
667 | self.ymin = numpy.nanmin(Y) - 5 |
|
686 | self.ymin = numpy.nanmin(Y) - 5 | |
668 | self.ymax = numpy.nanmax(Y) + 5 |
|
687 | self.ymax = numpy.nanmax(Y) + 5 | |
669 | self.saveTime = self.min_time |
|
688 | self.saveTime = self.min_time | |
670 |
|
689 | |||
671 |
|
690 | |||
672 | class PlotSNRData(PlotRTIData): |
|
691 | class PlotSNRData(PlotRTIData): | |
673 | ''' |
|
692 | ''' | |
674 | Plot for SNR Data |
|
693 | Plot for SNR Data | |
675 | ''' |
|
694 | ''' | |
676 |
|
695 | |||
677 | CODE = 'snr' |
|
696 | CODE = 'snr' | |
678 | colormap = 'jet' |
|
697 | colormap = 'jet' | |
679 |
|
698 | |||
680 |
|
699 | |||
681 | class PlotDOPData(PlotRTIData): |
|
700 | class PlotDOPData(PlotRTIData): | |
682 | ''' |
|
701 | ''' | |
683 | Plot for DOPPLER Data |
|
702 | Plot for DOPPLER Data | |
684 | ''' |
|
703 | ''' | |
685 |
|
704 | |||
686 | CODE = 'dop' |
|
705 | CODE = 'dop' | |
687 | colormap = 'jet' |
|
706 | colormap = 'jet' | |
688 |
|
707 | |||
689 |
|
708 | |||
690 | class PlotSkyMapData(PlotData): |
|
709 | class PlotSkyMapData(PlotData): | |
691 | ''' |
|
710 | ''' | |
692 | Plot for meteors detection data |
|
711 | Plot for meteors detection data | |
693 | ''' |
|
712 | ''' | |
694 |
|
713 | |||
695 | CODE = 'met' |
|
714 | CODE = 'met' | |
696 |
|
715 | |||
697 | def setup(self): |
|
716 | def setup(self): | |
698 |
|
717 | |||
699 | self.ncols = 1 |
|
718 | self.ncols = 1 | |
700 | self.nrows = 1 |
|
719 | self.nrows = 1 | |
701 | self.width = 7.2 |
|
720 | self.width = 7.2 | |
702 | self.height = 7.2 |
|
721 | self.height = 7.2 | |
703 |
|
722 | |||
704 | self.xlabel = 'Zonal Zenith Angle (deg)' |
|
723 | self.xlabel = 'Zonal Zenith Angle (deg)' | |
705 | self.ylabel = 'Meridional Zenith Angle (deg)' |
|
724 | self.ylabel = 'Meridional Zenith Angle (deg)' | |
706 |
|
725 | |||
707 | if self.figure is None: |
|
726 | if self.figure is None: | |
708 | self.figure = plt.figure(figsize=(self.width, self.height), |
|
727 | self.figure = plt.figure(figsize=(self.width, self.height), | |
709 | edgecolor='k', |
|
728 | edgecolor='k', | |
710 | facecolor='w') |
|
729 | facecolor='w') | |
711 | else: |
|
730 | else: | |
712 | self.figure.clf() |
|
731 | self.figure.clf() | |
713 |
|
732 | |||
714 | self.ax = plt.subplot2grid((self.nrows, self.ncols), (0, 0), 1, 1, polar=True) |
|
733 | self.ax = plt.subplot2grid( | |
|
734 | (self.nrows, self.ncols), (0, 0), 1, 1, polar=True) | |||
715 | self.ax.firsttime = True |
|
735 | self.ax.firsttime = True | |
716 |
|
736 | |||
717 |
|
||||
718 | def plot(self): |
|
737 | def plot(self): | |
719 |
|
738 | |||
720 |
arrayParameters = numpy.concatenate( |
|
739 | arrayParameters = numpy.concatenate( | |
721 | error = arrayParameters[:,-1] |
|
740 | [self.data['param'][t] for t in self.times]) | |
|
741 | error = arrayParameters[:, -1] | |||
722 | indValid = numpy.where(error == 0)[0] |
|
742 | indValid = numpy.where(error == 0)[0] | |
723 | finalMeteor = arrayParameters[indValid,:] |
|
743 | finalMeteor = arrayParameters[indValid, :] | |
724 | finalAzimuth = finalMeteor[:,3] |
|
744 | finalAzimuth = finalMeteor[:, 3] | |
725 | finalZenith = finalMeteor[:,4] |
|
745 | finalZenith = finalMeteor[:, 4] | |
726 |
|
746 | |||
727 | x = finalAzimuth*numpy.pi/180 |
|
747 | x = finalAzimuth * numpy.pi / 180 | |
728 | y = finalZenith |
|
748 | y = finalZenith | |
729 |
|
749 | |||
730 | if self.ax.firsttime: |
|
750 | if self.ax.firsttime: | |
731 | self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0] |
|
751 | self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0] | |
732 | self.ax.set_ylim(0,90) |
|
752 | self.ax.set_ylim(0, 90) | |
733 | self.ax.set_yticks(numpy.arange(0,90,20)) |
|
753 | self.ax.set_yticks(numpy.arange(0, 90, 20)) | |
734 | self.ax.set_xlabel(self.xlabel) |
|
754 | self.ax.set_xlabel(self.xlabel) | |
735 | self.ax.set_ylabel(self.ylabel) |
|
755 | self.ax.set_ylabel(self.ylabel) | |
736 | self.ax.yaxis.labelpad = 40 |
|
756 | self.ax.yaxis.labelpad = 40 | |
737 | self.ax.firsttime = False |
|
757 | self.ax.firsttime = False | |
738 | else: |
|
758 | else: | |
739 | self.ax.plot.set_data(x, y) |
|
759 | self.ax.plot.set_data(x, y) | |
740 |
|
760 | |||
741 |
|
761 | dt1 = datetime.datetime.fromtimestamp( | ||
742 |
|
|
762 | self.min_time).strftime('%y/%m/%d %H:%M:%S') | |
743 |
dt2 = datetime.datetime.fromtimestamp( |
|
763 | dt2 = datetime.datetime.fromtimestamp( | |
|
764 | self.max_time).strftime('%y/%m/%d %H:%M:%S') | |||
744 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, |
|
765 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, | |
745 | dt2, |
|
766 | dt2, | |
746 | len(x)) |
|
767 | len(x)) | |
747 | self.ax.set_title(title, size=8) |
|
768 | self.ax.set_title(title, size=8) | |
748 |
|
769 | |||
749 | self.saveTime = self.max_time |
|
770 | self.saveTime = self.max_time | |
750 |
|
771 | |||
|
772 | ||||
751 | class PlotParamData(PlotRTIData): |
|
773 | class PlotParamData(PlotRTIData): | |
752 | ''' |
|
774 | ''' | |
753 | Plot for data_param object |
|
775 | Plot for data_param object | |
754 | ''' |
|
776 | ''' | |
755 |
|
777 | |||
756 | CODE = 'param' |
|
778 | CODE = 'param' | |
757 | colormap = 'seismic' |
|
779 | colormap = 'seismic' | |
758 |
|
780 | |||
759 | def setup(self): |
|
781 | def setup(self): | |
760 | self.xaxis = 'time' |
|
782 | self.xaxis = 'time' | |
761 | self.ncols = 1 |
|
783 | self.ncols = 1 | |
762 | self.nrows = self.data.shape(self.CODE)[0] |
|
784 | self.nrows = self.data.shape(self.CODE)[0] | |
763 | self.nplots = self.nrows |
|
785 | self.nplots = self.nrows | |
764 | if self.showSNR: |
|
786 | if self.showSNR: | |
765 | self.nrows += 1 |
|
787 | self.nrows += 1 | |
766 | self.nplots += 1 |
|
788 | self.nplots += 1 | |
767 |
|
789 | |||
768 | self.ylabel = 'Height [Km]' |
|
790 | self.ylabel = 'Height [Km]' | |
769 | self.titles = self.data.parameters \ |
|
791 | self.titles = self.data.parameters \ | |
770 | if self.data.parameters else ['Param {}'.format(x) for x in xrange(self.nrows)] |
|
792 | if self.data.parameters else ['Param {}'.format(x) for x in xrange(self.nrows)] | |
771 | if self.showSNR: |
|
793 | if self.showSNR: | |
772 | self.titles.append('SNR') |
|
794 | self.titles.append('SNR') | |
773 |
|
795 | |||
774 | def plot(self): |
|
796 | def plot(self): | |
775 |
self.data.normalize_heights() |
|
797 | self.data.normalize_heights() | |
776 | self.x = self.times |
|
798 | self.x = self.times | |
777 | self.y = self.data.heights |
|
799 | self.y = self.data.heights | |
778 |
if self.showSNR: |
|
800 | if self.showSNR: | |
779 | self.z = numpy.concatenate( |
|
801 | self.z = numpy.concatenate( | |
780 | (self.data[self.CODE], self.data['snr']) |
|
802 | (self.data[self.CODE], self.data['snr']) | |
781 | ) |
|
803 | ) | |
782 | else: |
|
804 | else: | |
783 | self.z = self.data[self.CODE] |
|
805 | self.z = self.data[self.CODE] | |
784 |
|
806 | |||
785 | self.z = numpy.ma.masked_invalid(self.z) |
|
807 | self.z = numpy.ma.masked_invalid(self.z) | |
786 |
|
808 | |||
787 | for n, ax in enumerate(self.axes): |
|
809 | for n, ax in enumerate(self.axes): | |
788 |
|
810 | |||
789 | x, y, z = self.fill_gaps(*self.decimate()) |
|
811 | x, y, z = self.fill_gaps(*self.decimate()) | |
790 |
|
812 | |||
791 | if ax.firsttime: |
|
813 | if ax.firsttime: | |
792 | if self.zlimits is not None: |
|
814 | if self.zlimits is not None: | |
793 | self.zmin, self.zmax = self.zlimits[n] |
|
815 | self.zmin, self.zmax = self.zlimits[n] | |
794 |
self.zmax = self.zmax if self.zmax is not None else numpy.nanmax( |
|
816 | self.zmax = self.zmax if self.zmax is not None else numpy.nanmax( | |
|
817 | abs(self.z[:-1, :])) | |||
795 | self.zmin = self.zmin if self.zmin is not None else -self.zmax |
|
818 | self.zmin = self.zmin if self.zmin is not None else -self.zmax | |
796 | ax.plt = ax.pcolormesh(x, y, z[n, :, :].T*self.factors[n], |
|
819 | ax.plt = ax.pcolormesh(x, y, z[n, :, :].T * self.factors[n], | |
797 | vmin=self.zmin, |
|
820 | vmin=self.zmin, | |
798 | vmax=self.zmax, |
|
821 | vmax=self.zmax, | |
799 | cmap=self.cmaps[n] |
|
822 | cmap=self.cmaps[n] | |
800 |
) |
|
823 | ) | |
801 | else: |
|
824 | else: | |
802 | if self.zlimits is not None: |
|
825 | if self.zlimits is not None: | |
803 | self.zmin, self.zmax = self.zlimits[n] |
|
826 | self.zmin, self.zmax = self.zlimits[n] | |
804 | ax.collections.remove(ax.collections[0]) |
|
827 | ax.collections.remove(ax.collections[0]) | |
805 | ax.plt = ax.pcolormesh(x, y, z[n, :, :].T*self.factors[n], |
|
828 | ax.plt = ax.pcolormesh(x, y, z[n, :, :].T * self.factors[n], | |
806 | vmin=self.zmin, |
|
829 | vmin=self.zmin, | |
807 | vmax=self.zmax, |
|
830 | vmax=self.zmax, | |
808 | cmap=self.cmaps[n] |
|
831 | cmap=self.cmaps[n] | |
809 | ) |
|
832 | ) | |
810 |
|
833 | |||
811 | self.saveTime = self.min_time |
|
834 | self.saveTime = self.min_time | |
812 |
|
835 | |||
|
836 | ||||
813 | class PlotOuputData(PlotParamData): |
|
837 | class PlotOuputData(PlotParamData): | |
814 | ''' |
|
838 | ''' | |
815 | Plot data_output object |
|
839 | Plot data_output object | |
816 | ''' |
|
840 | ''' | |
817 |
|
841 | |||
818 | CODE = 'output' |
|
842 | CODE = 'output' | |
819 | colormap = 'seismic' |
|
843 | colormap = 'seismic' |
@@ -1,141 +1,143 | |||||
1 | ''' |
|
1 | ''' | |
2 | @author: Daniel Suarez |
|
2 | @author: Daniel Suarez | |
3 | ''' |
|
3 | ''' | |
4 | import numpy |
|
4 | import numpy | |
5 | from jroproc_base import ProcessingUnit, Operation |
|
5 | from jroproc_base import ProcessingUnit, Operation | |
6 | from schainpy.model.data.jroamisr import AMISR |
|
6 | from schainpy.model.data.jroamisr import AMISR | |
7 |
|
7 | |||
8 | class AMISRProc(ProcessingUnit): |
|
8 | class AMISRProc(ProcessingUnit): | |
9 | def __init__(self): |
|
9 | def __init__(self, **kwargs): | |
10 | ProcessingUnit.__init__(self) |
|
10 | ProcessingUnit.__init__(self, **kwargs) | |
11 | self.objectDict = {} |
|
11 | self.objectDict = {} | |
12 | self.dataOut = AMISR() |
|
12 | self.dataOut = AMISR() | |
13 |
|
13 | |||
14 | def run(self): |
|
14 | def run(self): | |
15 | if self.dataIn.type == 'AMISR': |
|
15 | if self.dataIn.type == 'AMISR': | |
16 | self.dataOut.copy(self.dataIn) |
|
16 | self.dataOut.copy(self.dataIn) | |
17 |
|
17 | |||
18 |
|
18 | |||
19 | class PrintInfo(Operation): |
|
19 | class PrintInfo(Operation): | |
20 | def __init__(self): |
|
20 | def __init__(self, **kwargs): | |
|
21 | Operation.__init__(self, **kwargs) | |||
21 | self.__isPrinted = False |
|
22 | self.__isPrinted = False | |
22 |
|
23 | |||
23 | def run(self, dataOut): |
|
24 | def run(self, dataOut): | |
24 |
|
25 | |||
25 | if not self.__isPrinted: |
|
26 | if not self.__isPrinted: | |
26 | print 'Number of Records by File: %d'%dataOut.nRecords |
|
27 | print 'Number of Records by File: %d'%dataOut.nRecords | |
27 | print 'Number of Pulses: %d'%dataOut.nProfiles |
|
28 | print 'Number of Pulses: %d'%dataOut.nProfiles | |
28 | print 'Number of Pulses by Frame: %d'%dataOut.npulseByFrame |
|
29 | print 'Number of Pulses by Frame: %d'%dataOut.npulseByFrame | |
29 | print 'Number of Samples by Pulse: %d'%len(dataOut.heightList) |
|
30 | print 'Number of Samples by Pulse: %d'%len(dataOut.heightList) | |
30 | print 'Ipp Seconds: %f'%dataOut.ippSeconds |
|
31 | print 'Ipp Seconds: %f'%dataOut.ippSeconds | |
31 | print 'Number of Beams: %d'%dataOut.nBeams |
|
32 | print 'Number of Beams: %d'%dataOut.nBeams | |
32 | print 'BeamCodes:' |
|
33 | print 'BeamCodes:' | |
33 | beamStrList = ['Beam %d -> Code=%d, azimuth=%2.2f, zenith=%2.2f, gain=%2.2f'%(k,v[0],v[1],v[2],v[3]) for k,v in dataOut.beamCodeDict.items()] |
|
34 | beamStrList = ['Beam %d -> Code=%d, azimuth=%2.2f, zenith=%2.2f, gain=%2.2f'%(k,v[0],v[1],v[2],v[3]) for k,v in dataOut.beamCodeDict.items()] | |
34 | for b in beamStrList: |
|
35 | for b in beamStrList: | |
35 | print b |
|
36 | print b | |
36 | self.__isPrinted = True |
|
37 | self.__isPrinted = True | |
37 |
|
38 | |||
38 | return |
|
39 | return | |
39 |
|
40 | |||
40 |
|
41 | |||
41 | class BeamSelector(Operation): |
|
42 | class BeamSelector(Operation): | |
42 | profileIndex = None |
|
43 | profileIndex = None | |
43 | nProfiles = None |
|
44 | nProfiles = None | |
44 |
|
45 | |||
45 | def __init__(self): |
|
46 | def __init__(self, **kwargs): | |
46 |
|
47 | Operation.__init__(self, **kwargs) | ||
47 | self.profileIndex = 0 |
|
48 | self.profileIndex = 0 | |
48 | self.__isConfig = False |
|
49 | self.__isConfig = False | |
49 |
|
50 | |||
50 | def incIndex(self): |
|
51 | def incIndex(self): | |
51 | self.profileIndex += 1 |
|
52 | self.profileIndex += 1 | |
52 |
|
53 | |||
53 | if self.profileIndex >= self.nProfiles: |
|
54 | if self.profileIndex >= self.nProfiles: | |
54 | self.profileIndex = 0 |
|
55 | self.profileIndex = 0 | |
55 |
|
56 | |||
56 | def isProfileInRange(self, minIndex, maxIndex): |
|
57 | def isProfileInRange(self, minIndex, maxIndex): | |
57 |
|
58 | |||
58 | if self.profileIndex < minIndex: |
|
59 | if self.profileIndex < minIndex: | |
59 | return False |
|
60 | return False | |
60 |
|
61 | |||
61 | if self.profileIndex > maxIndex: |
|
62 | if self.profileIndex > maxIndex: | |
62 | return False |
|
63 | return False | |
63 |
|
64 | |||
64 | return True |
|
65 | return True | |
65 |
|
66 | |||
66 | def isProfileInList(self, profileList): |
|
67 | def isProfileInList(self, profileList): | |
67 |
|
68 | |||
68 | if self.profileIndex not in profileList: |
|
69 | if self.profileIndex not in profileList: | |
69 | return False |
|
70 | return False | |
70 |
|
71 | |||
71 | return True |
|
72 | return True | |
72 |
|
73 | |||
73 | def run(self, dataOut, beam=None): |
|
74 | def run(self, dataOut, beam=None): | |
74 |
|
75 | |||
75 | dataOut.flagNoData = True |
|
76 | dataOut.flagNoData = True | |
76 |
|
77 | |||
77 | if not(self.__isConfig): |
|
78 | if not(self.__isConfig): | |
78 |
|
79 | |||
79 | self.nProfiles = dataOut.nProfiles |
|
80 | self.nProfiles = dataOut.nProfiles | |
80 | self.profileIndex = dataOut.profileIndex |
|
81 | self.profileIndex = dataOut.profileIndex | |
81 | self.__isConfig = True |
|
82 | self.__isConfig = True | |
82 |
|
83 | |||
83 | if beam != None: |
|
84 | if beam != None: | |
84 | if self.isProfileInList(dataOut.beamRangeDict[beam]): |
|
85 | if self.isProfileInList(dataOut.beamRangeDict[beam]): | |
85 | beamInfo = dataOut.beamCodeDict[beam] |
|
86 | beamInfo = dataOut.beamCodeDict[beam] | |
86 | dataOut.azimuth = beamInfo[1] |
|
87 | dataOut.azimuth = beamInfo[1] | |
87 | dataOut.zenith = beamInfo[2] |
|
88 | dataOut.zenith = beamInfo[2] | |
88 | dataOut.gain = beamInfo[3] |
|
89 | dataOut.gain = beamInfo[3] | |
89 | dataOut.flagNoData = False |
|
90 | dataOut.flagNoData = False | |
90 |
|
91 | |||
91 | self.incIndex() |
|
92 | self.incIndex() | |
92 | return 1 |
|
93 | return 1 | |
93 |
|
94 | |||
94 | else: |
|
95 | else: | |
95 | raise ValueError, "BeamSelector needs beam value" |
|
96 | raise ValueError, "BeamSelector needs beam value" | |
96 |
|
97 | |||
97 | return 0 |
|
98 | return 0 | |
98 |
|
99 | |||
99 | class ProfileToChannels(Operation): |
|
100 | class ProfileToChannels(Operation): | |
100 |
|
101 | |||
101 | def __init__(self): |
|
102 | def __init__(self, **kwargs): | |
|
103 | Operation.__init__(self, **kwargs) | |||
102 | self.__isConfig = False |
|
104 | self.__isConfig = False | |
103 | self.__counter_chan = 0 |
|
105 | self.__counter_chan = 0 | |
104 | self.buffer = None |
|
106 | self.buffer = None | |
105 |
|
107 | |||
106 | def isProfileInList(self, profileList): |
|
108 | def isProfileInList(self, profileList): | |
107 |
|
109 | |||
108 | if self.profileIndex not in profileList: |
|
110 | if self.profileIndex not in profileList: | |
109 | return False |
|
111 | return False | |
110 |
|
112 | |||
111 | return True |
|
113 | return True | |
112 |
|
114 | |||
113 | def run(self, dataOut): |
|
115 | def run(self, dataOut): | |
114 |
|
116 | |||
115 | dataOut.flagNoData = True |
|
117 | dataOut.flagNoData = True | |
116 |
|
118 | |||
117 | if not(self.__isConfig): |
|
119 | if not(self.__isConfig): | |
118 | nchannels = len(dataOut.beamRangeDict.keys()) |
|
120 | nchannels = len(dataOut.beamRangeDict.keys()) | |
119 | nsamples = dataOut.nHeights |
|
121 | nsamples = dataOut.nHeights | |
120 | self.buffer = numpy.zeros((nchannels, nsamples), dtype = 'complex128') |
|
122 | self.buffer = numpy.zeros((nchannels, nsamples), dtype = 'complex128') | |
121 | dataOut.beam.codeList = [dataOut.beamCodeDict[x][0] for x in range(nchannels)] |
|
123 | dataOut.beam.codeList = [dataOut.beamCodeDict[x][0] for x in range(nchannels)] | |
122 | dataOut.beam.azimuthList = [dataOut.beamCodeDict[x][1] for x in range(nchannels)] |
|
124 | dataOut.beam.azimuthList = [dataOut.beamCodeDict[x][1] for x in range(nchannels)] | |
123 | dataOut.beam.zenithList = [dataOut.beamCodeDict[x][2] for x in range(nchannels)] |
|
125 | dataOut.beam.zenithList = [dataOut.beamCodeDict[x][2] for x in range(nchannels)] | |
124 | self.__isConfig = True |
|
126 | self.__isConfig = True | |
125 |
|
127 | |||
126 | for i in range(self.buffer.shape[0]): |
|
128 | for i in range(self.buffer.shape[0]): | |
127 | if dataOut.profileIndex in dataOut.beamRangeDict[i]: |
|
129 | if dataOut.profileIndex in dataOut.beamRangeDict[i]: | |
128 | self.buffer[i,:] = dataOut.data |
|
130 | self.buffer[i,:] = dataOut.data | |
129 | break |
|
131 | break | |
130 |
|
132 | |||
131 |
|
133 | |||
132 | self.__counter_chan += 1 |
|
134 | self.__counter_chan += 1 | |
133 |
|
135 | |||
134 | if self.__counter_chan >= self.buffer.shape[0]: |
|
136 | if self.__counter_chan >= self.buffer.shape[0]: | |
135 | self.__counter_chan = 0 |
|
137 | self.__counter_chan = 0 | |
136 | dataOut.data = self.buffer.copy() |
|
138 | dataOut.data = self.buffer.copy() | |
137 | dataOut.channelList = range(self.buffer.shape[0]) |
|
139 | dataOut.channelList = range(self.buffer.shape[0]) | |
138 | self.__isConfig = False |
|
140 | self.__isConfig = False | |
139 | dataOut.flagNoData = False |
|
141 | dataOut.flagNoData = False | |
140 | pass |
|
142 | pass | |
141 | No newline at end of file |
|
143 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now