@@ -1201,7 +1201,7 class Parameters(Spectra): | |||
|
1201 | 1201 | time1 = self.utctimeInit - self.timeZone*60 |
|
1202 | 1202 | else: |
|
1203 | 1203 | time1 = self.utctimeInit |
|
1204 | print 'interval',interval | |
|
1204 | ||
|
1205 | 1205 | datatime.append(time1) |
|
1206 | 1206 | datatime.append(time1 + interval) |
|
1207 | 1207 | datatime = numpy.array(datatime) |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -658,13 +658,8 class WindProfilerPlot(Figure): | |||
|
658 | 658 | # tmax = None |
|
659 | 659 | |
|
660 | 660 | x = dataOut.getTimeRange1(dataOut.paramInterval) |
|
661 | y = dataOut.heightList | |
|
662 | z = dataOut.data_output.copy() | |
|
663 | print ' ' | |
|
664 | print 'Xvel',z[0] | |
|
665 | print ' ' | |
|
666 | print 'Yvel',z[1] | |
|
667 | print ' ' | |
|
661 | y = dataOut.heightList | |
|
662 | z = dataOut.data_output.copy() | |
|
668 | 663 | nplots = z.shape[0] #Number of wind dimensions estimated |
|
669 | 664 | nplotsw = nplots |
|
670 | 665 |
|
1 | NO CONTENT: modified file, binary diff hidden |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -10,6 +10,7 import sys | |||
|
10 | 10 | import time |
|
11 | 11 | import glob |
|
12 | 12 | import datetime |
|
13 | ||
|
13 | 14 | import numpy |
|
14 | 15 | |
|
15 | 16 | from schainpy.model.proc.jroproc_base import ProcessingUnit |
@@ -241,7 +242,7 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||
|
241 | 242 | self.buffer = numpy.empty((self.nmodes, 3, self.nranges)) |
|
242 | 243 | |
|
243 | 244 | for mode in range(self.nmodes): |
|
244 | self.readHeader() | |
|
245 | self.readHeader() | |
|
245 | 246 | data = self.readData() |
|
246 | 247 | self.height[mode] = (data[0] - self.correction) / 1000. |
|
247 | 248 | self.buffer[mode] = data[1] |
@@ -272,14 +273,14 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||
|
272 | 273 | self.imode = self.header_rec['dmode_index'][0] |
|
273 | 274 | self.antenna = self.header_rec['antenna_coord'] |
|
274 | 275 | self.rx_gains = self.header_rec['rx_gains'] |
|
275 |
self.time |
|
|
276 | self.time = self.header_rec['time'][0] | |
|
276 | 277 | tseconds = self.header_rec['time'][0] |
|
277 | 278 | local_t1 = time.localtime(tseconds) |
|
278 | 279 | self.year = local_t1.tm_year |
|
279 | 280 | self.month = local_t1.tm_mon |
|
280 | 281 | self.day = local_t1.tm_mday |
|
281 | 282 | self.t = datetime.datetime(self.year, self.month, self.day) |
|
282 |
self.datatime = datetime.datetime.utcfromtimestamp(self.time |
|
|
283 | self.datatime = datetime.datetime.utcfromtimestamp(self.time) | |
|
283 | 284 | |
|
284 | 285 | def readData(self): |
|
285 | 286 | ''' |
@@ -306,7 +307,7 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||
|
306 | 307 | winds = numpy.array((data['zonal'], data['meridional'], data['vertical'])) |
|
307 | 308 | snr = data['rx_snr'].T |
|
308 | 309 | |
|
309 |
winds[numpy.where(winds == -9999.)] = numpy.nan |
|
|
310 | winds[numpy.where(winds == -9999.)] = numpy.nan | |
|
310 | 311 | winds[:, numpy.where(data['status'] != self.status_value)] = numpy.nan |
|
311 | 312 | snr[numpy.where(snr == -9999.)] = numpy.nan |
|
312 | 313 | snr[:, numpy.where(data['status'] != self.status_value)] = numpy.nan |
@@ -318,12 +319,11 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||
|
318 | 319 | ''' |
|
319 | 320 | Storing data from databuffer to dataOut object |
|
320 | 321 | ''' |
|
321 | ||
|
322 | self.dataOut.time1 = self.time1 | |
|
322 | ||
|
323 | 323 | self.dataOut.data_SNR = self.snr |
|
324 | self.dataOut.height= self.height | |
|
324 | self.dataOut.height = self.height | |
|
325 | 325 | self.dataOut.data_output = self.buffer |
|
326 |
self.dataOut.utctimeInit = self.time |
|
|
326 | self.dataOut.utctimeInit = self.time | |
|
327 | 327 | self.dataOut.utctime = self.dataOut.utctimeInit |
|
328 | 328 | self.dataOut.counter_records = self.counter_records |
|
329 | 329 | self.dataOut.nrecords = self.nrecords |
@@ -334,7 +334,7 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||
|
334 | 334 | self.dataOut.nrecords = self.nrecords |
|
335 | 335 | self.dataOut.sizeOfFile = self.sizeOfFile |
|
336 | 336 | self.dataOut.lat = self.lat |
|
337 |
self.dataOut.lon = self.lon |
|
|
337 | self.dataOut.lon = self.lon | |
|
338 | 338 | self.dataOut.channelList = range(self.nchannels) |
|
339 | 339 | self.dataOut.kchan = self.kchan |
|
340 | 340 | # self.dataOut.nHeights = self.nranges |
@@ -355,7 +355,7 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||
|
355 | 355 | print 'No file left to process' |
|
356 | 356 | return 0 |
|
357 | 357 | |
|
358 |
if not |
|
|
358 | if not self.readNextBlock(): | |
|
359 | 359 | self.dataOut.flagNoData = True |
|
360 | 360 | return 0 |
|
361 | 361 |
@@ -12,5 +12,4 from jroproc_correlation import * | |||
|
12 | 12 | from jroproc_parameters import * |
|
13 | 13 | from jroproc_spectra_lags import * |
|
14 | 14 | from jroproc_spectra_acf import * |
|
15 |
from |
|
|
16 | ||
|
15 | from bltrproc_parameters import * |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -10,13 +10,10 import datetime | |||
|
10 | 10 | import time |
|
11 | 11 | from time import gmtime |
|
12 | 12 | |
|
13 | from jroproc_base import ProcessingUnit | |
|
14 | from schainpy.model.data.jrodata import Parameters | |
|
15 | 13 | from numpy import transpose |
|
16 | 14 | |
|
17 | from matplotlib import cm | |
|
18 | import matplotlib.pyplot as plt | |
|
19 | from matplotlib.mlab import griddata | |
|
15 | from jroproc_base import ProcessingUnit, Operation | |
|
16 | from schainpy.model.data.jrodata import Parameters | |
|
20 | 17 | |
|
21 | 18 | |
|
22 | 19 | class BLTRParametersProc(ProcessingUnit): |
@@ -49,165 +46,65 class BLTRParametersProc(ProcessingUnit): | |||
|
49 | 46 | ProcessingUnit.__init__(self, **kwargs) |
|
50 | 47 | self.dataOut = Parameters() |
|
51 | 48 | |
|
52 |
def run |
|
|
49 | def run(self, mode, snr_threshold=None): | |
|
53 | 50 | ''' |
|
51 | ||
|
52 | Inputs: | |
|
53 | mode = High resolution (0) or Low resolution (1) data | |
|
54 | snr_threshold = snr filter value | |
|
54 | 55 | ''' |
|
55 |
if self.dataIn.type == |
|
|
56 | if self.dataIn.type == 'Parameters': | |
|
56 | 57 | self.dataOut.copy(self.dataIn) |
|
57 | ||
|
58 | ||
|
58 | 59 | self.dataOut.data_output = self.dataOut.data_output[mode] |
|
59 |
self.dataOut.heightList = self.dataOut.height[ |
|
|
60 | self.dataOut.heightList = self.dataOut.height[0] | |
|
61 | self.dataOut.data_SNR = self.dataOut.data_SNR[mode] | |
|
60 | 62 | |
|
61 | def TimeSelect(self): | |
|
62 | ''' | |
|
63 | Selecting the time array according to the day of the experiment with a duration of 24 hours | |
|
64 | ''' | |
|
65 | ||
|
66 | k1 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) - datetime.timedelta(hours=5) | |
|
67 | k2 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) + datetime.timedelta(hours=25) - datetime.timedelta(hours=5) | |
|
68 | limit_sec1 = time.mktime(k1.timetuple()) | |
|
69 | limit_sec2 = time.mktime(k2.timetuple()) | |
|
70 | valid_data = 0 | |
|
71 | ||
|
72 | doy = self.dataOut.doy | |
|
73 | t1 = numpy.where(self.dataOut.time[0, :] >= limit_sec1) | |
|
74 | t2 = numpy.where(self.dataOut.time[0, :] < limit_sec2) | |
|
75 | time_select = [] | |
|
76 | for val_sec in t1[0]: | |
|
77 | if val_sec in t2[0]: | |
|
78 | time_select.append(val_sec) | |
|
79 | ||
|
80 | time_select = numpy.array(time_select, dtype='int') | |
|
81 | valid_data = valid_data + len(time_select) | |
|
82 | ||
|
83 | ||
|
84 | if len(time_select) > 0: | |
|
85 | self.f_timesec = self.dataOut.time[:, time_select] | |
|
86 | snr = self.dataOut.data_SNR[time_select, :, :, :] | |
|
87 | zon = self.dataOut.data_output[0][time_select, :, :] | |
|
88 | mer = self.dataOut.data_output[1][time_select, :, :] | |
|
89 | ver = self.dataOut.data_output[2][time_select, :, :] | |
|
90 | ||
|
91 | if valid_data > 0: | |
|
92 | self.timesec1 = self.f_timesec[0, :] | |
|
93 | self.f_height = self.dataOut.height | |
|
94 | self.f_zon = zon | |
|
95 | self.f_mer = mer | |
|
96 | self.f_ver = ver | |
|
97 | self.f_snr = snr | |
|
98 | self.f_timedate = [] | |
|
99 | self.f_time = [] | |
|
100 | ||
|
101 | for valuet in self.timesec1: | |
|
102 | time_t = time.gmtime(valuet) | |
|
103 | year = time_t.tm_year | |
|
104 | month = time_t.tm_mon | |
|
105 | day = time_t.tm_mday | |
|
106 | hour = time_t.tm_hour | |
|
107 | minute = time_t.tm_min | |
|
108 | second = time_t.tm_sec | |
|
109 | f_timedate_0 = datetime.datetime(year, month, day, hour, minute, second) | |
|
110 | self.f_timedate.append(f_timedate_0) | |
|
111 | ||
|
112 | return self.f_timedate, self.f_timesec, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr | |
|
113 | ||
|
114 | else: | |
|
115 | self.f_timesec = None | |
|
116 | self.f_timedate = None | |
|
117 | self.f_height = None | |
|
118 | self.f_zon = None | |
|
119 | self.f_mer = None | |
|
120 | self.f_ver = None | |
|
121 | self.f_snr = None | |
|
122 | print 'Invalid time' | |
|
123 | ||
|
124 | return self.f_timedate, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr | |
|
125 | ||
|
126 | def SnrFilter(self, snr_val,modetofilter): | |
|
63 | if snr_threshold is not None: | |
|
64 | SNRavg = numpy.average(self.dataOut.data_SNR, axis=0) | |
|
65 | SNRavgdB = 10*numpy.log10(SNRavg) | |
|
66 | for i in range(3): | |
|
67 | self.dataOut.data_output[i][SNRavgdB <= snr_threshold] = numpy.nan | |
|
68 | ||
|
69 | # TODO | |
|
70 | class OutliersFilter(Operation): | |
|
71 | ||
|
72 | def __init__(self, **kwargs): | |
|
127 | 73 | ''' |
|
128 | Inputs: snr_val - Threshold value | |
|
129 | ||
|
130 | 74 | ''' |
|
131 | if modetofilter!=2 and modetofilter!=1 : | |
|
132 | raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter) | |
|
133 | m = modetofilter-1 | |
|
134 | ||
|
135 | print ' SNR filter [mode {}]: SNR <= {}: data_output = NA'.format(modetofilter,snr_val) | |
|
136 | for k in range(self.dataOut.nchannels): | |
|
137 | for r in range(self.dataOut.nranges): | |
|
138 | if self.dataOut.data_SNR[r,k,m] <= snr_val: | |
|
139 | self.dataOut.data_output[2][r,m] = numpy.nan | |
|
140 | self.dataOut.data_output[1][r,m] = numpy.nan | |
|
141 | self.dataOut.data_output[0][r,m] = numpy.nan | |
|
142 | ||
|
75 | Operation.__init__(self, **kwargs) | |
|
143 | 76 | |
|
144 | ||
|
145 | def OutliersFilter(self,modetofilter,svalue,svalue2,method,factor,filter,npoints): | |
|
77 | def run(self, svalue2, method, factor, filter, npoints=9): | |
|
146 | 78 | ''' |
|
147 | 79 | Inputs: |
|
148 | 80 | svalue - string to select array velocity |
|
149 | 81 | svalue2 - string to choose axis filtering |
|
150 | 82 | method - 0 for SMOOTH or 1 for MEDIAN |
|
151 |
factor - number used to set threshold |
|
|
83 | factor - number used to set threshold | |
|
152 | 84 | filter - 1 for data filtering using the standard deviation criteria else 0 |
|
153 | 85 | npoints - number of points for mask filter |
|
154 |
|
|
|
155 | ''' | |
|
156 | if modetofilter!=2 and modetofilter!=1 : | |
|
157 | raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter) | |
|
158 | ||
|
159 | m = modetofilter-1 | |
|
160 | ||
|
161 | print ' Outliers Filter [mode {}]: {} {} / threshold = {}'.format(modetofilter,svalue,svalue,factor) | |
|
162 | ||
|
163 | npoints = 9 | |
|
164 | novalid = 0.1 | |
|
165 | if svalue == 'zonal': | |
|
166 | value = self.dataOut.data_output[0] | |
|
167 | ||
|
168 | elif svalue == 'meridional': | |
|
169 | value = self.dataOut.data_output[1] | |
|
170 | ||
|
171 | elif svalue == 'vertical': | |
|
172 | value = self.dataOut.data_output[2] | |
|
173 | ||
|
174 | else: | |
|
175 | print 'value is not defined' | |
|
176 | return | |
|
86 | ''' | |
|
87 | ||
|
88 | print ' Outliers Filter {} {} / threshold = {}'.format(svalue, svalue, factor) | |
|
89 | ||
|
177 | 90 | |
|
178 | if svalue2 == 'inTime': | |
|
179 | yaxis = self.dataOut.height | |
|
180 | xaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]]) | |
|
181 | ||
|
182 | elif svalue2 == 'inHeight': | |
|
183 | yaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]]) | |
|
184 | xaxis = self.dataOut.height | |
|
185 | ||
|
186 | else: | |
|
187 | print 'svalue2 is required, either inHeight or inTime' | |
|
188 | return | |
|
91 | yaxis = self.dataOut.heightList | |
|
92 | xaxis = numpy.array([[self.dataOut.utctime]]) | |
|
189 | 93 | |
|
190 | output_array = value | |
|
94 | # Zonal | |
|
95 | value_temp = self.dataOut.data_output[0] | |
|
191 | 96 | |
|
192 | value_temp = value[:,m] | |
|
193 | error = numpy.zeros(len(self.dataOut.time[m,:])) | |
|
194 | if svalue2 == 'inHeight': | |
|
195 | value_temp = numpy.transpose(value_temp) | |
|
196 | error = numpy.zeros(len(self.dataOut.height)) | |
|
97 | # Zonal | |
|
98 | value_temp = self.dataOut.data_output[1] | |
|
197 | 99 | |
|
198 | htemp = yaxis[m,:] | |
|
100 | # Vertical | |
|
101 | value_temp = numpy.transpose(self.dataOut.data_output[2]) | |
|
102 | ||
|
103 | htemp = yaxis | |
|
199 | 104 | std = value_temp |
|
200 | 105 | for h in range(len(htemp)): |
|
201 | if filter: #standard deviation filtering | |
|
202 | std[h] = numpy.std(value_temp[h],ddof = npoints) | |
|
203 | value_temp[numpy.where(std[h] > 5),h] = numpy.nan | |
|
204 | error[numpy.where(std[h] > 5)] = error[numpy.where(std[h] > 5)] + 1 | |
|
205 | ||
|
206 | ||
|
207 | 106 | nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0]) |
|
208 |
minvalid = n |
|
|
209 | if minvalid <= npoints: | |
|
210 | minvalid = npoints | |
|
107 | minvalid = npoints | |
|
211 | 108 | |
|
212 | 109 | #only if valid values greater than the minimum required (10%) |
|
213 | 110 | if nvalues_valid > minvalid: |
@@ -491,74 +388,6 class BLTRParametersProc(ProcessingUnit): | |||
|
491 | 388 | |
|
492 | 389 | |
|
493 | 390 | return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List |
|
494 | ||
|
495 | ||
|
496 | def prePlot(self,modeselect=None): | |
|
497 | 391 | |
|
498 | ''' | |
|
499 | Inputs: | |
|
500 | ||
|
501 | self.dataOut.data_output - Zonal, Meridional and Vertical velocity array | |
|
502 | self.dataOut.height - height array | |
|
503 | self.dataOut.time - Time array (seconds) | |
|
504 | self.dataOut.data_SNR - SNR array | |
|
505 | ||
|
506 | ''' | |
|
507 | ||
|
508 | m = modeselect -1 | |
|
509 | ||
|
510 | print ' [Plotting mode {}]'.format(modeselect) | |
|
511 | if not (m ==1 or m==0): | |
|
512 | raise IndexError("'Mode' must be egual to : 1 or 2") | |
|
513 | # | |
|
514 | if self.flagfirstmode==0: | |
|
515 | #copy of the data | |
|
516 | self.data_output_copy = self.dataOut.data_output.copy() | |
|
517 | self.data_height_copy = self.dataOut.height.copy() | |
|
518 | self.data_time_copy = self.dataOut.time.copy() | |
|
519 | self.data_SNR_copy = self.dataOut.data_SNR.copy() | |
|
520 | self.flagfirstmode = 1 | |
|
521 | ||
|
522 | else: | |
|
523 | self.dataOut.data_output = self.data_output_copy | |
|
524 | self.dataOut.height = self.data_height_copy | |
|
525 | self.dataOut.time = self.data_time_copy | |
|
526 | self.dataOut.data_SNR = self.data_SNR_copy | |
|
527 | self.flagfirstmode = 0 | |
|
528 | ||
|
529 | ||
|
530 | #select data for mode m | |
|
531 | #self.dataOut.data_output = self.dataOut.data_output[:,:,m] | |
|
532 | self.dataOut.heightList = self.dataOut.height[0,:] | |
|
533 | ||
|
534 | data_SNR = self.dataOut.data_SNR[:,:,m] | |
|
535 | self.dataOut.data_SNR= transpose(data_SNR) | |
|
536 | ||
|
537 | if m==1 and self.dataOut.counter_records%2==0: | |
|
538 | print '*********' | |
|
539 | print 'MODO 2' | |
|
540 | #print 'Zonal', self.dataOut.data_output[0] | |
|
541 | #print 'Meridional', self.dataOut.data_output[1] | |
|
542 | #print 'Vertical', self.dataOut.data_output[2] | |
|
543 | ||
|
544 | print '*********' | |
|
545 | ||
|
546 | Vx=self.dataOut.data_output[0,:,m] | |
|
547 | Vy=self.dataOut.data_output[1,:,m] | |
|
548 | ||
|
549 | Vmag=numpy.sqrt(Vx**2+Vy**2) | |
|
550 | Vang=numpy.arctan2(Vy,Vx) | |
|
551 | #print 'Vmag', Vmag | |
|
552 | #print 'Vang', Vang | |
|
553 | ||
|
554 | self.dataOut.data_output[0,:,m]=Vmag | |
|
555 | self.dataOut.data_output[1,:,m]=Vang | |
|
556 | ||
|
557 | prin= self.dataOut.data_output[0,:,m][~numpy.isnan(self.dataOut.data_output[0,:,m])] | |
|
558 | print ' ' | |
|
559 | print 'VmagAverage',numpy.mean(prin) | |
|
560 | print ' ' | |
|
561 | self.dataOut.data_output = self.dataOut.data_output[:,:,m] | |
|
562 | ||
|
563 | 392 | |
|
564 | 393 | No newline at end of file |
|
1 | NO CONTENT: modified file, binary diff hidden |
|
1 | NO CONTENT: file was removed, binary diff hidden |
|
1 | NO CONTENT: file was removed, binary diff hidden |
General Comments 0
You need to be logged in to leave comments.
Login now