##// END OF EJS Templates
22/08/2017
ebocanegra -
r1006:8363978b5396
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,109 +1,106
1 <<<<<<< HEAD
2 # Byte-compiled / optimized / DLL files
1 # Byte-compiled / optimized / DLL files
3 __pycache__/
2 __pycache__/
4 *.py[cod]
3 *.py[cod]
5 *$py.class
4 *$py.class
6
5
7 # C extensions
6 # C extensions
8 *.so
7 *.so
9
8
10 # Distribution / packaging
9 # Distribution / packaging
11 .Python
10 .Python
12 env/
11 env/
13 build/
12 build/
14 develop-eggs/
13 develop-eggs/
15 dist/
14 dist/
16 downloads/
15 downloads/
17 eggs/
16 eggs/
18 .eggs/
17 .eggs/
19 lib/
18 lib/
20 lib64/
19 lib64/
21 parts/
20 parts/
22 sdist/
21 sdist/
23 var/
22 var/
24 wheels/
23 wheels/
25 *.egg-info/
24 *.egg-info/
26 .installed.cfg
25 .installed.cfg
27 *.egg
26 *.egg
28
27
29 # PyInstaller
28 # PyInstaller
30 # Usually these files are written by a python script from a template
29 # Usually these files are written by a python script from a template
31 # before PyInstaller builds the exe, so as to inject date/other infos into it.
30 # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 *.manifest
31 *.manifest
33 *.spec
32 *.spec
34
33
35 # Installer logs
34 # Installer logs
36 pip-log.txt
35 pip-log.txt
37 pip-delete-this-directory.txt
36 pip-delete-this-directory.txt
38
37
39 # Unit test / coverage reports
38 # Unit test / coverage reports
40 htmlcov/
39 htmlcov/
41 .tox/
40 .tox/
42 .coverage
41 .coverage
43 .coverage.*
42 .coverage.*
44 .cache
43 .cache
45 nosetests.xml
44 nosetests.xml
46 coverage.xml
45 coverage.xml
47 *,cover
46 *,cover
48 .hypothesis/
47 .hypothesis/
49
48
50 # Translations
49 # Translations
51 *.mo
50 *.mo
52 *.pot
51 *.pot
53
52
54 # Django stuff:
53 # Django stuff:
55 *.log
54 *.log
56 local_settings.py
55 local_settings.py
57
56
58 # Flask stuff:
57 # Flask stuff:
59 instance/
58 instance/
60 .webassets-cache
59 .webassets-cache
61
60
62 # Scrapy stuff:
61 # Scrapy stuff:
63 .scrapy
62 .scrapy
64
63
65 # Sphinx documentation
64 # Sphinx documentation
66 docs/_build/
65 docs/_build/
67
66
68 # PyBuilder
67 # PyBuilder
69 target/
68 target/
70
69
71 # Jupyter Notebook
70 # Jupyter Notebook
72 .ipynb_checkpoints
71 .ipynb_checkpoints
73
72
74 # pyenv
73 # pyenv
75 .python-version
74 .python-version
76
75
77 # celery beat schedule file
76 # celery beat schedule file
78 celerybeat-schedule
77 celerybeat-schedule
79
78
80 # SageMath parsed files
79 # SageMath parsed files
81 *.sage.py
80 *.sage.py
82
81
83 # dotenv
82 # dotenv
84 .env
83 .env
85
84
86 # virtualenv
85 # virtualenv
87 .venv
86 .venv
88 venv/
87 venv/
89 ENV/
88 ENV/
90
89
91 # Spyder project settings
90 # Spyder project settings
92 .spyderproject
91 .spyderproject
93 .spyproject
92 .spyproject
94
93
95 # Rope project settings
94 # Rope project settings
96 .ropeproject
95 .ropeproject
97
96
98 # mkdocs documentation
97 # mkdocs documentation
99 /site
98 /site
100
99
101 # eclipse
100 # eclipse
102 .project
101 .project
103 .pydevproject
102 .pydevproject
104 =======
105 build/
106 dist/
107 schainpy.egg-info/
108 .svn/
103 .svn/
109 >>>>>>> 08c4507d6c3c48f6c52326d5dedfa1972fb26356
104 *.png
105 *.pyc
106 schainpy/scripts
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
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
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
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
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
@@ -1,19 +1,19
1 '''
1 '''
2
2
3 $Author: murco $
3 $Author: murco $
4 $Id: JRODataIO.py 169 2012-11-19 21:57:03Z murco $
4 $Id: JRODataIO.py 169 2012-11-19 21:57:03Z murco $
5 '''
5 '''
6
6
7 from jroIO_voltage import *
7 from jroIO_voltage import *
8 from jroIO_spectra import *
8 from jroIO_spectra import *
9 from jroIO_heispectra import *
9 from jroIO_heispectra import *
10 from jroIO_usrp import *
10 from jroIO_usrp import *
11
11
12 from jroIO_kamisr import *
12 from jroIO_kamisr import *
13 from jroIO_param import *
13 from jroIO_param import *
14 from jroIO_hf import *
14 from jroIO_hf import *
15
15
16 from jroIO_bltr import *
16 from jroIO_bltr import *
17 from jroIO_mira35c import *
17 from jroIO_mira35c import *
18 #from io_bltr_block import *
18 from io_bltr_block import *
19
19
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,948 +1,950
1 '''
1 '''
2 Created on Nov 9, 2016
2 Created on Nov 9, 2016
3
3
4 @author: roj- LouVD
4 @author: roj- LouVD
5 '''
5 '''
6
6
7 import numpy
7 import numpy
8 import os.path
8 import os.path
9 import sys
9 import sys
10 import time
10 import time
11 import datetime
11 import datetime
12 from sys import path
12 from sys import path
13 from os.path import dirname
13 from os.path import dirname
14 from mimify import HeaderFile
14 from mimify import HeaderFile
15 from numpy import size, asarray
15 from numpy import size, asarray
16 from datetime import datetime
16 from datetime import datetime
17 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
17 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
18 from schainpy.model.data.jrodata import Parameters
18 from schainpy.model.data.jrodata import Parameters
19 from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader
19 from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader
20 from schainpy.model.graphics.jroplot_parameters import WindProfilerPlot
20 from schainpy.model.graphics.jroplot_parameters import WindProfilerPlot
21 from schainpy.model.io.jroIO_base import *
21 from schainpy.model.io.jroIO_base import *
22
22
23 import schainpy
23 import schainpy
24 #import madrigal
24 #import madrigal
25 #import madrigal.cedar
25 #import madrigal.cedar
26 #from madrigal.cedar import MadrigalCatalogRecord
26 #from madrigal.cedar import MadrigalCatalogRecord
27
27
28 import warnings
28 import warnings
29 from time import gmtime
29 from time import gmtime
30 from math import floor
30 from math import floor
31
31 warnings.simplefilter("error")
32 warnings.simplefilter("error")
32 from numpy.lib.nanfunctions import nansum
33 from numpy.lib.nanfunctions import nansum
33 warnings.simplefilter('ignore', FutureWarning)
34 warnings.simplefilter('ignore', FutureWarning)
34
35
35
36
36 class testBLTRReader(ProcessingUnit):
37 class testBLTRReader(ProcessingUnit):
37
38
38
39
39 def __init__(self):
40 def __init__(self, **kwargs):
40
41
41 path = None
42 path = None
42 startDate = None
43 startDate = None
43 endDate = None
44 endDate = None
44 startTime = None
45 startTime = None
45 endTime = None
46 endTime = None
46 startTime = None
47 startTime = None
47 endTime = None
48 endTime = None
48
49
49 isConfig = False
50 isConfig = False
50 dataOut = None
51 dataOut = None
51 walk = None
52 walk = None
52 ext = 'swwma'
53 ext = 'swwma'
53 fileList = []
54 fileList = []
54 fileIndex = -1
55 fileIndex = -1
55 timezone = None
56 timezone = None
56 filename = None
57 filename = None
57
58
58 timearray = None
59 timearray = None
59 height = None
60 height = None
60 snr_ref = None
61 snr_ref = None
61 zon_ref = None
62 zon_ref = None
62 ver_ref = None
63 ver_ref = None
63 mer_ref = None
64 mer_ref = None
64 nmodes = None
65 nmodes = None
65 nchannels = None
66 nchannels = None
66 nranges = None
67 nranges = None
67 year = None
68 year = None
68 month = None
69 month = None
69 day = None
70 day = None
70 lat = None
71 lat = None
71 lon = None
72 lon = None
72 siteFile = None
73 siteFile = None
73
74
74 ProcessingUnit.__init__(self)
75 ProcessingUnit.__init__(self , **kwargs)
75 self.dataOut = self.createObjByDefault()
76 self.dataOut = self.createObjByDefault()
76 self.imode = 0
77 self.imode = 0
77 self.counter_records = 0
78 self.counter_records = 0
78
79
79 self.isConfig = False
80 self.isConfig = False
80 self.flagNoMoreFiles = 0
81 self.flagNoMoreFiles = 0
81
82
82 self.buffer = None
83 self.buffer = None
83
84
84
85
85 def createObjByDefault(self):
86 def createObjByDefault(self):
86
87
87 dataObj = Parameters()
88 dataObj = Parameters()
88
89
89 return dataObj
90 return dataObj
90
91
91 def info(self):
92 def info(self):
92 '''
93 '''
93 Experience information
94 Experience information
94
95
95 '''
96 '''
96 self.hoy = datetime.datetime.now()
97 self.hoy = datetime.datetime.now()
97 place = 'Jicamarca Radio Observatory'
98 place = 'Jicamarca Radio Observatory'
98 signalchainweb='http://jro-dev.igp.gob.pe:3000/projects/signal-chain/wiki/Manual_de_Desarrollador'
99 signalchainweb='http://jro-dev.igp.gob.pe:3000/projects/signal-chain/wiki/Manual_de_Desarrollador'
99 print '{} at {}'.format(self.hoy,place)
100 print '{} at {}'.format(self.hoy,place)
100 print 'Boundary Layer and Tropospheric Radar (BLTR) script, Wind velocities and SNR from *.sswma files'
101 print 'Boundary Layer and Tropospheric Radar (BLTR) script, Wind velocities and SNR from *.sswma files'
101 print '{} \n'.format(signalchainweb)
102 print '{} \n'.format(signalchainweb)
102
103
103 def run(self, path, startDate, endDate, ext, startTime, endTime):
104 def run(self, path, startDate, endDate, ext, startTime, endTime, queue=None):
104
105
105 if not(self.isConfig):
106 if not(self.isConfig):
106 self.setup(path, startDate, endDate, ext)
107 self.setup(path, startDate, endDate, ext)
107 self.isConfig = True
108 self.isConfig = True
108
109
109 self.getData()
110 self.getData()
110
111
111 def setup(self,
112 def setup(self,
112 path=None,
113 path=None,
113 startDate=None,
114 startDate=None,
114 endDate=None,
115 endDate=None,
115 ext=None,
116 ext=None,
116 startTime=datetime.time(0, 0, 0),
117 startTime=datetime.time(0, 0, 0),
117 endTime=datetime.time(23, 59, 59),
118 endTime=datetime.time(23, 59, 59),
118 timezone=0):
119 timezone=0):
119
120
120 self.info()
121 self.info()
121 self.path = path
122 self.path = path
122 if self.path == None:
123 if self.path == None:
123 raise ValueError, "The path is not valid"
124 raise ValueError, "The path is not valid"
124
125
125 if ext == None:
126 if ext == None:
126 ext = self.ext
127 ext = self.ext
127
128
128 self.searchFiles(self.path, startDate, endDate, ext)
129 self.searchFiles(self.path, startDate, endDate, ext)
129
130
130 self.timezone = timezone
131 self.timezone = timezone
131 self.ext = ext
132 self.ext = ext
132 self.fileIndex = -1
133 self.fileIndex = -1
133
134
134 if not(self.fileList):
135 if not(self.fileList):
135 raise Warning, "There is no files matching these date in the folder: %s. \n Check 'startDate' and 'endDate' "%(path)
136 raise Warning, "There is no files matching these date in the folder: %s. \n Check 'startDate' and 'endDate' "%(path)
136
137
137
138
138 if not(self.setNextFile()):
139 if not(self.setNextFile()):
139
140
140 print 'not next file'
141 print 'not next file'
141 if (startDate!=None) and (endDate!=None):
142 if (startDate!=None) and (endDate!=None):
142 print "No files in range: %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
143 print "No files in range: %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
143 elif startDate != None:
144 elif startDate != None:
144 print "No files in range: %s" %(datetime.datetime.combine(startDate,startTime).ctime())
145 print "No files in range: %s" %(datetime.datetime.combine(startDate,startTime).ctime())
145 else:
146 else:
146 print "No files"
147 print "No files"
147
148
148 sys.exit(-1)
149 sys.exit(-1)
149
150
150 def searchFiles(self, path, startDate, endDate, ext=None):
151 def searchFiles(self, path, startDate, endDate, ext=None):
151 '''
152 '''
152 Searching for BLTR rawdata file in path
153 Searching for BLTR rawdata file in path
153 Creating a list of file to proces included in [startDate,endDate]
154 Creating a list of file to proces included in [startDate,endDate]
154
155
155 Input:
156 Input:
156 path - Path to find BLTR rawdata files
157 path - Path to find BLTR rawdata files
157 startDate - Select file from this date
158 startDate - Select file from this date
158 enDate - Select file until this date
159 enDate - Select file until this date
159 ext - Extension of the file to read
160 ext - Extension of the file to read
160
161
161 '''
162 '''
162
163
163 fullpath = path
164 fullpath = path
164 foldercounter = 0
165 foldercounter = 0
165
166
166 print 'Searching file in %s ' % (fullpath)
167 print 'Searching file in %s ' % (fullpath)
167 fileList0 = glob.glob1(fullpath, "*%s" % ext)
168 fileList0 = glob.glob1(fullpath, "*%s" % ext)
168 fileList0.sort()
169 fileList0.sort()
169
170
170 self.fileList = []
171 self.fileList = []
171 self.dateFileList = []
172 self.dateFileList = []
172
173
173 for thisFile in fileList0:
174 for thisFile in fileList0:
174 year = thisFile[-14:-10]
175 year = thisFile[-14:-10]
175 if not isNumber(year):
176 if not isNumber(year):
176 continue
177 continue
177
178
178 month = thisFile[-10:-8]
179 month = thisFile[-10:-8]
179 if not isNumber(month):
180 if not isNumber(month):
180 continue
181 continue
181
182
182 day = thisFile[-8:-6]
183 day = thisFile[-8:-6]
183 if not isNumber(day):
184 if not isNumber(day):
184 continue
185 continue
185
186
186 year, month, day = int(year), int(month), int(day)
187 year, month, day = int(year), int(month), int(day)
187 dateFile = datetime.date(year, month, day)
188 dateFile = datetime.date(year, month, day)
188
189
189 if not ((startDate <= dateFile) and (endDate > dateFile)):
190 if not ((startDate <= dateFile) and (endDate > dateFile)):
190 continue
191 continue
191
192
192 self.fileList.append(thisFile)
193 self.fileList.append(thisFile)
193 self.dateFileList.append(dateFile)
194 self.dateFileList.append(dateFile)
194
195
195 return 1
196 return 1
196
197
197
198
198 def setNextFile(self):
199 def setNextFile(self):
199
200
200 idFile = self.fileIndex
201 idFile = self.fileIndex
201
202
202 while (True):
203 while (True):
203 idFile += 1
204 idFile += 1
204 if idFile >= len(self.fileList):
205 if idFile >= len(self.fileList):
205 print '\nNo more files in the folder'
206 print '\nNo more files in the folder'
206 print 'Total number of file(s) read : {}'.format(self.fileIndex + 1)
207 print 'Total number of file(s) read : {}'.format(self.fileIndex + 1)
207 print 'Time of processing : {}'.format(datetime.datetime.now()- self.hoy)
208 print 'Time of processing : {}'.format(datetime.datetime.now()- self.hoy)
208 self.flagNoMoreFiles = 1
209 self.flagNoMoreFiles = 1
209 return 0
210 return 0
210 if self.isConfig: print '------------------------[Next File]---------------------------'
211 if self.isConfig: print '------------------------[Next File]---------------------------'
211 filename = os.path.join(self.path, self.fileList[idFile])
212 filename = os.path.join(self.path, self.fileList[idFile])
212 self.Open(filename)
213 self.Open(filename)
213
214
214 print '\n[Setting file] (%s) ...' % self.fileList[idFile]
215 print '\n[Setting file] (%s) ...' % self.fileList[idFile]
215
216
216 break
217 break
217
218
218 self.flagIsNewFile =0
219 self.flagIsNewFile =0
219
220
220 self.fileIndex = idFile
221 self.fileIndex = idFile
221 self.filename = filename
222 self.filename = filename
222 print 'File:',self.filename
223 print 'File:',self.filename
223
224
224 return 1
225 return 1
225
226
226 def readDataBlock(self):
227 def readDataBlock(self):
227
228
228
229
229 self.readHeader()
230 self.readHeader()
230 self.dataRecords(0)
231 self.dataRecords(0)
231
232
232 print '[New Record] record: {} /{} // file {}/{}'.format(self.counter_records,self.nrecords,self.fileIndex+1,len(self.fileList))
233 print '[New Record] record: {} /{} // file {}/{}'.format(self.counter_records,self.nrecords,self.fileIndex+1,len(self.fileList))
233
234
234 self.setDataBuffer()
235 self.setDataBuffer()
235
236
236 self.flagIsNewBlock = 1
237 self.flagIsNewBlock = 1
237
238
238 if self.counter_records > self.nrecords:
239 if self.counter_records > self.nrecords:
239 self.flagIsNewFile = 1
240 self.flagIsNewFile = 1
240 return 0
241 return 0
241
242
242 return 1
243 return 1
243
244
244 def setDataBuffer(self):
245 def setDataBuffer(self):
245
246
246 '''
247 '''
247 Storing data from one block
248 Storing data from one block
248
249
249 '''
250 '''
250 self.t = datetime.datetime(self.year, self.month, self.day)
251 self.t = datetime.datetime(self.year, self.month, self.day)
251 self.doy = time.localtime(time.mktime(self.t.timetuple())).tm_yday
252 self.doy = time.localtime(time.mktime(self.t.timetuple())).tm_yday
252 self.buffer = numpy.squeeze(numpy.array([[self.one_snr],[self.one_zonal],[self.one_vertical],[self.one_meridional],
253 self.buffer = numpy.squeeze(numpy.array([[self.one_snr],[self.one_zonal],[self.one_vertical],[self.one_meridional],
253 [self.time],[self.height],[self.fileIndex],
254 [self.time],[self.height],[self.fileIndex],
254 [self.year],[self.month],[self.day],[self.t],[self.doy]]))
255 [self.year],[self.month],[self.day],[self.t],[self.doy]]))
255
256
256 self.dataOut.time1 = self.time1
257 self.dataOut.time1 = self.time1
257
258
258 def Open(self, filename):
259 def Open(self, filename):
259 '''
260 '''
260 Opening BLTR rawdata file defined by filename
261 Opening BLTR rawdata file defined by filename
261
262
262 Inputs:
263 Inputs:
263
264
264 filename - Full path name of BLTR rawdata file
265 filename - Full path name of BLTR rawdata file
265
266
266 '''
267 '''
267 [dir, name] = os.path.split(filename)
268 [dir, name] = os.path.split(filename)
268 strFile = name.split('.')
269 strFile = name.split('.')
269 self.siteFile = strFile[0] # 'peru2' ---> Piura - 'peru1' ---> Huancayo or Porcuya
270 self.siteFile = strFile[0] # 'peru2' ---> Piura - 'peru1' ---> Huancayo or Porcuya
270
271
271 self.filename = filename
272 self.filename = filename
272 if os.path.isfile(self.filename) == False:
273 if os.path.isfile(self.filename) == False:
273 print 'File do not exist. Check "filename"'
274 print 'File do not exist. Check "filename"'
274 sys.exit(0)
275 sys.exit(0)
275
276
276 self.h_file = numpy.dtype([
277 self.h_file = numpy.dtype([
277 ('FMN', '<u4'),
278 ('FMN', '<u4'),
278 ('nrec', '<u4'),
279 ('nrec', '<u4'),
279 ('fr_offset', '<u4'),
280 ('fr_offset', '<u4'),
280 ('id', '<u4'),
281 ('id', '<u4'),
281 ('site', 'u1', (32,))
282 ('site', 'u1', (32,))
282 ])
283 ])
283 self.pointer = open(self.filename, 'rb') # rb : Read Binary
284 self.pointer = open(self.filename, 'rb') # rb : Read Binary
284
285 print self.filename
285 self.header_file = numpy.fromfile(self.pointer, self.h_file, 1)
286 self.header_file = numpy.fromfile(self.pointer, self.h_file, 1)
286
287 print self.header_file
287 self.nrecords = self.header_file['nrec'][0]
288 self.nrecords = self.header_file['nrec'][0]
288
289
289 self.sizeOfFile = os.path.getsize(self.filename)
290 self.sizeOfFile = os.path.getsize(self.filename)
290
291
291 self.time = numpy.zeros([2, self.nrecords], dtype='u4')
292 self.time = numpy.zeros([2, self.nrecords], dtype='u4')
292 self.counter_records = 0
293 self.counter_records = 0
293 self.count = 0
294 self.count = 0
294 self.flag_initialArray = False
295 self.flag_initialArray = False
295
296
296 self.year = 0
297 self.year = 0
297 self.month = 0
298 self.month = 0
298 self.day = 0
299 self.day = 0
299
300
300 def hasNotDataInBuffer(self):
301 def hasNotDataInBuffer(self):
301
302
302 if self.buffer == None:
303 if self.buffer == None:
303 return 1
304 return 1
304 return 0
305 return 0
305
306
306 def getData(self):
307 def getData(self):
307 '''
308 '''
308 Storing data from databuffer to dataOut object
309 Storing data from databuffer to dataOut object
309
310
310 '''
311 '''
311 if self.flagNoMoreFiles==1:
312 if self.flagNoMoreFiles==1:
312 self.dataOut.flagNoData = True
313 self.dataOut.flagNoData = True
313 print 'No file left to process'
314 print 'No file left to process'
314 return 0
315 return 0
315
316
316 self.flagIsNewBlock = 0
317 self.flagIsNewBlock = 0
317
318
318 if self.hasNotDataInBuffer():
319 if self.hasNotDataInBuffer():
319
320
320 if self.flagIsNewFile==0:
321 if self.flagIsNewFile==0:
321
322
322 self.readNextBlock()
323 self.readNextBlock()
323 '''RETURN A BLOCK OF DATA'''
324 '''RETURN A BLOCK OF DATA'''
324 if self.flagNoMoreFiles==0:
325 if self.flagNoMoreFiles==0:
325 self.dataOut.data_SNR = self.buffer[0]
326 self.dataOut.data_SNR = self.buffer[0]
326 self.dataOut.time = self.buffer[4]
327 self.dataOut.time = self.buffer[4]
327 self.dataOut.height = self.height
328 self.dataOut.height = self.height
328
329
329 self.dataOut.height= self.height
330 self.dataOut.height= self.height
330 self.dataOut.data_output = numpy.squeeze(numpy.array([[self.buffer[1]],
331 self.dataOut.data_output = numpy.squeeze(numpy.array([[self.buffer[1]],
331 [self.buffer[3]],
332 [self.buffer[3]],
332 [self.buffer[2]]]))
333 [self.buffer[2]]]))
333
334
334 #
335 #
335
336
336 self.dataOut.day, self.dataOut.month, self.dataOut.year = self.buffer[9], self.buffer[8], self.buffer[7]
337 self.dataOut.day, self.dataOut.month, self.dataOut.year = self.buffer[9], self.buffer[8], self.buffer[7]
337
338
338 self.dataOut.utctimeInit = self.time1
339 self.dataOut.utctimeInit = self.time1
339 self.dataOut.utctime = self.dataOut.utctimeInit
340 self.dataOut.utctime = self.dataOut.utctimeInit
340 self.dataOut.counter_records = self.counter_records
341 self.dataOut.counter_records = self.counter_records
341 self.dataOut.nrecords = self.nrecords
342 self.dataOut.nrecords = self.nrecords
342
343
343 self.setHeader()
344 self.setHeader()
344
345
345 self.buffer = None
346 self.buffer = None
346 self.dataOut.flagNoData = False
347 self.dataOut.flagNoData = False
347
348
348 def readNextBlock(self):
349 def readNextBlock(self):
349
350
350 if not(self.setNewBlock()):
351 if not(self.setNewBlock()):
351 return 0
352 return 0
352
353
353 if not(self.readDataBlock()):
354 if not(self.readDataBlock()):
354 return 0
355 return 0
355
356
356 if self.flagIsNewFile:
357 if self.flagIsNewFile:
357 self.setNextFile()
358 self.setNextFile()
358
359
359 return 1
360 return 1
360
361
361 def setNewBlock(self):
362 def setNewBlock(self):
362
363
363 if self.pointer==None:
364 if self.pointer==None:
364 return 0
365 return 0
365
366
366 if self.flagIsNewFile:
367 if self.flagIsNewFile:
367 return 1
368 return 1
368
369
369 if self.counter_records < self.nrecords:
370 if self.counter_records < self.nrecords:
370 return 1
371 return 1
371
372
372 if not(self.setNextFile()):
373 if not(self.setNextFile()):
373 return 0
374 return 0
374
375
375 return 1
376 return 1
376
377
377 def readHeader(self):
378 def readHeader(self):
378 '''
379 '''
379 RecordHeader of BLTR rawdata file
380 RecordHeader of BLTR rawdata file
380 '''
381 '''
381 if self.pointer.tell() == self.sizeOfFile:
382 if self.pointer.tell() == self.sizeOfFile:
382 print 'End of File'
383 print 'End of File'
383 return
384 return
384
385
385 self.h_rec1 = numpy.dtype([
386 self.h_rec1 = numpy.dtype([
386 ('rmn', '<u4'),
387 ('rmn', '<u4'),
387 ('rcounter', '<u4'),
388 ('rcounter', '<u4'),
388 ('nr_offset', '<u4'),
389 ('nr_offset', '<u4'),
389 ('tr_offset', '<u4'),
390 ('tr_offset', '<u4'),
390 ('time', '<u4'),
391 ('time', '<u4'),
391 ('time_msec', '<u4'),
392 ('time_msec', '<u4'),
392 ('tag', 'u1', (32,)),
393 ('tag', 'u1', (32,)),
393 ('comments', 'u1', (32,)),
394 ('comments', 'u1', (32,)),
394 ('lat', '<f4'),
395 ('lat', '<f4'),
395 ('lon', '<f4'),
396 ('lon', '<f4'),
396 ('gps_status', '<u4'),
397 ('gps_status', '<u4'),
397 ('freq', '<u4'),
398 ('freq', '<u4'),
398 ('freq0', '<u4'),
399 ('freq0', '<u4'),
399 ('nchan', '<u4'),
400 ('nchan', '<u4'),
400 ('delta_r', '<u4'),
401 ('delta_r', '<u4'),
401 ('nranges', '<u4'),
402 ('nranges', '<u4'),
402 ('r0', '<u4'),
403 ('r0', '<u4'),
403 ('prf', '<u4'),
404 ('prf', '<u4'),
404 ('ncoh', '<u4'),
405 ('ncoh', '<u4'),
405 ('npoints', '<u4'),
406 ('npoints', '<u4'),
406 ('polarization', '<i4'),
407 ('polarization', '<i4'),
407 ('rx_filter', '<u4'),
408 ('rx_filter', '<u4'),
408 ('nmodes', '<u4'),
409 ('nmodes', '<u4'),
409 ('dmode_index', '<u4'),
410 ('dmode_index', '<u4'),
410 ('dmode_rngcorr', '<u4'),
411 ('dmode_rngcorr', '<u4'),
411 ('nrxs', '<u4'),
412 ('nrxs', '<u4'),
412 ('acf_length', '<u4'),
413 ('acf_length', '<u4'),
413 ('acf_lags', '<u4'),
414 ('acf_lags', '<u4'),
414 ('sea_to_atmos', '<f4'),
415 ('sea_to_atmos', '<f4'),
415 ('sea_notch', '<u4'),
416 ('sea_notch', '<u4'),
416 ('lh_sea', '<u4'),
417 ('lh_sea', '<u4'),
417 ('hh_sea', '<u4'),
418 ('hh_sea', '<u4'),
418 ('nbins_sea', '<u4'),
419 ('nbins_sea', '<u4'),
419 ('min_snr', '<f4'),
420 ('min_snr', '<f4'),
420 ('min_cc', '<f4'),
421 ('min_cc', '<f4'),
421 ('max_time_diff', '<f4')
422 ('max_time_diff', '<f4')
422 ])
423 ])
423
424
424 self.header_rec1 = numpy.fromfile(self.pointer, self.h_rec1, 1)
425 self.header_rec1 = numpy.fromfile(self.pointer, self.h_rec1, 1)
425 self.lat = self.header_rec1['lat'][0]
426 self.lat = self.header_rec1['lat'][0]
426 self.lon = self.header_rec1['lon'][0]
427 self.lon = self.header_rec1['lon'][0]
427 self.nchannels = self.header_rec1['nchan'][0] / 2
428 self.nchannels = self.header_rec1['nchan'][0] / 2
428 self.kchan = self.header_rec1['nrxs'][0]
429 self.kchan = self.header_rec1['nrxs'][0]
429 self.nranges = self.header_rec1['nranges'][0]
430 self.nranges = self.header_rec1['nranges'][0]
430 self.deltha = self.header_rec1['delta_r'][0]
431 self.deltha = self.header_rec1['delta_r'][0]
431
432
432 self.correction = self.header_rec1['dmode_rngcorr'][0]
433 self.correction = self.header_rec1['dmode_rngcorr'][0]
433 self.nmodes = self.header_rec1['nmodes'][0]
434 self.nmodes = self.header_rec1['nmodes'][0]
434 self.imode = self.header_rec1['dmode_index'][0]
435 self.imode = self.header_rec1['dmode_index'][0]
435
436
436 self.h_rec2 = numpy.dtype([
437 self.h_rec2 = numpy.dtype([
437 ('antenna_coord', 'f4', (2, self.nchannels)),
438 ('antenna_coord', 'f4', (2, self.nchannels)),
438 ('rx_gains', 'u4', (self.nchannels,)),
439 ('rx_gains', 'u4', (self.nchannels,)),
439 ('rx_analysis', 'u4', (self.nchannels,))
440 ('rx_analysis', 'u4', (self.nchannels,))
440 ])
441 ])
441
442
442 self.header_rec2 = numpy.fromfile(self.pointer, self.h_rec2, 1) # header rec2
443 self.header_rec2 = numpy.fromfile(self.pointer, self.h_rec2, 1) # header rec2
443 self.antenna = self.header_rec2['antenna_coord']
444 self.antenna = self.header_rec2['antenna_coord']
444 self.rx_gains = self.header_rec2['rx_gains']
445 self.rx_gains = self.header_rec2['rx_gains']
445
446
446 self.d_rec = numpy.dtype ([
447 self.d_rec = numpy.dtype ([
447 ('range', '<u4'),
448 ('range', '<u4'),
448 ('status', '<u4'),
449 ('status', '<u4'),
449 ('zonal', '<f4'),
450 ('zonal', '<f4'),
450 ('meridional', '<f4'),
451 ('meridional', '<f4'),
451 ('vertical', '<f4'),
452 ('vertical', '<f4'),
452 ('zonal_a', '<f4'),
453 ('zonal_a', '<f4'),
453 ('meridional_a', '<f4'),
454 ('meridional_a', '<f4'),
454 ('corrected_fading', '<f4'), # seconds
455 ('corrected_fading', '<f4'), # seconds
455 ('uncorrected_fading', '<f4'), # seconds
456 ('uncorrected_fading', '<f4'), # seconds
456 ('time_diff', '<f4'),
457 ('time_diff', '<f4'),
457 ('major_axis', '<f4'),
458 ('major_axis', '<f4'),
458 ('axial_ratio', '<f4'),
459 ('axial_ratio', '<f4'),
459 ('orientation', '<f4'),
460 ('orientation', '<f4'),
460 ('sea_power', '<u4'),
461 ('sea_power', '<u4'),
461 ('sea_algorithm', '<u4'),
462 ('sea_algorithm', '<u4'),
462 ('rx_saturation', 'u4', (self.nchannels,)),
463 ('rx_saturation', 'u4', (self.nchannels,)),
463 ('chan_offset', 'u4', (2 * self.nchannels,)),
464 ('chan_offset', 'u4', (2 * self.nchannels,)),
464 ('rx_amp', 'u4', (self.nchannels,)),
465 ('rx_amp', 'u4', (self.nchannels,)),
465 ('rx_snr', 'f4', (self.nchannels,)),
466 ('rx_snr', 'f4', (self.nchannels,)),
466 ('cross_snr', 'f4', (self.kchan,)),
467 ('cross_snr', 'f4', (self.kchan,)),
467 ('sea_power_relative', 'f4', (self.kchan,))
468 ('sea_power_relative', 'f4', (self.kchan,))
468 ])
469 ])
469
470
470 # Memory allocation
471 # Memory allocation
471 if not(self.flag_initialArray):
472 if not(self.flag_initialArray):
472 self.height = numpy.zeros([2, self.nranges], dtype='f4') + numpy.nan
473 self.height = numpy.zeros([2, self.nranges], dtype='f4') + numpy.nan
473 self.p_zonal = numpy.zeros([self.nrecords, self.nranges, 2], dtype='f4') + numpy.nan
474 self.p_zonal = numpy.zeros([self.nrecords, self.nranges, 2], dtype='f4') + numpy.nan
474 self.p_meridional = numpy.zeros([self.nrecords, self.nranges, 2], dtype='f4') + numpy.nan
475 self.p_meridional = numpy.zeros([self.nrecords, self.nranges, 2], dtype='f4') + numpy.nan
475 self.p_vertical = numpy.zeros([self.nrecords, self.nranges, 2], dtype='f4') + numpy.nan
476 self.p_vertical = numpy.zeros([self.nrecords, self.nranges, 2], dtype='f4') + numpy.nan
476 self.p_snr = numpy.zeros([self.nrecords, self.nranges, self.kchan, 2], dtype='f4') + numpy.nan
477 self.p_snr = numpy.zeros([self.nrecords, self.nranges, self.kchan, 2], dtype='f4') + numpy.nan
477 self.flag_initialArray = True
478 self.flag_initialArray = True
478
479
479 self.time[self.imode, self.count] = self.header_rec1['time'][0]
480 self.time[self.imode, self.count] = self.header_rec1['time'][0]
480 self.time1 = self.header_rec1['time'][0]
481 self.time1 = self.header_rec1['time'][0]
481 tseconds = self.header_rec1['time'][0]
482 tseconds = self.header_rec1['time'][0]
482 local_t1 = time.localtime(tseconds)
483 local_t1 = time.localtime(tseconds)
483 self.year = local_t1.tm_year
484 self.year = local_t1.tm_year
484 self.month = local_t1.tm_mon
485 self.month = local_t1.tm_mon
485 self.day = local_t1.tm_mday
486 self.day = local_t1.tm_mday
486 self.t = datetime.datetime(self.year, self.month, self.day)
487 self.t = datetime.datetime(self.year, self.month, self.day)
487
488
488
489
489 def setHeader(self):
490 def setHeader(self):
490 '''
491 '''
491 Saving metada on dataOut object
492 Saving metada on dataOut object
492
493
493 '''
494 '''
494 self.dataOut.type = 'Parameters'
495 self.dataOut.type = 'Parameters'
495 self.dataOut.useLocalTime = False
496 self.dataOut.useLocalTime = False
496 self.dataOut.outputInterval = 157
497 # self.dataOut.outputInterval = 157
498 self.dataOut.paramInterval = 157
497 self.dataOut.timezone = self.timezone
499 self.dataOut.timezone = self.timezone
498 self.dataOut.site = self.siteFile
500 self.dataOut.site = self.siteFile
499 self.dataOut.nrecords = self.nrecords
501 self.dataOut.nrecords = self.nrecords
500 self.dataOut.sizeOfFile = self.sizeOfFile
502 self.dataOut.sizeOfFile = self.sizeOfFile
501 self.dataOut.lat = self.lat
503 self.dataOut.lat = self.lat
502 self.dataOut.lon = self.lon
504 self.dataOut.lon = self.lon
503 self.dataOut.nchannels = self.nchannels
505 self.dataOut.nchannels = self.nchannels
504 self.dataOut.kchan = self.kchan
506 self.dataOut.kchan = self.kchan
505 self.dataOut.nranges = self.nranges
507 self.dataOut.nranges = self.nranges
506 self.dataOut.deltha = self.deltha
508 self.dataOut.deltha = self.deltha
507 self.dataOut.correction = self.correction
509 self.dataOut.correction = self.correction
508 self.dataOut.nmodes = self.nmodes
510 self.dataOut.nmodes = self.nmodes
509 self.dataOut.imode = self.imode
511 self.dataOut.imode = self.imode
510 self.dataOut.antenna = self.antenna
512 self.dataOut.antenna = self.antenna
511 self.dataOut.rx_gains = self.rx_gains
513 self.dataOut.rx_gains = self.rx_gains
512
514
513 def dataRecords(self, status_value):
515 def dataRecords(self, status_value):
514 '''
516 '''
515 Reading and filtering data block record of BLTR rawdata file, filtering is according to status_value.
517 Reading and filtering data block record of BLTR rawdata file, filtering is according to status_value.
516
518
517 Input:
519 Input:
518 status_value - Array data is set to NAN for values that are not equal to status_value
520 status_value - Array data is set to NAN for values that are not equal to status_value
519
521
520 '''
522 '''
521 data_rec = numpy.fromfile(self.pointer, self.d_rec, self.nranges)
523 data_rec = numpy.fromfile(self.pointer, self.d_rec, self.nranges)
522 status = []
524 status = []
523 zonal = []
525 zonal = []
524 meridional = []
526 meridional = []
525 vertical = []
527 vertical = []
526 rx_snr = []
528 rx_snr = []
527
529
528 index = 0
530 index = 0
529 for rec in data_rec:
531 for rec in data_rec:
530 status.append(rec['status'])
532 status.append(rec['status'])
531 zonal.append(rec['zonal'])
533 zonal.append(rec['zonal'])
532 meridional.append(rec['meridional'])
534 meridional.append(rec['meridional'])
533 vertical.append(rec['vertical'])
535 vertical.append(rec['vertical'])
534 self.height[self.imode, index] = (rec['range'] - self.correction) / 1000.
536 self.height[self.imode, index] = (rec['range'] - self.correction) / 1000.
535 numpy.seterr(all='ignore')
537 numpy.seterr(all='ignore')
536 index = index + 1
538 index = index + 1
537 rx_snr.append(rec['rx_snr'])
539 rx_snr.append(rec['rx_snr'])
538
540
539 status = numpy.array(status, dtype='int')
541 status = numpy.array(status, dtype='int')
540 zonal = numpy.array(zonal, dtype='float')
542 zonal = numpy.array(zonal, dtype='float')
541 meridional = numpy.array(meridional, dtype='float')
543 meridional = numpy.array(meridional, dtype='float')
542 vertical = numpy.array(vertical, dtype='float')
544 vertical = numpy.array(vertical, dtype='float')
543 rx_snr = numpy.array(rx_snr, dtype='float')
545 rx_snr = numpy.array(rx_snr, dtype='float')
544
546
545
547
546
548
547 rx_snr = rx_snr.reshape((self.nranges, self.nchannels))
549 rx_snr = rx_snr.reshape((self.nranges, self.nchannels))
548
550
549 # FILTERING DATA
551 # FILTERING DATA
550 stvalue = status_value
552 stvalue = status_value
551 zonal[numpy.where(zonal == -9999.)] = numpy.nan
553 zonal[numpy.where(zonal == -9999.)] = numpy.nan
552 zonal[numpy.where(status != stvalue)] = numpy.nan
554 zonal[numpy.where(status != stvalue)] = numpy.nan
553 self.p_zonal[self.count, :, self.imode] = zonal
555 self.p_zonal[self.count, :, self.imode] = zonal
554 self.one_zonal= self.p_zonal[self.count, :, :]
556 self.one_zonal= self.p_zonal[self.count, :, :]
555
557
556 meridional[numpy.where(meridional == -9999.)] = numpy.nan
558 meridional[numpy.where(meridional == -9999.)] = numpy.nan
557 meridional[numpy.where(status != stvalue)] = numpy.nan
559 meridional[numpy.where(status != stvalue)] = numpy.nan
558 self.p_meridional[self.count, :, self.imode] = meridional
560 self.p_meridional[self.count, :, self.imode] = meridional
559 self.one_meridional = self.p_meridional[self.count, :, :]
561 self.one_meridional = self.p_meridional[self.count, :, :]
560
562
561 vertical[numpy.where(vertical == -9999.)] = numpy.nan
563 vertical[numpy.where(vertical == -9999.)] = numpy.nan
562 vertical[numpy.where(status != stvalue)] = numpy.nan
564 vertical[numpy.where(status != stvalue)] = numpy.nan
563 self.p_vertical[self.count, :, self.imode] = vertical
565 self.p_vertical[self.count, :, self.imode] = vertical
564 self.one_vertical = self.p_vertical[self.count, :, :]
566 self.one_vertical = self.p_vertical[self.count, :, :]
565
567
566 rx_snr[numpy.where(rx_snr == -9999.)] = numpy.nan
568 rx_snr[numpy.where(rx_snr == -9999.)] = numpy.nan
567 rx_snr[numpy.where(status != stvalue), :] = numpy.nan
569 rx_snr[numpy.where(status != stvalue), :] = numpy.nan
568
570
569
571
570 for k in range(self.kchan):
572 for k in range(self.kchan):
571 self.p_snr[self.count, :, k, self.imode] = numpy.power(10, rx_snr[:, k] / 10)
573 self.p_snr[self.count, :, k, self.imode] = numpy.power(10, rx_snr[:, k] / 10)
572
574
573 self.one_snr = self.p_snr[self.count, :, :, :]
575 self.one_snr = self.p_snr[self.count, :, :, :]
574 if self.nmodes == 2:
576 if self.nmodes == 2:
575 self.count = self.count + self.imode
577 self.count = self.count + self.imode
576 else:
578 else:
577 self.count = self.count + 1
579 self.count = self.count + 1
578
580
579 self.imode +=1
581 self.imode +=1
580 self.counter_records = self.counter_records + 1
582 self.counter_records = self.counter_records + 1
581
583
582 self.zon_ref = self.p_zonal
584 self.zon_ref = self.p_zonal
583 self.ver_ref = self.p_vertical
585 self.ver_ref = self.p_vertical
584 self.mer_ref = self.p_meridional
586 self.mer_ref = self.p_meridional
585 self.snr_ref = self.p_snr
587 self.snr_ref = self.p_snr
586
588
587
589
588
590
589
591
590 def Close (self):
592 def Close (self):
591 '''
593 '''
592 Closing BLTR rawdata file
594 Closing BLTR rawdata file
593 '''
595 '''
594 if self.pointer.tell() == self.sizeOfFile:
596 if self.pointer.tell() == self.sizeOfFile:
595 self.pointer.close()
597 self.pointer.close()
596 return
598 return
597
599
598
600
599
601
600 class testBLTRWriter(Operation):
602 class testBLTRWriter(Operation):
601
603
602
604
603 def __init__(self):
605 def __init__(self):
604
606
605 Operation.__init__(self)
607 Operation.__init__(self)
606 self.dataOut = Parameters()
608 self.dataOut = Parameters()
607 self.path = None
609 self.path = None
608 self.dataOut = None
610 self.dataOut = None
609 self.flagIsNewFile=1
611 self.flagIsNewFile=1
610 self.ext = ".hdf5"
612 self.ext = ".hdf5"
611
613
612 return
614 return
613
615
614 def run(self, dataOut, path , modetowrite,**kwargs):
616 def run(self, dataOut, path , modetowrite,**kwargs):
615
617
616 if self.flagIsNewFile:
618 if self.flagIsNewFile:
617 flagdata = self.setup(dataOut, path, modetowrite)
619 flagdata = self.setup(dataOut, path, modetowrite)
618
620
619 self.putData()
621 self.putData()
620 return
622 return
621
623
622 def setup(self, dataOut, path, modetowrite):
624 def setup(self, dataOut, path, modetowrite):
623 '''
625 '''
624 Recovering data to write in new *.hdf5 file
626 Recovering data to write in new *.hdf5 file
625 Inputs:
627 Inputs:
626 modew -- mode to write (1 or 2)
628 modew -- mode to write (1 or 2)
627 path -- destination path
629 path -- destination path
628
630
629 '''
631 '''
630
632
631 self.im = modetowrite-1
633 self.im = modetowrite-1
632 if self.im!=0 and self.im!=1:
634 if self.im!=0 and self.im!=1:
633 raise ValueError, 'Check "modetowrite" value. Must be egual to 1 or 2, "{}" is not valid. '.format(modetowrite)
635 raise ValueError, 'Check "modetowrite" value. Must be egual to 1 or 2, "{}" is not valid. '.format(modetowrite)
634
636
635 self.dataOut = dataOut
637 self.dataOut = dataOut
636 self.nmodes = self.dataOut.nmodes
638 self.nmodes = self.dataOut.nmodes
637 self.nchannels = self.dataOut.nchannels
639 self.nchannels = self.dataOut.nchannels
638 self.lat = self.dataOut.lat
640 self.lat = self.dataOut.lat
639 self.lon = self.dataOut.lon
641 self.lon = self.dataOut.lon
640 self.hcm = 3
642 self.hcm = 3
641 self.thisDate = self.dataOut.utctimeInit
643 self.thisDate = self.dataOut.utctimeInit
642 self.year = self.dataOut.year
644 self.year = self.dataOut.year
643 self.month = self.dataOut.month
645 self.month = self.dataOut.month
644 self.day = self.dataOut.day
646 self.day = self.dataOut.day
645 self.path = path
647 self.path = path
646
648
647 self.flagIsNewFile = 0
649 self.flagIsNewFile = 0
648
650
649 return 1
651 return 1
650
652
651 def setFile(self):
653 def setFile(self):
652 '''
654 '''
653 - Determining the file name for each mode of operation
655 - Determining the file name for each mode of operation
654 kinst - Kind of Instrument (mnemotic)
656 kinst - Kind of Instrument (mnemotic)
655 kindat - Kind of Data (mnemotic)
657 kindat - Kind of Data (mnemotic)
656
658
657 - Creating a cedarObject
659 - Creating a cedarObject
658
660
659 '''
661 '''
660 lat_piura = -5.17
662 lat_piura = -5.17
661 lat_huancayo = -12.04
663 lat_huancayo = -12.04
662 lat_porcuya = -5.8
664 lat_porcuya = -5.8
663
665
664 if '%2.2f' % self.lat == '%2.2f' % lat_piura:
666 if '%2.2f' % self.lat == '%2.2f' % lat_piura:
665 self.instMnemonic = 'pbr'
667 self.instMnemonic = 'pbr'
666
668
667 elif '%2.2f' % self.lat == '%2.2f' % lat_huancayo:
669 elif '%2.2f' % self.lat == '%2.2f' % lat_huancayo:
668 self.instMnemonic = 'hbr'
670 self.instMnemonic = 'hbr'
669
671
670 elif '%2.2f' % self.lat == '%2.2f' % lat_porcuya:
672 elif '%2.2f' % self.lat == '%2.2f' % lat_porcuya:
671 self.instMnemonic = 'obr'
673 self.instMnemonic = 'obr'
672 else: raise Warning, "The site of file read doesn't match any site known. Only file from Huancayo, Piura and Porcuya can be processed.\n Check the file "
674 else: raise Warning, "The site of file read doesn't match any site known. Only file from Huancayo, Piura and Porcuya can be processed.\n Check the file "
673
675
674 mode = ['_mode1','_mode2']
676 mode = ['_mode1','_mode2']
675
677
676 self.hdf5filename = '%s%4.4d%2.2d%2.2d%s%s' % (self.instMnemonic,
678 self.hdf5filename = '%s%4.4d%2.2d%2.2d%s%s' % (self.instMnemonic,
677 self.year,
679 self.year,
678 self.month,
680 self.month,
679 self.day,
681 self.day,
680 mode[self.im],
682 mode[self.im],
681 self.ext)
683 self.ext)
682
684
683 self.fullname=os.path.join(self.path,self.hdf5filename)
685 self.fullname=os.path.join(self.path,self.hdf5filename)
684
686
685 if os.path.isfile(self.fullname) :
687 if os.path.isfile(self.fullname) :
686 print "Destination path '%s' already exists. Previous file deleted. " %self.fullname
688 print "Destination path '%s' already exists. Previous file deleted. " %self.fullname
687 os.remove(self.fullname)
689 os.remove(self.fullname)
688
690
689 # Identify kinst and kindat
691 # Identify kinst and kindat
690 InstName = self.hdf5filename[0:3]
692 InstName = self.hdf5filename[0:3]
691 KinstList = [1000, 1001, 1002]
693 KinstList = [1000, 1001, 1002]
692 KinstId = {'pbr':0, 'hbr':1, 'obr':2} # pbr:piura, hbr:huancayo, obr:porcuya
694 KinstId = {'pbr':0, 'hbr':1, 'obr':2} # pbr:piura, hbr:huancayo, obr:porcuya
693 KindatList = [1600, 1601] # mode 1, mode 2
695 KindatList = [1600, 1601] # mode 1, mode 2
694 self.type = KinstId[InstName]
696 self.type = KinstId[InstName]
695 self.kinst = KinstList[self.type]
697 self.kinst = KinstList[self.type]
696 self.kindat = KindatList[self.im]
698 self.kindat = KindatList[self.im]
697
699
698 try:
700 try:
699 self.cedarObj = madrigal.cedar.MadrigalCedarFile(self.fullname, True)
701 self.cedarObj = madrigal.cedar.MadrigalCedarFile(self.fullname, True)
700 except ValueError, message:
702 except ValueError, message:
701 print '[Error]: Impossible to create a cedar object with "madrigal.cedar.MadrigalCedarFile" '
703 print '[Error]: Impossible to create a cedar object with "madrigal.cedar.MadrigalCedarFile" '
702 return
704 return
703
705
704 return 1
706 return 1
705
707
706 def writeBlock(self):
708 def writeBlock(self):
707 '''
709 '''
708 - Selecting mode of operation:
710 - Selecting mode of operation:
709
711
710 bltr high resolution mode 1 - Low Atmosphere (0 - 3km) // bltr high resolution mode 2 - High Atmosphere (0 - 10km)
712 bltr high resolution mode 1 - Low Atmosphere (0 - 3km) // bltr high resolution mode 2 - High Atmosphere (0 - 10km)
711 msnr - Average Signal Noise Ratio in dB
713 msnr - Average Signal Noise Ratio in dB
712 hcm - 3 km
714 hcm - 3 km
713
715
714 - Filling the cedarObject by a block: each array data entry is assigned a code that defines the parameter to write to the file
716 - Filling the cedarObject by a block: each array data entry is assigned a code that defines the parameter to write to the file
715
717
716 GDLATR - Reference geod latitude (deg)
718 GDLATR - Reference geod latitude (deg)
717 GDLONR - Reference geographic longitude (deg)
719 GDLONR - Reference geographic longitude (deg)
718 GDLAT2 - Geodetic latitude of second inst (deg)
720 GDLAT2 - Geodetic latitude of second inst (deg)
719 GLON2 - Geographic longitude of second inst (deg)
721 GLON2 - Geographic longitude of second inst (deg)
720
722
721 GDALT - Geodetic altitude (height) (km)
723 GDALT - Geodetic altitude (height) (km)
722 SNL - Log10 (signal to noise ratio)
724 SNL - Log10 (signal to noise ratio)
723 VN1P2 - Neutral wind in direction 1 (eastward) (m/s), ie zonal wind
725 VN1P2 - Neutral wind in direction 1 (eastward) (m/s), ie zonal wind
724 VN2P2 - Neutral wind in direction 2 (northward) (m/s), ie meridional wind
726 VN2P2 - Neutral wind in direction 2 (northward) (m/s), ie meridional wind
725 EL2 - Ending elevation angle (deg), ie vertical wind
727 EL2 - Ending elevation angle (deg), ie vertical wind
726
728
727 Other parameters: /madrigal3/metadata/parcodes.tab
729 Other parameters: /madrigal3/metadata/parcodes.tab
728
730
729 '''
731 '''
730
732
731 self.z_zon = self.dataOut.data_output[0,:,:]
733 self.z_zon = self.dataOut.data_output[0,:,:]
732 self.z_mer =self.dataOut.data_output[1,:,:]
734 self.z_mer =self.dataOut.data_output[1,:,:]
733 self.z_ver = self.dataOut.data_output[2,:,:]
735 self.z_ver = self.dataOut.data_output[2,:,:]
734
736
735 if self.im == 0:
737 if self.im == 0:
736 h_select = numpy.where(numpy.bitwise_and(self.dataOut.height[0, :] >= 0., self.dataOut.height[0, :] <= self.hcm, numpy.isfinite(self.dataOut.height[0, :])))
738 h_select = numpy.where(numpy.bitwise_and(self.dataOut.height[0, :] >= 0., self.dataOut.height[0, :] <= self.hcm, numpy.isfinite(self.dataOut.height[0, :])))
737 else:
739 else:
738 h_select = numpy.where(numpy.bitwise_and(self.dataOut.height[0, :] >= 0., self.dataOut.height[0, :] < 20, numpy.isfinite(self.dataOut.height[0, :])))
740 h_select = numpy.where(numpy.bitwise_and(self.dataOut.height[0, :] >= 0., self.dataOut.height[0, :] < 20, numpy.isfinite(self.dataOut.height[0, :])))
739
741
740 ht = h_select[0]
742 ht = h_select[0]
741
743
742 self.o_height = self.dataOut.height[self.im, ht]
744 self.o_height = self.dataOut.height[self.im, ht]
743 self.o_zon = self.z_zon[ht, self.im]
745 self.o_zon = self.z_zon[ht, self.im]
744 self.o_mer = self.z_mer[ht, self.im]
746 self.o_mer = self.z_mer[ht, self.im]
745 self.o_ver = self.z_ver[ht, self.im]
747 self.o_ver = self.z_ver[ht, self.im]
746 o_snr = self.dataOut.data_SNR[ :, :, self.im]
748 o_snr = self.dataOut.data_SNR[ :, :, self.im]
747
749
748 o_snr = o_snr[ht, :]
750 o_snr = o_snr[ht, :]
749
751
750 ndiv = numpy.nansum((numpy.isfinite(o_snr)), 1)
752 ndiv = numpy.nansum((numpy.isfinite(o_snr)), 1)
751 ndiv = ndiv.astype(float)
753 ndiv = ndiv.astype(float)
752
754
753 sel_div = numpy.where(ndiv == 0.)
755 sel_div = numpy.where(ndiv == 0.)
754 ndiv[sel_div] = numpy.nan
756 ndiv[sel_div] = numpy.nan
755
757
756 if self.nchannels > 1:
758 if self.nchannels > 1:
757 msnr = numpy.nansum(o_snr, axis=1)
759 msnr = numpy.nansum(o_snr, axis=1)
758 else:
760 else:
759 msnr = o_snr
761 msnr = o_snr
760
762
761 try:
763 try:
762 self.msnr = 10 * numpy.log10(msnr / ndiv)
764 self.msnr = 10 * numpy.log10(msnr / ndiv)
763 except ZeroDivisionError:
765 except ZeroDivisionError:
764 self.msnr = 10 * numpy.log10(msnr /1)
766 self.msnr = 10 * numpy.log10(msnr /1)
765 print 'Number of division (ndiv) egal to 1 by default. Check SNR'
767 print 'Number of division (ndiv) egal to 1 by default. Check SNR'
766
768
767 time_t = time.gmtime(self.dataOut.time1)
769 time_t = time.gmtime(self.dataOut.time1)
768 year = time_t.tm_year
770 year = time_t.tm_year
769 month = time_t.tm_mon
771 month = time_t.tm_mon
770 day = time_t.tm_mday
772 day = time_t.tm_mday
771 hour = time_t.tm_hour
773 hour = time_t.tm_hour
772 minute = time_t.tm_min
774 minute = time_t.tm_min
773 second = time_t.tm_sec
775 second = time_t.tm_sec
774 timedate_0 = datetime.datetime(year, month, day, hour, minute, second)
776 timedate_0 = datetime.datetime(year, month, day, hour, minute, second)
775
777
776 # 1d parameters
778 # 1d parameters
777 GDLATR = self.lat
779 GDLATR = self.lat
778 GDLONR = self.lon
780 GDLONR = self.lon
779 GDLAT2 = self.lat
781 GDLAT2 = self.lat
780 GLON2 = self.lon
782 GLON2 = self.lon
781
783
782 # 2d parameters
784 # 2d parameters
783 GDALT = self.o_height
785 GDALT = self.o_height
784
786
785 SNL = self.msnr
787 SNL = self.msnr
786 VN1P2 = self.o_zon
788 VN1P2 = self.o_zon
787 VN2P2 = self.o_mer
789 VN2P2 = self.o_mer
788 EL2 = self.o_ver
790 EL2 = self.o_ver
789 NROW = len(self.o_height)
791 NROW = len(self.o_height)
790
792
791 startTime = timedate_0
793 startTime = timedate_0
792 endTime = startTime
794 endTime = startTime
793 self.dataRec = madrigal.cedar.MadrigalDataRecord(self.kinst,
795 self.dataRec = madrigal.cedar.MadrigalDataRecord(self.kinst,
794 self.kindat,
796 self.kindat,
795 startTime.year,
797 startTime.year,
796 startTime.month,
798 startTime.month,
797 startTime.day,
799 startTime.day,
798 startTime.hour,
800 startTime.hour,
799 startTime.minute,
801 startTime.minute,
800 startTime.second,
802 startTime.second,
801 0,
803 0,
802 endTime.year,
804 endTime.year,
803 endTime.month,
805 endTime.month,
804 endTime.day,
806 endTime.day,
805 endTime.hour,
807 endTime.hour,
806 endTime.minute,
808 endTime.minute,
807 endTime.second,
809 endTime.second,
808 0,
810 0,
809 ('gdlatr', 'gdlonr', 'gdlat2', 'glon2'),
811 ('gdlatr', 'gdlonr', 'gdlat2', 'glon2'),
810 ('gdalt', 'snl', 'vn1p2', 'vn2p2', 'el2'),
812 ('gdalt', 'snl', 'vn1p2', 'vn2p2', 'el2'),
811 NROW, ind2DList=['gdalt'])
813 NROW, ind2DList=['gdalt'])
812
814
813 # Setting 1d values
815 # Setting 1d values
814 self.dataRec.set1D('gdlatr', GDLATR)
816 self.dataRec.set1D('gdlatr', GDLATR)
815 self.dataRec.set1D('gdlonr', GDLONR)
817 self.dataRec.set1D('gdlonr', GDLONR)
816 self.dataRec.set1D('gdlat2', GDLAT2)
818 self.dataRec.set1D('gdlat2', GDLAT2)
817 self.dataRec.set1D('glon2', GLON2)
819 self.dataRec.set1D('glon2', GLON2)
818
820
819 # Setting 2d values
821 # Setting 2d values
820 for n in range(self.o_height.shape[0]):
822 for n in range(self.o_height.shape[0]):
821 self.dataRec.set2D('gdalt', n, GDALT[n])
823 self.dataRec.set2D('gdalt', n, GDALT[n])
822 self.dataRec.set2D('snl', n, SNL[n])
824 self.dataRec.set2D('snl', n, SNL[n])
823 self.dataRec.set2D('vn1p2', n, VN1P2[n])
825 self.dataRec.set2D('vn1p2', n, VN1P2[n])
824 self.dataRec.set2D('vn2p2', n, VN2P2[n])
826 self.dataRec.set2D('vn2p2', n, VN2P2[n])
825 self.dataRec.set2D('el2', n, EL2[n])
827 self.dataRec.set2D('el2', n, EL2[n])
826
828
827 # Appending new data record
829 # Appending new data record
828 '''
830 '''
829 [MADRIGAL3]There are two ways to write to a MadrigalCedarFile. Either this method (write) is called after all the
831 [MADRIGAL3]There are two ways to write to a MadrigalCedarFile. Either this method (write) is called after all the
830 records have been appended to the MadrigalCedarFile, or dump is called after a certain number of records are appended,
832 records have been appended to the MadrigalCedarFile, or dump is called after a certain number of records are appended,
831 and then at the end dump is called a final time if there were any records not yet dumped, followed by addArray.
833 and then at the end dump is called a final time if there were any records not yet dumped, followed by addArray.
832 '''
834 '''
833
835
834 self.cedarObj.append(self.dataRec)
836 self.cedarObj.append(self.dataRec)
835 print ' [Writing] records {} (mode {}).'.format(self.dataOut.counter_records,self.im+1)
837 print ' [Writing] records {} (mode {}).'.format(self.dataOut.counter_records,self.im+1)
836 self.cedarObj.dump()
838 self.cedarObj.dump()
837
839
838
840
839
841
840
842
841 def setHeader(self):
843 def setHeader(self):
842 '''
844 '''
843 - Creating self.catHeadObj
845 - Creating self.catHeadObj
844 - Adding information catalog
846 - Adding information catalog
845 - Writing file header
847 - Writing file header
846
848
847 '''
849 '''
848 self.catHeadObj = madrigal.cedar.CatalogHeaderCreator(self.fullname)
850 self.catHeadObj = madrigal.cedar.CatalogHeaderCreator(self.fullname)
849 kindatDesc, comments, analyst, history, principleInvestigator = self._info_BLTR()
851 kindatDesc, comments, analyst, history, principleInvestigator = self._info_BLTR()
850
852
851 self.catHeadObj.createCatalog(principleInvestigator="Jarjar",
853 self.catHeadObj.createCatalog(principleInvestigator="Jarjar",
852 expPurpose='characterize the atmospheric dynamics in this region where frequently it happens the El Nino',
854 expPurpose='characterize the atmospheric dynamics in this region where frequently it happens the El Nino',
853 sciRemarks="http://madrigal3.haystack.mit.edu/static/CEDARMadrigalHdf5Format.pdf")
855 sciRemarks="http://madrigal3.haystack.mit.edu/static/CEDARMadrigalHdf5Format.pdf")
854
856
855 self.catHeadObj.createHeader(kindatDesc, analyst, comments, history)
857 self.catHeadObj.createHeader(kindatDesc, analyst, comments, history)
856
858
857 self.catHeadObj.write()
859 self.catHeadObj.write()
858
860
859 print '[File created] path: %s' % (self.fullname)
861 print '[File created] path: %s' % (self.fullname)
860
862
861 def putData(self):
863 def putData(self):
862
864
863 if self.dataOut.flagNoData:
865 if self.dataOut.flagNoData:
864 return 0
866 return 0
865
867
866 if self.dataOut.counter_records == 1:
868 if self.dataOut.counter_records == 1:
867 self.setFile()
869 self.setFile()
868 print '[Writing] Setting new hdf5 file for the mode {}'.format(self.im+1)
870 print '[Writing] Setting new hdf5 file for the mode {}'.format(self.im+1)
869
871
870 if self.dataOut.counter_records <= self.dataOut.nrecords:
872 if self.dataOut.counter_records <= self.dataOut.nrecords:
871 self.writeBlock()
873 self.writeBlock()
872
874
873
875
874 if self.dataOut.counter_records == self.dataOut.nrecords:
876 if self.dataOut.counter_records == self.dataOut.nrecords:
875 self.cedarObj.addArray()
877 self.cedarObj.addArray()
876
878
877 self.setHeader()
879 self.setHeader()
878 self.flagIsNewFile = 1
880 self.flagIsNewFile = 1
879
881
880 def _info_BLTR(self):
882 def _info_BLTR(self):
881
883
882 kindatDesc = '''--This header is for KINDAT = %d''' % self.kindat
884 kindatDesc = '''--This header is for KINDAT = %d''' % self.kindat
883 history = None
885 history = None
884 analyst = '''Jarjar'''
886 analyst = '''Jarjar'''
885 principleInvestigator = '''
887 principleInvestigator = '''
886 Jarjar
888 Jarjar
887 Radio Observatorio de Jicamarca
889 Radio Observatorio de Jicamarca
888 Instituto Geofisico del Peru
890 Instituto Geofisico del Peru
889
891
890 '''
892 '''
891 if self.type == 1:
893 if self.type == 1:
892 comments = '''
894 comments = '''
893
895
894 --These data are provided by two Boundary Layer and Tropospheric Radar (BLTR) deployed at two different locations at Peru(GMT-5), one of them at Piura(5.17 S, 80.64W) and another located at Huancayo (12.04 S, 75.32 W).
896 --These data are provided by two Boundary Layer and Tropospheric Radar (BLTR) deployed at two different locations at Peru(GMT-5), one of them at Piura(5.17 S, 80.64W) and another located at Huancayo (12.04 S, 75.32 W).
895
897
896 --The purpose of conducting these observations is to measure wind in the differents levels of height, this radar makes measurements the Zonal(U), Meridional(V) and Vertical(W) wind velocities component in northcoast from Peru. And the main purpose of these mensurations is to characterize the atmospheric dynamics in this region where frequently it happens the 'El Nino Phenomenon'
898 --The purpose of conducting these observations is to measure wind in the differents levels of height, this radar makes measurements the Zonal(U), Meridional(V) and Vertical(W) wind velocities component in northcoast from Peru. And the main purpose of these mensurations is to characterize the atmospheric dynamics in this region where frequently it happens the 'El Nino Phenomenon'
897
899
898 --In Kindat = 1600, contains information of wind velocities component since 0 Km to 3 Km.
900 --In Kindat = 1600, contains information of wind velocities component since 0 Km to 3 Km.
899
901
900 --In Kindat = 1601, contains information of wind velocities component since 0 Km to 10 Km.
902 --In Kindat = 1601, contains information of wind velocities component since 0 Km to 10 Km.
901
903
902 --The Huancayo-BLTR is a VHF Profiler Radar System is a 3 channel coherent receiver pulsed radar utilising state-of-the-art software and computing techniques to acquire, decode, and translate signals obtained from partial reflection echoes in the troposphere, lower stratosphere and mesosphere. It uses an array of three horizontal spaced and vertically directed receiving antennas. The data is recorded thirty seconds, averaged to one minute mean values of Height, Zonal, Meridional and Vertical wind.
904 --The Huancayo-BLTR is a VHF Profiler Radar System is a 3 channel coherent receiver pulsed radar utilising state-of-the-art software and computing techniques to acquire, decode, and translate signals obtained from partial reflection echoes in the troposphere, lower stratosphere and mesosphere. It uses an array of three horizontal spaced and vertically directed receiving antennas. The data is recorded thirty seconds, averaged to one minute mean values of Height, Zonal, Meridional and Vertical wind.
903
905
904 --The Huancayo-BLTR was installed in January 2010. This instrument was designed and constructed by Genesis Soft Pty. Ltd. Is constituted by three groups of spaced antennas (distributed) forming an isosceles triangle.
906 --The Huancayo-BLTR was installed in January 2010. This instrument was designed and constructed by Genesis Soft Pty. Ltd. Is constituted by three groups of spaced antennas (distributed) forming an isosceles triangle.
905
907
906
908
907 Station _______ Geographic Coord ______ Geomagnetic Coord
909 Station _______ Geographic Coord ______ Geomagnetic Coord
908
910
909 _______________ Latitude _ Longitude __ Latitude _ Longitude
911 _______________ Latitude _ Longitude __ Latitude _ Longitude
910
912
911 Huancayo (HUA) __12.04 S ___ 75.32 W _____ -12.05 ____ 352.85
913 Huancayo (HUA) __12.04 S ___ 75.32 W _____ -12.05 ____ 352.85
912 Piura (PIU) _____ 5.17 S ___ 80.64 W ______ 5.18 ____ 350.93
914 Piura (PIU) _____ 5.17 S ___ 80.64 W ______ 5.18 ____ 350.93
913
915
914 WIND OBSERVATIONS
916 WIND OBSERVATIONS
915
917
916 --To obtain wind the BLTR uses Spaced Antenna technique (e.g., Briggs 1984). The scatter and reflection it still provided by variations in the refractive index as in the Doppler method(Gage and Basley,1978; Balsley and Gage 1982; Larsen and Rottger 1982), but instead of using the Doppler shift to derive the velocity components, the cross-correlation between signals in an array of three horizontally spaced and vertically directed receiving antennas is used.
918 --To obtain wind the BLTR uses Spaced Antenna technique (e.g., Briggs 1984). The scatter and reflection it still provided by variations in the refractive index as in the Doppler method(Gage and Basley,1978; Balsley and Gage 1982; Larsen and Rottger 1982), but instead of using the Doppler shift to derive the velocity components, the cross-correlation between signals in an array of three horizontally spaced and vertically directed receiving antennas is used.
917
919
918 ......................................................................
920 ......................................................................
919 For more information, consult the following references:
921 For more information, consult the following references:
920 - Balsley, B. B., and K. S. Gage., On the use of radars for operational wind profiling, Bull. Amer. Meteor.Soc.,63, 1009-1018, 1982.
922 - Balsley, B. B., and K. S. Gage., On the use of radars for operational wind profiling, Bull. Amer. Meteor.Soc.,63, 1009-1018, 1982.
921
923
922 - Briggs, B. H., The analysis of spaced sensor data by correations techniques, Handbook for MAP, Vol. 13, SCOTEP Secretariat, University of Illinois, Urbana, 166-186, 1984.
924 - Briggs, B. H., The analysis of spaced sensor data by correations techniques, Handbook for MAP, Vol. 13, SCOTEP Secretariat, University of Illinois, Urbana, 166-186, 1984.
923
925
924 - Gage, K. S., and B.B. Balsley., Doppler radar probing of the clear atmosphere, Bull. Amer. Meteor.Soc., 59, 1074-1093, 1978.
926 - Gage, K. S., and B.B. Balsley., Doppler radar probing of the clear atmosphere, Bull. Amer. Meteor.Soc., 59, 1074-1093, 1978.
925
927
926 - Larsen, M. F., The Spaced Antenna Technique for Radar Wind Profiling, Journal of Atm. and Ocean. Technology. , Vol.6, 920-937, 1989.
928 - Larsen, M. F., The Spaced Antenna Technique for Radar Wind Profiling, Journal of Atm. and Ocean. Technology. , Vol.6, 920-937, 1989.
927
929
928 - Larsen, M. F., A method for single radar voracity measurements?, Handbook for MAP,SCOSTEP Secretariat, University of the Illinois, Urban, in press, 1989.
930 - Larsen, M. F., A method for single radar voracity measurements?, Handbook for MAP,SCOSTEP Secretariat, University of the Illinois, Urban, in press, 1989.
929 ......................................................................
931 ......................................................................
930
932
931 ACKNOWLEDGEMENTS:
933 ACKNOWLEDGEMENTS:
932
934
933 --The Piura and Huancayo BLTR are part of the network of instruments operated by the Jicamarca Radio Observatory.
935 --The Piura and Huancayo BLTR are part of the network of instruments operated by the Jicamarca Radio Observatory.
934
936
935 --The Jicamarca Radio Observatory is a facility of the Instituto Geofisico del Peru operated with support from the NSF Cooperative Agreement ATM-0432565 through Cornell University
937 --The Jicamarca Radio Observatory is a facility of the Instituto Geofisico del Peru operated with support from the NSF Cooperative Agreement ATM-0432565 through Cornell University
936
938
937 ......................................................................
939 ......................................................................
938
940
939 Further questions and comments should be addressed to:
941 Further questions and comments should be addressed to:
940 Radio Observatorio de Jicamarca
942 Radio Observatorio de Jicamarca
941 Instituto Geofisico del Peru
943 Instituto Geofisico del Peru
942 Lima, Peru
944 Lima, Peru
943 Web URL: http://jro.igp.gob.pe
945 Web URL: http://jro.igp.gob.pe
944 ......................................................................
946 ......................................................................
945 '''
947 '''
946
948
947 return kindatDesc, comments, analyst, history, principleInvestigator
949 return kindatDesc, comments, analyst, history, principleInvestigator
948
950
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
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
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
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,16 +1,16
1 '''
1 '''
2
2
3 $Author: murco $
3 $Author: murco $
4 $Id: Processor.py 1 2012-11-12 18:56:07Z murco $
4 $Id: Processor.py 1 2012-11-12 18:56:07Z murco $
5 '''
5 '''
6
6
7 from jroproc_voltage import *
7 from jroproc_voltage import *
8 from jroproc_spectra import *
8 from jroproc_spectra import *
9 from jroproc_heispectra import *
9 from jroproc_heispectra import *
10 from jroproc_amisr import *
10 from jroproc_amisr import *
11 from jroproc_correlation import *
11 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 jroproc_bltr import *
16
16
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
@@ -1,576 +1,576
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 jroproc_base import ProcessingUnit
13 from jroproc_base import ProcessingUnit
14 from schainpy.model.data.jrodata import Parameters
14 from schainpy.model.data.jrodata import Parameters
15 from numpy import transpose
15 from numpy import transpose
16
16
17 from matplotlib import cm
17 from matplotlib import cm
18 import matplotlib.pyplot as plt
18 import matplotlib.pyplot as plt
19 from matplotlib.mlab import griddata
19 from matplotlib.mlab import griddata
20
20
21
21
22
22
23
23
24 class BLTRProcess(ProcessingUnit):
24 class BLTRProcess(ProcessingUnit):
25 isConfig = False
25 isConfig = False
26 '''
26 '''
27 Processing unit for BLTR rawdata
27 Processing unit for BLTR rawdata
28
28
29 Inputs:
29 Inputs:
30 self.dataOut.nmodes - Number of operation modes
30 self.dataOut.nmodes - Number of operation modes
31 self.dataOut.nchannels - Number of channels
31 self.dataOut.nchannels - Number of channels
32 self.dataOut.nranges - Number of ranges
32 self.dataOut.nranges - Number of ranges
33
33
34 self.dataOut.data_SNR - SNR array
34 self.dataOut.data_SNR - SNR array
35 self.dataOut.data_output - Zonal, Vertical and Meridional velocity array
35 self.dataOut.data_output - Zonal, Vertical and Meridional velocity array
36 self.dataOut.height - Height array (km)
36 self.dataOut.height - Height array (km)
37 self.dataOut.time - Time array (seconds)
37 self.dataOut.time - Time array (seconds)
38
38
39 self.dataOut.fileIndex -Index of the file currently read
39 self.dataOut.fileIndex -Index of the file currently read
40 self.dataOut.lat - Latitude coordinate of BLTR location
40 self.dataOut.lat - Latitude coordinate of BLTR location
41
41
42 self.dataOut.doy - Experiment doy (number of the day in the current year)
42 self.dataOut.doy - Experiment doy (number of the day in the current year)
43 self.dataOut.month - Experiment month
43 self.dataOut.month - Experiment month
44 self.dataOut.day - Experiment day
44 self.dataOut.day - Experiment day
45 self.dataOut.year - Experiment year
45 self.dataOut.year - Experiment year
46 '''
46 '''
47
47
48 def __init__(self):
48 def __init__(self, **kwargs):
49 '''
49 '''
50 Inputs: None
50 Inputs: None
51
51
52 '''
52 '''
53 ProcessingUnit.__init__(self)
53 ProcessingUnit.__init__(self, **kwargs)
54 self.dataOut = Parameters()
54 self.dataOut = Parameters()
55
55
56 # Filters
56 # Filters
57 snr_val = None
57 snr_val = None
58 value = None
58 value = None
59 svalue2 = None
59 svalue2 = None
60 method = None
60 method = None
61 factor = None
61 factor = None
62 filter = None
62 filter = None
63 npoints = None
63 npoints = None
64 status_value = None
64 status_value = None
65 width = None
65 width = None
66 self.flagfirstmode = 0
66 self.flagfirstmode = 0
67
67
68 def run (self):
68 def run (self):
69 if self.dataIn.type == "Parameters":
69 if self.dataIn.type == "Parameters":
70 self.dataOut.copy(self.dataIn)
70 self.dataOut.copy(self.dataIn)
71
71
72
72
73 def TimeSelect(self):
73 def TimeSelect(self):
74 '''
74 '''
75 Selecting the time array according to the day of the experiment with a duration of 24 hours
75 Selecting the time array according to the day of the experiment with a duration of 24 hours
76 '''
76 '''
77
77
78 k1 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) - datetime.timedelta(hours=5)
78 k1 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) - datetime.timedelta(hours=5)
79 k2 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) + datetime.timedelta(hours=25) - datetime.timedelta(hours=5)
79 k2 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) + datetime.timedelta(hours=25) - datetime.timedelta(hours=5)
80 limit_sec1 = time.mktime(k1.timetuple())
80 limit_sec1 = time.mktime(k1.timetuple())
81 limit_sec2 = time.mktime(k2.timetuple())
81 limit_sec2 = time.mktime(k2.timetuple())
82 valid_data = 0
82 valid_data = 0
83
83
84 doy = self.dataOut.doy
84 doy = self.dataOut.doy
85 t1 = numpy.where(self.dataOut.time[0, :] >= limit_sec1)
85 t1 = numpy.where(self.dataOut.time[0, :] >= limit_sec1)
86 t2 = numpy.where(self.dataOut.time[0, :] < limit_sec2)
86 t2 = numpy.where(self.dataOut.time[0, :] < limit_sec2)
87 time_select = []
87 time_select = []
88 for val_sec in t1[0]:
88 for val_sec in t1[0]:
89 if val_sec in t2[0]:
89 if val_sec in t2[0]:
90 time_select.append(val_sec)
90 time_select.append(val_sec)
91
91
92 time_select = numpy.array(time_select, dtype='int')
92 time_select = numpy.array(time_select, dtype='int')
93 valid_data = valid_data + len(time_select)
93 valid_data = valid_data + len(time_select)
94
94
95
95
96 if len(time_select) > 0:
96 if len(time_select) > 0:
97 self.f_timesec = self.dataOut.time[:, time_select]
97 self.f_timesec = self.dataOut.time[:, time_select]
98 snr = self.dataOut.data_SNR[time_select, :, :, :]
98 snr = self.dataOut.data_SNR[time_select, :, :, :]
99 zon = self.dataOut.data_output[0][time_select, :, :]
99 zon = self.dataOut.data_output[0][time_select, :, :]
100 mer = self.dataOut.data_output[1][time_select, :, :]
100 mer = self.dataOut.data_output[1][time_select, :, :]
101 ver = self.dataOut.data_output[2][time_select, :, :]
101 ver = self.dataOut.data_output[2][time_select, :, :]
102
102
103 if valid_data > 0:
103 if valid_data > 0:
104 self.timesec1 = self.f_timesec[0, :]
104 self.timesec1 = self.f_timesec[0, :]
105 self.f_height = self.dataOut.height
105 self.f_height = self.dataOut.height
106 self.f_zon = zon
106 self.f_zon = zon
107 self.f_mer = mer
107 self.f_mer = mer
108 self.f_ver = ver
108 self.f_ver = ver
109 self.f_snr = snr
109 self.f_snr = snr
110 self.f_timedate = []
110 self.f_timedate = []
111 self.f_time = []
111 self.f_time = []
112
112
113 for valuet in self.timesec1:
113 for valuet in self.timesec1:
114 time_t = time.gmtime(valuet)
114 time_t = time.gmtime(valuet)
115 year = time_t.tm_year
115 year = time_t.tm_year
116 month = time_t.tm_mon
116 month = time_t.tm_mon
117 day = time_t.tm_mday
117 day = time_t.tm_mday
118 hour = time_t.tm_hour
118 hour = time_t.tm_hour
119 minute = time_t.tm_min
119 minute = time_t.tm_min
120 second = time_t.tm_sec
120 second = time_t.tm_sec
121 f_timedate_0 = datetime.datetime(year, month, day, hour, minute, second)
121 f_timedate_0 = datetime.datetime(year, month, day, hour, minute, second)
122 self.f_timedate.append(f_timedate_0)
122 self.f_timedate.append(f_timedate_0)
123
123
124 return self.f_timedate, self.f_timesec, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr
124 return self.f_timedate, self.f_timesec, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr
125
125
126 else:
126 else:
127 self.f_timesec = None
127 self.f_timesec = None
128 self.f_timedate = None
128 self.f_timedate = None
129 self.f_height = None
129 self.f_height = None
130 self.f_zon = None
130 self.f_zon = None
131 self.f_mer = None
131 self.f_mer = None
132 self.f_ver = None
132 self.f_ver = None
133 self.f_snr = None
133 self.f_snr = None
134 print 'Invalid time'
134 print 'Invalid time'
135
135
136 return self.f_timedate, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr
136 return self.f_timedate, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr
137
137
138 def SnrFilter(self, snr_val,modetofilter):
138 def SnrFilter(self, snr_val,modetofilter):
139 '''
139 '''
140 Inputs: snr_val - Threshold value
140 Inputs: snr_val - Threshold value
141
141
142 '''
142 '''
143 if modetofilter!=2 and modetofilter!=1 :
143 if modetofilter!=2 and modetofilter!=1 :
144 raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter)
144 raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter)
145 m = modetofilter-1
145 m = modetofilter-1
146
146
147 print ' SNR filter [mode {}]: SNR <= {}: data_output = NA'.format(modetofilter,snr_val)
147 print ' SNR filter [mode {}]: SNR <= {}: data_output = NA'.format(modetofilter,snr_val)
148 for k in range(self.dataOut.nchannels):
148 for k in range(self.dataOut.nchannels):
149 for r in range(self.dataOut.nranges):
149 for r in range(self.dataOut.nranges):
150 if self.dataOut.data_SNR[r,k,m] <= snr_val:
150 if self.dataOut.data_SNR[r,k,m] <= snr_val:
151 self.dataOut.data_output[2][r,m] = numpy.nan
151 self.dataOut.data_output[2][r,m] = numpy.nan
152 self.dataOut.data_output[1][r,m] = numpy.nan
152 self.dataOut.data_output[1][r,m] = numpy.nan
153 self.dataOut.data_output[0][r,m] = numpy.nan
153 self.dataOut.data_output[0][r,m] = numpy.nan
154
154
155
155
156
156
157 def OutliersFilter(self,modetofilter,svalue,svalue2,method,factor,filter,npoints):
157 def OutliersFilter(self,modetofilter,svalue,svalue2,method,factor,filter,npoints):
158 '''
158 '''
159 Inputs:
159 Inputs:
160 svalue - string to select array velocity
160 svalue - string to select array velocity
161 svalue2 - string to choose axis filtering
161 svalue2 - string to choose axis filtering
162 method - 0 for SMOOTH or 1 for MEDIAN
162 method - 0 for SMOOTH or 1 for MEDIAN
163 factor - number used to set threshold
163 factor - number used to set threshold
164 filter - 1 for data filtering using the standard deviation criteria else 0
164 filter - 1 for data filtering using the standard deviation criteria else 0
165 npoints - number of points for mask filter
165 npoints - number of points for mask filter
166
166
167 '''
167 '''
168 if modetofilter!=2 and modetofilter!=1 :
168 if modetofilter!=2 and modetofilter!=1 :
169 raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter)
169 raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter)
170
170
171 m = modetofilter-1
171 m = modetofilter-1
172
172
173 print ' Outliers Filter [mode {}]: {} {} / threshold = {}'.format(modetofilter,svalue,svalue,factor)
173 print ' Outliers Filter [mode {}]: {} {} / threshold = {}'.format(modetofilter,svalue,svalue,factor)
174
174
175 npoints = 9
175 npoints = 9
176 novalid = 0.1
176 novalid = 0.1
177 if svalue == 'zonal':
177 if svalue == 'zonal':
178 value = self.dataOut.data_output[0]
178 value = self.dataOut.data_output[0]
179
179
180 elif svalue == 'meridional':
180 elif svalue == 'meridional':
181 value = self.dataOut.data_output[1]
181 value = self.dataOut.data_output[1]
182
182
183 elif svalue == 'vertical':
183 elif svalue == 'vertical':
184 value = self.dataOut.data_output[2]
184 value = self.dataOut.data_output[2]
185
185
186 else:
186 else:
187 print 'value is not defined'
187 print 'value is not defined'
188 return
188 return
189
189
190 if svalue2 == 'inTime':
190 if svalue2 == 'inTime':
191 yaxis = self.dataOut.height
191 yaxis = self.dataOut.height
192 xaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]])
192 xaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]])
193
193
194 elif svalue2 == 'inHeight':
194 elif svalue2 == 'inHeight':
195 yaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]])
195 yaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]])
196 xaxis = self.dataOut.height
196 xaxis = self.dataOut.height
197
197
198 else:
198 else:
199 print 'svalue2 is required, either inHeight or inTime'
199 print 'svalue2 is required, either inHeight or inTime'
200 return
200 return
201
201
202 output_array = value
202 output_array = value
203
203
204 value_temp = value[:,m]
204 value_temp = value[:,m]
205 error = numpy.zeros(len(self.dataOut.time[m,:]))
205 error = numpy.zeros(len(self.dataOut.time[m,:]))
206 if svalue2 == 'inHeight':
206 if svalue2 == 'inHeight':
207 value_temp = numpy.transpose(value_temp)
207 value_temp = numpy.transpose(value_temp)
208 error = numpy.zeros(len(self.dataOut.height))
208 error = numpy.zeros(len(self.dataOut.height))
209
209
210 htemp = yaxis[m,:]
210 htemp = yaxis[m,:]
211 std = value_temp
211 std = value_temp
212 for h in range(len(htemp)):
212 for h in range(len(htemp)):
213 if filter: #standard deviation filtering
213 if filter: #standard deviation filtering
214 std[h] = numpy.std(value_temp[h],ddof = npoints)
214 std[h] = numpy.std(value_temp[h],ddof = npoints)
215 value_temp[numpy.where(std[h] > 5),h] = numpy.nan
215 value_temp[numpy.where(std[h] > 5),h] = numpy.nan
216 error[numpy.where(std[h] > 5)] = error[numpy.where(std[h] > 5)] + 1
216 error[numpy.where(std[h] > 5)] = error[numpy.where(std[h] > 5)] + 1
217
217
218
218
219 nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0])
219 nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0])
220 minvalid = novalid*len(xaxis[m,:])
220 minvalid = novalid*len(xaxis[m,:])
221 if minvalid <= npoints:
221 if minvalid <= npoints:
222 minvalid = npoints
222 minvalid = npoints
223
223
224 #only if valid values greater than the minimum required (10%)
224 #only if valid values greater than the minimum required (10%)
225 if nvalues_valid > minvalid:
225 if nvalues_valid > minvalid:
226
226
227 if method == 0:
227 if method == 0:
228 #SMOOTH
228 #SMOOTH
229 w = value_temp[h] - self.Smooth(input=value_temp[h], width=npoints, edge_truncate=1)
229 w = value_temp[h] - self.Smooth(input=value_temp[h], width=npoints, edge_truncate=1)
230
230
231
231
232 if method == 1:
232 if method == 1:
233 #MEDIAN
233 #MEDIAN
234 w = value_temp[h] - self.Median(input=value_temp[h], width = npoints)
234 w = value_temp[h] - self.Median(input=value_temp[h], width = npoints)
235
235
236 dw = numpy.std(w[numpy.where(numpy.isfinite(w))],ddof = 1)
236 dw = numpy.std(w[numpy.where(numpy.isfinite(w))],ddof = 1)
237
237
238 threshold = dw*factor
238 threshold = dw*factor
239 value_temp[numpy.where(w > threshold),h] = numpy.nan
239 value_temp[numpy.where(w > threshold),h] = numpy.nan
240 value_temp[numpy.where(w < -1*threshold),h] = numpy.nan
240 value_temp[numpy.where(w < -1*threshold),h] = numpy.nan
241
241
242
242
243 #At the end
243 #At the end
244 if svalue2 == 'inHeight':
244 if svalue2 == 'inHeight':
245 value_temp = numpy.transpose(value_temp)
245 value_temp = numpy.transpose(value_temp)
246 output_array[:,m] = value_temp
246 output_array[:,m] = value_temp
247
247
248 if svalue == 'zonal':
248 if svalue == 'zonal':
249 self.dataOut.data_output[0] = output_array
249 self.dataOut.data_output[0] = output_array
250
250
251 elif svalue == 'meridional':
251 elif svalue == 'meridional':
252 self.dataOut.data_output[1] = output_array
252 self.dataOut.data_output[1] = output_array
253
253
254 elif svalue == 'vertical':
254 elif svalue == 'vertical':
255 self.dataOut.data_output[2] = output_array
255 self.dataOut.data_output[2] = output_array
256
256
257 return self.dataOut.data_output
257 return self.dataOut.data_output
258
258
259
259
260 def Median(self,input,width):
260 def Median(self,input,width):
261 '''
261 '''
262 Inputs:
262 Inputs:
263 input - Velocity array
263 input - Velocity array
264 width - Number of points for mask filter
264 width - Number of points for mask filter
265
265
266 '''
266 '''
267
267
268 if numpy.mod(width,2) == 1:
268 if numpy.mod(width,2) == 1:
269 pc = int((width - 1) / 2)
269 pc = int((width - 1) / 2)
270 cont = 0
270 cont = 0
271 output = []
271 output = []
272
272
273 for i in range(len(input)):
273 for i in range(len(input)):
274 if i >= pc and i < len(input) - pc:
274 if i >= pc and i < len(input) - pc:
275 new2 = input[i-pc:i+pc+1]
275 new2 = input[i-pc:i+pc+1]
276 temp = numpy.where(numpy.isfinite(new2))
276 temp = numpy.where(numpy.isfinite(new2))
277 new = new2[temp]
277 new = new2[temp]
278 value = numpy.median(new)
278 value = numpy.median(new)
279 output.append(value)
279 output.append(value)
280
280
281 output = numpy.array(output)
281 output = numpy.array(output)
282 output = numpy.hstack((input[0:pc],output))
282 output = numpy.hstack((input[0:pc],output))
283 output = numpy.hstack((output,input[-pc:len(input)]))
283 output = numpy.hstack((output,input[-pc:len(input)]))
284
284
285 return output
285 return output
286
286
287 def Smooth(self,input,width,edge_truncate = None):
287 def Smooth(self,input,width,edge_truncate = None):
288 '''
288 '''
289 Inputs:
289 Inputs:
290 input - Velocity array
290 input - Velocity array
291 width - Number of points for mask filter
291 width - Number of points for mask filter
292 edge_truncate - 1 for truncate the convolution product else
292 edge_truncate - 1 for truncate the convolution product else
293
293
294 '''
294 '''
295
295
296 if numpy.mod(width,2) == 0:
296 if numpy.mod(width,2) == 0:
297 real_width = width + 1
297 real_width = width + 1
298 nzeros = width / 2
298 nzeros = width / 2
299 else:
299 else:
300 real_width = width
300 real_width = width
301 nzeros = (width - 1) / 2
301 nzeros = (width - 1) / 2
302
302
303 half_width = int(real_width)/2
303 half_width = int(real_width)/2
304 length = len(input)
304 length = len(input)
305
305
306 gate = numpy.ones(real_width,dtype='float')
306 gate = numpy.ones(real_width,dtype='float')
307 norm_of_gate = numpy.sum(gate)
307 norm_of_gate = numpy.sum(gate)
308
308
309 nan_process = 0
309 nan_process = 0
310 nan_id = numpy.where(numpy.isnan(input))
310 nan_id = numpy.where(numpy.isnan(input))
311 if len(nan_id[0]) > 0:
311 if len(nan_id[0]) > 0:
312 nan_process = 1
312 nan_process = 1
313 pb = numpy.zeros(len(input))
313 pb = numpy.zeros(len(input))
314 pb[nan_id] = 1.
314 pb[nan_id] = 1.
315 input[nan_id] = 0.
315 input[nan_id] = 0.
316
316
317 if edge_truncate == True:
317 if edge_truncate == True:
318 output = numpy.convolve(input/norm_of_gate,gate,mode='same')
318 output = numpy.convolve(input/norm_of_gate,gate,mode='same')
319 elif edge_truncate == False or edge_truncate == None:
319 elif edge_truncate == False or edge_truncate == None:
320 output = numpy.convolve(input/norm_of_gate,gate,mode='valid')
320 output = numpy.convolve(input/norm_of_gate,gate,mode='valid')
321 output = numpy.hstack((input[0:half_width],output))
321 output = numpy.hstack((input[0:half_width],output))
322 output = numpy.hstack((output,input[len(input)-half_width:len(input)]))
322 output = numpy.hstack((output,input[len(input)-half_width:len(input)]))
323
323
324 if nan_process:
324 if nan_process:
325 pb = numpy.convolve(pb/norm_of_gate,gate,mode='valid')
325 pb = numpy.convolve(pb/norm_of_gate,gate,mode='valid')
326 pb = numpy.hstack((numpy.zeros(half_width),pb))
326 pb = numpy.hstack((numpy.zeros(half_width),pb))
327 pb = numpy.hstack((pb,numpy.zeros(half_width)))
327 pb = numpy.hstack((pb,numpy.zeros(half_width)))
328 output[numpy.where(pb > 0.9999)] = numpy.nan
328 output[numpy.where(pb > 0.9999)] = numpy.nan
329 input[nan_id] = numpy.nan
329 input[nan_id] = numpy.nan
330 return output
330 return output
331
331
332 def Average(self,aver=0,nhaver=1):
332 def Average(self,aver=0,nhaver=1):
333 '''
333 '''
334 Inputs:
334 Inputs:
335 aver - Indicates the time period over which is averaged or consensus data
335 aver - Indicates the time period over which is averaged or consensus data
336 nhaver - Indicates the decimation factor in heights
336 nhaver - Indicates the decimation factor in heights
337
337
338 '''
338 '''
339 nhpoints = 48
339 nhpoints = 48
340
340
341 lat_piura = -5.17
341 lat_piura = -5.17
342 lat_huancayo = -12.04
342 lat_huancayo = -12.04
343 lat_porcuya = -5.8
343 lat_porcuya = -5.8
344
344
345 if '%2.2f'%self.dataOut.lat == '%2.2f'%lat_piura:
345 if '%2.2f'%self.dataOut.lat == '%2.2f'%lat_piura:
346 hcm = 3.
346 hcm = 3.
347 if self.dataOut.year == 2003 :
347 if self.dataOut.year == 2003 :
348 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
348 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
349 nhpoints = 12
349 nhpoints = 12
350
350
351 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_huancayo:
351 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_huancayo:
352 hcm = 3.
352 hcm = 3.
353 if self.dataOut.year == 2003 :
353 if self.dataOut.year == 2003 :
354 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
354 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
355 nhpoints = 12
355 nhpoints = 12
356
356
357
357
358 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_porcuya:
358 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_porcuya:
359 hcm = 5.#2
359 hcm = 5.#2
360
360
361 pdata = 0.2
361 pdata = 0.2
362 taver = [1,2,3,4,6,8,12,24]
362 taver = [1,2,3,4,6,8,12,24]
363 t0 = 0
363 t0 = 0
364 tf = 24
364 tf = 24
365 ntime =(tf-t0)/taver[aver]
365 ntime =(tf-t0)/taver[aver]
366 ti = numpy.arange(ntime)
366 ti = numpy.arange(ntime)
367 tf = numpy.arange(ntime) + taver[aver]
367 tf = numpy.arange(ntime) + taver[aver]
368
368
369
369
370 old_height = self.dataOut.heightList
370 old_height = self.dataOut.heightList
371
371
372 if nhaver > 1:
372 if nhaver > 1:
373 num_hei = len(self.dataOut.heightList)/nhaver/self.dataOut.nmodes
373 num_hei = len(self.dataOut.heightList)/nhaver/self.dataOut.nmodes
374 deltha = 0.05*nhaver
374 deltha = 0.05*nhaver
375 minhvalid = pdata*nhaver
375 minhvalid = pdata*nhaver
376 for im in range(self.dataOut.nmodes):
376 for im in range(self.dataOut.nmodes):
377 new_height = numpy.arange(num_hei)*deltha + self.dataOut.height[im,0] + deltha/2.
377 new_height = numpy.arange(num_hei)*deltha + self.dataOut.height[im,0] + deltha/2.
378
378
379
379
380 data_fHeigths_List = []
380 data_fHeigths_List = []
381 data_fZonal_List = []
381 data_fZonal_List = []
382 data_fMeridional_List = []
382 data_fMeridional_List = []
383 data_fVertical_List = []
383 data_fVertical_List = []
384 startDTList = []
384 startDTList = []
385
385
386
386
387 for i in range(ntime):
387 for i in range(ntime):
388 height = old_height
388 height = old_height
389
389
390 start = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(ti[i])) - datetime.timedelta(hours = 5)
390 start = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(ti[i])) - datetime.timedelta(hours = 5)
391 stop = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(tf[i])) - datetime.timedelta(hours = 5)
391 stop = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(tf[i])) - datetime.timedelta(hours = 5)
392
392
393
393
394 limit_sec1 = time.mktime(start.timetuple())
394 limit_sec1 = time.mktime(start.timetuple())
395 limit_sec2 = time.mktime(stop.timetuple())
395 limit_sec2 = time.mktime(stop.timetuple())
396
396
397 t1 = numpy.where(self.f_timesec >= limit_sec1)
397 t1 = numpy.where(self.f_timesec >= limit_sec1)
398 t2 = numpy.where(self.f_timesec < limit_sec2)
398 t2 = numpy.where(self.f_timesec < limit_sec2)
399 time_select = []
399 time_select = []
400 for val_sec in t1[0]:
400 for val_sec in t1[0]:
401 if val_sec in t2[0]:
401 if val_sec in t2[0]:
402 time_select.append(val_sec)
402 time_select.append(val_sec)
403
403
404
404
405 time_select = numpy.array(time_select,dtype = 'int')
405 time_select = numpy.array(time_select,dtype = 'int')
406 minvalid = numpy.ceil(pdata*nhpoints)
406 minvalid = numpy.ceil(pdata*nhpoints)
407
407
408 zon_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
408 zon_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
409 mer_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
409 mer_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
410 ver_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
410 ver_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
411
411
412 if nhaver > 1:
412 if nhaver > 1:
413 new_zon_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
413 new_zon_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
414 new_mer_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
414 new_mer_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
415 new_ver_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
415 new_ver_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
416
416
417 if len(time_select) > minvalid:
417 if len(time_select) > minvalid:
418 time_average = self.f_timesec[time_select]
418 time_average = self.f_timesec[time_select]
419
419
420 for im in range(self.dataOut.nmodes):
420 for im in range(self.dataOut.nmodes):
421
421
422 for ih in range(self.dataOut.nranges):
422 for ih in range(self.dataOut.nranges):
423 if numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im])) >= minvalid:
423 if numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im])) >= minvalid:
424 zon_aver[ih,im] = numpy.nansum(self.f_zon[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im]))
424 zon_aver[ih,im] = numpy.nansum(self.f_zon[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im]))
425
425
426 if numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im])) >= minvalid:
426 if numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im])) >= minvalid:
427 mer_aver[ih,im] = numpy.nansum(self.f_mer[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im]))
427 mer_aver[ih,im] = numpy.nansum(self.f_mer[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im]))
428
428
429 if numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im])) >= minvalid:
429 if numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im])) >= minvalid:
430 ver_aver[ih,im] = numpy.nansum(self.f_ver[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im]))
430 ver_aver[ih,im] = numpy.nansum(self.f_ver[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im]))
431
431
432 if nhaver > 1:
432 if nhaver > 1:
433 for ih in range(num_hei):
433 for ih in range(num_hei):
434 hvalid = numpy.arange(nhaver) + nhaver*ih
434 hvalid = numpy.arange(nhaver) + nhaver*ih
435
435
436 if numpy.sum(numpy.isfinite(zon_aver[hvalid,im])) >= minvalid:
436 if numpy.sum(numpy.isfinite(zon_aver[hvalid,im])) >= minvalid:
437 new_zon_aver[ih,im] = numpy.nansum(zon_aver[hvalid,im]) / numpy.sum(numpy.isfinite(zon_aver[hvalid,im]))
437 new_zon_aver[ih,im] = numpy.nansum(zon_aver[hvalid,im]) / numpy.sum(numpy.isfinite(zon_aver[hvalid,im]))
438
438
439 if numpy.sum(numpy.isfinite(mer_aver[hvalid,im])) >= minvalid:
439 if numpy.sum(numpy.isfinite(mer_aver[hvalid,im])) >= minvalid:
440 new_mer_aver[ih,im] = numpy.nansum(mer_aver[hvalid,im]) / numpy.sum(numpy.isfinite(mer_aver[hvalid,im]))
440 new_mer_aver[ih,im] = numpy.nansum(mer_aver[hvalid,im]) / numpy.sum(numpy.isfinite(mer_aver[hvalid,im]))
441
441
442 if numpy.sum(numpy.isfinite(ver_aver[hvalid,im])) >= minvalid:
442 if numpy.sum(numpy.isfinite(ver_aver[hvalid,im])) >= minvalid:
443 new_ver_aver[ih,im] = numpy.nansum(ver_aver[hvalid,im]) / numpy.sum(numpy.isfinite(ver_aver[hvalid,im]))
443 new_ver_aver[ih,im] = numpy.nansum(ver_aver[hvalid,im]) / numpy.sum(numpy.isfinite(ver_aver[hvalid,im]))
444 if nhaver > 1:
444 if nhaver > 1:
445 zon_aver = new_zon_aver
445 zon_aver = new_zon_aver
446 mer_aver = new_mer_aver
446 mer_aver = new_mer_aver
447 ver_aver = new_ver_aver
447 ver_aver = new_ver_aver
448 height = new_height
448 height = new_height
449
449
450
450
451 tstart = time_average[0]
451 tstart = time_average[0]
452 tend = time_average[-1]
452 tend = time_average[-1]
453 startTime = time.gmtime(tstart)
453 startTime = time.gmtime(tstart)
454
454
455 year = startTime.tm_year
455 year = startTime.tm_year
456 month = startTime.tm_mon
456 month = startTime.tm_mon
457 day = startTime.tm_mday
457 day = startTime.tm_mday
458 hour = startTime.tm_hour
458 hour = startTime.tm_hour
459 minute = startTime.tm_min
459 minute = startTime.tm_min
460 second = startTime.tm_sec
460 second = startTime.tm_sec
461
461
462 startDTList.append(datetime.datetime(year,month,day,hour,minute,second))
462 startDTList.append(datetime.datetime(year,month,day,hour,minute,second))
463
463
464
464
465 o_height = numpy.array([])
465 o_height = numpy.array([])
466 o_zon_aver = numpy.array([])
466 o_zon_aver = numpy.array([])
467 o_mer_aver = numpy.array([])
467 o_mer_aver = numpy.array([])
468 o_ver_aver = numpy.array([])
468 o_ver_aver = numpy.array([])
469 if self.dataOut.nmodes > 1:
469 if self.dataOut.nmodes > 1:
470 for im in range(self.dataOut.nmodes):
470 for im in range(self.dataOut.nmodes):
471
471
472 if im == 0:
472 if im == 0:
473 h_select = numpy.where(numpy.bitwise_and(height[0,:] >=0,height[0,:] <= hcm,numpy.isfinite(height[0,:])))
473 h_select = numpy.where(numpy.bitwise_and(height[0,:] >=0,height[0,:] <= hcm,numpy.isfinite(height[0,:])))
474 else:
474 else:
475 h_select = numpy.where(numpy.bitwise_and(height[1,:] > hcm,height[1,:] < 20,numpy.isfinite(height[1,:])))
475 h_select = numpy.where(numpy.bitwise_and(height[1,:] > hcm,height[1,:] < 20,numpy.isfinite(height[1,:])))
476
476
477
477
478 ht = h_select[0]
478 ht = h_select[0]
479
479
480 o_height = numpy.hstack((o_height,height[im,ht]))
480 o_height = numpy.hstack((o_height,height[im,ht]))
481 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
481 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
482 o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im]))
482 o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im]))
483 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
483 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
484
484
485 data_fHeigths_List.append(o_height)
485 data_fHeigths_List.append(o_height)
486 data_fZonal_List.append(o_zon_aver)
486 data_fZonal_List.append(o_zon_aver)
487 data_fMeridional_List.append(o_mer_aver)
487 data_fMeridional_List.append(o_mer_aver)
488 data_fVertical_List.append(o_ver_aver)
488 data_fVertical_List.append(o_ver_aver)
489
489
490
490
491 else:
491 else:
492 h_select = numpy.where(numpy.bitwise_and(height[0,:] <= hcm,numpy.isfinite(height[0,:])))
492 h_select = numpy.where(numpy.bitwise_and(height[0,:] <= hcm,numpy.isfinite(height[0,:])))
493 ht = h_select[0]
493 ht = h_select[0]
494 o_height = numpy.hstack((o_height,height[im,ht]))
494 o_height = numpy.hstack((o_height,height[im,ht]))
495 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
495 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
496 o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im]))
496 o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im]))
497 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
497 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
498
498
499 data_fHeigths_List.append(o_height)
499 data_fHeigths_List.append(o_height)
500 data_fZonal_List.append(o_zon_aver)
500 data_fZonal_List.append(o_zon_aver)
501 data_fMeridional_List.append(o_mer_aver)
501 data_fMeridional_List.append(o_mer_aver)
502 data_fVertical_List.append(o_ver_aver)
502 data_fVertical_List.append(o_ver_aver)
503
503
504
504
505 return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List
505 return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List
506
506
507
507
508 def prePlot(self,modeselect=None):
508 def prePlot(self,modeselect=None):
509
509
510 '''
510 '''
511 Inputs:
511 Inputs:
512
512
513 self.dataOut.data_output - Zonal, Meridional and Vertical velocity array
513 self.dataOut.data_output - Zonal, Meridional and Vertical velocity array
514 self.dataOut.height - height array
514 self.dataOut.height - height array
515 self.dataOut.time - Time array (seconds)
515 self.dataOut.time - Time array (seconds)
516 self.dataOut.data_SNR - SNR array
516 self.dataOut.data_SNR - SNR array
517
517
518 '''
518 '''
519
519
520 m = modeselect -1
520 m = modeselect -1
521
521
522 print ' [Plotting mode {}]'.format(modeselect)
522 print ' [Plotting mode {}]'.format(modeselect)
523 if not (m ==1 or m==0):
523 if not (m ==1 or m==0):
524 raise IndexError("'Mode' must be egual to : 1 or 2")
524 raise IndexError("'Mode' must be egual to : 1 or 2")
525 #
525 #
526 if self.flagfirstmode==0:
526 if self.flagfirstmode==0:
527 #copy of the data
527 #copy of the data
528 self.data_output_copy = self.dataOut.data_output.copy()
528 self.data_output_copy = self.dataOut.data_output.copy()
529 self.data_height_copy = self.dataOut.height.copy()
529 self.data_height_copy = self.dataOut.height.copy()
530 self.data_time_copy = self.dataOut.time.copy()
530 self.data_time_copy = self.dataOut.time.copy()
531 self.data_SNR_copy = self.dataOut.data_SNR.copy()
531 self.data_SNR_copy = self.dataOut.data_SNR.copy()
532 self.flagfirstmode = 1
532 self.flagfirstmode = 1
533
533
534 else:
534 else:
535 self.dataOut.data_output = self.data_output_copy
535 self.dataOut.data_output = self.data_output_copy
536 self.dataOut.height = self.data_height_copy
536 self.dataOut.height = self.data_height_copy
537 self.dataOut.time = self.data_time_copy
537 self.dataOut.time = self.data_time_copy
538 self.dataOut.data_SNR = self.data_SNR_copy
538 self.dataOut.data_SNR = self.data_SNR_copy
539 self.flagfirstmode = 0
539 self.flagfirstmode = 0
540
540
541
541
542 #select data for mode m
542 #select data for mode m
543 #self.dataOut.data_output = self.dataOut.data_output[:,:,m]
543 #self.dataOut.data_output = self.dataOut.data_output[:,:,m]
544 self.dataOut.heightList = self.dataOut.height[0,:]
544 self.dataOut.heightList = self.dataOut.height[0,:]
545
545
546 data_SNR = self.dataOut.data_SNR[:,:,m]
546 data_SNR = self.dataOut.data_SNR[:,:,m]
547 self.dataOut.data_SNR= transpose(data_SNR)
547 self.dataOut.data_SNR= transpose(data_SNR)
548
548
549 if m==1 and self.dataOut.counter_records%2==0:
549 if m==1 and self.dataOut.counter_records%2==0:
550 print '*********'
550 print '*********'
551 print 'MODO 2'
551 print 'MODO 2'
552 #print 'Zonal', self.dataOut.data_output[0]
552 #print 'Zonal', self.dataOut.data_output[0]
553 #print 'Meridional', self.dataOut.data_output[1]
553 #print 'Meridional', self.dataOut.data_output[1]
554 #print 'Vertical', self.dataOut.data_output[2]
554 #print 'Vertical', self.dataOut.data_output[2]
555
555
556 print '*********'
556 print '*********'
557
557
558 Vx=self.dataOut.data_output[0,:,m]
558 Vx=self.dataOut.data_output[0,:,m]
559 Vy=self.dataOut.data_output[1,:,m]
559 Vy=self.dataOut.data_output[1,:,m]
560
560
561 Vmag=numpy.sqrt(Vx**2+Vy**2)
561 Vmag=numpy.sqrt(Vx**2+Vy**2)
562 Vang=numpy.arctan2(Vy,Vx)
562 Vang=numpy.arctan2(Vy,Vx)
563 #print 'Vmag', Vmag
563 #print 'Vmag', Vmag
564 #print 'Vang', Vang
564 #print 'Vang', Vang
565
565
566 self.dataOut.data_output[0,:,m]=Vmag
566 self.dataOut.data_output[0,:,m]=Vmag
567 self.dataOut.data_output[1,:,m]=Vang
567 self.dataOut.data_output[1,:,m]=Vang
568
568
569 prin= self.dataOut.data_output[0,:,m][~numpy.isnan(self.dataOut.data_output[0,:,m])]
569 prin= self.dataOut.data_output[0,:,m][~numpy.isnan(self.dataOut.data_output[0,:,m])]
570 print ' '
570 print ' '
571 print 'VmagAverage',numpy.mean(prin)
571 print 'VmagAverage',numpy.mean(prin)
572 print ' '
572 print ' '
573 self.dataOut.data_output = self.dataOut.data_output[:,:,m]
573 self.dataOut.data_output = self.dataOut.data_output[:,:,m]
574
574
575
575
576 No newline at end of file
576
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
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, 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
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,1 +1,1
1 <Project description="Segundo Test" id="191" name="test01"><ReadUnit datatype="VoltageReader" id="1911" inputId="0" name="VoltageReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="VoltageReader" /><Parameter format="str" id="191112" name="path" value="/home/erick/Documents/Data/Claire_Data/raw" /><Parameter format="date" id="191113" name="startDate" value="2017/07/26" /><Parameter format="date" id="191114" name="endDate" value="2017/10/28" /><Parameter format="time" id="191115" name="startTime" value="09:40:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:00" /><Parameter format="int" id="191118" name="online" value="0" /><Parameter format="int" id="191119" name="walk" value="1" /></Operation><Operation id="19112" name="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="SpectraProc" id="1913" inputId="1912" name="SpectraProc"><Operation id="19131" name="run" priority="1" type="self"><Parameter format="int" id="191311" name="nFFTPoints" value="256" /><Parameter format="pairslist" id="191312" name="pairsList" value="(0,1),(0,2),(1,2)" /></Operation><Operation id="19132" name="removeDC" priority="2" type="self" /><Operation id="19133" name="IncohInt" priority="3" type="external"><Parameter format="float" id="191331" name="n" value="30" /></Operation><Operation id="19134" name="SpectraPlot" priority="4" type="external"><Parameter format="int" id="191341" name="id" value="11" /><Parameter format="str" id="191342" name="wintitle" value="SpectraPlot" /><Parameter format="str" id="191343" name="xaxis" value="velocity" /><Parameter format="int" id="191344" name="zmin" value="0" /><Parameter format="float" id="191345" name="ymin" value="1.5" /><Parameter format="int" id="191346" name="ymax" value="7" /><Parameter format="int" id="191347" name="zmax" value="40" /><Parameter format="int" id="191348" name="save" value="1" /></Operation><Operation id="19135" name="RTIPlot" priority="5" type="other"><Parameter format="int" id="191351" name="id" value="30" /><Parameter format="str" id="191352" name="wintitle" value="RTI" /><Parameter format="int" id="191353" name="zmin" value="0" /><Parameter format="int" id="191354" name="zmax" value="40" /><Parameter format="float" id="191355" name="ymin" value="1.5" /><Parameter format="int" id="191356" name="ymax" value="8" /><Parameter format="int" id="191357" name="showprofile" value="1" /><Parameter format="float" id="191358" name="xmin" value="0" /><Parameter format="float" id="191359" name="xmax" value="23.9" /><Parameter format="int" id="191360" name="save" value="1" /></Operation><Operation id="19136" name="CrossSpectraPlot" priority="6" type="other"><Parameter format="str" id="191361" name="phase_cmap" value="bwr" /><Parameter format="int" id="191362" name="id" value="2005" /><Parameter format="str" id="191363" name="wintitle" value="CrossSpectraPlot_ShortPulse" /><Parameter format="str" id="191364" name="xaxis" value="Velocity" /><Parameter format="float" id="191365" name="ymin" value="1.5" /><Parameter format="int" id="191366" name="ymax" value="7" /></Operation></ProcUnit><ProcUnit datatype="VoltageProc" id="1912" inputId="1911" name="VoltageProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="setRadarFrequency" priority="2" type="self"><Parameter format="float" id="191221" name="frequency" value="445.09e6" /></Operation><Operation id="19123" name="selectHeights" priority="3" type="self"><Parameter format="float" id="191231" name="minHei" value="0" /><Parameter format="float" id="191232" name="maxHei" value="64" /></Operation></ProcUnit><ProcUnit datatype="Parameters" id="1914" inputId="1913" name="ParametersProc"><Operation id="19141" name="run" priority="1" type="self" /><Operation id="19142" name="SpectralMoments" priority="2" type="other" /><Operation id="19143" name="FullSpectralAnalysis" priority="3" type="other"><Parameter format="float" id="191431" name="E01" value="1.5" /><Parameter format="float" id="191432" name="E02" value="1.5" /><Parameter format="float" id="191433" name="E12" value="0" /><Parameter format="float" id="191434" name="N01" value="0.875" /><Parameter format="float" id="191435" name="N02" value="-0.875" /><Parameter format="float" id="191436" name="N12" value="-1.75" /></Operation><Operation id="19144" name="WindProfilerPlot" priority="4" type="other"><Parameter format="int" id="191441" name="id" value="4" /><Parameter format="str" id="191442" name="wintitle" value="Wind Profiler" /><Parameter format="bool" id="191443" name="save" value="1" /><Parameter format="float" id="191444" name="ymin" value="1.5" /><Parameter format="int" id="191445" name="ymax" value="7" /><Parameter format="float" id="191446" name="zmin" value="-0.00" /><Parameter format="float" id="191447" name="zmax" value="1.1" /></Operation></ProcUnit></Project> No newline at end of file
1 <Project description="read bltr data sswma file" id="191" name="test1"><ReadUnit datatype="testBLTRReader" id="1911" inputId="0" name="testBLTRReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="testBLTRReader" /><Parameter format="str" id="191112" name="path" value="/media/erick/6F60F7113095A154/BLTR" /><Parameter format="date" id="191113" name="startDate" value="2017/01/17" /><Parameter format="date" id="191114" name="endDate" value="2018/01/01" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="str" id="191118" name="ext" value="sswma" /></Operation></ReadUnit><ProcUnit datatype="BLTRProcess" id="1912" inputId="1911" name="BLTRProcess"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="SnrFilter" priority="2" type="self"><Parameter format="float" id="191221" name="snr_val" value="-20" /><Parameter format="int" id="191222" name="modetofilter" value="2" /></Operation><Operation id="19123" name="OutliersFilter" priority="3" type="self"><Parameter format="str" id="191231" name="svalue" value="meridional" /><Parameter format="str" id="191232" name="svalue2" value="inTime" /><Parameter format="float" id="191233" name="method" value="0" /><Parameter format="float" id="191234" name="factor" value="2" /><Parameter format="float" id="191235" name="filter" value="0" /><Parameter format="float" id="191236" name="npoints" value="9" /><Parameter format="int" id="191237" name="modetofilter" value="2" /></Operation><Operation id="19124" name="OutliersFilter" priority="4" type="self"><Parameter format="str" id="191241" name="svalue" value="zonal" /><Parameter format="str" id="191242" name="svalue2" value="inTime" /><Parameter format="float" id="191243" name="method" value="0" /><Parameter format="float" id="191244" name="factor" value="2" /><Parameter format="float" id="191245" name="filter" value="0" /><Parameter format="float" id="191246" name="npoints" value="9" /><Parameter format="int" id="191247" name="modetofilter" value="2" /></Operation><Operation id="19125" name="OutliersFilter" priority="5" type="self"><Parameter format="str" id="191251" name="svalue" value="vertical" /><Parameter format="str" id="191252" name="svalue2" value="inHeight" /><Parameter format="float" id="191253" name="method" value="0" /><Parameter format="float" id="191254" name="factor" value="2" /><Parameter format="float" id="191255" name="filter" value="0" /><Parameter format="float" id="191256" name="npoints" value="9" /><Parameter format="int" id="191257" name="modetofilter" value="2" /></Operation><Operation id="19126" name="prePlot" priority="6" type="self"><Parameter format="int" id="191261" name="modeselect" value="1" /></Operation><Operation id="19127" name="WindProfilerPlot" priority="7" type="other"><Parameter format="int" id="191271" name="id" value="1" /><Parameter format="str" id="191272" name="wintitle" value="" /><Parameter format="intlist" id="191273" name="channelList" value="0" /><Parameter format="int" id="191274" name="SNRmin" value="-10" /><Parameter format="int" id="191275" name="SNRmax" value="50" /><Parameter format="float" id="191276" name="SNRthresh" value="0" /><Parameter format="float" id="191277" name="xmin" value="0" /><Parameter format="float" id="191278" name="xmax" value="24" /><Parameter format="float" id="191279" name="ymax" value="3" /><Parameter format="float" id="191280" name="zmin" value="-20" /><Parameter format="float" id="191281" name="zmax" value="20" /><Parameter format="float" id="191282" name="zmin_ver" value="-200" /><Parameter format="float" id="191283" name="zmax_ver" value="200" /></Operation><Operation id="19128" name="prePlot" priority="8" type="self"><Parameter format="int" id="191281" name="modeselect" value="2" /></Operation><Operation id="19129" name="WindProfilerPlot" priority="9" type="other"><Parameter format="int" id="191291" name="id" value="2" /><Parameter format="str" id="191292" name="wintitle" value="" /><Parameter format="bool" id="191293" name="save" value="1" /><Parameter format="str" id="191294" name="figpath" value="/media/erick/6F60F7113095A154/BLTR/" /><Parameter format="int" id="191295" name="SNRmin" value="-20" /><Parameter format="int" id="191296" name="SNRmax" value="40" /><Parameter format="float" id="191297" name="SNRthresh" value="0" /><Parameter format="float" id="191298" name="xmin" value="0" /><Parameter format="float" id="191299" name="xmax" value="24" /><Parameter format="float" id="191300" name="ymin" value="0" /><Parameter format="float" id="191301" name="ymax" value="10" /><Parameter format="float" id="191302" name="zmin" value="-4" /><Parameter format="float" id="191303" name="zmax" value="4" /><Parameter format="float" id="191304" name="zmin_ver" value="-200" /><Parameter format="float" id="191305" name="zmax_ver" value="200" /></Operation></ProcUnit></Project> No newline at end of file
@@ -1,170 +1,171
1 '''
1 '''
2 Created on Nov 09, 2016
2 Created on Nov 09, 2016
3
3
4 @author: roj- LouVD
4 @author: roj- LouVD
5 '''
5 '''
6 import os, sys
6 import os, sys
7
7
8
8
9 path = os.path.split(os.getcwd())[0]
9 path = os.path.split(os.getcwd())[0]
10 path = os.path.split(path)[0]
10 path = os.path.split(path)[0]
11
11
12 sys.path.insert(0, path)
12 sys.path.insert(0, path)
13
13
14 from schainpy.controller import Project
14 from schainpy.controller import Project
15
15
16 filename = 'test1.xml'
16 filename = 'test1.xml'
17 # path = '/home/jespinoza/workspace/data/bltr/'
17 # path = '/home/jespinoza/workspace/data/bltr/'
18 path = '/home/erick/Documents/Data/BLTR_Data/sswma/'
18 path = '/media/erick/6F60F7113095A154/BLTR/'
19 desc = "read bltr data sswma file"
19 desc = "read bltr data sswma file"
20 figpath = '/home/erick/workspace'
20 figpath = '/media/erick/6F60F7113095A154/BLTR/'
21 pathhdf5 = '/tmp/'
21 pathhdf5 = '/tmp/'
22
22
23 controllerObj = Project()
23 controllerObj = Project()
24
24
25 controllerObj.setup(id = '191', name='test1', description=desc)
25 controllerObj.setup(id = '191', name='test1', description=desc)
26 readUnitConfObj = controllerObj.addReadUnit(datatype='testBLTRReader',
26 readUnitConfObj = controllerObj.addReadUnit(datatype='testBLTRReader',
27 path=path,
27 path=path,
28 startDate='2015/01/17',
28 startDate='2017/01/17',
29 endDate='2017/01/01',
29 endDate='2018/01/01',
30 startTime='00:00:00',
30 startTime='00:00:00',
31 endTime='23:59:59',
31 endTime='23:59:59',
32 ext='sswma')
32 ext='sswma')
33
33
34 procUnitConfObj1 = controllerObj.addProcUnit(datatype='BLTRProcess',
34 procUnitConfObj1 = controllerObj.addProcUnit(datatype='BLTRProcess',
35 inputId=readUnitConfObj.getId())
35 inputId=readUnitConfObj.getId())
36
36
37 '''-------------------------------------------Processing--------------------------------------------'''
37 '''-------------------------------------------Processing--------------------------------------------'''
38
38
39 '''MODE 1: LOW ATMOSPHERE: 0- 3 km'''
39 '''MODE 1: LOW ATMOSPHERE: 0- 3 km'''
40 # opObj10 = procUnitConfObj1.addOperation(name='SnrFilter')
40 # opObj10 = procUnitConfObj1.addOperation(name='SnrFilter')
41 # opObj10.addParameter(name='snr_val', value='-10', format='float')
41 # opObj10.addParameter(name='snr_val', value='-10', format='float')
42 # opObj10.addParameter(name='modetofilter', value='1', format='int')
42 # opObj10.addParameter(name='modetofilter', value='1', format='int')
43 #
43 #
44 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
44 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
45 # opObj10.addParameter(name='svalue', value='meridional', format='str')
45 # opObj10.addParameter(name='svalue', value='meridional', format='str')
46 # opObj10.addParameter(name='svalue2', value='inTime', format='str')
46 # opObj10.addParameter(name='svalue2', value='inTime', format='str')
47 # opObj10.addParameter(name='method', value='0', format='float')
47 # opObj10.addParameter(name='method', value='0', format='float')
48 # opObj10.addParameter(name='factor', value='1', format='float')
48 # opObj10.addParameter(name='factor', value='1', format='float')
49 # opObj10.addParameter(name='filter', value='0', format='float')
49 # opObj10.addParameter(name='filter', value='0', format='float')
50 # opObj10.addParameter(name='npoints', value='5', format='float')
50 # opObj10.addParameter(name='npoints', value='5', format='float')
51 # opObj10.addParameter(name='modetofilter', value='1', format='int')
51 # opObj10.addParameter(name='modetofilter', value='1', format='int')
52 # #
52 # #
53 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
53 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
54 # opObj10.addParameter(name='svalue', value='zonal', format='str')
54 # opObj10.addParameter(name='svalue', value='zonal', format='str')
55 # opObj10.addParameter(name='svalue2', value='inTime', format='str')
55 # opObj10.addParameter(name='svalue2', value='inTime', format='str')
56 # opObj10.addParameter(name='method', value='0', format='float')
56 # opObj10.addParameter(name='method', value='0', format='float')
57 # opObj10.addParameter(name='factor', value='1', format='float')
57 # opObj10.addParameter(name='factor', value='1', format='float')
58 # opObj10.addParameter(name='filter', value='0', format='float')
58 # opObj10.addParameter(name='filter', value='0', format='float')
59 # opObj10.addParameter(name='npoints', value='5', format='float')
59 # opObj10.addParameter(name='npoints', value='5', format='float')
60 # opObj10.addParameter(name='modetofilter', value='1', format='int')
60 # opObj10.addParameter(name='modetofilter', value='1', format='int')
61 # #
61 # #
62 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
62 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
63 # opObj10.addParameter(name='svalue', value='vertical', format='str')
63 # opObj10.addParameter(name='svalue', value='vertical', format='str')
64 # opObj10.addParameter(name='svalue2', value='inHeight', format='str')
64 # opObj10.addParameter(name='svalue2', value='inHeight', format='str')
65 # opObj10.addParameter(name='method', value='0', format='float')
65 # opObj10.addParameter(name='method', value='0', format='float')
66 # opObj10.addParameter(name='factor', value='2', format='float')
66 # opObj10.addParameter(name='factor', value='2', format='float')
67 # opObj10.addParameter(name='filter', value='0', format='float')
67 # opObj10.addParameter(name='filter', value='0', format='float')
68 # opObj10.addParameter(name='npoints', value='9', format='float')
68 # opObj10.addParameter(name='npoints', value='9', format='float')
69 # opObj10.addParameter(name='modetofilter', value='1', format='int')
69 # opObj10.addParameter(name='modetofilter', value='1', format='int')
70 #
70 #
71
71
72 ''' MODE 2: 0 - 10 km '''
72 ''' MODE 2: 0 - 10 km '''
73
73
74 opObj10 = procUnitConfObj1.addOperation(name='SnrFilter')
74 opObj10 = procUnitConfObj1.addOperation(name='SnrFilter')
75 opObj10.addParameter(name='snr_val', value='-20', format='float')
75 opObj10.addParameter(name='snr_val', value='-20', format='float')
76 opObj10.addParameter(name='modetofilter', value='2', format='int')
76 opObj10.addParameter(name='modetofilter', value='2', format='int')
77
77
78 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
78 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
79 opObj10.addParameter(name='svalue', value='meridional', format='str')
79 opObj10.addParameter(name='svalue', value='meridional', format='str')
80 opObj10.addParameter(name='svalue2', value='inTime', format='str')
80 opObj10.addParameter(name='svalue2', value='inTime', format='str')
81 opObj10.addParameter(name='method', value='0', format='float')
81 opObj10.addParameter(name='method', value='0', format='float')
82 opObj10.addParameter(name='factor', value='2', format='float')
82 opObj10.addParameter(name='factor', value='2', format='float')
83 opObj10.addParameter(name='filter', value='0', format='float')
83 opObj10.addParameter(name='filter', value='0', format='float')
84 opObj10.addParameter(name='npoints', value='9', format='float')
84 opObj10.addParameter(name='npoints', value='9', format='float')
85 opObj10.addParameter(name='modetofilter', value='2', format='int')
85 opObj10.addParameter(name='modetofilter', value='2', format='int')
86 # #
86 # #
87 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
87 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
88 opObj10.addParameter(name='svalue', value='zonal', format='str')
88 opObj10.addParameter(name='svalue', value='zonal', format='str')
89 opObj10.addParameter(name='svalue2', value='inTime', format='str')
89 opObj10.addParameter(name='svalue2', value='inTime', format='str')
90 opObj10.addParameter(name='method', value='0', format='float')
90 opObj10.addParameter(name='method', value='0', format='float')
91 opObj10.addParameter(name='factor', value='2', format='float')
91 opObj10.addParameter(name='factor', value='2', format='float')
92 opObj10.addParameter(name='filter', value='0', format='float')
92 opObj10.addParameter(name='filter', value='0', format='float')
93 opObj10.addParameter(name='npoints', value='9', format='float')
93 opObj10.addParameter(name='npoints', value='9', format='float')
94 opObj10.addParameter(name='modetofilter', value='2', format='int')
94 opObj10.addParameter(name='modetofilter', value='2', format='int')
95 # #
95 # #
96 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
96 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
97 opObj10.addParameter(name='svalue', value='vertical', format='str')
97 opObj10.addParameter(name='svalue', value='vertical', format='str')
98 opObj10.addParameter(name='svalue2', value='inHeight', format='str')
98 opObj10.addParameter(name='svalue2', value='inHeight', format='str')
99 opObj10.addParameter(name='method', value='0', format='float')
99 opObj10.addParameter(name='method', value='0', format='float')
100 opObj10.addParameter(name='factor', value='2', format='float')
100 opObj10.addParameter(name='factor', value='2', format='float')
101 opObj10.addParameter(name='filter', value='0', format='float')
101 opObj10.addParameter(name='filter', value='0', format='float')
102 opObj10.addParameter(name='npoints', value='9', format='float')
102 opObj10.addParameter(name='npoints', value='9', format='float')
103 opObj10.addParameter(name='modetofilter', value='2', format='int')
103 opObj10.addParameter(name='modetofilter', value='2', format='int')
104
104
105 # '''-----------------------------------------Writing-------------------------------------------'''
105 # '''-----------------------------------------Writing-------------------------------------------'''
106 #
106 #
107 # # opObj10 = procUnitConfObj1.addOperation(name='testBLTRWriter',optype='other')
107 # # opObj10 = procUnitConfObj1.addOperation(name='testBLTRWriter',optype='other')
108 # # opObj10.addParameter(name='path', value = pathhdf5)
108 # # opObj10.addParameter(name='path', value = pathhdf5)
109 # # opObj10.addParameter(name='modetowrite', value = '2',format='int')
109 # # opObj10.addParameter(name='modetowrite', value = '2',format='int')
110 # #
110 # #
111 # # opObj10 = procUnitConfObj1.addOperation(name='testBLTRWriter',optype='other')
111 # # opObj10 = procUnitConfObj1.addOperation(name='testBLTRWriter',optype='other')
112 # # opObj10.addParameter(name='path', value = pathhdf5)
112 # # opObj10.addParameter(name='path', value = pathhdf5)
113 # # opObj10.addParameter(name='modetowrite', value = '1',format='int')
113 # # opObj10.addParameter(name='modetowrite', value = '1',format='int')
114 #
114 #
115 # '''----------------------------------------Plotting--------------------------------------------'''
115 # '''----------------------------------------Plotting--------------------------------------------'''
116 #
116 #
117 opObj10 = procUnitConfObj1.addOperation(name='prePlot')
117 opObj10 = procUnitConfObj1.addOperation(name='prePlot')
118 opObj10.addParameter(name='modeselect',value='1',format='int')
118 opObj10.addParameter(name='modeselect',value='1',format='int')
119 # #
119 # #
120 opObj10 = procUnitConfObj1.addOperation(name='WindProfilerPlot', optype='other')
120 opObj10 = procUnitConfObj1.addOperation(name='WindProfilerPlot', optype='other')
121 opObj10.addParameter(name='id', value='1', format='int')
121 opObj10.addParameter(name='id', value='1', format='int')
122 opObj10.addParameter(name='wintitle', value='', format='str')
122 opObj10.addParameter(name='wintitle', value='', format='str')
123 opObj10.addParameter(name='channelList', value='0', format='intlist')
123 opObj10.addParameter(name='channelList', value='0', format='intlist')
124 #opObj10.addParameter(name='save', value='1', format='bool')
124 #opObj10.addParameter(name='save', value='1', format='bool')
125 #opObj10.addParameter(name='figpath', value=figpath, format='str')
125 #opObj10.addParameter(name='figpath', value=figpath, format='str')
126 opObj10.addParameter(name='SNRmin', value='-10', format='int')
126 opObj10.addParameter(name='SNRmin', value='-10', format='int')
127 opObj10.addParameter(name='SNRmax', value='50', format='int')
127 opObj10.addParameter(name='SNRmax', value='50', format='int')
128 opObj10.addParameter(name='SNRthresh', value='0', format='float')
128 opObj10.addParameter(name='SNRthresh', value='0', format='float')
129 opObj10.addParameter(name='xmin', value='0', format='float')
129 opObj10.addParameter(name='xmin', value='0', format='float')
130 opObj10.addParameter(name='xmax', value='24', format='float')
130 opObj10.addParameter(name='xmax', value='24', format='float')
131 opObj10.addParameter(name='ymax', value='3', format='float')
131 opObj10.addParameter(name='ymax', value='3', format='float')
132 opObj10.addParameter(name='zmin', value='-20', format='float')
132 opObj10.addParameter(name='zmin', value='-20', format='float')
133 opObj10.addParameter(name='zmax', value='20', format='float')
133 opObj10.addParameter(name='zmax', value='20', format='float')
134 opObj10.addParameter(name='zmin_ver', value='-200', format='float')
134 opObj10.addParameter(name='zmin_ver', value='-200', format='float')
135 opObj10.addParameter(name='zmax_ver', value='200', format='float')
135 opObj10.addParameter(name='zmax_ver', value='200', format='float')
136 #opObj10.addParameter(name='showprofile', value='1', format='bool')
136 #opObj10.addParameter(name='showprofile', value='1', format='bool')
137 #opObj10.addParameter(name='show', value='1', format='bool')
137 #opObj10.addParameter(name='show', value='1', format='bool')
138
138
139 opObj10 = procUnitConfObj1.addOperation(name='prePlot')
139 opObj10 = procUnitConfObj1.addOperation(name='prePlot')
140 opObj10.addParameter(name='modeselect',value='2',format='int')
140 opObj10.addParameter(name='modeselect',value='2',format='int')
141 #
141 #
142 opObj10 = procUnitConfObj1.addOperation(name='WindProfilerPlot', optype='other')
142 opObj10 = procUnitConfObj1.addOperation(name='WindProfilerPlot', optype='other')
143 opObj10.addParameter(name='id', value='2', format='int')
143 opObj10.addParameter(name='id', value='2', format='int')
144 opObj10.addParameter(name='wintitle', value='', format='str')
144 opObj10.addParameter(name='wintitle', value='', format='str')
145 #opObj10.addParameter(name='channelList', value='0', format='intlist')
145 #opObj10.addParameter(name='channelList', value='0', format='intlist')
146 #opObj10.addParameter(name='save', value='1', format='bool')
146 opObj10.addParameter(name='save', value='1', format='bool')
147 #opObj10.addParameter(name='figpath', value=figpath, format='str')
147 opObj10.addParameter(name='figpath', value=figpath, format='str')
148 opObj10.addParameter(name='SNRmin', value='-20', format='int')
148 opObj10.addParameter(name='SNRmin', value='-20', format='int')
149 opObj10.addParameter(name='SNRmax', value='40', format='int')
149 opObj10.addParameter(name='SNRmax', value='40', format='int')
150 opObj10.addParameter(name='SNRthresh', value='0', format='float')
150 opObj10.addParameter(name='SNRthresh', value='0', format='float')
151 opObj10.addParameter(name='xmin', value='0', format='float')
151 opObj10.addParameter(name='xmin', value='0', format='float')
152 opObj10.addParameter(name='xmax', value='24', format='float')
152 opObj10.addParameter(name='xmax', value='24', format='float')
153 #opObj10.addParameter(name='ymax', value='8', format='float')
153 opObj10.addParameter(name='ymin', value='0', format='float')
154 opObj10.addParameter(name='ymax', value='10', format='float')
154 opObj10.addParameter(name='zmin', value='-4', format='float')
155 opObj10.addParameter(name='zmin', value='-4', format='float')
155 opObj10.addParameter(name='zmax', value='4', format='float')
156 opObj10.addParameter(name='zmax', value='4', format='float')
156 opObj10.addParameter(name='zmin_ver', value='-200', format='float')
157 opObj10.addParameter(name='zmin_ver', value='-200', format='float')
157 opObj10.addParameter(name='zmax_ver', value='200', format='float')
158 opObj10.addParameter(name='zmax_ver', value='200', format='float')
158 #opObj10.addParameter(name='showprofile', value='1', format='bool')
159 #opObj10.addParameter(name='showprofile', value='1', format='bool')
159 #opObj10.addParameter(name='show', value='1', format='bool')
160 #opObj10.addParameter(name='show', value='1', format='bool')
160
161
161 # # print "Escribiendo el archivo XML"
162 # # print "Escribiendo el archivo XML"
162 # controllerObj.writeXml(filename)
163 # controllerObj.writeXml(filename)
163 # # print "Leyendo el archivo XML"
164 # # print "Leyendo el archivo XML"
164 # controllerObj.readXml(filename)
165 # controllerObj.readXml(filename)
165
166
166 # controllerObj.createObjects()
167 # controllerObj.createObjects()
167 # controllerObj.connectObjects()
168 # controllerObj.connectObjects()
168 # controllerObj.run()
169 # controllerObj.run()
169 controllerObj.start()
170 controllerObj.start()
170
171
@@ -1,146 +1,150
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 import os, sys
2 import os, sys
3
3
4 # path = os.path.dirname(os.getcwd())
4 # path = os.path.dirname(os.getcwd())
5 # path = os.path.join(path, 'source')
5 # path = os.path.join(path, 'source')
6 # sys.path.insert(0, '../')
6 # sys.path.insert(0, '../')
7
7
8 from schainpy.controller import Project
8 from schainpy.controller import Project
9
9
10 xmin = '15.5'
10 xmin = '15.5'
11 xmax = '24'
11 xmax = '24'
12
12
13
13 desc = "ProcBLTR Test"
14 desc = "ProcBLTR Test"
14 filename = "ProcBLTR.xml"
15 filename = "ProcBLTR.xml"
16 figpath = '/media/erick/6F60F7113095A154/BLTR'
15
17
16 controllerObj = Project()
18 controllerObj = Project()
17
19
18
20
19 controllerObj.setup(id='191', name='test01', description=desc)
21 controllerObj.setup(id='191', name='test01', description=desc)
20
22
21 readUnitConfObj = controllerObj.addReadUnit(datatype='BLTRReader',
23 readUnitConfObj = controllerObj.addReadUnit(datatype='BLTRReader',
22 path='/home/erick/Documents/Data/BLTR_Data/fdt/',
24 path='/media/erick/6F60F7113095A154/BLTR/',
23
25
24 endDate='2017/10/19',
26 endDate='2017/10/19',
25 startTime='13:00:00',
27 startTime='13:00:00',
26 startDate='2016/11/8',
28 startDate='2016/11/8',
27 endTime='23:59:59',
29 endTime='23:59:59',
28
30
29
31
30 online=0,
32 online=0,
31 walk=0,
33 walk=0,
32 ReadMode='1')
34 ReadMode='1')
33 # expLabel='')
35 # expLabel='')
34
36
35 # opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
37 # opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
36
38
37 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
39 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
38
40
39
41
40
42
41 opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
43 opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
42 opObj11.addParameter(name='n', value='2', format='float')
44 opObj11.addParameter(name='n', value='3', format='float')
43
45
44 opObj10 = procUnitConfObj1.addOperation(name='removeDC')
46 opObj10 = procUnitConfObj1.addOperation(name='removeDC')
45
47
46 # opObj10 = procUnitConfObj1.addOperation(name='calcMag')
48 # opObj10 = procUnitConfObj1.addOperation(name='calcMag')
47
49
48 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
50 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
49 # opObj11.addParameter(name='id', value='21', format='int')
51 # opObj11.addParameter(name='id', value='21', format='int')
50 # opObj11.addParameter(name='wintitle', value='SpectraCutPlot', format='str')
52 # opObj11.addParameter(name='wintitle', value='SpectraCutPlot', format='str')
51 # opObj11.addParameter(name='xaxis', value='frequency', format='str')
53 # opObj11.addParameter(name='xaxis', value='frequency', format='str')
52 # opObj11.addParameter(name='colormap', value='winter', format='str')
54 # opObj11.addParameter(name='colormap', value='winter', format='str')
53 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
55 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
54 # opObj11.addParameter(name='xmax', value='0.005', format='float')
56 # opObj11.addParameter(name='xmax', value='0.005', format='float')
55 # #opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
57 # #opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
56 # #opObj10.addParameter(name='channelList', value='0,1', format='intlist')
58 # #opObj10.addParameter(name='channelList', value='0,1', format='intlist')
57 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
59 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
58 # opObj11.addParameter(name='id', value='21', format='int')
60 # opObj11.addParameter(name='id', value='21', format='int')
59 # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
61 # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
60 # #opObj11.addParameter(name='xaxis', value='Velocity', format='str')
62 # #opObj11.addParameter(name='xaxis', value='Velocity', format='str')
61
63
62 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
64 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
63 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
65 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
64 # opObj11.addParameter(name='xmax', value='0.005', format='float')
66 # opObj11.addParameter(name='xmax', value='0.005', format='float')
65
67
66 # opObj11.addParameter(name='ymin', value='225', format='float')
68 # opObj11.addParameter(name='ymin', value='225', format='float')
67 # opObj11.addParameter(name='ymax', value='3000', format='float')
69 # opObj11.addParameter(name='ymax', value='3000', format='float')
68 # opObj11.addParameter(name='zmin', value='-100', format='int')
70 # opObj11.addParameter(name='zmin', value='-100', format='int')
69 # opObj11.addParameter(name='zmax', value='-65', format='int')
71 # opObj11.addParameter(name='zmax', value='-65', format='int')
70
72
71 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
73 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
72 # opObj11.addParameter(name='id', value='10', format='int')
74 # opObj11.addParameter(name='id', value='10', format='int')
73 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
75 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
74 # opObj11.addParameter(name='ymin', value='0', format='float')
76 # opObj11.addParameter(name='ymin', value='0', format='float')
75 # opObj11.addParameter(name='ymax', value='4000', format='float')
77 # opObj11.addParameter(name='ymax', value='4000', format='float')
76 # #opObj11.addParameter(name='zmin', value='-100', format='int')
78 # #opObj11.addParameter(name='zmin', value='-100', format='int')
77 # #opObj11.addParameter(name='zmax', value='-70', format='int')
79 # #opObj11.addParameter(name='zmax', value='-70', format='int')
78 # opObj11.addParameter(name='zmin', value='-90', format='int')
80 # opObj11.addParameter(name='zmin', value='-90', format='int')
79 # opObj11.addParameter(name='zmax', value='-40', format='int')
81 # opObj11.addParameter(name='zmax', value='-40', format='int')
80 # opObj11.addParameter(name='showprofile', value='1', format='int')
82 # opObj11.addParameter(name='showprofile', value='1', format='int')
81 # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int')
83 # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int')
82
84
83 opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
85 opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
84 procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
86 procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
85 opObj11.addParameter(name='id', value='2005', format='int')
87 opObj11.addParameter(name='id', value='2005', format='int')
86 opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
88 opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
87 # opObj11.addParameter(name='exp_code', value='13', format='int')
89 # opObj11.addParameter(name='exp_code', value='13', format='int')
88 opObj11.addParameter(name='xaxis', value='Velocity', format='str')
90 opObj11.addParameter(name='xaxis', value='Velocity', format='str')
89 #opObj11.addParameter(name='xmin', value='-10', format='float')
91 #opObj11.addParameter(name='xmin', value='-10', format='float')
90 #opObj11.addParameter(name='xmax', value='10', format='float')
92 #opObj11.addParameter(name='xmax', value='10', format='float')
91 #opObj11.addParameter(name='ymin', value='225', format='float')
93 #opObj11.addParameter(name='ymin', value='225', format='float')
92 #opObj11.addParameter(name='ymax', value='3000', format='float')
94 #opObj11.addParameter(name='ymax', value='3000', format='float')
93 #opObj11.addParameter(name='phase_min', value='-4', format='int')
95 #opObj11.addParameter(name='phase_min', value='-4', format='int')
94 #opObj11.addParameter(name='phase_max', value='4', format='int')
96 #opObj11.addParameter(name='phase_max', value='4', format='int')
95
97
96 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj1.getId())
98 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj1.getId())
97 # procUnitConfObj2.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
99 # procUnitConfObj2.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
98
100
99 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId())
101 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId())
100 opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
102 opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
101 opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other')
103 opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other')
102 #
104 #
103 opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other')
105 opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other')
104 opObj22.addParameter(name='id', value='4', format='int')
106 opObj22.addParameter(name='id', value='4', format='int')
105 opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str')
107 opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str')
106 opObj22.addParameter(name='save', value='1', format='bool')
108 opObj22.addParameter(name='save', value='1', format='bool')
107 # opObj22.addParameter(name='figpath', value = '/home/erick/Pictures', format='str')
109 # opObj22.addParameter(name='figpath', value = '/home/erick/Pictures', format='str')
108
110
109 opObj22.addParameter(name='zmin', value='-20', format='int')
111 opObj22.addParameter(name='zmin', value='-20', format='int')
110 opObj22.addParameter(name='zmax', value='20', format='int')
112 opObj22.addParameter(name='zmax', value='20', format='int')
111 opObj22.addParameter(name='zmin_ver', value='-250', format='float')
113 opObj22.addParameter(name='zmin_ver', value='-250', format='float')
112 opObj22.addParameter(name='zmax_ver', value='250', format='float')
114 opObj22.addParameter(name='zmax_ver', value='250', format='float')
113 opObj22.addParameter(name='SNRmin', value='-5', format='int')
115 opObj22.addParameter(name='SNRmin', value='-5', format='int')
114 opObj22.addParameter(name='SNRmax', value='30', format='int')
116 opObj22.addParameter(name='SNRmax', value='30', format='int')
115 # opObj22.addParameter(name='SNRthresh', value='-3.5', format='float')
117 # opObj22.addParameter(name='SNRthresh', value='-3.5', format='float')
116 opObj22.addParameter(name='xmin', value=0, format='float')
118 opObj22.addParameter(name='xmin', value=0, format='float')
117 opObj22.addParameter(name='xmax', value=24, format='float')
119 opObj22.addParameter(name='xmax', value=24, format='float')
118 opObj22.addParameter(name='ymin', value='225', format='float')
120 opObj22.addParameter(name='ymin', value='225', format='float')
119 #opObj22.addParameter(name='ymax', value='2000', format='float')
121 #opObj22.addParameter(name='ymax', value='2000', format='float')
120
122 opObj22.addParameter(name='save', value='1', format='int')
121
123 opObj22.addParameter(name='figpath', value=figpath, format='str')
124
125
122 # opObj11.addParameter(name='pairlist', value='(1,0),(0,2),(1,2)', format='pairsList')
126 # opObj11.addParameter(name='pairlist', value='(1,0),(0,2),(1,2)', format='pairsList')
123 #opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
127 #opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
124 #opObj10.addParameter(name='minHei', value='225', format='float')
128 #opObj10.addParameter(name='minHei', value='225', format='float')
125 #opObj10.addParameter(name='maxHei', value='1000', format='float')
129 #opObj10.addParameter(name='maxHei', value='1000', format='float')
126
130
127 # opObj11 = procUnitConfObj1.addOperation(name='CoherenceMap', optype='other')
131 # opObj11 = procUnitConfObj1.addOperation(name='CoherenceMap', optype='other')
128 # opObj11.addParameter(name='id', value='102', format='int')
132 # opObj11.addParameter(name='id', value='102', format='int')
129 # opObj11.addParameter(name='wintitle', value='Coherence', format='str')
133 # opObj11.addParameter(name='wintitle', value='Coherence', format='str')
130 # opObj11.addParameter(name='ymin', value='225', format='float')
134 # opObj11.addParameter(name='ymin', value='225', format='float')
131 # opObj11.addParameter(name='ymax', value='4000', format='float')
135 # opObj11.addParameter(name='ymax', value='4000', format='float')
132
136
133 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
137 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
134 # opObj11.addParameter(name='xmin', value='8.5', format='float')
138 # opObj11.addParameter(name='xmin', value='8.5', format='float')
135 # opObj11.addParameter(name='xmax', value='9.5', format='float')
139 # opObj11.addParameter(name='xmax', value='9.5', format='float')
136 # opObj11.addParameter(name='figpath', value=figpath, format='str')
140 # opObj11.addParameter(name='figpath', value=figpath, format='str')
137 # opObj11.addParameter(name='save', value=1, format='bool')
141 # opObj11.addParameter(name='save', value=1, format='bool')
138 # opObj11.addParameter(name='pairsList', value='(1,0),(3,2)', format='pairsList')
142 # opObj11.addParameter(name='pairsList', value='(1,0),(3,2)', format='pairsList')
139
143
140 # opObj12 = procUnitConfObj1.addOperation(name='PublishData', optype='other')
144 # opObj12 = procUnitConfObj1.addOperation(name='PublishData', optype='other')
141 # opObj12.addParameter(name='zeromq', value=1, format='int')
145 # opObj12.addParameter(name='zeromq', value=1, format='int')
142 # opObj12.addParameter(name='verbose', value=0, format='bool')
146 # opObj12.addParameter(name='verbose', value=0, format='bool')
143 # opObj12.addParameter(name='server', value='erick2', format='str')
147 # opObj12.addParameter(name='server', value='erick2', format='str')
144 controllerObj.start()
148 controllerObj.start()
145
149
146
150
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now