##// END OF EJS Templates
BLTR ok
Juan C. Espinoza -
r1018:f15cf5631d3c
parent child
Show More
@@ -1201,7 +1201,7 class Parameters(Spectra):
1201 time1 = self.utctimeInit - self.timeZone*60
1201 time1 = self.utctimeInit - self.timeZone*60
1202 else:
1202 else:
1203 time1 = self.utctimeInit
1203 time1 = self.utctimeInit
1204 print 'interval',interval
1204
1205 datatime.append(time1)
1205 datatime.append(time1)
1206 datatime.append(time1 + interval)
1206 datatime.append(time1 + interval)
1207 datatime = numpy.array(datatime)
1207 datatime = numpy.array(datatime)
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -660,11 +660,6 class WindProfilerPlot(Figure):
660 x = dataOut.getTimeRange1(dataOut.paramInterval)
660 x = dataOut.getTimeRange1(dataOut.paramInterval)
661 y = dataOut.heightList
661 y = dataOut.heightList
662 z = dataOut.data_output.copy()
662 z = dataOut.data_output.copy()
663 print ' '
664 print 'Xvel',z[0]
665 print ' '
666 print 'Yvel',z[1]
667 print ' '
668 nplots = z.shape[0] #Number of wind dimensions estimated
663 nplots = z.shape[0] #Number of wind dimensions estimated
669 nplotsw = nplots
664 nplotsw = nplots
670
665
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -10,6 +10,7 import sys
10 import time
10 import time
11 import glob
11 import glob
12 import datetime
12 import datetime
13
13 import numpy
14 import numpy
14
15
15 from schainpy.model.proc.jroproc_base import ProcessingUnit
16 from schainpy.model.proc.jroproc_base import ProcessingUnit
@@ -272,14 +273,14 class BLTRParamReader(JRODataReader, ProcessingUnit):
272 self.imode = self.header_rec['dmode_index'][0]
273 self.imode = self.header_rec['dmode_index'][0]
273 self.antenna = self.header_rec['antenna_coord']
274 self.antenna = self.header_rec['antenna_coord']
274 self.rx_gains = self.header_rec['rx_gains']
275 self.rx_gains = self.header_rec['rx_gains']
275 self.time1 = self.header_rec['time'][0]
276 self.time = self.header_rec['time'][0]
276 tseconds = self.header_rec['time'][0]
277 tseconds = self.header_rec['time'][0]
277 local_t1 = time.localtime(tseconds)
278 local_t1 = time.localtime(tseconds)
278 self.year = local_t1.tm_year
279 self.year = local_t1.tm_year
279 self.month = local_t1.tm_mon
280 self.month = local_t1.tm_mon
280 self.day = local_t1.tm_mday
281 self.day = local_t1.tm_mday
281 self.t = datetime.datetime(self.year, self.month, self.day)
282 self.t = datetime.datetime(self.year, self.month, self.day)
282 self.datatime = datetime.datetime.utcfromtimestamp(self.time1)
283 self.datatime = datetime.datetime.utcfromtimestamp(self.time)
283
284
284 def readData(self):
285 def readData(self):
285 '''
286 '''
@@ -319,11 +320,10 class BLTRParamReader(JRODataReader, ProcessingUnit):
319 Storing data from databuffer to dataOut object
320 Storing data from databuffer to dataOut object
320 '''
321 '''
321
322
322 self.dataOut.time1 = self.time1
323 self.dataOut.data_SNR = self.snr
323 self.dataOut.data_SNR = self.snr
324 self.dataOut.height= self.height
324 self.dataOut.height = self.height
325 self.dataOut.data_output = self.buffer
325 self.dataOut.data_output = self.buffer
326 self.dataOut.utctimeInit = self.time1
326 self.dataOut.utctimeInit = self.time
327 self.dataOut.utctime = self.dataOut.utctimeInit
327 self.dataOut.utctime = self.dataOut.utctimeInit
328 self.dataOut.counter_records = self.counter_records
328 self.dataOut.counter_records = self.counter_records
329 self.dataOut.nrecords = self.nrecords
329 self.dataOut.nrecords = self.nrecords
@@ -355,7 +355,7 class BLTRParamReader(JRODataReader, ProcessingUnit):
355 print 'No file left to process'
355 print 'No file left to process'
356 return 0
356 return 0
357
357
358 if not(self.readNextBlock()):
358 if not self.readNextBlock():
359 self.dataOut.flagNoData = True
359 self.dataOut.flagNoData = True
360 return 0
360 return 0
361
361
@@ -12,5 +12,4 from jroproc_correlation import *
12 from jroproc_parameters import *
12 from jroproc_parameters import *
13 from jroproc_spectra_lags import *
13 from jroproc_spectra_lags import *
14 from jroproc_spectra_acf import *
14 from jroproc_spectra_acf import *
15 from jroproc_bltr import *
15 from bltrproc_parameters import *
16
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -10,13 +10,10 import datetime
10 import time
10 import time
11 from time import gmtime
11 from time import gmtime
12
12
13 from jroproc_base import ProcessingUnit
14 from schainpy.model.data.jrodata import Parameters
15 from numpy import transpose
13 from numpy import transpose
16
14
17 from matplotlib import cm
15 from jroproc_base import ProcessingUnit, Operation
18 import matplotlib.pyplot as plt
16 from schainpy.model.data.jrodata import Parameters
19 from matplotlib.mlab import griddata
20
17
21
18
22 class BLTRParametersProc(ProcessingUnit):
19 class BLTRParametersProc(ProcessingUnit):
@@ -49,100 +46,35 class BLTRParametersProc(ProcessingUnit):
49 ProcessingUnit.__init__(self, **kwargs)
46 ProcessingUnit.__init__(self, **kwargs)
50 self.dataOut = Parameters()
47 self.dataOut = Parameters()
51
48
52 def run (self, mode):
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 == "Parameters":
56 if self.dataIn.type == 'Parameters':
56 self.dataOut.copy(self.dataIn)
57 self.dataOut.copy(self.dataIn)
57
58
58 self.dataOut.data_output = self.dataOut.data_output[mode]
59 self.dataOut.data_output = self.dataOut.data_output[mode]
59 self.dataOut.heightList = self.dataOut.height[mode]
60 self.dataOut.heightList = self.dataOut.height[0]
61 self.dataOut.data_SNR = self.dataOut.data_SNR[mode]
60
62
61 def TimeSelect(self):
63 if snr_threshold is not None:
62 '''
64 SNRavg = numpy.average(self.dataOut.data_SNR, axis=0)
63 Selecting the time array according to the day of the experiment with a duration of 24 hours
65 SNRavgdB = 10*numpy.log10(SNRavg)
64 '''
66 for i in range(3):
67 self.dataOut.data_output[i][SNRavgdB <= snr_threshold] = numpy.nan
65
68
66 k1 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) - datetime.timedelta(hours=5)
69 # TODO
67 k2 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) + datetime.timedelta(hours=25) - datetime.timedelta(hours=5)
70 class OutliersFilter(Operation):
68 limit_sec1 = time.mktime(k1.timetuple())
69 limit_sec2 = time.mktime(k2.timetuple())
70 valid_data = 0
71
71
72 doy = self.dataOut.doy
72 def __init__(self, **kwargs):
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):
127 '''
73 '''
128 Inputs: snr_val - Threshold value
129
130 '''
74 '''
131 if modetofilter!=2 and modetofilter!=1 :
75 Operation.__init__(self, **kwargs)
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
143
144
76
145 def OutliersFilter(self,modetofilter,svalue,svalue2,method,factor,filter,npoints):
77 def run(self, svalue2, method, factor, filter, npoints=9):
146 '''
78 '''
147 Inputs:
79 Inputs:
148 svalue - string to select array velocity
80 svalue - string to select array velocity
@@ -151,62 +83,27 class BLTRParametersProc(ProcessingUnit):
151 factor - number used to set threshold
83 factor - number used to set threshold
152 filter - 1 for data filtering using the standard deviation criteria else 0
84 filter - 1 for data filtering using the standard deviation criteria else 0
153 npoints - number of points for mask filter
85 npoints - number of points for mask filter
154
155 '''
86 '''
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
87
163 npoints = 9
88 print ' Outliers Filter {} {} / threshold = {}'.format(svalue, svalue, factor)
164 novalid = 0.1
165 if svalue == 'zonal':
166 value = self.dataOut.data_output[0]
167
89
168 elif svalue == 'meridional':
169 value = self.dataOut.data_output[1]
170
90
171 elif svalue == 'vertical':
91 yaxis = self.dataOut.heightList
172 value = self.dataOut.data_output[2]
92 xaxis = numpy.array([[self.dataOut.utctime]])
173
93
174 else:
94 # Zonal
175 print 'value is not defined'
95 value_temp = self.dataOut.data_output[0]
176 return
177
96
178 if svalue2 == 'inTime':
97 # Zonal
179 yaxis = self.dataOut.height
98 value_temp = self.dataOut.data_output[1]
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
189
99
190 output_array = value
100 # Vertical
101 value_temp = numpy.transpose(self.dataOut.data_output[2])
191
102
192 value_temp = value[:,m]
103 htemp = yaxis
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))
197
198 htemp = yaxis[m,:]
199 std = value_temp
104 std = value_temp
200 for h in range(len(htemp)):
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 nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0])
106 nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0])
208 minvalid = novalid*len(xaxis[m,:])
209 if minvalid <= npoints:
210 minvalid = npoints
107 minvalid = npoints
211
108
212 #only if valid values greater than the minimum required (10%)
109 #only if valid values greater than the minimum required (10%)
@@ -493,72 +390,4 class BLTRParametersProc(ProcessingUnit):
493 return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List
390 return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List
494
391
495
392
496 def prePlot(self,modeselect=None):
497
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
564 No newline at end of file
393
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
1 NO CONTENT: file was removed, binary diff hidden
NO CONTENT: file was removed, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now