@@ -16,6 +16,7 import numpy | |||||
16 | from schainpy.model.proc.jroproc_base import ProcessingUnit |
|
16 | from schainpy.model.proc.jroproc_base import ProcessingUnit | |
17 | from schainpy.model.data.jrodata import Parameters |
|
17 | from schainpy.model.data.jrodata import Parameters | |
18 | from schainpy.model.io.jroIO_base import JRODataReader, isNumber |
|
18 | from schainpy.model.io.jroIO_base import JRODataReader, isNumber | |
|
19 | from schainpy.utils import log | |||
19 |
|
20 | |||
20 | FILE_HEADER_STRUCTURE = numpy.dtype([ |
|
21 | FILE_HEADER_STRUCTURE = numpy.dtype([ | |
21 | ('FMN', '<u4'), |
|
22 | ('FMN', '<u4'), | |
@@ -111,9 +112,12 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||||
111 | **kwargs): |
|
112 | **kwargs): | |
112 |
|
113 | |||
113 | self.path = path |
|
114 | self.path = path | |
|
115 | self.startDate = startDate | |||
|
116 | self.endDate = endDate | |||
114 | self.startTime = startTime |
|
117 | self.startTime = startTime | |
115 |
self.endTime = endTime |
|
118 | self.endTime = endTime | |
116 | self.status_value = status_value |
|
119 | self.status_value = status_value | |
|
120 | self.datatime = datetime.datetime(1900,1,1) | |||
117 |
|
121 | |||
118 | if self.path is None: |
|
122 | if self.path is None: | |
119 | raise ValueError, "The path is not valid" |
|
123 | raise ValueError, "The path is not valid" | |
@@ -143,7 +147,7 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||||
143 |
|
147 | |||
144 | ''' |
|
148 | ''' | |
145 |
|
149 | |||
146 | print 'Searching file in %s ' % (path) |
|
150 | log.success('Searching files in {} '.format(path), 'BLTRParamReader') | |
147 | foldercounter = 0 |
|
151 | foldercounter = 0 | |
148 | fileList0 = glob.glob1(path, "*%s" % ext) |
|
152 | fileList0 = glob.glob1(path, "*%s" % ext) | |
149 | fileList0.sort() |
|
153 | fileList0.sort() | |
@@ -180,12 +184,11 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||||
180 | file_id = self.fileIndex |
|
184 | file_id = self.fileIndex | |
181 |
|
185 | |||
182 | if file_id == len(self.fileList): |
|
186 | if file_id == len(self.fileList): | |
183 |
|
|
187 | log.success('No more files in the folder', 'BLTRParamReader') | |
184 | print 'Total number of file(s) read : {}'.format(self.fileIndex + 1) |
|
|||
185 | self.flagNoMoreFiles = 1 |
|
188 | self.flagNoMoreFiles = 1 | |
186 | return 0 |
|
189 | return 0 | |
187 |
|
190 | |||
188 | print '\n[Setting file] (%s) ...' % self.fileList[file_id] |
|
191 | log.success('Opening {}'.format(self.fileList[file_id]), 'BLTRParamReader') | |
189 | filename = os.path.join(self.path, self.fileList[file_id]) |
|
192 | filename = os.path.join(self.path, self.fileList[file_id]) | |
190 |
|
193 | |||
191 | dirname, name = os.path.split(filename) |
|
194 | dirname, name = os.path.split(filename) | |
@@ -213,18 +216,21 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||||
213 |
|
216 | |||
214 | self.readBlock() |
|
217 | self.readBlock() | |
215 |
|
218 | |||
216 | if (self.datatime.time() < self.startTime) or (self.datatime.time() > self.endTime): |
|
219 | if (self.datatime < datetime.datetime.combine(self.startDate, self.startTime)) or \ | |
217 | print "[Reading] Record No. %d/%d -> %s [Skipping]" %( |
|
220 | (self.datatime > datetime.datetime.combine(self.endDate, self.endTime)): | |
|
221 | log.warning( | |||
|
222 | 'Reading Record No. {}/{} -> {} [Skipping]'.format( | |||
218 | self.counter_records, |
|
223 | self.counter_records, | |
219 | self.nrecords, |
|
224 | self.nrecords, | |
220 | self.datatime.ctime()) |
|
225 | self.datatime.ctime()), | |
|
226 | 'BLTRParamReader') | |||
221 | continue |
|
227 | continue | |
222 | break |
|
228 | break | |
223 |
|
229 | |||
224 |
|
|
230 | log.log('Reading Record No. {}/{} -> {}'.format( | |
225 | self.counter_records, |
|
231 | self.counter_records, | |
226 | self.nrecords, |
|
232 | self.nrecords, | |
227 | self.datatime.ctime()) |
|
233 | self.datatime.ctime()), 'BLTRParamReader') | |
228 |
|
234 | |||
229 | return 1 |
|
235 | return 1 | |
230 |
|
236 | |||
@@ -240,6 +246,7 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||||
240 | self.height = numpy.empty((self.nmodes, self.nranges)) |
|
246 | self.height = numpy.empty((self.nmodes, self.nranges)) | |
241 | self.snr = numpy.empty((self.nmodes, self.nchannels, self.nranges)) |
|
247 | self.snr = numpy.empty((self.nmodes, self.nchannels, self.nranges)) | |
242 | self.buffer = numpy.empty((self.nmodes, 3, self.nranges)) |
|
248 | self.buffer = numpy.empty((self.nmodes, 3, self.nranges)) | |
|
249 | self.flagDiscontinuousBlock = 0 | |||
243 |
|
250 | |||
244 | for mode in range(self.nmodes): |
|
251 | for mode in range(self.nmodes): | |
245 | self.readHeader() |
|
252 | self.readHeader() | |
@@ -274,13 +281,10 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||||
274 | self.antenna = self.header_rec['antenna_coord'] |
|
281 | self.antenna = self.header_rec['antenna_coord'] | |
275 | self.rx_gains = self.header_rec['rx_gains'] |
|
282 | self.rx_gains = self.header_rec['rx_gains'] | |
276 | self.time = self.header_rec['time'][0] |
|
283 | self.time = self.header_rec['time'][0] | |
277 | tseconds = self.header_rec['time'][0] |
|
284 | dt = datetime.datetime.utcfromtimestamp(self.time) | |
278 | local_t1 = time.localtime(tseconds) |
|
285 | if dt.date()>self.datatime.date(): | |
279 | self.year = local_t1.tm_year |
|
286 | self.flagDiscontinuousBlock = 1 | |
280 | self.month = local_t1.tm_mon |
|
287 | self.datatime = dt | |
281 | self.day = local_t1.tm_mday |
|
|||
282 | self.t = datetime.datetime(self.year, self.month, self.day) |
|
|||
283 | self.datatime = datetime.datetime.utcfromtimestamp(self.time) |
|
|||
284 |
|
288 | |||
285 | def readData(self): |
|
289 | def readData(self): | |
286 | ''' |
|
290 | ''' | |
@@ -322,7 +326,7 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||||
322 |
|
326 | |||
323 | self.dataOut.data_SNR = self.snr |
|
327 | self.dataOut.data_SNR = self.snr | |
324 | self.dataOut.height = self.height |
|
328 | self.dataOut.height = self.height | |
325 |
self.dataOut.data |
|
329 | self.dataOut.data = self.buffer | |
326 | self.dataOut.utctimeInit = self.time |
|
330 | self.dataOut.utctimeInit = self.time | |
327 | self.dataOut.utctime = self.dataOut.utctimeInit |
|
331 | self.dataOut.utctime = self.dataOut.utctimeInit | |
328 | self.dataOut.useLocalTime = False |
|
332 | self.dataOut.useLocalTime = False | |
@@ -335,7 +339,6 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||||
335 | self.dataOut.lon = self.lon |
|
339 | self.dataOut.lon = self.lon | |
336 | self.dataOut.channelList = range(self.nchannels) |
|
340 | self.dataOut.channelList = range(self.nchannels) | |
337 | self.dataOut.kchan = self.kchan |
|
341 | self.dataOut.kchan = self.kchan | |
338 | # self.dataOut.nHeights = self.nranges |
|
|||
339 | self.dataOut.delta = self.delta |
|
342 | self.dataOut.delta = self.delta | |
340 | self.dataOut.correction = self.correction |
|
343 | self.dataOut.correction = self.correction | |
341 | self.dataOut.nmodes = self.nmodes |
|
344 | self.dataOut.nmodes = self.nmodes | |
@@ -343,6 +346,7 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||||
343 | self.dataOut.antenna = self.antenna |
|
346 | self.dataOut.antenna = self.antenna | |
344 | self.dataOut.rx_gains = self.rx_gains |
|
347 | self.dataOut.rx_gains = self.rx_gains | |
345 | self.dataOut.flagNoData = False |
|
348 | self.dataOut.flagNoData = False | |
|
349 | self.dataOut.flagDiscontinuousBlock = self.flagDiscontinuousBlock | |||
346 |
|
350 | |||
347 | def getData(self): |
|
351 | def getData(self): | |
348 | ''' |
|
352 | ''' | |
@@ -350,7 +354,7 class BLTRParamReader(JRODataReader, ProcessingUnit): | |||||
350 | ''' |
|
354 | ''' | |
351 | if self.flagNoMoreFiles: |
|
355 | if self.flagNoMoreFiles: | |
352 | self.dataOut.flagNoData = True |
|
356 | self.dataOut.flagNoData = True | |
353 |
|
|
357 | log.success('No file left to process', 'BLTRParamReader') | |
354 | return 0 |
|
358 | return 0 | |
355 |
|
359 | |||
356 | if not self.readNextBlock(): |
|
360 | if not self.readNextBlock(): |
@@ -66,7 +66,7 class BLTRParametersProc(ProcessingUnit): | |||||
66 | if self.dataIn.type == 'Parameters': |
|
66 | if self.dataIn.type == 'Parameters': | |
67 | self.dataOut.copy(self.dataIn) |
|
67 | self.dataOut.copy(self.dataIn) | |
68 |
|
68 | |||
69 |
self.dataOut.data_ |
|
69 | self.dataOut.data_param = self.dataOut.data[mode] | |
70 | self.dataOut.heightList = self.dataOut.height[0] |
|
70 | self.dataOut.heightList = self.dataOut.height[0] | |
71 | self.dataOut.data_SNR = self.dataOut.data_SNR[mode] |
|
71 | self.dataOut.data_SNR = self.dataOut.data_SNR[mode] | |
72 |
|
72 | |||
@@ -74,7 +74,7 class BLTRParametersProc(ProcessingUnit): | |||||
74 | SNRavg = numpy.average(self.dataOut.data_SNR, axis=0) |
|
74 | SNRavg = numpy.average(self.dataOut.data_SNR, axis=0) | |
75 | SNRavgdB = 10*numpy.log10(SNRavg) |
|
75 | SNRavgdB = 10*numpy.log10(SNRavg) | |
76 | for i in range(3): |
|
76 | for i in range(3): | |
77 |
self.dataOut.data_ |
|
77 | self.dataOut.data_param[i][SNRavgdB <= snr_threshold] = numpy.nan | |
78 |
|
78 | |||
79 | # TODO |
|
79 | # TODO | |
80 | class OutliersFilter(Operation): |
|
80 | class OutliersFilter(Operation): |
General Comments 0
You need to be logged in to leave comments.
Login now