##// END OF EJS Templates
Actualizacion de SNR como parte de data_param
Danny Scipión -
r1357:4fd53dc3a7e2
parent child
Show More
@@ -1,402 +1,413
1 '''
1 '''
2 Created on Oct 24, 2016
2 Created on Oct 24, 2016
3
3
4 @author: roj- LouVD
4 @author: roj- LouVD
5 '''
5 '''
6
6
7 import numpy
7 import numpy
8 import copy
8 import copy
9 import datetime
9 import datetime
10 import time
10 import time
11 from time import gmtime
11 from time import gmtime
12
12
13 from numpy import transpose
13 from numpy import transpose
14
14
15 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator
15 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator
16 from schainpy.model.data.jrodata import Parameters
16 from schainpy.model.data.jrodata import Parameters
17
17
18
18
19 class BLTRParametersProc(ProcessingUnit):
19 class BLTRParametersProc(ProcessingUnit):
20 '''
20 '''
21 Processing unit for BLTR parameters data (winds)
21 Processing unit for BLTR parameters data (winds)
22
22
23 Inputs:
23 Inputs:
24 self.dataOut.nmodes - Number of operation modes
24 self.dataOut.nmodes - Number of operation modes
25 self.dataOut.nchannels - Number of channels
25 self.dataOut.nchannels - Number of channels
26 self.dataOut.nranges - Number of ranges
26 self.dataOut.nranges - Number of ranges
27
27
28 self.dataOut.data_snr - SNR array
28 self.dataOut.data_snr - SNR array
29 self.dataOut.data_output - Zonal, Vertical and Meridional velocity array
29 self.dataOut.data_output - Zonal, Vertical and Meridional velocity array
30 self.dataOut.height - Height array (km)
30 self.dataOut.height - Height array (km)
31 self.dataOut.time - Time array (seconds)
31 self.dataOut.time - Time array (seconds)
32
32
33 self.dataOut.fileIndex -Index of the file currently read
33 self.dataOut.fileIndex -Index of the file currently read
34 self.dataOut.lat - Latitude coordinate of BLTR location
34 self.dataOut.lat - Latitude coordinate of BLTR location
35
35
36 self.dataOut.doy - Experiment doy (number of the day in the current year)
36 self.dataOut.doy - Experiment doy (number of the day in the current year)
37 self.dataOut.month - Experiment month
37 self.dataOut.month - Experiment month
38 self.dataOut.day - Experiment day
38 self.dataOut.day - Experiment day
39 self.dataOut.year - Experiment year
39 self.dataOut.year - Experiment year
40 '''
40 '''
41
41
42 def __init__(self):
42 def __init__(self):
43 '''
43 '''
44 Inputs: None
44 Inputs: None
45 '''
45 '''
46 ProcessingUnit.__init__(self)
46 ProcessingUnit.__init__(self)
47 self.dataOut = Parameters()
47 self.dataOut = Parameters()
48
48
49 def setup(self, mode):
49 def setup(self, mode):
50 '''
50 '''
51 '''
51 '''
52 self.dataOut.mode = mode
52 self.dataOut.mode = mode
53
53
54 def run(self, mode, snr_threshold=None):
54 def run(self, mode, snr_threshold=None):
55 '''
55 '''
56 Inputs:
56 Inputs:
57 mode = High resolution (0) or Low resolution (1) data
57 mode = High resolution (0) or Low resolution (1) data
58 snr_threshold = snr filter value
58 snr_threshold = snr filter value
59 '''
59 '''
60
60
61 if not self.isConfig:
61 if not self.isConfig:
62 self.setup(mode)
62 self.setup(mode)
63 self.isConfig = True
63 self.isConfig = True
64
64
65 if self.dataIn.type == 'Parameters':
65 if self.dataIn.type == 'Parameters':
66 self.dataOut.copy(self.dataIn)
66 self.dataOut.copy(self.dataIn)
67
67
68 self.dataOut.data_param = self.dataOut.data[mode]
68 self.dataOut.data_param = self.dataOut.data[mode]
69 self.dataOut.heightList = self.dataOut.height[0]
69 self.dataOut.heightList = self.dataOut.height[0]
70 self.dataOut.data_snr = self.dataOut.data_snr[mode]
70 self.dataOut.data_snr = self.dataOut.data_snr[mode]
71
72 data_param = numpy.zeros([4, len(self.dataOut.heightList)])
71
73
74 SNRavg = numpy.average(self.dataOut.data_snr, axis=0)
75 SNRavgdB = 10*numpy.log10(SNRavg)
76 # Censoring Data
72 if snr_threshold is not None:
77 if snr_threshold is not None:
73 SNRavg = numpy.average(self.dataOut.data_snr, axis=0)
74 SNRavgdB = 10*numpy.log10(SNRavg)
75 for i in range(3):
78 for i in range(3):
76 self.dataOut.data_param[i][SNRavgdB <= snr_threshold] = numpy.nan
79 self.dataOut.data_param[i][SNRavgdB <= snr_threshold] = numpy.nan
80 # Including AvgSNR in data_param
81 for i in range(data_param.shape[0]):
82 if i == 3:
83 data_param[i] = SNRavgdB
84 else:
85 data_param[i] = self.dataOut.data_param[i]
86
87 self.dataOut.data_param = data_param
77
88
78 # TODO
89 # TODO
79
90
80 class OutliersFilter(Operation):
91 class OutliersFilter(Operation):
81
92
82 def __init__(self):
93 def __init__(self):
83 '''
94 '''
84 '''
95 '''
85 Operation.__init__(self)
96 Operation.__init__(self)
86
97
87 def run(self, svalue2, method, factor, filter, npoints=9):
98 def run(self, svalue2, method, factor, filter, npoints=9):
88 '''
99 '''
89 Inputs:
100 Inputs:
90 svalue - string to select array velocity
101 svalue - string to select array velocity
91 svalue2 - string to choose axis filtering
102 svalue2 - string to choose axis filtering
92 method - 0 for SMOOTH or 1 for MEDIAN
103 method - 0 for SMOOTH or 1 for MEDIAN
93 factor - number used to set threshold
104 factor - number used to set threshold
94 filter - 1 for data filtering using the standard deviation criteria else 0
105 filter - 1 for data filtering using the standard deviation criteria else 0
95 npoints - number of points for mask filter
106 npoints - number of points for mask filter
96 '''
107 '''
97
108
98 print(' Outliers Filter {} {} / threshold = {}'.format(svalue, svalue, factor))
109 print(' Outliers Filter {} {} / threshold = {}'.format(svalue, svalue, factor))
99
110
100
111
101 yaxis = self.dataOut.heightList
112 yaxis = self.dataOut.heightList
102 xaxis = numpy.array([[self.dataOut.utctime]])
113 xaxis = numpy.array([[self.dataOut.utctime]])
103
114
104 # Zonal
115 # Zonal
105 value_temp = self.dataOut.data_output[0]
116 value_temp = self.dataOut.data_output[0]
106
117
107 # Zonal
118 # Zonal
108 value_temp = self.dataOut.data_output[1]
119 value_temp = self.dataOut.data_output[1]
109
120
110 # Vertical
121 # Vertical
111 value_temp = numpy.transpose(self.dataOut.data_output[2])
122 value_temp = numpy.transpose(self.dataOut.data_output[2])
112
123
113 htemp = yaxis
124 htemp = yaxis
114 std = value_temp
125 std = value_temp
115 for h in range(len(htemp)):
126 for h in range(len(htemp)):
116 nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0])
127 nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0])
117 minvalid = npoints
128 minvalid = npoints
118
129
119 #only if valid values greater than the minimum required (10%)
130 #only if valid values greater than the minimum required (10%)
120 if nvalues_valid > minvalid:
131 if nvalues_valid > minvalid:
121
132
122 if method == 0:
133 if method == 0:
123 #SMOOTH
134 #SMOOTH
124 w = value_temp[h] - self.Smooth(input=value_temp[h], width=npoints, edge_truncate=1)
135 w = value_temp[h] - self.Smooth(input=value_temp[h], width=npoints, edge_truncate=1)
125
136
126
137
127 if method == 1:
138 if method == 1:
128 #MEDIAN
139 #MEDIAN
129 w = value_temp[h] - self.Median(input=value_temp[h], width = npoints)
140 w = value_temp[h] - self.Median(input=value_temp[h], width = npoints)
130
141
131 dw = numpy.std(w[numpy.where(numpy.isfinite(w))],ddof = 1)
142 dw = numpy.std(w[numpy.where(numpy.isfinite(w))],ddof = 1)
132
143
133 threshold = dw*factor
144 threshold = dw*factor
134 value_temp[numpy.where(w > threshold),h] = numpy.nan
145 value_temp[numpy.where(w > threshold),h] = numpy.nan
135 value_temp[numpy.where(w < -1*threshold),h] = numpy.nan
146 value_temp[numpy.where(w < -1*threshold),h] = numpy.nan
136
147
137
148
138 #At the end
149 #At the end
139 if svalue2 == 'inHeight':
150 if svalue2 == 'inHeight':
140 value_temp = numpy.transpose(value_temp)
151 value_temp = numpy.transpose(value_temp)
141 output_array[:,m] = value_temp
152 output_array[:,m] = value_temp
142
153
143 if svalue == 'zonal':
154 if svalue == 'zonal':
144 self.dataOut.data_output[0] = output_array
155 self.dataOut.data_output[0] = output_array
145
156
146 elif svalue == 'meridional':
157 elif svalue == 'meridional':
147 self.dataOut.data_output[1] = output_array
158 self.dataOut.data_output[1] = output_array
148
159
149 elif svalue == 'vertical':
160 elif svalue == 'vertical':
150 self.dataOut.data_output[2] = output_array
161 self.dataOut.data_output[2] = output_array
151
162
152 return self.dataOut.data_output
163 return self.dataOut.data_output
153
164
154
165
155 def Median(self,input,width):
166 def Median(self,input,width):
156 '''
167 '''
157 Inputs:
168 Inputs:
158 input - Velocity array
169 input - Velocity array
159 width - Number of points for mask filter
170 width - Number of points for mask filter
160
171
161 '''
172 '''
162
173
163 if numpy.mod(width,2) == 1:
174 if numpy.mod(width,2) == 1:
164 pc = int((width - 1) / 2)
175 pc = int((width - 1) / 2)
165 cont = 0
176 cont = 0
166 output = []
177 output = []
167
178
168 for i in range(len(input)):
179 for i in range(len(input)):
169 if i >= pc and i < len(input) - pc:
180 if i >= pc and i < len(input) - pc:
170 new2 = input[i-pc:i+pc+1]
181 new2 = input[i-pc:i+pc+1]
171 temp = numpy.where(numpy.isfinite(new2))
182 temp = numpy.where(numpy.isfinite(new2))
172 new = new2[temp]
183 new = new2[temp]
173 value = numpy.median(new)
184 value = numpy.median(new)
174 output.append(value)
185 output.append(value)
175
186
176 output = numpy.array(output)
187 output = numpy.array(output)
177 output = numpy.hstack((input[0:pc],output))
188 output = numpy.hstack((input[0:pc],output))
178 output = numpy.hstack((output,input[-pc:len(input)]))
189 output = numpy.hstack((output,input[-pc:len(input)]))
179
190
180 return output
191 return output
181
192
182 def Smooth(self,input,width,edge_truncate = None):
193 def Smooth(self,input,width,edge_truncate = None):
183 '''
194 '''
184 Inputs:
195 Inputs:
185 input - Velocity array
196 input - Velocity array
186 width - Number of points for mask filter
197 width - Number of points for mask filter
187 edge_truncate - 1 for truncate the convolution product else
198 edge_truncate - 1 for truncate the convolution product else
188
199
189 '''
200 '''
190
201
191 if numpy.mod(width,2) == 0:
202 if numpy.mod(width,2) == 0:
192 real_width = width + 1
203 real_width = width + 1
193 nzeros = width / 2
204 nzeros = width / 2
194 else:
205 else:
195 real_width = width
206 real_width = width
196 nzeros = (width - 1) / 2
207 nzeros = (width - 1) / 2
197
208
198 half_width = int(real_width)/2
209 half_width = int(real_width)/2
199 length = len(input)
210 length = len(input)
200
211
201 gate = numpy.ones(real_width,dtype='float')
212 gate = numpy.ones(real_width,dtype='float')
202 norm_of_gate = numpy.sum(gate)
213 norm_of_gate = numpy.sum(gate)
203
214
204 nan_process = 0
215 nan_process = 0
205 nan_id = numpy.where(numpy.isnan(input))
216 nan_id = numpy.where(numpy.isnan(input))
206 if len(nan_id[0]) > 0:
217 if len(nan_id[0]) > 0:
207 nan_process = 1
218 nan_process = 1
208 pb = numpy.zeros(len(input))
219 pb = numpy.zeros(len(input))
209 pb[nan_id] = 1.
220 pb[nan_id] = 1.
210 input[nan_id] = 0.
221 input[nan_id] = 0.
211
222
212 if edge_truncate == True:
223 if edge_truncate == True:
213 output = numpy.convolve(input/norm_of_gate,gate,mode='same')
224 output = numpy.convolve(input/norm_of_gate,gate,mode='same')
214 elif edge_truncate == False or edge_truncate == None:
225 elif edge_truncate == False or edge_truncate == None:
215 output = numpy.convolve(input/norm_of_gate,gate,mode='valid')
226 output = numpy.convolve(input/norm_of_gate,gate,mode='valid')
216 output = numpy.hstack((input[0:half_width],output))
227 output = numpy.hstack((input[0:half_width],output))
217 output = numpy.hstack((output,input[len(input)-half_width:len(input)]))
228 output = numpy.hstack((output,input[len(input)-half_width:len(input)]))
218
229
219 if nan_process:
230 if nan_process:
220 pb = numpy.convolve(pb/norm_of_gate,gate,mode='valid')
231 pb = numpy.convolve(pb/norm_of_gate,gate,mode='valid')
221 pb = numpy.hstack((numpy.zeros(half_width),pb))
232 pb = numpy.hstack((numpy.zeros(half_width),pb))
222 pb = numpy.hstack((pb,numpy.zeros(half_width)))
233 pb = numpy.hstack((pb,numpy.zeros(half_width)))
223 output[numpy.where(pb > 0.9999)] = numpy.nan
234 output[numpy.where(pb > 0.9999)] = numpy.nan
224 input[nan_id] = numpy.nan
235 input[nan_id] = numpy.nan
225 return output
236 return output
226
237
227 def Average(self,aver=0,nhaver=1):
238 def Average(self,aver=0,nhaver=1):
228 '''
239 '''
229 Inputs:
240 Inputs:
230 aver - Indicates the time period over which is averaged or consensus data
241 aver - Indicates the time period over which is averaged or consensus data
231 nhaver - Indicates the decimation factor in heights
242 nhaver - Indicates the decimation factor in heights
232
243
233 '''
244 '''
234 nhpoints = 48
245 nhpoints = 48
235
246
236 lat_piura = -5.17
247 lat_piura = -5.17
237 lat_huancayo = -12.04
248 lat_huancayo = -12.04
238 lat_porcuya = -5.8
249 lat_porcuya = -5.8
239
250
240 if '%2.2f'%self.dataOut.lat == '%2.2f'%lat_piura:
251 if '%2.2f'%self.dataOut.lat == '%2.2f'%lat_piura:
241 hcm = 3.
252 hcm = 3.
242 if self.dataOut.year == 2003 :
253 if self.dataOut.year == 2003 :
243 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
254 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
244 nhpoints = 12
255 nhpoints = 12
245
256
246 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_huancayo:
257 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_huancayo:
247 hcm = 3.
258 hcm = 3.
248 if self.dataOut.year == 2003 :
259 if self.dataOut.year == 2003 :
249 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
260 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
250 nhpoints = 12
261 nhpoints = 12
251
262
252
263
253 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_porcuya:
264 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_porcuya:
254 hcm = 5.#2
265 hcm = 5.#2
255
266
256 pdata = 0.2
267 pdata = 0.2
257 taver = [1,2,3,4,6,8,12,24]
268 taver = [1,2,3,4,6,8,12,24]
258 t0 = 0
269 t0 = 0
259 tf = 24
270 tf = 24
260 ntime =(tf-t0)/taver[aver]
271 ntime =(tf-t0)/taver[aver]
261 ti = numpy.arange(ntime)
272 ti = numpy.arange(ntime)
262 tf = numpy.arange(ntime) + taver[aver]
273 tf = numpy.arange(ntime) + taver[aver]
263
274
264
275
265 old_height = self.dataOut.heightList
276 old_height = self.dataOut.heightList
266
277
267 if nhaver > 1:
278 if nhaver > 1:
268 num_hei = len(self.dataOut.heightList)/nhaver/self.dataOut.nmodes
279 num_hei = len(self.dataOut.heightList)/nhaver/self.dataOut.nmodes
269 deltha = 0.05*nhaver
280 deltha = 0.05*nhaver
270 minhvalid = pdata*nhaver
281 minhvalid = pdata*nhaver
271 for im in range(self.dataOut.nmodes):
282 for im in range(self.dataOut.nmodes):
272 new_height = numpy.arange(num_hei)*deltha + self.dataOut.height[im,0] + deltha/2.
283 new_height = numpy.arange(num_hei)*deltha + self.dataOut.height[im,0] + deltha/2.
273
284
274
285
275 data_fHeigths_List = []
286 data_fHeigths_List = []
276 data_fZonal_List = []
287 data_fZonal_List = []
277 data_fMeridional_List = []
288 data_fMeridional_List = []
278 data_fVertical_List = []
289 data_fVertical_List = []
279 startDTList = []
290 startDTList = []
280
291
281
292
282 for i in range(ntime):
293 for i in range(ntime):
283 height = old_height
294 height = old_height
284
295
285 start = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(ti[i])) - datetime.timedelta(hours = 5)
296 start = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(ti[i])) - datetime.timedelta(hours = 5)
286 stop = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(tf[i])) - datetime.timedelta(hours = 5)
297 stop = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(tf[i])) - datetime.timedelta(hours = 5)
287
298
288
299
289 limit_sec1 = time.mktime(start.timetuple())
300 limit_sec1 = time.mktime(start.timetuple())
290 limit_sec2 = time.mktime(stop.timetuple())
301 limit_sec2 = time.mktime(stop.timetuple())
291
302
292 t1 = numpy.where(self.f_timesec >= limit_sec1)
303 t1 = numpy.where(self.f_timesec >= limit_sec1)
293 t2 = numpy.where(self.f_timesec < limit_sec2)
304 t2 = numpy.where(self.f_timesec < limit_sec2)
294 time_select = []
305 time_select = []
295 for val_sec in t1[0]:
306 for val_sec in t1[0]:
296 if val_sec in t2[0]:
307 if val_sec in t2[0]:
297 time_select.append(val_sec)
308 time_select.append(val_sec)
298
309
299
310
300 time_select = numpy.array(time_select,dtype = 'int')
311 time_select = numpy.array(time_select,dtype = 'int')
301 minvalid = numpy.ceil(pdata*nhpoints)
312 minvalid = numpy.ceil(pdata*nhpoints)
302
313
303 zon_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
314 zon_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
304 mer_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
315 mer_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
305 ver_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
316 ver_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
306
317
307 if nhaver > 1:
318 if nhaver > 1:
308 new_zon_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
319 new_zon_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
309 new_mer_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
320 new_mer_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
310 new_ver_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
321 new_ver_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
311
322
312 if len(time_select) > minvalid:
323 if len(time_select) > minvalid:
313 time_average = self.f_timesec[time_select]
324 time_average = self.f_timesec[time_select]
314
325
315 for im in range(self.dataOut.nmodes):
326 for im in range(self.dataOut.nmodes):
316
327
317 for ih in range(self.dataOut.nranges):
328 for ih in range(self.dataOut.nranges):
318 if numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im])) >= minvalid:
329 if numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im])) >= minvalid:
319 zon_aver[ih,im] = numpy.nansum(self.f_zon[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im]))
330 zon_aver[ih,im] = numpy.nansum(self.f_zon[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im]))
320
331
321 if numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im])) >= minvalid:
332 if numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im])) >= minvalid:
322 mer_aver[ih,im] = numpy.nansum(self.f_mer[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im]))
333 mer_aver[ih,im] = numpy.nansum(self.f_mer[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im]))
323
334
324 if numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im])) >= minvalid:
335 if numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im])) >= minvalid:
325 ver_aver[ih,im] = numpy.nansum(self.f_ver[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im]))
336 ver_aver[ih,im] = numpy.nansum(self.f_ver[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im]))
326
337
327 if nhaver > 1:
338 if nhaver > 1:
328 for ih in range(num_hei):
339 for ih in range(num_hei):
329 hvalid = numpy.arange(nhaver) + nhaver*ih
340 hvalid = numpy.arange(nhaver) + nhaver*ih
330
341
331 if numpy.sum(numpy.isfinite(zon_aver[hvalid,im])) >= minvalid:
342 if numpy.sum(numpy.isfinite(zon_aver[hvalid,im])) >= minvalid:
332 new_zon_aver[ih,im] = numpy.nansum(zon_aver[hvalid,im]) / numpy.sum(numpy.isfinite(zon_aver[hvalid,im]))
343 new_zon_aver[ih,im] = numpy.nansum(zon_aver[hvalid,im]) / numpy.sum(numpy.isfinite(zon_aver[hvalid,im]))
333
344
334 if numpy.sum(numpy.isfinite(mer_aver[hvalid,im])) >= minvalid:
345 if numpy.sum(numpy.isfinite(mer_aver[hvalid,im])) >= minvalid:
335 new_mer_aver[ih,im] = numpy.nansum(mer_aver[hvalid,im]) / numpy.sum(numpy.isfinite(mer_aver[hvalid,im]))
346 new_mer_aver[ih,im] = numpy.nansum(mer_aver[hvalid,im]) / numpy.sum(numpy.isfinite(mer_aver[hvalid,im]))
336
347
337 if numpy.sum(numpy.isfinite(ver_aver[hvalid,im])) >= minvalid:
348 if numpy.sum(numpy.isfinite(ver_aver[hvalid,im])) >= minvalid:
338 new_ver_aver[ih,im] = numpy.nansum(ver_aver[hvalid,im]) / numpy.sum(numpy.isfinite(ver_aver[hvalid,im]))
349 new_ver_aver[ih,im] = numpy.nansum(ver_aver[hvalid,im]) / numpy.sum(numpy.isfinite(ver_aver[hvalid,im]))
339 if nhaver > 1:
350 if nhaver > 1:
340 zon_aver = new_zon_aver
351 zon_aver = new_zon_aver
341 mer_aver = new_mer_aver
352 mer_aver = new_mer_aver
342 ver_aver = new_ver_aver
353 ver_aver = new_ver_aver
343 height = new_height
354 height = new_height
344
355
345
356
346 tstart = time_average[0]
357 tstart = time_average[0]
347 tend = time_average[-1]
358 tend = time_average[-1]
348 startTime = time.gmtime(tstart)
359 startTime = time.gmtime(tstart)
349
360
350 year = startTime.tm_year
361 year = startTime.tm_year
351 month = startTime.tm_mon
362 month = startTime.tm_mon
352 day = startTime.tm_mday
363 day = startTime.tm_mday
353 hour = startTime.tm_hour
364 hour = startTime.tm_hour
354 minute = startTime.tm_min
365 minute = startTime.tm_min
355 second = startTime.tm_sec
366 second = startTime.tm_sec
356
367
357 startDTList.append(datetime.datetime(year,month,day,hour,minute,second))
368 startDTList.append(datetime.datetime(year,month,day,hour,minute,second))
358
369
359
370
360 o_height = numpy.array([])
371 o_height = numpy.array([])
361 o_zon_aver = numpy.array([])
372 o_zon_aver = numpy.array([])
362 o_mer_aver = numpy.array([])
373 o_mer_aver = numpy.array([])
363 o_ver_aver = numpy.array([])
374 o_ver_aver = numpy.array([])
364 if self.dataOut.nmodes > 1:
375 if self.dataOut.nmodes > 1:
365 for im in range(self.dataOut.nmodes):
376 for im in range(self.dataOut.nmodes):
366
377
367 if im == 0:
378 if im == 0:
368 h_select = numpy.where(numpy.bitwise_and(height[0,:] >=0,height[0,:] <= hcm,numpy.isfinite(height[0,:])))
379 h_select = numpy.where(numpy.bitwise_and(height[0,:] >=0,height[0,:] <= hcm,numpy.isfinite(height[0,:])))
369 else:
380 else:
370 h_select = numpy.where(numpy.bitwise_and(height[1,:] > hcm,height[1,:] < 20,numpy.isfinite(height[1,:])))
381 h_select = numpy.where(numpy.bitwise_and(height[1,:] > hcm,height[1,:] < 20,numpy.isfinite(height[1,:])))
371
382
372
383
373 ht = h_select[0]
384 ht = h_select[0]
374
385
375 o_height = numpy.hstack((o_height,height[im,ht]))
386 o_height = numpy.hstack((o_height,height[im,ht]))
376 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
387 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
377 o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im]))
388 o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im]))
378 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
389 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
379
390
380 data_fHeigths_List.append(o_height)
391 data_fHeigths_List.append(o_height)
381 data_fZonal_List.append(o_zon_aver)
392 data_fZonal_List.append(o_zon_aver)
382 data_fMeridional_List.append(o_mer_aver)
393 data_fMeridional_List.append(o_mer_aver)
383 data_fVertical_List.append(o_ver_aver)
394 data_fVertical_List.append(o_ver_aver)
384
395
385
396
386 else:
397 else:
387 h_select = numpy.where(numpy.bitwise_and(height[0,:] <= hcm,numpy.isfinite(height[0,:])))
398 h_select = numpy.where(numpy.bitwise_and(height[0,:] <= hcm,numpy.isfinite(height[0,:])))
388 ht = h_select[0]
399 ht = h_select[0]
389 o_height = numpy.hstack((o_height,height[im,ht]))
400 o_height = numpy.hstack((o_height,height[im,ht]))
390 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
401 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
391 o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im]))
402 o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im]))
392 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
403 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
393
404
394 data_fHeigths_List.append(o_height)
405 data_fHeigths_List.append(o_height)
395 data_fZonal_List.append(o_zon_aver)
406 data_fZonal_List.append(o_zon_aver)
396 data_fMeridional_List.append(o_mer_aver)
407 data_fMeridional_List.append(o_mer_aver)
397 data_fVertical_List.append(o_ver_aver)
408 data_fVertical_List.append(o_ver_aver)
398
409
399
410
400 return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List
411 return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List
401
412
402
413
General Comments 0
You need to be logged in to leave comments. Login now