The requested changes are too big and content was truncated. Show full diff
@@ -1,1345 +1,1428 | |||||
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 |
|
7 | |||
8 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG |
|
8 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG | |
9 |
|
9 | |||
10 | from .jroplot_spectra import RTIPlot, NoisePlot |
|
10 | from .jroplot_spectra import RTIPlot, NoisePlot | |
11 |
|
11 | |||
12 | from schainpy.utils import log |
|
12 | from schainpy.utils import log | |
13 | from .plotting_codes import * |
|
13 | from .plotting_codes import * | |
14 |
|
14 | |||
15 | from schainpy.model.graphics.jroplot_base import Plot, plt |
|
15 | from schainpy.model.graphics.jroplot_base import Plot, plt | |
16 |
|
16 | |||
17 | import matplotlib.pyplot as plt |
|
17 | import matplotlib.pyplot as plt | |
18 | import matplotlib.colors as colors |
|
18 | import matplotlib.colors as colors | |
19 | from matplotlib.ticker import MultipleLocator, LogLocator, NullFormatter |
|
19 | from matplotlib.ticker import MultipleLocator, LogLocator, NullFormatter | |
20 |
|
20 | |||
21 | class RTIDPPlot(RTIPlot): |
|
21 | class RTIDPPlot(RTIPlot): | |
22 | ''' |
|
22 | ''' | |
23 | Written by R. Flores |
|
23 | Written by R. Flores | |
24 | ''' |
|
24 | ''' | |
25 | '''Plot for RTI Double Pulse Experiment Using Cross Products Analysis |
|
25 | '''Plot for RTI Double Pulse Experiment Using Cross Products Analysis | |
26 | ''' |
|
26 | ''' | |
27 |
|
27 | |||
28 | CODE = 'RTIDP' |
|
28 | CODE = 'RTIDP' | |
29 | colormap = 'jet' |
|
29 | colormap = 'jet' | |
30 | plot_name = 'RTI' |
|
30 | plot_name = 'RTI' | |
31 | plot_type = 'pcolorbuffer' |
|
31 | plot_type = 'pcolorbuffer' | |
32 |
|
32 | |||
33 | def setup(self): |
|
33 | def setup(self): | |
34 | self.xaxis = 'time' |
|
34 | self.xaxis = 'time' | |
35 | self.ncols = 1 |
|
35 | self.ncols = 1 | |
36 | self.nrows = 3 |
|
36 | self.nrows = 3 | |
37 | self.nplots = self.nrows |
|
37 | self.nplots = self.nrows | |
38 |
|
38 | |||
39 | self.ylabel = 'Range [km]' |
|
39 | self.ylabel = 'Range [km]' | |
40 | self.xlabel = 'Time (LT)' |
|
40 | self.xlabel = 'Time (LT)' | |
41 |
|
41 | |||
42 | self.cb_label = 'Intensity (dB)' |
|
42 | self.cb_label = 'Intensity (dB)' | |
43 |
|
43 | |||
44 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) |
|
44 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) | |
45 |
|
45 | |||
46 | self.titles = ['{} Channel {}'.format( |
|
46 | self.titles = ['{} Channel {}'.format( | |
47 | self.plot_name.upper(), '0x1'),'{} Channel {}'.format( |
|
47 | self.plot_name.upper(), '0x1'),'{} Channel {}'.format( | |
48 | self.plot_name.upper(), '0'),'{} Channel {}'.format( |
|
48 | self.plot_name.upper(), '0'),'{} Channel {}'.format( | |
49 | self.plot_name.upper(), '1')] |
|
49 | self.plot_name.upper(), '1')] | |
50 |
|
50 | |||
51 | def update(self, dataOut): |
|
51 | def update(self, dataOut): | |
52 |
|
52 | |||
53 | data = {} |
|
53 | data = {} | |
54 | meta = {} |
|
54 | meta = {} | |
55 | data['rti'] = dataOut.data_for_RTI_DP |
|
55 | data['rti'] = dataOut.data_for_RTI_DP | |
56 | data['NDP'] = dataOut.NDP |
|
56 | data['NDP'] = dataOut.NDP | |
57 |
|
57 | |||
58 | return data, meta |
|
58 | return data, meta | |
59 |
|
59 | |||
60 | def plot(self): |
|
60 | def plot(self): | |
61 |
|
61 | |||
62 | NDP = self.data['NDP'][-1] |
|
62 | NDP = self.data['NDP'][-1] | |
63 | self.x = self.data.times |
|
63 | self.x = self.data.times | |
64 | self.y = self.data.yrange[0:NDP] |
|
64 | self.y = self.data.yrange[0:NDP] | |
65 | self.z = self.data['rti'] |
|
65 | self.z = self.data['rti'] | |
66 | self.z = numpy.ma.masked_invalid(self.z) |
|
66 | self.z = numpy.ma.masked_invalid(self.z) | |
67 |
|
67 | |||
68 | if self.decimation is None: |
|
68 | if self.decimation is None: | |
69 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
69 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
70 | else: |
|
70 | else: | |
71 | x, y, z = self.fill_gaps(*self.decimate()) |
|
71 | x, y, z = self.fill_gaps(*self.decimate()) | |
72 |
|
72 | |||
73 | for n, ax in enumerate(self.axes): |
|
73 | for n, ax in enumerate(self.axes): | |
74 |
|
74 | |||
75 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
75 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
76 | self.z[1][0,12:40]) |
|
76 | self.z[1][0,12:40]) | |
77 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
77 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
78 | self.z[1][0,12:40]) |
|
78 | self.z[1][0,12:40]) | |
79 |
|
79 | |||
80 | if ax.firsttime: |
|
80 | if ax.firsttime: | |
81 |
|
81 | |||
82 | if self.zlimits is not None: |
|
82 | if self.zlimits is not None: | |
83 | self.zmin, self.zmax = self.zlimits[n] |
|
83 | self.zmin, self.zmax = self.zlimits[n] | |
84 |
|
84 | |||
85 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
85 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
86 | vmin=self.zmin, |
|
86 | vmin=self.zmin, | |
87 | vmax=self.zmax, |
|
87 | vmax=self.zmax, | |
88 | cmap=plt.get_cmap(self.colormap) |
|
88 | cmap=plt.get_cmap(self.colormap) | |
89 | ) |
|
89 | ) | |
90 | else: |
|
90 | else: | |
91 | #if self.zlimits is not None: |
|
91 | #if self.zlimits is not None: | |
92 | #self.zmin, self.zmax = self.zlimits[n] |
|
92 | #self.zmin, self.zmax = self.zlimits[n] | |
93 | ax.collections.remove(ax.collections[0]) |
|
93 | ax.collections.remove(ax.collections[0]) | |
94 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
94 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
95 | vmin=self.zmin, |
|
95 | vmin=self.zmin, | |
96 | vmax=self.zmax, |
|
96 | vmax=self.zmax, | |
97 | cmap=plt.get_cmap(self.colormap) |
|
97 | cmap=plt.get_cmap(self.colormap) | |
98 | ) |
|
98 | ) | |
99 |
|
99 | |||
100 |
|
100 | |||
101 | class RTILPPlot(RTIPlot): |
|
101 | class RTILPPlot(RTIPlot): | |
102 | ''' |
|
102 | ''' | |
103 | Written by R. Flores |
|
103 | Written by R. Flores | |
104 | ''' |
|
104 | ''' | |
105 | ''' |
|
105 | ''' | |
106 | Plot for RTI Long Pulse Using Cross Products Analysis |
|
106 | Plot for RTI Long Pulse Using Cross Products Analysis | |
107 | ''' |
|
107 | ''' | |
108 |
|
108 | |||
109 | CODE = 'RTILP' |
|
109 | CODE = 'RTILP' | |
110 | colormap = 'jet' |
|
110 | colormap = 'jet' | |
111 | plot_name = 'RTI LP' |
|
111 | plot_name = 'RTI LP' | |
112 | plot_type = 'pcolorbuffer' |
|
112 | plot_type = 'pcolorbuffer' | |
113 |
|
113 | |||
114 | def setup(self): |
|
114 | def setup(self): | |
115 | self.xaxis = 'time' |
|
115 | self.xaxis = 'time' | |
116 | self.ncols = 1 |
|
116 | self.ncols = 1 | |
117 | self.nrows = 2 |
|
117 | self.nrows = 2 | |
118 | self.nplots = self.nrows |
|
118 | self.nplots = self.nrows | |
119 |
|
119 | |||
120 | self.ylabel = 'Range [km]' |
|
120 | self.ylabel = 'Range [km]' | |
121 | self.xlabel = 'Time (LT)' |
|
121 | self.xlabel = 'Time (LT)' | |
122 |
|
122 | |||
123 | self.cb_label = 'Intensity (dB)' |
|
123 | self.cb_label = 'Intensity (dB)' | |
124 |
|
124 | |||
125 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) |
|
125 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) | |
126 |
|
126 | |||
127 |
|
127 | |||
128 | self.titles = ['{} Channel {}'.format( |
|
128 | self.titles = ['{} Channel {}'.format( | |
129 | self.plot_name.upper(), '0'),'{} Channel {}'.format( |
|
129 | self.plot_name.upper(), '0'),'{} Channel {}'.format( | |
130 | self.plot_name.upper(), '1'),'{} Channel {}'.format( |
|
130 | self.plot_name.upper(), '1'),'{} Channel {}'.format( | |
131 | self.plot_name.upper(), '2'),'{} Channel {}'.format( |
|
131 | self.plot_name.upper(), '2'),'{} Channel {}'.format( | |
132 | self.plot_name.upper(), '3')] |
|
132 | self.plot_name.upper(), '3')] | |
133 |
|
133 | |||
134 |
|
134 | |||
135 | def update(self, dataOut): |
|
135 | def update(self, dataOut): | |
136 |
|
136 | |||
137 | data = {} |
|
137 | data = {} | |
138 | meta = {} |
|
138 | meta = {} | |
139 | data['rti'] = dataOut.data_for_RTI_LP |
|
139 | data['rti'] = dataOut.data_for_RTI_LP | |
140 | data['NRANGE'] = dataOut.NRANGE |
|
140 | data['NRANGE'] = dataOut.NRANGE | |
141 |
|
141 | |||
142 | return data, meta |
|
142 | return data, meta | |
143 |
|
143 | |||
144 | def plot(self): |
|
144 | def plot(self): | |
145 |
|
145 | |||
146 | NRANGE = self.data['NRANGE'][-1] |
|
146 | NRANGE = self.data['NRANGE'][-1] | |
147 | self.x = self.data.times |
|
147 | self.x = self.data.times | |
148 | self.y = self.data.yrange[0:NRANGE] |
|
148 | self.y = self.data.yrange[0:NRANGE] | |
149 |
|
149 | |||
150 | self.z = self.data['rti'] |
|
150 | self.z = self.data['rti'] | |
151 |
|
151 | |||
152 | self.z = numpy.ma.masked_invalid(self.z) |
|
152 | self.z = numpy.ma.masked_invalid(self.z) | |
153 |
|
153 | |||
154 | if self.decimation is None: |
|
154 | if self.decimation is None: | |
155 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
155 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
156 | else: |
|
156 | else: | |
157 | x, y, z = self.fill_gaps(*self.decimate()) |
|
157 | x, y, z = self.fill_gaps(*self.decimate()) | |
158 |
|
158 | |||
159 | for n, ax in enumerate(self.axes): |
|
159 | for n, ax in enumerate(self.axes): | |
160 |
|
160 | |||
161 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
161 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
162 | self.z[1][0,12:40]) |
|
162 | self.z[1][0,12:40]) | |
163 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
163 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
164 | self.z[1][0,12:40]) |
|
164 | self.z[1][0,12:40]) | |
165 |
|
165 | |||
166 | if ax.firsttime: |
|
166 | if ax.firsttime: | |
167 |
|
167 | |||
168 | if self.zlimits is not None: |
|
168 | if self.zlimits is not None: | |
169 | self.zmin, self.zmax = self.zlimits[n] |
|
169 | self.zmin, self.zmax = self.zlimits[n] | |
170 |
|
170 | |||
171 |
|
171 | |||
172 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
172 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
173 | vmin=self.zmin, |
|
173 | vmin=self.zmin, | |
174 | vmax=self.zmax, |
|
174 | vmax=self.zmax, | |
175 | cmap=plt.get_cmap(self.colormap) |
|
175 | cmap=plt.get_cmap(self.colormap) | |
176 | ) |
|
176 | ) | |
177 |
|
177 | |||
178 | else: |
|
178 | else: | |
179 | if self.zlimits is not None: |
|
179 | if self.zlimits is not None: | |
180 | self.zmin, self.zmax = self.zlimits[n] |
|
180 | self.zmin, self.zmax = self.zlimits[n] | |
181 | ax.collections.remove(ax.collections[0]) |
|
181 | ax.collections.remove(ax.collections[0]) | |
182 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
182 | ax.plt = ax.pcolormesh(x, y, z[n].T, | |
183 | vmin=self.zmin, |
|
183 | vmin=self.zmin, | |
184 | vmax=self.zmax, |
|
184 | vmax=self.zmax, | |
185 | cmap=plt.get_cmap(self.colormap) |
|
185 | cmap=plt.get_cmap(self.colormap) | |
186 | ) |
|
186 | ) | |
187 |
|
187 | |||
188 |
|
188 | |||
189 | class DenRTIPlot(RTIPlot): |
|
189 | class DenRTIPlot(RTIPlot): | |
190 | ''' |
|
190 | ''' | |
191 | Written by R. Flores |
|
191 | Written by R. Flores | |
192 | ''' |
|
192 | ''' | |
193 | ''' |
|
193 | ''' | |
194 | Plot for Den |
|
194 | Plot for Den | |
195 | ''' |
|
195 | ''' | |
196 |
|
196 | |||
197 | CODE = 'denrti' |
|
197 | CODE = 'denrti' | |
198 | colormap = 'jet' |
|
198 | colormap = 'jet' | |
199 |
|
199 | |||
200 | def setup(self): |
|
200 | def setup(self): | |
201 | self.xaxis = 'time' |
|
201 | self.xaxis = 'time' | |
202 | self.ncols = 1 |
|
202 | self.ncols = 1 | |
203 | self.nrows = self.data.shape(self.CODE)[0] |
|
203 | self.nrows = self.data.shape(self.CODE)[0] | |
204 | self.nplots = self.nrows |
|
204 | self.nplots = self.nrows | |
205 |
|
205 | |||
206 | self.ylabel = 'Range [km]' |
|
206 | self.ylabel = 'Range [km]' | |
207 | self.xlabel = 'Time (LT)' |
|
207 | self.xlabel = 'Time (LT)' | |
208 |
|
208 | |||
209 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
209 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
210 |
|
210 | |||
211 | if self.CODE == 'denrti': |
|
211 | if self.CODE == 'denrti': | |
212 | self.cb_label = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' |
|
212 | self.cb_label = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' | |
213 |
|
213 | |||
214 | self.titles = ['Electron Density RTI'] |
|
214 | self.titles = ['Electron Density RTI'] | |
215 |
|
215 | |||
216 | def update(self, dataOut): |
|
216 | def update(self, dataOut): | |
217 |
|
217 | |||
218 | data = {} |
|
218 | data = {} | |
219 | meta = {} |
|
219 | meta = {} | |
220 |
|
220 | |||
221 | data['denrti'] = dataOut.DensityFinal*1.e-6 #To Plot in cm^-3 |
|
221 | data['denrti'] = dataOut.DensityFinal*1.e-6 #To Plot in cm^-3 | |
222 |
|
222 | |||
223 | return data, meta |
|
223 | return data, meta | |
224 |
|
224 | |||
225 | def plot(self): |
|
225 | def plot(self): | |
226 |
|
226 | |||
227 | self.x = self.data.times |
|
227 | self.x = self.data.times | |
228 | self.y = self.data.yrange |
|
228 | self.y = self.data.yrange | |
229 |
|
229 | |||
230 | self.z = self.data[self.CODE] |
|
230 | self.z = self.data[self.CODE] | |
231 |
|
231 | |||
232 | self.z = numpy.ma.masked_invalid(self.z) |
|
232 | self.z = numpy.ma.masked_invalid(self.z) | |
233 |
|
233 | |||
234 | if self.decimation is None: |
|
234 | if self.decimation is None: | |
235 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
235 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
236 | else: |
|
236 | else: | |
237 | x, y, z = self.fill_gaps(*self.decimate()) |
|
237 | x, y, z = self.fill_gaps(*self.decimate()) | |
238 |
|
238 | |||
239 | for n, ax in enumerate(self.axes): |
|
239 | for n, ax in enumerate(self.axes): | |
240 |
|
240 | |||
241 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
241 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
242 | self.z[n]) |
|
242 | self.z[n]) | |
243 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
243 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
244 | self.z[n]) |
|
244 | self.z[n]) | |
245 |
|
245 | |||
246 | if ax.firsttime: |
|
246 | if ax.firsttime: | |
247 |
|
247 | |||
248 | if self.zlimits is not None: |
|
248 | if self.zlimits is not None: | |
249 | self.zmin, self.zmax = self.zlimits[n] |
|
249 | self.zmin, self.zmax = self.zlimits[n] | |
250 | if numpy.log10(self.zmin)<0: |
|
250 | if numpy.log10(self.zmin)<0: | |
251 | self.zmin=1 |
|
251 | self.zmin=1 | |
252 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
252 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
253 | vmin=self.zmin, |
|
253 | vmin=self.zmin, | |
254 | vmax=self.zmax, |
|
254 | vmax=self.zmax, | |
255 | cmap=self.cmaps[n], |
|
255 | cmap=self.cmaps[n], | |
256 | norm=colors.LogNorm() |
|
256 | norm=colors.LogNorm() | |
257 | ) |
|
257 | ) | |
258 |
|
258 | |||
259 | else: |
|
259 | else: | |
260 | if self.zlimits is not None: |
|
260 | if self.zlimits is not None: | |
261 | self.zmin, self.zmax = self.zlimits[n] |
|
261 | self.zmin, self.zmax = self.zlimits[n] | |
262 | ax.collections.remove(ax.collections[0]) |
|
262 | ax.collections.remove(ax.collections[0]) | |
263 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
263 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
264 | vmin=self.zmin, |
|
264 | vmin=self.zmin, | |
265 | vmax=self.zmax, |
|
265 | vmax=self.zmax, | |
266 | cmap=self.cmaps[n], |
|
266 | cmap=self.cmaps[n], | |
267 | norm=colors.LogNorm() |
|
267 | norm=colors.LogNorm() | |
268 | ) |
|
268 | ) | |
269 |
|
269 | |||
270 |
|
270 | |||
271 | class ETempRTIPlot(RTIPlot): |
|
271 | class ETempRTIPlot(RTIPlot): | |
272 | ''' |
|
272 | ''' | |
273 | Written by R. Flores |
|
273 | Written by R. Flores | |
274 | ''' |
|
274 | ''' | |
275 | ''' |
|
275 | ''' | |
276 | Plot for Electron Temperature |
|
276 | Plot for Electron Temperature | |
277 | ''' |
|
277 | ''' | |
278 |
|
278 | |||
279 | CODE = 'ETemp' |
|
279 | CODE = 'ETemp' | |
280 | colormap = 'jet' |
|
280 | colormap = 'jet' | |
281 |
|
281 | |||
282 | def setup(self): |
|
282 | def setup(self): | |
283 | self.xaxis = 'time' |
|
283 | self.xaxis = 'time' | |
284 | self.ncols = 1 |
|
284 | self.ncols = 1 | |
285 | self.nrows = self.data.shape(self.CODE)[0] |
|
285 | self.nrows = self.data.shape(self.CODE)[0] | |
286 | self.nplots = self.nrows |
|
286 | self.nplots = self.nrows | |
287 |
|
287 | |||
288 | self.ylabel = 'Range [km]' |
|
288 | self.ylabel = 'Range [km]' | |
289 | self.xlabel = 'Time (LT)' |
|
289 | self.xlabel = 'Time (LT)' | |
290 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
290 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) | |
291 | if self.CODE == 'ETemp': |
|
291 | if self.CODE == 'ETemp': | |
292 | self.cb_label = 'Electron Temperature (K)' |
|
292 | self.cb_label = 'Electron Temperature (K)' | |
293 | self.titles = ['Electron Temperature RTI'] |
|
293 | self.titles = ['Electron Temperature RTI'] | |
294 | if self.CODE == 'ITemp': |
|
294 | if self.CODE == 'ITemp': | |
295 | self.cb_label = 'Ion Temperature (K)' |
|
295 | self.cb_label = 'Ion Temperature (K)' | |
296 | self.titles = ['Ion Temperature RTI'] |
|
296 | self.titles = ['Ion Temperature RTI'] | |
297 | if self.CODE == 'HeFracLP': |
|
297 | if self.CODE == 'HeFracLP': | |
298 | self.cb_label ='He+ Fraction' |
|
298 | self.cb_label ='He+ Fraction' | |
299 | self.titles = ['He+ Fraction RTI'] |
|
299 | self.titles = ['He+ Fraction RTI'] | |
300 | self.zmax=0.16 |
|
300 | self.zmax=0.16 | |
301 | if self.CODE == 'HFracLP': |
|
301 | if self.CODE == 'HFracLP': | |
302 | self.cb_label ='H+ Fraction' |
|
302 | self.cb_label ='H+ Fraction' | |
303 | self.titles = ['H+ Fraction RTI'] |
|
303 | self.titles = ['H+ Fraction RTI'] | |
304 |
|
304 | |||
305 | def update(self, dataOut): |
|
305 | def update(self, dataOut): | |
306 |
|
306 | |||
307 | data = {} |
|
307 | data = {} | |
308 | meta = {} |
|
308 | meta = {} | |
309 |
|
309 | |||
310 | data['ETemp'] = dataOut.ElecTempFinal |
|
310 | data['ETemp'] = dataOut.ElecTempFinal | |
311 |
|
311 | |||
312 | return data, meta |
|
312 | return data, meta | |
313 |
|
313 | |||
314 | def plot(self): |
|
314 | def plot(self): | |
315 |
|
315 | |||
316 | self.x = self.data.times |
|
316 | self.x = self.data.times | |
317 | self.y = self.data.yrange |
|
317 | self.y = self.data.yrange | |
318 | self.z = self.data[self.CODE] |
|
318 | self.z = self.data[self.CODE] | |
319 |
|
319 | |||
320 | self.z = numpy.ma.masked_invalid(self.z) |
|
320 | self.z = numpy.ma.masked_invalid(self.z) | |
321 |
|
321 | |||
322 | if self.decimation is None: |
|
322 | if self.decimation is None: | |
323 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
323 | x, y, z = self.fill_gaps(self.x, self.y, self.z) | |
324 | else: |
|
324 | else: | |
325 | x, y, z = self.fill_gaps(*self.decimate()) |
|
325 | x, y, z = self.fill_gaps(*self.decimate()) | |
326 |
|
326 | |||
327 | for n, ax in enumerate(self.axes): |
|
327 | for n, ax in enumerate(self.axes): | |
328 |
|
328 | |||
329 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
329 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
330 | self.z[n]) |
|
330 | self.z[n]) | |
331 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
331 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
332 | self.z[n]) |
|
332 | self.z[n]) | |
333 |
|
333 | |||
334 | if ax.firsttime: |
|
334 | if ax.firsttime: | |
335 |
|
335 | |||
336 | if self.zlimits is not None: |
|
336 | if self.zlimits is not None: | |
337 | self.zmin, self.zmax = self.zlimits[n] |
|
337 | self.zmin, self.zmax = self.zlimits[n] | |
338 |
|
338 | |||
339 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
339 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
340 | vmin=self.zmin, |
|
340 | vmin=self.zmin, | |
341 | vmax=self.zmax, |
|
341 | vmax=self.zmax, | |
342 | cmap=self.cmaps[n] |
|
342 | cmap=self.cmaps[n] | |
343 | ) |
|
343 | ) | |
344 | #plt.tight_layout() |
|
344 | #plt.tight_layout() | |
345 |
|
345 | |||
346 | else: |
|
346 | else: | |
347 | if self.zlimits is not None: |
|
347 | if self.zlimits is not None: | |
348 | self.zmin, self.zmax = self.zlimits[n] |
|
348 | self.zmin, self.zmax = self.zlimits[n] | |
349 | ax.collections.remove(ax.collections[0]) |
|
349 | ax.collections.remove(ax.collections[0]) | |
350 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
350 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], | |
351 | vmin=self.zmin, |
|
351 | vmin=self.zmin, | |
352 | vmax=self.zmax, |
|
352 | vmax=self.zmax, | |
353 | cmap=self.cmaps[n] |
|
353 | cmap=self.cmaps[n] | |
354 | ) |
|
354 | ) | |
355 |
|
355 | |||
356 |
|
356 | |||
357 | class ITempRTIPlot(ETempRTIPlot): |
|
357 | class ITempRTIPlot(ETempRTIPlot): | |
358 | ''' |
|
358 | ''' | |
359 | Written by R. Flores |
|
359 | Written by R. Flores | |
360 | ''' |
|
360 | ''' | |
361 | ''' |
|
361 | ''' | |
362 | Plot for Ion Temperature |
|
362 | Plot for Ion Temperature | |
363 | ''' |
|
363 | ''' | |
364 |
|
364 | |||
365 | CODE = 'ITemp' |
|
365 | CODE = 'ITemp' | |
366 | colormap = 'jet' |
|
366 | colormap = 'jet' | |
367 | plot_name = 'Ion Temperature' |
|
367 | plot_name = 'Ion Temperature' | |
368 |
|
368 | |||
369 | def update(self, dataOut): |
|
369 | def update(self, dataOut): | |
370 |
|
370 | |||
371 | data = {} |
|
371 | data = {} | |
372 | meta = {} |
|
372 | meta = {} | |
373 |
|
373 | |||
374 | data['ITemp'] = dataOut.IonTempFinal |
|
374 | data['ITemp'] = dataOut.IonTempFinal | |
375 |
|
375 | |||
376 | return data, meta |
|
376 | return data, meta | |
377 |
|
377 | |||
378 |
|
378 | |||
379 | class HFracRTIPlot(ETempRTIPlot): |
|
379 | class HFracRTIPlot(ETempRTIPlot): | |
380 | ''' |
|
380 | ''' | |
381 | Written by R. Flores |
|
381 | Written by R. Flores | |
382 | ''' |
|
382 | ''' | |
383 | ''' |
|
383 | ''' | |
384 | Plot for H+ LP |
|
384 | Plot for H+ LP | |
385 | ''' |
|
385 | ''' | |
386 |
|
386 | |||
387 | CODE = 'HFracLP' |
|
387 | CODE = 'HFracLP' | |
388 | colormap = 'jet' |
|
388 | colormap = 'jet' | |
389 | plot_name = 'H+ Frac' |
|
389 | plot_name = 'H+ Frac' | |
390 |
|
390 | |||
391 | def update(self, dataOut): |
|
391 | def update(self, dataOut): | |
392 |
|
392 | |||
393 | data = {} |
|
393 | data = {} | |
394 | meta = {} |
|
394 | meta = {} | |
395 | data['HFracLP'] = dataOut.PhyFinal |
|
395 | data['HFracLP'] = dataOut.PhyFinal | |
396 |
|
396 | |||
397 | return data, meta |
|
397 | return data, meta | |
398 |
|
398 | |||
399 |
|
399 | |||
400 | class HeFracRTIPlot(ETempRTIPlot): |
|
400 | class HeFracRTIPlot(ETempRTIPlot): | |
401 | ''' |
|
401 | ''' | |
402 | Written by R. Flores |
|
402 | Written by R. Flores | |
403 | ''' |
|
403 | ''' | |
404 | ''' |
|
404 | ''' | |
405 | Plot for He+ LP |
|
405 | Plot for He+ LP | |
406 | ''' |
|
406 | ''' | |
407 |
|
407 | |||
408 | CODE = 'HeFracLP' |
|
408 | CODE = 'HeFracLP' | |
409 | colormap = 'jet' |
|
409 | colormap = 'jet' | |
410 | plot_name = 'He+ Frac' |
|
410 | plot_name = 'He+ Frac' | |
411 |
|
411 | |||
412 | def update(self, dataOut): |
|
412 | def update(self, dataOut): | |
413 |
|
413 | |||
414 | data = {} |
|
414 | data = {} | |
415 | meta = {} |
|
415 | meta = {} | |
416 | data['HeFracLP'] = dataOut.PheFinal |
|
416 | data['HeFracLP'] = dataOut.PheFinal | |
417 |
|
417 | |||
418 | return data, meta |
|
418 | return data, meta | |
419 |
|
419 | |||
420 |
|
420 | |||
421 | class TempsDPPlot(Plot): |
|
421 | class TempsDPPlot(Plot): | |
422 | ''' |
|
422 | ''' | |
423 | Written by R. Flores |
|
423 | Written by R. Flores | |
424 | ''' |
|
424 | ''' | |
425 | ''' |
|
425 | ''' | |
426 | Plot for Electron - Ion Temperatures |
|
426 | Plot for Electron - Ion Temperatures | |
427 | ''' |
|
427 | ''' | |
428 |
|
428 | |||
429 | CODE = 'tempsDP' |
|
429 | CODE = 'tempsDP' | |
430 | #plot_name = 'Temperatures' |
|
430 | #plot_name = 'Temperatures' | |
431 | plot_type = 'scatterbuffer' |
|
431 | plot_type = 'scatterbuffer' | |
432 |
|
432 | |||
433 | def setup(self): |
|
433 | def setup(self): | |
434 |
|
434 | |||
435 | self.ncols = 1 |
|
435 | self.ncols = 1 | |
436 | self.nrows = 1 |
|
436 | self.nrows = 1 | |
437 | self.nplots = 1 |
|
437 | self.nplots = 1 | |
438 | self.ylabel = 'Range [km]' |
|
438 | self.ylabel = 'Range [km]' | |
439 | self.xlabel = 'Temperature (K)' |
|
439 | self.xlabel = 'Temperature (K)' | |
440 | self.titles = ['Electron/Ion Temperatures'] |
|
440 | self.titles = ['Electron/Ion Temperatures'] | |
441 | self.width = 3.5 |
|
441 | self.width = 3.5 | |
442 | self.height = 5.5 |
|
442 | self.height = 5.5 | |
443 | self.colorbar = False |
|
443 | self.colorbar = False | |
444 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
444 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
445 |
|
445 | |||
446 | def update(self, dataOut): |
|
446 | def update(self, dataOut): | |
447 | data = {} |
|
447 | data = {} | |
448 | meta = {} |
|
448 | meta = {} | |
449 |
|
449 | |||
450 | data['Te'] = dataOut.te2 |
|
450 | data['Te'] = dataOut.te2 | |
451 | data['Ti'] = dataOut.ti2 |
|
451 | data['Ti'] = dataOut.ti2 | |
452 | data['Te_error'] = dataOut.ete2 |
|
452 | data['Te_error'] = dataOut.ete2 | |
453 | data['Ti_error'] = dataOut.eti2 |
|
453 | data['Ti_error'] = dataOut.eti2 | |
454 |
|
454 | |||
455 | meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] |
|
455 | meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] | |
456 |
|
456 | |||
457 | return data, meta |
|
457 | return data, meta | |
458 |
|
458 | |||
459 | def plot(self): |
|
459 | def plot(self): | |
460 |
|
460 | |||
461 | y = self.data.yrange |
|
461 | y = self.data.yrange | |
462 |
|
462 | |||
463 | self.xmin = -100 |
|
463 | self.xmin = -100 | |
464 | self.xmax = 5000 |
|
464 | self.xmax = 5000 | |
465 |
|
465 | |||
466 | ax = self.axes[0] |
|
466 | ax = self.axes[0] | |
467 |
|
467 | |||
468 | data = self.data[-1] |
|
468 | data = self.data[-1] | |
469 |
|
469 | |||
470 | Te = data['Te'] |
|
470 | Te = data['Te'] | |
471 | Ti = data['Ti'] |
|
471 | Ti = data['Ti'] | |
472 | errTe = data['Te_error'] |
|
472 | errTe = data['Te_error'] | |
473 | errTi = data['Ti_error'] |
|
473 | errTi = data['Ti_error'] | |
474 |
|
474 | |||
475 | if ax.firsttime: |
|
475 | if ax.firsttime: | |
476 | ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
476 | ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
477 | ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
477 | ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
478 | plt.legend(loc='lower right') |
|
478 | plt.legend(loc='lower right') | |
479 | self.ystep_given = 50 |
|
479 | self.ystep_given = 50 | |
480 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
480 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
481 | ax.grid(which='minor') |
|
481 | ax.grid(which='minor') | |
482 |
|
482 | |||
483 | else: |
|
483 | else: | |
484 | self.clear_figures() |
|
484 | self.clear_figures() | |
485 | ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
485 | ax.errorbar(Te, y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
486 | ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
486 | ax.errorbar(Ti, y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
487 | plt.legend(loc='lower right') |
|
487 | plt.legend(loc='lower right') | |
488 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
488 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
489 |
|
489 | |||
490 |
|
490 | |||
491 | class TempsHPPlot(Plot): |
|
491 | class TempsHPPlot(Plot): | |
492 | ''' |
|
492 | ''' | |
493 | Written by R. Flores |
|
493 | Written by R. Flores | |
494 | ''' |
|
494 | ''' | |
495 | ''' |
|
495 | ''' | |
496 | Plot for Temperatures Hybrid Experiment |
|
496 | Plot for Temperatures Hybrid Experiment | |
497 | ''' |
|
497 | ''' | |
498 |
|
498 | |||
499 | CODE = 'temps_LP' |
|
499 | CODE = 'temps_LP' | |
500 | #plot_name = 'Temperatures' |
|
500 | #plot_name = 'Temperatures' | |
501 | plot_type = 'scatterbuffer' |
|
501 | plot_type = 'scatterbuffer' | |
502 |
|
502 | |||
503 |
|
503 | |||
504 | def setup(self): |
|
504 | def setup(self): | |
505 |
|
505 | |||
506 | self.ncols = 1 |
|
506 | self.ncols = 1 | |
507 | self.nrows = 1 |
|
507 | self.nrows = 1 | |
508 | self.nplots = 1 |
|
508 | self.nplots = 1 | |
509 | self.ylabel = 'Range [km]' |
|
509 | self.ylabel = 'Range [km]' | |
510 | self.xlabel = 'Temperature (K)' |
|
510 | self.xlabel = 'Temperature (K)' | |
511 | self.titles = ['Electron/Ion Temperatures'] |
|
511 | self.titles = ['Electron/Ion Temperatures'] | |
512 | self.width = 3.5 |
|
512 | self.width = 3.5 | |
513 | self.height = 6.5 |
|
513 | self.height = 6.5 | |
514 | self.colorbar = False |
|
514 | self.colorbar = False | |
515 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
515 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
516 |
|
516 | |||
517 | def update(self, dataOut): |
|
517 | def update(self, dataOut): | |
518 | data = {} |
|
518 | data = {} | |
519 | meta = {} |
|
519 | meta = {} | |
520 |
|
520 | |||
521 |
|
521 | |||
522 | data['Te'] = numpy.concatenate((dataOut.te2[:dataOut.cut],dataOut.te[dataOut.cut:])) |
|
522 | data['Te'] = numpy.concatenate((dataOut.te2[:dataOut.cut],dataOut.te[dataOut.cut:])) | |
523 | data['Ti'] = numpy.concatenate((dataOut.ti2[:dataOut.cut],dataOut.ti[dataOut.cut:])) |
|
523 | data['Ti'] = numpy.concatenate((dataOut.ti2[:dataOut.cut],dataOut.ti[dataOut.cut:])) | |
524 | data['Te_error'] = numpy.concatenate((dataOut.ete2[:dataOut.cut],dataOut.ete[dataOut.cut:])) |
|
524 | data['Te_error'] = numpy.concatenate((dataOut.ete2[:dataOut.cut],dataOut.ete[dataOut.cut:])) | |
525 | data['Ti_error'] = numpy.concatenate((dataOut.eti2[:dataOut.cut],dataOut.eti[dataOut.cut:])) |
|
525 | data['Ti_error'] = numpy.concatenate((dataOut.eti2[:dataOut.cut],dataOut.eti[dataOut.cut:])) | |
526 |
|
526 | |||
527 | meta['yrange'] = dataOut.heightList[0:dataOut.NACF] |
|
527 | meta['yrange'] = dataOut.heightList[0:dataOut.NACF] | |
528 |
|
528 | |||
529 | return data, meta |
|
529 | return data, meta | |
530 |
|
530 | |||
531 | def plot(self): |
|
531 | def plot(self): | |
532 |
|
532 | |||
533 |
|
533 | |||
534 | self.y = self.data.yrange |
|
534 | self.y = self.data.yrange | |
535 | self.xmin = -100 |
|
535 | self.xmin = -100 | |
536 | self.xmax = 4500 |
|
536 | self.xmax = 4500 | |
537 | ax = self.axes[0] |
|
537 | ax = self.axes[0] | |
538 |
|
538 | |||
539 | data = self.data[-1] |
|
539 | data = self.data[-1] | |
540 |
|
540 | |||
541 | Te = data['Te'] |
|
541 | Te = data['Te'] | |
542 | Ti = data['Ti'] |
|
542 | Ti = data['Ti'] | |
543 | errTe = data['Te_error'] |
|
543 | errTe = data['Te_error'] | |
544 | errTi = data['Ti_error'] |
|
544 | errTi = data['Ti_error'] | |
545 |
|
545 | |||
546 | if ax.firsttime: |
|
546 | if ax.firsttime: | |
547 |
|
547 | |||
548 | ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
548 | ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
549 | ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
549 | ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
550 | plt.legend(loc='lower right') |
|
550 | plt.legend(loc='lower right') | |
551 | self.ystep_given = 200 |
|
551 | self.ystep_given = 200 | |
552 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
552 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
553 | ax.grid(which='minor') |
|
553 | ax.grid(which='minor') | |
554 |
|
554 | |||
555 | else: |
|
555 | else: | |
556 | self.clear_figures() |
|
556 | self.clear_figures() | |
557 | ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
557 | ax.errorbar(Te, self.y, xerr=errTe, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') | |
558 | ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
558 | ax.errorbar(Ti, self.y, fmt='k^', xerr=errTi,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') | |
559 | plt.legend(loc='lower right') |
|
559 | plt.legend(loc='lower right') | |
560 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
560 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
561 | ax.grid(which='minor') |
|
561 | ax.grid(which='minor') | |
562 |
|
562 | |||
563 |
|
563 | |||
564 | class FracsHPPlot(Plot): |
|
564 | class FracsHPPlot(Plot): | |
565 | ''' |
|
565 | ''' | |
566 | Written by R. Flores |
|
566 | Written by R. Flores | |
567 | ''' |
|
567 | ''' | |
568 | ''' |
|
568 | ''' | |
569 | Plot for Composition LP |
|
569 | Plot for Composition LP | |
570 | ''' |
|
570 | ''' | |
571 |
|
571 | |||
572 | CODE = 'fracs_LP' |
|
572 | CODE = 'fracs_LP' | |
573 | plot_type = 'scatterbuffer' |
|
573 | plot_type = 'scatterbuffer' | |
574 |
|
574 | |||
575 |
|
575 | |||
576 | def setup(self): |
|
576 | def setup(self): | |
577 |
|
577 | |||
578 | self.ncols = 1 |
|
578 | self.ncols = 1 | |
579 | self.nrows = 1 |
|
579 | self.nrows = 1 | |
580 | self.nplots = 1 |
|
580 | self.nplots = 1 | |
581 | self.ylabel = 'Range [km]' |
|
581 | self.ylabel = 'Range [km]' | |
582 | self.xlabel = 'Frac' |
|
582 | self.xlabel = 'Frac' | |
583 | self.titles = ['Composition'] |
|
583 | self.titles = ['Composition'] | |
584 | self.width = 3.5 |
|
584 | self.width = 3.5 | |
585 | self.height = 6.5 |
|
585 | self.height = 6.5 | |
586 | self.colorbar = False |
|
586 | self.colorbar = False | |
587 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
587 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
588 |
|
588 | |||
589 | def update(self, dataOut): |
|
589 | def update(self, dataOut): | |
590 | data = {} |
|
590 | data = {} | |
591 | meta = {} |
|
591 | meta = {} | |
592 |
|
592 | |||
593 | #aux_nan=numpy.zeros(dataOut.cut,'float32') |
|
593 | #aux_nan=numpy.zeros(dataOut.cut,'float32') | |
594 | #aux_nan[:]=numpy.nan |
|
594 | #aux_nan[:]=numpy.nan | |
595 | #data['ph'] = numpy.concatenate((aux_nan,dataOut.ph[dataOut.cut:])) |
|
595 | #data['ph'] = numpy.concatenate((aux_nan,dataOut.ph[dataOut.cut:])) | |
596 | #data['eph'] = numpy.concatenate((aux_nan,dataOut.eph[dataOut.cut:])) |
|
596 | #data['eph'] = numpy.concatenate((aux_nan,dataOut.eph[dataOut.cut:])) | |
597 |
|
597 | |||
598 | data['ph'] = dataOut.ph[dataOut.cut:] |
|
598 | data['ph'] = dataOut.ph[dataOut.cut:] | |
599 | data['eph'] = dataOut.eph[dataOut.cut:] |
|
599 | data['eph'] = dataOut.eph[dataOut.cut:] | |
600 | data['phe'] = dataOut.phe[dataOut.cut:] |
|
600 | data['phe'] = dataOut.phe[dataOut.cut:] | |
601 | data['ephe'] = dataOut.ephe[dataOut.cut:] |
|
601 | data['ephe'] = dataOut.ephe[dataOut.cut:] | |
602 |
|
602 | |||
603 | data['cut'] = dataOut.cut |
|
603 | data['cut'] = dataOut.cut | |
604 |
|
604 | |||
605 | meta['yrange'] = dataOut.heightList[0:dataOut.NACF] |
|
605 | meta['yrange'] = dataOut.heightList[0:dataOut.NACF] | |
606 |
|
606 | |||
607 |
|
607 | |||
608 | return data, meta |
|
608 | return data, meta | |
609 |
|
609 | |||
610 | def plot(self): |
|
610 | def plot(self): | |
611 |
|
611 | |||
612 | data = self.data[-1] |
|
612 | data = self.data[-1] | |
613 |
|
613 | |||
614 | ph = data['ph'] |
|
614 | ph = data['ph'] | |
615 | eph = data['eph'] |
|
615 | eph = data['eph'] | |
616 | phe = data['phe'] |
|
616 | phe = data['phe'] | |
617 | ephe = data['ephe'] |
|
617 | ephe = data['ephe'] | |
618 | cut = data['cut'] |
|
618 | cut = data['cut'] | |
619 | self.y = self.data.yrange |
|
619 | self.y = self.data.yrange | |
620 |
|
620 | |||
621 | self.xmin = 0 |
|
621 | self.xmin = 0 | |
622 | self.xmax = 1 |
|
622 | self.xmax = 1 | |
623 | ax = self.axes[0] |
|
623 | ax = self.axes[0] | |
624 |
|
624 | |||
625 | if ax.firsttime: |
|
625 | if ax.firsttime: | |
626 |
|
626 | |||
627 | ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') |
|
627 | ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') | |
628 | ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') |
|
628 | ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') | |
629 | plt.legend(loc='lower right') |
|
629 | plt.legend(loc='lower right') | |
630 | self.xstep_given = 0.2 |
|
630 | self.xstep_given = 0.2 | |
631 | self.ystep_given = 200 |
|
631 | self.ystep_given = 200 | |
632 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
632 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
633 | ax.grid(which='minor') |
|
633 | ax.grid(which='minor') | |
634 |
|
634 | |||
635 | else: |
|
635 | else: | |
636 | self.clear_figures() |
|
636 | self.clear_figures() | |
637 | ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') |
|
637 | ax.errorbar(ph, self.y[cut:], xerr=eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') | |
638 | ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') |
|
638 | ax.errorbar(phe, self.y[cut:], fmt='k^', xerr=ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') | |
639 | plt.legend(loc='lower right') |
|
639 | plt.legend(loc='lower right') | |
640 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
640 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
641 | ax.grid(which='minor') |
|
641 | ax.grid(which='minor') | |
642 |
|
642 | |||
643 | class EDensityPlot(Plot): |
|
643 | class EDensityPlot(Plot): | |
644 | ''' |
|
644 | ''' | |
645 | Written by R. Flores |
|
645 | Written by R. Flores | |
646 | ''' |
|
646 | ''' | |
647 | ''' |
|
647 | ''' | |
648 | Plot for electron density |
|
648 | Plot for electron density | |
649 | ''' |
|
649 | ''' | |
650 |
|
650 | |||
651 | CODE = 'den' |
|
651 | CODE = 'den' | |
652 | #plot_name = 'Electron Density' |
|
652 | #plot_name = 'Electron Density' | |
653 | plot_type = 'scatterbuffer' |
|
653 | plot_type = 'scatterbuffer' | |
654 |
|
654 | |||
655 | def setup(self): |
|
655 | def setup(self): | |
656 |
|
656 | |||
657 | self.ncols = 1 |
|
657 | self.ncols = 1 | |
658 | self.nrows = 1 |
|
658 | self.nrows = 1 | |
659 | self.nplots = 1 |
|
659 | self.nplots = 1 | |
660 | self.ylabel = 'Range [km]' |
|
660 | self.ylabel = 'Range [km]' | |
661 | self.xlabel = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' |
|
661 | self.xlabel = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' | |
662 | self.titles = ['Electron Density'] |
|
662 | self.titles = ['Electron Density'] | |
663 | self.width = 3.5 |
|
663 | self.width = 3.5 | |
664 | self.height = 5.5 |
|
664 | self.height = 5.5 | |
665 | self.colorbar = False |
|
665 | self.colorbar = False | |
666 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
666 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
667 |
|
667 | |||
668 | def update(self, dataOut): |
|
668 | def update(self, dataOut): | |
669 | data = {} |
|
669 | data = {} | |
670 | meta = {} |
|
670 | meta = {} | |
671 |
|
671 | |||
672 | data['den_power'] = dataOut.ph2[:dataOut.NSHTS] |
|
672 | data['den_power'] = dataOut.ph2[:dataOut.NSHTS] | |
673 | data['den_Faraday'] = dataOut.dphi[:dataOut.NSHTS] |
|
673 | data['den_Faraday'] = dataOut.dphi[:dataOut.NSHTS] | |
674 | data['den_error'] = dataOut.sdp2[:dataOut.NSHTS] |
|
674 | data['den_error'] = dataOut.sdp2[:dataOut.NSHTS] | |
675 | #data['err_Faraday'] = dataOut.sdn1[:dataOut.NSHTS] |
|
675 | #data['err_Faraday'] = dataOut.sdn1[:dataOut.NSHTS] | |
676 | #print(numpy.shape(data['den_power'])) |
|
676 | #print(numpy.shape(data['den_power'])) | |
677 | #print(numpy.shape(data['den_Faraday'])) |
|
677 | #print(numpy.shape(data['den_Faraday'])) | |
678 | #print(numpy.shape(data['den_error'])) |
|
678 | #print(numpy.shape(data['den_error'])) | |
679 |
|
679 | |||
680 | data['NSHTS'] = dataOut.NSHTS |
|
680 | data['NSHTS'] = dataOut.NSHTS | |
681 |
|
681 | |||
682 | meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] |
|
682 | meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] | |
683 |
|
683 | |||
684 | return data, meta |
|
684 | return data, meta | |
685 |
|
685 | |||
686 | def plot(self): |
|
686 | def plot(self): | |
687 |
|
687 | |||
688 | y = self.data.yrange |
|
688 | y = self.data.yrange | |
689 |
|
689 | |||
690 | #self.xmin = 1e3 |
|
690 | #self.xmin = 1e3 | |
691 | #self.xmax = 1e7 |
|
691 | #self.xmax = 1e7 | |
692 |
|
692 | |||
693 | ax = self.axes[0] |
|
693 | ax = self.axes[0] | |
694 |
|
694 | |||
695 | data = self.data[-1] |
|
695 | data = self.data[-1] | |
696 |
|
696 | |||
697 | DenPow = data['den_power'] |
|
697 | DenPow = data['den_power'] | |
698 | DenFar = data['den_Faraday'] |
|
698 | DenFar = data['den_Faraday'] | |
699 | errDenPow = data['den_error'] |
|
699 | errDenPow = data['den_error'] | |
700 | #errFaraday = data['err_Faraday'] |
|
700 | #errFaraday = data['err_Faraday'] | |
701 |
|
701 | |||
702 | NSHTS = data['NSHTS'] |
|
702 | NSHTS = data['NSHTS'] | |
703 |
|
703 | |||
704 | if self.CODE == 'denLP': |
|
704 | if self.CODE == 'denLP': | |
705 | DenPowLP = data['den_LP'] |
|
705 | DenPowLP = data['den_LP'] | |
706 | errDenPowLP = data['den_LP_error'] |
|
706 | errDenPowLP = data['den_LP_error'] | |
707 | cut = data['cut'] |
|
707 | cut = data['cut'] | |
708 |
|
708 | |||
709 | if ax.firsttime: |
|
709 | if ax.firsttime: | |
710 | self.autoxticks=False |
|
710 | self.autoxticks=False | |
711 | #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
711 | #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) | |
712 | ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2,linestyle='-') |
|
712 | ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2,linestyle='-') | |
713 | #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) |
|
713 | #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) | |
714 | ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-') |
|
714 | ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-') | |
715 |
|
715 | |||
716 | if self.CODE=='denLP': |
|
716 | if self.CODE=='denLP': | |
717 | ax.errorbar(DenPowLP[cut:], y[cut:], xerr=errDenPowLP[cut:], fmt='r^-',elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) |
|
717 | ax.errorbar(DenPowLP[cut:], y[cut:], xerr=errDenPowLP[cut:], fmt='r^-',elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) | |
718 |
|
718 | |||
719 | plt.legend(loc='upper left',fontsize=8.5) |
|
719 | plt.legend(loc='upper left',fontsize=8.5) | |
720 | #plt.legend(loc='lower left',fontsize=8.5) |
|
720 | #plt.legend(loc='lower left',fontsize=8.5) | |
721 | ax.set_xscale("log", nonposx='clip') |
|
721 | ax.set_xscale("log", nonposx='clip') | |
722 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) |
|
722 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) | |
723 | self.ystep_given=100 |
|
723 | self.ystep_given=100 | |
724 | if self.CODE=='denLP': |
|
724 | if self.CODE=='denLP': | |
725 | self.ystep_given=200 |
|
725 | self.ystep_given=200 | |
726 | ax.set_yticks(grid_y_ticks,minor=True) |
|
726 | ax.set_yticks(grid_y_ticks,minor=True) | |
727 | locmaj = LogLocator(base=10,numticks=12) |
|
727 | locmaj = LogLocator(base=10,numticks=12) | |
728 | ax.xaxis.set_major_locator(locmaj) |
|
728 | ax.xaxis.set_major_locator(locmaj) | |
729 | locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12) |
|
729 | locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12) | |
730 | ax.xaxis.set_minor_locator(locmin) |
|
730 | ax.xaxis.set_minor_locator(locmin) | |
731 | ax.xaxis.set_minor_formatter(NullFormatter()) |
|
731 | ax.xaxis.set_minor_formatter(NullFormatter()) | |
732 | ax.grid(which='minor') |
|
732 | ax.grid(which='minor') | |
733 |
|
733 | |||
734 | else: |
|
734 | else: | |
735 | dataBefore = self.data[-2] |
|
735 | dataBefore = self.data[-2] | |
736 | DenPowBefore = dataBefore['den_power'] |
|
736 | DenPowBefore = dataBefore['den_power'] | |
737 | self.clear_figures() |
|
737 | self.clear_figures() | |
738 | #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
738 | #ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) | |
739 | ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2,linestyle='-') |
|
739 | ax.errorbar(DenFar, y[:NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday',markersize=2,linestyle='-') | |
740 | #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) |
|
740 | #ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) | |
741 | ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-') |
|
741 | ax.errorbar(DenPow, y[:NSHTS], fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-') | |
742 | ax.errorbar(DenPowBefore, y[:NSHTS], elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed") |
|
742 | ax.errorbar(DenPowBefore, y[:NSHTS], elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed") | |
743 |
|
743 | |||
744 | if self.CODE=='denLP': |
|
744 | if self.CODE=='denLP': | |
745 | ax.errorbar(DenPowLP[cut:], y[cut:], fmt='r^-', xerr=errDenPowLP[cut:],elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) |
|
745 | ax.errorbar(DenPowLP[cut:], y[cut:], fmt='r^-', xerr=errDenPowLP[cut:],elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) | |
746 |
|
746 | |||
747 | ax.set_xscale("log", nonposx='clip') |
|
747 | ax.set_xscale("log", nonposx='clip') | |
748 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) |
|
748 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) | |
749 | ax.set_yticks(grid_y_ticks,minor=True) |
|
749 | ax.set_yticks(grid_y_ticks,minor=True) | |
750 | locmaj = LogLocator(base=10,numticks=12) |
|
750 | locmaj = LogLocator(base=10,numticks=12) | |
751 | ax.xaxis.set_major_locator(locmaj) |
|
751 | ax.xaxis.set_major_locator(locmaj) | |
752 | locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12) |
|
752 | locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12) | |
753 | ax.xaxis.set_minor_locator(locmin) |
|
753 | ax.xaxis.set_minor_locator(locmin) | |
754 | ax.xaxis.set_minor_formatter(NullFormatter()) |
|
754 | ax.xaxis.set_minor_formatter(NullFormatter()) | |
755 | ax.grid(which='minor') |
|
755 | ax.grid(which='minor') | |
756 | plt.legend(loc='upper left',fontsize=8.5) |
|
756 | plt.legend(loc='upper left',fontsize=8.5) | |
757 | #plt.legend(loc='lower left',fontsize=8.5) |
|
757 | #plt.legend(loc='lower left',fontsize=8.5) | |
758 |
|
758 | |||
|
759 | class RelativeDenPlot(Plot): | |||
|
760 | ''' | |||
|
761 | Written by R. Flores | |||
|
762 | ''' | |||
|
763 | ''' | |||
|
764 | Plot for electron density | |||
|
765 | ''' | |||
|
766 | ||||
|
767 | CODE = 'den' | |||
|
768 | #plot_name = 'Electron Density' | |||
|
769 | plot_type = 'scatterbuffer' | |||
|
770 | ||||
|
771 | def setup(self): | |||
|
772 | ||||
|
773 | self.ncols = 1 | |||
|
774 | self.nrows = 1 | |||
|
775 | self.nplots = 1 | |||
|
776 | self.ylabel = 'Range [km]' | |||
|
777 | self.xlabel = r'$\mathrm{N_e}$ Relative Electron Density ($\mathrm{1/cm^3}$)' | |||
|
778 | self.titles = ['Electron Density'] | |||
|
779 | self.width = 3.5 | |||
|
780 | self.height = 5.5 | |||
|
781 | self.colorbar = False | |||
|
782 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |||
|
783 | ||||
|
784 | def update(self, dataOut): | |||
|
785 | data = {} | |||
|
786 | meta = {} | |||
|
787 | ||||
|
788 | data['den_power'] = dataOut.ph2 | |||
|
789 | data['den_error'] = dataOut.sdp2 | |||
|
790 | ||||
|
791 | meta['yrange'] = dataOut.heightList | |||
|
792 | ||||
|
793 | return data, meta | |||
|
794 | ||||
|
795 | def plot(self): | |||
|
796 | ||||
|
797 | y = self.data.yrange | |||
|
798 | ||||
|
799 | ax = self.axes[0] | |||
|
800 | ||||
|
801 | data = self.data[-1] | |||
|
802 | ||||
|
803 | DenPow = data['den_power'] | |||
|
804 | errDenPow = data['den_error'] | |||
|
805 | ||||
|
806 | if ax.firsttime: | |||
|
807 | self.autoxticks=False | |||
|
808 | ax.errorbar(DenPow, y, fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-') | |||
|
809 | ||||
|
810 | plt.legend(loc='upper left',fontsize=8.5) | |||
|
811 | #plt.legend(loc='lower left',fontsize=8.5) | |||
|
812 | ax.set_xscale("log", nonposx='clip') | |||
|
813 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) | |||
|
814 | self.ystep_given=100 | |||
|
815 | ax.set_yticks(grid_y_ticks,minor=True) | |||
|
816 | locmaj = LogLocator(base=10,numticks=12) | |||
|
817 | ax.xaxis.set_major_locator(locmaj) | |||
|
818 | locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12) | |||
|
819 | ax.xaxis.set_minor_locator(locmin) | |||
|
820 | ax.xaxis.set_minor_formatter(NullFormatter()) | |||
|
821 | ax.grid(which='minor') | |||
|
822 | ||||
|
823 | else: | |||
|
824 | dataBefore = self.data[-2] | |||
|
825 | DenPowBefore = dataBefore['den_power'] | |||
|
826 | self.clear_figures() | |||
|
827 | ax.errorbar(DenPow, y, fmt='k^-', xerr=errDenPow,elinewidth=1.0,color='b',linewidth=1.0, label='Power',markersize=2,linestyle='-') | |||
|
828 | ax.errorbar(DenPowBefore, y, elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed") | |||
|
829 | ||||
|
830 | ax.set_xscale("log", nonposx='clip') | |||
|
831 | grid_y_ticks=numpy.arange(numpy.nanmin(y),numpy.nanmax(y),50) | |||
|
832 | ax.set_yticks(grid_y_ticks,minor=True) | |||
|
833 | locmaj = LogLocator(base=10,numticks=12) | |||
|
834 | ax.xaxis.set_major_locator(locmaj) | |||
|
835 | locmin = LogLocator(base=10.0,subs=(0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9),numticks=12) | |||
|
836 | ax.xaxis.set_minor_locator(locmin) | |||
|
837 | ax.xaxis.set_minor_formatter(NullFormatter()) | |||
|
838 | ax.grid(which='minor') | |||
|
839 | plt.legend(loc='upper left',fontsize=8.5) | |||
|
840 | #plt.legend(loc='lower left',fontsize=8.5) | |||
|
841 | ||||
759 | class FaradayAnglePlot(Plot): |
|
842 | class FaradayAnglePlot(Plot): | |
760 | ''' |
|
843 | ''' | |
761 | Written by R. Flores |
|
844 | Written by R. Flores | |
762 | ''' |
|
845 | ''' | |
763 | ''' |
|
846 | ''' | |
764 | Plot for electron density |
|
847 | Plot for electron density | |
765 | ''' |
|
848 | ''' | |
766 |
|
849 | |||
767 | CODE = 'angle' |
|
850 | CODE = 'angle' | |
768 | plot_name = 'Faraday Angle' |
|
851 | plot_name = 'Faraday Angle' | |
769 | plot_type = 'scatterbuffer' |
|
852 | plot_type = 'scatterbuffer' | |
770 |
|
853 | |||
771 | def setup(self): |
|
854 | def setup(self): | |
772 |
|
855 | |||
773 | self.ncols = 1 |
|
856 | self.ncols = 1 | |
774 | self.nrows = 1 |
|
857 | self.nrows = 1 | |
775 | self.nplots = 1 |
|
858 | self.nplots = 1 | |
776 | self.ylabel = 'Range [km]' |
|
859 | self.ylabel = 'Range [km]' | |
777 | self.xlabel = 'Faraday Angle (º)' |
|
860 | self.xlabel = 'Faraday Angle (º)' | |
778 | self.titles = ['Electron Density'] |
|
861 | self.titles = ['Electron Density'] | |
779 | self.width = 3.5 |
|
862 | self.width = 3.5 | |
780 | self.height = 5.5 |
|
863 | self.height = 5.5 | |
781 | self.colorbar = False |
|
864 | self.colorbar = False | |
782 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
865 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
783 |
|
866 | |||
784 | def update(self, dataOut): |
|
867 | def update(self, dataOut): | |
785 | data = {} |
|
868 | data = {} | |
786 | meta = {} |
|
869 | meta = {} | |
787 |
|
870 | |||
788 | data['angle'] = numpy.degrees(dataOut.phi) |
|
871 | data['angle'] = numpy.degrees(dataOut.phi) | |
789 | #''' |
|
872 | #''' | |
790 | #print(dataOut.phi_uwrp) |
|
873 | #print(dataOut.phi_uwrp) | |
791 | #print(data['angle']) |
|
874 | #print(data['angle']) | |
792 | #exit(1) |
|
875 | #exit(1) | |
793 | #''' |
|
876 | #''' | |
794 | data['dphi'] = dataOut.dphi_uc*10 |
|
877 | data['dphi'] = dataOut.dphi_uc*10 | |
795 | #print(dataOut.dphi) |
|
878 | #print(dataOut.dphi) | |
796 |
|
879 | |||
797 | #data['NSHTS'] = dataOut.NSHTS |
|
880 | #data['NSHTS'] = dataOut.NSHTS | |
798 |
|
881 | |||
799 | #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] |
|
882 | #meta['yrange'] = dataOut.heightList[0:dataOut.NSHTS] | |
800 |
|
883 | |||
801 | return data, meta |
|
884 | return data, meta | |
802 |
|
885 | |||
803 | def plot(self): |
|
886 | def plot(self): | |
804 |
|
887 | |||
805 | data = self.data[-1] |
|
888 | data = self.data[-1] | |
806 | self.x = data[self.CODE] |
|
889 | self.x = data[self.CODE] | |
807 | dphi = data['dphi'] |
|
890 | dphi = data['dphi'] | |
808 | self.y = self.data.yrange |
|
891 | self.y = self.data.yrange | |
809 | self.xmin = -360#-180 |
|
892 | self.xmin = -360#-180 | |
810 | self.xmax = 360#180 |
|
893 | self.xmax = 360#180 | |
811 | ax = self.axes[0] |
|
894 | ax = self.axes[0] | |
812 |
|
895 | |||
813 | if ax.firsttime: |
|
896 | if ax.firsttime: | |
814 | self.autoxticks=False |
|
897 | self.autoxticks=False | |
815 | #if self.CODE=='den': |
|
898 | #if self.CODE=='den': | |
816 | ax.plot(self.x, self.y,marker='o',color='g',linewidth=1.0,markersize=2) |
|
899 | ax.plot(self.x, self.y,marker='o',color='g',linewidth=1.0,markersize=2) | |
817 | ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2) |
|
900 | ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2) | |
818 |
|
901 | |||
819 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) |
|
902 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) | |
820 | self.ystep_given=100 |
|
903 | self.ystep_given=100 | |
821 | if self.CODE=='denLP': |
|
904 | if self.CODE=='denLP': | |
822 | self.ystep_given=200 |
|
905 | self.ystep_given=200 | |
823 | ax.set_yticks(grid_y_ticks,minor=True) |
|
906 | ax.set_yticks(grid_y_ticks,minor=True) | |
824 | ax.grid(which='minor') |
|
907 | ax.grid(which='minor') | |
825 | #plt.tight_layout() |
|
908 | #plt.tight_layout() | |
826 | else: |
|
909 | else: | |
827 |
|
910 | |||
828 | self.clear_figures() |
|
911 | self.clear_figures() | |
829 | #if self.CODE=='den': |
|
912 | #if self.CODE=='den': | |
830 | #print(numpy.shape(self.x)) |
|
913 | #print(numpy.shape(self.x)) | |
831 | ax.plot(self.x, self.y, marker='o',color='g',linewidth=1.0, markersize=2) |
|
914 | ax.plot(self.x, self.y, marker='o',color='g',linewidth=1.0, markersize=2) | |
832 | ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2) |
|
915 | ax.plot(dphi, self.y,marker='o',color='blue',linewidth=1.0,markersize=2) | |
833 |
|
916 | |||
834 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) |
|
917 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) | |
835 | ax.set_yticks(grid_y_ticks,minor=True) |
|
918 | ax.set_yticks(grid_y_ticks,minor=True) | |
836 | ax.grid(which='minor') |
|
919 | ax.grid(which='minor') | |
837 |
|
920 | |||
838 | class EDensityHPPlot(EDensityPlot): |
|
921 | class EDensityHPPlot(EDensityPlot): | |
839 | ''' |
|
922 | ''' | |
840 | Written by R. Flores |
|
923 | Written by R. Flores | |
841 | ''' |
|
924 | ''' | |
842 | ''' |
|
925 | ''' | |
843 | Plot for Electron Density Hybrid Experiment |
|
926 | Plot for Electron Density Hybrid Experiment | |
844 | ''' |
|
927 | ''' | |
845 |
|
928 | |||
846 | CODE = 'denLP' |
|
929 | CODE = 'denLP' | |
847 | plot_name = 'Electron Density' |
|
930 | plot_name = 'Electron Density' | |
848 | plot_type = 'scatterbuffer' |
|
931 | plot_type = 'scatterbuffer' | |
849 |
|
932 | |||
850 | def update(self, dataOut): |
|
933 | def update(self, dataOut): | |
851 | data = {} |
|
934 | data = {} | |
852 | meta = {} |
|
935 | meta = {} | |
853 |
|
936 | |||
854 | data['den_power'] = dataOut.ph2[:dataOut.NSHTS] |
|
937 | data['den_power'] = dataOut.ph2[:dataOut.NSHTS] | |
855 | data['den_Faraday']=dataOut.dphi[:dataOut.NSHTS] |
|
938 | data['den_Faraday']=dataOut.dphi[:dataOut.NSHTS] | |
856 | data['den_error']=dataOut.sdp2[:dataOut.NSHTS] |
|
939 | data['den_error']=dataOut.sdp2[:dataOut.NSHTS] | |
857 | data['den_LP']=dataOut.ne[:dataOut.NACF] |
|
940 | data['den_LP']=dataOut.ne[:dataOut.NACF] | |
858 | data['den_LP_error']=dataOut.ene[:dataOut.NACF]*dataOut.ne[:dataOut.NACF]*0.434 |
|
941 | data['den_LP_error']=dataOut.ene[:dataOut.NACF]*dataOut.ne[:dataOut.NACF]*0.434 | |
859 | #self.ene=10**dataOut.ene[:dataOut.NACF] |
|
942 | #self.ene=10**dataOut.ene[:dataOut.NACF] | |
860 | data['NSHTS']=dataOut.NSHTS |
|
943 | data['NSHTS']=dataOut.NSHTS | |
861 | data['cut']=dataOut.cut |
|
944 | data['cut']=dataOut.cut | |
862 |
|
945 | |||
863 | return data, meta |
|
946 | return data, meta | |
864 |
|
947 | |||
865 |
|
948 | |||
866 | class ACFsPlot(Plot): |
|
949 | class ACFsPlot(Plot): | |
867 | ''' |
|
950 | ''' | |
868 | Written by R. Flores |
|
951 | Written by R. Flores | |
869 | ''' |
|
952 | ''' | |
870 | ''' |
|
953 | ''' | |
871 | Plot for ACFs Double Pulse Experiment |
|
954 | Plot for ACFs Double Pulse Experiment | |
872 | ''' |
|
955 | ''' | |
873 |
|
956 | |||
874 | CODE = 'acfs' |
|
957 | CODE = 'acfs' | |
875 | #plot_name = 'ACF' |
|
958 | #plot_name = 'ACF' | |
876 | plot_type = 'scatterbuffer' |
|
959 | plot_type = 'scatterbuffer' | |
877 |
|
960 | |||
878 |
|
961 | |||
879 | def setup(self): |
|
962 | def setup(self): | |
880 | self.ncols = 1 |
|
963 | self.ncols = 1 | |
881 | self.nrows = 1 |
|
964 | self.nrows = 1 | |
882 | self.nplots = 1 |
|
965 | self.nplots = 1 | |
883 | self.ylabel = 'Range [km]' |
|
966 | self.ylabel = 'Range [km]' | |
884 | self.xlabel = 'Lag (ms)' |
|
967 | self.xlabel = 'Lag (ms)' | |
885 | self.titles = ['ACFs'] |
|
968 | self.titles = ['ACFs'] | |
886 | self.width = 3.5 |
|
969 | self.width = 3.5 | |
887 | self.height = 5.5 |
|
970 | self.height = 5.5 | |
888 | self.colorbar = False |
|
971 | self.colorbar = False | |
889 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
972 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
890 |
|
973 | |||
891 | def update(self, dataOut): |
|
974 | def update(self, dataOut): | |
892 | data = {} |
|
975 | data = {} | |
893 | meta = {} |
|
976 | meta = {} | |
894 |
|
977 | |||
895 | data['ACFs'] = dataOut.acfs_to_plot |
|
978 | data['ACFs'] = dataOut.acfs_to_plot | |
896 | data['ACFs_error'] = dataOut.acfs_error_to_plot |
|
979 | data['ACFs_error'] = dataOut.acfs_error_to_plot | |
897 | data['lags'] = dataOut.lags_to_plot |
|
980 | data['lags'] = dataOut.lags_to_plot | |
898 | data['Lag_contaminated_1'] = dataOut.x_igcej_to_plot |
|
981 | data['Lag_contaminated_1'] = dataOut.x_igcej_to_plot | |
899 | data['Lag_contaminated_2'] = dataOut.x_ibad_to_plot |
|
982 | data['Lag_contaminated_2'] = dataOut.x_ibad_to_plot | |
900 | data['Height_contaminated_1'] = dataOut.y_igcej_to_plot |
|
983 | data['Height_contaminated_1'] = dataOut.y_igcej_to_plot | |
901 | data['Height_contaminated_2'] = dataOut.y_ibad_to_plot |
|
984 | data['Height_contaminated_2'] = dataOut.y_ibad_to_plot | |
902 |
|
985 | |||
903 | meta['yrange'] = numpy.array([]) |
|
986 | meta['yrange'] = numpy.array([]) | |
904 | #meta['NSHTS'] = dataOut.NSHTS |
|
987 | #meta['NSHTS'] = dataOut.NSHTS | |
905 | #meta['DPL'] = dataOut.DPL |
|
988 | #meta['DPL'] = dataOut.DPL | |
906 | data['NSHTS'] = dataOut.NSHTS #This is metadata |
|
989 | data['NSHTS'] = dataOut.NSHTS #This is metadata | |
907 | data['DPL'] = dataOut.DPL #This is metadata |
|
990 | data['DPL'] = dataOut.DPL #This is metadata | |
908 |
|
991 | |||
909 | return data, meta |
|
992 | return data, meta | |
910 |
|
993 | |||
911 | def plot(self): |
|
994 | def plot(self): | |
912 |
|
995 | |||
913 | data = self.data[-1] |
|
996 | data = self.data[-1] | |
914 | #NSHTS = self.meta['NSHTS'] |
|
997 | #NSHTS = self.meta['NSHTS'] | |
915 | #DPL = self.meta['DPL'] |
|
998 | #DPL = self.meta['DPL'] | |
916 | NSHTS = data['NSHTS'] #This is metadata |
|
999 | NSHTS = data['NSHTS'] #This is metadata | |
917 | DPL = data['DPL'] #This is metadata |
|
1000 | DPL = data['DPL'] #This is metadata | |
918 |
|
1001 | |||
919 | lags = data['lags'] |
|
1002 | lags = data['lags'] | |
920 | ACFs = data['ACFs'] |
|
1003 | ACFs = data['ACFs'] | |
921 | errACFs = data['ACFs_error'] |
|
1004 | errACFs = data['ACFs_error'] | |
922 | BadLag1 = data['Lag_contaminated_1'] |
|
1005 | BadLag1 = data['Lag_contaminated_1'] | |
923 | BadLag2 = data['Lag_contaminated_2'] |
|
1006 | BadLag2 = data['Lag_contaminated_2'] | |
924 | BadHei1 = data['Height_contaminated_1'] |
|
1007 | BadHei1 = data['Height_contaminated_1'] | |
925 | BadHei2 = data['Height_contaminated_2'] |
|
1008 | BadHei2 = data['Height_contaminated_2'] | |
926 |
|
1009 | |||
927 | self.xmin = 0.0 |
|
1010 | self.xmin = 0.0 | |
928 | self.xmax = 2.0 |
|
1011 | self.xmax = 2.0 | |
929 | self.y = ACFs |
|
1012 | self.y = ACFs | |
930 |
|
1013 | |||
931 | ax = self.axes[0] |
|
1014 | ax = self.axes[0] | |
932 |
|
1015 | |||
933 | if ax.firsttime: |
|
1016 | if ax.firsttime: | |
934 |
|
1017 | |||
935 | for i in range(NSHTS): |
|
1018 | for i in range(NSHTS): | |
936 | x_aux = numpy.isfinite(lags[i,:]) |
|
1019 | x_aux = numpy.isfinite(lags[i,:]) | |
937 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
1020 | y_aux = numpy.isfinite(ACFs[i,:]) | |
938 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
1021 | yerr_aux = numpy.isfinite(errACFs[i,:]) | |
939 | x_igcej_aux = numpy.isfinite(BadLag1[i,:]) |
|
1022 | x_igcej_aux = numpy.isfinite(BadLag1[i,:]) | |
940 | y_igcej_aux = numpy.isfinite(BadHei1[i,:]) |
|
1023 | y_igcej_aux = numpy.isfinite(BadHei1[i,:]) | |
941 | x_ibad_aux = numpy.isfinite(BadLag2[i,:]) |
|
1024 | x_ibad_aux = numpy.isfinite(BadLag2[i,:]) | |
942 | y_ibad_aux = numpy.isfinite(BadHei2[i,:]) |
|
1025 | y_ibad_aux = numpy.isfinite(BadHei2[i,:]) | |
943 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
1026 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: | |
944 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',marker='o',linewidth=1.0,markersize=2) |
|
1027 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',marker='o',linewidth=1.0,markersize=2) | |
945 | ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2) |
|
1028 | ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2) | |
946 | ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2) |
|
1029 | ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2) | |
947 |
|
1030 | |||
948 | self.xstep_given = (self.xmax-self.xmin)/(DPL-1) |
|
1031 | self.xstep_given = (self.xmax-self.xmin)/(DPL-1) | |
949 | self.ystep_given = 50 |
|
1032 | self.ystep_given = 50 | |
950 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
1033 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
951 | ax.grid(which='minor') |
|
1034 | ax.grid(which='minor') | |
952 |
|
1035 | |||
953 | else: |
|
1036 | else: | |
954 | self.clear_figures() |
|
1037 | self.clear_figures() | |
955 | for i in range(NSHTS): |
|
1038 | for i in range(NSHTS): | |
956 | x_aux = numpy.isfinite(lags[i,:]) |
|
1039 | x_aux = numpy.isfinite(lags[i,:]) | |
957 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
1040 | y_aux = numpy.isfinite(ACFs[i,:]) | |
958 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
1041 | yerr_aux = numpy.isfinite(errACFs[i,:]) | |
959 | x_igcej_aux = numpy.isfinite(BadLag1[i,:]) |
|
1042 | x_igcej_aux = numpy.isfinite(BadLag1[i,:]) | |
960 | y_igcej_aux = numpy.isfinite(BadHei1[i,:]) |
|
1043 | y_igcej_aux = numpy.isfinite(BadHei1[i,:]) | |
961 | x_ibad_aux = numpy.isfinite(BadLag2[i,:]) |
|
1044 | x_ibad_aux = numpy.isfinite(BadLag2[i,:]) | |
962 | y_ibad_aux = numpy.isfinite(BadHei2[i,:]) |
|
1045 | y_ibad_aux = numpy.isfinite(BadHei2[i,:]) | |
963 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
1046 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: | |
964 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],linewidth=1.0,markersize=2,color='b',marker='o') |
|
1047 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],linewidth=1.0,markersize=2,color='b',marker='o') | |
965 | ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2) |
|
1048 | ax.plot(BadLag1[i,x_igcej_aux],BadHei1[i,y_igcej_aux],'x',color='red',markersize=2) | |
966 | ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2) |
|
1049 | ax.plot(BadLag2[i,x_ibad_aux],BadHei2[i,y_ibad_aux],'X',color='red',markersize=2) | |
967 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
1050 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
968 |
|
1051 | |||
969 | class ACFsLPPlot(Plot): |
|
1052 | class ACFsLPPlot(Plot): | |
970 | ''' |
|
1053 | ''' | |
971 | Written by R. Flores |
|
1054 | Written by R. Flores | |
972 | ''' |
|
1055 | ''' | |
973 | ''' |
|
1056 | ''' | |
974 | Plot for ACFs Double Pulse Experiment |
|
1057 | Plot for ACFs Double Pulse Experiment | |
975 | ''' |
|
1058 | ''' | |
976 |
|
1059 | |||
977 | CODE = 'acfs_LP' |
|
1060 | CODE = 'acfs_LP' | |
978 | #plot_name = 'ACF' |
|
1061 | #plot_name = 'ACF' | |
979 | plot_type = 'scatterbuffer' |
|
1062 | plot_type = 'scatterbuffer' | |
980 |
|
1063 | |||
981 |
|
1064 | |||
982 | def setup(self): |
|
1065 | def setup(self): | |
983 | self.ncols = 1 |
|
1066 | self.ncols = 1 | |
984 | self.nrows = 1 |
|
1067 | self.nrows = 1 | |
985 | self.nplots = 1 |
|
1068 | self.nplots = 1 | |
986 | self.ylabel = 'Range [km]' |
|
1069 | self.ylabel = 'Range [km]' | |
987 | self.xlabel = 'Lag (ms)' |
|
1070 | self.xlabel = 'Lag (ms)' | |
988 | self.titles = ['ACFs'] |
|
1071 | self.titles = ['ACFs'] | |
989 | self.width = 3.5 |
|
1072 | self.width = 3.5 | |
990 | self.height = 5.5 |
|
1073 | self.height = 5.5 | |
991 | self.colorbar = False |
|
1074 | self.colorbar = False | |
992 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
1075 | self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
993 |
|
1076 | |||
994 | def update(self, dataOut): |
|
1077 | def update(self, dataOut): | |
995 | data = {} |
|
1078 | data = {} | |
996 | meta = {} |
|
1079 | meta = {} | |
997 |
|
1080 | |||
998 | aux=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') |
|
1081 | aux=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') | |
999 | errors=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') |
|
1082 | errors=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') | |
1000 | lags_LP_to_plot=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') |
|
1083 | lags_LP_to_plot=numpy.zeros((dataOut.NACF,dataOut.IBITS),'float32') | |
1001 |
|
1084 | |||
1002 | for i in range(dataOut.NACF): |
|
1085 | for i in range(dataOut.NACF): | |
1003 | for j in range(dataOut.IBITS): |
|
1086 | for j in range(dataOut.IBITS): | |
1004 | if numpy.abs(dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0])<1.0: |
|
1087 | if numpy.abs(dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0])<1.0: | |
1005 | aux[i,j]=dataOut.output_LP_integrated.real[j,i,0]/dataOut.output_LP_integrated.real[0,i,0] |
|
1088 | aux[i,j]=dataOut.output_LP_integrated.real[j,i,0]/dataOut.output_LP_integrated.real[0,i,0] | |
1006 | aux[i,j]=max(min(aux[i,j],1.0),-1.0)*dataOut.DH+dataOut.heightList[i] |
|
1089 | aux[i,j]=max(min(aux[i,j],1.0),-1.0)*dataOut.DH+dataOut.heightList[i] | |
1007 | lags_LP_to_plot[i,j]=dataOut.lags_LP[j] |
|
1090 | lags_LP_to_plot[i,j]=dataOut.lags_LP[j] | |
1008 | errors[i,j]=dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0]*dataOut.DH |
|
1091 | errors[i,j]=dataOut.errors[j,i]/dataOut.output_LP_integrated.real[0,i,0]*dataOut.DH | |
1009 | else: |
|
1092 | else: | |
1010 | aux[i,j]=numpy.nan |
|
1093 | aux[i,j]=numpy.nan | |
1011 | lags_LP_to_plot[i,j]=numpy.nan |
|
1094 | lags_LP_to_plot[i,j]=numpy.nan | |
1012 | errors[i,j]=numpy.nan |
|
1095 | errors[i,j]=numpy.nan | |
1013 |
|
1096 | |||
1014 | data['ACFs'] = aux |
|
1097 | data['ACFs'] = aux | |
1015 | data['ACFs_error'] = errors |
|
1098 | data['ACFs_error'] = errors | |
1016 | data['lags'] = lags_LP_to_plot |
|
1099 | data['lags'] = lags_LP_to_plot | |
1017 |
|
1100 | |||
1018 | meta['yrange'] = numpy.array([]) |
|
1101 | meta['yrange'] = numpy.array([]) | |
1019 | #meta['NACF'] = dataOut.NACF |
|
1102 | #meta['NACF'] = dataOut.NACF | |
1020 | #meta['NLAG'] = dataOut.NLAG |
|
1103 | #meta['NLAG'] = dataOut.NLAG | |
1021 | data['NACF'] = dataOut.NACF #This is metadata |
|
1104 | data['NACF'] = dataOut.NACF #This is metadata | |
1022 | data['NLAG'] = dataOut.NLAG #This is metadata |
|
1105 | data['NLAG'] = dataOut.NLAG #This is metadata | |
1023 |
|
1106 | |||
1024 | return data, meta |
|
1107 | return data, meta | |
1025 |
|
1108 | |||
1026 | def plot(self): |
|
1109 | def plot(self): | |
1027 |
|
1110 | |||
1028 | data = self.data[-1] |
|
1111 | data = self.data[-1] | |
1029 | #NACF = self.meta['NACF'] |
|
1112 | #NACF = self.meta['NACF'] | |
1030 | #NLAG = self.meta['NLAG'] |
|
1113 | #NLAG = self.meta['NLAG'] | |
1031 | NACF = data['NACF'] #This is metadata |
|
1114 | NACF = data['NACF'] #This is metadata | |
1032 | NLAG = data['NLAG'] #This is metadata |
|
1115 | NLAG = data['NLAG'] #This is metadata | |
1033 |
|
1116 | |||
1034 | lags = data['lags'] |
|
1117 | lags = data['lags'] | |
1035 | ACFs = data['ACFs'] |
|
1118 | ACFs = data['ACFs'] | |
1036 | errACFs = data['ACFs_error'] |
|
1119 | errACFs = data['ACFs_error'] | |
1037 |
|
1120 | |||
1038 | self.xmin = 0.0 |
|
1121 | self.xmin = 0.0 | |
1039 | self.xmax = 1.5 |
|
1122 | self.xmax = 1.5 | |
1040 |
|
1123 | |||
1041 | self.y = ACFs |
|
1124 | self.y = ACFs | |
1042 |
|
1125 | |||
1043 | ax = self.axes[0] |
|
1126 | ax = self.axes[0] | |
1044 |
|
1127 | |||
1045 | if ax.firsttime: |
|
1128 | if ax.firsttime: | |
1046 |
|
1129 | |||
1047 | for i in range(NACF): |
|
1130 | for i in range(NACF): | |
1048 | x_aux = numpy.isfinite(lags[i,:]) |
|
1131 | x_aux = numpy.isfinite(lags[i,:]) | |
1049 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
1132 | y_aux = numpy.isfinite(ACFs[i,:]) | |
1050 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
1133 | yerr_aux = numpy.isfinite(errACFs[i,:]) | |
1051 |
|
1134 | |||
1052 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
1135 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: | |
1053 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') |
|
1136 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') | |
1054 |
|
1137 | |||
1055 | #self.xstep_given = (self.xmax-self.xmin)/(self.data.NLAG-1) |
|
1138 | #self.xstep_given = (self.xmax-self.xmin)/(self.data.NLAG-1) | |
1056 | self.xstep_given=0.3 |
|
1139 | self.xstep_given=0.3 | |
1057 | self.ystep_given = 200 |
|
1140 | self.ystep_given = 200 | |
1058 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
1141 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
1059 | ax.grid(which='minor') |
|
1142 | ax.grid(which='minor') | |
1060 |
|
1143 | |||
1061 | else: |
|
1144 | else: | |
1062 | self.clear_figures() |
|
1145 | self.clear_figures() | |
1063 |
|
1146 | |||
1064 | for i in range(NACF): |
|
1147 | for i in range(NACF): | |
1065 | x_aux = numpy.isfinite(lags[i,:]) |
|
1148 | x_aux = numpy.isfinite(lags[i,:]) | |
1066 | y_aux = numpy.isfinite(ACFs[i,:]) |
|
1149 | y_aux = numpy.isfinite(ACFs[i,:]) | |
1067 | yerr_aux = numpy.isfinite(errACFs[i,:]) |
|
1150 | yerr_aux = numpy.isfinite(errACFs[i,:]) | |
1068 |
|
1151 | |||
1069 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: |
|
1152 | if lags[i,:][~numpy.isnan(lags[i,:])].shape[0]>2: | |
1070 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') |
|
1153 | ax.errorbar(lags[i,x_aux], ACFs[i,y_aux], yerr=errACFs[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') | |
1071 |
|
1154 | |||
1072 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
1155 | ax.yaxis.set_minor_locator(MultipleLocator(15)) | |
1073 |
|
1156 | |||
1074 |
|
1157 | |||
1075 | class CrossProductsPlot(Plot): |
|
1158 | class CrossProductsPlot(Plot): | |
1076 | ''' |
|
1159 | ''' | |
1077 | Written by R. Flores |
|
1160 | Written by R. Flores | |
1078 | ''' |
|
1161 | ''' | |
1079 | ''' |
|
1162 | ''' | |
1080 | Plot for cross products |
|
1163 | Plot for cross products | |
1081 | ''' |
|
1164 | ''' | |
1082 |
|
1165 | |||
1083 | CODE = 'crossprod' |
|
1166 | CODE = 'crossprod' | |
1084 | plot_name = 'Cross Products' |
|
1167 | plot_name = 'Cross Products' | |
1085 | plot_type = 'scatterbuffer' |
|
1168 | plot_type = 'scatterbuffer' | |
1086 |
|
1169 | |||
1087 | def setup(self): |
|
1170 | def setup(self): | |
1088 |
|
1171 | |||
1089 | self.ncols = 3 |
|
1172 | self.ncols = 3 | |
1090 | self.nrows = 1 |
|
1173 | self.nrows = 1 | |
1091 | self.nplots = 3 |
|
1174 | self.nplots = 3 | |
1092 | self.ylabel = 'Range [km]' |
|
1175 | self.ylabel = 'Range [km]' | |
1093 | self.titles = [] |
|
1176 | self.titles = [] | |
1094 | self.width = 3.5*self.nplots |
|
1177 | self.width = 3.5*self.nplots | |
1095 | self.height = 5.5 |
|
1178 | self.height = 5.5 | |
1096 | self.colorbar = False |
|
1179 | self.colorbar = False | |
1097 | self.plots_adjust.update({'wspace':.3, 'left': 0.12, 'right': 0.92, 'bottom': 0.1}) |
|
1180 | self.plots_adjust.update({'wspace':.3, 'left': 0.12, 'right': 0.92, 'bottom': 0.1}) | |
1098 |
|
1181 | |||
1099 |
|
1182 | |||
1100 | def update(self, dataOut): |
|
1183 | def update(self, dataOut): | |
1101 |
|
1184 | |||
1102 | data = {} |
|
1185 | data = {} | |
1103 | meta = {} |
|
1186 | meta = {} | |
1104 |
|
1187 | |||
1105 | data['crossprod'] = dataOut.crossprods |
|
1188 | data['crossprod'] = dataOut.crossprods | |
1106 | data['NDP'] = dataOut.NDP |
|
1189 | data['NDP'] = dataOut.NDP | |
1107 |
|
1190 | |||
1108 | return data, meta |
|
1191 | return data, meta | |
1109 |
|
1192 | |||
1110 | def plot(self): |
|
1193 | def plot(self): | |
1111 |
|
1194 | |||
1112 | NDP = self.data['NDP'][-1] |
|
1195 | NDP = self.data['NDP'][-1] | |
1113 | x = self.data['crossprod'][:,-1,:,:,:,:] |
|
1196 | x = self.data['crossprod'][:,-1,:,:,:,:] | |
1114 | y = self.data.yrange[0:NDP] |
|
1197 | y = self.data.yrange[0:NDP] | |
1115 |
|
1198 | |||
1116 | for n, ax in enumerate(self.axes): |
|
1199 | for n, ax in enumerate(self.axes): | |
1117 |
|
1200 | |||
1118 | 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]))) |
|
1201 | 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]))) | |
1119 | 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]))) |
|
1202 | 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]))) | |
1120 |
|
1203 | |||
1121 | if ax.firsttime: |
|
1204 | if ax.firsttime: | |
1122 |
|
1205 | |||
1123 | self.autoxticks=False |
|
1206 | self.autoxticks=False | |
1124 | if n==0: |
|
1207 | if n==0: | |
1125 | label1='kax' |
|
1208 | label1='kax' | |
1126 | label2='kay' |
|
1209 | label2='kay' | |
1127 | label3='kbx' |
|
1210 | label3='kbx' | |
1128 | label4='kby' |
|
1211 | label4='kby' | |
1129 | self.xlimits=[(self.xmin,self.xmax)] |
|
1212 | self.xlimits=[(self.xmin,self.xmax)] | |
1130 | elif n==1: |
|
1213 | elif n==1: | |
1131 | label1='kax2' |
|
1214 | label1='kax2' | |
1132 | label2='kay2' |
|
1215 | label2='kay2' | |
1133 | label3='kbx2' |
|
1216 | label3='kbx2' | |
1134 | label4='kby2' |
|
1217 | label4='kby2' | |
1135 | self.xlimits.append((self.xmin,self.xmax)) |
|
1218 | self.xlimits.append((self.xmin,self.xmax)) | |
1136 | elif n==2: |
|
1219 | elif n==2: | |
1137 | label1='kaxay' |
|
1220 | label1='kaxay' | |
1138 | label2='kbxby' |
|
1221 | label2='kbxby' | |
1139 | label3='kaxbx' |
|
1222 | label3='kaxbx' | |
1140 | label4='kaxby' |
|
1223 | label4='kaxby' | |
1141 | self.xlimits.append((self.xmin,self.xmax)) |
|
1224 | self.xlimits.append((self.xmin,self.xmax)) | |
1142 |
|
1225 | |||
1143 | ax.plotline1 = ax.plot(x[n][0,:,0,0], y, color='r',linewidth=2.0, label=label1) |
|
1226 | ax.plotline1 = ax.plot(x[n][0,:,0,0], y, color='r',linewidth=2.0, label=label1) | |
1144 | ax.plotline2 = ax.plot(x[n][1,:,0,0], y, color='k',linewidth=2.0, label=label2) |
|
1227 | ax.plotline2 = ax.plot(x[n][1,:,0,0], y, color='k',linewidth=2.0, label=label2) | |
1145 | ax.plotline3 = ax.plot(x[n][2,:,0,0], y, color='b',linewidth=2.0, label=label3) |
|
1228 | ax.plotline3 = ax.plot(x[n][2,:,0,0], y, color='b',linewidth=2.0, label=label3) | |
1146 | ax.plotline4 = ax.plot(x[n][3,:,0,0], y, color='m',linewidth=2.0, label=label4) |
|
1229 | ax.plotline4 = ax.plot(x[n][3,:,0,0], y, color='m',linewidth=2.0, label=label4) | |
1147 | ax.legend(loc='upper right') |
|
1230 | ax.legend(loc='upper right') | |
1148 | ax.set_xlim(self.xmin, self.xmax) |
|
1231 | ax.set_xlim(self.xmin, self.xmax) | |
1149 | self.titles.append('{}'.format(self.plot_name.upper())) |
|
1232 | self.titles.append('{}'.format(self.plot_name.upper())) | |
1150 |
|
1233 | |||
1151 | else: |
|
1234 | else: | |
1152 |
|
1235 | |||
1153 | if n==0: |
|
1236 | if n==0: | |
1154 | self.xlimits=[(self.xmin,self.xmax)] |
|
1237 | self.xlimits=[(self.xmin,self.xmax)] | |
1155 | else: |
|
1238 | else: | |
1156 | self.xlimits.append((self.xmin,self.xmax)) |
|
1239 | self.xlimits.append((self.xmin,self.xmax)) | |
1157 |
|
1240 | |||
1158 | ax.set_xlim(self.xmin, self.xmax) |
|
1241 | ax.set_xlim(self.xmin, self.xmax) | |
1159 |
|
1242 | |||
1160 | ax.plotline1[0].set_data(x[n][0,:,0,0],y) |
|
1243 | ax.plotline1[0].set_data(x[n][0,:,0,0],y) | |
1161 | ax.plotline2[0].set_data(x[n][1,:,0,0],y) |
|
1244 | ax.plotline2[0].set_data(x[n][1,:,0,0],y) | |
1162 | ax.plotline3[0].set_data(x[n][2,:,0,0],y) |
|
1245 | ax.plotline3[0].set_data(x[n][2,:,0,0],y) | |
1163 | ax.plotline4[0].set_data(x[n][3,:,0,0],y) |
|
1246 | ax.plotline4[0].set_data(x[n][3,:,0,0],y) | |
1164 | self.titles.append('{}'.format(self.plot_name.upper())) |
|
1247 | self.titles.append('{}'.format(self.plot_name.upper())) | |
1165 |
|
1248 | |||
1166 |
|
1249 | |||
1167 | class CrossProductsLPPlot(Plot): |
|
1250 | class CrossProductsLPPlot(Plot): | |
1168 | ''' |
|
1251 | ''' | |
1169 | Written by R. Flores |
|
1252 | Written by R. Flores | |
1170 | ''' |
|
1253 | ''' | |
1171 | ''' |
|
1254 | ''' | |
1172 | Plot for cross products LP |
|
1255 | Plot for cross products LP | |
1173 | ''' |
|
1256 | ''' | |
1174 |
|
1257 | |||
1175 | CODE = 'crossprodslp' |
|
1258 | CODE = 'crossprodslp' | |
1176 | plot_name = 'Cross Products LP' |
|
1259 | plot_name = 'Cross Products LP' | |
1177 | plot_type = 'scatterbuffer' |
|
1260 | plot_type = 'scatterbuffer' | |
1178 |
|
1261 | |||
1179 |
|
1262 | |||
1180 | def setup(self): |
|
1263 | def setup(self): | |
1181 |
|
1264 | |||
1182 | self.ncols = 2 |
|
1265 | self.ncols = 2 | |
1183 | self.nrows = 1 |
|
1266 | self.nrows = 1 | |
1184 | self.nplots = 2 |
|
1267 | self.nplots = 2 | |
1185 | self.ylabel = 'Range [km]' |
|
1268 | self.ylabel = 'Range [km]' | |
1186 | self.xlabel = 'dB' |
|
1269 | self.xlabel = 'dB' | |
1187 | self.width = 3.5*self.nplots |
|
1270 | self.width = 3.5*self.nplots | |
1188 | self.height = 5.5 |
|
1271 | self.height = 5.5 | |
1189 | self.colorbar = False |
|
1272 | self.colorbar = False | |
1190 | self.titles = [] |
|
1273 | self.titles = [] | |
1191 | self.plots_adjust.update({'wspace': .8 ,'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
1274 | self.plots_adjust.update({'wspace': .8 ,'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
1192 |
|
1275 | |||
1193 | def update(self, dataOut): |
|
1276 | def update(self, dataOut): | |
1194 | data = {} |
|
1277 | data = {} | |
1195 | meta = {} |
|
1278 | meta = {} | |
1196 |
|
1279 | |||
1197 | data['crossprodslp'] = 10*numpy.log10(numpy.abs(dataOut.output_LP)) |
|
1280 | data['crossprodslp'] = 10*numpy.log10(numpy.abs(dataOut.output_LP)) | |
1198 |
|
1281 | |||
1199 | data['NRANGE'] = dataOut.NRANGE #This is metadata |
|
1282 | data['NRANGE'] = dataOut.NRANGE #This is metadata | |
1200 | data['NLAG'] = dataOut.NLAG #This is metadata |
|
1283 | data['NLAG'] = dataOut.NLAG #This is metadata | |
1201 |
|
1284 | |||
1202 | return data, meta |
|
1285 | return data, meta | |
1203 |
|
1286 | |||
1204 | def plot(self): |
|
1287 | def plot(self): | |
1205 |
|
1288 | |||
1206 | NRANGE = self.data['NRANGE'][-1] |
|
1289 | NRANGE = self.data['NRANGE'][-1] | |
1207 | NLAG = self.data['NLAG'][-1] |
|
1290 | NLAG = self.data['NLAG'][-1] | |
1208 |
|
1291 | |||
1209 | x = self.data[self.CODE][:,-1,:,:] |
|
1292 | x = self.data[self.CODE][:,-1,:,:] | |
1210 | self.y = self.data.yrange[0:NRANGE] |
|
1293 | self.y = self.data.yrange[0:NRANGE] | |
1211 |
|
1294 | |||
1212 | label_array=numpy.array(['lag '+ str(x) for x in range(NLAG)]) |
|
1295 | label_array=numpy.array(['lag '+ str(x) for x in range(NLAG)]) | |
1213 | color_array=['r','k','g','b','c','m','y','orange','steelblue','purple','peru','darksalmon','grey','limegreen','olive','midnightblue'] |
|
1296 | color_array=['r','k','g','b','c','m','y','orange','steelblue','purple','peru','darksalmon','grey','limegreen','olive','midnightblue'] | |
1214 |
|
1297 | |||
1215 |
|
1298 | |||
1216 | for n, ax in enumerate(self.axes): |
|
1299 | for n, ax in enumerate(self.axes): | |
1217 |
|
1300 | |||
1218 | self.xmin=28#30 |
|
1301 | self.xmin=28#30 | |
1219 | self.xmax=70#70 |
|
1302 | self.xmax=70#70 | |
1220 | #self.xmin=numpy.min(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) |
|
1303 | #self.xmin=numpy.min(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) | |
1221 | #self.xmax=numpy.max(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) |
|
1304 | #self.xmax=numpy.max(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) | |
1222 |
|
1305 | |||
1223 | if ax.firsttime: |
|
1306 | if ax.firsttime: | |
1224 |
|
1307 | |||
1225 | self.autoxticks=False |
|
1308 | self.autoxticks=False | |
1226 | if n == 0: |
|
1309 | if n == 0: | |
1227 | self.plotline_array=numpy.zeros((2,NLAG),dtype=object) |
|
1310 | self.plotline_array=numpy.zeros((2,NLAG),dtype=object) | |
1228 |
|
1311 | |||
1229 | for i in range(NLAG): |
|
1312 | for i in range(NLAG): | |
1230 | self.plotline_array[n,i], = ax.plot(x[i,:,n], self.y, color=color_array[i],linewidth=1.0, label=label_array[i]) |
|
1313 | self.plotline_array[n,i], = ax.plot(x[i,:,n], self.y, color=color_array[i],linewidth=1.0, label=label_array[i]) | |
1231 |
|
1314 | |||
1232 | ax.legend(loc='upper right') |
|
1315 | ax.legend(loc='upper right') | |
1233 | ax.set_xlim(self.xmin, self.xmax) |
|
1316 | ax.set_xlim(self.xmin, self.xmax) | |
1234 | if n==0: |
|
1317 | if n==0: | |
1235 | self.titles.append('{} CH0'.format(self.plot_name.upper())) |
|
1318 | self.titles.append('{} CH0'.format(self.plot_name.upper())) | |
1236 | if n==1: |
|
1319 | if n==1: | |
1237 | self.titles.append('{} CH1'.format(self.plot_name.upper())) |
|
1320 | self.titles.append('{} CH1'.format(self.plot_name.upper())) | |
1238 | else: |
|
1321 | else: | |
1239 | for i in range(NLAG): |
|
1322 | for i in range(NLAG): | |
1240 | self.plotline_array[n,i].set_data(x[i,:,n],self.y) |
|
1323 | self.plotline_array[n,i].set_data(x[i,:,n],self.y) | |
1241 |
|
1324 | |||
1242 | if n==0: |
|
1325 | if n==0: | |
1243 | self.titles.append('{} CH0'.format(self.plot_name.upper())) |
|
1326 | self.titles.append('{} CH0'.format(self.plot_name.upper())) | |
1244 | if n==1: |
|
1327 | if n==1: | |
1245 | self.titles.append('{} CH1'.format(self.plot_name.upper())) |
|
1328 | self.titles.append('{} CH1'.format(self.plot_name.upper())) | |
1246 |
|
1329 | |||
1247 |
|
1330 | |||
1248 | class NoiseDPPlot(NoisePlot): |
|
1331 | class NoiseDPPlot(NoisePlot): | |
1249 | ''' |
|
1332 | ''' | |
1250 | Written by R. Flores |
|
1333 | Written by R. Flores | |
1251 | ''' |
|
1334 | ''' | |
1252 | ''' |
|
1335 | ''' | |
1253 | Plot for noise Double Pulse |
|
1336 | Plot for noise Double Pulse | |
1254 | ''' |
|
1337 | ''' | |
1255 |
|
1338 | |||
1256 | CODE = 'noise' |
|
1339 | CODE = 'noise' | |
1257 | #plot_name = 'Noise' |
|
1340 | #plot_name = 'Noise' | |
1258 | #plot_type = 'scatterbuffer' |
|
1341 | #plot_type = 'scatterbuffer' | |
1259 |
|
1342 | |||
1260 | def update(self, dataOut): |
|
1343 | def update(self, dataOut): | |
1261 |
|
1344 | |||
1262 | data = {} |
|
1345 | data = {} | |
1263 | meta = {} |
|
1346 | meta = {} | |
1264 | data['noise'] = 10*numpy.log10(dataOut.noise_final) |
|
1347 | data['noise'] = 10*numpy.log10(dataOut.noise_final) | |
1265 |
|
1348 | |||
1266 | return data, meta |
|
1349 | return data, meta | |
1267 |
|
1350 | |||
1268 |
|
1351 | |||
1269 | class XmitWaveformPlot(Plot): |
|
1352 | class XmitWaveformPlot(Plot): | |
1270 | ''' |
|
1353 | ''' | |
1271 | Written by R. Flores |
|
1354 | Written by R. Flores | |
1272 | ''' |
|
1355 | ''' | |
1273 | ''' |
|
1356 | ''' | |
1274 | Plot for xmit waveform |
|
1357 | Plot for xmit waveform | |
1275 | ''' |
|
1358 | ''' | |
1276 |
|
1359 | |||
1277 | CODE = 'xmit' |
|
1360 | CODE = 'xmit' | |
1278 | plot_name = 'Xmit Waveform' |
|
1361 | plot_name = 'Xmit Waveform' | |
1279 | plot_type = 'scatterbuffer' |
|
1362 | plot_type = 'scatterbuffer' | |
1280 |
|
1363 | |||
1281 |
|
1364 | |||
1282 | def setup(self): |
|
1365 | def setup(self): | |
1283 |
|
1366 | |||
1284 | self.ncols = 1 |
|
1367 | self.ncols = 1 | |
1285 | self.nrows = 1 |
|
1368 | self.nrows = 1 | |
1286 | self.nplots = 1 |
|
1369 | self.nplots = 1 | |
1287 | self.ylabel = '' |
|
1370 | self.ylabel = '' | |
1288 | self.xlabel = 'Number of Lag' |
|
1371 | self.xlabel = 'Number of Lag' | |
1289 | self.width = 5.5 |
|
1372 | self.width = 5.5 | |
1290 | self.height = 3.5 |
|
1373 | self.height = 3.5 | |
1291 | self.colorbar = False |
|
1374 | self.colorbar = False | |
1292 | self.plots_adjust.update({'right': 0.85 }) |
|
1375 | self.plots_adjust.update({'right': 0.85 }) | |
1293 | self.titles = [self.plot_name] |
|
1376 | self.titles = [self.plot_name] | |
1294 | #self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) |
|
1377 | #self.plots_adjust.update({'left': 0.17, 'right': 0.88, 'bottom': 0.1}) | |
1295 |
|
1378 | |||
1296 | #if not self.titles: |
|
1379 | #if not self.titles: | |
1297 | #self.titles = self.data.parameters \ |
|
1380 | #self.titles = self.data.parameters \ | |
1298 | #if self.data.parameters else ['{}'.format(self.plot_name.upper())] |
|
1381 | #if self.data.parameters else ['{}'.format(self.plot_name.upper())] | |
1299 |
|
1382 | |||
1300 | def update(self, dataOut): |
|
1383 | def update(self, dataOut): | |
1301 |
|
1384 | |||
1302 | data = {} |
|
1385 | data = {} | |
1303 | meta = {} |
|
1386 | meta = {} | |
1304 |
|
1387 | |||
1305 | y_1=numpy.arctan2(dataOut.output_LP[:,0,2].imag,dataOut.output_LP[:,0,2].real)* 180 / (numpy.pi*10) |
|
1388 | y_1=numpy.arctan2(dataOut.output_LP[:,0,2].imag,dataOut.output_LP[:,0,2].real)* 180 / (numpy.pi*10) | |
1306 | y_2=numpy.abs(dataOut.output_LP[:,0,2]) |
|
1389 | y_2=numpy.abs(dataOut.output_LP[:,0,2]) | |
1307 | norm=numpy.max(y_2) |
|
1390 | norm=numpy.max(y_2) | |
1308 | norm=max(norm,0.1) |
|
1391 | norm=max(norm,0.1) | |
1309 | y_2=y_2/norm |
|
1392 | y_2=y_2/norm | |
1310 |
|
1393 | |||
1311 | meta['yrange'] = numpy.array([]) |
|
1394 | meta['yrange'] = numpy.array([]) | |
1312 |
|
1395 | |||
1313 | data['xmit'] = numpy.vstack((y_1,y_2)) |
|
1396 | data['xmit'] = numpy.vstack((y_1,y_2)) | |
1314 | data['NLAG'] = dataOut.NLAG |
|
1397 | data['NLAG'] = dataOut.NLAG | |
1315 |
|
1398 | |||
1316 | return data, meta |
|
1399 | return data, meta | |
1317 |
|
1400 | |||
1318 | def plot(self): |
|
1401 | def plot(self): | |
1319 |
|
1402 | |||
1320 | data = self.data[-1] |
|
1403 | data = self.data[-1] | |
1321 | NLAG = data['NLAG'] |
|
1404 | NLAG = data['NLAG'] | |
1322 | x = numpy.arange(0,NLAG,1,'float32') |
|
1405 | x = numpy.arange(0,NLAG,1,'float32') | |
1323 | y = data['xmit'] |
|
1406 | y = data['xmit'] | |
1324 |
|
1407 | |||
1325 | self.xmin = 0 |
|
1408 | self.xmin = 0 | |
1326 | self.xmax = NLAG-1 |
|
1409 | self.xmax = NLAG-1 | |
1327 | self.ymin = -1.0 |
|
1410 | self.ymin = -1.0 | |
1328 | self.ymax = 1.0 |
|
1411 | self.ymax = 1.0 | |
1329 | ax = self.axes[0] |
|
1412 | ax = self.axes[0] | |
1330 |
|
1413 | |||
1331 | if ax.firsttime: |
|
1414 | if ax.firsttime: | |
1332 | ax.plotline0=ax.plot(x,y[0,:],color='blue') |
|
1415 | ax.plotline0=ax.plot(x,y[0,:],color='blue') | |
1333 | ax.plotline1=ax.plot(x,y[1,:],color='red') |
|
1416 | ax.plotline1=ax.plot(x,y[1,:],color='red') | |
1334 | secax=ax.secondary_xaxis(location=0.5) |
|
1417 | secax=ax.secondary_xaxis(location=0.5) | |
1335 | secax.xaxis.tick_bottom() |
|
1418 | secax.xaxis.tick_bottom() | |
1336 | secax.tick_params( labelleft=False, labeltop=False, |
|
1419 | secax.tick_params( labelleft=False, labeltop=False, | |
1337 | labelright=False, labelbottom=False) |
|
1420 | labelright=False, labelbottom=False) | |
1338 |
|
1421 | |||
1339 | self.xstep_given = 3 |
|
1422 | self.xstep_given = 3 | |
1340 | self.ystep_given = .25 |
|
1423 | self.ystep_given = .25 | |
1341 | secax.set_xticks(numpy.linspace(self.xmin, self.xmax, 6)) #only works on matplotlib.version>3.2 |
|
1424 | secax.set_xticks(numpy.linspace(self.xmin, self.xmax, 6)) #only works on matplotlib.version>3.2 | |
1342 |
|
1425 | |||
1343 | else: |
|
1426 | else: | |
1344 | ax.plotline0[0].set_data(x,y[0,:]) |
|
1427 | ax.plotline0[0].set_data(x,y[0,:]) | |
1345 | ax.plotline1[0].set_data(x,y[1,:]) |
|
1428 | ax.plotline1[0].set_data(x,y[1,:]) |
@@ -1,626 +1,636 | |||||
1 | import os |
|
1 | import os | |
2 | import time |
|
2 | import time | |
3 | import datetime |
|
3 | import datetime | |
4 |
|
4 | |||
5 | import numpy |
|
5 | import numpy | |
6 | import h5py |
|
6 | import h5py | |
7 |
|
7 | |||
8 | import schainpy.admin |
|
8 | import schainpy.admin | |
9 | from schainpy.model.data.jrodata import * |
|
9 | from schainpy.model.data.jrodata import * | |
10 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator |
|
10 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator | |
11 | from schainpy.model.io.jroIO_base import * |
|
11 | from schainpy.model.io.jroIO_base import * | |
12 | from schainpy.utils import log |
|
12 | from schainpy.utils import log | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | class HDFReader(Reader, ProcessingUnit): |
|
15 | class HDFReader(Reader, ProcessingUnit): | |
16 | """Processing unit to read HDF5 format files |
|
16 | """Processing unit to read HDF5 format files | |
17 |
|
17 | |||
18 | This unit reads HDF5 files created with `HDFWriter` operation contains |
|
18 | This unit reads HDF5 files created with `HDFWriter` operation contains | |
19 | by default two groups Data and Metadata all variables would be saved as `dataOut` |
|
19 | by default two groups Data and Metadata all variables would be saved as `dataOut` | |
20 | attributes. |
|
20 | attributes. | |
21 | It is possible to read any HDF5 file by given the structure in the `description` |
|
21 | It is possible to read any HDF5 file by given the structure in the `description` | |
22 | parameter, also you can add extra values to metadata with the parameter `extras`. |
|
22 | parameter, also you can add extra values to metadata with the parameter `extras`. | |
23 |
|
23 | |||
24 | Parameters: |
|
24 | Parameters: | |
25 | ----------- |
|
25 | ----------- | |
26 | path : str |
|
26 | path : str | |
27 | Path where files are located. |
|
27 | Path where files are located. | |
28 | startDate : date |
|
28 | startDate : date | |
29 | Start date of the files |
|
29 | Start date of the files | |
30 | endDate : list |
|
30 | endDate : list | |
31 | End date of the files |
|
31 | End date of the files | |
32 | startTime : time |
|
32 | startTime : time | |
33 | Start time of the files |
|
33 | Start time of the files | |
34 | endTime : time |
|
34 | endTime : time | |
35 | End time of the files |
|
35 | End time of the files | |
36 | description : dict, optional |
|
36 | description : dict, optional | |
37 | Dictionary with the description of the HDF5 file |
|
37 | Dictionary with the description of the HDF5 file | |
38 | extras : dict, optional |
|
38 | extras : dict, optional | |
39 | Dictionary with extra metadata to be be added to `dataOut` |
|
39 | Dictionary with extra metadata to be be added to `dataOut` | |
40 |
|
40 | |||
41 | Examples |
|
41 | Examples | |
42 | -------- |
|
42 | -------- | |
43 |
|
43 | |||
44 | desc = { |
|
44 | desc = { | |
45 | 'Data': { |
|
45 | 'Data': { | |
46 | 'data_output': ['u', 'v', 'w'], |
|
46 | 'data_output': ['u', 'v', 'w'], | |
47 | 'utctime': 'timestamps', |
|
47 | 'utctime': 'timestamps', | |
48 | } , |
|
48 | } , | |
49 | 'Metadata': { |
|
49 | 'Metadata': { | |
50 | 'heightList': 'heights' |
|
50 | 'heightList': 'heights' | |
51 | } |
|
51 | } | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | desc = { |
|
54 | desc = { | |
55 | 'Data': { |
|
55 | 'Data': { | |
56 | 'data_output': 'winds', |
|
56 | 'data_output': 'winds', | |
57 | 'utctime': 'timestamps' |
|
57 | 'utctime': 'timestamps' | |
58 | }, |
|
58 | }, | |
59 | 'Metadata': { |
|
59 | 'Metadata': { | |
60 | 'heightList': 'heights' |
|
60 | 'heightList': 'heights' | |
61 | } |
|
61 | } | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | extras = { |
|
64 | extras = { | |
65 | 'timeZone': 300 |
|
65 | 'timeZone': 300 | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | reader = project.addReadUnit( |
|
68 | reader = project.addReadUnit( | |
69 | name='HDFReader', |
|
69 | name='HDFReader', | |
70 | path='/path/to/files', |
|
70 | path='/path/to/files', | |
71 | startDate='2019/01/01', |
|
71 | startDate='2019/01/01', | |
72 | endDate='2019/01/31', |
|
72 | endDate='2019/01/31', | |
73 | startTime='00:00:00', |
|
73 | startTime='00:00:00', | |
74 | endTime='23:59:59', |
|
74 | endTime='23:59:59', | |
75 | # description=json.dumps(desc), |
|
75 | # description=json.dumps(desc), | |
76 | # extras=json.dumps(extras), |
|
76 | # extras=json.dumps(extras), | |
77 | ) |
|
77 | ) | |
78 |
|
78 | |||
79 | """ |
|
79 | """ | |
80 |
|
80 | |||
81 | __attrs__ = ['path', 'startDate', 'endDate', 'startTime', 'endTime', 'description', 'extras'] |
|
81 | __attrs__ = ['path', 'startDate', 'endDate', 'startTime', 'endTime', 'description', 'extras'] | |
82 |
|
82 | |||
83 | def __init__(self): |
|
83 | def __init__(self): | |
84 | ProcessingUnit.__init__(self) |
|
84 | ProcessingUnit.__init__(self) | |
85 | self.dataOut = Parameters() |
|
85 | self.dataOut = Parameters() | |
86 | self.ext = ".hdf5" |
|
86 | self.ext = ".hdf5" | |
87 | self.optchar = "D" |
|
87 | self.optchar = "D" | |
88 | self.meta = {} |
|
88 | self.meta = {} | |
89 | self.data = {} |
|
89 | self.data = {} | |
90 | self.open_file = h5py.File |
|
90 | self.open_file = h5py.File | |
91 | self.open_mode = 'r' |
|
91 | self.open_mode = 'r' | |
92 | self.description = {} |
|
92 | self.description = {} | |
93 | self.extras = {} |
|
93 | self.extras = {} | |
94 | self.filefmt = "*%Y%j***" |
|
94 | self.filefmt = "*%Y%j***" | |
95 | self.folderfmt = "*%Y%j" |
|
95 | self.folderfmt = "*%Y%j" | |
96 | self.utcoffset = 0 |
|
96 | self.utcoffset = 0 | |
97 |
|
97 | |||
98 | def setup(self, **kwargs): |
|
98 | def setup(self, **kwargs): | |
99 |
|
99 | |||
100 | self.set_kwargs(**kwargs) |
|
100 | self.set_kwargs(**kwargs) | |
101 | if not self.ext.startswith('.'): |
|
101 | if not self.ext.startswith('.'): | |
102 | self.ext = '.{}'.format(self.ext) |
|
102 | self.ext = '.{}'.format(self.ext) | |
103 |
|
103 | |||
104 | if self.online: |
|
104 | if self.online: | |
105 | log.log("Searching files in online mode...", self.name) |
|
105 | log.log("Searching files in online mode...", self.name) | |
106 |
|
106 | |||
107 | for nTries in range(self.nTries): |
|
107 | for nTries in range(self.nTries): | |
108 | fullpath = self.searchFilesOnLine(self.path, self.startDate, |
|
108 | fullpath = self.searchFilesOnLine(self.path, self.startDate, | |
109 | self.endDate, self.expLabel, self.ext, self.walk, |
|
109 | self.endDate, self.expLabel, self.ext, self.walk, | |
110 | self.filefmt, self.folderfmt) |
|
110 | self.filefmt, self.folderfmt) | |
111 | try: |
|
111 | try: | |
112 | fullpath = next(fullpath) |
|
112 | fullpath = next(fullpath) | |
113 | except: |
|
113 | except: | |
114 | fullpath = None |
|
114 | fullpath = None | |
115 |
|
115 | |||
116 | if fullpath: |
|
116 | if fullpath: | |
117 | break |
|
117 | break | |
118 |
|
118 | |||
119 | log.warning( |
|
119 | log.warning( | |
120 | 'Waiting {} sec for a valid file in {}: try {} ...'.format( |
|
120 | 'Waiting {} sec for a valid file in {}: try {} ...'.format( | |
121 | self.delay, self.path, nTries + 1), |
|
121 | self.delay, self.path, nTries + 1), | |
122 | self.name) |
|
122 | self.name) | |
123 | time.sleep(self.delay) |
|
123 | time.sleep(self.delay) | |
124 |
|
124 | |||
125 | if not(fullpath): |
|
125 | if not(fullpath): | |
126 | raise schainpy.admin.SchainError( |
|
126 | raise schainpy.admin.SchainError( | |
127 | 'There isn\'t any valid file in {}'.format(self.path)) |
|
127 | 'There isn\'t any valid file in {}'.format(self.path)) | |
128 |
|
128 | |||
129 | pathname, filename = os.path.split(fullpath) |
|
129 | pathname, filename = os.path.split(fullpath) | |
130 | self.year = int(filename[1:5]) |
|
130 | self.year = int(filename[1:5]) | |
131 | self.doy = int(filename[5:8]) |
|
131 | self.doy = int(filename[5:8]) | |
132 | self.set = int(filename[8:11]) - 1 |
|
132 | self.set = int(filename[8:11]) - 1 | |
133 | else: |
|
133 | else: | |
134 | log.log("Searching files in {}".format(self.path), self.name) |
|
134 | log.log("Searching files in {}".format(self.path), self.name) | |
135 | self.filenameList = self.searchFilesOffLine(self.path, self.startDate, |
|
135 | self.filenameList = self.searchFilesOffLine(self.path, self.startDate, | |
136 | self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt) |
|
136 | self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt) | |
137 |
|
137 | |||
138 | self.setNextFile() |
|
138 | self.setNextFile() | |
139 |
|
139 | |||
140 | return |
|
140 | return | |
141 |
|
141 | |||
142 | def readFirstHeader(self): |
|
142 | def readFirstHeader(self): | |
143 | '''Read metadata and data''' |
|
143 | '''Read metadata and data''' | |
144 |
|
144 | |||
145 | self.__readMetadata() |
|
145 | self.__readMetadata() | |
146 | self.__readData() |
|
146 | self.__readData() | |
147 | self.__setBlockList() |
|
147 | self.__setBlockList() | |
148 |
|
148 | |||
149 | if 'type' in self.meta: |
|
149 | if 'type' in self.meta: | |
150 | self.dataOut = eval(self.meta['type'])() |
|
150 | self.dataOut = eval(self.meta['type'])() | |
151 |
|
151 | |||
152 | for attr in self.meta: |
|
152 | for attr in self.meta: | |
153 | setattr(self.dataOut, attr, self.meta[attr]) |
|
153 | setattr(self.dataOut, attr, self.meta[attr]) | |
154 |
|
154 | |||
155 | self.blockIndex = 0 |
|
155 | self.blockIndex = 0 | |
156 |
|
156 | |||
157 | return |
|
157 | return | |
158 |
|
158 | |||
159 | def __setBlockList(self): |
|
159 | def __setBlockList(self): | |
160 | ''' |
|
160 | ''' | |
161 | Selects the data within the times defined |
|
161 | Selects the data within the times defined | |
162 |
|
162 | |||
163 | self.fp |
|
163 | self.fp | |
164 | self.startTime |
|
164 | self.startTime | |
165 | self.endTime |
|
165 | self.endTime | |
166 | self.blockList |
|
166 | self.blockList | |
167 | self.blocksPerFile |
|
167 | self.blocksPerFile | |
168 |
|
168 | |||
169 | ''' |
|
169 | ''' | |
170 |
|
170 | |||
171 | startTime = self.startTime |
|
171 | startTime = self.startTime | |
172 | endTime = self.endTime |
|
172 | endTime = self.endTime | |
173 | thisUtcTime = self.data['utctime'] + self.utcoffset |
|
173 | thisUtcTime = self.data['utctime'] + self.utcoffset | |
174 | self.interval = numpy.min(thisUtcTime[1:] - thisUtcTime[:-1]) |
|
174 | self.interval = numpy.min(thisUtcTime[1:] - thisUtcTime[:-1]) | |
175 | thisDatetime = datetime.datetime.utcfromtimestamp(thisUtcTime[0]) |
|
175 | thisDatetime = datetime.datetime.utcfromtimestamp(thisUtcTime[0]) | |
176 |
|
176 | |||
177 | thisDate = thisDatetime.date() |
|
177 | thisDate = thisDatetime.date() | |
178 | thisTime = thisDatetime.time() |
|
178 | thisTime = thisDatetime.time() | |
179 |
|
179 | |||
180 | startUtcTime = (datetime.datetime.combine(thisDate, startTime) - datetime.datetime(1970, 1, 1)).total_seconds() |
|
180 | startUtcTime = (datetime.datetime.combine(thisDate, startTime) - datetime.datetime(1970, 1, 1)).total_seconds() | |
181 | endUtcTime = (datetime.datetime.combine(thisDate, endTime) - datetime.datetime(1970, 1, 1)).total_seconds() |
|
181 | endUtcTime = (datetime.datetime.combine(thisDate, endTime) - datetime.datetime(1970, 1, 1)).total_seconds() | |
182 |
|
182 | |||
183 | ind = numpy.where(numpy.logical_and(thisUtcTime >= startUtcTime, thisUtcTime < endUtcTime))[0] |
|
183 | ind = numpy.where(numpy.logical_and(thisUtcTime >= startUtcTime, thisUtcTime < endUtcTime))[0] | |
184 |
|
184 | |||
185 | self.blockList = ind |
|
185 | self.blockList = ind | |
186 | self.blocksPerFile = len(ind) |
|
186 | self.blocksPerFile = len(ind) | |
187 | return |
|
187 | return | |
188 |
|
188 | |||
189 | def __readMetadata(self): |
|
189 | def __readMetadata(self): | |
190 | ''' |
|
190 | ''' | |
191 | Reads Metadata |
|
191 | Reads Metadata | |
192 | ''' |
|
192 | ''' | |
193 |
|
193 | |||
194 | meta = {} |
|
194 | meta = {} | |
195 |
|
195 | |||
196 | if self.description: |
|
196 | if self.description: | |
197 | for key, value in self.description['Metadata'].items(): |
|
197 | for key, value in self.description['Metadata'].items(): | |
198 | meta[key] = self.fp[value][()] |
|
198 | meta[key] = self.fp[value][()] | |
199 | else: |
|
199 | else: | |
200 | grp = self.fp['Metadata'] |
|
200 | grp = self.fp['Metadata'] | |
201 | for name in grp: |
|
201 | for name in grp: | |
202 | meta[name] = grp[name][()] |
|
202 | meta[name] = grp[name][()] | |
203 |
|
203 | |||
204 | if self.extras: |
|
204 | if self.extras: | |
205 | for key, value in self.extras.items(): |
|
205 | for key, value in self.extras.items(): | |
206 | meta[key] = value |
|
206 | meta[key] = value | |
207 | self.meta = meta |
|
207 | self.meta = meta | |
208 |
|
208 | |||
209 | return |
|
209 | return | |
210 |
|
210 | |||
211 | def __readData(self): |
|
211 | def __readData(self): | |
212 |
|
212 | |||
213 | data = {} |
|
213 | data = {} | |
214 |
|
214 | |||
215 | if self.description: |
|
215 | if self.description: | |
216 | for key, value in self.description['Data'].items(): |
|
216 | for key, value in self.description['Data'].items(): | |
217 | if isinstance(value, str): |
|
217 | if isinstance(value, str): | |
218 | if isinstance(self.fp[value], h5py.Dataset): |
|
218 | if isinstance(self.fp[value], h5py.Dataset): | |
219 | data[key] = self.fp[value][()] |
|
219 | data[key] = self.fp[value][()] | |
220 | elif isinstance(self.fp[value], h5py.Group): |
|
220 | elif isinstance(self.fp[value], h5py.Group): | |
221 | array = [] |
|
221 | array = [] | |
222 | for ch in self.fp[value]: |
|
222 | for ch in self.fp[value]: | |
223 | array.append(self.fp[value][ch][()]) |
|
223 | array.append(self.fp[value][ch][()]) | |
224 | data[key] = numpy.array(array) |
|
224 | data[key] = numpy.array(array) | |
225 | elif isinstance(value, list): |
|
225 | elif isinstance(value, list): | |
226 | array = [] |
|
226 | array = [] | |
227 | for ch in value: |
|
227 | for ch in value: | |
228 | array.append(self.fp[ch][()]) |
|
228 | array.append(self.fp[ch][()]) | |
229 | data[key] = numpy.array(array) |
|
229 | data[key] = numpy.array(array) | |
230 | else: |
|
230 | else: | |
231 | grp = self.fp['Data'] |
|
231 | grp = self.fp['Data'] | |
232 | for name in grp: |
|
232 | for name in grp: | |
233 | if isinstance(grp[name], h5py.Dataset): |
|
233 | if isinstance(grp[name], h5py.Dataset): | |
234 | array = grp[name][()] |
|
234 | array = grp[name][()] | |
235 | elif isinstance(grp[name], h5py.Group): |
|
235 | elif isinstance(grp[name], h5py.Group): | |
236 | array = [] |
|
236 | array = [] | |
237 | for ch in grp[name]: |
|
237 | for ch in grp[name]: | |
238 | array.append(grp[name][ch][()]) |
|
238 | array.append(grp[name][ch][()]) | |
239 | array = numpy.array(array) |
|
239 | array = numpy.array(array) | |
240 | else: |
|
240 | else: | |
241 | log.warning('Unknown type: {}'.format(name)) |
|
241 | log.warning('Unknown type: {}'.format(name)) | |
242 |
|
242 | |||
243 | if name in self.description: |
|
243 | if name in self.description: | |
244 | key = self.description[name] |
|
244 | key = self.description[name] | |
245 | else: |
|
245 | else: | |
246 | key = name |
|
246 | key = name | |
247 | data[key] = array |
|
247 | data[key] = array | |
248 |
|
248 | |||
249 | self.data = data |
|
249 | self.data = data | |
250 | return |
|
250 | return | |
251 |
|
251 | |||
252 | def getData(self): |
|
252 | def getData(self): | |
253 |
|
253 | |||
254 | for attr in self.data: |
|
254 | for attr in self.data: | |
255 | if self.data[attr].ndim == 1: |
|
255 | if self.data[attr].ndim == 1: | |
256 | setattr(self.dataOut, attr, self.data[attr][self.blockIndex]) |
|
256 | setattr(self.dataOut, attr, self.data[attr][self.blockIndex]) | |
257 | else: |
|
257 | else: | |
258 | setattr(self.dataOut, attr, self.data[attr][:, self.blockIndex]) |
|
258 | setattr(self.dataOut, attr, self.data[attr][:, self.blockIndex]) | |
259 |
|
259 | |||
260 | self.dataOut.flagNoData = False |
|
260 | self.dataOut.flagNoData = False | |
261 | self.blockIndex += 1 |
|
261 | self.blockIndex += 1 | |
262 |
|
262 | |||
263 | log.log("Block No. {}/{} -> {}".format( |
|
263 | log.log("Block No. {}/{} -> {}".format( | |
264 | self.blockIndex, |
|
264 | self.blockIndex, | |
265 | self.blocksPerFile, |
|
265 | self.blocksPerFile, | |
266 | self.dataOut.datatime.ctime()), self.name) |
|
266 | self.dataOut.datatime.ctime()), self.name) | |
267 |
|
267 | |||
268 | return |
|
268 | return | |
269 |
|
269 | |||
270 | def run(self, **kwargs): |
|
270 | def run(self, **kwargs): | |
271 |
|
271 | |||
272 | if not(self.isConfig): |
|
272 | if not(self.isConfig): | |
273 | self.setup(**kwargs) |
|
273 | self.setup(**kwargs) | |
274 | self.isConfig = True |
|
274 | self.isConfig = True | |
275 |
|
275 | |||
276 | if self.blockIndex == self.blocksPerFile: |
|
276 | if self.blockIndex == self.blocksPerFile: | |
277 | self.setNextFile() |
|
277 | self.setNextFile() | |
278 |
|
278 | |||
279 | self.getData() |
|
279 | self.getData() | |
280 |
|
280 | |||
281 | return |
|
281 | return | |
282 |
|
282 | |||
283 | @MPDecorator |
|
283 | @MPDecorator | |
284 | class HDFWriter(Operation): |
|
284 | class HDFWriter(Operation): | |
285 | """Operation to write HDF5 files. |
|
285 | """Operation to write HDF5 files. | |
286 |
|
286 | |||
287 | The HDF5 file contains by default two groups Data and Metadata where |
|
287 | The HDF5 file contains by default two groups Data and Metadata where | |
288 | you can save any `dataOut` attribute specified by `dataList` and `metadataList` |
|
288 | you can save any `dataOut` attribute specified by `dataList` and `metadataList` | |
289 | parameters, data attributes are normaly time dependent where the metadata |
|
289 | parameters, data attributes are normaly time dependent where the metadata | |
290 | are not. |
|
290 | are not. | |
291 | It is possible to customize the structure of the HDF5 file with the |
|
291 | It is possible to customize the structure of the HDF5 file with the | |
292 | optional description parameter see the examples. |
|
292 | optional description parameter see the examples. | |
293 |
|
293 | |||
294 | Parameters: |
|
294 | Parameters: | |
295 | ----------- |
|
295 | ----------- | |
296 | path : str |
|
296 | path : str | |
297 | Path where files will be saved. |
|
297 | Path where files will be saved. | |
298 | blocksPerFile : int |
|
298 | blocksPerFile : int | |
299 | Number of blocks per file |
|
299 | Number of blocks per file | |
300 | metadataList : list |
|
300 | metadataList : list | |
301 | List of the dataOut attributes that will be saved as metadata |
|
301 | List of the dataOut attributes that will be saved as metadata | |
302 | dataList : int |
|
302 | dataList : int | |
303 | List of the dataOut attributes that will be saved as data |
|
303 | List of the dataOut attributes that will be saved as data | |
304 | setType : bool |
|
304 | setType : bool | |
305 | If True the name of the files corresponds to the timestamp of the data |
|
305 | If True the name of the files corresponds to the timestamp of the data | |
306 | description : dict, optional |
|
306 | description : dict, optional | |
307 | Dictionary with the desired description of the HDF5 file |
|
307 | Dictionary with the desired description of the HDF5 file | |
308 |
|
308 | |||
309 | Examples |
|
309 | Examples | |
310 | -------- |
|
310 | -------- | |
311 |
|
311 | |||
312 | desc = { |
|
312 | desc = { | |
313 | 'data_output': {'winds': ['z', 'w', 'v']}, |
|
313 | 'data_output': {'winds': ['z', 'w', 'v']}, | |
314 | 'utctime': 'timestamps', |
|
314 | 'utctime': 'timestamps', | |
315 | 'heightList': 'heights' |
|
315 | 'heightList': 'heights' | |
316 | } |
|
316 | } | |
317 | desc = { |
|
317 | desc = { | |
318 | 'data_output': ['z', 'w', 'v'], |
|
318 | 'data_output': ['z', 'w', 'v'], | |
319 | 'utctime': 'timestamps', |
|
319 | 'utctime': 'timestamps', | |
320 | 'heightList': 'heights' |
|
320 | 'heightList': 'heights' | |
321 | } |
|
321 | } | |
322 | desc = { |
|
322 | desc = { | |
323 | 'Data': { |
|
323 | 'Data': { | |
324 | 'data_output': 'winds', |
|
324 | 'data_output': 'winds', | |
325 | 'utctime': 'timestamps' |
|
325 | 'utctime': 'timestamps' | |
326 | }, |
|
326 | }, | |
327 | 'Metadata': { |
|
327 | 'Metadata': { | |
328 | 'heightList': 'heights' |
|
328 | 'heightList': 'heights' | |
329 | } |
|
329 | } | |
330 | } |
|
330 | } | |
331 |
|
331 | |||
332 | writer = proc_unit.addOperation(name='HDFWriter') |
|
332 | writer = proc_unit.addOperation(name='HDFWriter') | |
333 | writer.addParameter(name='path', value='/path/to/file') |
|
333 | writer.addParameter(name='path', value='/path/to/file') | |
334 | writer.addParameter(name='blocksPerFile', value='32') |
|
334 | writer.addParameter(name='blocksPerFile', value='32') | |
335 | writer.addParameter(name='metadataList', value='heightList,timeZone') |
|
335 | writer.addParameter(name='metadataList', value='heightList,timeZone') | |
336 | writer.addParameter(name='dataList',value='data_output,utctime') |
|
336 | writer.addParameter(name='dataList',value='data_output,utctime') | |
337 | # writer.addParameter(name='description',value=json.dumps(desc)) |
|
337 | # writer.addParameter(name='description',value=json.dumps(desc)) | |
338 |
|
338 | |||
339 | """ |
|
339 | """ | |
340 |
|
340 | |||
341 | ext = ".hdf5" |
|
341 | ext = ".hdf5" | |
342 | optchar = "D" |
|
342 | optchar = "D" | |
343 | filename = None |
|
343 | filename = None | |
344 | path = None |
|
344 | path = None | |
345 | setFile = None |
|
345 | setFile = None | |
346 | fp = None |
|
346 | fp = None | |
347 | firsttime = True |
|
347 | firsttime = True | |
348 | #Configurations |
|
348 | #Configurations | |
349 | blocksPerFile = None |
|
349 | blocksPerFile = None | |
350 | blockIndex = None |
|
350 | blockIndex = None | |
351 | dataOut = None |
|
351 | dataOut = None | |
352 | #Data Arrays |
|
352 | #Data Arrays | |
353 | dataList = None |
|
353 | dataList = None | |
354 | metadataList = None |
|
354 | metadataList = None | |
355 | currentDay = None |
|
355 | currentDay = None | |
356 | lastTime = None |
|
356 | lastTime = None | |
357 |
|
357 | |||
358 | def __init__(self): |
|
358 | def __init__(self): | |
359 |
|
359 | |||
360 | Operation.__init__(self) |
|
360 | Operation.__init__(self) | |
361 | return |
|
361 | return | |
362 |
|
362 | |||
363 | def setup(self, path=None, blocksPerFile=10, metadataList=None, dataList=None, setType=None, description=None): |
|
363 | def setup(self, path=None, blocksPerFile=10, metadataList=None, dataList=None, setType=None, description=None, uniqueChannel=False): | |
364 | self.path = path |
|
364 | self.path = path | |
365 | self.blocksPerFile = blocksPerFile |
|
365 | self.blocksPerFile = blocksPerFile | |
366 | self.metadataList = metadataList |
|
366 | self.metadataList = metadataList | |
367 | self.dataList = [s.strip() for s in dataList] |
|
367 | self.dataList = [s.strip() for s in dataList] | |
368 | self.setType = setType |
|
368 | self.setType = setType | |
369 | self.description = description |
|
369 | self.description = description | |
|
370 | self.uniqueChannel = uniqueChannel | |||
370 |
|
371 | |||
371 | if self.metadataList is None: |
|
372 | if self.metadataList is None: | |
372 | self.metadataList = self.dataOut.metadata_list |
|
373 | self.metadataList = self.dataOut.metadata_list | |
373 |
|
374 | |||
374 | tableList = [] |
|
375 | tableList = [] | |
375 | dsList = [] |
|
376 | dsList = [] | |
376 |
|
377 | |||
377 | for i in range(len(self.dataList)): |
|
378 | for i in range(len(self.dataList)): | |
378 | dsDict = {} |
|
379 | dsDict = {} | |
379 | if hasattr(self.dataOut, self.dataList[i]): |
|
380 | if hasattr(self.dataOut, self.dataList[i]): | |
380 | dataAux = getattr(self.dataOut, self.dataList[i]) |
|
381 | dataAux = getattr(self.dataOut, self.dataList[i]) | |
381 | dsDict['variable'] = self.dataList[i] |
|
382 | dsDict['variable'] = self.dataList[i] | |
382 | else: |
|
383 | else: | |
383 | log.warning('Attribute {} not found in dataOut', self.name) |
|
384 | log.warning('Attribute {} not found in dataOut', self.name) | |
384 | continue |
|
385 | continue | |
385 |
|
386 | |||
386 | if dataAux is None: |
|
387 | if dataAux is None: | |
387 | continue |
|
388 | continue | |
388 | elif isinstance(dataAux, (int, float, numpy.integer, numpy.float)): |
|
389 | elif isinstance(dataAux, (int, float, numpy.integer, numpy.float)): | |
389 | dsDict['nDim'] = 0 |
|
390 | dsDict['nDim'] = 0 | |
390 | else: |
|
391 | else: | |
|
392 | if uniqueChannel: #Creates extra dimension to avoid the creation of multiple channels | |||
|
393 | dataAux = numpy.expand_dims(dataAux, axis=0) | |||
|
394 | ||||
391 | dsDict['nDim'] = len(dataAux.shape) |
|
395 | dsDict['nDim'] = len(dataAux.shape) | |
392 | dsDict['shape'] = dataAux.shape |
|
396 | dsDict['shape'] = dataAux.shape | |
393 | dsDict['dsNumber'] = dataAux.shape[0] |
|
397 | dsDict['dsNumber'] = dataAux.shape[0] | |
394 | dsDict['dtype'] = dataAux.dtype |
|
398 | dsDict['dtype'] = dataAux.dtype | |
395 |
|
399 | |||
396 | dsList.append(dsDict) |
|
400 | dsList.append(dsDict) | |
397 |
|
401 | |||
398 | self.dsList = dsList |
|
402 | self.dsList = dsList | |
399 | self.currentDay = self.dataOut.datatime.date() |
|
403 | self.currentDay = self.dataOut.datatime.date() | |
400 |
|
404 | |||
401 | def timeFlag(self): |
|
405 | def timeFlag(self): | |
402 | currentTime = self.dataOut.utctime |
|
406 | currentTime = self.dataOut.utctime | |
403 | timeTuple = time.localtime(currentTime) |
|
407 | timeTuple = time.localtime(currentTime) | |
404 | dataDay = timeTuple.tm_yday |
|
408 | dataDay = timeTuple.tm_yday | |
405 |
|
409 | |||
406 | if self.lastTime is None: |
|
410 | if self.lastTime is None: | |
407 | self.lastTime = currentTime |
|
411 | self.lastTime = currentTime | |
408 | self.currentDay = dataDay |
|
412 | self.currentDay = dataDay | |
409 | return False |
|
413 | return False | |
410 |
|
414 | |||
411 | timeDiff = currentTime - self.lastTime |
|
415 | timeDiff = currentTime - self.lastTime | |
412 |
|
416 | |||
413 | #Si el dia es diferente o si la diferencia entre un dato y otro supera la hora |
|
417 | #Si el dia es diferente o si la diferencia entre un dato y otro supera la hora | |
414 | if dataDay != self.currentDay: |
|
418 | if dataDay != self.currentDay: | |
415 | self.currentDay = dataDay |
|
419 | self.currentDay = dataDay | |
416 | return True |
|
420 | return True | |
417 | elif timeDiff > 3*60*60: |
|
421 | elif timeDiff > 3*60*60: | |
418 | self.lastTime = currentTime |
|
422 | self.lastTime = currentTime | |
419 | return True |
|
423 | return True | |
420 | else: |
|
424 | else: | |
421 | self.lastTime = currentTime |
|
425 | self.lastTime = currentTime | |
422 | return False |
|
426 | return False | |
423 |
|
427 | |||
424 | def run(self, dataOut, path, blocksPerFile=10, metadataList=None, |
|
428 | def run(self, dataOut, path, blocksPerFile=10, metadataList=None, | |
425 | dataList=[], setType=None, description={}): |
|
429 | dataList=[], setType=None, description={}, uniqueChannel= False): | |
426 |
|
430 | |||
427 | self.dataOut = dataOut |
|
431 | self.dataOut = dataOut | |
428 | if not(self.isConfig): |
|
432 | if not(self.isConfig): | |
429 | self.setup(path=path, blocksPerFile=blocksPerFile, |
|
433 | self.setup(path=path, blocksPerFile=blocksPerFile, | |
430 | metadataList=metadataList, dataList=dataList, |
|
434 | metadataList=metadataList, dataList=dataList, | |
431 | setType=setType, description=description) |
|
435 | setType=setType, description=description, uniqueChannel=uniqueChannel) | |
432 |
|
436 | |||
433 | self.isConfig = True |
|
437 | self.isConfig = True | |
434 | self.setNextFile() |
|
438 | self.setNextFile() | |
435 |
|
439 | |||
436 | self.putData() |
|
440 | self.putData() | |
|
441 | ||||
437 | return |
|
442 | return | |
438 |
|
443 | |||
439 | def setNextFile(self): |
|
444 | def setNextFile(self): | |
440 |
|
445 | |||
441 | ext = self.ext |
|
446 | ext = self.ext | |
442 | path = self.path |
|
447 | path = self.path | |
443 | setFile = self.setFile |
|
448 | setFile = self.setFile | |
444 |
|
449 | |||
445 | timeTuple = time.localtime(self.dataOut.utctime) |
|
450 | timeTuple = time.localtime(self.dataOut.utctime) | |
446 | subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday) |
|
451 | subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday) | |
447 | fullpath = os.path.join(path, subfolder) |
|
452 | fullpath = os.path.join(path, subfolder) | |
448 |
|
453 | |||
449 | if os.path.exists(fullpath): |
|
454 | if os.path.exists(fullpath): | |
450 | filesList = os.listdir(fullpath) |
|
455 | filesList = os.listdir(fullpath) | |
451 | filesList = [k for k in filesList if k.startswith(self.optchar)] |
|
456 | filesList = [k for k in filesList if k.startswith(self.optchar)] | |
452 | if len( filesList ) > 0: |
|
457 | if len( filesList ) > 0: | |
453 | filesList = sorted(filesList, key=str.lower) |
|
458 | filesList = sorted(filesList, key=str.lower) | |
454 | filen = filesList[-1] |
|
459 | filen = filesList[-1] | |
455 | # el filename debera tener el siguiente formato |
|
460 | # el filename debera tener el siguiente formato | |
456 | # 0 1234 567 89A BCDE (hex) |
|
461 | # 0 1234 567 89A BCDE (hex) | |
457 | # x YYYY DDD SSS .ext |
|
462 | # x YYYY DDD SSS .ext | |
458 | if isNumber(filen[8:11]): |
|
463 | if isNumber(filen[8:11]): | |
459 | setFile = int(filen[8:11]) #inicializo mi contador de seteo al seteo del ultimo file |
|
464 | setFile = int(filen[8:11]) #inicializo mi contador de seteo al seteo del ultimo file | |
460 | else: |
|
465 | else: | |
461 | setFile = -1 |
|
466 | setFile = -1 | |
462 | else: |
|
467 | else: | |
463 | setFile = -1 #inicializo mi contador de seteo |
|
468 | setFile = -1 #inicializo mi contador de seteo | |
464 | else: |
|
469 | else: | |
465 | os.makedirs(fullpath) |
|
470 | os.makedirs(fullpath) | |
466 | setFile = -1 #inicializo mi contador de seteo |
|
471 | setFile = -1 #inicializo mi contador de seteo | |
467 |
|
472 | |||
468 | if self.setType is None: |
|
473 | if self.setType is None: | |
469 | setFile += 1 |
|
474 | setFile += 1 | |
470 | file = '%s%4.4d%3.3d%03d%s' % (self.optchar, |
|
475 | file = '%s%4.4d%3.3d%03d%s' % (self.optchar, | |
471 | timeTuple.tm_year, |
|
476 | timeTuple.tm_year, | |
472 | timeTuple.tm_yday, |
|
477 | timeTuple.tm_yday, | |
473 | setFile, |
|
478 | setFile, | |
474 | ext ) |
|
479 | ext ) | |
475 | else: |
|
480 | else: | |
476 | setFile = timeTuple.tm_hour*60+timeTuple.tm_min |
|
481 | setFile = timeTuple.tm_hour*60+timeTuple.tm_min | |
477 | file = '%s%4.4d%3.3d%04d%s' % (self.optchar, |
|
482 | file = '%s%4.4d%3.3d%04d%s' % (self.optchar, | |
478 | timeTuple.tm_year, |
|
483 | timeTuple.tm_year, | |
479 | timeTuple.tm_yday, |
|
484 | timeTuple.tm_yday, | |
480 | setFile, |
|
485 | setFile, | |
481 | ext ) |
|
486 | ext ) | |
482 |
|
487 | |||
483 | self.filename = os.path.join( path, subfolder, file ) |
|
488 | self.filename = os.path.join( path, subfolder, file ) | |
484 |
|
489 | |||
485 | #Setting HDF5 File |
|
490 | #Setting HDF5 File | |
486 | self.fp = h5py.File(self.filename, 'w') |
|
491 | self.fp = h5py.File(self.filename, 'w') | |
487 | #write metadata |
|
492 | #write metadata | |
488 | self.writeMetadata(self.fp) |
|
493 | self.writeMetadata(self.fp) | |
489 | #Write data |
|
494 | #Write data | |
490 | self.writeData(self.fp) |
|
495 | self.writeData(self.fp) | |
491 |
|
496 | |||
492 | def getLabel(self, name, x=None): |
|
497 | def getLabel(self, name, x=None): | |
493 |
|
498 | #print("x: ", x) | ||
494 | if x is None: |
|
499 | if x is None: | |
495 | if 'Data' in self.description: |
|
500 | if 'Data' in self.description: | |
496 | data = self.description['Data'] |
|
501 | data = self.description['Data'] | |
497 | if 'Metadata' in self.description: |
|
502 | if 'Metadata' in self.description: | |
498 | data.update(self.description['Metadata']) |
|
503 | data.update(self.description['Metadata']) | |
499 | else: |
|
504 | else: | |
500 | data = self.description |
|
505 | data = self.description | |
501 | if name in data: |
|
506 | if name in data: | |
502 | if isinstance(data[name], str): |
|
507 | if isinstance(data[name], str): | |
503 | return data[name] |
|
508 | return data[name] | |
504 | elif isinstance(data[name], list): |
|
509 | elif isinstance(data[name], list): | |
505 | return None |
|
510 | return None | |
506 | elif isinstance(data[name], dict): |
|
511 | elif isinstance(data[name], dict): | |
507 | for key, value in data[name].items(): |
|
512 | for key, value in data[name].items(): | |
508 | return key |
|
513 | return key | |
509 | return name |
|
514 | return name | |
510 | else: |
|
515 | else: | |
511 | if 'Metadata' in self.description: |
|
516 | if 'Metadata' in self.description: | |
512 | meta = self.description['Metadata'] |
|
517 | meta = self.description['Metadata'] | |
513 | else: |
|
518 | else: | |
514 | meta = self.description |
|
519 | meta = self.description | |
515 | if name in meta: |
|
520 | if name in meta: | |
516 | if isinstance(meta[name], list): |
|
521 | if isinstance(meta[name], list): | |
517 | return meta[name][x] |
|
522 | return meta[name][x] | |
518 | elif isinstance(meta[name], dict): |
|
523 | elif isinstance(meta[name], dict): | |
519 | for key, value in meta[name].items(): |
|
524 | for key, value in meta[name].items(): | |
520 | return value[x] |
|
525 | return value[x] | |
521 | if 'cspc' in name: |
|
526 | if 'cspc' in name: | |
522 | return 'pair{:02d}'.format(x) |
|
527 | return 'pair{:02d}'.format(x) | |
523 | else: |
|
528 | else: | |
524 | return 'channel{:02d}'.format(x) |
|
529 | return 'channel{:02d}'.format(x) | |
525 |
|
530 | |||
526 | def writeMetadata(self, fp): |
|
531 | def writeMetadata(self, fp): | |
527 |
|
532 | |||
528 | if self.description: |
|
533 | if self.description: | |
529 | if 'Metadata' in self.description: |
|
534 | if 'Metadata' in self.description: | |
530 | grp = fp.create_group('Metadata') |
|
535 | grp = fp.create_group('Metadata') | |
531 | else: |
|
536 | else: | |
532 | grp = fp |
|
537 | grp = fp | |
533 | else: |
|
538 | else: | |
534 | grp = fp.create_group('Metadata') |
|
539 | grp = fp.create_group('Metadata') | |
535 |
|
540 | |||
536 | for i in range(len(self.metadataList)): |
|
541 | for i in range(len(self.metadataList)): | |
537 | if not hasattr(self.dataOut, self.metadataList[i]): |
|
542 | if not hasattr(self.dataOut, self.metadataList[i]): | |
538 | log.warning('Metadata: `{}` not found'.format(self.metadataList[i]), self.name) |
|
543 | log.warning('Metadata: `{}` not found'.format(self.metadataList[i]), self.name) | |
539 | continue |
|
544 | continue | |
540 | value = getattr(self.dataOut, self.metadataList[i]) |
|
545 | value = getattr(self.dataOut, self.metadataList[i]) | |
541 | if isinstance(value, bool): |
|
546 | if isinstance(value, bool): | |
542 | if value is True: |
|
547 | if value is True: | |
543 | value = 1 |
|
548 | value = 1 | |
544 | else: |
|
549 | else: | |
545 | value = 0 |
|
550 | value = 0 | |
546 | grp.create_dataset(self.getLabel(self.metadataList[i]), data=value) |
|
551 | grp.create_dataset(self.getLabel(self.metadataList[i]), data=value) | |
547 | return |
|
552 | return | |
548 |
|
553 | |||
549 | def writeData(self, fp): |
|
554 | def writeData(self, fp): | |
550 |
|
555 | |||
551 | if self.description: |
|
556 | if self.description: | |
552 | if 'Data' in self.description: |
|
557 | if 'Data' in self.description: | |
553 | grp = fp.create_group('Data') |
|
558 | grp = fp.create_group('Data') | |
554 | else: |
|
559 | else: | |
555 | grp = fp |
|
560 | grp = fp | |
556 | else: |
|
561 | else: | |
557 | grp = fp.create_group('Data') |
|
562 | grp = fp.create_group('Data') | |
558 |
|
563 | |||
559 | dtsets = [] |
|
564 | dtsets = [] | |
560 | data = [] |
|
565 | data = [] | |
561 |
|
566 | #print("self.dsList: ", self.dsList) | ||
562 | for dsInfo in self.dsList: |
|
567 | for dsInfo in self.dsList: | |
563 | if dsInfo['nDim'] == 0: |
|
568 | if dsInfo['nDim'] == 0: | |
564 | ds = grp.create_dataset( |
|
569 | ds = grp.create_dataset( | |
565 | self.getLabel(dsInfo['variable']), |
|
570 | self.getLabel(dsInfo['variable']), | |
566 | (self.blocksPerFile, ), |
|
571 | (self.blocksPerFile, ), | |
567 | chunks=True, |
|
572 | chunks=True, | |
568 | dtype=numpy.float64) |
|
573 | dtype=numpy.float64) | |
569 | dtsets.append(ds) |
|
574 | dtsets.append(ds) | |
570 | data.append((dsInfo['variable'], -1)) |
|
575 | data.append((dsInfo['variable'], -1)) | |
571 | else: |
|
576 | else: | |
572 | label = self.getLabel(dsInfo['variable']) |
|
577 | label = self.getLabel(dsInfo['variable']) | |
573 | if label is not None: |
|
578 | if label is not None: | |
574 | sgrp = grp.create_group(label) |
|
579 | sgrp = grp.create_group(label) | |
575 | else: |
|
580 | else: | |
576 | sgrp = grp |
|
581 | sgrp = grp | |
577 | for i in range(dsInfo['dsNumber']): |
|
582 | for i in range(dsInfo['dsNumber']): | |
578 | ds = sgrp.create_dataset( |
|
583 | ds = sgrp.create_dataset( | |
579 | self.getLabel(dsInfo['variable'], i), |
|
584 | self.getLabel(dsInfo['variable'], i), | |
580 | (self.blocksPerFile, ) + dsInfo['shape'][1:], |
|
585 | (self.blocksPerFile, ) + dsInfo['shape'][1:], | |
581 | chunks=True, |
|
586 | chunks=True, | |
582 | dtype=dsInfo['dtype']) |
|
587 | dtype=dsInfo['dtype']) | |
583 | dtsets.append(ds) |
|
588 | dtsets.append(ds) | |
584 | data.append((dsInfo['variable'], i)) |
|
589 | data.append((dsInfo['variable'], i)) | |
|
590 | ||||
|
591 | if self.uniqueChannel: #Deletes extra dimension created to avoid the creation of multiple channels | |||
|
592 | dataAux = getattr(self.dataOut, dsInfo['variable']) | |||
|
593 | dataAux = dataAux[0] | |||
|
594 | ||||
585 | fp.flush() |
|
595 | fp.flush() | |
586 |
|
596 | |||
587 | log.log('Creating file: {}'.format(fp.filename), self.name) |
|
597 | log.log('Creating file: {}'.format(fp.filename), self.name) | |
588 |
|
598 | |||
589 | self.ds = dtsets |
|
599 | self.ds = dtsets | |
590 | self.data = data |
|
600 | self.data = data | |
591 | self.firsttime = True |
|
601 | self.firsttime = True | |
592 | self.blockIndex = 0 |
|
602 | self.blockIndex = 0 | |
593 | return |
|
603 | return | |
594 |
|
604 | |||
595 | def putData(self): |
|
605 | def putData(self): | |
596 |
|
606 | |||
597 | if (self.blockIndex == self.blocksPerFile) or self.timeFlag(): |
|
607 | if (self.blockIndex == self.blocksPerFile) or self.timeFlag(): | |
598 | self.closeFile() |
|
608 | self.closeFile() | |
599 | self.setNextFile() |
|
609 | self.setNextFile() | |
600 |
|
610 | |||
601 | for i, ds in enumerate(self.ds): |
|
611 | for i, ds in enumerate(self.ds): | |
602 | attr, ch = self.data[i] |
|
612 | attr, ch = self.data[i] | |
603 | if ch == -1: |
|
613 | if ch == -1: | |
604 | ds[self.blockIndex] = getattr(self.dataOut, attr) |
|
614 | ds[self.blockIndex] = getattr(self.dataOut, attr) | |
605 | else: |
|
615 | else: | |
606 | ds[self.blockIndex] = getattr(self.dataOut, attr)[ch] |
|
616 | ds[self.blockIndex] = getattr(self.dataOut, attr)[ch] | |
607 |
|
617 | |||
608 | self.fp.flush() |
|
618 | self.fp.flush() | |
609 | self.blockIndex += 1 |
|
619 | self.blockIndex += 1 | |
610 | log.log('Block No. {}/{}'.format(self.blockIndex, self.blocksPerFile), self.name) |
|
620 | log.log('Block No. {}/{}'.format(self.blockIndex, self.blocksPerFile), self.name) | |
611 |
|
621 | |||
612 | return |
|
622 | return | |
613 |
|
623 | |||
614 | def closeFile(self): |
|
624 | def closeFile(self): | |
615 |
|
625 | |||
616 | if self.blockIndex != self.blocksPerFile: |
|
626 | if self.blockIndex != self.blocksPerFile: | |
617 | for ds in self.ds: |
|
627 | for ds in self.ds: | |
618 | ds.resize(self.blockIndex, axis=0) |
|
628 | ds.resize(self.blockIndex, axis=0) | |
619 |
|
629 | |||
620 | if self.fp: |
|
630 | if self.fp: | |
621 | self.fp.flush() |
|
631 | self.fp.flush() | |
622 | self.fp.close() |
|
632 | self.fp.close() | |
623 |
|
633 | |||
624 | def close(self): |
|
634 | def close(self): | |
625 |
|
635 | |||
626 | self.closeFile() |
|
636 | self.closeFile() |
@@ -1,982 +1,1049 | |||||
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 | """Spectra processing Unit and operations |
|
5 | """Spectra processing Unit and operations | |
6 |
|
6 | |||
7 | Here you will find the processing unit `SpectraProc` and several operations |
|
7 | Here you will find the processing unit `SpectraProc` and several operations | |
8 | to work with Spectra data type |
|
8 | to work with Spectra data type | |
9 | """ |
|
9 | """ | |
10 |
|
10 | |||
11 | import time |
|
11 | import time | |
12 | import itertools |
|
12 | import itertools | |
13 |
|
13 | |||
14 | import numpy |
|
14 | import numpy | |
15 |
|
15 | |||
16 | from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation |
|
16 | from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation | |
17 | from schainpy.model.data.jrodata import Spectra |
|
17 | from schainpy.model.data.jrodata import Spectra | |
18 | from schainpy.model.data.jrodata import hildebrand_sekhon |
|
18 | from schainpy.model.data.jrodata import hildebrand_sekhon | |
19 | from schainpy.utils import log |
|
19 | from schainpy.utils import log | |
20 |
|
20 | |||
21 |
|
21 | |||
22 | class SpectraProc(ProcessingUnit): |
|
22 | class SpectraProc(ProcessingUnit): | |
23 |
|
23 | |||
24 | def __init__(self): |
|
24 | def __init__(self): | |
25 |
|
25 | |||
26 | ProcessingUnit.__init__(self) |
|
26 | ProcessingUnit.__init__(self) | |
27 |
|
27 | |||
28 | self.buffer = None |
|
28 | self.buffer = None | |
29 | self.firstdatatime = None |
|
29 | self.firstdatatime = None | |
30 | self.profIndex = 0 |
|
30 | self.profIndex = 0 | |
31 | self.dataOut = Spectra() |
|
31 | self.dataOut = Spectra() | |
32 | self.id_min = None |
|
32 | self.id_min = None | |
33 | self.id_max = None |
|
33 | self.id_max = None | |
34 | self.setupReq = False #Agregar a todas las unidades de proc |
|
34 | self.setupReq = False #Agregar a todas las unidades de proc | |
35 |
|
35 | |||
36 | def __updateSpecFromVoltage(self): |
|
36 | def __updateSpecFromVoltage(self): | |
37 |
|
37 | |||
38 | self.dataOut.timeZone = self.dataIn.timeZone |
|
38 | self.dataOut.timeZone = self.dataIn.timeZone | |
39 | self.dataOut.dstFlag = self.dataIn.dstFlag |
|
39 | self.dataOut.dstFlag = self.dataIn.dstFlag | |
40 | self.dataOut.errorCount = self.dataIn.errorCount |
|
40 | self.dataOut.errorCount = self.dataIn.errorCount | |
41 | self.dataOut.useLocalTime = self.dataIn.useLocalTime |
|
41 | self.dataOut.useLocalTime = self.dataIn.useLocalTime | |
42 | try: |
|
42 | try: | |
43 | self.dataOut.processingHeaderObj = self.dataIn.processingHeaderObj.copy() |
|
43 | self.dataOut.processingHeaderObj = self.dataIn.processingHeaderObj.copy() | |
44 | except: |
|
44 | except: | |
45 | pass |
|
45 | pass | |
46 | self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy() |
|
46 | self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy() | |
47 | self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy() |
|
47 | self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy() | |
48 | self.dataOut.channelList = self.dataIn.channelList |
|
48 | self.dataOut.channelList = self.dataIn.channelList | |
49 | self.dataOut.heightList = self.dataIn.heightList |
|
49 | self.dataOut.heightList = self.dataIn.heightList | |
50 | self.dataOut.dtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')]) |
|
50 | self.dataOut.dtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')]) | |
51 | self.dataOut.nProfiles = self.dataOut.nFFTPoints |
|
51 | self.dataOut.nProfiles = self.dataOut.nFFTPoints | |
52 | self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock |
|
52 | self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock | |
53 | self.dataOut.utctime = self.firstdatatime |
|
53 | self.dataOut.utctime = self.firstdatatime | |
54 | self.dataOut.flagDecodeData = self.dataIn.flagDecodeData |
|
54 | self.dataOut.flagDecodeData = self.dataIn.flagDecodeData | |
55 | self.dataOut.flagDeflipData = self.dataIn.flagDeflipData |
|
55 | self.dataOut.flagDeflipData = self.dataIn.flagDeflipData | |
56 | self.dataOut.flagShiftFFT = False |
|
56 | self.dataOut.flagShiftFFT = False | |
57 | self.dataOut.nCohInt = self.dataIn.nCohInt |
|
57 | self.dataOut.nCohInt = self.dataIn.nCohInt | |
58 | self.dataOut.nIncohInt = 1 |
|
58 | self.dataOut.nIncohInt = 1 | |
59 | self.dataOut.windowOfFilter = self.dataIn.windowOfFilter |
|
59 | self.dataOut.windowOfFilter = self.dataIn.windowOfFilter | |
60 | self.dataOut.frequency = self.dataIn.frequency |
|
60 | self.dataOut.frequency = self.dataIn.frequency | |
61 | self.dataOut.realtime = self.dataIn.realtime |
|
61 | self.dataOut.realtime = self.dataIn.realtime | |
62 | self.dataOut.azimuth = self.dataIn.azimuth |
|
62 | self.dataOut.azimuth = self.dataIn.azimuth | |
63 | self.dataOut.zenith = self.dataIn.zenith |
|
63 | self.dataOut.zenith = self.dataIn.zenith | |
64 | self.dataOut.beam.codeList = self.dataIn.beam.codeList |
|
64 | self.dataOut.beam.codeList = self.dataIn.beam.codeList | |
65 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList |
|
65 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList | |
66 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList |
|
66 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList | |
67 | self.dataOut.runNextUnit = self.dataIn.runNextUnit |
|
67 | self.dataOut.runNextUnit = self.dataIn.runNextUnit | |
68 | try: |
|
68 | try: | |
69 | self.dataOut.step = self.dataIn.step |
|
69 | self.dataOut.step = self.dataIn.step | |
70 | except: |
|
70 | except: | |
71 | pass |
|
71 | pass | |
72 |
|
72 | |||
73 | def __getFft(self): |
|
73 | def __getFft(self): | |
74 | """ |
|
74 | """ | |
75 | Convierte valores de Voltaje a Spectra |
|
75 | Convierte valores de Voltaje a Spectra | |
76 |
|
76 | |||
77 | Affected: |
|
77 | Affected: | |
78 | self.dataOut.data_spc |
|
78 | self.dataOut.data_spc | |
79 | self.dataOut.data_cspc |
|
79 | self.dataOut.data_cspc | |
80 | self.dataOut.data_dc |
|
80 | self.dataOut.data_dc | |
81 | self.dataOut.heightList |
|
81 | self.dataOut.heightList | |
82 | self.profIndex |
|
82 | self.profIndex | |
83 | self.buffer |
|
83 | self.buffer | |
84 | self.dataOut.flagNoData |
|
84 | self.dataOut.flagNoData | |
85 | """ |
|
85 | """ | |
86 | fft_volt = numpy.fft.fft( |
|
86 | fft_volt = numpy.fft.fft( | |
87 | self.buffer, n=self.dataOut.nFFTPoints, axis=1) |
|
87 | self.buffer, n=self.dataOut.nFFTPoints, axis=1) | |
88 | fft_volt = fft_volt.astype(numpy.dtype('complex')) |
|
88 | fft_volt = fft_volt.astype(numpy.dtype('complex')) | |
89 | dc = fft_volt[:, 0, :] |
|
89 | dc = fft_volt[:, 0, :] | |
90 |
|
90 | |||
91 | # calculo de self-spectra |
|
91 | # calculo de self-spectra | |
92 | fft_volt = numpy.fft.fftshift(fft_volt, axes=(1,)) |
|
92 | fft_volt = numpy.fft.fftshift(fft_volt, axes=(1,)) | |
93 | spc = fft_volt * numpy.conjugate(fft_volt) |
|
93 | spc = fft_volt * numpy.conjugate(fft_volt) | |
94 | spc = spc.real |
|
94 | spc = spc.real | |
95 |
|
95 | |||
96 | blocksize = 0 |
|
96 | blocksize = 0 | |
97 | blocksize += dc.size |
|
97 | blocksize += dc.size | |
98 | blocksize += spc.size |
|
98 | blocksize += spc.size | |
99 |
|
99 | |||
100 | cspc = None |
|
100 | cspc = None | |
101 | pairIndex = 0 |
|
101 | pairIndex = 0 | |
102 | if self.dataOut.pairsList != None: |
|
102 | if self.dataOut.pairsList != None: | |
103 | # calculo de cross-spectra |
|
103 | # calculo de cross-spectra | |
104 | cspc = numpy.zeros( |
|
104 | cspc = numpy.zeros( | |
105 | (self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex') |
|
105 | (self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex') | |
106 | for pair in self.dataOut.pairsList: |
|
106 | for pair in self.dataOut.pairsList: | |
107 | if pair[0] not in self.dataOut.channelList: |
|
107 | if pair[0] not in self.dataOut.channelList: | |
108 | raise ValueError("Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" % ( |
|
108 | raise ValueError("Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" % ( | |
109 | str(pair), str(self.dataOut.channelList))) |
|
109 | str(pair), str(self.dataOut.channelList))) | |
110 | if pair[1] not in self.dataOut.channelList: |
|
110 | if pair[1] not in self.dataOut.channelList: | |
111 | raise ValueError("Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" % ( |
|
111 | raise ValueError("Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" % ( | |
112 | str(pair), str(self.dataOut.channelList))) |
|
112 | str(pair), str(self.dataOut.channelList))) | |
113 |
|
113 | |||
114 | cspc[pairIndex, :, :] = fft_volt[pair[0], :, :] * \ |
|
114 | cspc[pairIndex, :, :] = fft_volt[pair[0], :, :] * \ | |
115 | numpy.conjugate(fft_volt[pair[1], :, :]) |
|
115 | numpy.conjugate(fft_volt[pair[1], :, :]) | |
116 | pairIndex += 1 |
|
116 | pairIndex += 1 | |
117 | blocksize += cspc.size |
|
117 | blocksize += cspc.size | |
118 |
|
118 | |||
119 | self.dataOut.data_spc = spc |
|
119 | self.dataOut.data_spc = spc | |
120 | self.dataOut.data_cspc = cspc |
|
120 | self.dataOut.data_cspc = cspc | |
121 | self.dataOut.data_dc = dc |
|
121 | self.dataOut.data_dc = dc | |
122 | self.dataOut.blockSize = blocksize |
|
122 | self.dataOut.blockSize = blocksize | |
123 | self.dataOut.flagShiftFFT = False |
|
123 | self.dataOut.flagShiftFFT = False | |
124 |
|
124 | |||
125 | def run(self, nProfiles=None, nFFTPoints=None, pairsList=None, ippFactor=None, shift_fft=False, runNextUnit = 0): |
|
125 | def run(self, nProfiles=None, nFFTPoints=None, pairsList=None, ippFactor=None, shift_fft=False, runNextUnit = 0): | |
126 |
|
126 | |||
127 | self.dataIn.runNextUnit = runNextUnit |
|
127 | self.dataIn.runNextUnit = runNextUnit | |
128 | if self.dataIn.type == "Spectra": |
|
128 | if self.dataIn.type == "Spectra": | |
129 |
|
129 | |||
130 | self.dataOut.copy(self.dataIn) |
|
130 | self.dataOut.copy(self.dataIn) | |
131 | if shift_fft: |
|
131 | if shift_fft: | |
132 | #desplaza a la derecha en el eje 2 determinadas posiciones |
|
132 | #desplaza a la derecha en el eje 2 determinadas posiciones | |
133 | shift = int(self.dataOut.nFFTPoints/2) |
|
133 | shift = int(self.dataOut.nFFTPoints/2) | |
134 | self.dataOut.data_spc = numpy.roll(self.dataOut.data_spc, shift , axis=1) |
|
134 | self.dataOut.data_spc = numpy.roll(self.dataOut.data_spc, shift , axis=1) | |
135 |
|
135 | |||
136 | if self.dataOut.data_cspc is not None: |
|
136 | if self.dataOut.data_cspc is not None: | |
137 | #desplaza a la derecha en el eje 2 determinadas posiciones |
|
137 | #desplaza a la derecha en el eje 2 determinadas posiciones | |
138 | self.dataOut.data_cspc = numpy.roll(self.dataOut.data_cspc, shift, axis=1) |
|
138 | self.dataOut.data_cspc = numpy.roll(self.dataOut.data_cspc, shift, axis=1) | |
139 | if pairsList: |
|
139 | if pairsList: | |
140 | self.__selectPairs(pairsList) |
|
140 | self.__selectPairs(pairsList) | |
141 |
|
141 | |||
142 | elif self.dataIn.type == "Voltage": |
|
142 | elif self.dataIn.type == "Voltage": | |
143 |
|
143 | |||
144 | self.dataOut.flagNoData = True |
|
144 | self.dataOut.flagNoData = True | |
145 |
|
145 | |||
146 | if nFFTPoints == None: |
|
146 | if nFFTPoints == None: | |
147 | raise ValueError("This SpectraProc.run() need nFFTPoints input variable") |
|
147 | raise ValueError("This SpectraProc.run() need nFFTPoints input variable") | |
148 |
|
148 | |||
149 | if nProfiles == None: |
|
149 | if nProfiles == None: | |
150 | nProfiles = nFFTPoints |
|
150 | nProfiles = nFFTPoints | |
151 | #print(self.dataOut.ipp) |
|
151 | #print(self.dataOut.ipp) | |
152 | #exit(1) |
|
152 | #exit(1) | |
153 | if ippFactor == None: |
|
153 | if ippFactor == None: | |
154 | self.dataOut.ippFactor = 1 |
|
154 | self.dataOut.ippFactor = 1 | |
155 | #if ippFactor is not None: |
|
155 | #if ippFactor is not None: | |
156 | #self.dataOut.ippFactor = ippFactor |
|
156 | #self.dataOut.ippFactor = ippFactor | |
157 | #print(ippFactor) |
|
157 | #print(ippFactor) | |
158 | #print(self.dataOut.ippFactor) |
|
158 | #print(self.dataOut.ippFactor) | |
159 | #exit(1) |
|
159 | #exit(1) | |
160 |
|
160 | |||
161 | self.dataOut.nFFTPoints = nFFTPoints |
|
161 | self.dataOut.nFFTPoints = nFFTPoints | |
162 |
|
162 | |||
163 | if self.buffer is None: |
|
163 | if self.buffer is None: | |
164 | self.buffer = numpy.zeros((self.dataIn.nChannels, |
|
164 | self.buffer = numpy.zeros((self.dataIn.nChannels, | |
165 | nProfiles, |
|
165 | nProfiles, | |
166 | self.dataIn.nHeights), |
|
166 | self.dataIn.nHeights), | |
167 | dtype='complex') |
|
167 | dtype='complex') | |
168 |
|
168 | |||
169 | if self.dataIn.flagDataAsBlock: |
|
169 | if self.dataIn.flagDataAsBlock: | |
170 | nVoltProfiles = self.dataIn.data.shape[1] |
|
170 | nVoltProfiles = self.dataIn.data.shape[1] | |
171 |
|
171 | |||
172 | if nVoltProfiles == nProfiles: |
|
172 | if nVoltProfiles == nProfiles: | |
173 | self.buffer = self.dataIn.data.copy() |
|
173 | self.buffer = self.dataIn.data.copy() | |
174 | self.profIndex = nVoltProfiles |
|
174 | self.profIndex = nVoltProfiles | |
175 |
|
175 | |||
176 | elif nVoltProfiles < nProfiles: |
|
176 | elif nVoltProfiles < nProfiles: | |
177 |
|
177 | |||
178 | if self.profIndex == 0: |
|
178 | if self.profIndex == 0: | |
179 | self.id_min = 0 |
|
179 | self.id_min = 0 | |
180 | self.id_max = nVoltProfiles |
|
180 | self.id_max = nVoltProfiles | |
181 | #print(self.id_min) |
|
181 | #print(self.id_min) | |
182 | #print(self.id_max) |
|
182 | #print(self.id_max) | |
183 | #print(numpy.shape(self.buffer)) |
|
183 | #print(numpy.shape(self.buffer)) | |
184 | self.buffer[:, self.id_min:self.id_max, |
|
184 | self.buffer[:, self.id_min:self.id_max, | |
185 | :] = self.dataIn.data |
|
185 | :] = self.dataIn.data | |
186 | self.profIndex += nVoltProfiles |
|
186 | self.profIndex += nVoltProfiles | |
187 | self.id_min += nVoltProfiles |
|
187 | self.id_min += nVoltProfiles | |
188 | self.id_max += nVoltProfiles |
|
188 | self.id_max += nVoltProfiles | |
189 | else: |
|
189 | else: | |
190 | raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % ( |
|
190 | raise ValueError("The type object %s has %d profiles, it should just has %d profiles" % ( | |
191 | self.dataIn.type, self.dataIn.data.shape[1], nProfiles)) |
|
191 | self.dataIn.type, self.dataIn.data.shape[1], nProfiles)) | |
192 | self.dataOut.flagNoData = True |
|
192 | self.dataOut.flagNoData = True | |
193 | else: |
|
193 | else: | |
194 | self.buffer[:, self.profIndex, :] = self.dataIn.data.copy() |
|
194 | self.buffer[:, self.profIndex, :] = self.dataIn.data.copy() | |
195 | self.profIndex += 1 |
|
195 | self.profIndex += 1 | |
196 |
|
196 | |||
197 | if self.firstdatatime == None: |
|
197 | if self.firstdatatime == None: | |
198 | self.firstdatatime = self.dataIn.utctime |
|
198 | self.firstdatatime = self.dataIn.utctime | |
199 |
|
199 | |||
200 | if self.profIndex == nProfiles: |
|
200 | if self.profIndex == nProfiles: | |
201 | self.__updateSpecFromVoltage() |
|
201 | self.__updateSpecFromVoltage() | |
202 | if pairsList == None: |
|
202 | if pairsList == None: | |
203 | self.dataOut.pairsList = [pair for pair in itertools.combinations(self.dataOut.channelList, 2)] |
|
203 | self.dataOut.pairsList = [pair for pair in itertools.combinations(self.dataOut.channelList, 2)] | |
204 | else: |
|
204 | else: | |
205 | self.dataOut.pairsList = pairsList |
|
205 | self.dataOut.pairsList = pairsList | |
206 | self.__getFft() |
|
206 | self.__getFft() | |
207 | self.dataOut.flagNoData = False |
|
207 | self.dataOut.flagNoData = False | |
208 | self.firstdatatime = None |
|
208 | self.firstdatatime = None | |
209 | self.profIndex = 0 |
|
209 | self.profIndex = 0 | |
210 | else: |
|
210 | else: | |
211 | raise ValueError("The type of input object '%s' is not valid".format( |
|
211 | raise ValueError("The type of input object '%s' is not valid".format( | |
212 | self.dataIn.type)) |
|
212 | self.dataIn.type)) | |
213 |
|
213 | |||
214 |
|
214 | |||
215 | def __selectPairs(self, pairsList): |
|
215 | def __selectPairs(self, pairsList): | |
216 |
|
216 | |||
217 | if not pairsList: |
|
217 | if not pairsList: | |
218 | return |
|
218 | return | |
219 |
|
219 | |||
220 | pairs = [] |
|
220 | pairs = [] | |
221 | pairsIndex = [] |
|
221 | pairsIndex = [] | |
222 |
|
222 | |||
223 | for pair in pairsList: |
|
223 | for pair in pairsList: | |
224 | if pair[0] not in self.dataOut.channelList or pair[1] not in self.dataOut.channelList: |
|
224 | if pair[0] not in self.dataOut.channelList or pair[1] not in self.dataOut.channelList: | |
225 | continue |
|
225 | continue | |
226 | pairs.append(pair) |
|
226 | pairs.append(pair) | |
227 | pairsIndex.append(pairs.index(pair)) |
|
227 | pairsIndex.append(pairs.index(pair)) | |
228 |
|
228 | |||
229 | self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndex] |
|
229 | self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndex] | |
230 | self.dataOut.pairsList = pairs |
|
230 | self.dataOut.pairsList = pairs | |
231 |
|
231 | |||
232 | return |
|
232 | return | |
233 |
|
233 | |||
234 | def selectFFTs(self, minFFT, maxFFT ): |
|
234 | def selectFFTs(self, minFFT, maxFFT ): | |
235 | """ |
|
235 | """ | |
236 | Selecciona un bloque de datos en base a un grupo de valores de puntos FFTs segun el rango |
|
236 | Selecciona un bloque de datos en base a un grupo de valores de puntos FFTs segun el rango | |
237 | minFFT<= FFT <= maxFFT |
|
237 | minFFT<= FFT <= maxFFT | |
238 | """ |
|
238 | """ | |
239 |
|
239 | |||
240 | if (minFFT > maxFFT): |
|
240 | if (minFFT > maxFFT): | |
241 | raise ValueError("Error selecting heights: Height range (%d,%d) is not valid" % (minFFT, maxFFT)) |
|
241 | raise ValueError("Error selecting heights: Height range (%d,%d) is not valid" % (minFFT, maxFFT)) | |
242 |
|
242 | |||
243 | if (minFFT < self.dataOut.getFreqRange()[0]): |
|
243 | if (minFFT < self.dataOut.getFreqRange()[0]): | |
244 | minFFT = self.dataOut.getFreqRange()[0] |
|
244 | minFFT = self.dataOut.getFreqRange()[0] | |
245 |
|
245 | |||
246 | if (maxFFT > self.dataOut.getFreqRange()[-1]): |
|
246 | if (maxFFT > self.dataOut.getFreqRange()[-1]): | |
247 | maxFFT = self.dataOut.getFreqRange()[-1] |
|
247 | maxFFT = self.dataOut.getFreqRange()[-1] | |
248 |
|
248 | |||
249 | minIndex = 0 |
|
249 | minIndex = 0 | |
250 | maxIndex = 0 |
|
250 | maxIndex = 0 | |
251 | FFTs = self.dataOut.getFreqRange() |
|
251 | FFTs = self.dataOut.getFreqRange() | |
252 |
|
252 | |||
253 | inda = numpy.where(FFTs >= minFFT) |
|
253 | inda = numpy.where(FFTs >= minFFT) | |
254 | indb = numpy.where(FFTs <= maxFFT) |
|
254 | indb = numpy.where(FFTs <= maxFFT) | |
255 |
|
255 | |||
256 | try: |
|
256 | try: | |
257 | minIndex = inda[0][0] |
|
257 | minIndex = inda[0][0] | |
258 | except: |
|
258 | except: | |
259 | minIndex = 0 |
|
259 | minIndex = 0 | |
260 |
|
260 | |||
261 | try: |
|
261 | try: | |
262 | maxIndex = indb[0][-1] |
|
262 | maxIndex = indb[0][-1] | |
263 | except: |
|
263 | except: | |
264 | maxIndex = len(FFTs) |
|
264 | maxIndex = len(FFTs) | |
265 |
|
265 | |||
266 | self.selectFFTsByIndex(minIndex, maxIndex) |
|
266 | self.selectFFTsByIndex(minIndex, maxIndex) | |
267 |
|
267 | |||
268 | return 1 |
|
268 | return 1 | |
269 |
|
269 | |||
270 | def getBeaconSignal(self, tauindex=0, channelindex=0, hei_ref=None): |
|
270 | def getBeaconSignal(self, tauindex=0, channelindex=0, hei_ref=None): | |
271 | newheis = numpy.where( |
|
271 | newheis = numpy.where( | |
272 | self.dataOut.heightList > self.dataOut.radarControllerHeaderObj.Taus[tauindex]) |
|
272 | self.dataOut.heightList > self.dataOut.radarControllerHeaderObj.Taus[tauindex]) | |
273 |
|
273 | |||
274 | if hei_ref != None: |
|
274 | if hei_ref != None: | |
275 | newheis = numpy.where(self.dataOut.heightList > hei_ref) |
|
275 | newheis = numpy.where(self.dataOut.heightList > hei_ref) | |
276 |
|
276 | |||
277 | minIndex = min(newheis[0]) |
|
277 | minIndex = min(newheis[0]) | |
278 | maxIndex = max(newheis[0]) |
|
278 | maxIndex = max(newheis[0]) | |
279 | data_spc = self.dataOut.data_spc[:, :, minIndex:maxIndex + 1] |
|
279 | data_spc = self.dataOut.data_spc[:, :, minIndex:maxIndex + 1] | |
280 | heightList = self.dataOut.heightList[minIndex:maxIndex + 1] |
|
280 | heightList = self.dataOut.heightList[minIndex:maxIndex + 1] | |
281 |
|
281 | |||
282 | # determina indices |
|
282 | # determina indices | |
283 | nheis = int(self.dataOut.radarControllerHeaderObj.txB / |
|
283 | nheis = int(self.dataOut.radarControllerHeaderObj.txB / | |
284 | (self.dataOut.heightList[1] - self.dataOut.heightList[0])) |
|
284 | (self.dataOut.heightList[1] - self.dataOut.heightList[0])) | |
285 | avg_dB = 10 * \ |
|
285 | avg_dB = 10 * \ | |
286 | numpy.log10(numpy.sum(data_spc[channelindex, :, :], axis=0)) |
|
286 | numpy.log10(numpy.sum(data_spc[channelindex, :, :], axis=0)) | |
287 | beacon_dB = numpy.sort(avg_dB)[-nheis:] |
|
287 | beacon_dB = numpy.sort(avg_dB)[-nheis:] | |
288 | beacon_heiIndexList = [] |
|
288 | beacon_heiIndexList = [] | |
289 | for val in avg_dB.tolist(): |
|
289 | for val in avg_dB.tolist(): | |
290 | if val >= beacon_dB[0]: |
|
290 | if val >= beacon_dB[0]: | |
291 | beacon_heiIndexList.append(avg_dB.tolist().index(val)) |
|
291 | beacon_heiIndexList.append(avg_dB.tolist().index(val)) | |
292 |
|
292 | |||
293 | #data_spc = data_spc[:,:,beacon_heiIndexList] |
|
293 | #data_spc = data_spc[:,:,beacon_heiIndexList] | |
294 | data_cspc = None |
|
294 | data_cspc = None | |
295 | if self.dataOut.data_cspc is not None: |
|
295 | if self.dataOut.data_cspc is not None: | |
296 | data_cspc = self.dataOut.data_cspc[:, :, minIndex:maxIndex + 1] |
|
296 | data_cspc = self.dataOut.data_cspc[:, :, minIndex:maxIndex + 1] | |
297 | #data_cspc = data_cspc[:,:,beacon_heiIndexList] |
|
297 | #data_cspc = data_cspc[:,:,beacon_heiIndexList] | |
298 |
|
298 | |||
299 | data_dc = None |
|
299 | data_dc = None | |
300 | if self.dataOut.data_dc is not None: |
|
300 | if self.dataOut.data_dc is not None: | |
301 | data_dc = self.dataOut.data_dc[:, minIndex:maxIndex + 1] |
|
301 | data_dc = self.dataOut.data_dc[:, minIndex:maxIndex + 1] | |
302 | #data_dc = data_dc[:,beacon_heiIndexList] |
|
302 | #data_dc = data_dc[:,beacon_heiIndexList] | |
303 |
|
303 | |||
304 | self.dataOut.data_spc = data_spc |
|
304 | self.dataOut.data_spc = data_spc | |
305 | self.dataOut.data_cspc = data_cspc |
|
305 | self.dataOut.data_cspc = data_cspc | |
306 | self.dataOut.data_dc = data_dc |
|
306 | self.dataOut.data_dc = data_dc | |
307 | self.dataOut.heightList = heightList |
|
307 | self.dataOut.heightList = heightList | |
308 | self.dataOut.beacon_heiIndexList = beacon_heiIndexList |
|
308 | self.dataOut.beacon_heiIndexList = beacon_heiIndexList | |
309 |
|
309 | |||
310 | return 1 |
|
310 | return 1 | |
311 |
|
311 | |||
312 | def selectFFTsByIndex(self, minIndex, maxIndex): |
|
312 | def selectFFTsByIndex(self, minIndex, maxIndex): | |
313 | """ |
|
313 | """ | |
314 |
|
314 | |||
315 | """ |
|
315 | """ | |
316 |
|
316 | |||
317 | if (minIndex < 0) or (minIndex > maxIndex): |
|
317 | if (minIndex < 0) or (minIndex > maxIndex): | |
318 | raise ValueError("Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)) |
|
318 | raise ValueError("Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)) | |
319 |
|
319 | |||
320 | if (maxIndex >= self.dataOut.nProfiles): |
|
320 | if (maxIndex >= self.dataOut.nProfiles): | |
321 | maxIndex = self.dataOut.nProfiles-1 |
|
321 | maxIndex = self.dataOut.nProfiles-1 | |
322 |
|
322 | |||
323 | #Spectra |
|
323 | #Spectra | |
324 | data_spc = self.dataOut.data_spc[:,minIndex:maxIndex+1,:] |
|
324 | data_spc = self.dataOut.data_spc[:,minIndex:maxIndex+1,:] | |
325 |
|
325 | |||
326 | data_cspc = None |
|
326 | data_cspc = None | |
327 | if self.dataOut.data_cspc is not None: |
|
327 | if self.dataOut.data_cspc is not None: | |
328 | data_cspc = self.dataOut.data_cspc[:,minIndex:maxIndex+1,:] |
|
328 | data_cspc = self.dataOut.data_cspc[:,minIndex:maxIndex+1,:] | |
329 |
|
329 | |||
330 | data_dc = None |
|
330 | data_dc = None | |
331 | if self.dataOut.data_dc is not None: |
|
331 | if self.dataOut.data_dc is not None: | |
332 | data_dc = self.dataOut.data_dc[minIndex:maxIndex+1,:] |
|
332 | data_dc = self.dataOut.data_dc[minIndex:maxIndex+1,:] | |
333 |
|
333 | |||
334 | self.dataOut.data_spc = data_spc |
|
334 | self.dataOut.data_spc = data_spc | |
335 | self.dataOut.data_cspc = data_cspc |
|
335 | self.dataOut.data_cspc = data_cspc | |
336 | self.dataOut.data_dc = data_dc |
|
336 | self.dataOut.data_dc = data_dc | |
337 |
|
337 | |||
338 | self.dataOut.ippSeconds = self.dataOut.ippSeconds*(self.dataOut.nFFTPoints / numpy.shape(data_cspc)[1]) |
|
338 | self.dataOut.ippSeconds = self.dataOut.ippSeconds*(self.dataOut.nFFTPoints / numpy.shape(data_cspc)[1]) | |
339 | self.dataOut.nFFTPoints = numpy.shape(data_cspc)[1] |
|
339 | self.dataOut.nFFTPoints = numpy.shape(data_cspc)[1] | |
340 | self.dataOut.profilesPerBlock = numpy.shape(data_cspc)[1] |
|
340 | self.dataOut.profilesPerBlock = numpy.shape(data_cspc)[1] | |
341 |
|
341 | |||
342 | return 1 |
|
342 | return 1 | |
343 |
|
343 | |||
344 | def getNoise(self, minHei=None, maxHei=None, minVel=None, maxVel=None): |
|
344 | def getNoise(self, minHei=None, maxHei=None, minVel=None, maxVel=None): | |
345 | # validacion de rango |
|
345 | # validacion de rango | |
346 | print("NOISeeee") |
|
346 | print("NOISeeee") | |
347 | if minHei == None: |
|
347 | if minHei == None: | |
348 | minHei = self.dataOut.heightList[0] |
|
348 | minHei = self.dataOut.heightList[0] | |
349 |
|
349 | |||
350 | if maxHei == None: |
|
350 | if maxHei == None: | |
351 | maxHei = self.dataOut.heightList[-1] |
|
351 | maxHei = self.dataOut.heightList[-1] | |
352 |
|
352 | |||
353 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): |
|
353 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): | |
354 | print('minHei: %.2f is out of the heights range' % (minHei)) |
|
354 | print('minHei: %.2f is out of the heights range' % (minHei)) | |
355 | print('minHei is setting to %.2f' % (self.dataOut.heightList[0])) |
|
355 | print('minHei is setting to %.2f' % (self.dataOut.heightList[0])) | |
356 | minHei = self.dataOut.heightList[0] |
|
356 | minHei = self.dataOut.heightList[0] | |
357 |
|
357 | |||
358 | if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei): |
|
358 | if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei): | |
359 | print('maxHei: %.2f is out of the heights range' % (maxHei)) |
|
359 | print('maxHei: %.2f is out of the heights range' % (maxHei)) | |
360 | print('maxHei is setting to %.2f' % (self.dataOut.heightList[-1])) |
|
360 | print('maxHei is setting to %.2f' % (self.dataOut.heightList[-1])) | |
361 | maxHei = self.dataOut.heightList[-1] |
|
361 | maxHei = self.dataOut.heightList[-1] | |
362 |
|
362 | |||
363 | # validacion de velocidades |
|
363 | # validacion de velocidades | |
364 | velrange = self.dataOut.getVelRange(1) |
|
364 | velrange = self.dataOut.getVelRange(1) | |
365 |
|
365 | |||
366 | if minVel == None: |
|
366 | if minVel == None: | |
367 | minVel = velrange[0] |
|
367 | minVel = velrange[0] | |
368 |
|
368 | |||
369 | if maxVel == None: |
|
369 | if maxVel == None: | |
370 | maxVel = velrange[-1] |
|
370 | maxVel = velrange[-1] | |
371 |
|
371 | |||
372 | if (minVel < velrange[0]) or (minVel > maxVel): |
|
372 | if (minVel < velrange[0]) or (minVel > maxVel): | |
373 | print('minVel: %.2f is out of the velocity range' % (minVel)) |
|
373 | print('minVel: %.2f is out of the velocity range' % (minVel)) | |
374 | print('minVel is setting to %.2f' % (velrange[0])) |
|
374 | print('minVel is setting to %.2f' % (velrange[0])) | |
375 | minVel = velrange[0] |
|
375 | minVel = velrange[0] | |
376 |
|
376 | |||
377 | if (maxVel > velrange[-1]) or (maxVel < minVel): |
|
377 | if (maxVel > velrange[-1]) or (maxVel < minVel): | |
378 | print('maxVel: %.2f is out of the velocity range' % (maxVel)) |
|
378 | print('maxVel: %.2f is out of the velocity range' % (maxVel)) | |
379 | print('maxVel is setting to %.2f' % (velrange[-1])) |
|
379 | print('maxVel is setting to %.2f' % (velrange[-1])) | |
380 | maxVel = velrange[-1] |
|
380 | maxVel = velrange[-1] | |
381 |
|
381 | |||
382 | # seleccion de indices para rango |
|
382 | # seleccion de indices para rango | |
383 | minIndex = 0 |
|
383 | minIndex = 0 | |
384 | maxIndex = 0 |
|
384 | maxIndex = 0 | |
385 | heights = self.dataOut.heightList |
|
385 | heights = self.dataOut.heightList | |
386 |
|
386 | |||
387 | inda = numpy.where(heights >= minHei) |
|
387 | inda = numpy.where(heights >= minHei) | |
388 | indb = numpy.where(heights <= maxHei) |
|
388 | indb = numpy.where(heights <= maxHei) | |
389 |
|
389 | |||
390 | try: |
|
390 | try: | |
391 | minIndex = inda[0][0] |
|
391 | minIndex = inda[0][0] | |
392 | except: |
|
392 | except: | |
393 | minIndex = 0 |
|
393 | minIndex = 0 | |
394 |
|
394 | |||
395 | try: |
|
395 | try: | |
396 | maxIndex = indb[0][-1] |
|
396 | maxIndex = indb[0][-1] | |
397 | except: |
|
397 | except: | |
398 | maxIndex = len(heights) |
|
398 | maxIndex = len(heights) | |
399 |
|
399 | |||
400 | if (minIndex < 0) or (minIndex > maxIndex): |
|
400 | if (minIndex < 0) or (minIndex > maxIndex): | |
401 | raise ValueError("some value in (%d,%d) is not valid" % ( |
|
401 | raise ValueError("some value in (%d,%d) is not valid" % ( | |
402 | minIndex, maxIndex)) |
|
402 | minIndex, maxIndex)) | |
403 |
|
403 | |||
404 | if (maxIndex >= self.dataOut.nHeights): |
|
404 | if (maxIndex >= self.dataOut.nHeights): | |
405 | maxIndex = self.dataOut.nHeights - 1 |
|
405 | maxIndex = self.dataOut.nHeights - 1 | |
406 |
|
406 | |||
407 | # seleccion de indices para velocidades |
|
407 | # seleccion de indices para velocidades | |
408 | indminvel = numpy.where(velrange >= minVel) |
|
408 | indminvel = numpy.where(velrange >= minVel) | |
409 | indmaxvel = numpy.where(velrange <= maxVel) |
|
409 | indmaxvel = numpy.where(velrange <= maxVel) | |
410 | try: |
|
410 | try: | |
411 | minIndexVel = indminvel[0][0] |
|
411 | minIndexVel = indminvel[0][0] | |
412 | except: |
|
412 | except: | |
413 | minIndexVel = 0 |
|
413 | minIndexVel = 0 | |
414 |
|
414 | |||
415 | try: |
|
415 | try: | |
416 | maxIndexVel = indmaxvel[0][-1] |
|
416 | maxIndexVel = indmaxvel[0][-1] | |
417 | except: |
|
417 | except: | |
418 | maxIndexVel = len(velrange) |
|
418 | maxIndexVel = len(velrange) | |
419 |
|
419 | |||
420 | # seleccion del espectro |
|
420 | # seleccion del espectro | |
421 | data_spc = self.dataOut.data_spc[:, |
|
421 | data_spc = self.dataOut.data_spc[:, | |
422 | minIndexVel:maxIndexVel + 1, minIndex:maxIndex + 1] |
|
422 | minIndexVel:maxIndexVel + 1, minIndex:maxIndex + 1] | |
423 | # estimacion de ruido |
|
423 | # estimacion de ruido | |
424 | noise = numpy.zeros(self.dataOut.nChannels) |
|
424 | noise = numpy.zeros(self.dataOut.nChannels) | |
425 |
|
425 | |||
426 | for channel in range(self.dataOut.nChannels): |
|
426 | for channel in range(self.dataOut.nChannels): | |
427 | daux = data_spc[channel, :, :] |
|
427 | daux = data_spc[channel, :, :] | |
428 | sortdata = numpy.sort(daux, axis=None) |
|
428 | sortdata = numpy.sort(daux, axis=None) | |
429 | noise[channel] = hildebrand_sekhon(sortdata, self.dataOut.nIncohInt) |
|
429 | noise[channel] = hildebrand_sekhon(sortdata, self.dataOut.nIncohInt) | |
430 |
|
430 | |||
431 | self.dataOut.noise_estimation = noise.copy() |
|
431 | self.dataOut.noise_estimation = noise.copy() | |
432 |
|
432 | |||
433 | return 1 |
|
433 | return 1 | |
434 |
|
434 | |||
435 | class GetSNR(Operation): |
|
435 | class GetSNR(Operation): | |
436 | ''' |
|
436 | ''' | |
437 | Written by R. Flores |
|
437 | Written by R. Flores | |
438 | ''' |
|
438 | ''' | |
439 | """Operation to get SNR. |
|
439 | """Operation to get SNR. | |
440 |
|
440 | |||
441 | Parameters: |
|
441 | Parameters: | |
442 | ----------- |
|
442 | ----------- | |
443 |
|
443 | |||
444 | Example |
|
444 | Example | |
445 | -------- |
|
445 | -------- | |
446 |
|
446 | |||
447 | op = proc_unit.addOperation(name='GetSNR', optype='other') |
|
447 | op = proc_unit.addOperation(name='GetSNR', optype='other') | |
448 |
|
448 | |||
449 | """ |
|
449 | """ | |
450 |
|
450 | |||
451 | def __init__(self, **kwargs): |
|
451 | def __init__(self, **kwargs): | |
452 |
|
452 | |||
453 | Operation.__init__(self, **kwargs) |
|
453 | Operation.__init__(self, **kwargs) | |
454 |
|
454 | |||
455 |
|
455 | |||
456 | def run(self,dataOut): |
|
456 | def run(self,dataOut): | |
457 |
|
457 | |||
458 | #noise = dataOut.getNoise() |
|
458 | #noise = dataOut.getNoise() | |
459 | noise = dataOut.getNoise(ymin_index=-10) #Región superior donde solo debería de haber ruido |
|
459 | noise = dataOut.getNoise(ymin_index=-10) #Región superior donde solo debería de haber ruido | |
460 | #print("Noise: ", noise) |
|
460 | #print("Noise: ", noise) | |
461 | #print("Noise_dB: ", 10*numpy.log10(noise/dataOut.normFactor)) |
|
461 | #print("Noise_dB: ", 10*numpy.log10(noise/dataOut.normFactor)) | |
462 | #print("Heights: ", dataOut.heightList) |
|
462 | #print("Heights: ", dataOut.heightList) | |
463 | #dataOut.data_snr = (dataOut.data_spc.sum(axis=1))/(noise[:,None]*dataOut.normFactor) |
|
463 | #dataOut.data_snr = (dataOut.data_spc.sum(axis=1))/(noise[:,None]*dataOut.normFactor) | |
464 | ################dataOut.data_snr = (dataOut.data_spc.sum(axis=1))/(noise[:,None]*dataOut.nFFTPoints) #Before 12Jan2023 |
|
464 | ################dataOut.data_snr = (dataOut.data_spc.sum(axis=1))/(noise[:,None]*dataOut.nFFTPoints) #Before 12Jan2023 | |
465 | #dataOut.data_snr = (dataOut.data_spc.sum(axis=1)-noise[:,None])/(noise[:,None]) |
|
465 | #dataOut.data_snr = (dataOut.data_spc.sum(axis=1)-noise[:,None])/(noise[:,None]) | |
466 | dataOut.data_snr = (dataOut.data_spc.sum(axis=1)-noise[:,None]*dataOut.nFFTPoints)/(noise[:,None]*dataOut.nFFTPoints) #It works apparently |
|
466 | dataOut.data_snr = (dataOut.data_spc.sum(axis=1)-noise[:,None]*dataOut.nFFTPoints)/(noise[:,None]*dataOut.nFFTPoints) #It works apparently | |
467 | dataOut.snl = numpy.log10(dataOut.data_snr) |
|
467 | dataOut.snl = numpy.log10(dataOut.data_snr) | |
468 | #print("snl: ", dataOut.snl) |
|
468 | #print("snl: ", dataOut.snl) | |
469 | #exit(1) |
|
469 | #exit(1) | |
470 | #print(dataOut.heightList[-11]) |
|
470 | #print(dataOut.heightList[-11]) | |
471 | #print(numpy.shape(dataOut.heightList)) |
|
471 | #print(numpy.shape(dataOut.heightList)) | |
472 | #print(dataOut.data_snr) |
|
472 | #print(dataOut.data_snr) | |
473 | #print(dataOut.data_snr[0,-11]) |
|
473 | #print(dataOut.data_snr[0,-11]) | |
474 | #exit(1) |
|
474 | #exit(1) | |
475 | #dataOut.data_snr = numpy.where(10*numpy.log10(dataOut.data_snr)<.5, numpy.nan, dataOut.data_snr) |
|
475 | #dataOut.data_snr = numpy.where(10*numpy.log10(dataOut.data_snr)<.5, numpy.nan, dataOut.data_snr) | |
476 | #dataOut.data_snr = numpy.where(10*numpy.log10(dataOut.data_snr)<.1, numpy.nan, dataOut.data_snr) |
|
476 | #dataOut.data_snr = numpy.where(10*numpy.log10(dataOut.data_snr)<.1, numpy.nan, dataOut.data_snr) | |
477 | #dataOut.data_snr = numpy.where(10*numpy.log10(dataOut.data_snr)<.0, numpy.nan, dataOut.data_snr) |
|
477 | #dataOut.data_snr = numpy.where(10*numpy.log10(dataOut.data_snr)<.0, numpy.nan, dataOut.data_snr) | |
478 | #dataOut.data_snr = numpy.where(dataOut.data_snr<.05, numpy.nan, dataOut.data_snr) |
|
478 | #dataOut.data_snr = numpy.where(dataOut.data_snr<.05, numpy.nan, dataOut.data_snr) | |
479 | #dataOut.snl = numpy.where(dataOut.data_snr<.01, numpy.nan, dataOut.snl) |
|
479 | #dataOut.snl = numpy.where(dataOut.data_snr<.01, numpy.nan, dataOut.snl) | |
480 | dataOut.snl = numpy.where(dataOut.snl<-1, numpy.nan, dataOut.snl) |
|
480 | dataOut.snl = numpy.where(dataOut.snl<-1, numpy.nan, dataOut.snl) | |
481 | ''' |
|
481 | ''' | |
482 | import matplotlib.pyplot as plt |
|
482 | import matplotlib.pyplot as plt | |
483 | #plt.plot(10*numpy.log10(dataOut.data_snr[0]),dataOut.heightList) |
|
483 | #plt.plot(10*numpy.log10(dataOut.data_snr[0]),dataOut.heightList) | |
484 | plt.plot(dataOut.data_snr[0],dataOut.heightList)#,marker='*') |
|
484 | plt.plot(dataOut.data_snr[0],dataOut.heightList)#,marker='*') | |
485 | plt.xlim(-1,10) |
|
485 | plt.xlim(-1,10) | |
486 | plt.axvline(1,color='k') |
|
486 | plt.axvline(1,color='k') | |
487 | plt.axvline(.1,color='k',linestyle='--') |
|
487 | plt.axvline(.1,color='k',linestyle='--') | |
488 | plt.grid() |
|
488 | plt.grid() | |
489 | plt.show() |
|
489 | plt.show() | |
490 | ''' |
|
490 | ''' | |
491 | #dataOut.data_snr = 10*numpy.log10(dataOut.data_snr) |
|
491 | #dataOut.data_snr = 10*numpy.log10(dataOut.data_snr) | |
492 | #dataOut.data_snr = numpy.expand_dims(dataOut.data_snr,axis=0) |
|
492 | #dataOut.data_snr = numpy.expand_dims(dataOut.data_snr,axis=0) | |
493 | #print(dataOut.data_snr.shape) |
|
493 | #print(dataOut.data_snr.shape) | |
494 | #exit(1) |
|
494 | #exit(1) | |
495 | #print("Before: ", dataOut.data_snr[0]) |
|
495 | #print("Before: ", dataOut.data_snr[0]) | |
496 |
|
496 | |||
497 |
|
497 | |||
498 | return dataOut |
|
498 | return dataOut | |
499 |
|
499 | |||
500 | class removeDC(Operation): |
|
500 | class removeDC(Operation): | |
501 |
|
501 | |||
502 | def run(self, dataOut, mode=2): |
|
502 | def run(self, dataOut, mode=2): | |
503 | self.dataOut = dataOut |
|
503 | self.dataOut = dataOut | |
504 | jspectra = self.dataOut.data_spc |
|
504 | jspectra = self.dataOut.data_spc | |
505 | jcspectra = self.dataOut.data_cspc |
|
505 | jcspectra = self.dataOut.data_cspc | |
506 |
|
506 | |||
507 | num_chan = jspectra.shape[0] |
|
507 | num_chan = jspectra.shape[0] | |
508 | num_hei = jspectra.shape[2] |
|
508 | num_hei = jspectra.shape[2] | |
509 |
|
509 | |||
510 | if jcspectra is not None: |
|
510 | if jcspectra is not None: | |
511 | jcspectraExist = True |
|
511 | jcspectraExist = True | |
512 | num_pairs = jcspectra.shape[0] |
|
512 | num_pairs = jcspectra.shape[0] | |
513 | else: |
|
513 | else: | |
514 | jcspectraExist = False |
|
514 | jcspectraExist = False | |
515 |
|
515 | |||
516 | freq_dc = int(jspectra.shape[1] / 2) |
|
516 | freq_dc = int(jspectra.shape[1] / 2) | |
517 | ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc |
|
517 | ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc | |
518 | ind_vel = ind_vel.astype(int) |
|
518 | ind_vel = ind_vel.astype(int) | |
519 |
|
519 | |||
520 | if ind_vel[0] < 0: |
|
520 | if ind_vel[0] < 0: | |
521 | ind_vel[list(range(0, 1))] = ind_vel[list(range(0, 1))] + self.num_prof |
|
521 | ind_vel[list(range(0, 1))] = ind_vel[list(range(0, 1))] + self.num_prof | |
522 |
|
522 | |||
523 | if mode == 1: |
|
523 | if mode == 1: | |
524 | jspectra[:, freq_dc, :] = ( |
|
524 | jspectra[:, freq_dc, :] = ( | |
525 | jspectra[:, ind_vel[1], :] + jspectra[:, ind_vel[2], :]) / 2 # CORRECCION |
|
525 | jspectra[:, ind_vel[1], :] + jspectra[:, ind_vel[2], :]) / 2 # CORRECCION | |
526 |
|
526 | |||
527 | if jcspectraExist: |
|
527 | if jcspectraExist: | |
528 | jcspectra[:, freq_dc, :] = ( |
|
528 | jcspectra[:, freq_dc, :] = ( | |
529 | jcspectra[:, ind_vel[1], :] + jcspectra[:, ind_vel[2], :]) / 2 |
|
529 | jcspectra[:, ind_vel[1], :] + jcspectra[:, ind_vel[2], :]) / 2 | |
530 |
|
530 | |||
531 | if mode == 2: |
|
531 | if mode == 2: | |
532 |
|
532 | |||
533 | vel = numpy.array([-2, -1, 1, 2]) |
|
533 | vel = numpy.array([-2, -1, 1, 2]) | |
534 | xx = numpy.zeros([4, 4]) |
|
534 | xx = numpy.zeros([4, 4]) | |
535 |
|
535 | |||
536 | for fil in range(4): |
|
536 | for fil in range(4): | |
537 | xx[fil, :] = vel[fil]**numpy.asarray(list(range(4))) |
|
537 | xx[fil, :] = vel[fil]**numpy.asarray(list(range(4))) | |
538 |
|
538 | |||
539 | xx_inv = numpy.linalg.inv(xx) |
|
539 | xx_inv = numpy.linalg.inv(xx) | |
540 | xx_aux = xx_inv[0, :] |
|
540 | xx_aux = xx_inv[0, :] | |
541 |
|
541 | |||
542 | for ich in range(num_chan): |
|
542 | for ich in range(num_chan): | |
543 | yy = jspectra[ich, ind_vel, :] |
|
543 | yy = jspectra[ich, ind_vel, :] | |
544 | jspectra[ich, freq_dc, :] = numpy.dot(xx_aux, yy) |
|
544 | jspectra[ich, freq_dc, :] = numpy.dot(xx_aux, yy) | |
545 |
|
545 | |||
546 | junkid = jspectra[ich, freq_dc, :] <= 0 |
|
546 | junkid = jspectra[ich, freq_dc, :] <= 0 | |
547 | cjunkid = sum(junkid) |
|
547 | cjunkid = sum(junkid) | |
548 |
|
548 | |||
549 | if cjunkid.any(): |
|
549 | if cjunkid.any(): | |
550 | jspectra[ich, freq_dc, junkid.nonzero()] = ( |
|
550 | jspectra[ich, freq_dc, junkid.nonzero()] = ( | |
551 | jspectra[ich, ind_vel[1], junkid] + jspectra[ich, ind_vel[2], junkid]) / 2 |
|
551 | jspectra[ich, ind_vel[1], junkid] + jspectra[ich, ind_vel[2], junkid]) / 2 | |
552 |
|
552 | |||
553 | if jcspectraExist: |
|
553 | if jcspectraExist: | |
554 | for ip in range(num_pairs): |
|
554 | for ip in range(num_pairs): | |
555 | yy = jcspectra[ip, ind_vel, :] |
|
555 | yy = jcspectra[ip, ind_vel, :] | |
556 | jcspectra[ip, freq_dc, :] = numpy.dot(xx_aux, yy) |
|
556 | jcspectra[ip, freq_dc, :] = numpy.dot(xx_aux, yy) | |
557 |
|
557 | |||
558 | self.dataOut.data_spc = jspectra |
|
558 | self.dataOut.data_spc = jspectra | |
559 | self.dataOut.data_cspc = jcspectra |
|
559 | self.dataOut.data_cspc = jcspectra | |
560 |
|
560 | |||
561 | return self.dataOut |
|
561 | return self.dataOut | |
562 |
|
562 | |||
563 | class removeInterference(Operation): |
|
563 | class removeInterference(Operation): | |
564 |
|
564 | |||
565 | def removeInterference2(self): |
|
565 | def removeInterference2(self): | |
566 |
|
566 | |||
567 | cspc = self.dataOut.data_cspc |
|
567 | cspc = self.dataOut.data_cspc | |
568 | spc = self.dataOut.data_spc |
|
568 | spc = self.dataOut.data_spc | |
569 | Heights = numpy.arange(cspc.shape[2]) |
|
569 | Heights = numpy.arange(cspc.shape[2]) | |
570 | realCspc = numpy.abs(cspc) |
|
570 | realCspc = numpy.abs(cspc) | |
571 |
|
571 | |||
572 | for i in range(cspc.shape[0]): |
|
572 | for i in range(cspc.shape[0]): | |
573 | LinePower= numpy.sum(realCspc[i], axis=0) |
|
573 | LinePower= numpy.sum(realCspc[i], axis=0) | |
574 | Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)] |
|
574 | Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)] | |
575 | SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ] |
|
575 | SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ] | |
576 | InterferenceSum = numpy.sum( realCspc[i,:,SelectedHeights], axis=0 ) |
|
576 | InterferenceSum = numpy.sum( realCspc[i,:,SelectedHeights], axis=0 ) | |
577 | InterferenceThresholdMin = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)] |
|
577 | InterferenceThresholdMin = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)] | |
578 | InterferenceThresholdMax = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.99)] |
|
578 | InterferenceThresholdMax = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.99)] | |
579 |
|
579 | |||
580 |
|
580 | |||
581 | InterferenceRange = numpy.where( ([InterferenceSum > InterferenceThresholdMin]))# , InterferenceSum < InterferenceThresholdMax]) ) |
|
581 | InterferenceRange = numpy.where( ([InterferenceSum > InterferenceThresholdMin]))# , InterferenceSum < InterferenceThresholdMax]) ) | |
582 | #InterferenceRange = numpy.where( ([InterferenceRange < InterferenceThresholdMax])) |
|
582 | #InterferenceRange = numpy.where( ([InterferenceRange < InterferenceThresholdMax])) | |
583 | if len(InterferenceRange)<int(cspc.shape[1]*0.3): |
|
583 | if len(InterferenceRange)<int(cspc.shape[1]*0.3): | |
584 | cspc[i,InterferenceRange,:] = numpy.NaN |
|
584 | cspc[i,InterferenceRange,:] = numpy.NaN | |
585 |
|
585 | |||
586 | self.dataOut.data_cspc = cspc |
|
586 | self.dataOut.data_cspc = cspc | |
587 |
|
587 | |||
588 | def removeInterference(self, interf = 2, hei_interf = None, nhei_interf = None, offhei_interf = None): |
|
588 | def removeInterference(self, interf = 2, hei_interf = None, nhei_interf = None, offhei_interf = None): | |
589 |
|
589 | |||
590 | jspectra = self.dataOut.data_spc |
|
590 | jspectra = self.dataOut.data_spc | |
591 | jcspectra = self.dataOut.data_cspc |
|
591 | jcspectra = self.dataOut.data_cspc | |
592 | jnoise = self.dataOut.getNoise() |
|
592 | jnoise = self.dataOut.getNoise() | |
593 | num_incoh = self.dataOut.nIncohInt |
|
593 | num_incoh = self.dataOut.nIncohInt | |
594 |
|
594 | |||
595 | num_channel = jspectra.shape[0] |
|
595 | num_channel = jspectra.shape[0] | |
596 | num_prof = jspectra.shape[1] |
|
596 | num_prof = jspectra.shape[1] | |
597 | num_hei = jspectra.shape[2] |
|
597 | num_hei = jspectra.shape[2] | |
598 |
|
598 | |||
599 | # hei_interf |
|
599 | # hei_interf | |
600 | if hei_interf is None: |
|
600 | if hei_interf is None: | |
601 | count_hei = int(num_hei / 2) |
|
601 | count_hei = int(num_hei / 2) | |
602 | hei_interf = numpy.asmatrix(list(range(count_hei))) + num_hei - count_hei |
|
602 | hei_interf = numpy.asmatrix(list(range(count_hei))) + num_hei - count_hei | |
603 | hei_interf = numpy.asarray(hei_interf)[0] |
|
603 | hei_interf = numpy.asarray(hei_interf)[0] | |
604 | # nhei_interf |
|
604 | # nhei_interf | |
605 | if (nhei_interf == None): |
|
605 | if (nhei_interf == None): | |
606 | nhei_interf = 5 |
|
606 | nhei_interf = 5 | |
607 | if (nhei_interf < 1): |
|
607 | if (nhei_interf < 1): | |
608 | nhei_interf = 1 |
|
608 | nhei_interf = 1 | |
609 | if (nhei_interf > count_hei): |
|
609 | if (nhei_interf > count_hei): | |
610 | nhei_interf = count_hei |
|
610 | nhei_interf = count_hei | |
611 | if (offhei_interf == None): |
|
611 | if (offhei_interf == None): | |
612 | offhei_interf = 0 |
|
612 | offhei_interf = 0 | |
613 |
|
613 | |||
614 | ind_hei = list(range(num_hei)) |
|
614 | ind_hei = list(range(num_hei)) | |
615 | # mask_prof = numpy.asarray(range(num_prof - 2)) + 1 |
|
615 | # mask_prof = numpy.asarray(range(num_prof - 2)) + 1 | |
616 | # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1 |
|
616 | # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1 | |
617 | mask_prof = numpy.asarray(list(range(num_prof))) |
|
617 | mask_prof = numpy.asarray(list(range(num_prof))) | |
618 | num_mask_prof = mask_prof.size |
|
618 | num_mask_prof = mask_prof.size | |
619 | comp_mask_prof = [0, num_prof / 2] |
|
619 | comp_mask_prof = [0, num_prof / 2] | |
620 |
|
620 | |||
621 | # noise_exist: Determina si la variable jnoise ha sido definida y contiene la informacion del ruido de cada canal |
|
621 | # noise_exist: Determina si la variable jnoise ha sido definida y contiene la informacion del ruido de cada canal | |
622 | if (jnoise.size < num_channel or numpy.isnan(jnoise).any()): |
|
622 | if (jnoise.size < num_channel or numpy.isnan(jnoise).any()): | |
623 | jnoise = numpy.nan |
|
623 | jnoise = numpy.nan | |
624 | noise_exist = jnoise[0] < numpy.Inf |
|
624 | noise_exist = jnoise[0] < numpy.Inf | |
625 |
|
625 | |||
626 | # Subrutina de Remocion de la Interferencia |
|
626 | # Subrutina de Remocion de la Interferencia | |
627 | for ich in range(num_channel): |
|
627 | for ich in range(num_channel): | |
628 | # Se ordena los espectros segun su potencia (menor a mayor) |
|
628 | # Se ordena los espectros segun su potencia (menor a mayor) | |
629 | power = jspectra[ich, mask_prof, :] |
|
629 | power = jspectra[ich, mask_prof, :] | |
630 | power = power[:, hei_interf] |
|
630 | power = power[:, hei_interf] | |
631 | power = power.sum(axis=0) |
|
631 | power = power.sum(axis=0) | |
632 | psort = power.ravel().argsort() |
|
632 | psort = power.ravel().argsort() | |
633 |
|
633 | |||
634 | # Se estima la interferencia promedio en los Espectros de Potencia empleando |
|
634 | # Se estima la interferencia promedio en los Espectros de Potencia empleando | |
635 | junkspc_interf = jspectra[ich, :, hei_interf[psort[list(range( |
|
635 | junkspc_interf = jspectra[ich, :, hei_interf[psort[list(range( | |
636 | offhei_interf, nhei_interf + offhei_interf))]]] |
|
636 | offhei_interf, nhei_interf + offhei_interf))]]] | |
637 |
|
637 | |||
638 | if noise_exist: |
|
638 | if noise_exist: | |
639 | # tmp_noise = jnoise[ich] / num_prof |
|
639 | # tmp_noise = jnoise[ich] / num_prof | |
640 | tmp_noise = jnoise[ich] |
|
640 | tmp_noise = jnoise[ich] | |
641 | junkspc_interf = junkspc_interf - tmp_noise |
|
641 | junkspc_interf = junkspc_interf - tmp_noise | |
642 | #junkspc_interf[:,comp_mask_prof] = 0 |
|
642 | #junkspc_interf[:,comp_mask_prof] = 0 | |
643 |
|
643 | |||
644 | jspc_interf = junkspc_interf.sum(axis=0) / nhei_interf |
|
644 | jspc_interf = junkspc_interf.sum(axis=0) / nhei_interf | |
645 | jspc_interf = jspc_interf.transpose() |
|
645 | jspc_interf = jspc_interf.transpose() | |
646 | # Calculando el espectro de interferencia promedio |
|
646 | # Calculando el espectro de interferencia promedio | |
647 | noiseid = numpy.where( |
|
647 | noiseid = numpy.where( | |
648 | jspc_interf <= tmp_noise / numpy.sqrt(num_incoh)) |
|
648 | jspc_interf <= tmp_noise / numpy.sqrt(num_incoh)) | |
649 | noiseid = noiseid[0] |
|
649 | noiseid = noiseid[0] | |
650 | cnoiseid = noiseid.size |
|
650 | cnoiseid = noiseid.size | |
651 | interfid = numpy.where( |
|
651 | interfid = numpy.where( | |
652 | jspc_interf > tmp_noise / numpy.sqrt(num_incoh)) |
|
652 | jspc_interf > tmp_noise / numpy.sqrt(num_incoh)) | |
653 | interfid = interfid[0] |
|
653 | interfid = interfid[0] | |
654 | cinterfid = interfid.size |
|
654 | cinterfid = interfid.size | |
655 |
|
655 | |||
656 | if (cnoiseid > 0): |
|
656 | if (cnoiseid > 0): | |
657 | jspc_interf[noiseid] = 0 |
|
657 | jspc_interf[noiseid] = 0 | |
658 |
|
658 | |||
659 | # Expandiendo los perfiles a limpiar |
|
659 | # Expandiendo los perfiles a limpiar | |
660 | if (cinterfid > 0): |
|
660 | if (cinterfid > 0): | |
661 | new_interfid = ( |
|
661 | new_interfid = ( | |
662 | numpy.r_[interfid - 1, interfid, interfid + 1] + num_prof) % num_prof |
|
662 | numpy.r_[interfid - 1, interfid, interfid + 1] + num_prof) % num_prof | |
663 | new_interfid = numpy.asarray(new_interfid) |
|
663 | new_interfid = numpy.asarray(new_interfid) | |
664 | new_interfid = {x for x in new_interfid} |
|
664 | new_interfid = {x for x in new_interfid} | |
665 | new_interfid = numpy.array(list(new_interfid)) |
|
665 | new_interfid = numpy.array(list(new_interfid)) | |
666 | new_cinterfid = new_interfid.size |
|
666 | new_cinterfid = new_interfid.size | |
667 | else: |
|
667 | else: | |
668 | new_cinterfid = 0 |
|
668 | new_cinterfid = 0 | |
669 |
|
669 | |||
670 | for ip in range(new_cinterfid): |
|
670 | for ip in range(new_cinterfid): | |
671 | ind = junkspc_interf[:, new_interfid[ip]].ravel().argsort() |
|
671 | ind = junkspc_interf[:, new_interfid[ip]].ravel().argsort() | |
672 | jspc_interf[new_interfid[ip] |
|
672 | jspc_interf[new_interfid[ip] | |
673 | ] = junkspc_interf[ind[nhei_interf // 2], new_interfid[ip]] |
|
673 | ] = junkspc_interf[ind[nhei_interf // 2], new_interfid[ip]] | |
674 |
|
674 | |||
675 | jspectra[ich, :, ind_hei] = jspectra[ich, :, |
|
675 | jspectra[ich, :, ind_hei] = jspectra[ich, :, | |
676 | ind_hei] - jspc_interf # Corregir indices |
|
676 | ind_hei] - jspc_interf # Corregir indices | |
677 |
|
677 | |||
678 | # Removiendo la interferencia del punto de mayor interferencia |
|
678 | # Removiendo la interferencia del punto de mayor interferencia | |
679 | ListAux = jspc_interf[mask_prof].tolist() |
|
679 | ListAux = jspc_interf[mask_prof].tolist() | |
680 | maxid = ListAux.index(max(ListAux)) |
|
680 | maxid = ListAux.index(max(ListAux)) | |
681 |
|
681 | |||
682 | if cinterfid > 0: |
|
682 | if cinterfid > 0: | |
683 | for ip in range(cinterfid * (interf == 2) - 1): |
|
683 | for ip in range(cinterfid * (interf == 2) - 1): | |
684 | ind = (jspectra[ich, interfid[ip], :] < tmp_noise * |
|
684 | ind = (jspectra[ich, interfid[ip], :] < tmp_noise * | |
685 | (1 + 1 / numpy.sqrt(num_incoh))).nonzero() |
|
685 | (1 + 1 / numpy.sqrt(num_incoh))).nonzero() | |
686 | cind = len(ind) |
|
686 | cind = len(ind) | |
687 |
|
687 | |||
688 | if (cind > 0): |
|
688 | if (cind > 0): | |
689 | jspectra[ich, interfid[ip], ind] = tmp_noise * \ |
|
689 | jspectra[ich, interfid[ip], ind] = tmp_noise * \ | |
690 | (1 + (numpy.random.uniform(cind) - 0.5) / |
|
690 | (1 + (numpy.random.uniform(cind) - 0.5) / | |
691 | numpy.sqrt(num_incoh)) |
|
691 | numpy.sqrt(num_incoh)) | |
692 |
|
692 | |||
693 | ind = numpy.array([-2, -1, 1, 2]) |
|
693 | ind = numpy.array([-2, -1, 1, 2]) | |
694 | xx = numpy.zeros([4, 4]) |
|
694 | xx = numpy.zeros([4, 4]) | |
695 |
|
695 | |||
696 | for id1 in range(4): |
|
696 | for id1 in range(4): | |
697 | xx[:, id1] = ind[id1]**numpy.asarray(list(range(4))) |
|
697 | xx[:, id1] = ind[id1]**numpy.asarray(list(range(4))) | |
698 |
|
698 | |||
699 | xx_inv = numpy.linalg.inv(xx) |
|
699 | xx_inv = numpy.linalg.inv(xx) | |
700 | xx = xx_inv[:, 0] |
|
700 | xx = xx_inv[:, 0] | |
701 | ind = (ind + maxid + num_mask_prof) % num_mask_prof |
|
701 | ind = (ind + maxid + num_mask_prof) % num_mask_prof | |
702 | yy = jspectra[ich, mask_prof[ind], :] |
|
702 | yy = jspectra[ich, mask_prof[ind], :] | |
703 | jspectra[ich, mask_prof[maxid], :] = numpy.dot( |
|
703 | jspectra[ich, mask_prof[maxid], :] = numpy.dot( | |
704 | yy.transpose(), xx) |
|
704 | yy.transpose(), xx) | |
705 |
|
705 | |||
706 | indAux = (jspectra[ich, :, :] < tmp_noise * |
|
706 | indAux = (jspectra[ich, :, :] < tmp_noise * | |
707 | (1 - 1 / numpy.sqrt(num_incoh))).nonzero() |
|
707 | (1 - 1 / numpy.sqrt(num_incoh))).nonzero() | |
708 | jspectra[ich, indAux[0], indAux[1]] = tmp_noise * \ |
|
708 | jspectra[ich, indAux[0], indAux[1]] = tmp_noise * \ | |
709 | (1 - 1 / numpy.sqrt(num_incoh)) |
|
709 | (1 - 1 / numpy.sqrt(num_incoh)) | |
710 |
|
710 | |||
711 | # Remocion de Interferencia en el Cross Spectra |
|
711 | # Remocion de Interferencia en el Cross Spectra | |
712 | if jcspectra is None: |
|
712 | if jcspectra is None: | |
713 | return jspectra, jcspectra |
|
713 | return jspectra, jcspectra | |
714 | num_pairs = int(jcspectra.size / (num_prof * num_hei)) |
|
714 | num_pairs = int(jcspectra.size / (num_prof * num_hei)) | |
715 | jcspectra = jcspectra.reshape(num_pairs, num_prof, num_hei) |
|
715 | jcspectra = jcspectra.reshape(num_pairs, num_prof, num_hei) | |
716 |
|
716 | |||
717 | for ip in range(num_pairs): |
|
717 | for ip in range(num_pairs): | |
718 |
|
718 | |||
719 | #------------------------------------------- |
|
719 | #------------------------------------------- | |
720 |
|
720 | |||
721 | cspower = numpy.abs(jcspectra[ip, mask_prof, :]) |
|
721 | cspower = numpy.abs(jcspectra[ip, mask_prof, :]) | |
722 | cspower = cspower[:, hei_interf] |
|
722 | cspower = cspower[:, hei_interf] | |
723 | cspower = cspower.sum(axis=0) |
|
723 | cspower = cspower.sum(axis=0) | |
724 |
|
724 | |||
725 | cspsort = cspower.ravel().argsort() |
|
725 | cspsort = cspower.ravel().argsort() | |
726 | junkcspc_interf = jcspectra[ip, :, hei_interf[cspsort[list(range( |
|
726 | junkcspc_interf = jcspectra[ip, :, hei_interf[cspsort[list(range( | |
727 | offhei_interf, nhei_interf + offhei_interf))]]] |
|
727 | offhei_interf, nhei_interf + offhei_interf))]]] | |
728 | junkcspc_interf = junkcspc_interf.transpose() |
|
728 | junkcspc_interf = junkcspc_interf.transpose() | |
729 | jcspc_interf = junkcspc_interf.sum(axis=1) / nhei_interf |
|
729 | jcspc_interf = junkcspc_interf.sum(axis=1) / nhei_interf | |
730 |
|
730 | |||
731 | ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort() |
|
731 | ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort() | |
732 |
|
732 | |||
733 | median_real = int(numpy.median(numpy.real( |
|
733 | median_real = int(numpy.median(numpy.real( | |
734 | junkcspc_interf[mask_prof[ind[list(range(3 * num_prof // 4))]], :]))) |
|
734 | junkcspc_interf[mask_prof[ind[list(range(3 * num_prof // 4))]], :]))) | |
735 | median_imag = int(numpy.median(numpy.imag( |
|
735 | median_imag = int(numpy.median(numpy.imag( | |
736 | junkcspc_interf[mask_prof[ind[list(range(3 * num_prof // 4))]], :]))) |
|
736 | junkcspc_interf[mask_prof[ind[list(range(3 * num_prof // 4))]], :]))) | |
737 | comp_mask_prof = [int(e) for e in comp_mask_prof] |
|
737 | comp_mask_prof = [int(e) for e in comp_mask_prof] | |
738 | junkcspc_interf[comp_mask_prof, :] = numpy.complex( |
|
738 | junkcspc_interf[comp_mask_prof, :] = numpy.complex( | |
739 | median_real, median_imag) |
|
739 | median_real, median_imag) | |
740 |
|
740 | |||
741 | for iprof in range(num_prof): |
|
741 | for iprof in range(num_prof): | |
742 | ind = numpy.abs(junkcspc_interf[iprof, :]).ravel().argsort() |
|
742 | ind = numpy.abs(junkcspc_interf[iprof, :]).ravel().argsort() | |
743 | jcspc_interf[iprof] = junkcspc_interf[iprof, ind[nhei_interf // 2]] |
|
743 | jcspc_interf[iprof] = junkcspc_interf[iprof, ind[nhei_interf // 2]] | |
744 |
|
744 | |||
745 | # Removiendo la Interferencia |
|
745 | # Removiendo la Interferencia | |
746 | jcspectra[ip, :, ind_hei] = jcspectra[ip, |
|
746 | jcspectra[ip, :, ind_hei] = jcspectra[ip, | |
747 | :, ind_hei] - jcspc_interf |
|
747 | :, ind_hei] - jcspc_interf | |
748 |
|
748 | |||
749 | ListAux = numpy.abs(jcspc_interf[mask_prof]).tolist() |
|
749 | ListAux = numpy.abs(jcspc_interf[mask_prof]).tolist() | |
750 | maxid = ListAux.index(max(ListAux)) |
|
750 | maxid = ListAux.index(max(ListAux)) | |
751 |
|
751 | |||
752 | ind = numpy.array([-2, -1, 1, 2]) |
|
752 | ind = numpy.array([-2, -1, 1, 2]) | |
753 | xx = numpy.zeros([4, 4]) |
|
753 | xx = numpy.zeros([4, 4]) | |
754 |
|
754 | |||
755 | for id1 in range(4): |
|
755 | for id1 in range(4): | |
756 | xx[:, id1] = ind[id1]**numpy.asarray(list(range(4))) |
|
756 | xx[:, id1] = ind[id1]**numpy.asarray(list(range(4))) | |
757 |
|
757 | |||
758 | xx_inv = numpy.linalg.inv(xx) |
|
758 | xx_inv = numpy.linalg.inv(xx) | |
759 | xx = xx_inv[:, 0] |
|
759 | xx = xx_inv[:, 0] | |
760 |
|
760 | |||
761 | ind = (ind + maxid + num_mask_prof) % num_mask_prof |
|
761 | ind = (ind + maxid + num_mask_prof) % num_mask_prof | |
762 | yy = jcspectra[ip, mask_prof[ind], :] |
|
762 | yy = jcspectra[ip, mask_prof[ind], :] | |
763 | jcspectra[ip, mask_prof[maxid], :] = numpy.dot(yy.transpose(), xx) |
|
763 | jcspectra[ip, mask_prof[maxid], :] = numpy.dot(yy.transpose(), xx) | |
764 |
|
764 | |||
765 | # Guardar Resultados |
|
765 | # Guardar Resultados | |
766 | self.dataOut.data_spc = jspectra |
|
766 | self.dataOut.data_spc = jspectra | |
767 | self.dataOut.data_cspc = jcspectra |
|
767 | self.dataOut.data_cspc = jcspectra | |
768 |
|
768 | |||
769 | return 1 |
|
769 | return 1 | |
770 |
|
770 | |||
771 | def run(self, dataOut, interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None, mode=1): |
|
771 | def run(self, dataOut, interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None, mode=1): | |
772 |
|
772 | |||
773 | self.dataOut = dataOut |
|
773 | self.dataOut = dataOut | |
774 |
|
774 | |||
775 | if mode == 1: |
|
775 | if mode == 1: | |
776 | self.removeInterference(interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None) |
|
776 | self.removeInterference(interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None) | |
777 | elif mode == 2: |
|
777 | elif mode == 2: | |
778 | self.removeInterference2() |
|
778 | self.removeInterference2() | |
779 |
|
779 | |||
780 | return self.dataOut |
|
780 | return self.dataOut | |
781 |
|
781 | |||
|
782 | class removeInterferenceAtFreq(Operation): | |||
|
783 | ''' | |||
|
784 | Written by R. Flores | |||
|
785 | ''' | |||
|
786 | """Operation to remove interfernce at a known frequency(s). | |||
|
787 | ||||
|
788 | Parameters: | |||
|
789 | ----------- | |||
|
790 | None | |||
|
791 | ||||
|
792 | Example | |||
|
793 | -------- | |||
|
794 | ||||
|
795 | op = proc_unit.addOperation(name='removeInterferenceAtFreq') | |||
|
796 | ||||
|
797 | """ | |||
|
798 | ||||
|
799 | def __init__(self): | |||
|
800 | ||||
|
801 | Operation.__init__(self) | |||
|
802 | ||||
|
803 | def run(self, dataOut, freq = None, freqList = None): | |||
|
804 | ||||
|
805 | VelRange = dataOut.getVelRange() | |||
|
806 | #print("VelRange: ", VelRange) | |||
|
807 | ||||
|
808 | freq_ids = [] | |||
|
809 | ||||
|
810 | if freq is not None: | |||
|
811 | #print("freq") | |||
|
812 | #if freq < 0: | |||
|
813 | inda = numpy.where(VelRange >= freq) | |||
|
814 | minIndex = inda[0][0] | |||
|
815 | #print(numpy.shape(dataOut.dataLag_spc)) | |||
|
816 | dataOut.data_spc[:,minIndex,:] = numpy.nan | |||
|
817 | ||||
|
818 | #inda = numpy.where(VelRange >= ymin_noise) | |||
|
819 | #indb = numpy.where(VelRange <= ymax_noise) | |||
|
820 | ||||
|
821 | #minIndex = inda[0][0] | |||
|
822 | #maxIndex = indb[0][-1] | |||
|
823 | ||||
|
824 | elif freqList is not None: | |||
|
825 | #print("freqList") | |||
|
826 | for freq in freqList: | |||
|
827 | #if freq < 0: | |||
|
828 | inda = numpy.where(VelRange >= freq) | |||
|
829 | minIndex = inda[0][0] | |||
|
830 | #print(numpy.shape(dataOut.dataLag_spc)) | |||
|
831 | if freq > 0: | |||
|
832 | #dataOut.data_spc[:,minIndex-1,:] = numpy.nan | |||
|
833 | freq_ids.append(minIndex-1) | |||
|
834 | else: | |||
|
835 | #dataOut.data_spc[:,minIndex,:] = numpy.nan | |||
|
836 | freq_ids.append(minIndex) | |||
|
837 | else: | |||
|
838 | raise ValueError("freq or freqList should be specified ...") | |||
|
839 | ||||
|
840 | #freq_ids = numpy.array(freq_ids).flatten() | |||
|
841 | ||||
|
842 | avg = numpy.mean(dataOut.data_spc[:,[t for t in range(dataOut.data_spc.shape[0]) if t not in freq_ids],:],axis=1) | |||
|
843 | ||||
|
844 | for p in list(freq_ids): | |||
|
845 | dataOut.data_spc[:,p,:] = avg#numpy.nan | |||
|
846 | ||||
|
847 | ||||
|
848 | return dataOut | |||
782 |
|
849 | |||
783 | class IncohInt(Operation): |
|
850 | class IncohInt(Operation): | |
784 |
|
851 | |||
785 | __profIndex = 0 |
|
852 | __profIndex = 0 | |
786 | __withOverapping = False |
|
853 | __withOverapping = False | |
787 |
|
854 | |||
788 | __byTime = False |
|
855 | __byTime = False | |
789 | __initime = None |
|
856 | __initime = None | |
790 | __lastdatatime = None |
|
857 | __lastdatatime = None | |
791 | __integrationtime = None |
|
858 | __integrationtime = None | |
792 |
|
859 | |||
793 | __buffer_spc = None |
|
860 | __buffer_spc = None | |
794 | __buffer_cspc = None |
|
861 | __buffer_cspc = None | |
795 | __buffer_dc = None |
|
862 | __buffer_dc = None | |
796 |
|
863 | |||
797 | __dataReady = False |
|
864 | __dataReady = False | |
798 |
|
865 | |||
799 | __timeInterval = None |
|
866 | __timeInterval = None | |
800 |
|
867 | |||
801 | n = None |
|
868 | n = None | |
802 |
|
869 | |||
803 | def __init__(self): |
|
870 | def __init__(self): | |
804 |
|
871 | |||
805 | Operation.__init__(self) |
|
872 | Operation.__init__(self) | |
806 |
|
873 | |||
807 | def setup(self, n=None, timeInterval=None, overlapping=False): |
|
874 | def setup(self, n=None, timeInterval=None, overlapping=False): | |
808 | """ |
|
875 | """ | |
809 | Set the parameters of the integration class. |
|
876 | Set the parameters of the integration class. | |
810 |
|
877 | |||
811 | Inputs: |
|
878 | Inputs: | |
812 |
|
879 | |||
813 | n : Number of coherent integrations |
|
880 | n : Number of coherent integrations | |
814 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work |
|
881 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
815 | overlapping : |
|
882 | overlapping : | |
816 |
|
883 | |||
817 | """ |
|
884 | """ | |
818 |
|
885 | |||
819 | self.__initime = None |
|
886 | self.__initime = None | |
820 | self.__lastdatatime = 0 |
|
887 | self.__lastdatatime = 0 | |
821 |
|
888 | |||
822 | self.__buffer_spc = 0 |
|
889 | self.__buffer_spc = 0 | |
823 | self.__buffer_cspc = 0 |
|
890 | self.__buffer_cspc = 0 | |
824 | self.__buffer_dc = 0 |
|
891 | self.__buffer_dc = 0 | |
825 |
|
892 | |||
826 | self.__profIndex = 0 |
|
893 | self.__profIndex = 0 | |
827 | self.__dataReady = False |
|
894 | self.__dataReady = False | |
828 | self.__byTime = False |
|
895 | self.__byTime = False | |
829 |
|
896 | |||
830 | if n is None and timeInterval is None: |
|
897 | if n is None and timeInterval is None: | |
831 | raise ValueError("n or timeInterval should be specified ...") |
|
898 | raise ValueError("n or timeInterval should be specified ...") | |
832 |
|
899 | |||
833 | if n is not None: |
|
900 | if n is not None: | |
834 | self.n = int(n) |
|
901 | self.n = int(n) | |
835 | else: |
|
902 | else: | |
836 |
|
903 | |||
837 | self.__integrationtime = int(timeInterval) |
|
904 | self.__integrationtime = int(timeInterval) | |
838 | self.n = None |
|
905 | self.n = None | |
839 | self.__byTime = True |
|
906 | self.__byTime = True | |
840 |
|
907 | |||
841 | def putData(self, data_spc, data_cspc, data_dc): |
|
908 | def putData(self, data_spc, data_cspc, data_dc): | |
842 | """ |
|
909 | """ | |
843 | Add a profile to the __buffer_spc and increase in one the __profileIndex |
|
910 | Add a profile to the __buffer_spc and increase in one the __profileIndex | |
844 |
|
911 | |||
845 | """ |
|
912 | """ | |
846 |
|
913 | |||
847 | self.__buffer_spc += data_spc |
|
914 | self.__buffer_spc += data_spc | |
848 |
|
915 | |||
849 | if data_cspc is None: |
|
916 | if data_cspc is None: | |
850 | self.__buffer_cspc = None |
|
917 | self.__buffer_cspc = None | |
851 | else: |
|
918 | else: | |
852 | self.__buffer_cspc += data_cspc |
|
919 | self.__buffer_cspc += data_cspc | |
853 |
|
920 | |||
854 | if data_dc is None: |
|
921 | if data_dc is None: | |
855 | self.__buffer_dc = None |
|
922 | self.__buffer_dc = None | |
856 | else: |
|
923 | else: | |
857 | self.__buffer_dc += data_dc |
|
924 | self.__buffer_dc += data_dc | |
858 |
|
925 | |||
859 | self.__profIndex += 1 |
|
926 | self.__profIndex += 1 | |
860 |
|
927 | |||
861 | return |
|
928 | return | |
862 |
|
929 | |||
863 | def pushData(self): |
|
930 | def pushData(self): | |
864 | """ |
|
931 | """ | |
865 | Return the sum of the last profiles and the profiles used in the sum. |
|
932 | Return the sum of the last profiles and the profiles used in the sum. | |
866 |
|
933 | |||
867 | Affected: |
|
934 | Affected: | |
868 |
|
935 | |||
869 | self.__profileIndex |
|
936 | self.__profileIndex | |
870 |
|
937 | |||
871 | """ |
|
938 | """ | |
872 |
|
939 | |||
873 | data_spc = self.__buffer_spc |
|
940 | data_spc = self.__buffer_spc | |
874 | data_cspc = self.__buffer_cspc |
|
941 | data_cspc = self.__buffer_cspc | |
875 | data_dc = self.__buffer_dc |
|
942 | data_dc = self.__buffer_dc | |
876 | n = self.__profIndex |
|
943 | n = self.__profIndex | |
877 |
|
944 | |||
878 | self.__buffer_spc = 0 |
|
945 | self.__buffer_spc = 0 | |
879 | self.__buffer_cspc = 0 |
|
946 | self.__buffer_cspc = 0 | |
880 | self.__buffer_dc = 0 |
|
947 | self.__buffer_dc = 0 | |
881 | self.__profIndex = 0 |
|
948 | self.__profIndex = 0 | |
882 |
|
949 | |||
883 | return data_spc, data_cspc, data_dc, n |
|
950 | return data_spc, data_cspc, data_dc, n | |
884 |
|
951 | |||
885 | def byProfiles(self, *args): |
|
952 | def byProfiles(self, *args): | |
886 |
|
953 | |||
887 | self.__dataReady = False |
|
954 | self.__dataReady = False | |
888 | avgdata_spc = None |
|
955 | avgdata_spc = None | |
889 | avgdata_cspc = None |
|
956 | avgdata_cspc = None | |
890 | avgdata_dc = None |
|
957 | avgdata_dc = None | |
891 |
|
958 | |||
892 | self.putData(*args) |
|
959 | self.putData(*args) | |
893 |
|
960 | |||
894 | if self.__profIndex == self.n: |
|
961 | if self.__profIndex == self.n: | |
895 |
|
962 | |||
896 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() |
|
963 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() | |
897 | self.n = n |
|
964 | self.n = n | |
898 | self.__dataReady = True |
|
965 | self.__dataReady = True | |
899 |
|
966 | |||
900 | return avgdata_spc, avgdata_cspc, avgdata_dc |
|
967 | return avgdata_spc, avgdata_cspc, avgdata_dc | |
901 |
|
968 | |||
902 | def byTime(self, datatime, *args): |
|
969 | def byTime(self, datatime, *args): | |
903 |
|
970 | |||
904 | self.__dataReady = False |
|
971 | self.__dataReady = False | |
905 | avgdata_spc = None |
|
972 | avgdata_spc = None | |
906 | avgdata_cspc = None |
|
973 | avgdata_cspc = None | |
907 | avgdata_dc = None |
|
974 | avgdata_dc = None | |
908 |
|
975 | |||
909 | self.putData(*args) |
|
976 | self.putData(*args) | |
910 |
|
977 | |||
911 | if (datatime - self.__initime) >= self.__integrationtime: |
|
978 | if (datatime - self.__initime) >= self.__integrationtime: | |
912 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() |
|
979 | avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData() | |
913 | self.n = n |
|
980 | self.n = n | |
914 | self.__dataReady = True |
|
981 | self.__dataReady = True | |
915 |
|
982 | |||
916 | return avgdata_spc, avgdata_cspc, avgdata_dc |
|
983 | return avgdata_spc, avgdata_cspc, avgdata_dc | |
917 |
|
984 | |||
918 | def integrate(self, datatime, *args): |
|
985 | def integrate(self, datatime, *args): | |
919 |
|
986 | |||
920 | if self.__profIndex == 0: |
|
987 | if self.__profIndex == 0: | |
921 | self.__initime = datatime |
|
988 | self.__initime = datatime | |
922 |
|
989 | |||
923 | if self.__byTime: |
|
990 | if self.__byTime: | |
924 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byTime( |
|
991 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byTime( | |
925 | datatime, *args) |
|
992 | datatime, *args) | |
926 | else: |
|
993 | else: | |
927 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args) |
|
994 | avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args) | |
928 |
|
995 | |||
929 | if not self.__dataReady: |
|
996 | if not self.__dataReady: | |
930 | return None, None, None, None |
|
997 | return None, None, None, None | |
931 |
|
998 | |||
932 | return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc |
|
999 | return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc | |
933 |
|
1000 | |||
934 | def run(self, dataOut, n=None, timeInterval=None, overlapping=False): |
|
1001 | def run(self, dataOut, n=None, timeInterval=None, overlapping=False): | |
935 | if n == 1: |
|
1002 | if n == 1: | |
936 | return dataOut |
|
1003 | return dataOut | |
937 | print("JERE") |
|
1004 | print("JERE") | |
938 | dataOut.flagNoData = True |
|
1005 | dataOut.flagNoData = True | |
939 |
|
1006 | |||
940 | if not self.isConfig: |
|
1007 | if not self.isConfig: | |
941 | self.setup(n, timeInterval, overlapping) |
|
1008 | self.setup(n, timeInterval, overlapping) | |
942 | self.isConfig = True |
|
1009 | self.isConfig = True | |
943 |
|
1010 | |||
944 | avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime, |
|
1011 | avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime, | |
945 | dataOut.data_spc, |
|
1012 | dataOut.data_spc, | |
946 | dataOut.data_cspc, |
|
1013 | dataOut.data_cspc, | |
947 | dataOut.data_dc) |
|
1014 | dataOut.data_dc) | |
948 |
|
1015 | |||
949 | if self.__dataReady: |
|
1016 | if self.__dataReady: | |
950 |
|
1017 | |||
951 | dataOut.data_spc = avgdata_spc |
|
1018 | dataOut.data_spc = avgdata_spc | |
952 | print(numpy.sum(dataOut.data_spc)) |
|
1019 | print(numpy.sum(dataOut.data_spc)) | |
953 | exit(1) |
|
1020 | exit(1) | |
954 | dataOut.data_cspc = avgdata_cspc |
|
1021 | dataOut.data_cspc = avgdata_cspc | |
955 | dataOut.data_dc = avgdata_dc |
|
1022 | dataOut.data_dc = avgdata_dc | |
956 | dataOut.nIncohInt *= self.n |
|
1023 | dataOut.nIncohInt *= self.n | |
957 | dataOut.utctime = avgdatatime |
|
1024 | dataOut.utctime = avgdatatime | |
958 | dataOut.flagNoData = False |
|
1025 | dataOut.flagNoData = False | |
959 |
|
1026 | |||
960 | return dataOut |
|
1027 | return dataOut | |
961 |
|
1028 | |||
962 | class dopplerFlip(Operation): |
|
1029 | class dopplerFlip(Operation): | |
963 |
|
1030 | |||
964 | def run(self, dataOut, chann = None): |
|
1031 | def run(self, dataOut, chann = None): | |
965 | # arreglo 1: (num_chan, num_profiles, num_heights) |
|
1032 | # arreglo 1: (num_chan, num_profiles, num_heights) | |
966 | self.dataOut = dataOut |
|
1033 | self.dataOut = dataOut | |
967 | # JULIA-oblicua, indice 2 |
|
1034 | # JULIA-oblicua, indice 2 | |
968 | # arreglo 2: (num_profiles, num_heights) |
|
1035 | # arreglo 2: (num_profiles, num_heights) | |
969 | jspectra = self.dataOut.data_spc[chann] |
|
1036 | jspectra = self.dataOut.data_spc[chann] | |
970 | jspectra_tmp = numpy.zeros(jspectra.shape) |
|
1037 | jspectra_tmp = numpy.zeros(jspectra.shape) | |
971 | num_profiles = jspectra.shape[0] |
|
1038 | num_profiles = jspectra.shape[0] | |
972 | freq_dc = int(num_profiles / 2) |
|
1039 | freq_dc = int(num_profiles / 2) | |
973 | # Flip con for |
|
1040 | # Flip con for | |
974 | for j in range(num_profiles): |
|
1041 | for j in range(num_profiles): | |
975 | jspectra_tmp[num_profiles-j-1]= jspectra[j] |
|
1042 | jspectra_tmp[num_profiles-j-1]= jspectra[j] | |
976 | # Intercambio perfil de DC con perfil inmediato anterior |
|
1043 | # Intercambio perfil de DC con perfil inmediato anterior | |
977 | jspectra_tmp[freq_dc-1]= jspectra[freq_dc-1] |
|
1044 | jspectra_tmp[freq_dc-1]= jspectra[freq_dc-1] | |
978 | jspectra_tmp[freq_dc]= jspectra[freq_dc] |
|
1045 | jspectra_tmp[freq_dc]= jspectra[freq_dc] | |
979 | # canal modificado es re-escrito en el arreglo de canales |
|
1046 | # canal modificado es re-escrito en el arreglo de canales | |
980 | self.dataOut.data_spc[chann] = jspectra_tmp |
|
1047 | self.dataOut.data_spc[chann] = jspectra_tmp | |
981 |
|
1048 | |||
982 | return self.dataOut |
|
1049 | return self.dataOut |
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