The requested changes are too big and content was truncated. Show full diff
@@ -1,698 +1,698 | |||||
1 | # Copyright (c) 2012-2020 Jicamarca Radio Observatory |
|
1 | # Copyright (c) 2012-2020 Jicamarca Radio Observatory | |
2 | # All rights reserved. |
|
2 | # All rights reserved. | |
3 | # |
|
3 | # | |
4 | # Distributed under the terms of the BSD 3-clause license. |
|
4 | # Distributed under the terms of the BSD 3-clause license. | |
5 | """Base class to create plot operations |
|
5 | """Base class to create plot operations | |
6 |
|
6 | |||
7 | """ |
|
7 | """ | |
8 |
|
8 | |||
9 | import os |
|
9 | import os | |
10 | import sys |
|
10 | import sys | |
11 | import zmq |
|
11 | import zmq | |
12 | import time |
|
12 | import time | |
13 | import numpy |
|
13 | import numpy | |
14 | import datetime |
|
14 | import datetime | |
15 | from collections import deque |
|
15 | from collections import deque | |
16 | from functools import wraps |
|
16 | from functools import wraps | |
17 | from threading import Thread |
|
17 | from threading import Thread | |
18 | import matplotlib |
|
18 | import matplotlib | |
19 |
|
19 | |||
20 | if 'BACKEND' in os.environ: |
|
20 | if 'BACKEND' in os.environ: | |
21 | matplotlib.use(os.environ['BACKEND']) |
|
21 | matplotlib.use(os.environ['BACKEND']) | |
22 | elif 'linux' in sys.platform: |
|
22 | elif 'linux' in sys.platform: | |
23 | matplotlib.use("TkAgg") |
|
23 | matplotlib.use("TkAgg") | |
24 | elif 'darwin' in sys.platform: |
|
24 | elif 'darwin' in sys.platform: | |
25 | matplotlib.use('MacOSX') |
|
25 | matplotlib.use('MacOSX') | |
26 | else: |
|
26 | else: | |
27 | from schainpy.utils import log |
|
27 | from schainpy.utils import log | |
28 | log.warning('Using default Backend="Agg"', 'INFO') |
|
28 | log.warning('Using default Backend="Agg"', 'INFO') | |
29 | matplotlib.use('Agg') |
|
29 | matplotlib.use('Agg') | |
30 |
|
30 | |||
31 | import matplotlib.pyplot as plt |
|
31 | import matplotlib.pyplot as plt | |
32 | from matplotlib.patches import Polygon |
|
32 | from matplotlib.patches import Polygon | |
33 | from mpl_toolkits.axes_grid1 import make_axes_locatable |
|
33 | from mpl_toolkits.axes_grid1 import make_axes_locatable | |
34 | from matplotlib.ticker import FuncFormatter, LinearLocator, MultipleLocator |
|
34 | from matplotlib.ticker import FuncFormatter, LinearLocator, MultipleLocator | |
35 |
|
35 | |||
36 | from schainpy.model.data.jrodata import PlotterData |
|
36 | from schainpy.model.data.jrodata import PlotterData | |
37 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator |
|
37 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator | |
38 | from schainpy.utils import log |
|
38 | from schainpy.utils import log | |
39 |
|
39 | |||
40 | jet_values = matplotlib.pyplot.get_cmap('jet', 100)(numpy.arange(100))[10:90] |
|
40 | jet_values = matplotlib.pyplot.get_cmap('jet', 100)(numpy.arange(100))[10:90] | |
41 | blu_values = matplotlib.pyplot.get_cmap( |
|
41 | blu_values = matplotlib.pyplot.get_cmap( | |
42 | 'seismic_r', 20)(numpy.arange(20))[10:15] |
|
42 | 'seismic_r', 20)(numpy.arange(20))[10:15] | |
43 | ncmap = matplotlib.colors.LinearSegmentedColormap.from_list( |
|
43 | ncmap = matplotlib.colors.LinearSegmentedColormap.from_list( | |
44 | 'jro', numpy.vstack((blu_values, jet_values))) |
|
44 | 'jro', numpy.vstack((blu_values, jet_values))) | |
45 | matplotlib.pyplot.register_cmap(cmap=ncmap) |
|
45 | matplotlib.pyplot.register_cmap(cmap=ncmap) | |
46 |
|
46 | |||
47 | CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'viridis', |
|
47 | CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'viridis', | |
48 | 'plasma', 'inferno', 'Greys', 'seismic', 'bwr', 'coolwarm')] |
|
48 | 'plasma', 'inferno', 'Greys', 'seismic', 'bwr', 'coolwarm')] | |
49 |
|
49 | |||
50 | EARTH_RADIUS = 6.3710e3 |
|
50 | EARTH_RADIUS = 6.3710e3 | |
51 |
|
51 | |||
52 | def ll2xy(lat1, lon1, lat2, lon2): |
|
52 | def ll2xy(lat1, lon1, lat2, lon2): | |
53 |
|
53 | |||
54 | p = 0.017453292519943295 |
|
54 | p = 0.017453292519943295 | |
55 | a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \ |
|
55 | a = 0.5 - numpy.cos((lat2 - lat1) * p)/2 + numpy.cos(lat1 * p) * \ | |
56 | numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2 |
|
56 | numpy.cos(lat2 * p) * (1 - numpy.cos((lon2 - lon1) * p)) / 2 | |
57 | r = 12742 * numpy.arcsin(numpy.sqrt(a)) |
|
57 | r = 12742 * numpy.arcsin(numpy.sqrt(a)) | |
58 | theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p) |
|
58 | theta = numpy.arctan2(numpy.sin((lon2-lon1)*p)*numpy.cos(lat2*p), numpy.cos(lat1*p) | |
59 | * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p)) |
|
59 | * numpy.sin(lat2*p)-numpy.sin(lat1*p)*numpy.cos(lat2*p)*numpy.cos((lon2-lon1)*p)) | |
60 | theta = -theta + numpy.pi/2 |
|
60 | theta = -theta + numpy.pi/2 | |
61 | return r*numpy.cos(theta), r*numpy.sin(theta) |
|
61 | return r*numpy.cos(theta), r*numpy.sin(theta) | |
62 |
|
62 | |||
63 |
|
63 | |||
64 | def km2deg(km): |
|
64 | def km2deg(km): | |
65 | ''' |
|
65 | ''' | |
66 | Convert distance in km to degrees |
|
66 | Convert distance in km to degrees | |
67 | ''' |
|
67 | ''' | |
68 |
|
68 | |||
69 | return numpy.rad2deg(km/EARTH_RADIUS) |
|
69 | return numpy.rad2deg(km/EARTH_RADIUS) | |
70 |
|
70 | |||
71 |
|
71 | |||
72 | def figpause(interval): |
|
72 | def figpause(interval): | |
73 | backend = plt.rcParams['backend'] |
|
73 | backend = plt.rcParams['backend'] | |
74 | if backend in matplotlib.rcsetup.interactive_bk: |
|
74 | if backend in matplotlib.rcsetup.interactive_bk: | |
75 | figManager = matplotlib._pylab_helpers.Gcf.get_active() |
|
75 | figManager = matplotlib._pylab_helpers.Gcf.get_active() | |
76 | if figManager is not None: |
|
76 | if figManager is not None: | |
77 | canvas = figManager.canvas |
|
77 | canvas = figManager.canvas | |
78 | if canvas.figure.stale: |
|
78 | if canvas.figure.stale: | |
79 | canvas.draw() |
|
79 | canvas.draw() | |
80 | try: |
|
80 | try: | |
81 | canvas.start_event_loop(interval) |
|
81 | canvas.start_event_loop(interval) | |
82 | except: |
|
82 | except: | |
83 | pass |
|
83 | pass | |
84 | return |
|
84 | return | |
85 |
|
85 | |||
86 | def popup(message): |
|
86 | def popup(message): | |
87 | ''' |
|
87 | ''' | |
88 | ''' |
|
88 | ''' | |
89 |
|
89 | |||
90 | fig = plt.figure(figsize=(12, 8), facecolor='r') |
|
90 | fig = plt.figure(figsize=(12, 8), facecolor='r') | |
91 | text = '\n'.join([s.strip() for s in message.split(':')]) |
|
91 | text = '\n'.join([s.strip() for s in message.split(':')]) | |
92 | fig.text(0.01, 0.5, text, ha='left', va='center', |
|
92 | fig.text(0.01, 0.5, text, ha='left', va='center', | |
93 | size='20', weight='heavy', color='w') |
|
93 | size='20', weight='heavy', color='w') | |
94 | fig.show() |
|
94 | fig.show() | |
95 | figpause(1000) |
|
95 | figpause(1000) | |
96 |
|
96 | |||
97 |
|
97 | |||
98 | class Throttle(object): |
|
98 | class Throttle(object): | |
99 | ''' |
|
99 | ''' | |
100 | Decorator that prevents a function from being called more than once every |
|
100 | Decorator that prevents a function from being called more than once every | |
101 | time period. |
|
101 | time period. | |
102 | To create a function that cannot be called more than once a minute, but |
|
102 | To create a function that cannot be called more than once a minute, but | |
103 | will sleep until it can be called: |
|
103 | will sleep until it can be called: | |
104 | @Throttle(minutes=1) |
|
104 | @Throttle(minutes=1) | |
105 | def foo(): |
|
105 | def foo(): | |
106 | pass |
|
106 | pass | |
107 |
|
107 | |||
108 | for i in range(10): |
|
108 | for i in range(10): | |
109 | foo() |
|
109 | foo() | |
110 | print "This function has run %s times." % i |
|
110 | print "This function has run %s times." % i | |
111 | ''' |
|
111 | ''' | |
112 |
|
112 | |||
113 | def __init__(self, seconds=0, minutes=0, hours=0): |
|
113 | def __init__(self, seconds=0, minutes=0, hours=0): | |
114 | self.throttle_period = datetime.timedelta( |
|
114 | self.throttle_period = datetime.timedelta( | |
115 | seconds=seconds, minutes=minutes, hours=hours |
|
115 | seconds=seconds, minutes=minutes, hours=hours | |
116 | ) |
|
116 | ) | |
117 |
|
117 | |||
118 | self.time_of_last_call = datetime.datetime.min |
|
118 | self.time_of_last_call = datetime.datetime.min | |
119 |
|
119 | |||
120 | def __call__(self, fn): |
|
120 | def __call__(self, fn): | |
121 | @wraps(fn) |
|
121 | @wraps(fn) | |
122 | def wrapper(*args, **kwargs): |
|
122 | def wrapper(*args, **kwargs): | |
123 | coerce = kwargs.pop('coerce', None) |
|
123 | coerce = kwargs.pop('coerce', None) | |
124 | if coerce: |
|
124 | if coerce: | |
125 | self.time_of_last_call = datetime.datetime.now() |
|
125 | self.time_of_last_call = datetime.datetime.now() | |
126 | return fn(*args, **kwargs) |
|
126 | return fn(*args, **kwargs) | |
127 | else: |
|
127 | else: | |
128 | now = datetime.datetime.now() |
|
128 | now = datetime.datetime.now() | |
129 | time_since_last_call = now - self.time_of_last_call |
|
129 | time_since_last_call = now - self.time_of_last_call | |
130 | time_left = self.throttle_period - time_since_last_call |
|
130 | time_left = self.throttle_period - time_since_last_call | |
131 |
|
131 | |||
132 | if time_left > datetime.timedelta(seconds=0): |
|
132 | if time_left > datetime.timedelta(seconds=0): | |
133 | return |
|
133 | return | |
134 |
|
134 | |||
135 | self.time_of_last_call = datetime.datetime.now() |
|
135 | self.time_of_last_call = datetime.datetime.now() | |
136 | return fn(*args, **kwargs) |
|
136 | return fn(*args, **kwargs) | |
137 |
|
137 | |||
138 | return wrapper |
|
138 | return wrapper | |
139 |
|
139 | |||
140 | def apply_throttle(value): |
|
140 | def apply_throttle(value): | |
141 |
|
141 | |||
142 | @Throttle(seconds=value) |
|
142 | @Throttle(seconds=value) | |
143 | def fnThrottled(fn): |
|
143 | def fnThrottled(fn): | |
144 | fn() |
|
144 | fn() | |
145 |
|
145 | |||
146 | return fnThrottled |
|
146 | return fnThrottled | |
147 |
|
147 | |||
148 |
|
148 | |||
149 | @MPDecorator |
|
149 | @MPDecorator | |
150 | class Plot(Operation): |
|
150 | class Plot(Operation): | |
151 | """Base class for Schain plotting operations |
|
151 | """Base class for Schain plotting operations | |
152 |
|
152 | |||
153 | This class should never be use directtly you must subclass a new operation, |
|
153 | This class should never be use directtly you must subclass a new operation, | |
154 | children classes must be defined as follow: |
|
154 | children classes must be defined as follow: | |
155 |
|
155 | |||
156 | ExamplePlot(Plot): |
|
156 | ExamplePlot(Plot): | |
157 |
|
157 | |||
158 | CODE = 'code' |
|
158 | CODE = 'code' | |
159 | colormap = 'jet' |
|
159 | colormap = 'jet' | |
160 | plot_type = 'pcolor' # options are ('pcolor', 'pcolorbuffer', 'scatter', 'scatterbuffer') |
|
160 | plot_type = 'pcolor' # options are ('pcolor', 'pcolorbuffer', 'scatter', 'scatterbuffer') | |
161 |
|
161 | |||
162 | def setup(self): |
|
162 | def setup(self): | |
163 | pass |
|
163 | pass | |
164 |
|
164 | |||
165 | def plot(self): |
|
165 | def plot(self): | |
166 | pass |
|
166 | pass | |
167 |
|
167 | |||
168 | """ |
|
168 | """ | |
169 |
|
169 | |||
170 | CODE = 'Figure' |
|
170 | CODE = 'Figure' | |
171 | colormap = 'jet' |
|
171 | colormap = 'jet' | |
172 | bgcolor = 'white' |
|
172 | bgcolor = 'white' | |
173 | buffering = True |
|
173 | buffering = True | |
174 | __missing = 1E30 |
|
174 | __missing = 1E30 | |
175 |
|
175 | |||
176 | __attrs__ = ['show', 'save', 'ymin', 'ymax', 'zmin', 'zmax', 'title', |
|
176 | __attrs__ = ['show', 'save', 'ymin', 'ymax', 'zmin', 'zmax', 'title', | |
177 | 'showprofile'] |
|
177 | 'showprofile'] | |
178 |
|
178 | |||
179 | def __init__(self): |
|
179 | def __init__(self): | |
180 |
|
180 | |||
181 | Operation.__init__(self) |
|
181 | Operation.__init__(self) | |
182 | self.isConfig = False |
|
182 | self.isConfig = False | |
183 | self.isPlotConfig = False |
|
183 | self.isPlotConfig = False | |
184 | self.save_time = 0 |
|
184 | self.save_time = 0 | |
185 | self.sender_time = 0 |
|
185 | self.sender_time = 0 | |
186 | self.data = None |
|
186 | self.data = None | |
187 | self.firsttime = True |
|
187 | self.firsttime = True | |
188 | self.sender_queue = deque(maxlen=10) |
|
188 | self.sender_queue = deque(maxlen=10) | |
189 | self.plots_adjust = {'left': 0.125, 'right': 0.9, 'bottom': 0.15, 'top': 0.9, 'wspace': 0.2, 'hspace': 0.2} |
|
189 | self.plots_adjust = {'left': 0.125, 'right': 0.9, 'bottom': 0.15, 'top': 0.9, 'wspace': 0.2, 'hspace': 0.2} | |
190 |
|
190 | |||
191 | def __fmtTime(self, x, pos): |
|
191 | def __fmtTime(self, x, pos): | |
192 | ''' |
|
192 | ''' | |
193 | ''' |
|
193 | ''' | |
194 |
|
194 | |||
195 | return '{}'.format(self.getDateTime(x).strftime('%H:%M')) |
|
195 | return '{}'.format(self.getDateTime(x).strftime('%H:%M')) | |
196 |
|
196 | |||
197 | def __setup(self, **kwargs): |
|
197 | def __setup(self, **kwargs): | |
198 | ''' |
|
198 | ''' | |
199 | Initialize variables |
|
199 | Initialize variables | |
200 | ''' |
|
200 | ''' | |
201 |
|
201 | |||
202 | self.figures = [] |
|
202 | self.figures = [] | |
203 | self.axes = [] |
|
203 | self.axes = [] | |
204 | self.cb_axes = [] |
|
204 | self.cb_axes = [] | |
205 | self.localtime = kwargs.pop('localtime', True) |
|
205 | self.localtime = kwargs.pop('localtime', True) | |
206 | self.show = kwargs.get('show', True) |
|
206 | self.show = kwargs.get('show', True) | |
207 | self.save = kwargs.get('save', False) |
|
207 | self.save = kwargs.get('save', False) | |
208 | self.save_period = kwargs.get('save_period', 0) |
|
208 | self.save_period = kwargs.get('save_period', 0) | |
209 | self.colormap = kwargs.get('colormap', self.colormap) |
|
209 | self.colormap = kwargs.get('colormap', self.colormap) | |
210 | self.colormap_coh = kwargs.get('colormap_coh', 'jet') |
|
210 | self.colormap_coh = kwargs.get('colormap_coh', 'jet') | |
211 | self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r') |
|
211 | self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r') | |
212 | self.colormaps = kwargs.get('colormaps', None) |
|
212 | self.colormaps = kwargs.get('colormaps', None) | |
213 | self.bgcolor = kwargs.get('bgcolor', self.bgcolor) |
|
213 | self.bgcolor = kwargs.get('bgcolor', self.bgcolor) | |
214 | self.showprofile = kwargs.get('showprofile', False) |
|
214 | self.showprofile = kwargs.get('showprofile', False) | |
215 | self.title = kwargs.get('wintitle', self.CODE.upper()) |
|
215 | self.title = kwargs.get('wintitle', self.CODE.upper()) | |
216 | self.cb_label = kwargs.get('cb_label', None) |
|
216 | self.cb_label = kwargs.get('cb_label', None) | |
217 | self.cb_labels = kwargs.get('cb_labels', None) |
|
217 | self.cb_labels = kwargs.get('cb_labels', None) | |
218 | self.labels = kwargs.get('labels', None) |
|
218 | self.labels = kwargs.get('labels', None) | |
219 | self.xaxis = kwargs.get('xaxis', 'frequency') |
|
219 | self.xaxis = kwargs.get('xaxis', 'frequency') | |
220 | self.zmin = kwargs.get('zmin', None) |
|
220 | self.zmin = kwargs.get('zmin', None) | |
221 | self.zmax = kwargs.get('zmax', None) |
|
221 | self.zmax = kwargs.get('zmax', None) | |
222 | self.zlimits = kwargs.get('zlimits', None) |
|
222 | self.zlimits = kwargs.get('zlimits', None) | |
223 | self.xlimits = kwargs.get('xlimits', None) |
|
223 | self.xlimits = kwargs.get('xlimits', None) | |
224 | self.xstep_given = kwargs.get('xstep_given', None) |
|
224 | self.xstep_given = kwargs.get('xstep_given', None) | |
225 | self.ystep_given = kwargs.get('ystep_given', None) |
|
225 | self.ystep_given = kwargs.get('ystep_given', None) | |
226 | self.autoxticks = kwargs.get('autoxticks', True) |
|
226 | self.autoxticks = kwargs.get('autoxticks', True) | |
227 | self.xmin = kwargs.get('xmin', None) |
|
227 | self.xmin = kwargs.get('xmin', None) | |
228 | self.xmax = kwargs.get('xmax', None) |
|
228 | self.xmax = kwargs.get('xmax', None) | |
229 | self.xrange = kwargs.get('xrange', 12) |
|
229 | self.xrange = kwargs.get('xrange', 12) | |
230 | self.xscale = kwargs.get('xscale', None) |
|
230 | self.xscale = kwargs.get('xscale', None) | |
231 | self.ymin = kwargs.get('ymin', None) |
|
231 | self.ymin = kwargs.get('ymin', None) | |
232 | self.ymax = kwargs.get('ymax', None) |
|
232 | self.ymax = kwargs.get('ymax', None) | |
233 | self.yscale = kwargs.get('yscale', None) |
|
233 | self.yscale = kwargs.get('yscale', None) | |
234 | self.xlabel = kwargs.get('xlabel', None) |
|
234 | self.xlabel = kwargs.get('xlabel', None) | |
235 | self.attr_time = kwargs.get('attr_time', 'utctime') |
|
235 | self.attr_time = kwargs.get('attr_time', 'utctime') | |
236 | self.attr_data = kwargs.get('attr_data', 'data_param') |
|
236 | self.attr_data = kwargs.get('attr_data', 'data_param') | |
237 | self.decimation = kwargs.get('decimation', None) |
|
237 | self.decimation = kwargs.get('decimation', None) | |
238 | self.oneFigure = kwargs.get('oneFigure', True) |
|
238 | self.oneFigure = kwargs.get('oneFigure', True) | |
239 | self.width = kwargs.get('width', None) |
|
239 | self.width = kwargs.get('width', None) | |
240 | self.height = kwargs.get('height', None) |
|
240 | self.height = kwargs.get('height', None) | |
241 | self.colorbar = kwargs.get('colorbar', True) |
|
241 | self.colorbar = kwargs.get('colorbar', True) | |
242 | self.factors = kwargs.get('factors', [1, 1, 1, 1, 1, 1, 1, 1]) |
|
242 | self.factors = kwargs.get('factors', [1, 1, 1, 1, 1, 1, 1, 1]) | |
243 | self.channels = kwargs.get('channels', None) |
|
243 | self.channels = kwargs.get('channels', None) | |
244 | self.titles = kwargs.get('titles', []) |
|
244 | self.titles = kwargs.get('titles', []) | |
245 | self.polar = False |
|
245 | self.polar = False | |
246 | self.type = kwargs.get('type', 'iq') |
|
246 | self.type = kwargs.get('type', 'iq') | |
247 | self.grid = kwargs.get('grid', False) |
|
247 | self.grid = kwargs.get('grid', False) | |
248 | self.pause = kwargs.get('pause', False) |
|
248 | self.pause = kwargs.get('pause', False) | |
249 | self.save_code = kwargs.get('save_code', self.CODE) |
|
249 | self.save_code = kwargs.get('save_code', self.CODE) | |
250 | self.throttle = kwargs.get('throttle', 0) |
|
250 | self.throttle = kwargs.get('throttle', 0) | |
251 | self.exp_code = kwargs.get('exp_code', None) |
|
251 | self.exp_code = kwargs.get('exp_code', None) | |
252 | self.server = kwargs.get('server', False) |
|
252 | self.server = kwargs.get('server', False) | |
253 | self.sender_period = kwargs.get('sender_period', 60) |
|
253 | self.sender_period = kwargs.get('sender_period', 60) | |
254 | self.tag = kwargs.get('tag', '') |
|
254 | self.tag = kwargs.get('tag', '') | |
255 | self.height_index = kwargs.get('height_index', None) |
|
255 | self.height_index = kwargs.get('height_index', None) | |
256 | self.__throttle_plot = apply_throttle(self.throttle) |
|
256 | self.__throttle_plot = apply_throttle(self.throttle) | |
257 | code = self.attr_data if self.attr_data else self.CODE |
|
257 | code = self.attr_data if self.attr_data else self.CODE | |
258 | self.data = PlotterData(self.CODE, self.exp_code, self.localtime) |
|
258 | self.data = PlotterData(self.CODE, self.exp_code, self.localtime) | |
259 | #self.EEJtype = kwargs.get('EEJtype', 2) |
|
259 | #self.EEJtype = kwargs.get('EEJtype', 2) | |
260 |
|
260 | |||
261 | if self.server: |
|
261 | if self.server: | |
262 | if not self.server.startswith('tcp://'): |
|
262 | if not self.server.startswith('tcp://'): | |
263 | self.server = 'tcp://{}'.format(self.server) |
|
263 | self.server = 'tcp://{}'.format(self.server) | |
264 | log.success( |
|
264 | log.success( | |
265 | 'Sending to server: {}'.format(self.server), |
|
265 | 'Sending to server: {}'.format(self.server), | |
266 | self.name |
|
266 | self.name | |
267 | ) |
|
267 | ) | |
268 |
|
268 | |||
269 | if isinstance(self.attr_data, str): |
|
269 | if isinstance(self.attr_data, str): | |
270 | self.attr_data = [self.attr_data] |
|
270 | self.attr_data = [self.attr_data] | |
271 |
|
271 | |||
272 | def __setup_plot(self): |
|
272 | def __setup_plot(self): | |
273 | ''' |
|
273 | ''' | |
274 | Common setup for all figures, here figures and axes are created |
|
274 | Common setup for all figures, here figures and axes are created | |
275 | ''' |
|
275 | ''' | |
276 |
|
276 | |||
277 | self.setup() |
|
277 | self.setup() | |
278 |
|
278 | |||
279 | self.time_label = 'LT' if self.localtime else 'UTC' |
|
279 | self.time_label = 'LT' if self.localtime else 'UTC' | |
280 |
|
280 | |||
281 | if self.width is None: |
|
281 | if self.width is None: | |
282 | self.width = 8 |
|
282 | self.width = 8 | |
283 |
|
283 | |||
284 | self.figures = [] |
|
284 | self.figures = [] | |
285 | self.axes = [] |
|
285 | self.axes = [] | |
286 | self.cb_axes = [] |
|
286 | self.cb_axes = [] | |
287 | self.pf_axes = [] |
|
287 | self.pf_axes = [] | |
288 | self.cmaps = [] |
|
288 | self.cmaps = [] | |
289 |
|
289 | |||
290 | size = '15%' if self.ncols == 1 else '30%' |
|
290 | size = '15%' if self.ncols == 1 else '30%' | |
291 | pad = '4%' if self.ncols == 1 else '8%' |
|
291 | pad = '4%' if self.ncols == 1 else '8%' | |
292 |
|
292 | |||
293 | if self.oneFigure: |
|
293 | if self.oneFigure: | |
294 | if self.height is None: |
|
294 | if self.height is None: | |
295 | self.height = 1.4 * self.nrows + 1 |
|
295 | self.height = 1.4 * self.nrows + 1 | |
296 | fig = plt.figure(figsize=(self.width, self.height), |
|
296 | fig = plt.figure(figsize=(self.width, self.height), | |
297 | edgecolor='k', |
|
297 | edgecolor='k', | |
298 | facecolor='w') |
|
298 | facecolor='w') | |
299 | self.figures.append(fig) |
|
299 | self.figures.append(fig) | |
300 | for n in range(self.nplots): |
|
300 | for n in range(self.nplots): | |
301 | ax = fig.add_subplot(self.nrows, self.ncols, |
|
301 | ax = fig.add_subplot(self.nrows, self.ncols, | |
302 | n + 1, polar=self.polar) |
|
302 | n + 1, polar=self.polar) | |
303 | ax.tick_params(labelsize=8) |
|
303 | ax.tick_params(labelsize=8) | |
304 | ax.firsttime = True |
|
304 | ax.firsttime = True | |
305 | ax.index = 0 |
|
305 | ax.index = 0 | |
306 | ax.press = None |
|
306 | ax.press = None | |
307 | self.axes.append(ax) |
|
307 | self.axes.append(ax) | |
308 | if self.showprofile: |
|
308 | if self.showprofile: | |
309 | cax = self.__add_axes(ax, size=size, pad=pad) |
|
309 | cax = self.__add_axes(ax, size=size, pad=pad) | |
310 | cax.tick_params(labelsize=8) |
|
310 | cax.tick_params(labelsize=8) | |
311 | self.pf_axes.append(cax) |
|
311 | self.pf_axes.append(cax) | |
312 | else: |
|
312 | else: | |
313 | if self.height is None: |
|
313 | if self.height is None: | |
314 | self.height = 3 |
|
314 | self.height = 3 | |
315 | for n in range(self.nplots): |
|
315 | for n in range(self.nplots): | |
316 | fig = plt.figure(figsize=(self.width, self.height), |
|
316 | fig = plt.figure(figsize=(self.width, self.height), | |
317 | edgecolor='k', |
|
317 | edgecolor='k', | |
318 | facecolor='w') |
|
318 | facecolor='w') | |
319 | ax = fig.add_subplot(1, 1, 1, polar=self.polar) |
|
319 | ax = fig.add_subplot(1, 1, 1, polar=self.polar) | |
320 | ax.tick_params(labelsize=8) |
|
320 | ax.tick_params(labelsize=8) | |
321 | ax.firsttime = True |
|
321 | ax.firsttime = True | |
322 | ax.index = 0 |
|
322 | ax.index = 0 | |
323 | ax.press = None |
|
323 | ax.press = None | |
324 | self.figures.append(fig) |
|
324 | self.figures.append(fig) | |
325 | self.axes.append(ax) |
|
325 | self.axes.append(ax) | |
326 | if self.showprofile: |
|
326 | if self.showprofile: | |
327 | cax = self.__add_axes(ax, size=size, pad=pad) |
|
327 | cax = self.__add_axes(ax, size=size, pad=pad) | |
328 | cax.tick_params(labelsize=8) |
|
328 | cax.tick_params(labelsize=8) | |
329 | self.pf_axes.append(cax) |
|
329 | self.pf_axes.append(cax) | |
330 |
|
330 | |||
331 | for n in range(self.nrows): |
|
331 | for n in range(self.nrows): | |
332 | if self.colormaps is not None: |
|
332 | if self.colormaps is not None: | |
333 | cmap = plt.get_cmap(self.colormaps[n]) |
|
333 | cmap = plt.get_cmap(self.colormaps[n]) | |
334 | else: |
|
334 | else: | |
335 | cmap = plt.get_cmap(self.colormap) |
|
335 | cmap = plt.get_cmap(self.colormap) | |
336 | cmap.set_bad(self.bgcolor, 1.) |
|
336 | cmap.set_bad(self.bgcolor, 1.) | |
337 | self.cmaps.append(cmap) |
|
337 | self.cmaps.append(cmap) | |
338 |
|
338 | |||
339 | def __add_axes(self, ax, size='30%', pad='8%'): |
|
339 | def __add_axes(self, ax, size='30%', pad='8%'): | |
340 | ''' |
|
340 | ''' | |
341 | Add new axes to the given figure |
|
341 | Add new axes to the given figure | |
342 | ''' |
|
342 | ''' | |
343 | divider = make_axes_locatable(ax) |
|
343 | divider = make_axes_locatable(ax) | |
344 | nax = divider.new_horizontal(size=size, pad=pad) |
|
344 | nax = divider.new_horizontal(size=size, pad=pad) | |
345 | ax.figure.add_axes(nax) |
|
345 | ax.figure.add_axes(nax) | |
346 | return nax |
|
346 | return nax | |
347 |
|
347 | |||
348 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): |
|
348 | def fill_gaps(self, x_buffer, y_buffer, z_buffer): | |
349 | ''' |
|
349 | ''' | |
350 | Create a masked array for missing data |
|
350 | Create a masked array for missing data | |
351 | ''' |
|
351 | ''' | |
352 | if x_buffer.shape[0] < 2: |
|
352 | if x_buffer.shape[0] < 2: | |
353 | return x_buffer, y_buffer, z_buffer |
|
353 | return x_buffer, y_buffer, z_buffer | |
354 |
|
354 | |||
355 | deltas = x_buffer[1:] - x_buffer[0:-1] |
|
355 | deltas = x_buffer[1:] - x_buffer[0:-1] | |
356 | x_median = numpy.median(deltas) |
|
356 | x_median = numpy.median(deltas) | |
357 |
|
357 | |||
358 | index = numpy.where(deltas > 5 * x_median) |
|
358 | index = numpy.where(deltas > 5 * x_median) | |
359 |
|
359 | |||
360 | if len(index[0]) != 0: |
|
360 | if len(index[0]) != 0: | |
361 | z_buffer[::, index[0], ::] = self.__missing |
|
361 | z_buffer[::, index[0], ::] = self.__missing | |
362 | z_buffer = numpy.ma.masked_inside(z_buffer, |
|
362 | z_buffer = numpy.ma.masked_inside(z_buffer, | |
363 | 0.99 * self.__missing, |
|
363 | 0.99 * self.__missing, | |
364 | 1.01 * self.__missing) |
|
364 | 1.01 * self.__missing) | |
365 |
|
365 | |||
366 | return x_buffer, y_buffer, z_buffer |
|
366 | return x_buffer, y_buffer, z_buffer | |
367 |
|
367 | |||
368 | def decimate(self): |
|
368 | def decimate(self): | |
369 |
|
369 | |||
370 | # dx = int(len(self.x)/self.__MAXNUMX) + 1 |
|
370 | # dx = int(len(self.x)/self.__MAXNUMX) + 1 | |
371 | dy = int(len(self.y) / self.decimation) + 1 |
|
371 | dy = int(len(self.y) / self.decimation) + 1 | |
372 |
|
372 | |||
373 | # x = self.x[::dx] |
|
373 | # x = self.x[::dx] | |
374 | x = self.x |
|
374 | x = self.x | |
375 | y = self.y[::dy] |
|
375 | y = self.y[::dy] | |
376 | z = self.z[::, ::, ::dy] |
|
376 | z = self.z[::, ::, ::dy] | |
377 |
|
377 | |||
378 | return x, y, z |
|
378 | return x, y, z | |
379 |
|
379 | |||
380 | def format(self): |
|
380 | def format(self): | |
381 | ''' |
|
381 | ''' | |
382 | Set min and max values, labels, ticks and titles |
|
382 | Set min and max values, labels, ticks and titles | |
383 | ''' |
|
383 | ''' | |
384 |
|
384 | |||
385 | for n, ax in enumerate(self.axes): |
|
385 | for n, ax in enumerate(self.axes): | |
386 | if ax.firsttime: |
|
386 | if ax.firsttime: | |
387 | if self.xaxis != 'time': |
|
387 | if self.xaxis != 'time': | |
388 | xmin = self.xmin |
|
388 | xmin = self.xmin | |
389 | xmax = self.xmax |
|
389 | xmax = self.xmax | |
390 | else: |
|
390 | else: | |
391 | xmin = self.tmin |
|
391 | xmin = self.tmin | |
392 | xmax = self.tmin + self.xrange*60*60 |
|
392 | xmax = self.tmin + self.xrange*60*60 | |
393 | ax.xaxis.set_major_formatter(FuncFormatter(self.__fmtTime)) |
|
393 | ax.xaxis.set_major_formatter(FuncFormatter(self.__fmtTime)) | |
394 | ax.xaxis.set_major_locator(LinearLocator(9)) |
|
394 | ax.xaxis.set_major_locator(LinearLocator(9)) | |
395 | ymin = self.ymin if self.ymin is not None else numpy.nanmin(self.y[numpy.isfinite(self.y)]) |
|
395 | ymin = self.ymin if self.ymin is not None else numpy.nanmin(self.y[numpy.isfinite(self.y)]) | |
396 | ymax = self.ymax if self.ymax is not None else numpy.nanmax(self.y[numpy.isfinite(self.y)]) |
|
396 | ymax = self.ymax if self.ymax is not None else numpy.nanmax(self.y[numpy.isfinite(self.y)]) | |
397 | ax.set_facecolor(self.bgcolor) |
|
397 | ax.set_facecolor(self.bgcolor) | |
398 | if self.xscale: |
|
398 | if self.xscale: | |
399 | ax.xaxis.set_major_formatter(FuncFormatter( |
|
399 | ax.xaxis.set_major_formatter(FuncFormatter( | |
400 | lambda x, pos: '{0:g}'.format(x*self.xscale))) |
|
400 | lambda x, pos: '{0:g}'.format(x*self.xscale))) | |
401 | if self.yscale: |
|
401 | if self.yscale: | |
402 | ax.yaxis.set_major_formatter(FuncFormatter( |
|
402 | ax.yaxis.set_major_formatter(FuncFormatter( | |
403 | lambda x, pos: '{0:g}'.format(x*self.yscale))) |
|
403 | lambda x, pos: '{0:g}'.format(x*self.yscale))) | |
404 | if self.xlabel is not None: |
|
404 | if self.xlabel is not None: | |
405 | ax.set_xlabel(self.xlabel) |
|
405 | ax.set_xlabel(self.xlabel) | |
406 | if self.ylabel is not None: |
|
406 | if self.ylabel is not None: | |
407 | ax.set_ylabel(self.ylabel) |
|
407 | ax.set_ylabel(self.ylabel) | |
408 | if self.showprofile: |
|
408 | if self.showprofile: | |
409 | self.pf_axes[n].set_ylim(ymin, ymax) |
|
409 | self.pf_axes[n].set_ylim(ymin, ymax) | |
410 | self.pf_axes[n].set_xlim(self.zmin, self.zmax) |
|
410 | self.pf_axes[n].set_xlim(self.zmin[n], self.zmax[n]) | |
411 | self.pf_axes[n].set_xlabel('dB') |
|
411 | self.pf_axes[n].set_xlabel('dB') | |
412 | self.pf_axes[n].grid(b=True, axis='x') |
|
412 | self.pf_axes[n].grid(b=True, axis='x') | |
413 | [tick.set_visible(False) |
|
413 | [tick.set_visible(False) | |
414 | for tick in self.pf_axes[n].get_yticklabels()] |
|
414 | for tick in self.pf_axes[n].get_yticklabels()] | |
415 | if self.colorbar: |
|
415 | if self.colorbar: | |
416 | ax.cbar = plt.colorbar( |
|
416 | ax.cbar = plt.colorbar( | |
417 | ax.plt, ax=ax, fraction=0.05, pad=0.02, aspect=10) |
|
417 | ax.plt, ax=ax, fraction=0.05, pad=0.02, aspect=10) | |
418 | ax.cbar.ax.tick_params(labelsize=8) |
|
418 | ax.cbar.ax.tick_params(labelsize=8) | |
419 | ax.cbar.ax.press = None |
|
419 | ax.cbar.ax.press = None | |
420 | if self.cb_label: |
|
420 | if self.cb_label: | |
421 | ax.cbar.set_label(self.cb_label, size=8) |
|
421 | ax.cbar.set_label(self.cb_label, size=8) | |
422 | elif self.cb_labels: |
|
422 | elif self.cb_labels: | |
423 | ax.cbar.set_label(self.cb_labels[n], size=8) |
|
423 | ax.cbar.set_label(self.cb_labels[n], size=8) | |
424 | else: |
|
424 | else: | |
425 | ax.cbar = None |
|
425 | ax.cbar = None | |
426 | ax.set_xlim(xmin, xmax) |
|
426 | ax.set_xlim(xmin, xmax) | |
427 | ax.set_ylim(ymin, ymax) |
|
427 | ax.set_ylim(ymin, ymax) | |
428 | ax.firsttime = False |
|
428 | ax.firsttime = False | |
429 | if self.grid: |
|
429 | if self.grid: | |
430 | ax.grid(True) |
|
430 | ax.grid(True) | |
431 | if not self.polar: |
|
431 | if not self.polar: | |
432 | ax.set_title('{} {} {}'.format( |
|
432 | ax.set_title('{} {} {}'.format( | |
433 | self.titles[n], |
|
433 | self.titles[n], | |
434 | self.getDateTime(self.data.max_time).strftime( |
|
434 | self.getDateTime(self.data.max_time).strftime( | |
435 | '%Y-%m-%d %H:%M:%S'), |
|
435 | '%Y-%m-%d %H:%M:%S'), | |
436 | self.time_label), |
|
436 | self.time_label), | |
437 | size=8) |
|
437 | size=8) | |
438 | else: |
|
438 | else: | |
439 | ax.set_title('{}'.format(self.titles[n]), size=8) |
|
439 | ax.set_title('{}'.format(self.titles[n]), size=8) | |
440 | ax.set_ylim(0, 90) |
|
440 | ax.set_ylim(0, 90) | |
441 | ax.set_yticks(numpy.arange(0, 90, 20)) |
|
441 | ax.set_yticks(numpy.arange(0, 90, 20)) | |
442 | ax.yaxis.labelpad = 40 |
|
442 | ax.yaxis.labelpad = 40 | |
443 |
|
443 | |||
444 | if self.firsttime: |
|
444 | if self.firsttime: | |
445 | for n, fig in enumerate(self.figures): |
|
445 | for n, fig in enumerate(self.figures): | |
446 | fig.subplots_adjust(**self.plots_adjust) |
|
446 | fig.subplots_adjust(**self.plots_adjust) | |
447 | self.firsttime = False |
|
447 | self.firsttime = False | |
448 |
|
448 | |||
449 | def clear_figures(self): |
|
449 | def clear_figures(self): | |
450 | ''' |
|
450 | ''' | |
451 | Reset axes for redraw plots |
|
451 | Reset axes for redraw plots | |
452 | ''' |
|
452 | ''' | |
453 |
|
453 | |||
454 | for ax in self.axes+self.pf_axes+self.cb_axes: |
|
454 | for ax in self.axes+self.pf_axes+self.cb_axes: | |
455 | ax.clear() |
|
455 | ax.clear() | |
456 | ax.firsttime = True |
|
456 | ax.firsttime = True | |
457 | if hasattr(ax, 'cbar') and ax.cbar: |
|
457 | if hasattr(ax, 'cbar') and ax.cbar: | |
458 | ax.cbar.remove() |
|
458 | ax.cbar.remove() | |
459 |
|
459 | |||
460 | def __plot(self): |
|
460 | def __plot(self): | |
461 | ''' |
|
461 | ''' | |
462 | Main function to plot, format and save figures |
|
462 | Main function to plot, format and save figures | |
463 | ''' |
|
463 | ''' | |
464 |
|
464 | |||
465 | self.plot() |
|
465 | self.plot() | |
466 | self.format() |
|
466 | self.format() | |
467 |
|
467 | |||
468 | for n, fig in enumerate(self.figures): |
|
468 | for n, fig in enumerate(self.figures): | |
469 | if self.nrows == 0 or self.nplots == 0: |
|
469 | if self.nrows == 0 or self.nplots == 0: | |
470 | log.warning('No data', self.name) |
|
470 | log.warning('No data', self.name) | |
471 | fig.text(0.5, 0.5, 'No Data', fontsize='large', ha='center') |
|
471 | fig.text(0.5, 0.5, 'No Data', fontsize='large', ha='center') | |
472 | fig.canvas.manager.set_window_title(self.CODE) |
|
472 | fig.canvas.manager.set_window_title(self.CODE) | |
473 | continue |
|
473 | continue | |
474 |
|
474 | |||
475 | fig.canvas.manager.set_window_title('{} - {}'.format(self.title, |
|
475 | fig.canvas.manager.set_window_title('{} - {}'.format(self.title, | |
476 | self.getDateTime(self.data.max_time).strftime('%Y/%m/%d'))) |
|
476 | self.getDateTime(self.data.max_time).strftime('%Y/%m/%d'))) | |
477 | fig.canvas.draw() |
|
477 | fig.canvas.draw() | |
478 | if self.show: |
|
478 | if self.show: | |
479 | fig.show() |
|
479 | fig.show() | |
480 | figpause(0.01) |
|
480 | figpause(0.01) | |
481 |
|
481 | |||
482 | if self.save: |
|
482 | if self.save: | |
483 | self.save_figure(n) |
|
483 | self.save_figure(n) | |
484 |
|
484 | |||
485 | if self.server: |
|
485 | if self.server: | |
486 | self.send_to_server() |
|
486 | self.send_to_server() | |
487 |
|
487 | |||
488 | def __update(self, dataOut, timestamp): |
|
488 | def __update(self, dataOut, timestamp): | |
489 | ''' |
|
489 | ''' | |
490 | ''' |
|
490 | ''' | |
491 |
|
491 | |||
492 | metadata = { |
|
492 | metadata = { | |
493 | 'yrange': dataOut.heightList, |
|
493 | 'yrange': dataOut.heightList, | |
494 | 'interval': dataOut.timeInterval, |
|
494 | 'interval': dataOut.timeInterval, | |
495 | 'channels': dataOut.channelList |
|
495 | 'channels': dataOut.channelList | |
496 | } |
|
496 | } | |
497 |
|
497 | |||
498 | data, meta = self.update(dataOut) |
|
498 | data, meta = self.update(dataOut) | |
499 | metadata.update(meta) |
|
499 | metadata.update(meta) | |
500 | self.data.update(data, timestamp, metadata) |
|
500 | self.data.update(data, timestamp, metadata) | |
501 |
|
501 | |||
502 | def save_figure(self, n): |
|
502 | def save_figure(self, n): | |
503 | ''' |
|
503 | ''' | |
504 | ''' |
|
504 | ''' | |
505 |
|
505 | |||
506 | if (self.data.max_time - self.save_time) <= self.save_period: |
|
506 | if (self.data.max_time - self.save_time) <= self.save_period: | |
507 | return |
|
507 | return | |
508 |
|
508 | |||
509 | self.save_time = self.data.max_time |
|
509 | self.save_time = self.data.max_time | |
510 |
|
510 | |||
511 | fig = self.figures[n] |
|
511 | fig = self.figures[n] | |
512 |
|
512 | |||
513 | if self.throttle == 0: |
|
513 | if self.throttle == 0: | |
514 | figname = os.path.join( |
|
514 | figname = os.path.join( | |
515 | self.save, |
|
515 | self.save, | |
516 | self.save_code, |
|
516 | self.save_code, | |
517 | '{}_{}.png'.format( |
|
517 | '{}_{}.png'.format( | |
518 | self.save_code, |
|
518 | self.save_code, | |
519 | self.getDateTime(self.data.max_time).strftime( |
|
519 | self.getDateTime(self.data.max_time).strftime( | |
520 | '%Y%m%d_%H%M%S' |
|
520 | '%Y%m%d_%H%M%S' | |
521 | ), |
|
521 | ), | |
522 | ) |
|
522 | ) | |
523 | ) |
|
523 | ) | |
524 | log.log('Saving figure: {}'.format(figname), self.name) |
|
524 | log.log('Saving figure: {}'.format(figname), self.name) | |
525 | if not os.path.isdir(os.path.dirname(figname)): |
|
525 | if not os.path.isdir(os.path.dirname(figname)): | |
526 | os.makedirs(os.path.dirname(figname)) |
|
526 | os.makedirs(os.path.dirname(figname)) | |
527 | fig.savefig(figname) |
|
527 | fig.savefig(figname) | |
528 |
|
528 | |||
529 | figname = os.path.join( |
|
529 | figname = os.path.join( | |
530 | self.save, |
|
530 | self.save, | |
531 | #self.save_code, |
|
531 | #self.save_code, | |
532 | '{}_{}.png'.format( |
|
532 | '{}_{}.png'.format( | |
533 | self.save_code, |
|
533 | self.save_code, | |
534 | self.getDateTime(self.data.min_time).strftime( |
|
534 | self.getDateTime(self.data.min_time).strftime( | |
535 | '%Y%m%d' |
|
535 | '%Y%m%d' | |
536 | ), |
|
536 | ), | |
537 | ) |
|
537 | ) | |
538 | ) |
|
538 | ) | |
539 | log.log('Saving figure: {}'.format(figname), self.name) |
|
539 | log.log('Saving figure: {}'.format(figname), self.name) | |
540 | if not os.path.isdir(os.path.dirname(figname)): |
|
540 | if not os.path.isdir(os.path.dirname(figname)): | |
541 | os.makedirs(os.path.dirname(figname)) |
|
541 | os.makedirs(os.path.dirname(figname)) | |
542 | fig.savefig(figname) |
|
542 | fig.savefig(figname) | |
543 |
|
543 | |||
544 | def send_to_server(self): |
|
544 | def send_to_server(self): | |
545 | ''' |
|
545 | ''' | |
546 | ''' |
|
546 | ''' | |
547 |
|
547 | |||
548 | if self.exp_code == None: |
|
548 | if self.exp_code == None: | |
549 | log.warning('Missing `exp_code` skipping sending to server...') |
|
549 | log.warning('Missing `exp_code` skipping sending to server...') | |
550 |
|
550 | |||
551 | last_time = self.data.max_time |
|
551 | last_time = self.data.max_time | |
552 | interval = last_time - self.sender_time |
|
552 | interval = last_time - self.sender_time | |
553 | if interval < self.sender_period: |
|
553 | if interval < self.sender_period: | |
554 | return |
|
554 | return | |
555 |
|
555 | |||
556 | self.sender_time = last_time |
|
556 | self.sender_time = last_time | |
557 |
|
557 | |||
558 | attrs = ['titles', 'zmin', 'zmax', 'tag', 'ymin', 'ymax'] |
|
558 | attrs = ['titles', 'zmin', 'zmax', 'tag', 'ymin', 'ymax'] | |
559 | for attr in attrs: |
|
559 | for attr in attrs: | |
560 | value = getattr(self, attr) |
|
560 | value = getattr(self, attr) | |
561 | if value: |
|
561 | if value: | |
562 | if isinstance(value, (numpy.float32, numpy.float64)): |
|
562 | if isinstance(value, (numpy.float32, numpy.float64)): | |
563 | value = round(float(value), 2) |
|
563 | value = round(float(value), 2) | |
564 | self.data.meta[attr] = value |
|
564 | self.data.meta[attr] = value | |
565 | if self.colormap == 'jet': |
|
565 | if self.colormap == 'jet': | |
566 | self.data.meta['colormap'] = 'Jet' |
|
566 | self.data.meta['colormap'] = 'Jet' | |
567 | elif 'RdBu' in self.colormap: |
|
567 | elif 'RdBu' in self.colormap: | |
568 | self.data.meta['colormap'] = 'RdBu' |
|
568 | self.data.meta['colormap'] = 'RdBu' | |
569 | else: |
|
569 | else: | |
570 | self.data.meta['colormap'] = 'Viridis' |
|
570 | self.data.meta['colormap'] = 'Viridis' | |
571 | self.data.meta['interval'] = int(interval) |
|
571 | self.data.meta['interval'] = int(interval) | |
572 |
|
572 | |||
573 | self.sender_queue.append(last_time) |
|
573 | self.sender_queue.append(last_time) | |
574 |
|
574 | |||
575 | while True: |
|
575 | while True: | |
576 | try: |
|
576 | try: | |
577 | tm = self.sender_queue.popleft() |
|
577 | tm = self.sender_queue.popleft() | |
578 | except IndexError: |
|
578 | except IndexError: | |
579 | break |
|
579 | break | |
580 | msg = self.data.jsonify(tm, self.save_code, self.plot_type) |
|
580 | msg = self.data.jsonify(tm, self.save_code, self.plot_type) | |
581 | self.socket.send_string(msg) |
|
581 | self.socket.send_string(msg) | |
582 | socks = dict(self.poll.poll(2000)) |
|
582 | socks = dict(self.poll.poll(2000)) | |
583 | if socks.get(self.socket) == zmq.POLLIN: |
|
583 | if socks.get(self.socket) == zmq.POLLIN: | |
584 | reply = self.socket.recv_string() |
|
584 | reply = self.socket.recv_string() | |
585 | if reply == 'ok': |
|
585 | if reply == 'ok': | |
586 | log.log("Response from server ok", self.name) |
|
586 | log.log("Response from server ok", self.name) | |
587 | time.sleep(0.1) |
|
587 | time.sleep(0.1) | |
588 | continue |
|
588 | continue | |
589 | else: |
|
589 | else: | |
590 | log.warning( |
|
590 | log.warning( | |
591 | "Malformed reply from server: {}".format(reply), self.name) |
|
591 | "Malformed reply from server: {}".format(reply), self.name) | |
592 | else: |
|
592 | else: | |
593 | log.warning( |
|
593 | log.warning( | |
594 | "No response from server, retrying...", self.name) |
|
594 | "No response from server, retrying...", self.name) | |
595 | self.sender_queue.appendleft(tm) |
|
595 | self.sender_queue.appendleft(tm) | |
596 | self.socket.setsockopt(zmq.LINGER, 0) |
|
596 | self.socket.setsockopt(zmq.LINGER, 0) | |
597 | self.socket.close() |
|
597 | self.socket.close() | |
598 | self.poll.unregister(self.socket) |
|
598 | self.poll.unregister(self.socket) | |
599 | self.socket = self.context.socket(zmq.REQ) |
|
599 | self.socket = self.context.socket(zmq.REQ) | |
600 | self.socket.connect(self.server) |
|
600 | self.socket.connect(self.server) | |
601 | self.poll.register(self.socket, zmq.POLLIN) |
|
601 | self.poll.register(self.socket, zmq.POLLIN) | |
602 | break |
|
602 | break | |
603 |
|
603 | |||
604 | def setup(self): |
|
604 | def setup(self): | |
605 | ''' |
|
605 | ''' | |
606 | This method should be implemented in the child class, the following |
|
606 | This method should be implemented in the child class, the following | |
607 | attributes should be set: |
|
607 | attributes should be set: | |
608 |
|
608 | |||
609 | self.nrows: number of rows |
|
609 | self.nrows: number of rows | |
610 | self.ncols: number of cols |
|
610 | self.ncols: number of cols | |
611 | self.nplots: number of plots (channels or pairs) |
|
611 | self.nplots: number of plots (channels or pairs) | |
612 | self.ylabel: label for Y axes |
|
612 | self.ylabel: label for Y axes | |
613 | self.titles: list of axes title |
|
613 | self.titles: list of axes title | |
614 |
|
614 | |||
615 | ''' |
|
615 | ''' | |
616 | raise NotImplementedError |
|
616 | raise NotImplementedError | |
617 |
|
617 | |||
618 | def plot(self): |
|
618 | def plot(self): | |
619 | ''' |
|
619 | ''' | |
620 | Must be defined in the child class, the actual plotting method |
|
620 | Must be defined in the child class, the actual plotting method | |
621 | ''' |
|
621 | ''' | |
622 | raise NotImplementedError |
|
622 | raise NotImplementedError | |
623 |
|
623 | |||
624 | def update(self, dataOut): |
|
624 | def update(self, dataOut): | |
625 | ''' |
|
625 | ''' | |
626 | Must be defined in the child class, update self.data with new data |
|
626 | Must be defined in the child class, update self.data with new data | |
627 | ''' |
|
627 | ''' | |
628 |
|
628 | |||
629 | data = { |
|
629 | data = { | |
630 | self.CODE: getattr(dataOut, 'data_{}'.format(self.CODE)) |
|
630 | self.CODE: getattr(dataOut, 'data_{}'.format(self.CODE)) | |
631 | } |
|
631 | } | |
632 | meta = {} |
|
632 | meta = {} | |
633 |
|
633 | |||
634 | return data, meta |
|
634 | return data, meta | |
635 |
|
635 | |||
636 | def run(self, dataOut, **kwargs): |
|
636 | def run(self, dataOut, **kwargs): | |
637 | ''' |
|
637 | ''' | |
638 | Main plotting routine |
|
638 | Main plotting routine | |
639 | ''' |
|
639 | ''' | |
640 |
|
640 | |||
641 | if self.isConfig is False: |
|
641 | if self.isConfig is False: | |
642 | self.__setup(**kwargs) |
|
642 | self.__setup(**kwargs) | |
643 |
|
643 | |||
644 | if self.localtime: |
|
644 | if self.localtime: | |
645 | self.getDateTime = datetime.datetime.fromtimestamp |
|
645 | self.getDateTime = datetime.datetime.fromtimestamp | |
646 | else: |
|
646 | else: | |
647 | self.getDateTime = datetime.datetime.utcfromtimestamp |
|
647 | self.getDateTime = datetime.datetime.utcfromtimestamp | |
648 |
|
648 | |||
649 | self.data.setup() |
|
649 | self.data.setup() | |
650 | self.isConfig = True |
|
650 | self.isConfig = True | |
651 | if self.server: |
|
651 | if self.server: | |
652 | self.context = zmq.Context() |
|
652 | self.context = zmq.Context() | |
653 | self.socket = self.context.socket(zmq.REQ) |
|
653 | self.socket = self.context.socket(zmq.REQ) | |
654 | self.socket.connect(self.server) |
|
654 | self.socket.connect(self.server) | |
655 | self.poll = zmq.Poller() |
|
655 | self.poll = zmq.Poller() | |
656 | self.poll.register(self.socket, zmq.POLLIN) |
|
656 | self.poll.register(self.socket, zmq.POLLIN) | |
657 |
|
657 | |||
658 | tm = getattr(dataOut, self.attr_time) |
|
658 | tm = getattr(dataOut, self.attr_time) | |
659 |
|
659 | |||
660 | if self.data and 'time' in self.xaxis and (tm - self.tmin) >= self.xrange*60*60: |
|
660 | if self.data and 'time' in self.xaxis and (tm - self.tmin) >= self.xrange*60*60: | |
661 | self.save_time = tm |
|
661 | self.save_time = tm | |
662 | self.__plot() |
|
662 | self.__plot() | |
663 | self.tmin += self.xrange*60*60 |
|
663 | self.tmin += self.xrange*60*60 | |
664 | self.data.setup() |
|
664 | self.data.setup() | |
665 | self.clear_figures() |
|
665 | self.clear_figures() | |
666 |
|
666 | |||
667 | self.__update(dataOut, tm) |
|
667 | self.__update(dataOut, tm) | |
668 |
|
668 | |||
669 | if self.isPlotConfig is False: |
|
669 | if self.isPlotConfig is False: | |
670 | self.__setup_plot() |
|
670 | self.__setup_plot() | |
671 | self.isPlotConfig = True |
|
671 | self.isPlotConfig = True | |
672 | if self.xaxis == 'time': |
|
672 | if self.xaxis == 'time': | |
673 | dt = self.getDateTime(tm) |
|
673 | dt = self.getDateTime(tm) | |
674 | if self.xmin is None: |
|
674 | if self.xmin is None: | |
675 | self.tmin = tm |
|
675 | self.tmin = tm | |
676 | self.xmin = dt.hour |
|
676 | self.xmin = dt.hour | |
677 | minutes = (self.xmin-int(self.xmin)) * 60 |
|
677 | minutes = (self.xmin-int(self.xmin)) * 60 | |
678 | seconds = (minutes - int(minutes)) * 60 |
|
678 | seconds = (minutes - int(minutes)) * 60 | |
679 | self.tmin = (dt.replace(hour=int(self.xmin), minute=int(minutes), second=int(seconds)) - |
|
679 | self.tmin = (dt.replace(hour=int(self.xmin), minute=int(minutes), second=int(seconds)) - | |
680 | datetime.datetime(1970, 1, 1)).total_seconds() |
|
680 | datetime.datetime(1970, 1, 1)).total_seconds() | |
681 | if self.localtime: |
|
681 | if self.localtime: | |
682 | self.tmin += time.timezone |
|
682 | self.tmin += time.timezone | |
683 |
|
683 | |||
684 | if self.xmin is not None and self.xmax is not None: |
|
684 | if self.xmin is not None and self.xmax is not None: | |
685 | self.xrange = self.xmax - self.xmin |
|
685 | self.xrange = self.xmax - self.xmin | |
686 |
|
686 | |||
687 | if self.throttle == 0: |
|
687 | if self.throttle == 0: | |
688 | self.__plot() |
|
688 | self.__plot() | |
689 | else: |
|
689 | else: | |
690 | self.__throttle_plot(self.__plot)#, coerce=coerce) |
|
690 | self.__throttle_plot(self.__plot)#, coerce=coerce) | |
691 |
|
691 | |||
692 | def close(self): |
|
692 | def close(self): | |
693 |
|
693 | |||
694 | if self.data and not self.data.flagNoData: |
|
694 | if self.data and not self.data.flagNoData: | |
695 | self.save_time = 0 |
|
695 | self.save_time = 0 | |
696 | self.__plot() |
|
696 | self.__plot() | |
697 | if self.data and not self.data.flagNoData and self.pause: |
|
697 | if self.data and not self.data.flagNoData and self.pause: | |
698 | figpause(10) |
|
698 | figpause(10) |
@@ -1,1315 +1,1341 | |||||
1 | # Copyright (c) 2012-2021 Jicamarca Radio Observatory |
|
1 | # Copyright (c) 2012-2021 Jicamarca Radio Observatory | |
2 | # All rights reserved. |
|
2 | # All rights reserved. | |
3 | # |
|
3 | # | |
4 | # Distributed under the terms of the BSD 3-clause license. |
|
4 | # Distributed under the terms of the BSD 3-clause license. | |
5 | """Classes to plot Spectra data |
|
5 | """Classes to plot Spectra data | |
6 |
|
6 | |||
7 | """ |
|
7 | """ | |
8 |
|
8 | |||
9 | import os |
|
9 | import os | |
10 | import numpy |
|
10 | import numpy | |
|
11 | import collections.abc | |||
11 |
|
12 | |||
12 | from schainpy.model.graphics.jroplot_base import Plot, plt, log |
|
13 | from schainpy.model.graphics.jroplot_base import Plot, plt, log | |
13 |
|
14 | |||
14 | class SpectraPlot(Plot): |
|
15 | class SpectraPlot(Plot): | |
15 | ''' |
|
16 | ''' | |
16 | Plot for Spectra data |
|
17 | Plot for Spectra data | |
17 | ''' |
|
18 | ''' | |
18 |
|
19 | |||
19 | CODE = 'spc' |
|
20 | CODE = 'spc' | |
20 | colormap = 'jet' |
|
21 | colormap = 'jet' | |
21 | plot_type = 'pcolor' |
|
22 | plot_type = 'pcolor' | |
22 | buffering = False |
|
23 | buffering = False | |
23 |
|
24 | |||
24 | def setup(self): |
|
25 | def setup(self): | |
25 |
|
26 | |||
26 | self.nplots = len(self.data.channels) |
|
27 | self.nplots = len(self.data.channels) | |
27 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
28 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) | |
28 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
29 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
29 | self.height = 2.6 * self.nrows |
|
30 | self.height = 2.6 * self.nrows | |
30 | self.cb_label = 'dB' |
|
31 | self.cb_label = 'dB' | |
31 | if self.showprofile: |
|
32 | if self.showprofile: | |
32 | self.width = 4 * self.ncols |
|
33 | self.width = 4 * self.ncols | |
33 | else: |
|
34 | else: | |
34 | self.width = 3.5 * self.ncols |
|
35 | self.width = 3.5 * self.ncols | |
35 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
36 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
36 | self.ylabel = 'Range [km]' |
|
37 | self.ylabel = 'Range [km]' | |
37 |
|
38 | |||
38 | def update(self, dataOut): |
|
39 | def update(self, dataOut): | |
39 |
|
40 | |||
40 | data = {} |
|
41 | data = {} | |
41 | meta = {} |
|
42 | meta = {} | |
42 |
|
43 | |||
43 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) |
|
44 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) | |
44 | #print("Spc: ",spc[0]) |
|
45 | #print("Spc: ",spc[0]) | |
45 | #exit(1) |
|
46 | #exit(1) | |
46 | data['spc'] = spc |
|
47 | data['spc'] = spc | |
47 | data['rti'] = dataOut.getPower() |
|
48 | data['rti'] = dataOut.getPower() | |
48 | #print(data['rti'][0]) |
|
49 | #print(data['rti'][0]) | |
49 | #exit(1) |
|
50 | #exit(1) | |
50 | #print("NormFactor: ",dataOut.normFactor) |
|
51 | #print("NormFactor: ",dataOut.normFactor) | |
51 | #data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
52 | #data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
52 | if hasattr(dataOut, 'LagPlot'): #Double Pulse |
|
53 | if hasattr(dataOut, 'LagPlot'): #Double Pulse | |
53 | max_hei_id = dataOut.nHeights - 2*dataOut.LagPlot |
|
54 | max_hei_id = dataOut.nHeights - 2*dataOut.LagPlot | |
54 | #data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=46,ymax_index=max_hei_id)/dataOut.normFactor) |
|
55 | #data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=46,ymax_index=max_hei_id)/dataOut.normFactor) | |
55 | #data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=40,ymax_index=max_hei_id)/dataOut.normFactor) |
|
56 | #data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=40,ymax_index=max_hei_id)/dataOut.normFactor) | |
56 | data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=53,ymax_index=max_hei_id)/dataOut.normFactor) |
|
57 | data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=53,ymax_index=max_hei_id)/dataOut.normFactor) | |
57 | data['noise'][0] = 10*numpy.log10(dataOut.getNoise(ymin_index=53)[0]/dataOut.normFactor) |
|
58 | data['noise'][0] = 10*numpy.log10(dataOut.getNoise(ymin_index=53)[0]/dataOut.normFactor) | |
58 | #data['noise'][1] = 22.035507 |
|
59 | #data['noise'][1] = 22.035507 | |
59 | else: |
|
60 | else: | |
60 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
61 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
61 | #data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=26,ymax_index=44)/dataOut.normFactor) |
|
62 | #data['noise'] = 10*numpy.log10(dataOut.getNoise(ymin_index=26,ymax_index=44)/dataOut.normFactor) | |
62 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
63 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
63 |
|
64 | |||
64 | if self.CODE == 'spc_moments': |
|
65 | if self.CODE == 'spc_moments': | |
65 | data['moments'] = dataOut.moments |
|
66 | data['moments'] = dataOut.moments | |
66 | if self.CODE == 'gaussian_fit': |
|
67 | if self.CODE == 'gaussian_fit': | |
67 | data['gaussfit'] = dataOut.DGauFitParams |
|
68 | data['gaussfit'] = dataOut.DGauFitParams | |
68 |
|
69 | |||
69 | return data, meta |
|
70 | return data, meta | |
70 |
|
71 | |||
71 | def plot(self): |
|
72 | def plot(self): | |
72 |
|
73 | |||
73 | if self.xaxis == "frequency": |
|
74 | if self.xaxis == "frequency": | |
74 | x = self.data.xrange[0] |
|
75 | x = self.data.xrange[0] | |
75 | self.xlabel = "Frequency (kHz)" |
|
76 | self.xlabel = "Frequency (kHz)" | |
76 | elif self.xaxis == "time": |
|
77 | elif self.xaxis == "time": | |
77 | x = self.data.xrange[1] |
|
78 | x = self.data.xrange[1] | |
78 | self.xlabel = "Time (ms)" |
|
79 | self.xlabel = "Time (ms)" | |
79 | else: |
|
80 | else: | |
80 | x = self.data.xrange[2] |
|
81 | x = self.data.xrange[2] | |
81 | self.xlabel = "Velocity (m/s)" |
|
82 | self.xlabel = "Velocity (m/s)" | |
82 |
|
83 | |||
83 | if (self.CODE == 'spc_moments') | (self.CODE == 'gaussian_fit'): |
|
84 | if (self.CODE == 'spc_moments') | (self.CODE == 'gaussian_fit'): | |
84 | x = self.data.xrange[2] |
|
85 | x = self.data.xrange[2] | |
85 | self.xlabel = "Velocity (m/s)" |
|
86 | self.xlabel = "Velocity (m/s)" | |
86 |
|
87 | |||
87 | self.titles = [] |
|
88 | self.titles = [] | |
88 |
|
89 | |||
89 | y = self.data.yrange |
|
90 | y = self.data.yrange | |
90 | self.y = y |
|
91 | self.y = y | |
91 |
|
92 | |||
92 | data = self.data[-1] |
|
93 | data = self.data[-1] | |
93 | z = data['spc'] |
|
94 | z = data['spc'] | |
94 |
|
95 | |||
95 | self.CODE2 = 'spc_oblique' |
|
96 | self.CODE2 = 'spc_oblique' | |
96 |
|
97 | |||
|
98 | if not isinstance(self.zmin, collections.abc.Sequence): | |||
|
99 | if not self.zmin: | |||
|
100 | self.zmin = [numpy.min(self.z)]*len(self.axes) | |||
|
101 | else: | |||
|
102 | self.zmin = [self.zmin]*len(self.axes) | |||
|
103 | ||||
|
104 | if not isinstance(self.zmax, collections.abc.Sequence): | |||
|
105 | if not self.zmax: | |||
|
106 | self.zmax = [numpy.max(self.z)]*len(self.axes) | |||
|
107 | else: | |||
|
108 | self.zmax = [self.zmax]*len(self.axes) | |||
97 |
|
109 | |||
98 | for n, ax in enumerate(self.axes): |
|
110 | for n, ax in enumerate(self.axes): | |
99 | noise = data['noise'][n] |
|
111 | noise = data['noise'][n] | |
100 | if self.CODE == 'spc_moments': |
|
112 | if self.CODE == 'spc_moments': | |
101 | mean = data['moments'][n, 1] |
|
113 | mean = data['moments'][n, 1] | |
102 | if self.CODE == 'gaussian_fit': |
|
114 | if self.CODE == 'gaussian_fit': | |
103 | gau0 = data['gaussfit'][n][2,:,0] |
|
115 | gau0 = data['gaussfit'][n][2,:,0] | |
104 | gau1 = data['gaussfit'][n][2,:,1] |
|
116 | gau1 = data['gaussfit'][n][2,:,1] | |
105 | if ax.firsttime: |
|
117 | if ax.firsttime: | |
106 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
118 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
107 | self.xmin = self.xmin if self.xmin else numpy.nanmin(x)#-self.xmax |
|
119 | self.xmin = self.xmin if self.xmin else numpy.nanmin(x)#-self.xmax | |
108 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) |
|
120 | #self.zmin = self.zmin if self.zmin else numpy.nanmin(z) | |
109 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) |
|
121 | #self.zmax = self.zmax if self.zmax else numpy.nanmax(z) | |
110 |
|
122 | |||
111 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
123 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
112 | vmin=self.zmin, |
|
124 | vmin=self.zmin[n], | |
113 | vmax=self.zmax, |
|
125 | vmax=self.zmax[n], | |
114 | cmap=plt.get_cmap(self.colormap), |
|
126 | cmap=plt.get_cmap(self.colormap), | |
115 | ) |
|
127 | ) | |
116 |
|
128 | |||
117 | if self.showprofile: |
|
129 | if self.showprofile: | |
118 | ax.plt_profile = self.pf_axes[n].plot( |
|
130 | ax.plt_profile = self.pf_axes[n].plot( | |
119 | data['rti'][n], y)[0] |
|
131 | data['rti'][n], y)[0] | |
120 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, |
|
132 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, | |
121 | color="k", linestyle="dashed", lw=1)[0] |
|
133 | color="k", linestyle="dashed", lw=1)[0] | |
122 | if self.CODE == 'spc_moments': |
|
134 | if self.CODE == 'spc_moments': | |
123 | ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0] |
|
135 | ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0] | |
124 | if self.CODE == 'gaussian_fit': |
|
136 | if self.CODE == 'gaussian_fit': | |
125 | ax.plt_gau0 = ax.plot(gau0, y, color='r', lw=1)[0] |
|
137 | ax.plt_gau0 = ax.plot(gau0, y, color='r', lw=1)[0] | |
126 | ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0] |
|
138 | ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0] | |
127 | else: |
|
139 | else: | |
128 | ax.plt.set_array(z[n].T.ravel()) |
|
140 | ax.plt.set_array(z[n].T.ravel()) | |
129 | if self.showprofile: |
|
141 | if self.showprofile: | |
130 | ax.plt_profile.set_data(data['rti'][n], y) |
|
142 | ax.plt_profile.set_data(data['rti'][n], y) | |
131 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) |
|
143 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) | |
132 | if self.CODE == 'spc_moments': |
|
144 | if self.CODE == 'spc_moments': | |
133 | ax.plt_mean.set_data(mean, y) |
|
145 | ax.plt_mean.set_data(mean, y) | |
134 | if self.CODE == 'gaussian_fit': |
|
146 | if self.CODE == 'gaussian_fit': | |
135 | ax.plt_gau0.set_data(gau0, y) |
|
147 | ax.plt_gau0.set_data(gau0, y) | |
136 | ax.plt_gau1.set_data(gau1, y) |
|
148 | ax.plt_gau1.set_data(gau1, y) | |
137 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
149 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) | |
138 |
|
150 | |||
139 | class SpectraObliquePlot(Plot): |
|
151 | class SpectraObliquePlot(Plot): | |
140 | ''' |
|
152 | ''' | |
141 | Plot for Spectra data |
|
153 | Plot for Spectra data | |
142 | ''' |
|
154 | ''' | |
143 |
|
155 | |||
144 | CODE = 'spc_oblique' |
|
156 | CODE = 'spc_oblique' | |
145 | colormap = 'jet' |
|
157 | colormap = 'jet' | |
146 | plot_type = 'pcolor' |
|
158 | plot_type = 'pcolor' | |
147 |
|
159 | |||
148 | def setup(self): |
|
160 | def setup(self): | |
149 | self.xaxis = "oblique" |
|
161 | self.xaxis = "oblique" | |
150 | self.nplots = len(self.data.channels) |
|
162 | self.nplots = len(self.data.channels) | |
151 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
163 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) | |
152 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
164 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
153 | self.height = 2.6 * self.nrows |
|
165 | self.height = 2.6 * self.nrows | |
154 | self.cb_label = 'dB' |
|
166 | self.cb_label = 'dB' | |
155 | if self.showprofile: |
|
167 | if self.showprofile: | |
156 | self.width = 4 * self.ncols |
|
168 | self.width = 4 * self.ncols | |
157 | else: |
|
169 | else: | |
158 | self.width = 3.5 * self.ncols |
|
170 | self.width = 3.5 * self.ncols | |
159 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
171 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
160 | self.ylabel = 'Range [km]' |
|
172 | self.ylabel = 'Range [km]' | |
161 |
|
173 | |||
162 | def update(self, dataOut): |
|
174 | def update(self, dataOut): | |
163 |
|
175 | |||
164 | data = {} |
|
176 | data = {} | |
165 | meta = {} |
|
177 | meta = {} | |
166 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) |
|
178 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) | |
167 | data['spc'] = spc |
|
179 | data['spc'] = spc | |
168 | data['rti'] = dataOut.getPower() |
|
180 | data['rti'] = dataOut.getPower() | |
169 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
181 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
170 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
182 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
171 | ''' |
|
183 | ''' | |
172 | data['shift1'] = dataOut.Oblique_params[0,-2,:] |
|
184 | data['shift1'] = dataOut.Oblique_params[0,-2,:] | |
173 | data['shift2'] = dataOut.Oblique_params[0,-1,:] |
|
185 | data['shift2'] = dataOut.Oblique_params[0,-1,:] | |
174 | data['shift1_error'] = dataOut.Oblique_param_errors[0,-2,:] |
|
186 | data['shift1_error'] = dataOut.Oblique_param_errors[0,-2,:] | |
175 | data['shift2_error'] = dataOut.Oblique_param_errors[0,-1,:] |
|
187 | data['shift2_error'] = dataOut.Oblique_param_errors[0,-1,:] | |
176 | ''' |
|
188 | ''' | |
177 | ''' |
|
189 | ''' | |
178 | data['shift1'] = dataOut.Oblique_params[0,1,:] |
|
190 | data['shift1'] = dataOut.Oblique_params[0,1,:] | |
179 | data['shift2'] = dataOut.Oblique_params[0,4,:] |
|
191 | data['shift2'] = dataOut.Oblique_params[0,4,:] | |
180 | data['shift1_error'] = dataOut.Oblique_param_errors[0,1,:] |
|
192 | data['shift1_error'] = dataOut.Oblique_param_errors[0,1,:] | |
181 | data['shift2_error'] = dataOut.Oblique_param_errors[0,4,:] |
|
193 | data['shift2_error'] = dataOut.Oblique_param_errors[0,4,:] | |
182 | ''' |
|
194 | ''' | |
183 | data['shift1'] = dataOut.Dop_EEJ_T1[0] |
|
195 | data['shift1'] = dataOut.Dop_EEJ_T1[0] | |
184 | data['shift2'] = dataOut.Dop_EEJ_T2[0] |
|
196 | data['shift2'] = dataOut.Dop_EEJ_T2[0] | |
185 | data['shift1_error'] = dataOut.Err_Dop_EEJ_T1[0] |
|
197 | data['shift1_error'] = dataOut.Err_Dop_EEJ_T1[0] | |
186 | data['shift2_error'] = dataOut.Err_Dop_EEJ_T2[0] |
|
198 | data['shift2_error'] = dataOut.Err_Dop_EEJ_T2[0] | |
187 |
|
199 | |||
188 | return data, meta |
|
200 | return data, meta | |
189 |
|
201 | |||
190 | def plot(self): |
|
202 | def plot(self): | |
191 |
|
203 | |||
192 | if self.xaxis == "frequency": |
|
204 | if self.xaxis == "frequency": | |
193 | x = self.data.xrange[0] |
|
205 | x = self.data.xrange[0] | |
194 | self.xlabel = "Frequency (kHz)" |
|
206 | self.xlabel = "Frequency (kHz)" | |
195 | elif self.xaxis == "time": |
|
207 | elif self.xaxis == "time": | |
196 | x = self.data.xrange[1] |
|
208 | x = self.data.xrange[1] | |
197 | self.xlabel = "Time (ms)" |
|
209 | self.xlabel = "Time (ms)" | |
198 | else: |
|
210 | else: | |
199 | x = self.data.xrange[2] |
|
211 | x = self.data.xrange[2] | |
200 | self.xlabel = "Velocity (m/s)" |
|
212 | self.xlabel = "Velocity (m/s)" | |
201 |
|
213 | |||
202 | self.titles = [] |
|
214 | self.titles = [] | |
203 |
|
215 | |||
204 | y = self.data.yrange |
|
216 | y = self.data.yrange | |
205 | self.y = y |
|
217 | self.y = y | |
206 |
|
218 | |||
207 | data = self.data[-1] |
|
219 | data = self.data[-1] | |
208 | z = data['spc'] |
|
220 | z = data['spc'] | |
209 |
|
221 | |||
210 | for n, ax in enumerate(self.axes): |
|
222 | for n, ax in enumerate(self.axes): | |
211 | noise = self.data['noise'][n][-1] |
|
223 | noise = self.data['noise'][n][-1] | |
212 | shift1 = data['shift1'] |
|
224 | shift1 = data['shift1'] | |
213 | #print(shift1) |
|
225 | #print(shift1) | |
214 | shift2 = data['shift2'] |
|
226 | shift2 = data['shift2'] | |
215 | err1 = data['shift1_error'] |
|
227 | err1 = data['shift1_error'] | |
216 | err2 = data['shift2_error'] |
|
228 | err2 = data['shift2_error'] | |
217 | if ax.firsttime: |
|
229 | if ax.firsttime: | |
218 |
|
230 | |||
219 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
231 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
220 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
232 | self.xmin = self.xmin if self.xmin else -self.xmax | |
221 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) |
|
233 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) | |
222 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) |
|
234 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) | |
223 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
235 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
224 | vmin=self.zmin, |
|
236 | vmin=self.zmin, | |
225 | vmax=self.zmax, |
|
237 | vmax=self.zmax, | |
226 | cmap=plt.get_cmap(self.colormap) |
|
238 | cmap=plt.get_cmap(self.colormap) | |
227 | ) |
|
239 | ) | |
228 |
|
240 | |||
229 | if self.showprofile: |
|
241 | if self.showprofile: | |
230 | ax.plt_profile = self.pf_axes[n].plot( |
|
242 | ax.plt_profile = self.pf_axes[n].plot( | |
231 | self.data['rti'][n][-1], y)[0] |
|
243 | self.data['rti'][n][-1], y)[0] | |
232 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, |
|
244 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, | |
233 | color="k", linestyle="dashed", lw=1)[0] |
|
245 | color="k", linestyle="dashed", lw=1)[0] | |
234 |
|
246 | |||
235 | self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=2.2, marker='o', linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) |
|
247 | self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=2.2, marker='o', linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) | |
236 | self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) |
|
248 | self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) | |
237 | #print("plotter1: ", self.ploterr1,shift1) |
|
249 | #print("plotter1: ", self.ploterr1,shift1) | |
238 |
|
250 | |||
239 | else: |
|
251 | else: | |
240 | #print("else plotter1: ", self.ploterr1,shift1) |
|
252 | #print("else plotter1: ", self.ploterr1,shift1) | |
241 | self.ploterr1.remove() |
|
253 | self.ploterr1.remove() | |
242 | self.ploterr2.remove() |
|
254 | self.ploterr2.remove() | |
243 | ax.plt.set_array(z[n].T.ravel()) |
|
255 | ax.plt.set_array(z[n].T.ravel()) | |
244 | if self.showprofile: |
|
256 | if self.showprofile: | |
245 | ax.plt_profile.set_data(self.data['rti'][n][-1], y) |
|
257 | ax.plt_profile.set_data(self.data['rti'][n][-1], y) | |
246 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) |
|
258 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) | |
247 | self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=2.2, marker='o', linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) |
|
259 | self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=2.2, marker='o', linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) | |
248 | self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) |
|
260 | self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=2.2,marker='o',linestyle='None',markersize=2.5,capsize=0.3,markeredgewidth=0.2) | |
249 |
|
261 | |||
250 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
262 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) | |
251 |
|
263 | |||
252 |
|
264 | |||
253 | class CrossSpectraPlot(Plot): |
|
265 | class CrossSpectraPlot(Plot): | |
254 |
|
266 | |||
255 | CODE = 'cspc' |
|
267 | CODE = 'cspc' | |
256 | colormap = 'jet' |
|
268 | colormap = 'jet' | |
257 | plot_type = 'pcolor' |
|
269 | plot_type = 'pcolor' | |
258 | zmin_coh = None |
|
270 | zmin_coh = None | |
259 | zmax_coh = None |
|
271 | zmax_coh = None | |
260 | zmin_phase = None |
|
272 | zmin_phase = None | |
261 | zmax_phase = None |
|
273 | zmax_phase = None | |
262 |
|
274 | |||
263 | def setup(self): |
|
275 | def setup(self): | |
264 |
|
276 | |||
265 | self.ncols = 4 |
|
277 | self.ncols = 4 | |
266 | self.nplots = len(self.data.pairs) * 2 |
|
278 | self.nplots = len(self.data.pairs) * 2 | |
267 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
279 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
268 | self.width = 3.1 * self.ncols |
|
280 | self.width = 3.1 * self.ncols | |
269 | self.height = 5 * self.nrows |
|
281 | self.height = 5 * self.nrows | |
270 | self.ylabel = 'Range [km]' |
|
282 | self.ylabel = 'Range [km]' | |
271 | self.showprofile = False |
|
283 | self.showprofile = False | |
272 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
284 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
273 |
|
285 | |||
274 | def update(self, dataOut): |
|
286 | def update(self, dataOut): | |
275 |
|
287 | |||
276 | data = {} |
|
288 | data = {} | |
277 | meta = {} |
|
289 | meta = {} | |
278 |
|
290 | |||
279 | spc = dataOut.data_spc |
|
291 | spc = dataOut.data_spc | |
280 | cspc = dataOut.data_cspc |
|
292 | cspc = dataOut.data_cspc | |
281 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
293 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
282 | meta['pairs'] = dataOut.pairsList |
|
294 | meta['pairs'] = dataOut.pairsList | |
283 |
|
295 | |||
284 | tmp = [] |
|
296 | tmp = [] | |
285 |
|
297 | |||
286 | for n, pair in enumerate(meta['pairs']): |
|
298 | for n, pair in enumerate(meta['pairs']): | |
287 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
299 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) | |
288 | coh = numpy.abs(out) |
|
300 | coh = numpy.abs(out) | |
289 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
301 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi | |
290 | tmp.append(coh) |
|
302 | tmp.append(coh) | |
291 | tmp.append(phase) |
|
303 | tmp.append(phase) | |
292 |
|
304 | |||
293 | data['cspc'] = numpy.array(tmp) |
|
305 | data['cspc'] = numpy.array(tmp) | |
294 |
|
306 | |||
295 | return data, meta |
|
307 | return data, meta | |
296 |
|
308 | |||
297 | def plot(self): |
|
309 | def plot(self): | |
298 |
|
310 | |||
299 | if self.xaxis == "frequency": |
|
311 | if self.xaxis == "frequency": | |
300 | x = self.data.xrange[0] |
|
312 | x = self.data.xrange[0] | |
301 | self.xlabel = "Frequency (kHz)" |
|
313 | self.xlabel = "Frequency (kHz)" | |
302 | elif self.xaxis == "time": |
|
314 | elif self.xaxis == "time": | |
303 | x = self.data.xrange[1] |
|
315 | x = self.data.xrange[1] | |
304 | self.xlabel = "Time (ms)" |
|
316 | self.xlabel = "Time (ms)" | |
305 | else: |
|
317 | else: | |
306 | x = self.data.xrange[2] |
|
318 | x = self.data.xrange[2] | |
307 | self.xlabel = "Velocity (m/s)" |
|
319 | self.xlabel = "Velocity (m/s)" | |
308 |
|
320 | |||
309 | self.titles = [] |
|
321 | self.titles = [] | |
310 |
|
322 | |||
311 | y = self.data.yrange |
|
323 | y = self.data.yrange | |
312 | self.y = y |
|
324 | self.y = y | |
313 |
|
325 | |||
314 | data = self.data[-1] |
|
326 | data = self.data[-1] | |
315 | cspc = data['cspc'] |
|
327 | cspc = data['cspc'] | |
316 |
|
328 | |||
317 | for n in range(len(self.data.pairs)): |
|
329 | for n in range(len(self.data.pairs)): | |
318 | pair = self.data.pairs[n] |
|
330 | pair = self.data.pairs[n] | |
319 | coh = cspc[n*2] |
|
331 | coh = cspc[n*2] | |
320 | phase = cspc[n*2+1] |
|
332 | phase = cspc[n*2+1] | |
321 | ax = self.axes[2 * n] |
|
333 | ax = self.axes[2 * n] | |
322 | if ax.firsttime: |
|
334 | if ax.firsttime: | |
323 | ax.plt = ax.pcolormesh(x, y, coh.T, |
|
335 | ax.plt = ax.pcolormesh(x, y, coh.T, | |
324 | vmin=0, |
|
336 | vmin=0, | |
325 | vmax=1, |
|
337 | vmax=1, | |
326 | cmap=plt.get_cmap(self.colormap_coh) |
|
338 | cmap=plt.get_cmap(self.colormap_coh) | |
327 | ) |
|
339 | ) | |
328 | else: |
|
340 | else: | |
329 | ax.plt.set_array(coh.T.ravel()) |
|
341 | ax.plt.set_array(coh.T.ravel()) | |
330 | self.titles.append( |
|
342 | self.titles.append( | |
331 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
343 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) | |
332 |
|
344 | |||
333 | ax = self.axes[2 * n + 1] |
|
345 | ax = self.axes[2 * n + 1] | |
334 | if ax.firsttime: |
|
346 | if ax.firsttime: | |
335 | ax.plt = ax.pcolormesh(x, y, phase.T, |
|
347 | ax.plt = ax.pcolormesh(x, y, phase.T, | |
336 | vmin=-180, |
|
348 | vmin=-180, | |
337 | vmax=180, |
|
349 | vmax=180, | |
338 | cmap=plt.get_cmap(self.colormap_phase) |
|
350 | cmap=plt.get_cmap(self.colormap_phase) | |
339 | ) |
|
351 | ) | |
340 | else: |
|
352 | else: | |
341 | ax.plt.set_array(phase.T.ravel()) |
|
353 | ax.plt.set_array(phase.T.ravel()) | |
342 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) |
|
354 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) | |
343 |
|
355 | |||
344 |
|
356 | |||
345 | class CrossSpectra4Plot(Plot): |
|
357 | class CrossSpectra4Plot(Plot): | |
346 |
|
358 | |||
347 | CODE = 'cspc' |
|
359 | CODE = 'cspc' | |
348 | colormap = 'jet' |
|
360 | colormap = 'jet' | |
349 | plot_type = 'pcolor' |
|
361 | plot_type = 'pcolor' | |
350 | zmin_coh = None |
|
362 | zmin_coh = None | |
351 | zmax_coh = None |
|
363 | zmax_coh = None | |
352 | zmin_phase = None |
|
364 | zmin_phase = None | |
353 | zmax_phase = None |
|
365 | zmax_phase = None | |
354 |
|
366 | |||
355 | def setup(self): |
|
367 | def setup(self): | |
356 |
|
368 | |||
357 | self.ncols = 4 |
|
369 | self.ncols = 4 | |
358 | self.nrows = len(self.data.pairs) |
|
370 | self.nrows = len(self.data.pairs) | |
359 | self.nplots = self.nrows * 4 |
|
371 | self.nplots = self.nrows * 4 | |
360 | self.width = 3.1 * self.ncols |
|
372 | self.width = 3.1 * self.ncols | |
361 | self.height = 5 * self.nrows |
|
373 | self.height = 5 * self.nrows | |
362 | self.ylabel = 'Range [km]' |
|
374 | self.ylabel = 'Range [km]' | |
363 | self.showprofile = False |
|
375 | self.showprofile = False | |
364 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
376 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
365 |
|
377 | |||
366 | def plot(self): |
|
378 | def plot(self): | |
367 |
|
379 | |||
368 | if self.xaxis == "frequency": |
|
380 | if self.xaxis == "frequency": | |
369 | x = self.data.xrange[0] |
|
381 | x = self.data.xrange[0] | |
370 | self.xlabel = "Frequency (kHz)" |
|
382 | self.xlabel = "Frequency (kHz)" | |
371 | elif self.xaxis == "time": |
|
383 | elif self.xaxis == "time": | |
372 | x = self.data.xrange[1] |
|
384 | x = self.data.xrange[1] | |
373 | self.xlabel = "Time (ms)" |
|
385 | self.xlabel = "Time (ms)" | |
374 | else: |
|
386 | else: | |
375 | x = self.data.xrange[2] |
|
387 | x = self.data.xrange[2] | |
376 | self.xlabel = "Velocity (m/s)" |
|
388 | self.xlabel = "Velocity (m/s)" | |
377 |
|
389 | |||
378 | self.titles = [] |
|
390 | self.titles = [] | |
379 |
|
391 | |||
380 |
|
392 | |||
381 | y = self.data.heights |
|
393 | y = self.data.heights | |
382 | self.y = y |
|
394 | self.y = y | |
383 | nspc = self.data['spc'] |
|
395 | nspc = self.data['spc'] | |
384 | #print(numpy.shape(self.data['spc'])) |
|
396 | #print(numpy.shape(self.data['spc'])) | |
385 | spc = self.data['cspc'][0] |
|
397 | spc = self.data['cspc'][0] | |
386 | #print(numpy.shape(nspc)) |
|
398 | #print(numpy.shape(nspc)) | |
387 | #exit() |
|
399 | #exit() | |
388 | #nspc[1,:,:] = numpy.flip(nspc[1,:,:],axis=0) |
|
400 | #nspc[1,:,:] = numpy.flip(nspc[1,:,:],axis=0) | |
389 | #print(numpy.shape(spc)) |
|
401 | #print(numpy.shape(spc)) | |
390 | #exit() |
|
402 | #exit() | |
391 | cspc = self.data['cspc'][1] |
|
403 | cspc = self.data['cspc'][1] | |
392 |
|
404 | |||
393 | #xflip=numpy.flip(x) |
|
405 | #xflip=numpy.flip(x) | |
394 | #print(numpy.shape(cspc)) |
|
406 | #print(numpy.shape(cspc)) | |
395 | #exit() |
|
407 | #exit() | |
396 |
|
408 | |||
397 | for n in range(self.nrows): |
|
409 | for n in range(self.nrows): | |
398 | noise = self.data['noise'][:,-1] |
|
410 | noise = self.data['noise'][:,-1] | |
399 | pair = self.data.pairs[n] |
|
411 | pair = self.data.pairs[n] | |
400 | #print(pair) |
|
412 | #print(pair) | |
401 | #exit() |
|
413 | #exit() | |
402 | ax = self.axes[4 * n] |
|
414 | ax = self.axes[4 * n] | |
403 | if ax.firsttime: |
|
415 | if ax.firsttime: | |
404 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
416 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
405 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
417 | self.xmin = self.xmin if self.xmin else -self.xmax | |
406 | self.zmin = self.zmin if self.zmin else numpy.nanmin(nspc) |
|
418 | self.zmin = self.zmin if self.zmin else numpy.nanmin(nspc) | |
407 | self.zmax = self.zmax if self.zmax else numpy.nanmax(nspc) |
|
419 | self.zmax = self.zmax if self.zmax else numpy.nanmax(nspc) | |
408 | ax.plt = ax.pcolormesh(x , y , nspc[pair[0]].T, |
|
420 | ax.plt = ax.pcolormesh(x , y , nspc[pair[0]].T, | |
409 | vmin=self.zmin, |
|
421 | vmin=self.zmin, | |
410 | vmax=self.zmax, |
|
422 | vmax=self.zmax, | |
411 | cmap=plt.get_cmap(self.colormap) |
|
423 | cmap=plt.get_cmap(self.colormap) | |
412 | ) |
|
424 | ) | |
413 | else: |
|
425 | else: | |
414 | #print(numpy.shape(nspc[pair[0]].T)) |
|
426 | #print(numpy.shape(nspc[pair[0]].T)) | |
415 | #exit() |
|
427 | #exit() | |
416 | ax.plt.set_array(nspc[pair[0]].T.ravel()) |
|
428 | ax.plt.set_array(nspc[pair[0]].T.ravel()) | |
417 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise[pair[0]])) |
|
429 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise[pair[0]])) | |
418 |
|
430 | |||
419 | ax = self.axes[4 * n + 1] |
|
431 | ax = self.axes[4 * n + 1] | |
420 |
|
432 | |||
421 | if ax.firsttime: |
|
433 | if ax.firsttime: | |
422 | ax.plt = ax.pcolormesh(x , y, numpy.flip(nspc[pair[1]],axis=0).T, |
|
434 | ax.plt = ax.pcolormesh(x , y, numpy.flip(nspc[pair[1]],axis=0).T, | |
423 | vmin=self.zmin, |
|
435 | vmin=self.zmin, | |
424 | vmax=self.zmax, |
|
436 | vmax=self.zmax, | |
425 | cmap=plt.get_cmap(self.colormap) |
|
437 | cmap=plt.get_cmap(self.colormap) | |
426 | ) |
|
438 | ) | |
427 | else: |
|
439 | else: | |
428 |
|
440 | |||
429 | ax.plt.set_array(numpy.flip(nspc[pair[1]],axis=0).T.ravel()) |
|
441 | ax.plt.set_array(numpy.flip(nspc[pair[1]],axis=0).T.ravel()) | |
430 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise[pair[1]])) |
|
442 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise[pair[1]])) | |
431 |
|
443 | |||
432 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
444 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) | |
433 | coh = numpy.abs(out) |
|
445 | coh = numpy.abs(out) | |
434 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
446 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi | |
435 |
|
447 | |||
436 | ax = self.axes[4 * n + 2] |
|
448 | ax = self.axes[4 * n + 2] | |
437 | if ax.firsttime: |
|
449 | if ax.firsttime: | |
438 | ax.plt = ax.pcolormesh(x, y, numpy.flip(coh,axis=0).T, |
|
450 | ax.plt = ax.pcolormesh(x, y, numpy.flip(coh,axis=0).T, | |
439 | vmin=0, |
|
451 | vmin=0, | |
440 | vmax=1, |
|
452 | vmax=1, | |
441 | cmap=plt.get_cmap(self.colormap_coh) |
|
453 | cmap=plt.get_cmap(self.colormap_coh) | |
442 | ) |
|
454 | ) | |
443 | else: |
|
455 | else: | |
444 | ax.plt.set_array(numpy.flip(coh,axis=0).T.ravel()) |
|
456 | ax.plt.set_array(numpy.flip(coh,axis=0).T.ravel()) | |
445 | self.titles.append( |
|
457 | self.titles.append( | |
446 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
458 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) | |
447 |
|
459 | |||
448 | ax = self.axes[4 * n + 3] |
|
460 | ax = self.axes[4 * n + 3] | |
449 | if ax.firsttime: |
|
461 | if ax.firsttime: | |
450 | ax.plt = ax.pcolormesh(x, y, numpy.flip(phase,axis=0).T, |
|
462 | ax.plt = ax.pcolormesh(x, y, numpy.flip(phase,axis=0).T, | |
451 | vmin=-180, |
|
463 | vmin=-180, | |
452 | vmax=180, |
|
464 | vmax=180, | |
453 | cmap=plt.get_cmap(self.colormap_phase) |
|
465 | cmap=plt.get_cmap(self.colormap_phase) | |
454 | ) |
|
466 | ) | |
455 | else: |
|
467 | else: | |
456 | ax.plt.set_array(numpy.flip(phase,axis=0).T.ravel()) |
|
468 | ax.plt.set_array(numpy.flip(phase,axis=0).T.ravel()) | |
457 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) |
|
469 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) | |
458 |
|
470 | |||
459 |
|
471 | |||
460 | class CrossSpectra2Plot(Plot): |
|
472 | class CrossSpectra2Plot(Plot): | |
461 |
|
473 | |||
462 | CODE = 'cspc' |
|
474 | CODE = 'cspc' | |
463 | colormap = 'jet' |
|
475 | colormap = 'jet' | |
464 | plot_type = 'pcolor' |
|
476 | plot_type = 'pcolor' | |
465 | zmin_coh = None |
|
477 | zmin_coh = None | |
466 | zmax_coh = None |
|
478 | zmax_coh = None | |
467 | zmin_phase = None |
|
479 | zmin_phase = None | |
468 | zmax_phase = None |
|
480 | zmax_phase = None | |
469 |
|
481 | |||
470 | def setup(self): |
|
482 | def setup(self): | |
471 |
|
483 | |||
472 | self.ncols = 1 |
|
484 | self.ncols = 1 | |
473 | self.nrows = len(self.data.pairs) |
|
485 | self.nrows = len(self.data.pairs) | |
474 | self.nplots = self.nrows * 1 |
|
486 | self.nplots = self.nrows * 1 | |
475 | self.width = 3.1 * self.ncols |
|
487 | self.width = 3.1 * self.ncols | |
476 | self.height = 5 * self.nrows |
|
488 | self.height = 5 * self.nrows | |
477 | self.ylabel = 'Range [km]' |
|
489 | self.ylabel = 'Range [km]' | |
478 | self.showprofile = False |
|
490 | self.showprofile = False | |
479 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
491 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
480 |
|
492 | |||
481 | def plot(self): |
|
493 | def plot(self): | |
482 |
|
494 | |||
483 | if self.xaxis == "frequency": |
|
495 | if self.xaxis == "frequency": | |
484 | x = self.data.xrange[0] |
|
496 | x = self.data.xrange[0] | |
485 | self.xlabel = "Frequency (kHz)" |
|
497 | self.xlabel = "Frequency (kHz)" | |
486 | elif self.xaxis == "time": |
|
498 | elif self.xaxis == "time": | |
487 | x = self.data.xrange[1] |
|
499 | x = self.data.xrange[1] | |
488 | self.xlabel = "Time (ms)" |
|
500 | self.xlabel = "Time (ms)" | |
489 | else: |
|
501 | else: | |
490 | x = self.data.xrange[2] |
|
502 | x = self.data.xrange[2] | |
491 | self.xlabel = "Velocity (m/s)" |
|
503 | self.xlabel = "Velocity (m/s)" | |
492 |
|
504 | |||
493 | self.titles = [] |
|
505 | self.titles = [] | |
494 |
|
506 | |||
495 |
|
507 | |||
496 | y = self.data.heights |
|
508 | y = self.data.heights | |
497 | self.y = y |
|
509 | self.y = y | |
498 | #nspc = self.data['spc'] |
|
510 | #nspc = self.data['spc'] | |
499 | #print(numpy.shape(self.data['spc'])) |
|
511 | #print(numpy.shape(self.data['spc'])) | |
500 | #spc = self.data['cspc'][0] |
|
512 | #spc = self.data['cspc'][0] | |
501 | #print(numpy.shape(spc)) |
|
513 | #print(numpy.shape(spc)) | |
502 | #exit() |
|
514 | #exit() | |
503 | cspc = self.data['cspc'][1] |
|
515 | cspc = self.data['cspc'][1] | |
504 | #print(numpy.shape(cspc)) |
|
516 | #print(numpy.shape(cspc)) | |
505 | #exit() |
|
517 | #exit() | |
506 |
|
518 | |||
507 | for n in range(self.nrows): |
|
519 | for n in range(self.nrows): | |
508 | noise = self.data['noise'][:,-1] |
|
520 | noise = self.data['noise'][:,-1] | |
509 | pair = self.data.pairs[n] |
|
521 | pair = self.data.pairs[n] | |
510 | #print(pair) #exit() |
|
522 | #print(pair) #exit() | |
511 |
|
523 | |||
512 |
|
524 | |||
513 |
|
525 | |||
514 | out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
526 | out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) | |
515 |
|
527 | |||
516 | #print(out[:,53]) |
|
528 | #print(out[:,53]) | |
517 | #exit() |
|
529 | #exit() | |
518 | cross = numpy.abs(out) |
|
530 | cross = numpy.abs(out) | |
519 | z = cross/self.data.nFactor |
|
531 | z = cross/self.data.nFactor | |
520 | #print("here") |
|
532 | #print("here") | |
521 | #print(dataOut.data_spc[0,0,0]) |
|
533 | #print(dataOut.data_spc[0,0,0]) | |
522 | #exit() |
|
534 | #exit() | |
523 |
|
535 | |||
524 | cross = 10*numpy.log10(z) |
|
536 | cross = 10*numpy.log10(z) | |
525 | #print(numpy.shape(cross)) |
|
537 | #print(numpy.shape(cross)) | |
526 | #print(cross[0,:]) |
|
538 | #print(cross[0,:]) | |
527 | #print(self.data.nFactor) |
|
539 | #print(self.data.nFactor) | |
528 | #exit() |
|
540 | #exit() | |
529 | #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
541 | #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi | |
530 |
|
542 | |||
531 | ax = self.axes[1 * n] |
|
543 | ax = self.axes[1 * n] | |
532 | if ax.firsttime: |
|
544 | if ax.firsttime: | |
533 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
545 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
534 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
546 | self.xmin = self.xmin if self.xmin else -self.xmax | |
535 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
547 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
536 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
548 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
537 | ax.plt = ax.pcolormesh(x, y, cross.T, |
|
549 | ax.plt = ax.pcolormesh(x, y, cross.T, | |
538 | vmin=self.zmin, |
|
550 | vmin=self.zmin, | |
539 | vmax=self.zmax, |
|
551 | vmax=self.zmax, | |
540 | cmap=plt.get_cmap(self.colormap) |
|
552 | cmap=plt.get_cmap(self.colormap) | |
541 | ) |
|
553 | ) | |
542 | else: |
|
554 | else: | |
543 | ax.plt.set_array(cross.T.ravel()) |
|
555 | ax.plt.set_array(cross.T.ravel()) | |
544 | self.titles.append( |
|
556 | self.titles.append( | |
545 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
557 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) | |
546 |
|
558 | |||
547 |
|
559 | |||
548 | class CrossSpectra3Plot(Plot): |
|
560 | class CrossSpectra3Plot(Plot): | |
549 |
|
561 | |||
550 | CODE = 'cspc' |
|
562 | CODE = 'cspc' | |
551 | colormap = 'jet' |
|
563 | colormap = 'jet' | |
552 | plot_type = 'pcolor' |
|
564 | plot_type = 'pcolor' | |
553 | zmin_coh = None |
|
565 | zmin_coh = None | |
554 | zmax_coh = None |
|
566 | zmax_coh = None | |
555 | zmin_phase = None |
|
567 | zmin_phase = None | |
556 | zmax_phase = None |
|
568 | zmax_phase = None | |
557 |
|
569 | |||
558 | def setup(self): |
|
570 | def setup(self): | |
559 |
|
571 | |||
560 | self.ncols = 3 |
|
572 | self.ncols = 3 | |
561 | self.nrows = len(self.data.pairs) |
|
573 | self.nrows = len(self.data.pairs) | |
562 | self.nplots = self.nrows * 3 |
|
574 | self.nplots = self.nrows * 3 | |
563 | self.width = 3.1 * self.ncols |
|
575 | self.width = 3.1 * self.ncols | |
564 | self.height = 5 * self.nrows |
|
576 | self.height = 5 * self.nrows | |
565 | self.ylabel = 'Range [km]' |
|
577 | self.ylabel = 'Range [km]' | |
566 | self.showprofile = False |
|
578 | self.showprofile = False | |
567 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
579 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) | |
568 |
|
580 | |||
569 | def plot(self): |
|
581 | def plot(self): | |
570 |
|
582 | |||
571 | if self.xaxis == "frequency": |
|
583 | if self.xaxis == "frequency": | |
572 | x = self.data.xrange[0] |
|
584 | x = self.data.xrange[0] | |
573 | self.xlabel = "Frequency (kHz)" |
|
585 | self.xlabel = "Frequency (kHz)" | |
574 | elif self.xaxis == "time": |
|
586 | elif self.xaxis == "time": | |
575 | x = self.data.xrange[1] |
|
587 | x = self.data.xrange[1] | |
576 | self.xlabel = "Time (ms)" |
|
588 | self.xlabel = "Time (ms)" | |
577 | else: |
|
589 | else: | |
578 | x = self.data.xrange[2] |
|
590 | x = self.data.xrange[2] | |
579 | self.xlabel = "Velocity (m/s)" |
|
591 | self.xlabel = "Velocity (m/s)" | |
580 |
|
592 | |||
581 | self.titles = [] |
|
593 | self.titles = [] | |
582 |
|
594 | |||
583 |
|
595 | |||
584 | y = self.data.heights |
|
596 | y = self.data.heights | |
585 | self.y = y |
|
597 | self.y = y | |
586 | #nspc = self.data['spc'] |
|
598 | #nspc = self.data['spc'] | |
587 | #print(numpy.shape(self.data['spc'])) |
|
599 | #print(numpy.shape(self.data['spc'])) | |
588 | #spc = self.data['cspc'][0] |
|
600 | #spc = self.data['cspc'][0] | |
589 | #print(numpy.shape(spc)) |
|
601 | #print(numpy.shape(spc)) | |
590 | #exit() |
|
602 | #exit() | |
591 | cspc = self.data['cspc'][1] |
|
603 | cspc = self.data['cspc'][1] | |
592 | #print(numpy.shape(cspc)) |
|
604 | #print(numpy.shape(cspc)) | |
593 | #exit() |
|
605 | #exit() | |
594 |
|
606 | |||
595 | for n in range(self.nrows): |
|
607 | for n in range(self.nrows): | |
596 | noise = self.data['noise'][:,-1] |
|
608 | noise = self.data['noise'][:,-1] | |
597 | pair = self.data.pairs[n] |
|
609 | pair = self.data.pairs[n] | |
598 | #print(pair) #exit() |
|
610 | #print(pair) #exit() | |
599 |
|
611 | |||
600 |
|
612 | |||
601 |
|
613 | |||
602 | out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
614 | out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) | |
603 |
|
615 | |||
604 | #print(out[:,53]) |
|
616 | #print(out[:,53]) | |
605 | #exit() |
|
617 | #exit() | |
606 | cross = numpy.abs(out) |
|
618 | cross = numpy.abs(out) | |
607 | z = cross/self.data.nFactor |
|
619 | z = cross/self.data.nFactor | |
608 | cross = 10*numpy.log10(z) |
|
620 | cross = 10*numpy.log10(z) | |
609 |
|
621 | |||
610 | out_r= out.real/self.data.nFactor |
|
622 | out_r= out.real/self.data.nFactor | |
611 | #out_r = 10*numpy.log10(out_r) |
|
623 | #out_r = 10*numpy.log10(out_r) | |
612 |
|
624 | |||
613 | out_i= out.imag/self.data.nFactor |
|
625 | out_i= out.imag/self.data.nFactor | |
614 | #out_i = 10*numpy.log10(out_i) |
|
626 | #out_i = 10*numpy.log10(out_i) | |
615 | #print(numpy.shape(cross)) |
|
627 | #print(numpy.shape(cross)) | |
616 | #print(cross[0,:]) |
|
628 | #print(cross[0,:]) | |
617 | #print(self.data.nFactor) |
|
629 | #print(self.data.nFactor) | |
618 | #exit() |
|
630 | #exit() | |
619 | #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
631 | #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi | |
620 |
|
632 | |||
621 | ax = self.axes[3 * n] |
|
633 | ax = self.axes[3 * n] | |
622 | if ax.firsttime: |
|
634 | if ax.firsttime: | |
623 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
635 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
624 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
636 | self.xmin = self.xmin if self.xmin else -self.xmax | |
625 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
637 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
626 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
638 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
627 | ax.plt = ax.pcolormesh(x, y, cross.T, |
|
639 | ax.plt = ax.pcolormesh(x, y, cross.T, | |
628 | vmin=self.zmin, |
|
640 | vmin=self.zmin, | |
629 | vmax=self.zmax, |
|
641 | vmax=self.zmax, | |
630 | cmap=plt.get_cmap(self.colormap) |
|
642 | cmap=plt.get_cmap(self.colormap) | |
631 | ) |
|
643 | ) | |
632 | else: |
|
644 | else: | |
633 | ax.plt.set_array(cross.T.ravel()) |
|
645 | ax.plt.set_array(cross.T.ravel()) | |
634 | self.titles.append( |
|
646 | self.titles.append( | |
635 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
647 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) | |
636 |
|
648 | |||
637 | ax = self.axes[3 * n + 1] |
|
649 | ax = self.axes[3 * n + 1] | |
638 | if ax.firsttime: |
|
650 | if ax.firsttime: | |
639 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
651 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
640 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
652 | self.xmin = self.xmin if self.xmin else -self.xmax | |
641 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
653 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
642 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
654 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
643 | ax.plt = ax.pcolormesh(x, y, out_r.T, |
|
655 | ax.plt = ax.pcolormesh(x, y, out_r.T, | |
644 | vmin=-1.e6, |
|
656 | vmin=-1.e6, | |
645 | vmax=0, |
|
657 | vmax=0, | |
646 | cmap=plt.get_cmap(self.colormap) |
|
658 | cmap=plt.get_cmap(self.colormap) | |
647 | ) |
|
659 | ) | |
648 | else: |
|
660 | else: | |
649 | ax.plt.set_array(out_r.T.ravel()) |
|
661 | ax.plt.set_array(out_r.T.ravel()) | |
650 | self.titles.append( |
|
662 | self.titles.append( | |
651 | 'Cross Spectra Real Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
663 | 'Cross Spectra Real Ch{} * Ch{}'.format(pair[0], pair[1])) | |
652 |
|
664 | |||
653 | ax = self.axes[3 * n + 2] |
|
665 | ax = self.axes[3 * n + 2] | |
654 |
|
666 | |||
655 |
|
667 | |||
656 | if ax.firsttime: |
|
668 | if ax.firsttime: | |
657 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
669 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
658 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
670 | self.xmin = self.xmin if self.xmin else -self.xmax | |
659 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
671 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) | |
660 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
672 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) | |
661 | ax.plt = ax.pcolormesh(x, y, out_i.T, |
|
673 | ax.plt = ax.pcolormesh(x, y, out_i.T, | |
662 | vmin=-1.e6, |
|
674 | vmin=-1.e6, | |
663 | vmax=1.e6, |
|
675 | vmax=1.e6, | |
664 | cmap=plt.get_cmap(self.colormap) |
|
676 | cmap=plt.get_cmap(self.colormap) | |
665 | ) |
|
677 | ) | |
666 | else: |
|
678 | else: | |
667 | ax.plt.set_array(out_i.T.ravel()) |
|
679 | ax.plt.set_array(out_i.T.ravel()) | |
668 | self.titles.append( |
|
680 | self.titles.append( | |
669 | 'Cross Spectra Imag Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
681 | 'Cross Spectra Imag Ch{} * Ch{}'.format(pair[0], pair[1])) | |
670 |
|
682 | |||
671 | class RTIPlot(Plot): |
|
683 | class RTIPlot(Plot): | |
672 | ''' |
|
684 | ''' | |
673 | Plot for RTI data |
|
685 | Plot for RTI data | |
674 | ''' |
|
686 | ''' | |
675 |
|
687 | |||
676 | CODE = 'rti' |
|
688 | CODE = 'rti' | |
677 | colormap = 'jet' |
|
689 | colormap = 'jet' | |
678 | plot_type = 'pcolorbuffer' |
|
690 | plot_type = 'pcolorbuffer' | |
679 |
|
691 | |||
680 | def setup(self): |
|
692 | def setup(self): | |
681 | self.xaxis = 'time' |
|
693 | self.xaxis = 'time' | |
682 | self.ncols = 1 |
|
694 | self.ncols = 1 | |
683 | self.nrows = len(self.data.channels) |
|
695 | self.nrows = len(self.data.channels) | |
684 | self.nplots = len(self.data.channels) |
|
696 | self.nplots = len(self.data.channels) | |
685 | self.ylabel = 'Range [km]' |
|
697 | self.ylabel = 'Range [km]' | |
686 | self.xlabel = 'Time' |
|
698 | self.xlabel = 'Time' | |
687 | self.cb_label = 'dB' |
|
699 | self.cb_label = 'dB' | |
688 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) |
|
700 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) | |
689 | self.titles = ['{} Channel {}'.format( |
|
701 | self.titles = ['{} Channel {}'.format( | |
690 | self.CODE.upper(), x) for x in range(self.nrows)] |
|
702 | self.CODE.upper(), x) for x in range(self.nrows)] | |
691 |
|
703 | |||
692 | def update(self, dataOut): |
|
704 | def update(self, dataOut): | |
693 |
|
705 | |||
694 | data = {} |
|
706 | data = {} | |
695 | meta = {} |
|
707 | meta = {} | |
696 | data['rti'] = dataOut.getPower() |
|
708 | data['rti'] = dataOut.getPower() | |
697 | #print(numpy.shape(data['rti'])) |
|
709 | #print(numpy.shape(data['rti'])) | |
698 |
|
710 | |||
699 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
711 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
700 |
|
712 | |||
701 | return data, meta |
|
713 | return data, meta | |
702 |
|
714 | |||
703 | def plot(self): |
|
715 | def plot(self): | |
704 |
|
716 | |||
705 | self.x = self.data.times |
|
717 | self.x = self.data.times | |
706 | self.y = self.data.yrange |
|
718 | self.y = self.data.yrange | |
707 | self.z = self.data[self.CODE] |
|
719 | self.z = self.data[self.CODE] | |
708 |
|
720 | |||
709 | self.z = numpy.ma.masked_invalid(self.z) |
|
721 | self.z = numpy.ma.masked_invalid(self.z) | |
710 |
|
722 | |||
711 | if self.decimation is None: |
|
723 | if self.decimation is None: | |
712 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
724 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
713 | else: |
|
725 | else: | |
714 | x, y, z = self.fill_gaps(*self.decimate()) |
|
726 | x, y, z = self.fill_gaps(*self.decimate()) | |
715 |
|
727 | |||
|
728 | ||||
|
729 | if not isinstance(self.zmin, collections.abc.Sequence): | |||
|
730 | if not self.zmin: | |||
|
731 | self.zmin = [numpy.min(self.z)]*len(self.axes) | |||
|
732 | else: | |||
|
733 | self.zmin = [self.zmin]*len(self.axes) | |||
|
734 | ||||
|
735 | if not isinstance(self.zmax, collections.abc.Sequence): | |||
|
736 | if not self.zmax: | |||
|
737 | self.zmax = [numpy.max(self.z)]*len(self.axes) | |||
|
738 | else: | |||
|
739 | self.zmax = [self.zmax]*len(self.axes) | |||
|
740 | ||||
716 | for n, ax in enumerate(self.axes): |
|
741 | for n, ax in enumerate(self.axes): | |
717 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) |
|
742 | ||
718 |
self.zm |
|
743 | #self.zmin = self.zmin if self.zmin else numpy.min(self.z) | |
|
744 | #self.zmax = self.zmax if self.zmax else numpy.max(self.z) | |||
719 |
|
745 | |||
720 | if ax.firsttime: |
|
746 | if ax.firsttime: | |
721 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
747 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
722 | vmin=self.zmin, |
|
748 | vmin=self.zmin[n], | |
723 | vmax=self.zmax, |
|
749 | vmax=self.zmax[n], | |
724 | cmap=plt.get_cmap(self.colormap) |
|
750 | cmap=plt.get_cmap(self.colormap) | |
725 | ) |
|
751 | ) | |
726 | if self.showprofile: |
|
752 | if self.showprofile: | |
727 | ax.plot_profile = self.pf_axes[n].plot( |
|
753 | ax.plot_profile = self.pf_axes[n].plot( | |
728 | self.data['rti'][n][-1], self.y)[0] |
|
754 | self.data['rti'][n][-1], self.y)[0] | |
729 | ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y, |
|
755 | ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y, | |
730 | color="k", linestyle="dashed", lw=1)[0] |
|
756 | color="k", linestyle="dashed", lw=1)[0] | |
731 | else: |
|
757 | else: | |
732 | ax.collections.remove(ax.collections[0]) |
|
758 | ax.collections.remove(ax.collections[0]) | |
733 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
759 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
734 | vmin=self.zmin, |
|
760 | vmin=self.zmin[n], | |
735 | vmax=self.zmax, |
|
761 | vmax=self.zmax[n], | |
736 | cmap=plt.get_cmap(self.colormap) |
|
762 | cmap=plt.get_cmap(self.colormap) | |
737 | ) |
|
763 | ) | |
738 | if self.showprofile: |
|
764 | if self.showprofile: | |
739 | ax.plot_profile.set_data(self.data['rti'][n][-1], self.y) |
|
765 | ax.plot_profile.set_data(self.data['rti'][n][-1], self.y) | |
740 | ax.plot_noise.set_data(numpy.repeat( |
|
766 | ax.plot_noise.set_data(numpy.repeat( | |
741 | self.data['noise'][n][-1], len(self.y)), self.y) |
|
767 | self.data['noise'][n][-1], len(self.y)), self.y) | |
742 |
|
768 | |||
743 |
|
769 | |||
744 | class SpectrogramPlot(Plot): |
|
770 | class SpectrogramPlot(Plot): | |
745 | ''' |
|
771 | ''' | |
746 | Plot for Spectrogram data |
|
772 | Plot for Spectrogram data | |
747 | ''' |
|
773 | ''' | |
748 |
|
774 | |||
749 | CODE = 'Spectrogram_Profile' |
|
775 | CODE = 'Spectrogram_Profile' | |
750 | colormap = 'binary' |
|
776 | colormap = 'binary' | |
751 | plot_type = 'pcolorbuffer' |
|
777 | plot_type = 'pcolorbuffer' | |
752 |
|
778 | |||
753 | def setup(self): |
|
779 | def setup(self): | |
754 | self.xaxis = 'time' |
|
780 | self.xaxis = 'time' | |
755 | self.ncols = 1 |
|
781 | self.ncols = 1 | |
756 | self.nrows = len(self.data.channels) |
|
782 | self.nrows = len(self.data.channels) | |
757 | self.nplots = len(self.data.channels) |
|
783 | self.nplots = len(self.data.channels) | |
758 | self.xlabel = 'Time' |
|
784 | self.xlabel = 'Time' | |
759 | #self.cb_label = 'dB' |
|
785 | #self.cb_label = 'dB' | |
760 | self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95}) |
|
786 | self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95}) | |
761 | self.titles = [] |
|
787 | self.titles = [] | |
762 |
|
788 | |||
763 | #self.titles = ['{} Channel {} \n H = {} km ({} - {})'.format( |
|
789 | #self.titles = ['{} Channel {} \n H = {} km ({} - {})'.format( | |
764 | #self.CODE.upper(), x, self.data.heightList[self.data.hei], self.data.heightList[self.data.hei],self.data.heightList[self.data.hei]+(self.data.DH*self.data.nProfiles)) for x in range(self.nrows)] |
|
790 | #self.CODE.upper(), x, self.data.heightList[self.data.hei], self.data.heightList[self.data.hei],self.data.heightList[self.data.hei]+(self.data.DH*self.data.nProfiles)) for x in range(self.nrows)] | |
765 |
|
791 | |||
766 | self.titles = ['{} Channel {}'.format( |
|
792 | self.titles = ['{} Channel {}'.format( | |
767 | self.CODE.upper(), x) for x in range(self.nrows)] |
|
793 | self.CODE.upper(), x) for x in range(self.nrows)] | |
768 |
|
794 | |||
769 |
|
795 | |||
770 | def update(self, dataOut): |
|
796 | def update(self, dataOut): | |
771 | data = {} |
|
797 | data = {} | |
772 | meta = {} |
|
798 | meta = {} | |
773 |
|
799 | |||
774 | maxHei = 1620#+12000 |
|
800 | maxHei = 1620#+12000 | |
775 | indb = numpy.where(dataOut.heightList <= maxHei) |
|
801 | indb = numpy.where(dataOut.heightList <= maxHei) | |
776 | hei = indb[0][-1] |
|
802 | hei = indb[0][-1] | |
777 | #print(dataOut.heightList) |
|
803 | #print(dataOut.heightList) | |
778 |
|
804 | |||
779 | factor = dataOut.nIncohInt |
|
805 | factor = dataOut.nIncohInt | |
780 | z = dataOut.data_spc[:,:,hei] / factor |
|
806 | z = dataOut.data_spc[:,:,hei] / factor | |
781 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
807 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
782 | #buffer = 10 * numpy.log10(z) |
|
808 | #buffer = 10 * numpy.log10(z) | |
783 |
|
809 | |||
784 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
810 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
785 |
|
811 | |||
786 |
|
812 | |||
787 | #self.hei = hei |
|
813 | #self.hei = hei | |
788 | #self.heightList = dataOut.heightList |
|
814 | #self.heightList = dataOut.heightList | |
789 | #self.DH = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step |
|
815 | #self.DH = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step | |
790 | #self.nProfiles = dataOut.nProfiles |
|
816 | #self.nProfiles = dataOut.nProfiles | |
791 |
|
817 | |||
792 | data['Spectrogram_Profile'] = 10 * numpy.log10(z) |
|
818 | data['Spectrogram_Profile'] = 10 * numpy.log10(z) | |
793 |
|
819 | |||
794 | data['hei'] = hei |
|
820 | data['hei'] = hei | |
795 | data['DH'] = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step |
|
821 | data['DH'] = (dataOut.heightList[1] - dataOut.heightList[0])/dataOut.step | |
796 | data['nProfiles'] = dataOut.nProfiles |
|
822 | data['nProfiles'] = dataOut.nProfiles | |
797 | #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] |
|
823 | #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] | |
798 | ''' |
|
824 | ''' | |
799 | import matplotlib.pyplot as plt |
|
825 | import matplotlib.pyplot as plt | |
800 | plt.plot(10 * numpy.log10(z[0,:])) |
|
826 | plt.plot(10 * numpy.log10(z[0,:])) | |
801 | plt.show() |
|
827 | plt.show() | |
802 |
|
828 | |||
803 | from time import sleep |
|
829 | from time import sleep | |
804 | sleep(10) |
|
830 | sleep(10) | |
805 | ''' |
|
831 | ''' | |
806 | return data, meta |
|
832 | return data, meta | |
807 |
|
833 | |||
808 | def plot(self): |
|
834 | def plot(self): | |
809 |
|
835 | |||
810 | self.x = self.data.times |
|
836 | self.x = self.data.times | |
811 | self.z = self.data[self.CODE] |
|
837 | self.z = self.data[self.CODE] | |
812 | self.y = self.data.xrange[0] |
|
838 | self.y = self.data.xrange[0] | |
813 |
|
839 | |||
814 | hei = self.data['hei'][-1] |
|
840 | hei = self.data['hei'][-1] | |
815 | DH = self.data['DH'][-1] |
|
841 | DH = self.data['DH'][-1] | |
816 | nProfiles = self.data['nProfiles'][-1] |
|
842 | nProfiles = self.data['nProfiles'][-1] | |
817 |
|
843 | |||
818 | self.ylabel = "Frequency (kHz)" |
|
844 | self.ylabel = "Frequency (kHz)" | |
819 |
|
845 | |||
820 | self.z = numpy.ma.masked_invalid(self.z) |
|
846 | self.z = numpy.ma.masked_invalid(self.z) | |
821 |
|
847 | |||
822 | if self.decimation is None: |
|
848 | if self.decimation is None: | |
823 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
849 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
824 | else: |
|
850 | else: | |
825 | x, y, z = self.fill_gaps(*self.decimate()) |
|
851 | x, y, z = self.fill_gaps(*self.decimate()) | |
826 |
|
852 | |||
827 | for n, ax in enumerate(self.axes): |
|
853 | for n, ax in enumerate(self.axes): | |
828 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) |
|
854 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) | |
829 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) |
|
855 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) | |
830 | data = self.data[-1] |
|
856 | data = self.data[-1] | |
831 | if ax.firsttime: |
|
857 | if ax.firsttime: | |
832 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
858 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
833 | vmin=self.zmin, |
|
859 | vmin=self.zmin, | |
834 | vmax=self.zmax, |
|
860 | vmax=self.zmax, | |
835 | cmap=plt.get_cmap(self.colormap) |
|
861 | cmap=plt.get_cmap(self.colormap) | |
836 | ) |
|
862 | ) | |
837 | else: |
|
863 | else: | |
838 | ax.collections.remove(ax.collections[0]) |
|
864 | ax.collections.remove(ax.collections[0]) | |
839 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
865 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
840 | vmin=self.zmin, |
|
866 | vmin=self.zmin, | |
841 | vmax=self.zmax, |
|
867 | vmax=self.zmax, | |
842 | cmap=plt.get_cmap(self.colormap) |
|
868 | cmap=plt.get_cmap(self.colormap) | |
843 | ) |
|
869 | ) | |
844 |
|
870 | |||
845 | #self.titles.append('Spectrogram') |
|
871 | #self.titles.append('Spectrogram') | |
846 |
|
872 | |||
847 | #self.titles.append('{} Channel {} \n H = {} km ({} - {})'.format( |
|
873 | #self.titles.append('{} Channel {} \n H = {} km ({} - {})'.format( | |
848 | #self.CODE.upper(), x, y[hei], y[hei],y[hei]+(DH*nProfiles))) |
|
874 | #self.CODE.upper(), x, y[hei], y[hei],y[hei]+(DH*nProfiles))) | |
849 |
|
875 | |||
850 |
|
876 | |||
851 |
|
877 | |||
852 |
|
878 | |||
853 | class CoherencePlot(RTIPlot): |
|
879 | class CoherencePlot(RTIPlot): | |
854 | ''' |
|
880 | ''' | |
855 | Plot for Coherence data |
|
881 | Plot for Coherence data | |
856 | ''' |
|
882 | ''' | |
857 |
|
883 | |||
858 | CODE = 'coh' |
|
884 | CODE = 'coh' | |
859 |
|
885 | |||
860 | def setup(self): |
|
886 | def setup(self): | |
861 | self.xaxis = 'time' |
|
887 | self.xaxis = 'time' | |
862 | self.ncols = 1 |
|
888 | self.ncols = 1 | |
863 | self.nrows = len(self.data.pairs) |
|
889 | self.nrows = len(self.data.pairs) | |
864 | self.nplots = len(self.data.pairs) |
|
890 | self.nplots = len(self.data.pairs) | |
865 | self.ylabel = 'Range [km]' |
|
891 | self.ylabel = 'Range [km]' | |
866 | self.xlabel = 'Time' |
|
892 | self.xlabel = 'Time' | |
867 | self.plots_adjust.update({'hspace':0.6, 'left': 0.1, 'bottom': 0.1,'right':0.95}) |
|
893 | self.plots_adjust.update({'hspace':0.6, 'left': 0.1, 'bottom': 0.1,'right':0.95}) | |
868 | if self.CODE == 'coh': |
|
894 | if self.CODE == 'coh': | |
869 | self.cb_label = '' |
|
895 | self.cb_label = '' | |
870 | self.titles = [ |
|
896 | self.titles = [ | |
871 | 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] |
|
897 | 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] | |
872 | else: |
|
898 | else: | |
873 | self.cb_label = 'Degrees' |
|
899 | self.cb_label = 'Degrees' | |
874 | self.titles = [ |
|
900 | self.titles = [ | |
875 | 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] |
|
901 | 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] | |
876 |
|
902 | |||
877 | def update(self, dataOut): |
|
903 | def update(self, dataOut): | |
878 |
|
904 | |||
879 | data = {} |
|
905 | data = {} | |
880 | meta = {} |
|
906 | meta = {} | |
881 | data['coh'] = dataOut.getCoherence() |
|
907 | data['coh'] = dataOut.getCoherence() | |
882 | meta['pairs'] = dataOut.pairsList |
|
908 | meta['pairs'] = dataOut.pairsList | |
883 |
|
909 | |||
884 | return data, meta |
|
910 | return data, meta | |
885 |
|
911 | |||
886 | class PhasePlot(CoherencePlot): |
|
912 | class PhasePlot(CoherencePlot): | |
887 | ''' |
|
913 | ''' | |
888 | Plot for Phase map data |
|
914 | Plot for Phase map data | |
889 | ''' |
|
915 | ''' | |
890 |
|
916 | |||
891 | CODE = 'phase' |
|
917 | CODE = 'phase' | |
892 | colormap = 'seismic' |
|
918 | colormap = 'seismic' | |
893 |
|
919 | |||
894 | def update(self, dataOut): |
|
920 | def update(self, dataOut): | |
895 |
|
921 | |||
896 | data = {} |
|
922 | data = {} | |
897 | meta = {} |
|
923 | meta = {} | |
898 | data['phase'] = dataOut.getCoherence(phase=True) |
|
924 | data['phase'] = dataOut.getCoherence(phase=True) | |
899 | meta['pairs'] = dataOut.pairsList |
|
925 | meta['pairs'] = dataOut.pairsList | |
900 |
|
926 | |||
901 | return data, meta |
|
927 | return data, meta | |
902 |
|
928 | |||
903 | class NoisePlot(Plot): |
|
929 | class NoisePlot(Plot): | |
904 | ''' |
|
930 | ''' | |
905 | Plot for noise |
|
931 | Plot for noise | |
906 | ''' |
|
932 | ''' | |
907 |
|
933 | |||
908 | CODE = 'noise' |
|
934 | CODE = 'noise' | |
909 | plot_type = 'scatterbuffer' |
|
935 | plot_type = 'scatterbuffer' | |
910 |
|
936 | |||
911 | def setup(self): |
|
937 | def setup(self): | |
912 | self.xaxis = 'time' |
|
938 | self.xaxis = 'time' | |
913 | self.ncols = 1 |
|
939 | self.ncols = 1 | |
914 | self.nrows = 1 |
|
940 | self.nrows = 1 | |
915 | self.nplots = 1 |
|
941 | self.nplots = 1 | |
916 | self.ylabel = 'Intensity [dB]' |
|
942 | self.ylabel = 'Intensity [dB]' | |
917 | self.xlabel = 'Time' |
|
943 | self.xlabel = 'Time' | |
918 | self.titles = ['Noise'] |
|
944 | self.titles = ['Noise'] | |
919 | self.colorbar = False |
|
945 | self.colorbar = False | |
920 | self.plots_adjust.update({'right': 0.85 }) |
|
946 | self.plots_adjust.update({'right': 0.85 }) | |
921 |
|
947 | |||
922 | def update(self, dataOut): |
|
948 | def update(self, dataOut): | |
923 |
|
949 | |||
924 | data = {} |
|
950 | data = {} | |
925 | meta = {} |
|
951 | meta = {} | |
926 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor).reshape(dataOut.nChannels, 1) |
|
952 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor).reshape(dataOut.nChannels, 1) | |
927 | meta['yrange'] = numpy.array([]) |
|
953 | meta['yrange'] = numpy.array([]) | |
928 |
|
954 | |||
929 | return data, meta |
|
955 | return data, meta | |
930 |
|
956 | |||
931 | def plot(self): |
|
957 | def plot(self): | |
932 |
|
958 | |||
933 | x = self.data.times |
|
959 | x = self.data.times | |
934 | xmin = self.data.min_time |
|
960 | xmin = self.data.min_time | |
935 | xmax = xmin + self.xrange * 60 * 60 |
|
961 | xmax = xmin + self.xrange * 60 * 60 | |
936 | Y = self.data['noise'] |
|
962 | Y = self.data['noise'] | |
937 |
|
963 | |||
938 | if self.axes[0].firsttime: |
|
964 | if self.axes[0].firsttime: | |
939 | self.ymin = numpy.nanmin(Y) - 5 |
|
965 | self.ymin = numpy.nanmin(Y) - 5 | |
940 | self.ymax = numpy.nanmax(Y) + 5 |
|
966 | self.ymax = numpy.nanmax(Y) + 5 | |
941 | for ch in self.data.channels: |
|
967 | for ch in self.data.channels: | |
942 | y = Y[ch] |
|
968 | y = Y[ch] | |
943 | self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch)) |
|
969 | self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch)) | |
944 | plt.legend(bbox_to_anchor=(1.18, 1.0)) |
|
970 | plt.legend(bbox_to_anchor=(1.18, 1.0)) | |
945 | else: |
|
971 | else: | |
946 | for ch in self.data.channels: |
|
972 | for ch in self.data.channels: | |
947 | y = Y[ch] |
|
973 | y = Y[ch] | |
948 | self.axes[0].lines[ch].set_data(x, y) |
|
974 | self.axes[0].lines[ch].set_data(x, y) | |
949 |
|
975 | |||
950 | self.ymin = numpy.nanmin(Y) - 5 |
|
976 | self.ymin = numpy.nanmin(Y) - 5 | |
951 | self.ymax = numpy.nanmax(Y) + 10 |
|
977 | self.ymax = numpy.nanmax(Y) + 10 | |
952 |
|
978 | |||
953 |
|
979 | |||
954 | class PowerProfilePlot(Plot): |
|
980 | class PowerProfilePlot(Plot): | |
955 |
|
981 | |||
956 | CODE = 'pow_profile' |
|
982 | CODE = 'pow_profile' | |
957 | plot_type = 'scatter' |
|
983 | plot_type = 'scatter' | |
958 |
|
984 | |||
959 | def setup(self): |
|
985 | def setup(self): | |
960 |
|
986 | |||
961 | self.ncols = 1 |
|
987 | self.ncols = 1 | |
962 | self.nrows = 1 |
|
988 | self.nrows = 1 | |
963 | self.nplots = 1 |
|
989 | self.nplots = 1 | |
964 | self.height = 4 |
|
990 | self.height = 4 | |
965 | self.width = 3 |
|
991 | self.width = 3 | |
966 | self.ylabel = 'Range [km]' |
|
992 | self.ylabel = 'Range [km]' | |
967 | self.xlabel = 'Intensity [dB]' |
|
993 | self.xlabel = 'Intensity [dB]' | |
968 | self.titles = ['Power Profile'] |
|
994 | self.titles = ['Power Profile'] | |
969 | self.colorbar = False |
|
995 | self.colorbar = False | |
970 |
|
996 | |||
971 | def update(self, dataOut): |
|
997 | def update(self, dataOut): | |
972 |
|
998 | |||
973 | data = {} |
|
999 | data = {} | |
974 | meta = {} |
|
1000 | meta = {} | |
975 | data[self.CODE] = dataOut.getPower() |
|
1001 | data[self.CODE] = dataOut.getPower() | |
976 |
|
1002 | |||
977 | return data, meta |
|
1003 | return data, meta | |
978 |
|
1004 | |||
979 | def plot(self): |
|
1005 | def plot(self): | |
980 |
|
1006 | |||
981 | y = self.data.yrange |
|
1007 | y = self.data.yrange | |
982 | self.y = y |
|
1008 | self.y = y | |
983 |
|
1009 | |||
984 | x = self.data[-1][self.CODE] |
|
1010 | x = self.data[-1][self.CODE] | |
985 |
|
1011 | |||
986 | if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9 |
|
1012 | if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9 | |
987 | if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1 |
|
1013 | if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1 | |
988 |
|
1014 | |||
989 | if self.axes[0].firsttime: |
|
1015 | if self.axes[0].firsttime: | |
990 | for ch in self.data.channels: |
|
1016 | for ch in self.data.channels: | |
991 | self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch)) |
|
1017 | self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch)) | |
992 | plt.legend() |
|
1018 | plt.legend() | |
993 | else: |
|
1019 | else: | |
994 | for ch in self.data.channels: |
|
1020 | for ch in self.data.channels: | |
995 | self.axes[0].lines[ch].set_data(x[ch], y) |
|
1021 | self.axes[0].lines[ch].set_data(x[ch], y) | |
996 |
|
1022 | |||
997 |
|
1023 | |||
998 | class SpectraCutPlot(Plot): |
|
1024 | class SpectraCutPlot(Plot): | |
999 |
|
1025 | |||
1000 | CODE = 'spc_cut' |
|
1026 | CODE = 'spc_cut' | |
1001 | plot_type = 'scatter' |
|
1027 | plot_type = 'scatter' | |
1002 | buffering = False |
|
1028 | buffering = False | |
1003 |
|
1029 | |||
1004 | def setup(self): |
|
1030 | def setup(self): | |
1005 |
|
1031 | |||
1006 | self.nplots = len(self.data.channels) |
|
1032 | self.nplots = len(self.data.channels) | |
1007 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
1033 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) | |
1008 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
1034 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) | |
1009 | self.width = 3.4 * self.ncols + 1.5 |
|
1035 | self.width = 3.4 * self.ncols + 1.5 | |
1010 | self.height = 3 * self.nrows |
|
1036 | self.height = 3 * self.nrows | |
1011 | self.ylabel = 'Power [dB]' |
|
1037 | self.ylabel = 'Power [dB]' | |
1012 | self.colorbar = False |
|
1038 | self.colorbar = False | |
1013 | self.plots_adjust.update({'left':0.1, 'hspace':0.3, 'right': 0.75, 'bottom':0.08}) |
|
1039 | self.plots_adjust.update({'left':0.1, 'hspace':0.3, 'right': 0.75, 'bottom':0.08}) | |
1014 |
|
1040 | |||
1015 | def update(self, dataOut): |
|
1041 | def update(self, dataOut): | |
1016 |
|
1042 | |||
1017 | data = {} |
|
1043 | data = {} | |
1018 | meta = {} |
|
1044 | meta = {} | |
1019 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) |
|
1045 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) | |
1020 | data['spc'] = spc |
|
1046 | data['spc'] = spc | |
1021 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
1047 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
1022 | if self.CODE == 'cut_gaussian_fit': |
|
1048 | if self.CODE == 'cut_gaussian_fit': | |
1023 | data['gauss_fit0'] = 10*numpy.log10(dataOut.GaussFit0/dataOut.normFactor) |
|
1049 | data['gauss_fit0'] = 10*numpy.log10(dataOut.GaussFit0/dataOut.normFactor) | |
1024 | data['gauss_fit1'] = 10*numpy.log10(dataOut.GaussFit1/dataOut.normFactor) |
|
1050 | data['gauss_fit1'] = 10*numpy.log10(dataOut.GaussFit1/dataOut.normFactor) | |
1025 | return data, meta |
|
1051 | return data, meta | |
1026 |
|
1052 | |||
1027 | def plot(self): |
|
1053 | def plot(self): | |
1028 | if self.xaxis == "frequency": |
|
1054 | if self.xaxis == "frequency": | |
1029 | x = self.data.xrange[0][1:] |
|
1055 | x = self.data.xrange[0][1:] | |
1030 | self.xlabel = "Frequency (kHz)" |
|
1056 | self.xlabel = "Frequency (kHz)" | |
1031 | elif self.xaxis == "time": |
|
1057 | elif self.xaxis == "time": | |
1032 | x = self.data.xrange[1] |
|
1058 | x = self.data.xrange[1] | |
1033 | self.xlabel = "Time (ms)" |
|
1059 | self.xlabel = "Time (ms)" | |
1034 | else: |
|
1060 | else: | |
1035 | x = self.data.xrange[2][:-1] |
|
1061 | x = self.data.xrange[2][:-1] | |
1036 | self.xlabel = "Velocity (m/s)" |
|
1062 | self.xlabel = "Velocity (m/s)" | |
1037 |
|
1063 | |||
1038 | if self.CODE == 'cut_gaussian_fit': |
|
1064 | if self.CODE == 'cut_gaussian_fit': | |
1039 | x = self.data.xrange[2][:-1] |
|
1065 | x = self.data.xrange[2][:-1] | |
1040 | self.xlabel = "Velocity (m/s)" |
|
1066 | self.xlabel = "Velocity (m/s)" | |
1041 |
|
1067 | |||
1042 | self.titles = [] |
|
1068 | self.titles = [] | |
1043 |
|
1069 | |||
1044 | y = self.data.yrange |
|
1070 | y = self.data.yrange | |
1045 | data = self.data[-1] |
|
1071 | data = self.data[-1] | |
1046 | z = data['spc'] |
|
1072 | z = data['spc'] | |
1047 |
|
1073 | |||
1048 | if self.height_index: |
|
1074 | if self.height_index: | |
1049 | index = numpy.array(self.height_index) |
|
1075 | index = numpy.array(self.height_index) | |
1050 | else: |
|
1076 | else: | |
1051 | index = numpy.arange(0, len(y), int((len(y))/9)) |
|
1077 | index = numpy.arange(0, len(y), int((len(y))/9)) | |
1052 |
|
1078 | |||
1053 | for n, ax in enumerate(self.axes): |
|
1079 | for n, ax in enumerate(self.axes): | |
1054 | if self.CODE == 'cut_gaussian_fit': |
|
1080 | if self.CODE == 'cut_gaussian_fit': | |
1055 | gau0 = data['gauss_fit0'] |
|
1081 | gau0 = data['gauss_fit0'] | |
1056 | gau1 = data['gauss_fit1'] |
|
1082 | gau1 = data['gauss_fit1'] | |
1057 | if ax.firsttime: |
|
1083 | if ax.firsttime: | |
1058 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
1084 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) | |
1059 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
1085 | self.xmin = self.xmin if self.xmin else -self.xmax | |
1060 | self.ymin = self.ymin if self.ymin else numpy.nanmin(z[:,:,index]) |
|
1086 | self.ymin = self.ymin if self.ymin else numpy.nanmin(z[:,:,index]) | |
1061 | self.ymax = self.ymax if self.ymax else numpy.nanmax(z[:,:,index]) |
|
1087 | self.ymax = self.ymax if self.ymax else numpy.nanmax(z[:,:,index]) | |
1062 | #print(self.ymax) |
|
1088 | #print(self.ymax) | |
1063 | #print(z[n, :, index]) |
|
1089 | #print(z[n, :, index]) | |
1064 | ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25) |
|
1090 | ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25) | |
1065 | if self.CODE == 'cut_gaussian_fit': |
|
1091 | if self.CODE == 'cut_gaussian_fit': | |
1066 | ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.') |
|
1092 | ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.') | |
1067 | for i, line in enumerate(ax.plt_gau0): |
|
1093 | for i, line in enumerate(ax.plt_gau0): | |
1068 | line.set_color(ax.plt[i].get_color()) |
|
1094 | line.set_color(ax.plt[i].get_color()) | |
1069 | ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--') |
|
1095 | ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--') | |
1070 | for i, line in enumerate(ax.plt_gau1): |
|
1096 | for i, line in enumerate(ax.plt_gau1): | |
1071 | line.set_color(ax.plt[i].get_color()) |
|
1097 | line.set_color(ax.plt[i].get_color()) | |
1072 | labels = ['Range = {:2.1f}km'.format(y[i]) for i in index] |
|
1098 | labels = ['Range = {:2.1f}km'.format(y[i]) for i in index] | |
1073 | self.figures[0].legend(ax.plt, labels, loc='center right') |
|
1099 | self.figures[0].legend(ax.plt, labels, loc='center right') | |
1074 | else: |
|
1100 | else: | |
1075 | for i, line in enumerate(ax.plt): |
|
1101 | for i, line in enumerate(ax.plt): | |
1076 | line.set_data(x, z[n, :, index[i]].T) |
|
1102 | line.set_data(x, z[n, :, index[i]].T) | |
1077 | for i, line in enumerate(ax.plt_gau0): |
|
1103 | for i, line in enumerate(ax.plt_gau0): | |
1078 | line.set_data(x, gau0[n, :, index[i]].T) |
|
1104 | line.set_data(x, gau0[n, :, index[i]].T) | |
1079 | line.set_color(ax.plt[i].get_color()) |
|
1105 | line.set_color(ax.plt[i].get_color()) | |
1080 | for i, line in enumerate(ax.plt_gau1): |
|
1106 | for i, line in enumerate(ax.plt_gau1): | |
1081 | line.set_data(x, gau1[n, :, index[i]].T) |
|
1107 | line.set_data(x, gau1[n, :, index[i]].T) | |
1082 | line.set_color(ax.plt[i].get_color()) |
|
1108 | line.set_color(ax.plt[i].get_color()) | |
1083 | self.titles.append('CH {}'.format(n)) |
|
1109 | self.titles.append('CH {}'.format(n)) | |
1084 |
|
1110 | |||
1085 |
|
1111 | |||
1086 | class BeaconPhase(Plot): |
|
1112 | class BeaconPhase(Plot): | |
1087 |
|
1113 | |||
1088 | __isConfig = None |
|
1114 | __isConfig = None | |
1089 | __nsubplots = None |
|
1115 | __nsubplots = None | |
1090 |
|
1116 | |||
1091 | PREFIX = 'beacon_phase' |
|
1117 | PREFIX = 'beacon_phase' | |
1092 |
|
1118 | |||
1093 | def __init__(self): |
|
1119 | def __init__(self): | |
1094 | Plot.__init__(self) |
|
1120 | Plot.__init__(self) | |
1095 | self.timerange = 24*60*60 |
|
1121 | self.timerange = 24*60*60 | |
1096 | self.isConfig = False |
|
1122 | self.isConfig = False | |
1097 | self.__nsubplots = 1 |
|
1123 | self.__nsubplots = 1 | |
1098 | self.counter_imagwr = 0 |
|
1124 | self.counter_imagwr = 0 | |
1099 | self.WIDTH = 800 |
|
1125 | self.WIDTH = 800 | |
1100 | self.HEIGHT = 400 |
|
1126 | self.HEIGHT = 400 | |
1101 | self.WIDTHPROF = 120 |
|
1127 | self.WIDTHPROF = 120 | |
1102 | self.HEIGHTPROF = 0 |
|
1128 | self.HEIGHTPROF = 0 | |
1103 | self.xdata = None |
|
1129 | self.xdata = None | |
1104 | self.ydata = None |
|
1130 | self.ydata = None | |
1105 |
|
1131 | |||
1106 | self.PLOT_CODE = BEACON_CODE |
|
1132 | self.PLOT_CODE = BEACON_CODE | |
1107 |
|
1133 | |||
1108 | self.FTP_WEI = None |
|
1134 | self.FTP_WEI = None | |
1109 | self.EXP_CODE = None |
|
1135 | self.EXP_CODE = None | |
1110 | self.SUB_EXP_CODE = None |
|
1136 | self.SUB_EXP_CODE = None | |
1111 | self.PLOT_POS = None |
|
1137 | self.PLOT_POS = None | |
1112 |
|
1138 | |||
1113 | self.filename_phase = None |
|
1139 | self.filename_phase = None | |
1114 |
|
1140 | |||
1115 | self.figfile = None |
|
1141 | self.figfile = None | |
1116 |
|
1142 | |||
1117 | self.xmin = None |
|
1143 | self.xmin = None | |
1118 | self.xmax = None |
|
1144 | self.xmax = None | |
1119 |
|
1145 | |||
1120 | def getSubplots(self): |
|
1146 | def getSubplots(self): | |
1121 |
|
1147 | |||
1122 | ncol = 1 |
|
1148 | ncol = 1 | |
1123 | nrow = 1 |
|
1149 | nrow = 1 | |
1124 |
|
1150 | |||
1125 | return nrow, ncol |
|
1151 | return nrow, ncol | |
1126 |
|
1152 | |||
1127 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1153 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1128 |
|
1154 | |||
1129 | self.__showprofile = showprofile |
|
1155 | self.__showprofile = showprofile | |
1130 | self.nplots = nplots |
|
1156 | self.nplots = nplots | |
1131 |
|
1157 | |||
1132 | ncolspan = 7 |
|
1158 | ncolspan = 7 | |
1133 | colspan = 6 |
|
1159 | colspan = 6 | |
1134 | self.__nsubplots = 2 |
|
1160 | self.__nsubplots = 2 | |
1135 |
|
1161 | |||
1136 | self.createFigure(id = id, |
|
1162 | self.createFigure(id = id, | |
1137 | wintitle = wintitle, |
|
1163 | wintitle = wintitle, | |
1138 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1164 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1139 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1165 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1140 | show=show) |
|
1166 | show=show) | |
1141 |
|
1167 | |||
1142 | nrow, ncol = self.getSubplots() |
|
1168 | nrow, ncol = self.getSubplots() | |
1143 |
|
1169 | |||
1144 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1170 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1145 |
|
1171 | |||
1146 | def save_phase(self, filename_phase): |
|
1172 | def save_phase(self, filename_phase): | |
1147 | f = open(filename_phase,'w+') |
|
1173 | f = open(filename_phase,'w+') | |
1148 | f.write('\n\n') |
|
1174 | f.write('\n\n') | |
1149 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') |
|
1175 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') | |
1150 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' ) |
|
1176 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' ) | |
1151 | f.close() |
|
1177 | f.close() | |
1152 |
|
1178 | |||
1153 | def save_data(self, filename_phase, data, data_datetime): |
|
1179 | def save_data(self, filename_phase, data, data_datetime): | |
1154 | f=open(filename_phase,'a') |
|
1180 | f=open(filename_phase,'a') | |
1155 | timetuple_data = data_datetime.timetuple() |
|
1181 | timetuple_data = data_datetime.timetuple() | |
1156 | day = str(timetuple_data.tm_mday) |
|
1182 | day = str(timetuple_data.tm_mday) | |
1157 | month = str(timetuple_data.tm_mon) |
|
1183 | month = str(timetuple_data.tm_mon) | |
1158 | year = str(timetuple_data.tm_year) |
|
1184 | year = str(timetuple_data.tm_year) | |
1159 | hour = str(timetuple_data.tm_hour) |
|
1185 | hour = str(timetuple_data.tm_hour) | |
1160 | minute = str(timetuple_data.tm_min) |
|
1186 | minute = str(timetuple_data.tm_min) | |
1161 | second = str(timetuple_data.tm_sec) |
|
1187 | second = str(timetuple_data.tm_sec) | |
1162 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') |
|
1188 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') | |
1163 | f.close() |
|
1189 | f.close() | |
1164 |
|
1190 | |||
1165 | def plot(self): |
|
1191 | def plot(self): | |
1166 | log.warning('TODO: Not yet implemented...') |
|
1192 | log.warning('TODO: Not yet implemented...') | |
1167 |
|
1193 | |||
1168 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
1194 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
1169 | xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None, |
|
1195 | xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None, | |
1170 | timerange=None, |
|
1196 | timerange=None, | |
1171 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1197 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1172 | server=None, folder=None, username=None, password=None, |
|
1198 | server=None, folder=None, username=None, password=None, | |
1173 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1199 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1174 |
|
1200 | |||
1175 | if dataOut.flagNoData: |
|
1201 | if dataOut.flagNoData: | |
1176 | return dataOut |
|
1202 | return dataOut | |
1177 |
|
1203 | |||
1178 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
1204 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
1179 | return |
|
1205 | return | |
1180 |
|
1206 | |||
1181 | if pairsList == None: |
|
1207 | if pairsList == None: | |
1182 | pairsIndexList = dataOut.pairsIndexList[:10] |
|
1208 | pairsIndexList = dataOut.pairsIndexList[:10] | |
1183 | else: |
|
1209 | else: | |
1184 | pairsIndexList = [] |
|
1210 | pairsIndexList = [] | |
1185 | for pair in pairsList: |
|
1211 | for pair in pairsList: | |
1186 | if pair not in dataOut.pairsList: |
|
1212 | if pair not in dataOut.pairsList: | |
1187 | raise ValueError("Pair %s is not in dataOut.pairsList" %(pair)) |
|
1213 | raise ValueError("Pair %s is not in dataOut.pairsList" %(pair)) | |
1188 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
1214 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
1189 |
|
1215 | |||
1190 | if pairsIndexList == []: |
|
1216 | if pairsIndexList == []: | |
1191 | return |
|
1217 | return | |
1192 |
|
1218 | |||
1193 | # if len(pairsIndexList) > 4: |
|
1219 | # if len(pairsIndexList) > 4: | |
1194 | # pairsIndexList = pairsIndexList[0:4] |
|
1220 | # pairsIndexList = pairsIndexList[0:4] | |
1195 |
|
1221 | |||
1196 | hmin_index = None |
|
1222 | hmin_index = None | |
1197 | hmax_index = None |
|
1223 | hmax_index = None | |
1198 |
|
1224 | |||
1199 | if hmin != None and hmax != None: |
|
1225 | if hmin != None and hmax != None: | |
1200 | indexes = numpy.arange(dataOut.nHeights) |
|
1226 | indexes = numpy.arange(dataOut.nHeights) | |
1201 | hmin_list = indexes[dataOut.heightList >= hmin] |
|
1227 | hmin_list = indexes[dataOut.heightList >= hmin] | |
1202 | hmax_list = indexes[dataOut.heightList <= hmax] |
|
1228 | hmax_list = indexes[dataOut.heightList <= hmax] | |
1203 |
|
1229 | |||
1204 | if hmin_list.any(): |
|
1230 | if hmin_list.any(): | |
1205 | hmin_index = hmin_list[0] |
|
1231 | hmin_index = hmin_list[0] | |
1206 |
|
1232 | |||
1207 | if hmax_list.any(): |
|
1233 | if hmax_list.any(): | |
1208 | hmax_index = hmax_list[-1]+1 |
|
1234 | hmax_index = hmax_list[-1]+1 | |
1209 |
|
1235 | |||
1210 | x = dataOut.getTimeRange() |
|
1236 | x = dataOut.getTimeRange() | |
1211 |
|
1237 | |||
1212 | thisDatetime = dataOut.datatime |
|
1238 | thisDatetime = dataOut.datatime | |
1213 |
|
1239 | |||
1214 | title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1240 | title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1215 | xlabel = "Local Time" |
|
1241 | xlabel = "Local Time" | |
1216 | ylabel = "Phase (degrees)" |
|
1242 | ylabel = "Phase (degrees)" | |
1217 |
|
1243 | |||
1218 | update_figfile = False |
|
1244 | update_figfile = False | |
1219 |
|
1245 | |||
1220 | nplots = len(pairsIndexList) |
|
1246 | nplots = len(pairsIndexList) | |
1221 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) |
|
1247 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) | |
1222 | phase_beacon = numpy.zeros(len(pairsIndexList)) |
|
1248 | phase_beacon = numpy.zeros(len(pairsIndexList)) | |
1223 | for i in range(nplots): |
|
1249 | for i in range(nplots): | |
1224 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
1250 | pair = dataOut.pairsList[pairsIndexList[i]] | |
1225 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0) |
|
1251 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0) | |
1226 | powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0) |
|
1252 | powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0) | |
1227 | powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0) |
|
1253 | powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0) | |
1228 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) |
|
1254 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) | |
1229 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
1255 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
1230 |
|
1256 | |||
1231 | if dataOut.beacon_heiIndexList: |
|
1257 | if dataOut.beacon_heiIndexList: | |
1232 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) |
|
1258 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) | |
1233 | else: |
|
1259 | else: | |
1234 | phase_beacon[i] = numpy.average(phase) |
|
1260 | phase_beacon[i] = numpy.average(phase) | |
1235 |
|
1261 | |||
1236 | if not self.isConfig: |
|
1262 | if not self.isConfig: | |
1237 |
|
1263 | |||
1238 | nplots = len(pairsIndexList) |
|
1264 | nplots = len(pairsIndexList) | |
1239 |
|
1265 | |||
1240 | self.setup(id=id, |
|
1266 | self.setup(id=id, | |
1241 | nplots=nplots, |
|
1267 | nplots=nplots, | |
1242 | wintitle=wintitle, |
|
1268 | wintitle=wintitle, | |
1243 | showprofile=showprofile, |
|
1269 | showprofile=showprofile, | |
1244 | show=show) |
|
1270 | show=show) | |
1245 |
|
1271 | |||
1246 | if timerange != None: |
|
1272 | if timerange != None: | |
1247 | self.timerange = timerange |
|
1273 | self.timerange = timerange | |
1248 |
|
1274 | |||
1249 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1275 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1250 |
|
1276 | |||
1251 | if ymin == None: ymin = 0 |
|
1277 | if ymin == None: ymin = 0 | |
1252 | if ymax == None: ymax = 360 |
|
1278 | if ymax == None: ymax = 360 | |
1253 |
|
1279 | |||
1254 | self.FTP_WEI = ftp_wei |
|
1280 | self.FTP_WEI = ftp_wei | |
1255 | self.EXP_CODE = exp_code |
|
1281 | self.EXP_CODE = exp_code | |
1256 | self.SUB_EXP_CODE = sub_exp_code |
|
1282 | self.SUB_EXP_CODE = sub_exp_code | |
1257 | self.PLOT_POS = plot_pos |
|
1283 | self.PLOT_POS = plot_pos | |
1258 |
|
1284 | |||
1259 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1285 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1260 | self.isConfig = True |
|
1286 | self.isConfig = True | |
1261 | self.figfile = figfile |
|
1287 | self.figfile = figfile | |
1262 | self.xdata = numpy.array([]) |
|
1288 | self.xdata = numpy.array([]) | |
1263 | self.ydata = numpy.array([]) |
|
1289 | self.ydata = numpy.array([]) | |
1264 |
|
1290 | |||
1265 | update_figfile = True |
|
1291 | update_figfile = True | |
1266 |
|
1292 | |||
1267 | #open file beacon phase |
|
1293 | #open file beacon phase | |
1268 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1294 | path = '%s%03d' %(self.PREFIX, self.id) | |
1269 | beacon_file = os.path.join(path,'%s.txt'%self.name) |
|
1295 | beacon_file = os.path.join(path,'%s.txt'%self.name) | |
1270 | self.filename_phase = os.path.join(figpath,beacon_file) |
|
1296 | self.filename_phase = os.path.join(figpath,beacon_file) | |
1271 | #self.save_phase(self.filename_phase) |
|
1297 | #self.save_phase(self.filename_phase) | |
1272 |
|
1298 | |||
1273 |
|
1299 | |||
1274 | #store data beacon phase |
|
1300 | #store data beacon phase | |
1275 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) |
|
1301 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) | |
1276 |
|
1302 | |||
1277 | self.setWinTitle(title) |
|
1303 | self.setWinTitle(title) | |
1278 |
|
1304 | |||
1279 |
|
1305 | |||
1280 | title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1306 | title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1281 |
|
1307 | |||
1282 | legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList] |
|
1308 | legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList] | |
1283 |
|
1309 | |||
1284 | axes = self.axesList[0] |
|
1310 | axes = self.axesList[0] | |
1285 |
|
1311 | |||
1286 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1312 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1287 |
|
1313 | |||
1288 | if len(self.ydata)==0: |
|
1314 | if len(self.ydata)==0: | |
1289 | self.ydata = phase_beacon.reshape(-1,1) |
|
1315 | self.ydata = phase_beacon.reshape(-1,1) | |
1290 | else: |
|
1316 | else: | |
1291 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) |
|
1317 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) | |
1292 |
|
1318 | |||
1293 |
|
1319 | |||
1294 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1320 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1295 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, |
|
1321 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, | |
1296 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1322 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1297 | XAxisAsTime=True, grid='both' |
|
1323 | XAxisAsTime=True, grid='both' | |
1298 | ) |
|
1324 | ) | |
1299 |
|
1325 | |||
1300 | self.draw() |
|
1326 | self.draw() | |
1301 |
|
1327 | |||
1302 | if dataOut.ltctime >= self.xmax: |
|
1328 | if dataOut.ltctime >= self.xmax: | |
1303 | self.counter_imagwr = wr_period |
|
1329 | self.counter_imagwr = wr_period | |
1304 | self.isConfig = False |
|
1330 | self.isConfig = False | |
1305 | update_figfile = True |
|
1331 | update_figfile = True | |
1306 |
|
1332 | |||
1307 | self.save(figpath=figpath, |
|
1333 | self.save(figpath=figpath, | |
1308 | figfile=figfile, |
|
1334 | figfile=figfile, | |
1309 | save=save, |
|
1335 | save=save, | |
1310 | ftp=ftp, |
|
1336 | ftp=ftp, | |
1311 | wr_period=wr_period, |
|
1337 | wr_period=wr_period, | |
1312 | thisDatetime=thisDatetime, |
|
1338 | thisDatetime=thisDatetime, | |
1313 | update_figfile=update_figfile) |
|
1339 | update_figfile=update_figfile) | |
1314 |
|
1340 | |||
1315 | return dataOut |
|
1341 | return dataOut |
@@ -1,1285 +1,1299 | |||||
1 |
|
1 | |||
2 | import os |
|
2 | import os | |
3 | import time |
|
3 | import time | |
4 | import math |
|
4 | import math | |
5 | import datetime |
|
5 | import datetime | |
6 | import numpy |
|
6 | import numpy | |
|
7 | import collections.abc | |||
7 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG |
|
8 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG | |
8 |
|
9 | |||
9 | from .jroplot_spectra import RTIPlot, NoisePlot |
|
10 | from .jroplot_spectra import RTIPlot, NoisePlot | |
10 |
|
11 | |||
11 | from schainpy.utils import log |
|
12 | from schainpy.utils import log | |
12 | from .plotting_codes import * |
|
13 | from .plotting_codes import * | |
13 |
|
14 | |||
14 | from schainpy.model.graphics.jroplot_base import Plot, plt |
|
15 | from schainpy.model.graphics.jroplot_base import Plot, plt | |
15 |
|
16 | |||
16 | import matplotlib.pyplot as plt |
|
17 | import matplotlib.pyplot as plt | |
17 | import matplotlib.colors as colors |
|
18 | import matplotlib.colors as colors | |
18 | from matplotlib.ticker import MultipleLocator |
|
19 | from matplotlib.ticker import MultipleLocator | |
19 |
|
20 | |||
20 |
|
21 | |||
21 | class RTIDPPlot(RTIPlot): |
|
22 | class RTIDPPlot(RTIPlot): | |
22 |
|
23 | |||
23 | '''Plot for RTI Double Pulse Experiment |
|
24 | '''Plot for RTI Double Pulse Experiment | |
24 | ''' |
|
25 | ''' | |
25 |
|
26 | |||
26 | CODE = 'RTIDP' |
|
27 | CODE = 'RTIDP' | |
27 | colormap = 'jet' |
|
28 | colormap = 'jet' | |
28 | plot_name = 'RTI' |
|
29 | plot_name = 'RTI' | |
29 | plot_type = 'pcolorbuffer' |
|
30 | plot_type = 'pcolorbuffer' | |
30 |
|
31 | |||
31 | def setup(self): |
|
32 | def setup(self): | |
32 | self.xaxis = 'time' |
|
33 | self.xaxis = 'time' | |
33 | self.ncols = 1 |
|
34 | self.ncols = 1 | |
34 | self.nrows = 3 |
|
35 | self.nrows = 3 | |
35 | self.nplots = self.nrows |
|
36 | self.nplots = self.nrows | |
36 |
|
37 | |||
37 | self.ylabel = 'Range [km]' |
|
38 | self.ylabel = 'Range [km]' | |
38 | self.xlabel = 'Time (LT)' |
|
39 | self.xlabel = 'Time (LT)' | |
39 |
|
40 | |||
40 | self.cb_label = 'Intensity (dB)' |
|
41 | self.cb_label = 'Intensity (dB)' | |
41 |
|
42 | |||
42 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) |
|
43 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) | |
43 |
|
44 | |||
44 | self.titles = ['{} Channel {}'.format( |
|
45 | self.titles = ['{} Channel {}'.format( | |
45 | self.plot_name.upper(), '0x1'),'{} Channel {}'.format( |
|
46 | self.plot_name.upper(), '0x1'),'{} Channel {}'.format( | |
46 | self.plot_name.upper(), '0'),'{} Channel {}'.format( |
|
47 | self.plot_name.upper(), '0'),'{} Channel {}'.format( | |
47 | self.plot_name.upper(), '1')] |
|
48 | self.plot_name.upper(), '1')] | |
48 |
|
49 | |||
49 | def update(self, dataOut): |
|
50 | def update(self, dataOut): | |
50 |
|
51 | |||
51 | data = {} |
|
52 | data = {} | |
52 | meta = {} |
|
53 | meta = {} | |
53 | data['rti'] = dataOut.data_for_RTI_DP |
|
54 | data['rti'] = dataOut.data_for_RTI_DP | |
54 | data['NDP'] = dataOut.NDP |
|
55 | data['NDP'] = dataOut.NDP | |
55 |
|
56 | |||
56 | return data, meta |
|
57 | return data, meta | |
57 |
|
58 | |||
58 | def plot(self): |
|
59 | def plot(self): | |
59 |
|
60 | |||
60 | NDP = self.data['NDP'][-1] |
|
61 | NDP = self.data['NDP'][-1] | |
61 | self.x = self.data.times |
|
62 | self.x = self.data.times | |
62 | self.y = self.data.yrange[0:NDP] |
|
63 | self.y = self.data.yrange[0:NDP] | |
63 | self.z = self.data['rti'] |
|
64 | self.z = self.data['rti'] | |
64 | self.z = numpy.ma.masked_invalid(self.z) |
|
65 | self.z = numpy.ma.masked_invalid(self.z) | |
65 |
|
66 | |||
66 | if self.decimation is None: |
|
67 | if self.decimation is None: | |
67 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
68 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
68 | else: |
|
69 | else: | |
69 | x, y, z = self.fill_gaps(*self.decimate()) |
|
70 | x, y, z = self.fill_gaps(*self.decimate()) | |
70 |
|
71 | |||
71 | for n, ax in enumerate(self.axes): |
|
72 | for n, ax in enumerate(self.axes): | |
72 |
|
73 | |||
73 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
74 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
74 | self.z[1][0,12:40]) |
|
75 | self.z[1][0,12:40]) | |
75 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
76 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
76 | self.z[1][0,12:40]) |
|
77 | self.z[1][0,12:40]) | |
77 |
|
78 | |||
78 | if ax.firsttime: |
|
79 | if ax.firsttime: | |
79 |
|
80 | |||
80 | if self.zlimits is not None: |
|
81 | if self.zlimits is not None: | |
81 | self.zmin, self.zmax = self.zlimits[n] |
|
82 | self.zmin, self.zmax = self.zlimits[n] | |
82 |
|
83 | |||
83 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
84 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
84 | vmin=self.zmin, |
|
85 | vmin=self.zmin, | |
85 | vmax=self.zmax, |
|
86 | vmax=self.zmax, | |
86 | cmap=plt.get_cmap(self.colormap) |
|
87 | cmap=plt.get_cmap(self.colormap) | |
87 | ) |
|
88 | ) | |
88 | else: |
|
89 | else: | |
89 | #if self.zlimits is not None: |
|
90 | #if self.zlimits is not None: | |
90 | #self.zmin, self.zmax = self.zlimits[n] |
|
91 | #self.zmin, self.zmax = self.zlimits[n] | |
91 | ax.collections.remove(ax.collections[0]) |
|
92 | ax.collections.remove(ax.collections[0]) | |
92 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
93 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
93 | vmin=self.zmin, |
|
94 | vmin=self.zmin, | |
94 | vmax=self.zmax, |
|
95 | vmax=self.zmax, | |
95 | cmap=plt.get_cmap(self.colormap) |
|
96 | cmap=plt.get_cmap(self.colormap) | |
96 | ) |
|
97 | ) | |
97 |
|
98 | |||
98 |
|
99 | |||
99 | class RTILPPlot(RTIPlot): |
|
100 | class RTILPPlot(RTIPlot): | |
100 |
|
101 | |||
101 | ''' |
|
102 | ''' | |
102 | Plot for RTI Long Pulse |
|
103 | Plot for RTI Long Pulse | |
103 | ''' |
|
104 | ''' | |
104 |
|
105 | |||
105 | CODE = 'RTILP' |
|
106 | CODE = 'RTILP' | |
106 | colormap = 'jet' |
|
107 | colormap = 'jet' | |
107 | plot_name = 'RTI LP' |
|
108 | plot_name = 'RTI LP' | |
108 | plot_type = 'pcolorbuffer' |
|
109 | plot_type = 'pcolorbuffer' | |
109 |
|
110 | |||
110 | def setup(self): |
|
111 | def setup(self): | |
111 | self.xaxis = 'time' |
|
112 | self.xaxis = 'time' | |
112 | self.ncols = 1 |
|
113 | self.ncols = 1 | |
113 |
self.nrows = |
|
114 | self.nrows = 2 | |
114 | self.nplots = self.nrows |
|
115 | self.nplots = self.nrows | |
115 |
|
116 | |||
116 | self.ylabel = 'Range [km]' |
|
117 | self.ylabel = 'Range [km]' | |
117 | self.xlabel = 'Time (LT)' |
|
118 | self.xlabel = 'Time (LT)' | |
118 |
|
119 | |||
119 | self.cb_label = 'Intensity (dB)' |
|
120 | self.cb_label = 'Intensity (dB)' | |
120 |
|
121 | |||
121 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) |
|
122 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) | |
122 |
|
123 | |||
123 |
|
124 | |||
124 | self.titles = ['{} Channel {}'.format( |
|
125 | self.titles = ['{} Channel {}'.format( | |
125 | self.plot_name.upper(), '0'),'{} Channel {}'.format( |
|
126 | self.plot_name.upper(), '0'),'{} Channel {}'.format( | |
126 | self.plot_name.upper(), '1'),'{} Channel {}'.format( |
|
127 | self.plot_name.upper(), '1'),'{} Channel {}'.format( | |
127 | self.plot_name.upper(), '2'),'{} Channel {}'.format( |
|
128 | self.plot_name.upper(), '2'),'{} Channel {}'.format( | |
128 | self.plot_name.upper(), '3')] |
|
129 | self.plot_name.upper(), '3')] | |
129 |
|
130 | |||
130 |
|
131 | |||
131 | def update(self, dataOut): |
|
132 | def update(self, dataOut): | |
132 |
|
133 | |||
133 | data = {} |
|
134 | data = {} | |
134 | meta = {} |
|
135 | meta = {} | |
135 | data['rti'] = dataOut.data_for_RTI_LP |
|
136 | data['rti'] = dataOut.data_for_RTI_LP | |
136 | data['NRANGE'] = dataOut.NRANGE |
|
137 | data['NRANGE'] = dataOut.NRANGE | |
137 |
|
138 | |||
138 | return data, meta |
|
139 | return data, meta | |
139 |
|
140 | |||
140 | def plot(self): |
|
141 | def plot(self): | |
141 |
|
142 | |||
142 | NRANGE = self.data['NRANGE'][-1] |
|
143 | NRANGE = self.data['NRANGE'][-1] | |
143 | self.x = self.data.times |
|
144 | self.x = self.data.times | |
144 | self.y = self.data.yrange[0:NRANGE] |
|
145 | self.y = self.data.yrange[0:NRANGE] | |
145 |
|
146 | |||
146 | self.z = self.data['rti'] |
|
147 | self.z = self.data['rti'] | |
147 |
|
148 | |||
148 | self.z = numpy.ma.masked_invalid(self.z) |
|
149 | self.z = numpy.ma.masked_invalid(self.z) | |
149 |
|
150 | |||
150 | if self.decimation is None: |
|
151 | if self.decimation is None: | |
151 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
152 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
152 | else: |
|
153 | else: | |
153 | x, y, z = self.fill_gaps(*self.decimate()) |
|
154 | x, y, z = self.fill_gaps(*self.decimate()) | |
154 |
|
155 | |||
|
156 | if not isinstance(self.zmin, collections.abc.Sequence): | |||
|
157 | if not self.zmin: | |||
|
158 | self.zmin = [numpy.min(self.z)]*len(self.axes) | |||
|
159 | else: | |||
|
160 | self.zmin = [self.zmin]*len(self.axes) | |||
|
161 | ||||
|
162 | if not isinstance(self.zmax, collections.abc.Sequence): | |||
|
163 | if not self.zmax: | |||
|
164 | self.zmax = [numpy.max(self.z)]*len(self.axes) | |||
|
165 | else: | |||
|
166 | self.zmax = [self.zmax]*len(self.axes) | |||
|
167 | ||||
155 | for n, ax in enumerate(self.axes): |
|
168 | for n, ax in enumerate(self.axes): | |
156 |
|
169 | |||
157 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
170 | #self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
158 | self.z[1][0,12:40]) |
|
171 | #self.z[1][0,12:40]) | |
159 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
172 | #self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
160 | self.z[1][0,12:40]) |
|
173 | #self.z[1][0,12:40]) | |
161 |
|
174 | |||
162 | if ax.firsttime: |
|
175 | if ax.firsttime: | |
163 |
|
176 | |||
164 | if self.zlimits is not None: |
|
177 | if self.zlimits is not None: | |
165 | self.zmin, self.zmax = self.zlimits[n] |
|
178 | self.zmin, self.zmax = self.zlimits[n] | |
166 |
|
179 | |||
167 |
|
180 | |||
168 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
181 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
169 | vmin=self.zmin, |
|
182 | vmin=self.zmin[n], | |
170 | vmax=self.zmax, |
|
183 | vmax=self.zmax[n], | |
171 | cmap=plt.get_cmap(self.colormap) |
|
184 | cmap=plt.get_cmap(self.colormap) | |
172 | ) |
|
185 | ) | |
173 |
|
186 | |||
174 | else: |
|
187 | else: | |
175 | #if self.zlimits is not None: |
|
188 | #if self.zlimits is not None: | |
176 | #self.zmin, self.zmax = self.zlimits[n] |
|
189 | #self.zmin, self.zmax = self.zlimits[n] | |
177 | ax.collections.remove(ax.collections[0]) |
|
190 | ax.collections.remove(ax.collections[0]) | |
178 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
191 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
179 | vmin=self.zmin, |
|
192 | vmin=self.zmin[n], | |
180 | vmax=self.zmax, |
|
193 | vmax=self.zmax[n], | |
181 | cmap=plt.get_cmap(self.colormap) |
|
194 | cmap=plt.get_cmap(self.colormap) | |
182 | ) |
|
195 | ) | |
183 |
|
196 | |||
184 |
|
197 | |||
185 | class DenRTIPlot(RTIPlot): |
|
198 | class DenRTIPlot(RTIPlot): | |
186 |
|
199 | |||
187 | ''' |
|
200 | ''' | |
188 | Plot for Den |
|
201 | Plot for Den | |
189 | ''' |
|
202 | ''' | |
190 |
|
203 | |||
191 | CODE = 'denrti' |
|
204 | CODE = 'denrti' | |
192 | colormap = 'jet' |
|
205 | colormap = 'jet' | |
193 |
|
206 | |||
194 | def setup(self): |
|
207 | def setup(self): | |
195 | self.xaxis = 'time' |
|
208 | self.xaxis = 'time' | |
196 | self.ncols = 1 |
|
209 | self.ncols = 1 | |
197 | self.nrows = self.data.shape(self.CODE)[0] |
|
210 | self.nrows = self.data.shape(self.CODE)[0] | |
198 | self.nplots = self.nrows |
|
211 | self.nplots = self.nrows | |
199 |
|
212 | |||
200 | self.ylabel = 'Range [km]' |
|
213 | self.ylabel = 'Range [km]' | |
201 | self.xlabel = 'Time (LT)' |
|
214 | self.xlabel = 'Time (LT)' | |
202 |
|
215 | |||
203 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
216 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
204 |
|
217 | |||
205 | if self.CODE == 'denrti': |
|
218 | if self.CODE == 'denrti': | |
206 | self.cb_label = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' |
|
219 | self.cb_label = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' | |
207 |
|
220 | |||
208 |
|
221 | |||
209 | self.titles = ['Electron Density RTI'] |
|
222 | self.titles = ['Electron Density RTI'] | |
210 |
|
223 | |||
211 | def update(self, dataOut): |
|
224 | def update(self, dataOut): | |
212 |
|
225 | |||
213 | data = {} |
|
226 | data = {} | |
214 | meta = {} |
|
227 | meta = {} | |
215 |
|
228 | |||
216 | data['denrti'] = dataOut.DensityFinal*1.e-6 #To Plot in cm^-3 |
|
229 | data['denrti'] = dataOut.DensityFinal*1.e-6 #To Plot in cm^-3 | |
217 |
|
230 | |||
218 | return data, meta |
|
231 | return data, meta | |
219 |
|
232 | |||
220 | def plot(self): |
|
233 | def plot(self): | |
221 |
|
234 | |||
222 | self.x = self.data.times |
|
235 | self.x = self.data.times | |
223 | self.y = self.data.yrange |
|
236 | self.y = self.data.yrange | |
224 |
|
237 | |||
225 | self.z = self.data[self.CODE] |
|
238 | self.z = self.data[self.CODE] | |
226 |
|
239 | |||
227 | self.z = numpy.ma.masked_invalid(self.z) |
|
240 | self.z = numpy.ma.masked_invalid(self.z) | |
228 |
|
241 | |||
229 | if self.decimation is None: |
|
242 | if self.decimation is None: | |
230 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
243 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
231 | else: |
|
244 | else: | |
232 | x, y, z = self.fill_gaps(*self.decimate()) |
|
245 | x, y, z = self.fill_gaps(*self.decimate()) | |
233 |
|
246 | |||
234 | for n, ax in enumerate(self.axes): |
|
247 | for n, ax in enumerate(self.axes): | |
235 |
|
248 | |||
236 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
249 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
237 | self.z[n]) |
|
250 | self.z[n]) | |
238 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
251 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
239 | self.z[n]) |
|
252 | self.z[n]) | |
240 |
|
253 | |||
241 | if ax.firsttime: |
|
254 | if ax.firsttime: | |
242 |
|
255 | |||
243 | if self.zlimits is not None: |
|
256 | if self.zlimits is not None: | |
244 | self.zmin, self.zmax = self.zlimits[n] |
|
257 | self.zmin, self.zmax = self.zlimits[n] | |
245 | if numpy.log10(self.zmin)<0: |
|
258 | if numpy.log10(self.zmin)<0: | |
246 | self.zmin=1 |
|
259 | self.zmin=1 | |
247 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
260 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
248 | vmin=self.zmin, |
|
261 | vmin=self.zmin, | |
249 | vmax=self.zmax, |
|
262 | vmax=self.zmax, | |
250 | cmap=self.cmaps[n], |
|
263 | cmap=self.cmaps[n], | |
251 | norm=colors.LogNorm() |
|
264 | norm=colors.LogNorm() | |
252 | ) |
|
265 | ) | |
253 |
|
266 | |||
254 | else: |
|
267 | else: | |
255 | if self.zlimits is not None: |
|
268 | if self.zlimits is not None: | |
256 | self.zmin, self.zmax = self.zlimits[n] |
|
269 | self.zmin, self.zmax = self.zlimits[n] | |
257 | ax.collections.remove(ax.collections[0]) |
|
270 | ax.collections.remove(ax.collections[0]) | |
258 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
271 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
259 | vmin=self.zmin, |
|
272 | vmin=self.zmin, | |
260 | vmax=self.zmax, |
|
273 | vmax=self.zmax, | |
261 | cmap=self.cmaps[n], |
|
274 | cmap=self.cmaps[n], | |
262 | norm=colors.LogNorm() |
|
275 | norm=colors.LogNorm() | |
263 | ) |
|
276 | ) | |
264 |
|
277 | |||
265 |
|
278 | |||
266 | class ETempRTIPlot(RTIPlot): |
|
279 | class ETempRTIPlot(RTIPlot): | |
267 |
|
280 | |||
268 | ''' |
|
281 | ''' | |
269 | Plot for Electron Temperature |
|
282 | Plot for Electron Temperature | |
270 | ''' |
|
283 | ''' | |
271 |
|
284 | |||
272 | CODE = 'ETemp' |
|
285 | CODE = 'ETemp' | |
273 | colormap = 'jet' |
|
286 | colormap = 'jet' | |
274 |
|
287 | |||
275 | def setup(self): |
|
288 | def setup(self): | |
276 | self.xaxis = 'time' |
|
289 | self.xaxis = 'time' | |
277 | self.ncols = 1 |
|
290 | self.ncols = 1 | |
278 | self.nrows = self.data.shape(self.CODE)[0] |
|
291 | self.nrows = self.data.shape(self.CODE)[0] | |
279 | self.nplots = self.nrows |
|
292 | self.nplots = self.nrows | |
280 |
|
293 | |||
281 | self.ylabel = 'Range [km]' |
|
294 | self.ylabel = 'Range [km]' | |
282 | self.xlabel = 'Time (LT)' |
|
295 | self.xlabel = 'Time (LT)' | |
283 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
296 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
284 | if self.CODE == 'ETemp': |
|
297 | if self.CODE == 'ETemp': | |
285 | self.cb_label = 'Electron Temperature (K)' |
|
298 | self.cb_label = 'Electron Temperature (K)' | |
286 | self.titles = ['Electron Temperature RTI'] |
|
299 | self.titles = ['Electron Temperature RTI'] | |
287 | if self.CODE == 'ITemp': |
|
300 | if self.CODE == 'ITemp': | |
288 | self.cb_label = 'Ion Temperature (K)' |
|
301 | self.cb_label = 'Ion Temperature (K)' | |
289 | self.titles = ['Ion Temperature RTI'] |
|
302 | self.titles = ['Ion Temperature RTI'] | |
290 | if self.CODE == 'HeFracLP': |
|
303 | if self.CODE == 'HeFracLP': | |
291 | self.cb_label='He+ Fraction' |
|
304 | self.cb_label='He+ Fraction' | |
292 | self.titles = ['He+ Fraction RTI'] |
|
305 | self.titles = ['He+ Fraction RTI'] | |
293 | self.zmax=0.16 |
|
306 | self.zmax=0.16 | |
294 | if self.CODE== 'HFracLP': |
|
307 | if self.CODE== 'HFracLP': | |
295 | self.cb_label='H+ Fraction' |
|
308 | self.cb_label='H+ Fraction' | |
296 | self.titles = ['H+ Fraction RTI'] |
|
309 | self.titles = ['H+ Fraction RTI'] | |
297 |
|
310 | |||
298 | def update(self, dataOut): |
|
311 | def update(self, dataOut): | |
299 |
|
312 | |||
300 | data = {} |
|
313 | data = {} | |
301 | meta = {} |
|
314 | meta = {} | |
302 |
|
315 | |||
303 | data['ETemp'] = dataOut.ElecTempFinal |
|
316 | data['ETemp'] = dataOut.ElecTempFinal | |
304 |
|
317 | |||
305 | return data, meta |
|
318 | return data, meta | |
306 |
|
319 | |||
307 | def plot(self): |
|
320 | def plot(self): | |
308 |
|
321 | |||
309 | self.x = self.data.times |
|
322 | self.x = self.data.times | |
310 | self.y = self.data.yrange |
|
323 | self.y = self.data.yrange | |
311 |
|
324 | |||
312 |
|
325 | |||
313 | self.z = self.data[self.CODE] |
|
326 | self.z = self.data[self.CODE] | |
314 |
|
327 | |||
315 | self.z = numpy.ma.masked_invalid(self.z) |
|
328 | self.z = numpy.ma.masked_invalid(self.z) | |
316 |
|
329 | |||
317 | if self.decimation is None: |
|
330 | if self.decimation is None: | |
318 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
331 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
319 | else: |
|
332 | else: | |
320 | x, y, z = self.fill_gaps(*self.decimate()) |
|
333 | x, y, z = self.fill_gaps(*self.decimate()) | |
321 |
|
334 | |||
322 | for n, ax in enumerate(self.axes): |
|
335 | for n, ax in enumerate(self.axes): | |
323 |
|
336 | |||
324 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
337 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
325 | self.z[n]) |
|
338 | self.z[n]) | |
326 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
339 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
327 | self.z[n]) |
|
340 | self.z[n]) | |
328 |
|
341 | |||
329 | if ax.firsttime: |
|
342 | if ax.firsttime: | |
330 |
|
343 | |||
331 | if self.zlimits is not None: |
|
344 | if self.zlimits is not None: | |
332 | self.zmin, self.zmax = self.zlimits[n] |
|
345 | self.zmin, self.zmax = self.zlimits[n] | |
333 |
|
346 | |||
334 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
347 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
335 | vmin=self.zmin, |
|
348 | vmin=self.zmin, | |
336 | vmax=self.zmax, |
|
349 | vmax=self.zmax, | |
337 | cmap=self.cmaps[n] |
|
350 | cmap=self.cmaps[n] | |
338 | ) |
|
351 | ) | |
339 | #plt.tight_layout() |
|
352 | #plt.tight_layout() | |
340 |
|
353 | |||
341 | else: |
|
354 | else: | |
342 | if self.zlimits is not None: |
|
355 | if self.zlimits is not None: | |
343 | self.zmin, self.zmax = self.zlimits[n] |
|
356 | self.zmin, self.zmax = self.zlimits[n] | |
344 | ax.collections.remove(ax.collections[0]) |
|
357 | ax.collections.remove(ax.collections[0]) | |
345 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
358 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
346 | vmin=self.zmin, |
|
359 | vmin=self.zmin, | |
347 | vmax=self.zmax, |
|
360 | vmax=self.zmax, | |
348 | cmap=self.cmaps[n] |
|
361 | cmap=self.cmaps[n] | |
349 | ) |
|
362 | ) | |
350 |
|
363 | |||
351 |
|
364 | |||
352 | class ITempRTIPlot(ETempRTIPlot): |
|
365 | class ITempRTIPlot(ETempRTIPlot): | |
353 |
|
366 | |||
354 | ''' |
|
367 | ''' | |
355 | Plot for Ion Temperature |
|
368 | Plot for Ion Temperature | |
356 | ''' |
|
369 | ''' | |
357 |
|
370 | |||
358 | CODE = 'ITemp' |
|
371 | CODE = 'ITemp' | |
359 | colormap = 'jet' |
|
372 | colormap = 'jet' | |
360 | plot_name = 'Ion Temperature' |
|
373 | plot_name = 'Ion Temperature' | |
361 |
|
374 | |||
362 | def update(self, dataOut): |
|
375 | def update(self, dataOut): | |
363 |
|
376 | |||
364 | data = {} |
|
377 | data = {} | |
365 | meta = {} |
|
378 | meta = {} | |
366 |
|
379 | |||
367 | data['ITemp'] = dataOut.IonTempFinal |
|
380 | data['ITemp'] = dataOut.IonTempFinal | |
368 |
|
381 | |||
369 | return data, meta |
|
382 | return data, meta | |
370 |
|
383 | |||
371 |
|
384 | |||
372 | class HFracRTIPlot(ETempRTIPlot): |
|
385 | class HFracRTIPlot(ETempRTIPlot): | |
373 |
|
386 | |||
374 | ''' |
|
387 | ''' | |
375 | Plot for H+ LP |
|
388 | Plot for H+ LP | |
376 | ''' |
|
389 | ''' | |
377 |
|
390 | |||
378 | CODE = 'HFracLP' |
|
391 | CODE = 'HFracLP' | |
379 | colormap = 'jet' |
|
392 | colormap = 'jet' | |
380 | plot_name = 'H+ Frac' |
|
393 | plot_name = 'H+ Frac' | |
381 |
|
394 | |||
382 | def update(self, dataOut): |
|
395 | def update(self, dataOut): | |
383 |
|
396 | |||
384 | data = {} |
|
397 | data = {} | |
385 | meta = {} |
|
398 | meta = {} | |
386 | data['HFracLP'] = dataOut.PhyFinal |
|
399 | data['HFracLP'] = dataOut.PhyFinal | |
387 |
|
400 | |||
388 | return data, meta |
|
401 | return data, meta | |
389 |
|
402 | |||
390 |
|
403 | |||
391 | class HeFracRTIPlot(ETempRTIPlot): |
|
404 | class HeFracRTIPlot(ETempRTIPlot): | |
392 |
|
405 | |||
393 | ''' |
|
406 | ''' | |
394 | Plot for He+ LP |
|
407 | Plot for He+ LP | |
395 | ''' |
|
408 | ''' | |
396 |
|
409 | |||
397 | CODE = 'HeFracLP' |
|
410 | CODE = 'HeFracLP' | |
398 | colormap = 'jet' |
|
411 | colormap = 'jet' | |
399 | plot_name = 'He+ Frac' |
|
412 | plot_name = 'He+ Frac' | |
400 |
|
413 | |||
401 | def update(self, dataOut): |
|
414 | def update(self, dataOut): | |
402 |
|
415 | |||
403 | data = {} |
|
416 | data = {} | |
404 | meta = {} |
|
417 | meta = {} | |
405 | data['HeFracLP'] = dataOut.PheFinal |
|
418 | data['HeFracLP'] = dataOut.PheFinal | |
406 |
|
419 | |||
407 | return data, meta |
|
420 | return data, meta | |
408 |
|
421 | |||
409 |
|
422 | |||
410 | class TempsDPPlot(Plot): |
|
423 | class TempsDPPlot(Plot): | |
411 | ''' |
|
424 | ''' | |
412 | Plot for Electron - Ion Temperatures |
|
425 | Plot for Electron - Ion Temperatures | |
413 | ''' |
|
426 | ''' | |
414 |
|
427 | |||
415 | CODE = 'tempsDP' |
|
428 | CODE = 'tempsDP' | |
416 | #plot_name = 'Temperatures' |
|
429 | #plot_name = 'Temperatures' | |
417 | plot_type = 'scatterbuffer' |
|
430 | plot_type = 'scatterbuffer' | |
418 |
|
431 | |||
419 | def setup(self): |
|
432 | def setup(self): | |
420 |
|
433 | |||
421 | self.ncols = 1 |
|
434 | self.ncols = 1 | |
422 | self.nrows = 1 |
|
435 | self.nrows = 1 | |
423 | self.nplots = 1 |
|
436 | self.nplots = 1 | |
424 | self.ylabel = 'Range [km]' |
|
437 | self.ylabel = 'Range [km]' | |
425 | self.xlabel = 'Temperature (K)' |
|
438 | self.xlabel = 'Temperature (K)' | |
426 | self.titles = ['Electron/Ion Temperatures'] |
|
439 | self.titles = ['Electron/Ion Temperatures'] | |
427 | self.width = 3.5 |
|
440 | self.width = 3.5 | |
428 | self.height = 5.5 |
|
441 | self.height = 5.5 | |
429 | self.colorbar = False |
|
442 | self.colorbar = False | |
430 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
443 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
431 |
|
444 | |||
432 | def update(self, dataOut): |
|
445 | def update(self, dataOut): | |
433 | data = {} |
|
446 | data = {} | |
434 | meta = {} |
|
447 | meta = {} | |
435 |
|
448 | |||
436 | data['Te'] = dataOut.te2 |
|
449 | data['Te'] = dataOut.te2 | |
437 | data['Ti'] = dataOut.ti2 |
|
450 | data['Ti'] = dataOut.ti2 | |
438 | data['Te_error'] = dataOut.ete2 |
|
451 | data['Te_error'] = dataOut.ete2 | |
439 | data['Ti_error'] = dataOut.eti2 |
|
452 | data['Ti_error'] = dataOut.eti2 | |
440 |
|
453 | |||
441 | meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] |
|
454 | meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] | |
442 |
|
455 | |||
443 | return data, meta |
|
456 | return data, meta | |
444 |
|
457 | |||
445 | def plot(self): |
|
458 | def plot(self): | |
446 |
|
459 | |||
447 | y = self.data.yrange |
|
460 | y = self.data.yrange | |
448 |
|
461 | |||
449 | self.xmin = -100 |
|
462 | self.xmin = -100 | |
450 | self.xmax = 5000 |
|
463 | self.xmax = 5000 | |
451 |
|
464 | |||
452 | ax = self.axes[0] |
|
465 | ax = self.axes[0] | |
453 |
|
466 | |||
454 | data = self.data[-1] |
|
467 | data = self.data[-1] | |
455 |
|
468 | |||
456 | Te = data['Te'] |
|
469 | Te = data['Te'] | |
457 | Ti = data['Ti'] |
|
470 | Ti = data['Ti'] | |
458 | errTe = data['Te_error'] |
|
471 | errTe = data['Te_error'] | |
459 | errTi = data['Ti_error'] |
|
472 | errTi = data['Ti_error'] | |
460 |
|
473 | |||
461 | if ax.firsttime: |
|
474 | if ax.firsttime: | |
462 | ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
475 | ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
463 | ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
476 | ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
464 | plt.legend(loc='lower right') |
|
477 | plt.legend(loc='lower right') | |
465 | self.ystep_given = 50 |
|
478 | self.ystep_given = 50 | |
466 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
479 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
467 | ax.grid(which='minor') |
|
480 | ax.grid(which='minor') | |
468 |
|
481 | |||
469 | else: |
|
482 | else: | |
470 | self.clear_figures() |
|
483 | self.clear_figures() | |
471 | ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
484 | ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
472 | ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
485 | ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
473 | plt.legend(loc='lower right') |
|
486 | plt.legend(loc='lower right') | |
474 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
487 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
475 |
|
488 | |||
476 |
|
489 | |||
477 | class TempsHPPlot(Plot): |
|
490 | class TempsHPPlot(Plot): | |
478 | ''' |
|
491 | ''' | |
479 | Plot for Temperatures Hybrid Experiment |
|
492 | Plot for Temperatures Hybrid Experiment | |
480 | ''' |
|
493 | ''' | |
481 |
|
494 | |||
482 | CODE = 'temps_LP' |
|
495 | CODE = 'temps_LP' | |
483 | #plot_name = 'Temperatures' |
|
496 | #plot_name = 'Temperatures' | |
484 | plot_type = 'scatterbuffer' |
|
497 | plot_type = 'scatterbuffer' | |
485 |
|
498 | |||
486 |
|
499 | |||
487 | def setup(self): |
|
500 | def setup(self): | |
488 |
|
501 | |||
489 | self.ncols = 1 |
|
502 | self.ncols = 1 | |
490 | self.nrows = 1 |
|
503 | self.nrows = 1 | |
491 | self.nplots = 1 |
|
504 | self.nplots = 1 | |
492 | self.ylabel = 'Range [km]' |
|
505 | self.ylabel = 'Range [km]' | |
493 | self.xlabel = 'Temperature (K)' |
|
506 | self.xlabel = 'Temperature (K)' | |
494 | self.titles = ['Electron/Ion Temperatures'] |
|
507 | self.titles = ['Electron/Ion Temperatures'] | |
495 | self.width = 3.5 |
|
508 | self.width = 3.5 | |
496 | self.height = 6.5 |
|
509 | self.height = 6.5 | |
497 | self.colorbar = False |
|
510 | self.colorbar = False | |
498 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
511 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
499 |
|
512 | |||
500 | def update(self, dataOut): |
|
513 | def update(self, dataOut): | |
501 | data = {} |
|
514 | data = {} | |
502 | meta = {} |
|
515 | meta = {} | |
503 |
|
516 | |||
504 |
|
517 | |||
505 | data['Te'] = numpy.concatenate((dataOut.te2[:dataOut.cut],dataOut.te[dataOut.cut:])) |
|
518 | data['Te'] = numpy.concatenate((dataOut.te2[:dataOut.cut],dataOut.te[dataOut.cut:])) | |
506 | data['Ti'] = numpy.concatenate((dataOut.ti2[:dataOut.cut],dataOut.ti[dataOut.cut:])) |
|
519 | data['Ti'] = numpy.concatenate((dataOut.ti2[:dataOut.cut],dataOut.ti[dataOut.cut:])) | |
507 | data['Te_error'] = numpy.concatenate((dataOut.ete2[:dataOut.cut],dataOut.ete[dataOut.cut:])) |
|
520 | data['Te_error'] = numpy.concatenate((dataOut.ete2[:dataOut.cut],dataOut.ete[dataOut.cut:])) | |
508 | data['Ti_error'] = numpy.concatenate((dataOut.eti2[:dataOut.cut],dataOut.eti[dataOut.cut:])) |
|
521 | data['Ti_error'] = numpy.concatenate((dataOut.eti2[:dataOut.cut],dataOut.eti[dataOut.cut:])) | |
509 |
|
522 | |||
510 | meta['yrange'] = dataOut.heightList[0:dataOut.NACF] |
|
523 | meta['yrange'] = dataOut.heightList[0:dataOut.NACF] | |
511 |
|
524 | |||
512 | return data, meta |
|
525 | return data, meta | |
513 |
|
526 | |||
514 | def plot(self): |
|
527 | def plot(self): | |
515 |
|
528 | |||
516 |
|
529 | |||
517 | self.y = self.data.yrange |
|
530 | self.y = self.data.yrange | |
518 | self.xmin = -100 |
|
531 | self.xmin = -100 | |
519 | self.xmax = 4500 |
|
532 | self.xmax = 4500 | |
520 | ax = self.axes[0] |
|
533 | ax = self.axes[0] | |
521 |
|
534 | |||
522 | data = self.data[-1] |
|
535 | data = self.data[-1] | |
523 |
|
536 | |||
524 | Te = data['Te'] |
|
537 | Te = data['Te'] | |
525 | Ti = data['Ti'] |
|
538 | Ti = data['Ti'] | |
526 | errTe = data['Te_error'] |
|
539 | errTe = data['Te_error'] | |
527 | errTi = data['Ti_error'] |
|
540 | errTi = data['Ti_error'] | |
528 |
|
541 | |||
529 | if ax.firsttime: |
|
542 | if ax.firsttime: | |
530 |
|
543 | |||
531 | ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
544 | ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
532 | ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
545 | ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
533 | plt.legend(loc='lower right') |
|
546 | plt.legend(loc='lower right') | |
534 | self.ystep_given = 200 |
|
547 | self.ystep_given = 200 | |
535 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
548 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
536 | ax.grid(which='minor') |
|
549 | ax.grid(which='minor') | |
537 |
|
550 | |||
538 | else: |
|
551 | else: | |
539 | self.clear_figures() |
|
552 | self.clear_figures() | |
540 | ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
553 | ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
541 | ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
554 | ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
542 | plt.legend(loc='lower right') |
|
555 | plt.legend(loc='lower right') | |
543 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
556 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
544 | ax.grid(which='minor') |
|
557 | ax.grid(which='minor') | |
545 |
|
558 | |||
546 |
|
559 | |||
547 | class FracsHPPlot(Plot): |
|
560 | class FracsHPPlot(Plot): | |
548 | ''' |
|
561 | ''' | |
549 | Plot for Composition LP |
|
562 | Plot for Composition LP | |
550 | ''' |
|
563 | ''' | |
551 |
|
564 | |||
552 | CODE = 'fracs_LP' |
|
565 | CODE = 'fracs_LP' | |
553 | plot_type = 'scatterbuffer' |
|
566 | plot_type = 'scatterbuffer' | |
554 |
|
567 | |||
555 |
|
568 | |||
556 | def setup(self): |
|
569 | def setup(self): | |
557 |
|
570 | |||
558 | self.ncols = 1 |
|
571 | self.ncols = 1 | |
559 | self.nrows = 1 |
|
572 | self.nrows = 1 | |
560 | self.nplots = 1 |
|
573 | self.nplots = 1 | |
561 | self.ylabel = 'Range [km]' |
|
574 | self.ylabel = 'Range [km]' | |
562 | self.xlabel = 'Frac' |
|
575 | self.xlabel = 'Frac' | |
563 | self.titles = ['Composition'] |
|
576 | self.titles = ['Composition'] | |
564 | self.width = 3.5 |
|
577 | self.width = 3.5 | |
565 | self.height = 6.5 |
|
578 | self.height = 6.5 | |
566 | self.colorbar = False |
|
579 | self.colorbar = False | |
567 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
580 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
568 |
|
581 | |||
569 | def update(self, dataOut): |
|
582 | def update(self, dataOut): | |
570 | data = {} |
|
583 | data = {} | |
571 | meta = {} |
|
584 | meta = {} | |
572 |
|
585 | |||
573 | #aux_nan=numpy.zeros(dataOut.cut,'float32') |
|
586 | #aux_nan=numpy.zeros(dataOut.cut,'float32') | |
574 | #aux_nan[:]=numpy.nan |
|
587 | #aux_nan[:]=numpy.nan | |
575 | #data['ph'] = numpy.concatenate((aux_nan,dataOut.ph[dataOut.cut:])) |
|
588 | #data['ph'] = numpy.concatenate((aux_nan,dataOut.ph[dataOut.cut:])) | |
576 | #data['eph'] = numpy.concatenate((aux_nan,dataOut.eph[dataOut.cut:])) |
|
589 | #data['eph'] = numpy.concatenate((aux_nan,dataOut.eph[dataOut.cut:])) | |
577 |
|
590 | |||
578 | data['ph'] = dataOut.ph[dataOut.cut:] |
|
591 | data['ph'] = dataOut.ph[dataOut.cut:] | |
579 | data['eph'] = dataOut.eph[dataOut.cut:] |
|
592 | data['eph'] = dataOut.eph[dataOut.cut:] | |
580 | data['phe'] = dataOut.phe[dataOut.cut:] |
|
593 | data['phe'] = dataOut.phe[dataOut.cut:] | |
581 | data['ephe'] = dataOut.ephe[dataOut.cut:] |
|
594 | data['ephe'] = dataOut.ephe[dataOut.cut:] | |
582 |
|
595 | |||
583 | data['cut'] = dataOut.cut |
|
596 | data['cut'] = dataOut.cut | |
584 |
|
597 | |||
585 | meta['yrange'] = dataOut.heightList[0:dataOut.NACF] |
|
598 | meta['yrange'] = dataOut.heightList[0:dataOut.NACF] | |
586 |
|
599 | |||
587 |
|
600 | |||
588 | return data, meta |
|
601 | return data, meta | |
589 |
|
602 | |||
590 | def plot(self): |
|
603 | def plot(self): | |
591 |
|
604 | |||
592 | data = self.data[-1] |
|
605 | data = self.data[-1] | |
593 |
|
606 | |||
594 | ph = data['ph'] |
|
607 | ph = data['ph'] | |
595 | eph = data['eph'] |
|
608 | eph = data['eph'] | |
596 | phe = data['phe'] |
|
609 | phe = data['phe'] | |
597 | ephe = data['ephe'] |
|
610 | ephe = data['ephe'] | |
598 | cut = data['cut'] |
|
611 | cut = data['cut'] | |
599 | self.y = self.data.yrange |
|
612 | self.y = self.data.yrange | |
600 |
|
613 | |||
601 | self.xmin = 0 |
|
614 | self.xmin = 0 | |
602 | self.xmax = 1 |
|
615 | self.xmax = 1 | |
603 | ax = self.axes[0] |
|
616 | ax = self.axes[0] | |
604 |
|
617 | |||
605 | if ax.firsttime: |
|
618 | if ax.firsttime: | |
606 |
|
619 | |||
607 | ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') |
|
620 | ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') | |
608 | ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') |
|
621 | ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') | |
609 | plt.legend(loc='lower right') |
|
622 | plt.legend(loc='lower right') | |
610 | self.xstep_given = 0.2 |
|
623 | self.xstep_given = 0.2 | |
611 | self.ystep_given = 200 |
|
624 | self.ystep_given = 200 | |
612 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
625 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
613 | ax.grid(which='minor') |
|
626 | ax.grid(which='minor') | |
614 |
|
627 | |||
615 | else: |
|
628 | else: | |
616 | self.clear_figures() |
|
629 | self.clear_figures() | |
617 | ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') |
|
630 | ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') | |
618 | ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') |
|
631 | ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') | |
619 | plt.legend(loc='lower right') |
|
632 | plt.legend(loc='lower right') | |
620 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
633 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
|
634 | ax.grid(which='minor') | |||
621 |
|
635 | |||
622 | class EDensityPlot(Plot): |
|
636 | class EDensityPlot(Plot): | |
623 | ''' |
|
637 | ''' | |
624 | Plot for electron density |
|
638 | Plot for electron density | |
625 | ''' |
|
639 | ''' | |
626 |
|
640 | |||
627 | CODE = 'den' |
|
641 | CODE = 'den' | |
628 | #plot_name = 'Electron Density' |
|
642 | #plot_name = 'Electron Density' | |
629 | plot_type = 'scatterbuffer' |
|
643 | plot_type = 'scatterbuffer' | |
630 |
|
644 | |||
631 | def setup(self): |
|
645 | def setup(self): | |
632 |
|
646 | |||
633 | self.ncols = 1 |
|
647 | self.ncols = 1 | |
634 | self.nrows = 1 |
|
648 | self.nrows = 1 | |
635 | self.nplots = 1 |
|
649 | self.nplots = 1 | |
636 | self.ylabel = 'Range [km]' |
|
650 | self.ylabel = 'Range [km]' | |
637 | self.xlabel = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' |
|
651 | self.xlabel = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' | |
638 | self.titles = ['Electron Density'] |
|
652 | self.titles = ['Electron Density'] | |
639 | self.width = 3.5 |
|
653 | self.width = 3.5 | |
640 | self.height = 5.5 |
|
654 | self.height = 5.5 | |
641 | self.colorbar = False |
|
655 | self.colorbar = False | |
642 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
656 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
643 |
|
657 | |||
644 | def update(self, dataOut): |
|
658 | def update(self, dataOut): | |
645 | data = {} |
|
659 | data = {} | |
646 | meta = {} |
|
660 | meta = {} | |
647 |
|
661 | |||
648 | data['den_power'] = dataOut.ph2[:dataOut.NSHTS] |
|
662 | data['den_power'] = dataOut.ph2[:dataOut.NSHTS] | |
649 | data['den_Faraday'] = dataOut.dphi[:dataOut.NSHTS] |
|
663 | data['den_Faraday'] = dataOut.dphi[:dataOut.NSHTS] | |
650 | data['den_error'] = dataOut.sdp2[:dataOut.NSHTS] |
|
664 | data['den_error'] = dataOut.sdp2[:dataOut.NSHTS] | |
651 | #data['err_Faraday'] = dataOut.sdn1[:dataOut.NSHTS] |
|
665 | #data['err_Faraday'] = dataOut.sdn1[:dataOut.NSHTS] | |
652 |
|
666 | |||
653 | data['NSHTS'] = dataOut.NSHTS |
|
667 | data['NSHTS'] = dataOut.NSHTS | |
654 |
|
668 | |||
655 | meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] |
|
669 | meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] | |
656 |
|
670 | |||
657 | return data, meta |
|
671 | return data, meta | |
658 |
|
672 | |||
659 | def plot(self): |
|
673 | def plot(self): | |
660 |
|
674 | |||
661 | y = self.data.yrange |
|
675 | y = self.data.yrange | |
662 |
|
676 | |||
663 | self.xmin = 1e3 |
|
677 | self.xmin = 1e3 | |
664 | self.xmax = 1e7 |
|
678 | self.xmax = 1e7 | |
665 |
|
679 | |||
666 | ax = self.axes[0] |
|
680 | ax = self.axes[0] | |
667 |
|
681 | |||
668 | data = self.data[-1] |
|
682 | data = self.data[-1] | |
669 |
|
683 | |||
670 | DenPow = data['den_power'] |
|
684 | DenPow = data['den_power'] | |
671 | DenFar = data['den_Faraday'] |
|
685 | DenFar = data['den_Faraday'] | |
672 | errDenPow = data['den_error'] |
|
686 | errDenPow = data['den_error'] | |
673 | #errFaraday = data['err_Faraday'] |
|
687 | #errFaraday = data['err_Faraday'] | |
674 |
|
688 | |||
675 | NSHTS = data['NSHTS'] |
|
689 | NSHTS = data['NSHTS'] | |
676 |
|
690 | |||
677 | if self.CODE == 'denLP': |
|
691 | if self.CODE == 'denLP': | |
678 | DenPowLP = data['den_LP'] |
|
692 | DenPowLP = data['den_LP'] | |
679 | errDenPowLP = data['den_LP_error'] |
|
693 | errDenPowLP = data['den_LP_error'] | |
680 | cut = data['cut'] |
|
694 | cut = data['cut'] | |
681 |
|
695 | |||
682 | if ax.firsttime: |
|
696 | if ax.firsttime: | |
683 | self.autoxticks=False |
|
697 | self.autoxticks=False | |
684 | #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
698 | #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) | |
685 | ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2) |
|
699 | ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2) | |
686 | #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) |
|
700 | #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) | |
687 | ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2) |
|
701 | ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2) | |
688 |
|
702 | |||
689 | if self.CODE=='denLP': |
|
703 | if self.CODE=='denLP': | |
690 | ax.errorbar(DenPowLP[cut:], y[cut:], xerr=errDenPowLP[cut:], fmt='r^-',elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) |
|
704 | ax.errorbar(DenPowLP[cut:], y[cut:], xerr=errDenPowLP[cut:], fmt='r^-',elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) | |
691 |
|
705 | |||
692 | plt.legend(loc='upper left',fontsize=8.5) |
|
706 | plt.legend(loc='upper left',fontsize=8.5) | |
693 | #plt.legend(loc='lower left',fontsize=8.5) |
|
707 | #plt.legend(loc='lower left',fontsize=8.5) | |
694 | ax.set_xscale("log", nonposx='clip') |
|
708 | ax.set_xscale("log", nonposx='clip') | |
695 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) |
|
709 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) | |
696 | self.ystep_given=100 |
|
710 | self.ystep_given=100 | |
697 | if self.CODE=='denLP': |
|
711 | if self.CODE=='denLP': | |
698 | self.ystep_given=200 |
|
712 | self.ystep_given=200 | |
699 | ax.set_yticks(grid_y_ticks,minor=True) |
|
713 | ax.set_yticks(grid_y_ticks,minor=True) | |
700 | ax.grid(which='minor') |
|
714 | ax.grid(which='minor') | |
701 |
|
715 | |||
702 | else: |
|
716 | else: | |
703 | dataBefore = self.data[-2] |
|
717 | dataBefore = self.data[-2] | |
704 | DenPowBefore = dataBefore['den_power'] |
|
718 | DenPowBefore = dataBefore['den_power'] | |
705 | self.clear_figures() |
|
719 | self.clear_figures() | |
706 | #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
720 | #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) | |
707 | ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2) |
|
721 | ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2) | |
708 | #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) |
|
722 | #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) | |
709 | ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2) |
|
723 | ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2) | |
710 | ax.errorbar(DenPowBefore, y[:NSHTS], elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed") |
|
724 | ax.errorbar(DenPowBefore, y[:NSHTS], elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed") | |
711 |
|
725 | |||
712 | if self.CODE=='denLP': |
|
726 | if self.CODE=='denLP': | |
713 | ax.errorbar(DenPowLP[cut:], y[cut:], fmt='r^-', xerr=errDenPowLP[cut:],elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) |
|
727 | ax.errorbar(DenPowLP[cut:], y[cut:], fmt='r^-', xerr=errDenPowLP[cut:],elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) | |
714 |
|
728 | |||
715 | ax.set_xscale("log", nonposx='clip') |
|
729 | ax.set_xscale("log", nonposx='clip') | |
716 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) |
|
730 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) | |
717 | ax.set_yticks(grid_y_ticks,minor=True) |
|
731 | ax.set_yticks(grid_y_ticks,minor=True) | |
718 | ax.grid(which='minor') |
|
732 | ax.grid(which='minor') | |
719 | plt.legend(loc='upper left',fontsize=8.5) |
|
733 | plt.legend(loc='upper left',fontsize=8.5) | |
720 | #plt.legend(loc='lower left',fontsize=8.5) |
|
734 | #plt.legend(loc='lower left',fontsize=8.5) | |
721 |
|
735 | |||
722 | class FaradayAnglePlot(Plot): |
|
736 | class FaradayAnglePlot(Plot): | |
723 | ''' |
|
737 | ''' | |
724 | Plot for electron density |
|
738 | Plot for electron density | |
725 | ''' |
|
739 | ''' | |
726 |
|
740 | |||
727 | CODE = 'angle' |
|
741 | CODE = 'angle' | |
728 | plot_name = 'Faraday Angle' |
|
742 | plot_name = 'Faraday Angle' | |
729 | plot_type = 'scatterbuffer' |
|
743 | plot_type = 'scatterbuffer' | |
730 |
|
744 | |||
731 | def setup(self): |
|
745 | def setup(self): | |
732 |
|
746 | |||
733 | self.ncols = 1 |
|
747 | self.ncols = 1 | |
734 | self.nrows = 1 |
|
748 | self.nrows = 1 | |
735 | self.nplots = 1 |
|
749 | self.nplots = 1 | |
736 | self.ylabel = 'Range [km]' |
|
750 | self.ylabel = 'Range [km]' | |
737 | self.xlabel = 'Faraday Angle (º)' |
|
751 | self.xlabel = 'Faraday Angle (º)' | |
738 | self.titles = ['Electron Density'] |
|
752 | self.titles = ['Electron Density'] | |
739 | self.width = 3.5 |
|
753 | self.width = 3.5 | |
740 | self.height = 5.5 |
|
754 | self.height = 5.5 | |
741 | self.colorbar = False |
|
755 | self.colorbar = False | |
742 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
756 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
743 |
|
757 | |||
744 | def update(self, dataOut): |
|
758 | def update(self, dataOut): | |
745 | data = {} |
|
759 | data = {} | |
746 | meta = {} |
|
760 | meta = {} | |
747 |
|
761 | |||
748 | data['angle'] = numpy.degrees(dataOut.phi) |
|
762 | data['angle'] = numpy.degrees(dataOut.phi) | |
749 | #''' |
|
763 | #''' | |
750 | print(dataOut.phi_uwrp) |
|
764 | print(dataOut.phi_uwrp) | |
751 | print(data['angle']) |
|
765 | print(data['angle']) | |
752 | exit(1) |
|
766 | exit(1) | |
753 | #''' |
|
767 | #''' | |
754 | data['dphi'] = dataOut.dphi_uc*10 |
|
768 | data['dphi'] = dataOut.dphi_uc*10 | |
755 | #print(dataOut.dphi) |
|
769 | #print(dataOut.dphi) | |
756 |
|
770 | |||
757 | #data['NSHTS'] = dataOut.NSHTS |
|
771 | #data['NSHTS'] = dataOut.NSHTS | |
758 |
|
772 | |||
759 | #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] |
|
773 | #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] | |
760 |
|
774 | |||
761 | return data, meta |
|
775 | return data, meta | |
762 |
|
776 | |||
763 | def plot(self): |
|
777 | def plot(self): | |
764 |
|
778 | |||
765 | data = self.data[-1] |
|
779 | data = self.data[-1] | |
766 | self.x = data[self.CODE] |
|
780 | self.x = data[self.CODE] | |
767 | dphi = data['dphi'] |
|
781 | dphi = data['dphi'] | |
768 | self.y = self.data.yrange |
|
782 | self.y = self.data.yrange | |
769 | self.xmin = -360#-180 |
|
783 | self.xmin = -360#-180 | |
770 | self.xmax = 360#180 |
|
784 | self.xmax = 360#180 | |
771 | ax = self.axes[0] |
|
785 | ax = self.axes[0] | |
772 |
|
786 | |||
773 | if ax.firsttime: |
|
787 | if ax.firsttime: | |
774 | self.autoxticks=False |
|
788 | self.autoxticks=False | |
775 | #if self.CODE=='den': |
|
789 | #if self.CODE=='den': | |
776 | ax.plot(self.x, self.y,marker='o',color='g',linewidth=1.0,markersize=2) |
|
790 | ax.plot(self.x, self.y,marker='o',color='g',linewidth=1.0,markersize=2) | |
777 | ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2) |
|
791 | ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2) | |
778 |
|
792 | |||
779 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) |
|
793 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) | |
780 | self.ystep_given=100 |
|
794 | self.ystep_given=100 | |
781 | if self.CODE=='denLP': |
|
795 | if self.CODE=='denLP': | |
782 | self.ystep_given=200 |
|
796 | self.ystep_given=200 | |
783 | ax.set_yticks(grid_y_ticks,minor=True) |
|
797 | ax.set_yticks(grid_y_ticks,minor=True) | |
784 | ax.grid(which='minor') |
|
798 | ax.grid(which='minor') | |
785 | #plt.tight_layout() |
|
799 | #plt.tight_layout() | |
786 | else: |
|
800 | else: | |
787 |
|
801 | |||
788 | self.clear_figures() |
|
802 | self.clear_figures() | |
789 | #if self.CODE=='den': |
|
803 | #if self.CODE=='den': | |
790 | #print(numpy.shape(self.x)) |
|
804 | #print(numpy.shape(self.x)) | |
791 | ax.plot(self.x, self.y, marker='o',color='g',linewidth=1.0, markersize=2) |
|
805 | ax.plot(self.x, self.y, marker='o',color='g',linewidth=1.0, markersize=2) | |
792 | ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2) |
|
806 | ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2) | |
793 |
|
807 | |||
794 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) |
|
808 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) | |
795 | ax.set_yticks(grid_y_ticks,minor=True) |
|
809 | ax.set_yticks(grid_y_ticks,minor=True) | |
796 | ax.grid(which='minor') |
|
810 | ax.grid(which='minor') | |
797 |
|
811 | |||
798 | class EDensityHPPlot(EDensityPlot): |
|
812 | class EDensityHPPlot(EDensityPlot): | |
799 |
|
813 | |||
800 | ''' |
|
814 | ''' | |
801 | Plot for Electron Density Hybrid Experiment |
|
815 | Plot for Electron Density Hybrid Experiment | |
802 | ''' |
|
816 | ''' | |
803 |
|
817 | |||
804 | CODE = 'denLP' |
|
818 | CODE = 'denLP' | |
805 | plot_name = 'Electron Density' |
|
819 | plot_name = 'Electron Density' | |
806 | plot_type = 'scatterbuffer' |
|
820 | plot_type = 'scatterbuffer' | |
807 |
|
821 | |||
808 | def update(self, dataOut): |
|
822 | def update(self, dataOut): | |
809 | data = {} |
|
823 | data = {} | |
810 | meta = {} |
|
824 | meta = {} | |
811 |
|
825 | |||
812 | data['den_power'] = dataOut.ph2[:dataOut.NSHTS] |
|
826 | data['den_power'] = dataOut.ph2[:dataOut.NSHTS] | |
813 | data['den_Faraday']=dataOut.dphi[:dataOut.NSHTS] |
|
827 | data['den_Faraday']=dataOut.dphi[:dataOut.NSHTS] | |
814 | data['den_error']=dataOut.sdp2[:dataOut.NSHTS] |
|
828 | data['den_error']=dataOut.sdp2[:dataOut.NSHTS] | |
815 | data['den_LP']=dataOut.ne[:dataOut.NACF] |
|
829 | data['den_LP']=dataOut.ne[:dataOut.NACF] | |
816 | data['den_LP_error']=dataOut.ene[:dataOut.NACF]*dataOut.ne[:dataOut.NACF]*0.434 |
|
830 | data['den_LP_error']=dataOut.ene[:dataOut.NACF]*dataOut.ne[:dataOut.NACF]*0.434 | |
817 | #self.ene=10**dataOut.ene[:dataOut.NACF] |
|
831 | #self.ene=10**dataOut.ene[:dataOut.NACF] | |
818 | data['NSHTS']=dataOut.NSHTS |
|
832 | data['NSHTS']=dataOut.NSHTS | |
819 | data['cut']=dataOut.cut |
|
833 | data['cut']=dataOut.cut | |
820 |
|
834 | |||
821 | return data, meta |
|
835 | return data, meta | |
822 |
|
836 | |||
823 |
|
837 | |||
824 | class ACFsPlot(Plot): |
|
838 | class ACFsPlot(Plot): | |
825 | ''' |
|
839 | ''' | |
826 | Plot for ACFs Double Pulse Experiment |
|
840 | Plot for ACFs Double Pulse Experiment | |
827 | ''' |
|
841 | ''' | |
828 |
|
842 | |||
829 | CODE = 'acfs' |
|
843 | CODE = 'acfs' | |
830 | #plot_name = 'ACF' |
|
844 | #plot_name = 'ACF' | |
831 | plot_type = 'scatterbuffer' |
|
845 | plot_type = 'scatterbuffer' | |
832 |
|
846 | |||
833 |
|
847 | |||
834 | def setup(self): |
|
848 | def setup(self): | |
835 | self.ncols = 1 |
|
849 | self.ncols = 1 | |
836 | self.nrows = 1 |
|
850 | self.nrows = 1 | |
837 | self.nplots = 1 |
|
851 | self.nplots = 1 | |
838 | self.ylabel = 'Range [km]' |
|
852 | self.ylabel = 'Range [km]' | |
839 | self.xlabel = 'Lag (ms)' |
|
853 | self.xlabel = 'Lag (ms)' | |
840 | self.titles = ['ACFs'] |
|
854 | self.titles = ['ACFs'] | |
841 | self.width = 3.5 |
|
855 | self.width = 3.5 | |
842 | self.height = 5.5 |
|
856 | self.height = 5.5 | |
843 | self.colorbar = False |
|
857 | self.colorbar = False | |
844 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
858 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
845 |
|
859 | |||
846 | def update(self, dataOut): |
|
860 | def update(self, dataOut): | |
847 | data = {} |
|
861 | data = {} | |
848 | meta = {} |
|
862 | meta = {} | |
849 |
|
863 | |||
850 | data['ACFs'] = dataOut.acfs_to_plot |
|
864 | data['ACFs'] = dataOut.acfs_to_plot | |
851 | data['ACFs_error'] = dataOut.acfs_error_to_plot |
|
865 | data['ACFs_error'] = dataOut.acfs_error_to_plot | |
852 | data['lags'] = dataOut.lags_to_plot |
|
866 | data['lags'] = dataOut.lags_to_plot | |
853 | data['Lag_contaminated_1'] = dataOut.x_igcej_to_plot |
|
867 | data['Lag_contaminated_1'] = dataOut.x_igcej_to_plot | |
854 | data['Lag_contaminated_2'] = dataOut.x_ibad_to_plot |
|
868 | data['Lag_contaminated_2'] = dataOut.x_ibad_to_plot | |
855 | data['Height_contaminated_1'] = dataOut.y_igcej_to_plot |
|
869 | data['Height_contaminated_1'] = dataOut.y_igcej_to_plot | |
856 | data['Height_contaminated_2'] = dataOut.y_ibad_to_plot |
|
870 | data['Height_contaminated_2'] = dataOut.y_ibad_to_plot | |
857 |
|
871 | |||
858 | meta['yrange'] = numpy.array([]) |
|
872 | meta['yrange'] = numpy.array([]) | |
859 | #meta['NSHTS'] = dataOut.NSHTS |
|
873 | #meta['NSHTS'] = dataOut.NSHTS | |
860 | #meta['DPL'] = dataOut.DPL |
|
874 | #meta['DPL'] = dataOut.DPL | |
861 | data['NSHTS'] = dataOut.NSHTS #This is metadata |
|
875 | data['NSHTS'] = dataOut.NSHTS #This is metadata | |
862 | data['DPL'] = dataOut.DPL #This is metadata |
|
876 | data['DPL'] = dataOut.DPL #This is metadata | |
863 |
|
877 | |||
864 | return data, meta |
|
878 | return data, meta | |
865 |
|
879 | |||
866 | def plot(self): |
|
880 | def plot(self): | |
867 |
|
881 | |||
868 | data = self.data[-1] |
|
882 | data = self.data[-1] | |
869 | #NSHTS = self.meta['NSHTS'] |
|
883 | #NSHTS = self.meta['NSHTS'] | |
870 | #DPL = self.meta['DPL'] |
|
884 | #DPL = self.meta['DPL'] | |
871 | NSHTS = data['NSHTS'] #This is metadata |
|
885 | NSHTS = data['NSHTS'] #This is metadata | |
872 | DPL = data['DPL'] #This is metadata |
|
886 | DPL = data['DPL'] #This is metadata | |
873 |
|
887 | |||
874 | lags = data['lags'] |
|
888 | lags = data['lags'] | |
875 | ACFs = data['ACFs'] |
|
889 | ACFs = data['ACFs'] | |
876 | errACFs = data['ACFs_error'] |
|
890 | errACFs = data['ACFs_error'] | |
877 | BadLag1 = data['Lag_contaminated_1'] |
|
891 | BadLag1 = data['Lag_contaminated_1'] | |
878 | BadLag2 = data['Lag_contaminated_2'] |
|
892 | BadLag2 = data['Lag_contaminated_2'] | |
879 | BadHei1 = data['Height_contaminated_1'] |
|
893 | BadHei1 = data['Height_contaminated_1'] | |
880 | BadHei2 = data['Height_contaminated_2'] |
|
894 | BadHei2 = data['Height_contaminated_2'] | |
881 |
|
895 | |||
882 | self.xmin = 0.0 |
|
896 | self.xmin = 0.0 | |
883 | self.xmax = 2.0 |
|
897 | self.xmax = 2.0 | |
884 | self.y = ACFs |
|
898 | self.y = ACFs | |
885 |
|
899 | |||
886 | ax = self.axes[0] |
|
900 | ax = self.axes[0] | |
887 |
|
901 | |||
888 | if ax.firsttime: |
|
902 | if ax.firsttime: | |
889 |
|
903 | |||
890 | for i in range(NSHTS): |
|
904 | for i in range(NSHTS): | |
891 | x_aux = numpy.isfinite(lags[i,:]) |
|
905 | x_aux = numpy.isfinite(lags[i,:]) | |
892 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
906 | y_aux = numpy.isfinite(ACFs[i,:]) | |
893 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
907 | yerr_aux = numpy.isfinite(errACFs[i,:]) | |
894 | x_igcej_aux = numpy.isfinite(BadLag1[i,:]) |
|
908 | x_igcej_aux = numpy.isfinite(BadLag1[i,:]) | |
895 | y_igcej_aux = numpy.isfinite(BadHei1[i,:]) |
|
909 | y_igcej_aux = numpy.isfinite(BadHei1[i,:]) | |
896 | x_ibad_aux = numpy.isfinite(BadLag2[i,:]) |
|
910 | x_ibad_aux = numpy.isfinite(BadLag2[i,:]) | |
897 | y_ibad_aux = numpy.isfinite(BadHei2[i,:]) |
|
911 | y_ibad_aux = numpy.isfinite(BadHei2[i,:]) | |
898 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
912 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: | |
899 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',marker='o',linewidth=1.0,markersize=2) |
|
913 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',marker='o',linewidth=1.0,markersize=2) | |
900 | ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2) |
|
914 | ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2) | |
901 | ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2) |
|
915 | ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2) | |
902 |
|
916 | |||
903 | self.xstep_given = (self.xmax-self.xmin)/(DPL-1) |
|
917 | self.xstep_given = (self.xmax-self.xmin)/(DPL-1) | |
904 | self.ystep_given = 50 |
|
918 | self.ystep_given = 50 | |
905 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
919 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
906 | ax.grid(which='minor') |
|
920 | ax.grid(which='minor') | |
907 |
|
921 | |||
908 | else: |
|
922 | else: | |
909 | self.clear_figures() |
|
923 | self.clear_figures() | |
910 | for i in range(NSHTS): |
|
924 | for i in range(NSHTS): | |
911 | x_aux = numpy.isfinite(lags[i,:]) |
|
925 | x_aux = numpy.isfinite(lags[i,:]) | |
912 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
926 | y_aux = numpy.isfinite(ACFs[i,:]) | |
913 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
927 | yerr_aux = numpy.isfinite(errACFs[i,:]) | |
914 | x_igcej_aux = numpy.isfinite(BadLag1[i,:]) |
|
928 | x_igcej_aux = numpy.isfinite(BadLag1[i,:]) | |
915 | y_igcej_aux = numpy.isfinite(BadHei1[i,:]) |
|
929 | y_igcej_aux = numpy.isfinite(BadHei1[i,:]) | |
916 | x_ibad_aux = numpy.isfinite(BadLag2[i,:]) |
|
930 | x_ibad_aux = numpy.isfinite(BadLag2[i,:]) | |
917 | y_ibad_aux = numpy.isfinite(BadHei2[i,:]) |
|
931 | y_ibad_aux = numpy.isfinite(BadHei2[i,:]) | |
918 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
932 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: | |
919 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],linewidth=1.0,markersize=2,color='b',marker='o') |
|
933 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],linewidth=1.0,markersize=2,color='b',marker='o') | |
920 | ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2) |
|
934 | ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2) | |
921 | ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2) |
|
935 | ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2) | |
922 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
936 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
923 |
|
937 | |||
924 | class ACFsLPPlot(Plot): |
|
938 | class ACFsLPPlot(Plot): | |
925 | ''' |
|
939 | ''' | |
926 | Plot for ACFs Double Pulse Experiment |
|
940 | Plot for ACFs Double Pulse Experiment | |
927 | ''' |
|
941 | ''' | |
928 |
|
942 | |||
929 | CODE = 'acfs_LP' |
|
943 | CODE = 'acfs_LP' | |
930 | #plot_name = 'ACF' |
|
944 | #plot_name = 'ACF' | |
931 | plot_type = 'scatterbuffer' |
|
945 | plot_type = 'scatterbuffer' | |
932 |
|
946 | |||
933 |
|
947 | |||
934 | def setup(self): |
|
948 | def setup(self): | |
935 | self.ncols = 1 |
|
949 | self.ncols = 1 | |
936 | self.nrows = 1 |
|
950 | self.nrows = 1 | |
937 | self.nplots = 1 |
|
951 | self.nplots = 1 | |
938 | self.ylabel = 'Range [km]' |
|
952 | self.ylabel = 'Range [km]' | |
939 | self.xlabel = 'Lag (ms)' |
|
953 | self.xlabel = 'Lag (ms)' | |
940 | self.titles = ['ACFs'] |
|
954 | self.titles = ['ACFs'] | |
941 | self.width = 3.5 |
|
955 | self.width = 3.5 | |
942 | self.height = 5.5 |
|
956 | self.height = 5.5 | |
943 | self.colorbar = False |
|
957 | self.colorbar = False | |
944 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
958 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
945 |
|
959 | |||
946 | def update(self, dataOut): |
|
960 | def update(self, dataOut): | |
947 | data = {} |
|
961 | data = {} | |
948 | meta = {} |
|
962 | meta = {} | |
949 |
|
963 | |||
950 | aux=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') |
|
964 | aux=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') | |
951 | errors=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') |
|
965 | errors=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') | |
952 | lags_LP_to_plot=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') |
|
966 | lags_LP_to_plot=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') | |
953 |
|
967 | |||
954 | for i in range(dataOut.NACF): |
|
968 | for i in range(dataOut.NACF): | |
955 | for j in range(dataOut.IBITS): |
|
969 | for j in range(dataOut.IBITS): | |
956 | if numpy.abs(dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0])<1.0: |
|
970 | if numpy.abs(dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0])<1.0: | |
957 | aux[i,j]=dataOut.output_LP_integrated.real[j,i,0]/dataOut.output_LP_integrated.real[0,i,0] |
|
971 | aux[i,j]=dataOut.output_LP_integrated.real[j,i,0]/dataOut.output_LP_integrated.real[0,i,0] | |
958 | aux[i,j]=max(min(aux[i,j],1.0),-1.0)*dataOut.DH+dataOut.heightList[i] |
|
972 | aux[i,j]=max(min(aux[i,j],1.0),-1.0)*dataOut.DH+dataOut.heightList[i] | |
959 | lags_LP_to_plot[i,j]=dataOut.lags_LP[j] |
|
973 | lags_LP_to_plot[i,j]=dataOut.lags_LP[j] | |
960 | errors[i,j]=dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0]*dataOut.DH |
|
974 | errors[i,j]=dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0]*dataOut.DH | |
961 | else: |
|
975 | else: | |
962 | aux[i,j]=numpy.nan |
|
976 | aux[i,j]=numpy.nan | |
963 | lags_LP_to_plot[i,j]=numpy.nan |
|
977 | lags_LP_to_plot[i,j]=numpy.nan | |
964 | errors[i,j]=numpy.nan |
|
978 | errors[i,j]=numpy.nan | |
965 |
|
979 | |||
966 | data['ACFs'] = aux |
|
980 | data['ACFs'] = aux | |
967 | data['ACFs_error'] = errors |
|
981 | data['ACFs_error'] = errors | |
968 | data['lags'] = lags_LP_to_plot |
|
982 | data['lags'] = lags_LP_to_plot | |
969 |
|
983 | |||
970 | meta['yrange'] = numpy.array([]) |
|
984 | meta['yrange'] = numpy.array([]) | |
971 | #meta['NACF'] = dataOut.NACF |
|
985 | #meta['NACF'] = dataOut.NACF | |
972 | #meta['NLAG'] = dataOut.NLAG |
|
986 | #meta['NLAG'] = dataOut.NLAG | |
973 | data['NACF'] = dataOut.NACF #This is metadata |
|
987 | data['NACF'] = dataOut.NACF #This is metadata | |
974 | data['NLAG'] = dataOut.NLAG #This is metadata |
|
988 | data['NLAG'] = dataOut.NLAG #This is metadata | |
975 |
|
989 | |||
976 | return data, meta |
|
990 | return data, meta | |
977 |
|
991 | |||
978 | def plot(self): |
|
992 | def plot(self): | |
979 |
|
993 | |||
980 | data = self.data[-1] |
|
994 | data = self.data[-1] | |
981 | #NACF = self.meta['NACF'] |
|
995 | #NACF = self.meta['NACF'] | |
982 | #NLAG = self.meta['NLAG'] |
|
996 | #NLAG = self.meta['NLAG'] | |
983 | NACF = data['NACF'] #This is metadata |
|
997 | NACF = data['NACF'] #This is metadata | |
984 | NLAG = data['NLAG'] #This is metadata |
|
998 | NLAG = data['NLAG'] #This is metadata | |
985 |
|
999 | |||
986 | lags = data['lags'] |
|
1000 | lags = data['lags'] | |
987 | ACFs = data['ACFs'] |
|
1001 | ACFs = data['ACFs'] | |
988 | errACFs = data['ACFs_error'] |
|
1002 | errACFs = data['ACFs_error'] | |
989 |
|
1003 | |||
990 | self.xmin = 0.0 |
|
1004 | self.xmin = 0.0 | |
991 | self.xmax = 1.5 |
|
1005 | self.xmax = 1.5 | |
992 |
|
1006 | |||
993 | self.y = ACFs |
|
1007 | self.y = ACFs | |
994 |
|
1008 | |||
995 | ax = self.axes[0] |
|
1009 | ax = self.axes[0] | |
996 |
|
1010 | |||
997 | if ax.firsttime: |
|
1011 | if ax.firsttime: | |
998 |
|
1012 | |||
999 | for i in range(NACF): |
|
1013 | for i in range(NACF): | |
1000 | x_aux = numpy.isfinite(lags[i,:]) |
|
1014 | x_aux = numpy.isfinite(lags[i,:]) | |
1001 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
1015 | y_aux = numpy.isfinite(ACFs[i,:]) | |
1002 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
1016 | yerr_aux = numpy.isfinite(errACFs[i,:]) | |
1003 |
|
1017 | |||
1004 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
1018 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: | |
1005 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') |
|
1019 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') | |
1006 |
|
1020 | |||
1007 | #self.xstep_given = (self.xmax-self.xmin)/(self.data.NLAG-1) |
|
1021 | #self.xstep_given = (self.xmax-self.xmin)/(self.data.NLAG-1) | |
1008 | self.xstep_given=0.3 |
|
1022 | self.xstep_given=0.3 | |
1009 | self.ystep_given = 200 |
|
1023 | self.ystep_given = 200 | |
1010 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
1024 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
1011 | ax.grid(which='minor') |
|
1025 | ax.grid(which='minor') | |
1012 |
|
1026 | |||
1013 | else: |
|
1027 | else: | |
1014 | self.clear_figures() |
|
1028 | self.clear_figures() | |
1015 |
|
1029 | |||
1016 | for i in range(NACF): |
|
1030 | for i in range(NACF): | |
1017 | x_aux = numpy.isfinite(lags[i,:]) |
|
1031 | x_aux = numpy.isfinite(lags[i,:]) | |
1018 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
1032 | y_aux = numpy.isfinite(ACFs[i,:]) | |
1019 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
1033 | yerr_aux = numpy.isfinite(errACFs[i,:]) | |
1020 |
|
1034 | |||
1021 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
1035 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: | |
1022 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') |
|
1036 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') | |
1023 |
|
1037 | |||
1024 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
1038 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
1025 |
|
1039 | |||
1026 |
|
1040 | |||
1027 | class CrossProductsPlot(Plot): |
|
1041 | class CrossProductsPlot(Plot): | |
1028 | ''' |
|
1042 | ''' | |
1029 | Plot for cross products |
|
1043 | Plot for cross products | |
1030 | ''' |
|
1044 | ''' | |
1031 |
|
1045 | |||
1032 | CODE = 'crossprod' |
|
1046 | CODE = 'crossprod' | |
1033 | plot_name = 'Cross Products' |
|
1047 | plot_name = 'Cross Products' | |
1034 | plot_type = 'scatterbuffer' |
|
1048 | plot_type = 'scatterbuffer' | |
1035 |
|
1049 | |||
1036 | def setup(self): |
|
1050 | def setup(self): | |
1037 |
|
1051 | |||
1038 | self.ncols = 3 |
|
1052 | self.ncols = 3 | |
1039 | self.nrows = 1 |
|
1053 | self.nrows = 1 | |
1040 | self.nplots = 3 |
|
1054 | self.nplots = 3 | |
1041 | self.ylabel = 'Range [km]' |
|
1055 | self.ylabel = 'Range [km]' | |
1042 | self.titles = [] |
|
1056 | self.titles = [] | |
1043 | self.width = 3.5*self.nplots |
|
1057 | self.width = 3.5*self.nplots | |
1044 | self.height = 5.5 |
|
1058 | self.height = 5.5 | |
1045 | self.colorbar = False |
|
1059 | self.colorbar = False | |
1046 | self.plots_adjust.update({'wspace':.3, 'left': 0.12, 'right': 0.92, 'bottom': 0.1}) |
|
1060 | self.plots_adjust.update({'wspace':.3, 'left': 0.12, 'right': 0.92, 'bottom': 0.1}) | |
1047 |
|
1061 | |||
1048 |
|
1062 | |||
1049 | def update(self, dataOut): |
|
1063 | def update(self, dataOut): | |
1050 |
|
1064 | |||
1051 | data = {} |
|
1065 | data = {} | |
1052 | meta = {} |
|
1066 | meta = {} | |
1053 |
|
1067 | |||
1054 | data['crossprod'] = dataOut.crossprods |
|
1068 | data['crossprod'] = dataOut.crossprods | |
1055 | data['NDP'] = dataOut.NDP |
|
1069 | data['NDP'] = dataOut.NDP | |
1056 |
|
1070 | |||
1057 | return data, meta |
|
1071 | return data, meta | |
1058 |
|
1072 | |||
1059 | def plot(self): |
|
1073 | def plot(self): | |
1060 |
|
1074 | |||
1061 | NDP = self.data['NDP'][-1] |
|
1075 | NDP = self.data['NDP'][-1] | |
1062 | x = self.data['crossprod'][:,-1,:,:,:,:] |
|
1076 | x = self.data['crossprod'][:,-1,:,:,:,:] | |
1063 | y = self.data.yrange[0:NDP] |
|
1077 | y = self.data.yrange[0:NDP] | |
1064 |
|
1078 | |||
1065 | for n, ax in enumerate(self.axes): |
|
1079 | for n, ax in enumerate(self.axes): | |
1066 |
|
1080 | |||
1067 | self.xmin=numpy.min(numpy.concatenate((x[n][0,20:30,0,0],x[n][1,20:30,0,0],x[n][2,20:30,0,0],x[n][3,20:30,0,0]))) |
|
1081 | self.xmin=numpy.min(numpy.concatenate((x[n][0,20:30,0,0],x[n][1,20:30,0,0],x[n][2,20:30,0,0],x[n][3,20:30,0,0]))) | |
1068 | self.xmax=numpy.max(numpy.concatenate((x[n][0,20:30,0,0],x[n][1,20:30,0,0],x[n][2,20:30,0,0],x[n][3,20:30,0,0]))) |
|
1082 | self.xmax=numpy.max(numpy.concatenate((x[n][0,20:30,0,0],x[n][1,20:30,0,0],x[n][2,20:30,0,0],x[n][3,20:30,0,0]))) | |
1069 |
|
1083 | |||
1070 | if ax.firsttime: |
|
1084 | if ax.firsttime: | |
1071 |
|
1085 | |||
1072 | self.autoxticks=False |
|
1086 | self.autoxticks=False | |
1073 | if n==0: |
|
1087 | if n==0: | |
1074 | label1='kax' |
|
1088 | label1='kax' | |
1075 | label2='kay' |
|
1089 | label2='kay' | |
1076 | label3='kbx' |
|
1090 | label3='kbx' | |
1077 | label4='kby' |
|
1091 | label4='kby' | |
1078 | self.xlimits=[(self.xmin,self.xmax)] |
|
1092 | self.xlimits=[(self.xmin,self.xmax)] | |
1079 | elif n==1: |
|
1093 | elif n==1: | |
1080 | label1='kax2' |
|
1094 | label1='kax2' | |
1081 | label2='kay2' |
|
1095 | label2='kay2' | |
1082 | label3='kbx2' |
|
1096 | label3='kbx2' | |
1083 | label4='kby2' |
|
1097 | label4='kby2' | |
1084 | self.xlimits.append((self.xmin,self.xmax)) |
|
1098 | self.xlimits.append((self.xmin,self.xmax)) | |
1085 | elif n==2: |
|
1099 | elif n==2: | |
1086 | label1='kaxay' |
|
1100 | label1='kaxay' | |
1087 | label2='kbxby' |
|
1101 | label2='kbxby' | |
1088 | label3='kaxbx' |
|
1102 | label3='kaxbx' | |
1089 | label4='kaxby' |
|
1103 | label4='kaxby' | |
1090 | self.xlimits.append((self.xmin,self.xmax)) |
|
1104 | self.xlimits.append((self.xmin,self.xmax)) | |
1091 |
|
1105 | |||
1092 | ax.plotline1 = ax.plot(x[n][0,:,0,0], y, color='r',linewidth=2.0, label=label1) |
|
1106 | ax.plotline1 = ax.plot(x[n][0,:,0,0], y, color='r',linewidth=2.0, label=label1) | |
1093 | ax.plotline2 = ax.plot(x[n][1,:,0,0], y, color='k',linewidth=2.0, label=label2) |
|
1107 | ax.plotline2 = ax.plot(x[n][1,:,0,0], y, color='k',linewidth=2.0, label=label2) | |
1094 | ax.plotline3 = ax.plot(x[n][2,:,0,0], y, color='b',linewidth=2.0, label=label3) |
|
1108 | ax.plotline3 = ax.plot(x[n][2,:,0,0], y, color='b',linewidth=2.0, label=label3) | |
1095 | ax.plotline4 = ax.plot(x[n][3,:,0,0], y, color='m',linewidth=2.0, label=label4) |
|
1109 | ax.plotline4 = ax.plot(x[n][3,:,0,0], y, color='m',linewidth=2.0, label=label4) | |
1096 | ax.legend(loc='upper right') |
|
1110 | ax.legend(loc='upper right') | |
1097 | ax.set_xlim(self.xmin, self.xmax) |
|
1111 | ax.set_xlim(self.xmin, self.xmax) | |
1098 | self.titles.append('{}'.format(self.plot_name.upper())) |
|
1112 | self.titles.append('{}'.format(self.plot_name.upper())) | |
1099 |
|
1113 | |||
1100 | else: |
|
1114 | else: | |
1101 |
|
1115 | |||
1102 | if n==0: |
|
1116 | if n==0: | |
1103 | self.xlimits=[(self.xmin,self.xmax)] |
|
1117 | self.xlimits=[(self.xmin,self.xmax)] | |
1104 | else: |
|
1118 | else: | |
1105 | self.xlimits.append((self.xmin,self.xmax)) |
|
1119 | self.xlimits.append((self.xmin,self.xmax)) | |
1106 |
|
1120 | |||
1107 | ax.set_xlim(self.xmin, self.xmax) |
|
1121 | ax.set_xlim(self.xmin, self.xmax) | |
1108 |
|
1122 | |||
1109 | ax.plotline1[0].set_data(x[n][0,:,0,0],y) |
|
1123 | ax.plotline1[0].set_data(x[n][0,:,0,0],y) | |
1110 | ax.plotline2[0].set_data(x[n][1,:,0,0],y) |
|
1124 | ax.plotline2[0].set_data(x[n][1,:,0,0],y) | |
1111 | ax.plotline3[0].set_data(x[n][2,:,0,0],y) |
|
1125 | ax.plotline3[0].set_data(x[n][2,:,0,0],y) | |
1112 | ax.plotline4[0].set_data(x[n][3,:,0,0],y) |
|
1126 | ax.plotline4[0].set_data(x[n][3,:,0,0],y) | |
1113 | self.titles.append('{}'.format(self.plot_name.upper())) |
|
1127 | self.titles.append('{}'.format(self.plot_name.upper())) | |
1114 |
|
1128 | |||
1115 |
|
1129 | |||
1116 | class CrossProductsLPPlot(Plot): |
|
1130 | class CrossProductsLPPlot(Plot): | |
1117 | ''' |
|
1131 | ''' | |
1118 | Plot for cross products LP |
|
1132 | Plot for cross products LP | |
1119 | ''' |
|
1133 | ''' | |
1120 |
|
1134 | |||
1121 | CODE = 'crossprodslp' |
|
1135 | CODE = 'crossprodslp' | |
1122 | plot_name = 'Cross Products LP' |
|
1136 | plot_name = 'Cross Products LP' | |
1123 | plot_type = 'scatterbuffer' |
|
1137 | plot_type = 'scatterbuffer' | |
1124 |
|
1138 | |||
1125 |
|
1139 | |||
1126 | def setup(self): |
|
1140 | def setup(self): | |
1127 |
|
1141 | |||
1128 | self.ncols = 2 |
|
1142 | self.ncols = 2 | |
1129 | self.nrows = 1 |
|
1143 | self.nrows = 1 | |
1130 | self.nplots = 2 |
|
1144 | self.nplots = 2 | |
1131 | self.ylabel = 'Range [km]' |
|
1145 | self.ylabel = 'Range [km]' | |
1132 | self.xlabel = 'dB' |
|
1146 | self.xlabel = 'dB' | |
1133 | self.width = 3.5*self.nplots |
|
1147 | self.width = 3.5*self.nplots | |
1134 | self.height = 5.5 |
|
1148 | self.height = 5.5 | |
1135 | self.colorbar = False |
|
1149 | self.colorbar = False | |
1136 | self.titles = [] |
|
1150 | self.titles = [] | |
1137 | self.plots_adjust.update({'wspace': .8 ,'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
1151 | self.plots_adjust.update({'wspace': .8 ,'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
1138 |
|
1152 | |||
1139 | def update(self, dataOut): |
|
1153 | def update(self, dataOut): | |
1140 | data = {} |
|
1154 | data = {} | |
1141 | meta = {} |
|
1155 | meta = {} | |
1142 |
|
1156 | |||
1143 | data['crossprodslp'] = 10*numpy.log10(numpy.abs(dataOut.output_LP)) |
|
1157 | data['crossprodslp'] = 10*numpy.log10(numpy.abs(dataOut.output_LP)) | |
1144 |
|
1158 | |||
1145 | data['NRANGE'] = dataOut.NRANGE #This is metadata |
|
1159 | data['NRANGE'] = dataOut.NRANGE #This is metadata | |
1146 | data['NLAG'] = dataOut.NLAG #This is metadata |
|
1160 | data['NLAG'] = dataOut.NLAG #This is metadata | |
1147 |
|
1161 | |||
1148 | return data, meta |
|
1162 | return data, meta | |
1149 |
|
1163 | |||
1150 | def plot(self): |
|
1164 | def plot(self): | |
1151 |
|
1165 | |||
1152 | NRANGE = self.data['NRANGE'][-1] |
|
1166 | NRANGE = self.data['NRANGE'][-1] | |
1153 | NLAG = self.data['NLAG'][-1] |
|
1167 | NLAG = self.data['NLAG'][-1] | |
1154 |
|
1168 | |||
1155 | x = self.data[self.CODE][:,-1,:,:] |
|
1169 | x = self.data[self.CODE][:,-1,:,:] | |
1156 | self.y = self.data.yrange[0:NRANGE] |
|
1170 | self.y = self.data.yrange[0:NRANGE] | |
1157 |
|
1171 | |||
1158 | label_array=numpy.array(['lag '+ str(x) for x in range(NLAG)]) |
|
1172 | label_array=numpy.array(['lag '+ str(x) for x in range(NLAG)]) | |
1159 | color_array=['r','k','g','b','c','m','y','orange','steelblue','purple','peru','darksalmon','grey','limegreen','olive','midnightblue'] |
|
1173 | color_array=['r','k','g','b','c','m','y','orange','steelblue','purple','peru','darksalmon','grey','limegreen','olive','midnightblue'] | |
1160 |
|
1174 | |||
1161 |
|
1175 | |||
1162 | for n, ax in enumerate(self.axes): |
|
1176 | for n, ax in enumerate(self.axes): | |
1163 |
|
1177 | |||
1164 | self.xmin=28#30 |
|
1178 | self.xmin=28#30 | |
1165 | self.xmax=70#70 |
|
1179 | self.xmax=70#70 | |
1166 | #self.xmin=numpy.min(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) |
|
1180 | #self.xmin=numpy.min(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) | |
1167 | #self.xmax=numpy.max(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) |
|
1181 | #self.xmax=numpy.max(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) | |
1168 |
|
1182 | |||
1169 | if ax.firsttime: |
|
1183 | if ax.firsttime: | |
1170 |
|
1184 | |||
1171 | self.autoxticks=False |
|
1185 | self.autoxticks=False | |
1172 | if n == 0: |
|
1186 | if n == 0: | |
1173 | self.plotline_array=numpy.zeros((2,NLAG),dtype=object) |
|
1187 | self.plotline_array=numpy.zeros((2,NLAG),dtype=object) | |
1174 |
|
1188 | |||
1175 | for i in range(NLAG): |
|
1189 | for i in range(NLAG): | |
1176 | self.plotline_array[n,i], = ax.plot(x[i,:,n], self.y, color=color_array[i],linewidth=1.0, label=label_array[i]) |
|
1190 | self.plotline_array[n,i], = ax.plot(x[i,:,n], self.y, color=color_array[i],linewidth=1.0, label=label_array[i]) | |
1177 |
|
1191 | |||
1178 | ax.legend(loc='upper right') |
|
1192 | ax.legend(loc='upper right') | |
1179 | ax.set_xlim(self.xmin, self.xmax) |
|
1193 | ax.set_xlim(self.xmin, self.xmax) | |
1180 | if n==0: |
|
1194 | if n==0: | |
1181 | self.titles.append('{} CH0'.format(self.plot_name.upper())) |
|
1195 | self.titles.append('{} CH0'.format(self.plot_name.upper())) | |
1182 | if n==1: |
|
1196 | if n==1: | |
1183 | self.titles.append('{} CH1'.format(self.plot_name.upper())) |
|
1197 | self.titles.append('{} CH1'.format(self.plot_name.upper())) | |
1184 | else: |
|
1198 | else: | |
1185 | for i in range(NLAG): |
|
1199 | for i in range(NLAG): | |
1186 | self.plotline_array[n,i].set_data(x[i,:,n],self.y) |
|
1200 | self.plotline_array[n,i].set_data(x[i,:,n],self.y) | |
1187 |
|
1201 | |||
1188 | if n==0: |
|
1202 | if n==0: | |
1189 | self.titles.append('{} CH0'.format(self.plot_name.upper())) |
|
1203 | self.titles.append('{} CH0'.format(self.plot_name.upper())) | |
1190 | if n==1: |
|
1204 | if n==1: | |
1191 | self.titles.append('{} CH1'.format(self.plot_name.upper())) |
|
1205 | self.titles.append('{} CH1'.format(self.plot_name.upper())) | |
1192 |
|
1206 | |||
1193 |
|
1207 | |||
1194 | class NoiseDPPlot(NoisePlot): |
|
1208 | class NoiseDPPlot(NoisePlot): | |
1195 | ''' |
|
1209 | ''' | |
1196 | Plot for noise Double Pulse |
|
1210 | Plot for noise Double Pulse | |
1197 | ''' |
|
1211 | ''' | |
1198 |
|
1212 | |||
1199 | CODE = 'noise' |
|
1213 | CODE = 'noise' | |
1200 | #plot_name = 'Noise' |
|
1214 | #plot_name = 'Noise' | |
1201 | #plot_type = 'scatterbuffer' |
|
1215 | #plot_type = 'scatterbuffer' | |
1202 |
|
1216 | |||
1203 | def update(self, dataOut): |
|
1217 | def update(self, dataOut): | |
1204 |
|
1218 | |||
1205 | data = {} |
|
1219 | data = {} | |
1206 | meta = {} |
|
1220 | meta = {} | |
1207 | data['noise'] = 10*numpy.log10(dataOut.noise_final) |
|
1221 | data['noise'] = 10*numpy.log10(dataOut.noise_final) | |
1208 |
|
1222 | |||
1209 | return data, meta |
|
1223 | return data, meta | |
1210 |
|
1224 | |||
1211 |
|
1225 | |||
1212 | class XmitWaveformPlot(Plot): |
|
1226 | class XmitWaveformPlot(Plot): | |
1213 | ''' |
|
1227 | ''' | |
1214 | Plot for xmit waveform |
|
1228 | Plot for xmit waveform | |
1215 | ''' |
|
1229 | ''' | |
1216 |
|
1230 | |||
1217 | CODE = 'xmit' |
|
1231 | CODE = 'xmit' | |
1218 | plot_name = 'Xmit Waveform' |
|
1232 | plot_name = 'Xmit Waveform' | |
1219 | plot_type = 'scatterbuffer' |
|
1233 | plot_type = 'scatterbuffer' | |
1220 |
|
1234 | |||
1221 |
|
1235 | |||
1222 | def setup(self): |
|
1236 | def setup(self): | |
1223 |
|
1237 | |||
1224 | self.ncols = 1 |
|
1238 | self.ncols = 1 | |
1225 | self.nrows = 1 |
|
1239 | self.nrows = 1 | |
1226 | self.nplots = 1 |
|
1240 | self.nplots = 1 | |
1227 | self.ylabel = '' |
|
1241 | self.ylabel = '' | |
1228 | self.xlabel = 'Number of Lag' |
|
1242 | self.xlabel = 'Number of Lag' | |
1229 | self.width = 5.5 |
|
1243 | self.width = 5.5 | |
1230 | self.height = 3.5 |
|
1244 | self.height = 3.5 | |
1231 | self.colorbar = False |
|
1245 | self.colorbar = False | |
1232 | self.plots_adjust.update({'right': 0.85 }) |
|
1246 | self.plots_adjust.update({'right': 0.85 }) | |
1233 | self.titles = [self.plot_name] |
|
1247 | self.titles = [self.plot_name] | |
1234 | #self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
1248 | #self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
1235 |
|
1249 | |||
1236 | #if not self.titles: |
|
1250 | #if not self.titles: | |
1237 | #self.titles = self.data.parameters \ |
|
1251 | #self.titles = self.data.parameters \ | |
1238 | #if self.data.parameters else ['{}'.format(self.plot_name.upper())] |
|
1252 | #if self.data.parameters else ['{}'.format(self.plot_name.upper())] | |
1239 |
|
1253 | |||
1240 | def update(self, dataOut): |
|
1254 | def update(self, dataOut): | |
1241 |
|
1255 | |||
1242 | data = {} |
|
1256 | data = {} | |
1243 | meta = {} |
|
1257 | meta = {} | |
1244 |
|
1258 | |||
1245 | y_1=numpy.arctan2(dataOut.output_LP[:,0,2].imag,dataOut.output_LP[:,0,2].real)* 180 / (numpy.pi*10) |
|
1259 | y_1=numpy.arctan2(dataOut.output_LP[:,0,2].imag,dataOut.output_LP[:,0,2].real)* 180 / (numpy.pi*10) | |
1246 | y_2=numpy.abs(dataOut.output_LP[:,0,2]) |
|
1260 | y_2=numpy.abs(dataOut.output_LP[:,0,2]) | |
1247 | norm=numpy.max(y_2) |
|
1261 | norm=numpy.max(y_2) | |
1248 | norm=max(norm,0.1) |
|
1262 | norm=max(norm,0.1) | |
1249 | y_2=y_2/norm |
|
1263 | y_2=y_2/norm | |
1250 |
|
1264 | |||
1251 | meta['yrange'] = numpy.array([]) |
|
1265 | meta['yrange'] = numpy.array([]) | |
1252 |
|
1266 | |||
1253 | data['xmit'] = numpy.vstack((y_1,y_2)) |
|
1267 | data['xmit'] = numpy.vstack((y_1,y_2)) | |
1254 | data['NLAG'] = dataOut.NLAG |
|
1268 | data['NLAG'] = dataOut.NLAG | |
1255 |
|
1269 | |||
1256 | return data, meta |
|
1270 | return data, meta | |
1257 |
|
1271 | |||
1258 | def plot(self): |
|
1272 | def plot(self): | |
1259 |
|
1273 | |||
1260 | data = self.data[-1] |
|
1274 | data = self.data[-1] | |
1261 | NLAG = data['NLAG'] |
|
1275 | NLAG = data['NLAG'] | |
1262 | x = numpy.arange(0,NLAG,1,'float32') |
|
1276 | x = numpy.arange(0,NLAG,1,'float32') | |
1263 | y = data['xmit'] |
|
1277 | y = data['xmit'] | |
1264 |
|
1278 | |||
1265 | self.xmin = 0 |
|
1279 | self.xmin = 0 | |
1266 | self.xmax = NLAG-1 |
|
1280 | self.xmax = NLAG-1 | |
1267 | self.ymin = -1.0 |
|
1281 | self.ymin = -1.0 | |
1268 | self.ymax = 1.0 |
|
1282 | self.ymax = 1.0 | |
1269 | ax = self.axes[0] |
|
1283 | ax = self.axes[0] | |
1270 |
|
1284 | |||
1271 | if ax.firsttime: |
|
1285 | if ax.firsttime: | |
1272 | ax.plotline0=ax.plot(x,y[0,:],color='blue') |
|
1286 | ax.plotline0=ax.plot(x,y[0,:],color='blue') | |
1273 | ax.plotline1=ax.plot(x,y[1,:],color='red') |
|
1287 | ax.plotline1=ax.plot(x,y[1,:],color='red') | |
1274 | secax=ax.secondary_xaxis(location=0.5) |
|
1288 | secax=ax.secondary_xaxis(location=0.5) | |
1275 | secax.xaxis.tick_bottom() |
|
1289 | secax.xaxis.tick_bottom() | |
1276 | secax.tick_params( labelleft=False, labeltop=False, |
|
1290 | secax.tick_params( labelleft=False, labeltop=False, | |
1277 | labelright=False, labelbottom=False) |
|
1291 | labelright=False, labelbottom=False) | |
1278 |
|
1292 | |||
1279 | self.xstep_given = 3 |
|
1293 | self.xstep_given = 3 | |
1280 | self.ystep_given = .25 |
|
1294 | self.ystep_given = .25 | |
1281 | secax.set_xticks(numpy.linspace(self.xmin, self.xmax, 6)) #only works on matplotlib.version>3.2 |
|
1295 | secax.set_xticks(numpy.linspace(self.xmin, self.xmax, 6)) #only works on matplotlib.version>3.2 | |
1282 |
|
1296 | |||
1283 | else: |
|
1297 | else: | |
1284 | ax.plotline0[0].set_data(x,y[0,:]) |
|
1298 | ax.plotline0[0].set_data(x,y[0,:]) | |
1285 | ax.plotline1[0].set_data(x,y[1,:]) |
|
1299 | ax.plotline1[0].set_data(x,y[1,:]) |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file | ||
The requested commit or file is too big and content was truncated. Show full diff |
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