##// END OF EJS Templates
BLTRParamreader ready
Juan C. Espinoza -
r1010:0630a39b8282
parent child
Show More
@@ -0,0 +1,364
1 '''
2 Created on Nov 9, 2016
3
4 @author: roj- LouVD
5 '''
6
7
8 import os
9 import sys
10 import time
11 import glob
12 import datetime
13 import numpy
14
15 from schainpy.model.proc.jroproc_base import ProcessingUnit
16 from schainpy.model.data.jrodata import Parameters
17 from schainpy.model.io.jroIO_base import JRODataReader, isNumber
18
19 FILE_HEADER_STRUCTURE = numpy.dtype([
20 ('FMN', '<u4'),
21 ('nrec', '<u4'),
22 ('fr_offset', '<u4'),
23 ('id', '<u4'),
24 ('site', 'u1', (32,))
25 ])
26
27 REC_HEADER_STRUCTURE = numpy.dtype([
28 ('rmn', '<u4'),
29 ('rcounter', '<u4'),
30 ('nr_offset', '<u4'),
31 ('tr_offset', '<u4'),
32 ('time', '<u4'),
33 ('time_msec', '<u4'),
34 ('tag', 'u1', (32,)),
35 ('comments', 'u1', (32,)),
36 ('lat', '<f4'),
37 ('lon', '<f4'),
38 ('gps_status', '<u4'),
39 ('freq', '<u4'),
40 ('freq0', '<u4'),
41 ('nchan', '<u4'),
42 ('delta_r', '<u4'),
43 ('nranges', '<u4'),
44 ('r0', '<u4'),
45 ('prf', '<u4'),
46 ('ncoh', '<u4'),
47 ('npoints', '<u4'),
48 ('polarization', '<i4'),
49 ('rx_filter', '<u4'),
50 ('nmodes', '<u4'),
51 ('dmode_index', '<u4'),
52 ('dmode_rngcorr', '<u4'),
53 ('nrxs', '<u4'),
54 ('acf_length', '<u4'),
55 ('acf_lags', '<u4'),
56 ('sea_to_atmos', '<f4'),
57 ('sea_notch', '<u4'),
58 ('lh_sea', '<u4'),
59 ('hh_sea', '<u4'),
60 ('nbins_sea', '<u4'),
61 ('min_snr', '<f4'),
62 ('min_cc', '<f4'),
63 ('max_time_diff', '<f4')
64 ])
65
66 DATA_STRUCTURE = numpy.dtype([
67 ('range', '<u4'),
68 ('status', '<u4'),
69 ('zonal', '<f4'),
70 ('meridional', '<f4'),
71 ('vertical', '<f4'),
72 ('zonal_a', '<f4'),
73 ('meridional_a', '<f4'),
74 ('corrected_fading', '<f4'), # seconds
75 ('uncorrected_fading', '<f4'), # seconds
76 ('time_diff', '<f4'),
77 ('major_axis', '<f4'),
78 ('axial_ratio', '<f4'),
79 ('orientation', '<f4'),
80 ('sea_power', '<u4'),
81 ('sea_algorithm', '<u4')
82 ])
83
84 class BLTRParamReader(JRODataReader, ProcessingUnit):
85 '''
86 Boundary Layer and Tropospheric Radar (BLTR) reader, Wind velocities and SNR from *.sswma files
87 '''
88
89 ext = '.sswma'
90
91 def __init__(self, **kwargs):
92
93 ProcessingUnit.__init__(self , **kwargs)
94
95 self.dataOut = Parameters()
96 self.counter_records = 0
97 self.flagNoMoreFiles = 0
98 self.isConfig = False
99 self.filename = None
100
101 def setup(self,
102 path=None,
103 startDate=None,
104 endDate=None,
105 ext=None,
106 startTime=datetime.time(0, 0, 0),
107 endTime=datetime.time(23, 59, 59),
108 timezone=0,
109 status_value=0,
110 **kwargs):
111
112 self.path = path
113 self.startTime = startTime
114 self.endTime = endTime
115 self.status_value = status_value
116
117 if self.path is None:
118 raise ValueError, "The path is not valid"
119
120 if ext is None:
121 ext = self.ext
122
123 self.search_files(self.path, startDate, endDate, ext)
124 self.timezone = timezone
125 self.fileIndex = 0
126
127 if not self.fileList:
128 raise Warning, "There is no files matching these date in the folder: %s. \n Check 'startDate' and 'endDate' "%(path)
129
130 self.setNextFile()
131
132 def search_files(self, path, startDate, endDate, ext):
133 '''
134 Searching for BLTR rawdata file in path
135 Creating a list of file to proces included in [startDate,endDate]
136
137 Input:
138 path - Path to find BLTR rawdata files
139 startDate - Select file from this date
140 enDate - Select file until this date
141 ext - Extension of the file to read
142
143 '''
144
145 print 'Searching file in %s ' % (path)
146 foldercounter = 0
147 fileList0 = glob.glob1(path, "*%s" % ext)
148 fileList0.sort()
149
150 self.fileList = []
151 self.dateFileList = []
152
153 for thisFile in fileList0:
154 year = thisFile[-14:-10]
155 if not isNumber(year):
156 continue
157
158 month = thisFile[-10:-8]
159 if not isNumber(month):
160 continue
161
162 day = thisFile[-8:-6]
163 if not isNumber(day):
164 continue
165
166 year, month, day = int(year), int(month), int(day)
167 dateFile = datetime.date(year, month, day)
168
169 if (startDate > dateFile) or (endDate < dateFile):
170 continue
171
172 self.fileList.append(thisFile)
173 self.dateFileList.append(dateFile)
174
175 return
176
177 def setNextFile(self):
178
179 file_id = self.fileIndex
180
181 if file_id == len(self.fileList):
182 print '\nNo more files in the folder'
183 print 'Total number of file(s) read : {}'.format(self.fileIndex + 1)
184 self.flagNoMoreFiles = 1
185 return 0
186
187 print '\n[Setting file] (%s) ...' % self.fileList[file_id]
188 filename = os.path.join(self.path, self.fileList[file_id])
189
190 dirname, name = os.path.split(filename)
191 self.siteFile = name.split('.')[0] # 'peru2' ---> Piura - 'peru1' ---> Huancayo or Porcuya
192 if self.filename is not None:
193 self.fp.close()
194 self.filename = filename
195 self.fp = open(self.filename, 'rb')
196 self.header_file = numpy.fromfile(self.fp, FILE_HEADER_STRUCTURE, 1)
197 self.nrecords = self.header_file['nrec'][0]
198 self.sizeOfFile = os.path.getsize(self.filename)
199 self.counter_records = 0
200 self.flagIsNewFile = 0
201 self.fileIndex += 1
202
203 return 1
204
205 def readNextBlock(self):
206
207 while True:
208 if self.counter_records == self.nrecords:
209 self.flagIsNewFile = 1
210 if not self.setNextFile():
211 return 0
212
213 self.readBlock()
214
215 if (self.datatime.time() < self.startTime) or (self.datatime.time() > self.endTime):
216 print "[Reading] Record No. %d/%d -> %s [Skipping]" %(
217 self.counter_records,
218 self.nrecords,
219 self.datatime.ctime())
220 continue
221 break
222
223 print "[Reading] Record No. %d/%d -> %s" %(
224 self.counter_records,
225 self.nrecords,
226 self.datatime.ctime())
227
228 return 1
229
230 def readBlock(self):
231
232 pointer = self.fp.tell()
233 header_rec = numpy.fromfile(self.fp, REC_HEADER_STRUCTURE, 1)
234 self.nchannels = header_rec['nchan'][0]/2
235 self.kchan = header_rec['nrxs'][0]
236 self.nmodes = header_rec['nmodes'][0]
237 self.nranges = header_rec['nranges'][0]
238 self.fp.seek(pointer)
239 self.height = numpy.empty((self.nmodes, self.nranges))
240 self.snr = numpy.empty((self.nmodes, self.nchannels, self.nranges))
241 self.buffer = numpy.empty((self.nmodes, 3, self.nranges))
242
243 for mode in range(self.nmodes):
244 self.readHeader()
245 data = self.readData()
246 self.height[mode] = (data[0] - self.correction) / 1000.
247 self.buffer[mode] = data[1]
248 self.snr[mode] = data[2]
249
250 self.counter_records = self.counter_records + self.nmodes
251
252 return
253
254 def readHeader(self):
255 '''
256 RecordHeader of BLTR rawdata file
257 '''
258
259 header_structure = numpy.dtype(
260 REC_HEADER_STRUCTURE.descr + [
261 ('antenna_coord', 'f4', (2, self.nchannels)),
262 ('rx_gains', 'u4', (self.nchannels,)),
263 ('rx_analysis', 'u4', (self.nchannels,))
264 ]
265 )
266
267 self.header_rec = numpy.fromfile(self.fp, header_structure, 1)
268 self.lat = self.header_rec['lat'][0]
269 self.lon = self.header_rec['lon'][0]
270 self.delta = self.header_rec['delta_r'][0]
271 self.correction = self.header_rec['dmode_rngcorr'][0]
272 self.imode = self.header_rec['dmode_index'][0]
273 self.antenna = self.header_rec['antenna_coord']
274 self.rx_gains = self.header_rec['rx_gains']
275 self.time1 = self.header_rec['time'][0]
276 tseconds = self.header_rec['time'][0]
277 local_t1 = time.localtime(tseconds)
278 self.year = local_t1.tm_year
279 self.month = local_t1.tm_mon
280 self.day = local_t1.tm_mday
281 self.t = datetime.datetime(self.year, self.month, self.day)
282 self.datatime = datetime.datetime.utcfromtimestamp(self.time1)
283
284 def readData(self):
285 '''
286 Reading and filtering data block record of BLTR rawdata file, filtering is according to status_value.
287
288 Input:
289 status_value - Array data is set to NAN for values that are not equal to status_value
290
291 '''
292
293 data_structure = numpy.dtype(
294 DATA_STRUCTURE.descr + [
295 ('rx_saturation', 'u4', (self.nchannels,)),
296 ('chan_offset', 'u4', (2 * self.nchannels,)),
297 ('rx_amp', 'u4', (self.nchannels,)),
298 ('rx_snr', 'f4', (self.nchannels,)),
299 ('cross_snr', 'f4', (self.kchan,)),
300 ('sea_power_relative', 'f4', (self.kchan,))]
301 )
302
303 data = numpy.fromfile(self.fp, data_structure, self.nranges)
304
305 height = data['range']
306 winds = numpy.array((data['zonal'], data['meridional'], data['vertical']))
307 snr = data['rx_snr'].T
308
309 winds[numpy.where(winds == -9999.)] = numpy.nan
310 winds[:, numpy.where(data['status'] != self.status_value)] = numpy.nan
311 snr[numpy.where(snr == -9999.)] = numpy.nan
312 snr[:, numpy.where(data['status'] != self.status_value)] = numpy.nan
313 snr = numpy.power(10, snr / 10)
314
315 return height, winds, snr
316
317 def set_output(self):
318 '''
319 Storing data from databuffer to dataOut object
320 '''
321
322 self.dataOut.time1 = self.time1
323 self.dataOut.data_SNR = self.snr
324 self.dataOut.height= self.height
325 self.dataOut.data_output = self.buffer
326 self.dataOut.utctimeInit = self.time1
327 self.dataOut.utctime = self.dataOut.utctimeInit
328 self.dataOut.counter_records = self.counter_records
329 self.dataOut.nrecords = self.nrecords
330 self.dataOut.useLocalTime = False
331 self.dataOut.paramInterval = 157
332 self.dataOut.timezone = self.timezone
333 self.dataOut.site = self.siteFile
334 self.dataOut.nrecords = self.nrecords
335 self.dataOut.sizeOfFile = self.sizeOfFile
336 self.dataOut.lat = self.lat
337 self.dataOut.lon = self.lon
338 self.dataOut.channelList = range(self.nchannels)
339 self.dataOut.kchan = self.kchan
340 # self.dataOut.nHeights = self.nranges
341 self.dataOut.delta = self.delta
342 self.dataOut.correction = self.correction
343 self.dataOut.nmodes = self.nmodes
344 self.dataOut.imode = self.imode
345 self.dataOut.antenna = self.antenna
346 self.dataOut.rx_gains = self.rx_gains
347 self.dataOut.flagNoData = False
348
349 def getData(self):
350 '''
351 Storing data from databuffer to dataOut object
352 '''
353 if self.flagNoMoreFiles:
354 self.dataOut.flagNoData = True
355 print 'No file left to process'
356 return 0
357
358 if not(self.readNextBlock()):
359 self.dataOut.flagNoData = True
360 return 0
361
362 self.set_output()
363
364 return 1
@@ -0,0 +1,375
1 '''
2 Created on Aug 1, 2017
3
4 @author: Juan C. Espinoza
5 '''
6
7 import os
8 import sys
9 import time
10 import datetime
11
12 import numpy
13
14 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
15 from schainpy.model.data.jrodata import Parameters
16 from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader
17 from schainpy.model.graphics.jroplot_parameters import WindProfilerPlot
18 from schainpy.model.io.jroIO_base import *
19
20 try:
21 import madrigal
22 import madrigal.cedar
23 from madrigal.cedar import MadrigalCatalogRecord
24 except:
25 print 'You should install "madrigal library" module if you want to read/write Madrigal data'
26
27
28 class MADWriter(Operation):
29
30 def __init__(self):
31
32 Operation.__init__(self)
33 self.dataOut = Parameters()
34 self.path = None
35 self.dataOut = None
36 self.flagIsNewFile=1
37 self.ext = ".hdf5"
38
39 return
40
41 def run(self, dataOut, path , modetowrite,**kwargs):
42
43 if self.flagIsNewFile:
44 flagdata = self.setup(dataOut, path, modetowrite)
45
46 self.putData()
47 return
48
49 def setup(self, dataOut, path, modetowrite):
50 '''
51 Recovering data to write in new *.hdf5 file
52 Inputs:
53 modew -- mode to write (1 or 2)
54 path -- destination path
55
56 '''
57
58 self.im = modetowrite-1
59 if self.im!=0 and self.im!=1:
60 raise ValueError, 'Check "modetowrite" value. Must be egual to 1 or 2, "{}" is not valid. '.format(modetowrite)
61
62 self.dataOut = dataOut
63 self.nmodes = self.dataOut.nmodes
64 self.nchannels = self.dataOut.nchannels
65 self.lat = self.dataOut.lat
66 self.lon = self.dataOut.lon
67 self.hcm = 3
68 self.thisDate = self.dataOut.utctimeInit
69 self.year = self.dataOut.year
70 self.month = self.dataOut.month
71 self.day = self.dataOut.day
72 self.path = path
73
74 self.flagIsNewFile = 0
75
76 return 1
77
78 def setFile(self):
79 '''
80 - Determining the file name for each mode of operation
81 kinst - Kind of Instrument (mnemotic)
82 kindat - Kind of Data (mnemotic)
83
84 - Creating a cedarObject
85
86 '''
87 lat_piura = -5.17
88 lat_huancayo = -12.04
89 lat_porcuya = -5.8
90
91 if '%2.2f' % self.lat == '%2.2f' % lat_piura:
92 self.instMnemonic = 'pbr'
93
94 elif '%2.2f' % self.lat == '%2.2f' % lat_huancayo:
95 self.instMnemonic = 'hbr'
96
97 elif '%2.2f' % self.lat == '%2.2f' % lat_porcuya:
98 self.instMnemonic = 'obr'
99 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 "
100
101 mode = ['_mode1','_mode2']
102
103 self.hdf5filename = '%s%4.4d%2.2d%2.2d%s%s' % (self.instMnemonic,
104 self.year,
105 self.month,
106 self.day,
107 mode[self.im],
108 self.ext)
109
110 self.fullname=os.path.join(self.path,self.hdf5filename)
111
112 if os.path.isfile(self.fullname) :
113 print "Destination path '%s' already exists. Previous file deleted. " %self.fullname
114 os.remove(self.fullname)
115
116 # Identify kinst and kindat
117 InstName = self.hdf5filename[0:3]
118 KinstList = [1000, 1001, 1002]
119 KinstId = {'pbr':0, 'hbr':1, 'obr':2} # pbr:piura, hbr:huancayo, obr:porcuya
120 KindatList = [1600, 1601] # mode 1, mode 2
121 self.type = KinstId[InstName]
122 self.kinst = KinstList[self.type]
123 self.kindat = KindatList[self.im]
124
125 try:
126 self.cedarObj = madrigal.cedar.MadrigalCedarFile(self.fullname, True)
127 except ValueError, message:
128 print '[Error]: Impossible to create a cedar object with "madrigal.cedar.MadrigalCedarFile" '
129 return
130
131 return 1
132
133 def writeBlock(self):
134 '''
135 - Selecting mode of operation:
136
137 bltr high resolution mode 1 - Low Atmosphere (0 - 3km) // bltr high resolution mode 2 - High Atmosphere (0 - 10km)
138 msnr - Average Signal Noise Ratio in dB
139 hcm - 3 km
140
141 - Filling the cedarObject by a block: each array data entry is assigned a code that defines the parameter to write to the file
142
143 GDLATR - Reference geod latitude (deg)
144 GDLONR - Reference geographic longitude (deg)
145 GDLAT2 - Geodetic latitude of second inst (deg)
146 GLON2 - Geographic longitude of second inst (deg)
147
148 GDALT - Geodetic altitude (height) (km)
149 SNL - Log10 (signal to noise ratio)
150 VN1P2 - Neutral wind in direction 1 (eastward) (m/s), ie zonal wind
151 VN2P2 - Neutral wind in direction 2 (northward) (m/s), ie meridional wind
152 EL2 - Ending elevation angle (deg), ie vertical wind
153
154 Other parameters: /madrigal3/metadata/parcodes.tab
155
156 '''
157
158 self.z_zon = self.dataOut.data_output[0,:,:]
159 self.z_mer =self.dataOut.data_output[1,:,:]
160 self.z_ver = self.dataOut.data_output[2,:,:]
161
162 if self.im == 0:
163 h_select = numpy.where(numpy.bitwise_and(self.dataOut.height[0, :] >= 0., self.dataOut.height[0, :] <= self.hcm, numpy.isfinite(self.dataOut.height[0, :])))
164 else:
165 h_select = numpy.where(numpy.bitwise_and(self.dataOut.height[0, :] >= 0., self.dataOut.height[0, :] < 20, numpy.isfinite(self.dataOut.height[0, :])))
166
167 ht = h_select[0]
168
169 self.o_height = self.dataOut.height[self.im, ht]
170 self.o_zon = self.z_zon[ht, self.im]
171 self.o_mer = self.z_mer[ht, self.im]
172 self.o_ver = self.z_ver[ht, self.im]
173 o_snr = self.dataOut.data_SNR[ :, :, self.im]
174
175 o_snr = o_snr[ht, :]
176
177 ndiv = numpy.nansum((numpy.isfinite(o_snr)), 1)
178 ndiv = ndiv.astype(float)
179
180 sel_div = numpy.where(ndiv == 0.)
181 ndiv[sel_div] = numpy.nan
182
183 if self.nchannels > 1:
184 msnr = numpy.nansum(o_snr, axis=1)
185 else:
186 msnr = o_snr
187
188 try:
189 self.msnr = 10 * numpy.log10(msnr / ndiv)
190 except ZeroDivisionError:
191 self.msnr = 10 * numpy.log10(msnr /1)
192 print 'Number of division (ndiv) egal to 1 by default. Check SNR'
193
194 time_t = time.gmtime(self.dataOut.time1)
195 year = time_t.tm_year
196 month = time_t.tm_mon
197 day = time_t.tm_mday
198 hour = time_t.tm_hour
199 minute = time_t.tm_min
200 second = time_t.tm_sec
201 timedate_0 = datetime.datetime(year, month, day, hour, minute, second)
202
203 # 1d parameters
204 GDLATR = self.lat
205 GDLONR = self.lon
206 GDLAT2 = self.lat
207 GLON2 = self.lon
208
209 # 2d parameters
210 GDALT = self.o_height
211
212 SNL = self.msnr
213 VN1P2 = self.o_zon
214 VN2P2 = self.o_mer
215 EL2 = self.o_ver
216 NROW = len(self.o_height)
217
218 startTime = timedate_0
219 endTime = startTime
220 self.dataRec = madrigal.cedar.MadrigalDataRecord(self.kinst,
221 self.kindat,
222 startTime.year,
223 startTime.month,
224 startTime.day,
225 startTime.hour,
226 startTime.minute,
227 startTime.second,
228 0,
229 endTime.year,
230 endTime.month,
231 endTime.day,
232 endTime.hour,
233 endTime.minute,
234 endTime.second,
235 0,
236 ('gdlatr', 'gdlonr', 'gdlat2', 'glon2'),
237 ('gdalt', 'snl', 'vn1p2', 'vn2p2', 'el2'),
238 NROW, ind2DList=['gdalt'])
239
240 # Setting 1d values
241 self.dataRec.set1D('gdlatr', GDLATR)
242 self.dataRec.set1D('gdlonr', GDLONR)
243 self.dataRec.set1D('gdlat2', GDLAT2)
244 self.dataRec.set1D('glon2', GLON2)
245
246 # Setting 2d values
247 for n in range(self.o_height.shape[0]):
248 self.dataRec.set2D('gdalt', n, GDALT[n])
249 self.dataRec.set2D('snl', n, SNL[n])
250 self.dataRec.set2D('vn1p2', n, VN1P2[n])
251 self.dataRec.set2D('vn2p2', n, VN2P2[n])
252 self.dataRec.set2D('el2', n, EL2[n])
253
254 # Appending new data record
255 '''
256 [MADRIGAL3]There are two ways to write to a MadrigalCedarFile. Either this method (write) is called after all the
257 records have been appended to the MadrigalCedarFile, or dump is called after a certain number of records are appended,
258 and then at the end dump is called a final time if there were any records not yet dumped, followed by addArray.
259 '''
260
261 self.cedarObj.append(self.dataRec)
262 print ' [Writing] records {} (mode {}).'.format(self.dataOut.counter_records,self.im+1)
263 self.cedarObj.dump()
264
265
266
267
268 def setHeader(self):
269 '''
270 - Creating self.catHeadObj
271 - Adding information catalog
272 - Writing file header
273
274 '''
275 self.catHeadObj = madrigal.cedar.CatalogHeaderCreator(self.fullname)
276 kindatDesc, comments, analyst, history, principleInvestigator = self._info_BLTR()
277
278 self.catHeadObj.createCatalog(principleInvestigator="Jarjar",
279 expPurpose='characterize the atmospheric dynamics in this region where frequently it happens the El Nino',
280 sciRemarks="http://madrigal3.haystack.mit.edu/static/CEDARMadrigalHdf5Format.pdf")
281
282 self.catHeadObj.createHeader(kindatDesc, analyst, comments, history)
283
284 self.catHeadObj.write()
285
286 print '[File created] path: %s' % (self.fullname)
287
288 def putData(self):
289
290 if self.dataOut.flagNoData:
291 return 0
292
293 if self.dataOut.counter_records == 1:
294 self.setFile()
295 print '[Writing] Setting new hdf5 file for the mode {}'.format(self.im+1)
296
297 if self.dataOut.counter_records <= self.dataOut.nrecords:
298 self.writeBlock()
299
300
301 if self.dataOut.counter_records == self.dataOut.nrecords:
302 self.cedarObj.addArray()
303
304 self.setHeader()
305 self.flagIsNewFile = 1
306
307 def _info_BLTR(self):
308
309 kindatDesc = '''--This header is for KINDAT = %d''' % self.kindat
310 history = None
311 analyst = '''Jarjar'''
312 principleInvestigator = '''
313 Jarjar
314 Radio Observatorio de Jicamarca
315 Instituto Geofisico del Peru
316
317 '''
318 if self.type == 1:
319 comments = '''
320
321 --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).
322
323 --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'
324
325 --In Kindat = 1600, contains information of wind velocities component since 0 Km to 3 Km.
326
327 --In Kindat = 1601, contains information of wind velocities component since 0 Km to 10 Km.
328
329 --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.
330
331 --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.
332
333
334 Station _______ Geographic Coord ______ Geomagnetic Coord
335
336 _______________ Latitude _ Longitude __ Latitude _ Longitude
337
338 Huancayo (HUA) __12.04 S ___ 75.32 W _____ -12.05 ____ 352.85
339 Piura (PIU) _____ 5.17 S ___ 80.64 W ______ 5.18 ____ 350.93
340
341 WIND OBSERVATIONS
342
343 --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.
344
345 ......................................................................
346 For more information, consult the following references:
347 - Balsley, B. B., and K. S. Gage., On the use of radars for operational wind profiling, Bull. Amer. Meteor.Soc.,63, 1009-1018, 1982.
348
349 - 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.
350
351 - Gage, K. S., and B.B. Balsley., Doppler radar probing of the clear atmosphere, Bull. Amer. Meteor.Soc., 59, 1074-1093, 1978.
352
353 - Larsen, M. F., The Spaced Antenna Technique for Radar Wind Profiling, Journal of Atm. and Ocean. Technology. , Vol.6, 920-937, 1989.
354
355 - Larsen, M. F., A method for single radar voracity measurements?, Handbook for MAP,SCOSTEP Secretariat, University of the Illinois, Urban, in press, 1989.
356 ......................................................................
357
358 ACKNOWLEDGEMENTS:
359
360 --The Piura and Huancayo BLTR are part of the network of instruments operated by the Jicamarca Radio Observatory.
361
362 --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
363
364 ......................................................................
365
366 Further questions and comments should be addressed to:
367 Radio Observatorio de Jicamarca
368 Instituto Geofisico del Peru
369 Lima, Peru
370 Web URL: http://jro.igp.gob.pe
371 ......................................................................
372 '''
373
374 return kindatDesc, comments, analyst, history, principleInvestigator
375
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 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 bltrIO_param import *
16 from jroIO_bltr import *
17 from jroIO_bltr import *
17 from jroIO_mira35c import *
18 from jroIO_mira35c 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 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,1795 +1,1794
1 '''
1 '''
2 Created on Jul 2, 2014
2 Created on Jul 2, 2014
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6 import os
6 import os
7 import sys
7 import sys
8 import glob
8 import glob
9 import time
9 import time
10 import numpy
10 import numpy
11 import fnmatch
11 import fnmatch
12 import inspect
12 import inspect
13 import time, datetime
13 import time, datetime
14 #import h5py
15 import traceback
14 import traceback
16
15
17 try:
16 try:
18 from gevent import sleep
17 from gevent import sleep
19 except:
18 except:
20 from time import sleep
19 from time import sleep
21
20
22 from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader
21 from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader
23 from schainpy.model.data.jroheaderIO import get_dtype_index, get_numpy_dtype, get_procflag_dtype, get_dtype_width
22 from schainpy.model.data.jroheaderIO import get_dtype_index, get_numpy_dtype, get_procflag_dtype, get_dtype_width
24
23
25 LOCALTIME = True
24 LOCALTIME = True
26
25
27 def isNumber(cad):
26 def isNumber(cad):
28 """
27 """
29 Chequea si el conjunto de caracteres que componen un string puede ser convertidos a un numero.
28 Chequea si el conjunto de caracteres que componen un string puede ser convertidos a un numero.
30
29
31 Excepciones:
30 Excepciones:
32 Si un determinado string no puede ser convertido a numero
31 Si un determinado string no puede ser convertido a numero
33 Input:
32 Input:
34 str, string al cual se le analiza para determinar si convertible a un numero o no
33 str, string al cual se le analiza para determinar si convertible a un numero o no
35
34
36 Return:
35 Return:
37 True : si el string es uno numerico
36 True : si el string es uno numerico
38 False : no es un string numerico
37 False : no es un string numerico
39 """
38 """
40 try:
39 try:
41 float( cad )
40 float( cad )
42 return True
41 return True
43 except:
42 except:
44 return False
43 return False
45
44
46 def isFileInEpoch(filename, startUTSeconds, endUTSeconds):
45 def isFileInEpoch(filename, startUTSeconds, endUTSeconds):
47 """
46 """
48 Esta funcion determina si un archivo de datos se encuentra o no dentro del rango de fecha especificado.
47 Esta funcion determina si un archivo de datos se encuentra o no dentro del rango de fecha especificado.
49
48
50 Inputs:
49 Inputs:
51 filename : nombre completo del archivo de datos en formato Jicamarca (.r)
50 filename : nombre completo del archivo de datos en formato Jicamarca (.r)
52
51
53 startUTSeconds : fecha inicial del rango seleccionado. La fecha esta dada en
52 startUTSeconds : fecha inicial del rango seleccionado. La fecha esta dada en
54 segundos contados desde 01/01/1970.
53 segundos contados desde 01/01/1970.
55 endUTSeconds : fecha final del rango seleccionado. La fecha esta dada en
54 endUTSeconds : fecha final del rango seleccionado. La fecha esta dada en
56 segundos contados desde 01/01/1970.
55 segundos contados desde 01/01/1970.
57
56
58 Return:
57 Return:
59 Boolean : Retorna True si el archivo de datos contiene datos en el rango de
58 Boolean : Retorna True si el archivo de datos contiene datos en el rango de
60 fecha especificado, de lo contrario retorna False.
59 fecha especificado, de lo contrario retorna False.
61
60
62 Excepciones:
61 Excepciones:
63 Si el archivo no existe o no puede ser abierto
62 Si el archivo no existe o no puede ser abierto
64 Si la cabecera no puede ser leida.
63 Si la cabecera no puede ser leida.
65
64
66 """
65 """
67 basicHeaderObj = BasicHeader(LOCALTIME)
66 basicHeaderObj = BasicHeader(LOCALTIME)
68
67
69 try:
68 try:
70 fp = open(filename,'rb')
69 fp = open(filename,'rb')
71 except IOError:
70 except IOError:
72 print "The file %s can't be opened" %(filename)
71 print "The file %s can't be opened" %(filename)
73 return 0
72 return 0
74
73
75 sts = basicHeaderObj.read(fp)
74 sts = basicHeaderObj.read(fp)
76 fp.close()
75 fp.close()
77
76
78 if not(sts):
77 if not(sts):
79 print "Skipping the file %s because it has not a valid header" %(filename)
78 print "Skipping the file %s because it has not a valid header" %(filename)
80 return 0
79 return 0
81
80
82 if not ((startUTSeconds <= basicHeaderObj.utc) and (endUTSeconds > basicHeaderObj.utc)):
81 if not ((startUTSeconds <= basicHeaderObj.utc) and (endUTSeconds > basicHeaderObj.utc)):
83 return 0
82 return 0
84
83
85 return 1
84 return 1
86
85
87 def isTimeInRange(thisTime, startTime, endTime):
86 def isTimeInRange(thisTime, startTime, endTime):
88
87
89 if endTime >= startTime:
88 if endTime >= startTime:
90 if (thisTime < startTime) or (thisTime > endTime):
89 if (thisTime < startTime) or (thisTime > endTime):
91 return 0
90 return 0
92
91
93 return 1
92 return 1
94 else:
93 else:
95 if (thisTime < startTime) and (thisTime > endTime):
94 if (thisTime < startTime) and (thisTime > endTime):
96 return 0
95 return 0
97
96
98 return 1
97 return 1
99
98
100 def isFileInTimeRange(filename, startDate, endDate, startTime, endTime):
99 def isFileInTimeRange(filename, startDate, endDate, startTime, endTime):
101 """
100 """
102 Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
101 Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
103
102
104 Inputs:
103 Inputs:
105 filename : nombre completo del archivo de datos en formato Jicamarca (.r)
104 filename : nombre completo del archivo de datos en formato Jicamarca (.r)
106
105
107 startDate : fecha inicial del rango seleccionado en formato datetime.date
106 startDate : fecha inicial del rango seleccionado en formato datetime.date
108
107
109 endDate : fecha final del rango seleccionado en formato datetime.date
108 endDate : fecha final del rango seleccionado en formato datetime.date
110
109
111 startTime : tiempo inicial del rango seleccionado en formato datetime.time
110 startTime : tiempo inicial del rango seleccionado en formato datetime.time
112
111
113 endTime : tiempo final del rango seleccionado en formato datetime.time
112 endTime : tiempo final del rango seleccionado en formato datetime.time
114
113
115 Return:
114 Return:
116 Boolean : Retorna True si el archivo de datos contiene datos en el rango de
115 Boolean : Retorna True si el archivo de datos contiene datos en el rango de
117 fecha especificado, de lo contrario retorna False.
116 fecha especificado, de lo contrario retorna False.
118
117
119 Excepciones:
118 Excepciones:
120 Si el archivo no existe o no puede ser abierto
119 Si el archivo no existe o no puede ser abierto
121 Si la cabecera no puede ser leida.
120 Si la cabecera no puede ser leida.
122
121
123 """
122 """
124
123
125
124
126 try:
125 try:
127 fp = open(filename,'rb')
126 fp = open(filename,'rb')
128 except IOError:
127 except IOError:
129 print "The file %s can't be opened" %(filename)
128 print "The file %s can't be opened" %(filename)
130 return None
129 return None
131
130
132 firstBasicHeaderObj = BasicHeader(LOCALTIME)
131 firstBasicHeaderObj = BasicHeader(LOCALTIME)
133 systemHeaderObj = SystemHeader()
132 systemHeaderObj = SystemHeader()
134 radarControllerHeaderObj = RadarControllerHeader()
133 radarControllerHeaderObj = RadarControllerHeader()
135 processingHeaderObj = ProcessingHeader()
134 processingHeaderObj = ProcessingHeader()
136
135
137 lastBasicHeaderObj = BasicHeader(LOCALTIME)
136 lastBasicHeaderObj = BasicHeader(LOCALTIME)
138
137
139 sts = firstBasicHeaderObj.read(fp)
138 sts = firstBasicHeaderObj.read(fp)
140
139
141 if not(sts):
140 if not(sts):
142 print "[Reading] Skipping the file %s because it has not a valid header" %(filename)
141 print "[Reading] Skipping the file %s because it has not a valid header" %(filename)
143 return None
142 return None
144
143
145 if not systemHeaderObj.read(fp):
144 if not systemHeaderObj.read(fp):
146 return None
145 return None
147
146
148 if not radarControllerHeaderObj.read(fp):
147 if not radarControllerHeaderObj.read(fp):
149 return None
148 return None
150
149
151 if not processingHeaderObj.read(fp):
150 if not processingHeaderObj.read(fp):
152 return None
151 return None
153
152
154 filesize = os.path.getsize(filename)
153 filesize = os.path.getsize(filename)
155
154
156 offset = processingHeaderObj.blockSize + 24 #header size
155 offset = processingHeaderObj.blockSize + 24 #header size
157
156
158 if filesize <= offset:
157 if filesize <= offset:
159 print "[Reading] %s: This file has not enough data" %filename
158 print "[Reading] %s: This file has not enough data" %filename
160 return None
159 return None
161
160
162 fp.seek(-offset, 2)
161 fp.seek(-offset, 2)
163
162
164 sts = lastBasicHeaderObj.read(fp)
163 sts = lastBasicHeaderObj.read(fp)
165
164
166 fp.close()
165 fp.close()
167
166
168 thisDatetime = lastBasicHeaderObj.datatime
167 thisDatetime = lastBasicHeaderObj.datatime
169 thisTime_last_block = thisDatetime.time()
168 thisTime_last_block = thisDatetime.time()
170
169
171 thisDatetime = firstBasicHeaderObj.datatime
170 thisDatetime = firstBasicHeaderObj.datatime
172 thisDate = thisDatetime.date()
171 thisDate = thisDatetime.date()
173 thisTime_first_block = thisDatetime.time()
172 thisTime_first_block = thisDatetime.time()
174
173
175 #General case
174 #General case
176 # o>>>>>>>>>>>>>><<<<<<<<<<<<<<o
175 # o>>>>>>>>>>>>>><<<<<<<<<<<<<<o
177 #-----------o----------------------------o-----------
176 #-----------o----------------------------o-----------
178 # startTime endTime
177 # startTime endTime
179
178
180 if endTime >= startTime:
179 if endTime >= startTime:
181 if (thisTime_last_block < startTime) or (thisTime_first_block > endTime):
180 if (thisTime_last_block < startTime) or (thisTime_first_block > endTime):
182 return None
181 return None
183
182
184 return thisDatetime
183 return thisDatetime
185
184
186 #If endTime < startTime then endTime belongs to the next day
185 #If endTime < startTime then endTime belongs to the next day
187
186
188
187
189 #<<<<<<<<<<<o o>>>>>>>>>>>
188 #<<<<<<<<<<<o o>>>>>>>>>>>
190 #-----------o----------------------------o-----------
189 #-----------o----------------------------o-----------
191 # endTime startTime
190 # endTime startTime
192
191
193 if (thisDate == startDate) and (thisTime_last_block < startTime):
192 if (thisDate == startDate) and (thisTime_last_block < startTime):
194 return None
193 return None
195
194
196 if (thisDate == endDate) and (thisTime_first_block > endTime):
195 if (thisDate == endDate) and (thisTime_first_block > endTime):
197 return None
196 return None
198
197
199 if (thisTime_last_block < startTime) and (thisTime_first_block > endTime):
198 if (thisTime_last_block < startTime) and (thisTime_first_block > endTime):
200 return None
199 return None
201
200
202 return thisDatetime
201 return thisDatetime
203
202
204 def isFolderInDateRange(folder, startDate=None, endDate=None):
203 def isFolderInDateRange(folder, startDate=None, endDate=None):
205 """
204 """
206 Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
205 Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
207
206
208 Inputs:
207 Inputs:
209 folder : nombre completo del directorio.
208 folder : nombre completo del directorio.
210 Su formato deberia ser "/path_root/?YYYYDDD"
209 Su formato deberia ser "/path_root/?YYYYDDD"
211
210
212 siendo:
211 siendo:
213 YYYY : Anio (ejemplo 2015)
212 YYYY : Anio (ejemplo 2015)
214 DDD : Dia del anio (ejemplo 305)
213 DDD : Dia del anio (ejemplo 305)
215
214
216 startDate : fecha inicial del rango seleccionado en formato datetime.date
215 startDate : fecha inicial del rango seleccionado en formato datetime.date
217
216
218 endDate : fecha final del rango seleccionado en formato datetime.date
217 endDate : fecha final del rango seleccionado en formato datetime.date
219
218
220 Return:
219 Return:
221 Boolean : Retorna True si el archivo de datos contiene datos en el rango de
220 Boolean : Retorna True si el archivo de datos contiene datos en el rango de
222 fecha especificado, de lo contrario retorna False.
221 fecha especificado, de lo contrario retorna False.
223 Excepciones:
222 Excepciones:
224 Si el directorio no tiene el formato adecuado
223 Si el directorio no tiene el formato adecuado
225 """
224 """
226
225
227 basename = os.path.basename(folder)
226 basename = os.path.basename(folder)
228
227
229 if not isRadarFolder(basename):
228 if not isRadarFolder(basename):
230 print "The folder %s has not the rigth format" %folder
229 print "The folder %s has not the rigth format" %folder
231 return 0
230 return 0
232
231
233 if startDate and endDate:
232 if startDate and endDate:
234 thisDate = getDateFromRadarFolder(basename)
233 thisDate = getDateFromRadarFolder(basename)
235
234
236 if thisDate < startDate:
235 if thisDate < startDate:
237 return 0
236 return 0
238
237
239 if thisDate > endDate:
238 if thisDate > endDate:
240 return 0
239 return 0
241
240
242 return 1
241 return 1
243
242
244 def isFileInDateRange(filename, startDate=None, endDate=None):
243 def isFileInDateRange(filename, startDate=None, endDate=None):
245 """
244 """
246 Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
245 Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
247
246
248 Inputs:
247 Inputs:
249 filename : nombre completo del archivo de datos en formato Jicamarca (.r)
248 filename : nombre completo del archivo de datos en formato Jicamarca (.r)
250
249
251 Su formato deberia ser "?YYYYDDDsss"
250 Su formato deberia ser "?YYYYDDDsss"
252
251
253 siendo:
252 siendo:
254 YYYY : Anio (ejemplo 2015)
253 YYYY : Anio (ejemplo 2015)
255 DDD : Dia del anio (ejemplo 305)
254 DDD : Dia del anio (ejemplo 305)
256 sss : set
255 sss : set
257
256
258 startDate : fecha inicial del rango seleccionado en formato datetime.date
257 startDate : fecha inicial del rango seleccionado en formato datetime.date
259
258
260 endDate : fecha final del rango seleccionado en formato datetime.date
259 endDate : fecha final del rango seleccionado en formato datetime.date
261
260
262 Return:
261 Return:
263 Boolean : Retorna True si el archivo de datos contiene datos en el rango de
262 Boolean : Retorna True si el archivo de datos contiene datos en el rango de
264 fecha especificado, de lo contrario retorna False.
263 fecha especificado, de lo contrario retorna False.
265 Excepciones:
264 Excepciones:
266 Si el archivo no tiene el formato adecuado
265 Si el archivo no tiene el formato adecuado
267 """
266 """
268
267
269 basename = os.path.basename(filename)
268 basename = os.path.basename(filename)
270
269
271 if not isRadarFile(basename):
270 if not isRadarFile(basename):
272 print "The filename %s has not the rigth format" %filename
271 print "The filename %s has not the rigth format" %filename
273 return 0
272 return 0
274
273
275 if startDate and endDate:
274 if startDate and endDate:
276 thisDate = getDateFromRadarFile(basename)
275 thisDate = getDateFromRadarFile(basename)
277
276
278 if thisDate < startDate:
277 if thisDate < startDate:
279 return 0
278 return 0
280
279
281 if thisDate > endDate:
280 if thisDate > endDate:
282 return 0
281 return 0
283
282
284 return 1
283 return 1
285
284
286 def getFileFromSet(path, ext, set):
285 def getFileFromSet(path, ext, set):
287 validFilelist = []
286 validFilelist = []
288 fileList = os.listdir(path)
287 fileList = os.listdir(path)
289
288
290 # 0 1234 567 89A BCDE
289 # 0 1234 567 89A BCDE
291 # H YYYY DDD SSS .ext
290 # H YYYY DDD SSS .ext
292
291
293 for thisFile in fileList:
292 for thisFile in fileList:
294 try:
293 try:
295 year = int(thisFile[1:5])
294 year = int(thisFile[1:5])
296 doy = int(thisFile[5:8])
295 doy = int(thisFile[5:8])
297 except:
296 except:
298 continue
297 continue
299
298
300 if (os.path.splitext(thisFile)[-1].lower() != ext.lower()):
299 if (os.path.splitext(thisFile)[-1].lower() != ext.lower()):
301 continue
300 continue
302
301
303 validFilelist.append(thisFile)
302 validFilelist.append(thisFile)
304
303
305 myfile = fnmatch.filter(validFilelist,'*%4.4d%3.3d%3.3d*'%(year,doy,set))
304 myfile = fnmatch.filter(validFilelist,'*%4.4d%3.3d%3.3d*'%(year,doy,set))
306
305
307 if len(myfile)!= 0:
306 if len(myfile)!= 0:
308 return myfile[0]
307 return myfile[0]
309 else:
308 else:
310 filename = '*%4.4d%3.3d%3.3d%s'%(year,doy,set,ext.lower())
309 filename = '*%4.4d%3.3d%3.3d%s'%(year,doy,set,ext.lower())
311 print 'the filename %s does not exist'%filename
310 print 'the filename %s does not exist'%filename
312 print '...going to the last file: '
311 print '...going to the last file: '
313
312
314 if validFilelist:
313 if validFilelist:
315 validFilelist = sorted( validFilelist, key=str.lower )
314 validFilelist = sorted( validFilelist, key=str.lower )
316 return validFilelist[-1]
315 return validFilelist[-1]
317
316
318 return None
317 return None
319
318
320 def getlastFileFromPath(path, ext):
319 def getlastFileFromPath(path, ext):
321 """
320 """
322 Depura el fileList dejando solo los que cumplan el formato de "PYYYYDDDSSS.ext"
321 Depura el fileList dejando solo los que cumplan el formato de "PYYYYDDDSSS.ext"
323 al final de la depuracion devuelve el ultimo file de la lista que quedo.
322 al final de la depuracion devuelve el ultimo file de la lista que quedo.
324
323
325 Input:
324 Input:
326 fileList : lista conteniendo todos los files (sin path) que componen una determinada carpeta
325 fileList : lista conteniendo todos los files (sin path) que componen una determinada carpeta
327 ext : extension de los files contenidos en una carpeta
326 ext : extension de los files contenidos en una carpeta
328
327
329 Return:
328 Return:
330 El ultimo file de una determinada carpeta, no se considera el path.
329 El ultimo file de una determinada carpeta, no se considera el path.
331 """
330 """
332 validFilelist = []
331 validFilelist = []
333 fileList = os.listdir(path)
332 fileList = os.listdir(path)
334
333
335 # 0 1234 567 89A BCDE
334 # 0 1234 567 89A BCDE
336 # H YYYY DDD SSS .ext
335 # H YYYY DDD SSS .ext
337
336
338 for thisFile in fileList:
337 for thisFile in fileList:
339
338
340 year = thisFile[1:5]
339 year = thisFile[1:5]
341 if not isNumber(year):
340 if not isNumber(year):
342 continue
341 continue
343
342
344 doy = thisFile[5:8]
343 doy = thisFile[5:8]
345 if not isNumber(doy):
344 if not isNumber(doy):
346 continue
345 continue
347
346
348 year = int(year)
347 year = int(year)
349 doy = int(doy)
348 doy = int(doy)
350
349
351 if (os.path.splitext(thisFile)[-1].lower() != ext.lower()):
350 if (os.path.splitext(thisFile)[-1].lower() != ext.lower()):
352 continue
351 continue
353
352
354 validFilelist.append(thisFile)
353 validFilelist.append(thisFile)
355
354
356 if validFilelist:
355 if validFilelist:
357 validFilelist = sorted( validFilelist, key=str.lower )
356 validFilelist = sorted( validFilelist, key=str.lower )
358 return validFilelist[-1]
357 return validFilelist[-1]
359
358
360 return None
359 return None
361
360
362 def checkForRealPath(path, foldercounter, year, doy, set, ext):
361 def checkForRealPath(path, foldercounter, year, doy, set, ext):
363 """
362 """
364 Por ser Linux Case Sensitive entonces checkForRealPath encuentra el nombre correcto de un path,
363 Por ser Linux Case Sensitive entonces checkForRealPath encuentra el nombre correcto de un path,
365 Prueba por varias combinaciones de nombres entre mayusculas y minusculas para determinar
364 Prueba por varias combinaciones de nombres entre mayusculas y minusculas para determinar
366 el path exacto de un determinado file.
365 el path exacto de un determinado file.
367
366
368 Example :
367 Example :
369 nombre correcto del file es .../.../D2009307/P2009307367.ext
368 nombre correcto del file es .../.../D2009307/P2009307367.ext
370
369
371 Entonces la funcion prueba con las siguientes combinaciones
370 Entonces la funcion prueba con las siguientes combinaciones
372 .../.../y2009307367.ext
371 .../.../y2009307367.ext
373 .../.../Y2009307367.ext
372 .../.../Y2009307367.ext
374 .../.../x2009307/y2009307367.ext
373 .../.../x2009307/y2009307367.ext
375 .../.../x2009307/Y2009307367.ext
374 .../.../x2009307/Y2009307367.ext
376 .../.../X2009307/y2009307367.ext
375 .../.../X2009307/y2009307367.ext
377 .../.../X2009307/Y2009307367.ext
376 .../.../X2009307/Y2009307367.ext
378 siendo para este caso, la ultima combinacion de letras, identica al file buscado
377 siendo para este caso, la ultima combinacion de letras, identica al file buscado
379
378
380 Return:
379 Return:
381 Si encuentra la cobinacion adecuada devuelve el path completo y el nombre del file
380 Si encuentra la cobinacion adecuada devuelve el path completo y el nombre del file
382 caso contrario devuelve None como path y el la ultima combinacion de nombre en mayusculas
381 caso contrario devuelve None como path y el la ultima combinacion de nombre en mayusculas
383 para el filename
382 para el filename
384 """
383 """
385 fullfilename = None
384 fullfilename = None
386 find_flag = False
385 find_flag = False
387 filename = None
386 filename = None
388
387
389 prefixDirList = [None,'d','D']
388 prefixDirList = [None,'d','D']
390 if ext.lower() == ".r": #voltage
389 if ext.lower() == ".r": #voltage
391 prefixFileList = ['d','D']
390 prefixFileList = ['d','D']
392 elif ext.lower() == ".pdata": #spectra
391 elif ext.lower() == ".pdata": #spectra
393 prefixFileList = ['p','P']
392 prefixFileList = ['p','P']
394 else:
393 else:
395 return None, filename
394 return None, filename
396
395
397 #barrido por las combinaciones posibles
396 #barrido por las combinaciones posibles
398 for prefixDir in prefixDirList:
397 for prefixDir in prefixDirList:
399 thispath = path
398 thispath = path
400 if prefixDir != None:
399 if prefixDir != None:
401 #formo el nombre del directorio xYYYYDDD (x=d o x=D)
400 #formo el nombre del directorio xYYYYDDD (x=d o x=D)
402 if foldercounter == 0:
401 if foldercounter == 0:
403 thispath = os.path.join(path, "%s%04d%03d" % ( prefixDir, year, doy ))
402 thispath = os.path.join(path, "%s%04d%03d" % ( prefixDir, year, doy ))
404 else:
403 else:
405 thispath = os.path.join(path, "%s%04d%03d_%02d" % ( prefixDir, year, doy , foldercounter))
404 thispath = os.path.join(path, "%s%04d%03d_%02d" % ( prefixDir, year, doy , foldercounter))
406 for prefixFile in prefixFileList: #barrido por las dos combinaciones posibles de "D"
405 for prefixFile in prefixFileList: #barrido por las dos combinaciones posibles de "D"
407 filename = "%s%04d%03d%03d%s" % ( prefixFile, year, doy, set, ext ) #formo el nombre del file xYYYYDDDSSS.ext
406 filename = "%s%04d%03d%03d%s" % ( prefixFile, year, doy, set, ext ) #formo el nombre del file xYYYYDDDSSS.ext
408 fullfilename = os.path.join( thispath, filename ) #formo el path completo
407 fullfilename = os.path.join( thispath, filename ) #formo el path completo
409
408
410 if os.path.exists( fullfilename ): #verifico que exista
409 if os.path.exists( fullfilename ): #verifico que exista
411 find_flag = True
410 find_flag = True
412 break
411 break
413 if find_flag:
412 if find_flag:
414 break
413 break
415
414
416 if not(find_flag):
415 if not(find_flag):
417 return None, filename
416 return None, filename
418
417
419 return fullfilename, filename
418 return fullfilename, filename
420
419
421 def isRadarFolder(folder):
420 def isRadarFolder(folder):
422 try:
421 try:
423 year = int(folder[1:5])
422 year = int(folder[1:5])
424 doy = int(folder[5:8])
423 doy = int(folder[5:8])
425 except:
424 except:
426 return 0
425 return 0
427
426
428 return 1
427 return 1
429
428
430 def isRadarFile(file):
429 def isRadarFile(file):
431 try:
430 try:
432 year = int(file[1:5])
431 year = int(file[1:5])
433 doy = int(file[5:8])
432 doy = int(file[5:8])
434 set = int(file[8:11])
433 set = int(file[8:11])
435 except:
434 except:
436 return 0
435 return 0
437
436
438 return 1
437 return 1
439
438
440 def getDateFromRadarFile(file):
439 def getDateFromRadarFile(file):
441 try:
440 try:
442 year = int(file[1:5])
441 year = int(file[1:5])
443 doy = int(file[5:8])
442 doy = int(file[5:8])
444 set = int(file[8:11])
443 set = int(file[8:11])
445 except:
444 except:
446 return None
445 return None
447
446
448 thisDate = datetime.date(year, 1, 1) + datetime.timedelta(doy-1)
447 thisDate = datetime.date(year, 1, 1) + datetime.timedelta(doy-1)
449 return thisDate
448 return thisDate
450
449
451 def getDateFromRadarFolder(folder):
450 def getDateFromRadarFolder(folder):
452 try:
451 try:
453 year = int(folder[1:5])
452 year = int(folder[1:5])
454 doy = int(folder[5:8])
453 doy = int(folder[5:8])
455 except:
454 except:
456 return None
455 return None
457
456
458 thisDate = datetime.date(year, 1, 1) + datetime.timedelta(doy-1)
457 thisDate = datetime.date(year, 1, 1) + datetime.timedelta(doy-1)
459 return thisDate
458 return thisDate
460
459
461 class JRODataIO:
460 class JRODataIO:
462
461
463 c = 3E8
462 c = 3E8
464
463
465 isConfig = False
464 isConfig = False
466
465
467 basicHeaderObj = None
466 basicHeaderObj = None
468
467
469 systemHeaderObj = None
468 systemHeaderObj = None
470
469
471 radarControllerHeaderObj = None
470 radarControllerHeaderObj = None
472
471
473 processingHeaderObj = None
472 processingHeaderObj = None
474
473
475 dtype = None
474 dtype = None
476
475
477 pathList = []
476 pathList = []
478
477
479 filenameList = []
478 filenameList = []
480
479
481 filename = None
480 filename = None
482
481
483 ext = None
482 ext = None
484
483
485 flagIsNewFile = 1
484 flagIsNewFile = 1
486
485
487 flagDiscontinuousBlock = 0
486 flagDiscontinuousBlock = 0
488
487
489 flagIsNewBlock = 0
488 flagIsNewBlock = 0
490
489
491 fp = None
490 fp = None
492
491
493 firstHeaderSize = 0
492 firstHeaderSize = 0
494
493
495 basicHeaderSize = 24
494 basicHeaderSize = 24
496
495
497 versionFile = 1103
496 versionFile = 1103
498
497
499 fileSize = None
498 fileSize = None
500
499
501 # ippSeconds = None
500 # ippSeconds = None
502
501
503 fileSizeByHeader = None
502 fileSizeByHeader = None
504
503
505 fileIndex = None
504 fileIndex = None
506
505
507 profileIndex = None
506 profileIndex = None
508
507
509 blockIndex = None
508 blockIndex = None
510
509
511 nTotalBlocks = None
510 nTotalBlocks = None
512
511
513 maxTimeStep = 30
512 maxTimeStep = 30
514
513
515 lastUTTime = None
514 lastUTTime = None
516
515
517 datablock = None
516 datablock = None
518
517
519 dataOut = None
518 dataOut = None
520
519
521 blocksize = None
520 blocksize = None
522
521
523 getByBlock = False
522 getByBlock = False
524
523
525 def __init__(self):
524 def __init__(self):
526
525
527 raise NotImplementedError
526 raise NotImplementedError
528
527
529 def run(self):
528 def run(self):
530
529
531 raise NotImplementedError
530 raise NotImplementedError
532
531
533 def getDtypeWidth(self):
532 def getDtypeWidth(self):
534
533
535 dtype_index = get_dtype_index(self.dtype)
534 dtype_index = get_dtype_index(self.dtype)
536 dtype_width = get_dtype_width(dtype_index)
535 dtype_width = get_dtype_width(dtype_index)
537
536
538 return dtype_width
537 return dtype_width
539
538
540 def getAllowedArgs(self):
539 def getAllowedArgs(self):
541 return inspect.getargspec(self.run).args
540 return inspect.getargspec(self.run).args
542
541
543 class JRODataReader(JRODataIO):
542 class JRODataReader(JRODataIO):
544
543
545
544
546 online = 0
545 online = 0
547
546
548 realtime = 0
547 realtime = 0
549
548
550 nReadBlocks = 0
549 nReadBlocks = 0
551
550
552 delay = 10 #number of seconds waiting a new file
551 delay = 10 #number of seconds waiting a new file
553
552
554 nTries = 3 #quantity tries
553 nTries = 3 #quantity tries
555
554
556 nFiles = 3 #number of files for searching
555 nFiles = 3 #number of files for searching
557
556
558 path = None
557 path = None
559
558
560 foldercounter = 0
559 foldercounter = 0
561
560
562 flagNoMoreFiles = 0
561 flagNoMoreFiles = 0
563
562
564 datetimeList = []
563 datetimeList = []
565
564
566 __isFirstTimeOnline = 1
565 __isFirstTimeOnline = 1
567
566
568 __printInfo = True
567 __printInfo = True
569
568
570 profileIndex = None
569 profileIndex = None
571
570
572 nTxs = 1
571 nTxs = 1
573
572
574 txIndex = None
573 txIndex = None
575
574
576 #Added--------------------
575 #Added--------------------
577
576
578 selBlocksize = None
577 selBlocksize = None
579
578
580 selBlocktime = None
579 selBlocktime = None
581
580
582
581
583 def __init__(self):
582 def __init__(self):
584
583
585 """
584 """
586 This class is used to find data files
585 This class is used to find data files
587
586
588 Example:
587 Example:
589 reader = JRODataReader()
588 reader = JRODataReader()
590 fileList = reader.findDataFiles()
589 fileList = reader.findDataFiles()
591
590
592 """
591 """
593 pass
592 pass
594
593
595
594
596 def createObjByDefault(self):
595 def createObjByDefault(self):
597 """
596 """
598
597
599 """
598 """
600 raise NotImplementedError
599 raise NotImplementedError
601
600
602 def getBlockDimension(self):
601 def getBlockDimension(self):
603
602
604 raise NotImplementedError
603 raise NotImplementedError
605
604
606 def __searchFilesOffLine(self,
605 def __searchFilesOffLine(self,
607 path,
606 path,
608 startDate=None,
607 startDate=None,
609 endDate=None,
608 endDate=None,
610 startTime=datetime.time(0,0,0),
609 startTime=datetime.time(0,0,0),
611 endTime=datetime.time(23,59,59),
610 endTime=datetime.time(23,59,59),
612 set=None,
611 set=None,
613 expLabel='',
612 expLabel='',
614 ext='.r',
613 ext='.r',
615 queue=None,
614 queue=None,
616 cursor=None,
615 cursor=None,
617 skip=None,
616 skip=None,
618 walk=True):
617 walk=True):
619
618
620 self.filenameList = []
619 self.filenameList = []
621 self.datetimeList = []
620 self.datetimeList = []
622
621
623 pathList = []
622 pathList = []
624
623
625 dateList, pathList = self.findDatafiles(path, startDate, endDate, expLabel, ext, walk, include_path=True)
624 dateList, pathList = self.findDatafiles(path, startDate, endDate, expLabel, ext, walk, include_path=True)
626
625
627 if dateList == []:
626 if dateList == []:
628 # print "[Reading] Date range selected invalid [%s - %s]: No *%s files in %s)" %(startDate, endDate, ext, path)
627 # print "[Reading] Date range selected invalid [%s - %s]: No *%s files in %s)" %(startDate, endDate, ext, path)
629 return None, None
628 return None, None
630
629
631 if len(dateList) > 1:
630 if len(dateList) > 1:
632 print "[Reading] Data found for date range [%s - %s]: total days = %d" %(startDate, endDate, len(dateList))
631 print "[Reading] Data found for date range [%s - %s]: total days = %d" %(startDate, endDate, len(dateList))
633 else:
632 else:
634 print "[Reading] Data found for date range [%s - %s]: date = %s" %(startDate, endDate, dateList[0])
633 print "[Reading] Data found for date range [%s - %s]: date = %s" %(startDate, endDate, dateList[0])
635
634
636 filenameList = []
635 filenameList = []
637 datetimeList = []
636 datetimeList = []
638
637
639 for thisPath in pathList:
638 for thisPath in pathList:
640 # thisPath = pathList[pathDict[file]]
639 # thisPath = pathList[pathDict[file]]
641
640
642 fileList = glob.glob1(thisPath, "*%s" %ext)
641 fileList = glob.glob1(thisPath, "*%s" %ext)
643 fileList.sort()
642 fileList.sort()
644
643
645 skippedFileList = []
644 skippedFileList = []
646
645
647 if cursor is not None and skip is not None:
646 if cursor is not None and skip is not None:
648 # if cursor*skip > len(fileList):
647 # if cursor*skip > len(fileList):
649 if skip == 0:
648 if skip == 0:
650 if queue is not None:
649 if queue is not None:
651 queue.put(len(fileList))
650 queue.put(len(fileList))
652 skippedFileList = []
651 skippedFileList = []
653 else:
652 else:
654 skippedFileList = fileList[cursor*skip: cursor*skip + skip]
653 skippedFileList = fileList[cursor*skip: cursor*skip + skip]
655
654
656 else:
655 else:
657 skippedFileList = fileList
656 skippedFileList = fileList
658
657
659 for file in skippedFileList:
658 for file in skippedFileList:
660
659
661 filename = os.path.join(thisPath,file)
660 filename = os.path.join(thisPath,file)
662
661
663 if not isFileInDateRange(filename, startDate, endDate):
662 if not isFileInDateRange(filename, startDate, endDate):
664 continue
663 continue
665
664
666 thisDatetime = isFileInTimeRange(filename, startDate, endDate, startTime, endTime)
665 thisDatetime = isFileInTimeRange(filename, startDate, endDate, startTime, endTime)
667
666
668 if not(thisDatetime):
667 if not(thisDatetime):
669 continue
668 continue
670
669
671 filenameList.append(filename)
670 filenameList.append(filename)
672 datetimeList.append(thisDatetime)
671 datetimeList.append(thisDatetime)
673
672
674 if not(filenameList):
673 if not(filenameList):
675 print "[Reading] Time range selected invalid [%s - %s]: No *%s files in %s)" %(startTime, endTime, ext, path)
674 print "[Reading] Time range selected invalid [%s - %s]: No *%s files in %s)" %(startTime, endTime, ext, path)
676 return None, None
675 return None, None
677
676
678 print "[Reading] %d file(s) was(were) found in time range: %s - %s" %(len(filenameList), startTime, endTime)
677 print "[Reading] %d file(s) was(were) found in time range: %s - %s" %(len(filenameList), startTime, endTime)
679 print
678 print
680
679
681 for i in range(len(filenameList)):
680 for i in range(len(filenameList)):
682 print "[Reading] %s -> [%s]" %(filenameList[i], datetimeList[i].ctime())
681 print "[Reading] %s -> [%s]" %(filenameList[i], datetimeList[i].ctime())
683
682
684 self.filenameList = filenameList
683 self.filenameList = filenameList
685 self.datetimeList = datetimeList
684 self.datetimeList = datetimeList
686
685
687 return pathList, filenameList
686 return pathList, filenameList
688
687
689 def __searchFilesOnLine(self, path, expLabel = "", ext = None, walk=True, set=None):
688 def __searchFilesOnLine(self, path, expLabel = "", ext = None, walk=True, set=None):
690
689
691 """
690 """
692 Busca el ultimo archivo de la ultima carpeta (determinada o no por startDateTime) y
691 Busca el ultimo archivo de la ultima carpeta (determinada o no por startDateTime) y
693 devuelve el archivo encontrado ademas de otros datos.
692 devuelve el archivo encontrado ademas de otros datos.
694
693
695 Input:
694 Input:
696 path : carpeta donde estan contenidos los files que contiene data
695 path : carpeta donde estan contenidos los files que contiene data
697
696
698 expLabel : Nombre del subexperimento (subfolder)
697 expLabel : Nombre del subexperimento (subfolder)
699
698
700 ext : extension de los files
699 ext : extension de los files
701
700
702 walk : Si es habilitado no realiza busquedas dentro de los ubdirectorios (doypath)
701 walk : Si es habilitado no realiza busquedas dentro de los ubdirectorios (doypath)
703
702
704 Return:
703 Return:
705 directory : eL directorio donde esta el file encontrado
704 directory : eL directorio donde esta el file encontrado
706 filename : el ultimo file de una determinada carpeta
705 filename : el ultimo file de una determinada carpeta
707 year : el anho
706 year : el anho
708 doy : el numero de dia del anho
707 doy : el numero de dia del anho
709 set : el set del archivo
708 set : el set del archivo
710
709
711
710
712 """
711 """
713 if not os.path.isdir(path):
712 if not os.path.isdir(path):
714 return None, None, None, None, None, None
713 return None, None, None, None, None, None
715
714
716 dirList = []
715 dirList = []
717
716
718 if not walk:
717 if not walk:
719 fullpath = path
718 fullpath = path
720 foldercounter = 0
719 foldercounter = 0
721 else:
720 else:
722 #Filtra solo los directorios
721 #Filtra solo los directorios
723 for thisPath in os.listdir(path):
722 for thisPath in os.listdir(path):
724 if not os.path.isdir(os.path.join(path,thisPath)):
723 if not os.path.isdir(os.path.join(path,thisPath)):
725 continue
724 continue
726 if not isRadarFolder(thisPath):
725 if not isRadarFolder(thisPath):
727 continue
726 continue
728
727
729 dirList.append(thisPath)
728 dirList.append(thisPath)
730
729
731 if not(dirList):
730 if not(dirList):
732 return None, None, None, None, None, None
731 return None, None, None, None, None, None
733
732
734 dirList = sorted( dirList, key=str.lower )
733 dirList = sorted( dirList, key=str.lower )
735
734
736 doypath = dirList[-1]
735 doypath = dirList[-1]
737 foldercounter = int(doypath.split('_')[1]) if len(doypath.split('_'))>1 else 0
736 foldercounter = int(doypath.split('_')[1]) if len(doypath.split('_'))>1 else 0
738 fullpath = os.path.join(path, doypath, expLabel)
737 fullpath = os.path.join(path, doypath, expLabel)
739
738
740
739
741 print "[Reading] %s folder was found: " %(fullpath )
740 print "[Reading] %s folder was found: " %(fullpath )
742
741
743 if set == None:
742 if set == None:
744 filename = getlastFileFromPath(fullpath, ext)
743 filename = getlastFileFromPath(fullpath, ext)
745 else:
744 else:
746 filename = getFileFromSet(fullpath, ext, set)
745 filename = getFileFromSet(fullpath, ext, set)
747
746
748 if not(filename):
747 if not(filename):
749 return None, None, None, None, None, None
748 return None, None, None, None, None, None
750
749
751 print "[Reading] %s file was found" %(filename)
750 print "[Reading] %s file was found" %(filename)
752
751
753 if not(self.__verifyFile(os.path.join(fullpath, filename))):
752 if not(self.__verifyFile(os.path.join(fullpath, filename))):
754 return None, None, None, None, None, None
753 return None, None, None, None, None, None
755
754
756 year = int( filename[1:5] )
755 year = int( filename[1:5] )
757 doy = int( filename[5:8] )
756 doy = int( filename[5:8] )
758 set = int( filename[8:11] )
757 set = int( filename[8:11] )
759
758
760 return fullpath, foldercounter, filename, year, doy, set
759 return fullpath, foldercounter, filename, year, doy, set
761
760
762 def __setNextFileOffline(self):
761 def __setNextFileOffline(self):
763
762
764 idFile = self.fileIndex
763 idFile = self.fileIndex
765
764
766 while (True):
765 while (True):
767 idFile += 1
766 idFile += 1
768 if not(idFile < len(self.filenameList)):
767 if not(idFile < len(self.filenameList)):
769 self.flagNoMoreFiles = 1
768 self.flagNoMoreFiles = 1
770 # print "[Reading] No more Files"
769 # print "[Reading] No more Files"
771 return 0
770 return 0
772
771
773 filename = self.filenameList[idFile]
772 filename = self.filenameList[idFile]
774
773
775 if not(self.__verifyFile(filename)):
774 if not(self.__verifyFile(filename)):
776 continue
775 continue
777
776
778 fileSize = os.path.getsize(filename)
777 fileSize = os.path.getsize(filename)
779 fp = open(filename,'rb')
778 fp = open(filename,'rb')
780 break
779 break
781
780
782 self.flagIsNewFile = 1
781 self.flagIsNewFile = 1
783 self.fileIndex = idFile
782 self.fileIndex = idFile
784 self.filename = filename
783 self.filename = filename
785 self.fileSize = fileSize
784 self.fileSize = fileSize
786 self.fp = fp
785 self.fp = fp
787
786
788 # print "[Reading] Setting the file: %s"%self.filename
787 # print "[Reading] Setting the file: %s"%self.filename
789
788
790 return 1
789 return 1
791
790
792 def __setNextFileOnline(self):
791 def __setNextFileOnline(self):
793 """
792 """
794 Busca el siguiente file que tenga suficiente data para ser leida, dentro de un folder especifico, si
793 Busca el siguiente file que tenga suficiente data para ser leida, dentro de un folder especifico, si
795 no encuentra un file valido espera un tiempo determinado y luego busca en los posibles n files
794 no encuentra un file valido espera un tiempo determinado y luego busca en los posibles n files
796 siguientes.
795 siguientes.
797
796
798 Affected:
797 Affected:
799 self.flagIsNewFile
798 self.flagIsNewFile
800 self.filename
799 self.filename
801 self.fileSize
800 self.fileSize
802 self.fp
801 self.fp
803 self.set
802 self.set
804 self.flagNoMoreFiles
803 self.flagNoMoreFiles
805
804
806 Return:
805 Return:
807 0 : si luego de una busqueda del siguiente file valido este no pudo ser encontrado
806 0 : si luego de una busqueda del siguiente file valido este no pudo ser encontrado
808 1 : si el file fue abierto con exito y esta listo a ser leido
807 1 : si el file fue abierto con exito y esta listo a ser leido
809
808
810 Excepciones:
809 Excepciones:
811 Si un determinado file no puede ser abierto
810 Si un determinado file no puede ser abierto
812 """
811 """
813 nFiles = 0
812 nFiles = 0
814 fileOk_flag = False
813 fileOk_flag = False
815 firstTime_flag = True
814 firstTime_flag = True
816
815
817 self.set += 1
816 self.set += 1
818
817
819 if self.set > 999:
818 if self.set > 999:
820 self.set = 0
819 self.set = 0
821 self.foldercounter += 1
820 self.foldercounter += 1
822
821
823 #busca el 1er file disponible
822 #busca el 1er file disponible
824 fullfilename, filename = checkForRealPath( self.path, self.foldercounter, self.year, self.doy, self.set, self.ext )
823 fullfilename, filename = checkForRealPath( self.path, self.foldercounter, self.year, self.doy, self.set, self.ext )
825 if fullfilename:
824 if fullfilename:
826 if self.__verifyFile(fullfilename, False):
825 if self.__verifyFile(fullfilename, False):
827 fileOk_flag = True
826 fileOk_flag = True
828
827
829 #si no encuentra un file entonces espera y vuelve a buscar
828 #si no encuentra un file entonces espera y vuelve a buscar
830 if not(fileOk_flag):
829 if not(fileOk_flag):
831 for nFiles in range(self.nFiles+1): #busco en los siguientes self.nFiles+1 files posibles
830 for nFiles in range(self.nFiles+1): #busco en los siguientes self.nFiles+1 files posibles
832
831
833 if firstTime_flag: #si es la 1era vez entonces hace el for self.nTries veces
832 if firstTime_flag: #si es la 1era vez entonces hace el for self.nTries veces
834 tries = self.nTries
833 tries = self.nTries
835 else:
834 else:
836 tries = 1 #si no es la 1era vez entonces solo lo hace una vez
835 tries = 1 #si no es la 1era vez entonces solo lo hace una vez
837
836
838 for nTries in range( tries ):
837 for nTries in range( tries ):
839 if firstTime_flag:
838 if firstTime_flag:
840 print "\t[Reading] Waiting %0.2f sec for the next file: \"%s\" , try %03d ..." % ( self.delay, filename, nTries+1 )
839 print "\t[Reading] Waiting %0.2f sec for the next file: \"%s\" , try %03d ..." % ( self.delay, filename, nTries+1 )
841 sleep( self.delay )
840 sleep( self.delay )
842 else:
841 else:
843 print "\t[Reading] Searching the next \"%s%04d%03d%03d%s\" file ..." % (self.optchar, self.year, self.doy, self.set, self.ext)
842 print "\t[Reading] Searching the next \"%s%04d%03d%03d%s\" file ..." % (self.optchar, self.year, self.doy, self.set, self.ext)
844
843
845 fullfilename, filename = checkForRealPath( self.path, self.foldercounter, self.year, self.doy, self.set, self.ext )
844 fullfilename, filename = checkForRealPath( self.path, self.foldercounter, self.year, self.doy, self.set, self.ext )
846 if fullfilename:
845 if fullfilename:
847 if self.__verifyFile(fullfilename):
846 if self.__verifyFile(fullfilename):
848 fileOk_flag = True
847 fileOk_flag = True
849 break
848 break
850
849
851 if fileOk_flag:
850 if fileOk_flag:
852 break
851 break
853
852
854 firstTime_flag = False
853 firstTime_flag = False
855
854
856 print "\t[Reading] Skipping the file \"%s\" due to this file doesn't exist" % filename
855 print "\t[Reading] Skipping the file \"%s\" due to this file doesn't exist" % filename
857 self.set += 1
856 self.set += 1
858
857
859 if nFiles == (self.nFiles-1): #si no encuentro el file buscado cambio de carpeta y busco en la siguiente carpeta
858 if nFiles == (self.nFiles-1): #si no encuentro el file buscado cambio de carpeta y busco en la siguiente carpeta
860 self.set = 0
859 self.set = 0
861 self.doy += 1
860 self.doy += 1
862 self.foldercounter = 0
861 self.foldercounter = 0
863
862
864 if fileOk_flag:
863 if fileOk_flag:
865 self.fileSize = os.path.getsize( fullfilename )
864 self.fileSize = os.path.getsize( fullfilename )
866 self.filename = fullfilename
865 self.filename = fullfilename
867 self.flagIsNewFile = 1
866 self.flagIsNewFile = 1
868 if self.fp != None: self.fp.close()
867 if self.fp != None: self.fp.close()
869 self.fp = open(fullfilename, 'rb')
868 self.fp = open(fullfilename, 'rb')
870 self.flagNoMoreFiles = 0
869 self.flagNoMoreFiles = 0
871 # print '[Reading] Setting the file: %s' % fullfilename
870 # print '[Reading] Setting the file: %s' % fullfilename
872 else:
871 else:
873 self.fileSize = 0
872 self.fileSize = 0
874 self.filename = None
873 self.filename = None
875 self.flagIsNewFile = 0
874 self.flagIsNewFile = 0
876 self.fp = None
875 self.fp = None
877 self.flagNoMoreFiles = 1
876 self.flagNoMoreFiles = 1
878 # print '[Reading] No more files to read'
877 # print '[Reading] No more files to read'
879
878
880 return fileOk_flag
879 return fileOk_flag
881
880
882 def setNextFile(self):
881 def setNextFile(self):
883 if self.fp != None:
882 if self.fp != None:
884 self.fp.close()
883 self.fp.close()
885
884
886 if self.online:
885 if self.online:
887 newFile = self.__setNextFileOnline()
886 newFile = self.__setNextFileOnline()
888 else:
887 else:
889 newFile = self.__setNextFileOffline()
888 newFile = self.__setNextFileOffline()
890
889
891 if not(newFile):
890 if not(newFile):
892 print '[Reading] No more files to read'
891 print '[Reading] No more files to read'
893 return 0
892 return 0
894
893
895 if self.verbose:
894 if self.verbose:
896 print '[Reading] Setting the file: %s' % self.filename
895 print '[Reading] Setting the file: %s' % self.filename
897
896
898 self.__readFirstHeader()
897 self.__readFirstHeader()
899 self.nReadBlocks = 0
898 self.nReadBlocks = 0
900 return 1
899 return 1
901
900
902 def __waitNewBlock(self):
901 def __waitNewBlock(self):
903 """
902 """
904 Return 1 si se encontro un nuevo bloque de datos, 0 de otra forma.
903 Return 1 si se encontro un nuevo bloque de datos, 0 de otra forma.
905
904
906 Si el modo de lectura es OffLine siempre retorn 0
905 Si el modo de lectura es OffLine siempre retorn 0
907 """
906 """
908 if not self.online:
907 if not self.online:
909 return 0
908 return 0
910
909
911 if (self.nReadBlocks >= self.processingHeaderObj.dataBlocksPerFile):
910 if (self.nReadBlocks >= self.processingHeaderObj.dataBlocksPerFile):
912 return 0
911 return 0
913
912
914 currentPointer = self.fp.tell()
913 currentPointer = self.fp.tell()
915
914
916 neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize
915 neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize
917
916
918 for nTries in range( self.nTries ):
917 for nTries in range( self.nTries ):
919
918
920 self.fp.close()
919 self.fp.close()
921 self.fp = open( self.filename, 'rb' )
920 self.fp = open( self.filename, 'rb' )
922 self.fp.seek( currentPointer )
921 self.fp.seek( currentPointer )
923
922
924 self.fileSize = os.path.getsize( self.filename )
923 self.fileSize = os.path.getsize( self.filename )
925 currentSize = self.fileSize - currentPointer
924 currentSize = self.fileSize - currentPointer
926
925
927 if ( currentSize >= neededSize ):
926 if ( currentSize >= neededSize ):
928 self.basicHeaderObj.read(self.fp)
927 self.basicHeaderObj.read(self.fp)
929 return 1
928 return 1
930
929
931 if self.fileSize == self.fileSizeByHeader:
930 if self.fileSize == self.fileSizeByHeader:
932 # self.flagEoF = True
931 # self.flagEoF = True
933 return 0
932 return 0
934
933
935 print "[Reading] Waiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries+1)
934 print "[Reading] Waiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries+1)
936 sleep( self.delay )
935 sleep( self.delay )
937
936
938
937
939 return 0
938 return 0
940
939
941 def waitDataBlock(self,pointer_location):
940 def waitDataBlock(self,pointer_location):
942
941
943 currentPointer = pointer_location
942 currentPointer = pointer_location
944
943
945 neededSize = self.processingHeaderObj.blockSize #+ self.basicHeaderSize
944 neededSize = self.processingHeaderObj.blockSize #+ self.basicHeaderSize
946
945
947 for nTries in range( self.nTries ):
946 for nTries in range( self.nTries ):
948 self.fp.close()
947 self.fp.close()
949 self.fp = open( self.filename, 'rb' )
948 self.fp = open( self.filename, 'rb' )
950 self.fp.seek( currentPointer )
949 self.fp.seek( currentPointer )
951
950
952 self.fileSize = os.path.getsize( self.filename )
951 self.fileSize = os.path.getsize( self.filename )
953 currentSize = self.fileSize - currentPointer
952 currentSize = self.fileSize - currentPointer
954
953
955 if ( currentSize >= neededSize ):
954 if ( currentSize >= neededSize ):
956 return 1
955 return 1
957
956
958 print "[Reading] Waiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries+1)
957 print "[Reading] Waiting %0.2f seconds for the next block, try %03d ..." % (self.delay, nTries+1)
959 sleep( self.delay )
958 sleep( self.delay )
960
959
961 return 0
960 return 0
962
961
963 def __jumpToLastBlock(self):
962 def __jumpToLastBlock(self):
964
963
965 if not(self.__isFirstTimeOnline):
964 if not(self.__isFirstTimeOnline):
966 return
965 return
967
966
968 csize = self.fileSize - self.fp.tell()
967 csize = self.fileSize - self.fp.tell()
969 blocksize = self.processingHeaderObj.blockSize
968 blocksize = self.processingHeaderObj.blockSize
970
969
971 #salta el primer bloque de datos
970 #salta el primer bloque de datos
972 if csize > self.processingHeaderObj.blockSize:
971 if csize > self.processingHeaderObj.blockSize:
973 self.fp.seek(self.fp.tell() + blocksize)
972 self.fp.seek(self.fp.tell() + blocksize)
974 else:
973 else:
975 return
974 return
976
975
977 csize = self.fileSize - self.fp.tell()
976 csize = self.fileSize - self.fp.tell()
978 neededsize = self.processingHeaderObj.blockSize + self.basicHeaderSize
977 neededsize = self.processingHeaderObj.blockSize + self.basicHeaderSize
979 while True:
978 while True:
980
979
981 if self.fp.tell()<self.fileSize:
980 if self.fp.tell()<self.fileSize:
982 self.fp.seek(self.fp.tell() + neededsize)
981 self.fp.seek(self.fp.tell() + neededsize)
983 else:
982 else:
984 self.fp.seek(self.fp.tell() - neededsize)
983 self.fp.seek(self.fp.tell() - neededsize)
985 break
984 break
986
985
987 # csize = self.fileSize - self.fp.tell()
986 # csize = self.fileSize - self.fp.tell()
988 # neededsize = self.processingHeaderObj.blockSize + self.basicHeaderSize
987 # neededsize = self.processingHeaderObj.blockSize + self.basicHeaderSize
989 # factor = int(csize/neededsize)
988 # factor = int(csize/neededsize)
990 # if factor > 0:
989 # if factor > 0:
991 # self.fp.seek(self.fp.tell() + factor*neededsize)
990 # self.fp.seek(self.fp.tell() + factor*neededsize)
992
991
993 self.flagIsNewFile = 0
992 self.flagIsNewFile = 0
994 self.__isFirstTimeOnline = 0
993 self.__isFirstTimeOnline = 0
995
994
996 def __setNewBlock(self):
995 def __setNewBlock(self):
997
996
998 if self.fp == None:
997 if self.fp == None:
999 return 0
998 return 0
1000
999
1001 # if self.online:
1000 # if self.online:
1002 # self.__jumpToLastBlock()
1001 # self.__jumpToLastBlock()
1003
1002
1004 if self.flagIsNewFile:
1003 if self.flagIsNewFile:
1005 self.lastUTTime = self.basicHeaderObj.utc
1004 self.lastUTTime = self.basicHeaderObj.utc
1006 return 1
1005 return 1
1007
1006
1008 if self.realtime:
1007 if self.realtime:
1009 self.flagDiscontinuousBlock = 1
1008 self.flagDiscontinuousBlock = 1
1010 if not(self.setNextFile()):
1009 if not(self.setNextFile()):
1011 return 0
1010 return 0
1012 else:
1011 else:
1013 return 1
1012 return 1
1014
1013
1015 currentSize = self.fileSize - self.fp.tell()
1014 currentSize = self.fileSize - self.fp.tell()
1016 neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize
1015 neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize
1017
1016
1018 if (currentSize >= neededSize):
1017 if (currentSize >= neededSize):
1019 self.basicHeaderObj.read(self.fp)
1018 self.basicHeaderObj.read(self.fp)
1020 self.lastUTTime = self.basicHeaderObj.utc
1019 self.lastUTTime = self.basicHeaderObj.utc
1021 return 1
1020 return 1
1022
1021
1023 if self.__waitNewBlock():
1022 if self.__waitNewBlock():
1024 self.lastUTTime = self.basicHeaderObj.utc
1023 self.lastUTTime = self.basicHeaderObj.utc
1025 return 1
1024 return 1
1026
1025
1027 if not(self.setNextFile()):
1026 if not(self.setNextFile()):
1028 return 0
1027 return 0
1029
1028
1030 deltaTime = self.basicHeaderObj.utc - self.lastUTTime #
1029 deltaTime = self.basicHeaderObj.utc - self.lastUTTime #
1031 self.lastUTTime = self.basicHeaderObj.utc
1030 self.lastUTTime = self.basicHeaderObj.utc
1032
1031
1033 self.flagDiscontinuousBlock = 0
1032 self.flagDiscontinuousBlock = 0
1034
1033
1035 if deltaTime > self.maxTimeStep:
1034 if deltaTime > self.maxTimeStep:
1036 self.flagDiscontinuousBlock = 1
1035 self.flagDiscontinuousBlock = 1
1037
1036
1038 return 1
1037 return 1
1039
1038
1040 def readNextBlock(self):
1039 def readNextBlock(self):
1041
1040
1042 #Skip block out of startTime and endTime
1041 #Skip block out of startTime and endTime
1043 while True:
1042 while True:
1044 if not(self.__setNewBlock()):
1043 if not(self.__setNewBlock()):
1045 return 0
1044 return 0
1046
1045
1047 if not(self.readBlock()):
1046 if not(self.readBlock()):
1048 return 0
1047 return 0
1049
1048
1050 self.getBasicHeader()
1049 self.getBasicHeader()
1051
1050
1052 if not isTimeInRange(self.dataOut.datatime.time(), self.startTime, self.endTime):
1051 if not isTimeInRange(self.dataOut.datatime.time(), self.startTime, self.endTime):
1053
1052
1054 print "[Reading] Block No. %d/%d -> %s [Skipping]" %(self.nReadBlocks,
1053 print "[Reading] Block No. %d/%d -> %s [Skipping]" %(self.nReadBlocks,
1055 self.processingHeaderObj.dataBlocksPerFile,
1054 self.processingHeaderObj.dataBlocksPerFile,
1056 self.dataOut.datatime.ctime())
1055 self.dataOut.datatime.ctime())
1057 continue
1056 continue
1058
1057
1059 break
1058 break
1060
1059
1061 # if self.verbose:
1060 if self.verbose:
1062 # print "[Reading] Block No. %d/%d -> %s" %(self.nReadBlocks,
1061 print "[Reading] Block No. %d/%d -> %s" %(self.nReadBlocks,
1063 # self.processingHeaderObj.dataBlocksPerFile,
1062 self.processingHeaderObj.dataBlocksPerFile,
1064 # self.dataOut.datatime.ctime())
1063 self.dataOut.datatime.ctime())
1065 return 1
1064 return 1
1066
1065
1067 def __readFirstHeader(self):
1066 def __readFirstHeader(self):
1068
1067
1069 self.basicHeaderObj.read(self.fp)
1068 self.basicHeaderObj.read(self.fp)
1070 self.systemHeaderObj.read(self.fp)
1069 self.systemHeaderObj.read(self.fp)
1071 self.radarControllerHeaderObj.read(self.fp)
1070 self.radarControllerHeaderObj.read(self.fp)
1072 self.processingHeaderObj.read(self.fp)
1071 self.processingHeaderObj.read(self.fp)
1073
1072
1074 self.firstHeaderSize = self.basicHeaderObj.size
1073 self.firstHeaderSize = self.basicHeaderObj.size
1075
1074
1076 datatype = int(numpy.log2((self.processingHeaderObj.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR))
1075 datatype = int(numpy.log2((self.processingHeaderObj.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR))
1077 if datatype == 0:
1076 if datatype == 0:
1078 datatype_str = numpy.dtype([('real','<i1'),('imag','<i1')])
1077 datatype_str = numpy.dtype([('real','<i1'),('imag','<i1')])
1079 elif datatype == 1:
1078 elif datatype == 1:
1080 datatype_str = numpy.dtype([('real','<i2'),('imag','<i2')])
1079 datatype_str = numpy.dtype([('real','<i2'),('imag','<i2')])
1081 elif datatype == 2:
1080 elif datatype == 2:
1082 datatype_str = numpy.dtype([('real','<i4'),('imag','<i4')])
1081 datatype_str = numpy.dtype([('real','<i4'),('imag','<i4')])
1083 elif datatype == 3:
1082 elif datatype == 3:
1084 datatype_str = numpy.dtype([('real','<i8'),('imag','<i8')])
1083 datatype_str = numpy.dtype([('real','<i8'),('imag','<i8')])
1085 elif datatype == 4:
1084 elif datatype == 4:
1086 datatype_str = numpy.dtype([('real','<f4'),('imag','<f4')])
1085 datatype_str = numpy.dtype([('real','<f4'),('imag','<f4')])
1087 elif datatype == 5:
1086 elif datatype == 5:
1088 datatype_str = numpy.dtype([('real','<f8'),('imag','<f8')])
1087 datatype_str = numpy.dtype([('real','<f8'),('imag','<f8')])
1089 else:
1088 else:
1090 raise ValueError, 'Data type was not defined'
1089 raise ValueError, 'Data type was not defined'
1091
1090
1092 self.dtype = datatype_str
1091 self.dtype = datatype_str
1093 #self.ippSeconds = 2 * 1000 * self.radarControllerHeaderObj.ipp / self.c
1092 #self.ippSeconds = 2 * 1000 * self.radarControllerHeaderObj.ipp / self.c
1094 self.fileSizeByHeader = self.processingHeaderObj.dataBlocksPerFile * self.processingHeaderObj.blockSize + self.firstHeaderSize + self.basicHeaderSize*(self.processingHeaderObj.dataBlocksPerFile - 1)
1093 self.fileSizeByHeader = self.processingHeaderObj.dataBlocksPerFile * self.processingHeaderObj.blockSize + self.firstHeaderSize + self.basicHeaderSize*(self.processingHeaderObj.dataBlocksPerFile - 1)
1095 # self.dataOut.channelList = numpy.arange(self.systemHeaderObj.numChannels)
1094 # self.dataOut.channelList = numpy.arange(self.systemHeaderObj.numChannels)
1096 # self.dataOut.channelIndexList = numpy.arange(self.systemHeaderObj.numChannels)
1095 # self.dataOut.channelIndexList = numpy.arange(self.systemHeaderObj.numChannels)
1097 self.getBlockDimension()
1096 self.getBlockDimension()
1098
1097
1099 def __verifyFile(self, filename, msgFlag=True):
1098 def __verifyFile(self, filename, msgFlag=True):
1100
1099
1101 msg = None
1100 msg = None
1102
1101
1103 try:
1102 try:
1104 fp = open(filename, 'rb')
1103 fp = open(filename, 'rb')
1105 except IOError:
1104 except IOError:
1106
1105
1107 if msgFlag:
1106 if msgFlag:
1108 print "[Reading] File %s can't be opened" % (filename)
1107 print "[Reading] File %s can't be opened" % (filename)
1109
1108
1110 return False
1109 return False
1111
1110
1112 currentPosition = fp.tell()
1111 currentPosition = fp.tell()
1113 neededSize = self.processingHeaderObj.blockSize + self.firstHeaderSize
1112 neededSize = self.processingHeaderObj.blockSize + self.firstHeaderSize
1114
1113
1115 if neededSize == 0:
1114 if neededSize == 0:
1116 basicHeaderObj = BasicHeader(LOCALTIME)
1115 basicHeaderObj = BasicHeader(LOCALTIME)
1117 systemHeaderObj = SystemHeader()
1116 systemHeaderObj = SystemHeader()
1118 radarControllerHeaderObj = RadarControllerHeader()
1117 radarControllerHeaderObj = RadarControllerHeader()
1119 processingHeaderObj = ProcessingHeader()
1118 processingHeaderObj = ProcessingHeader()
1120
1119
1121 if not( basicHeaderObj.read(fp) ):
1120 if not( basicHeaderObj.read(fp) ):
1122 fp.close()
1121 fp.close()
1123 return False
1122 return False
1124
1123
1125 if not( systemHeaderObj.read(fp) ):
1124 if not( systemHeaderObj.read(fp) ):
1126 fp.close()
1125 fp.close()
1127 return False
1126 return False
1128
1127
1129 if not( radarControllerHeaderObj.read(fp) ):
1128 if not( radarControllerHeaderObj.read(fp) ):
1130 fp.close()
1129 fp.close()
1131 return False
1130 return False
1132
1131
1133 if not( processingHeaderObj.read(fp) ):
1132 if not( processingHeaderObj.read(fp) ):
1134 fp.close()
1133 fp.close()
1135 return False
1134 return False
1136
1135
1137 neededSize = processingHeaderObj.blockSize + basicHeaderObj.size
1136 neededSize = processingHeaderObj.blockSize + basicHeaderObj.size
1138 else:
1137 else:
1139 msg = "[Reading] Skipping the file %s due to it hasn't enough data" %filename
1138 msg = "[Reading] Skipping the file %s due to it hasn't enough data" %filename
1140
1139
1141 fp.close()
1140 fp.close()
1142
1141
1143 fileSize = os.path.getsize(filename)
1142 fileSize = os.path.getsize(filename)
1144 currentSize = fileSize - currentPosition
1143 currentSize = fileSize - currentPosition
1145
1144
1146 if currentSize < neededSize:
1145 if currentSize < neededSize:
1147 if msgFlag and (msg != None):
1146 if msgFlag and (msg != None):
1148 print msg
1147 print msg
1149 return False
1148 return False
1150
1149
1151 return True
1150 return True
1152
1151
1153 def findDatafiles(self, path, startDate=None, endDate=None, expLabel='', ext='.r', walk=True, include_path=False):
1152 def findDatafiles(self, path, startDate=None, endDate=None, expLabel='', ext='.r', walk=True, include_path=False):
1154
1153
1155 path_empty = True
1154 path_empty = True
1156
1155
1157 dateList = []
1156 dateList = []
1158 pathList = []
1157 pathList = []
1159
1158
1160 multi_path = path.split(',')
1159 multi_path = path.split(',')
1161
1160
1162 if not walk:
1161 if not walk:
1163
1162
1164 for single_path in multi_path:
1163 for single_path in multi_path:
1165
1164
1166 if not os.path.isdir(single_path):
1165 if not os.path.isdir(single_path):
1167 continue
1166 continue
1168
1167
1169 fileList = glob.glob1(single_path, "*"+ext)
1168 fileList = glob.glob1(single_path, "*"+ext)
1170
1169
1171 if not fileList:
1170 if not fileList:
1172 continue
1171 continue
1173
1172
1174 path_empty = False
1173 path_empty = False
1175
1174
1176 fileList.sort()
1175 fileList.sort()
1177
1176
1178 for thisFile in fileList:
1177 for thisFile in fileList:
1179
1178
1180 if not os.path.isfile(os.path.join(single_path, thisFile)):
1179 if not os.path.isfile(os.path.join(single_path, thisFile)):
1181 continue
1180 continue
1182
1181
1183 if not isRadarFile(thisFile):
1182 if not isRadarFile(thisFile):
1184 continue
1183 continue
1185
1184
1186 if not isFileInDateRange(thisFile, startDate, endDate):
1185 if not isFileInDateRange(thisFile, startDate, endDate):
1187 continue
1186 continue
1188
1187
1189 thisDate = getDateFromRadarFile(thisFile)
1188 thisDate = getDateFromRadarFile(thisFile)
1190
1189
1191 if thisDate in dateList:
1190 if thisDate in dateList:
1192 continue
1191 continue
1193
1192
1194 dateList.append(thisDate)
1193 dateList.append(thisDate)
1195 pathList.append(single_path)
1194 pathList.append(single_path)
1196
1195
1197 else:
1196 else:
1198 for single_path in multi_path:
1197 for single_path in multi_path:
1199
1198
1200 if not os.path.isdir(single_path):
1199 if not os.path.isdir(single_path):
1201 continue
1200 continue
1202
1201
1203 dirList = []
1202 dirList = []
1204
1203
1205 for thisPath in os.listdir(single_path):
1204 for thisPath in os.listdir(single_path):
1206
1205
1207 if not os.path.isdir(os.path.join(single_path,thisPath)):
1206 if not os.path.isdir(os.path.join(single_path,thisPath)):
1208 continue
1207 continue
1209
1208
1210 if not isRadarFolder(thisPath):
1209 if not isRadarFolder(thisPath):
1211 continue
1210 continue
1212
1211
1213 if not isFolderInDateRange(thisPath, startDate, endDate):
1212 if not isFolderInDateRange(thisPath, startDate, endDate):
1214 continue
1213 continue
1215
1214
1216 dirList.append(thisPath)
1215 dirList.append(thisPath)
1217
1216
1218 if not dirList:
1217 if not dirList:
1219 continue
1218 continue
1220
1219
1221 dirList.sort()
1220 dirList.sort()
1222
1221
1223 for thisDir in dirList:
1222 for thisDir in dirList:
1224
1223
1225 datapath = os.path.join(single_path, thisDir, expLabel)
1224 datapath = os.path.join(single_path, thisDir, expLabel)
1226 fileList = glob.glob1(datapath, "*"+ext)
1225 fileList = glob.glob1(datapath, "*"+ext)
1227
1226
1228 if not fileList:
1227 if not fileList:
1229 continue
1228 continue
1230
1229
1231 path_empty = False
1230 path_empty = False
1232
1231
1233 thisDate = getDateFromRadarFolder(thisDir)
1232 thisDate = getDateFromRadarFolder(thisDir)
1234
1233
1235 pathList.append(datapath)
1234 pathList.append(datapath)
1236 dateList.append(thisDate)
1235 dateList.append(thisDate)
1237
1236
1238 dateList.sort()
1237 dateList.sort()
1239
1238
1240 if walk:
1239 if walk:
1241 pattern_path = os.path.join(multi_path[0], "[dYYYYDDD]", expLabel)
1240 pattern_path = os.path.join(multi_path[0], "[dYYYYDDD]", expLabel)
1242 else:
1241 else:
1243 pattern_path = multi_path[0]
1242 pattern_path = multi_path[0]
1244
1243
1245 if path_empty:
1244 if path_empty:
1246 print "[Reading] No *%s files in %s for %s to %s" %(ext, pattern_path, startDate, endDate)
1245 print "[Reading] No *%s files in %s for %s to %s" %(ext, pattern_path, startDate, endDate)
1247 else:
1246 else:
1248 if not dateList:
1247 if not dateList:
1249 print "[Reading] Date range selected invalid [%s - %s]: No *%s files in %s)" %(startDate, endDate, ext, path)
1248 print "[Reading] Date range selected invalid [%s - %s]: No *%s files in %s)" %(startDate, endDate, ext, path)
1250
1249
1251 if include_path:
1250 if include_path:
1252 return dateList, pathList
1251 return dateList, pathList
1253
1252
1254 return dateList
1253 return dateList
1255
1254
1256 def setup(self,
1255 def setup(self,
1257 path=None,
1256 path=None,
1258 startDate=None,
1257 startDate=None,
1259 endDate=None,
1258 endDate=None,
1260 startTime=datetime.time(0,0,0),
1259 startTime=datetime.time(0,0,0),
1261 endTime=datetime.time(23,59,59),
1260 endTime=datetime.time(23,59,59),
1262 set=None,
1261 set=None,
1263 expLabel = "",
1262 expLabel = "",
1264 ext = None,
1263 ext = None,
1265 online = False,
1264 online = False,
1266 delay = 60,
1265 delay = 60,
1267 walk = True,
1266 walk = True,
1268 getblock = False,
1267 getblock = False,
1269 nTxs = 1,
1268 nTxs = 1,
1270 realtime=False,
1269 realtime=False,
1271 blocksize=None,
1270 blocksize=None,
1272 blocktime=None,
1271 blocktime=None,
1273 queue=None,
1272 queue=None,
1274 skip=None,
1273 skip=None,
1275 cursor=None,
1274 cursor=None,
1276 warnings=True,
1275 warnings=True,
1277 verbose=True):
1276 verbose=True):
1278
1277
1279 if path == None:
1278 if path == None:
1280 raise ValueError, "[Reading] The path is not valid"
1279 raise ValueError, "[Reading] The path is not valid"
1281
1280
1282 if ext == None:
1281 if ext == None:
1283 ext = self.ext
1282 ext = self.ext
1284
1283
1285 if online:
1284 if online:
1286 print "[Reading] Searching files in online mode..."
1285 print "[Reading] Searching files in online mode..."
1287
1286
1288 for nTries in range( self.nTries ):
1287 for nTries in range( self.nTries ):
1289 fullpath, foldercounter, file, year, doy, set = self.__searchFilesOnLine(path=path, expLabel=expLabel, ext=ext, walk=walk, set=set)
1288 fullpath, foldercounter, file, year, doy, set = self.__searchFilesOnLine(path=path, expLabel=expLabel, ext=ext, walk=walk, set=set)
1290
1289
1291 if fullpath:
1290 if fullpath:
1292 break
1291 break
1293
1292
1294 print '[Reading] Waiting %0.2f sec for an valid file in %s: try %02d ...' % (self.delay, path, nTries+1)
1293 print '[Reading] Waiting %0.2f sec for an valid file in %s: try %02d ...' % (self.delay, path, nTries+1)
1295 sleep( self.delay )
1294 sleep( self.delay )
1296
1295
1297 if not(fullpath):
1296 if not(fullpath):
1298 print "[Reading] There 'isn't any valid file in %s" % path
1297 print "[Reading] There 'isn't any valid file in %s" % path
1299 return
1298 return
1300
1299
1301 self.year = year
1300 self.year = year
1302 self.doy = doy
1301 self.doy = doy
1303 self.set = set - 1
1302 self.set = set - 1
1304 self.path = path
1303 self.path = path
1305 self.foldercounter = foldercounter
1304 self.foldercounter = foldercounter
1306 last_set = None
1305 last_set = None
1307
1306
1308 else:
1307 else:
1309 print "[Reading] Searching files in offline mode ..."
1308 print "[Reading] Searching files in offline mode ..."
1310 pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate,
1309 pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate,
1311 startTime=startTime, endTime=endTime,
1310 startTime=startTime, endTime=endTime,
1312 set=set, expLabel=expLabel, ext=ext,
1311 set=set, expLabel=expLabel, ext=ext,
1313 walk=walk, cursor=cursor,
1312 walk=walk, cursor=cursor,
1314 skip=skip, queue=queue)
1313 skip=skip, queue=queue)
1315
1314
1316 if not(pathList):
1315 if not(pathList):
1317 # print "[Reading] No *%s files in %s (%s - %s)"%(ext, path,
1316 # print "[Reading] No *%s files in %s (%s - %s)"%(ext, path,
1318 # datetime.datetime.combine(startDate,startTime).ctime(),
1317 # datetime.datetime.combine(startDate,startTime).ctime(),
1319 # datetime.datetime.combine(endDate,endTime).ctime())
1318 # datetime.datetime.combine(endDate,endTime).ctime())
1320
1319
1321 # sys.exit(-1)
1320 # sys.exit(-1)
1322
1321
1323 self.fileIndex = -1
1322 self.fileIndex = -1
1324 self.pathList = []
1323 self.pathList = []
1325 self.filenameList = []
1324 self.filenameList = []
1326 return
1325 return
1327
1326
1328 self.fileIndex = -1
1327 self.fileIndex = -1
1329 self.pathList = pathList
1328 self.pathList = pathList
1330 self.filenameList = filenameList
1329 self.filenameList = filenameList
1331 file_name = os.path.basename(filenameList[-1])
1330 file_name = os.path.basename(filenameList[-1])
1332 basename, ext = os.path.splitext(file_name)
1331 basename, ext = os.path.splitext(file_name)
1333 last_set = int(basename[-3:])
1332 last_set = int(basename[-3:])
1334
1333
1335 self.online = online
1334 self.online = online
1336 self.realtime = realtime
1335 self.realtime = realtime
1337 self.delay = delay
1336 self.delay = delay
1338 ext = ext.lower()
1337 ext = ext.lower()
1339 self.ext = ext
1338 self.ext = ext
1340 self.getByBlock = getblock
1339 self.getByBlock = getblock
1341 self.nTxs = nTxs
1340 self.nTxs = nTxs
1342 self.startTime = startTime
1341 self.startTime = startTime
1343 self.endTime = endTime
1342 self.endTime = endTime
1344
1343
1345 #Added-----------------
1344 #Added-----------------
1346 self.selBlocksize = blocksize
1345 self.selBlocksize = blocksize
1347 self.selBlocktime = blocktime
1346 self.selBlocktime = blocktime
1348
1347
1349 # Verbose-----------
1348 # Verbose-----------
1350 self.verbose = verbose
1349 self.verbose = verbose
1351 self.warnings = warnings
1350 self.warnings = warnings
1352
1351
1353 if not(self.setNextFile()):
1352 if not(self.setNextFile()):
1354 if (startDate!=None) and (endDate!=None):
1353 if (startDate!=None) and (endDate!=None):
1355 print "[Reading] No files in range: %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
1354 print "[Reading] No files in range: %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
1356 elif startDate != None:
1355 elif startDate != None:
1357 print "[Reading] No files in range: %s" %(datetime.datetime.combine(startDate,startTime).ctime())
1356 print "[Reading] No files in range: %s" %(datetime.datetime.combine(startDate,startTime).ctime())
1358 else:
1357 else:
1359 print "[Reading] No files"
1358 print "[Reading] No files"
1360
1359
1361 self.fileIndex = -1
1360 self.fileIndex = -1
1362 self.pathList = []
1361 self.pathList = []
1363 self.filenameList = []
1362 self.filenameList = []
1364 return
1363 return
1365
1364
1366 # self.getBasicHeader()
1365 # self.getBasicHeader()
1367
1366
1368 if last_set != None:
1367 if last_set != None:
1369 self.dataOut.last_block = last_set * self.processingHeaderObj.dataBlocksPerFile + self.basicHeaderObj.dataBlock
1368 self.dataOut.last_block = last_set * self.processingHeaderObj.dataBlocksPerFile + self.basicHeaderObj.dataBlock
1370 return
1369 return
1371
1370
1372 def getBasicHeader(self):
1371 def getBasicHeader(self):
1373
1372
1374 self.dataOut.utctime = self.basicHeaderObj.utc + self.basicHeaderObj.miliSecond/1000. + self.profileIndex * self.radarControllerHeaderObj.ippSeconds
1373 self.dataOut.utctime = self.basicHeaderObj.utc + self.basicHeaderObj.miliSecond/1000. + self.profileIndex * self.radarControllerHeaderObj.ippSeconds
1375
1374
1376 self.dataOut.flagDiscontinuousBlock = self.flagDiscontinuousBlock
1375 self.dataOut.flagDiscontinuousBlock = self.flagDiscontinuousBlock
1377
1376
1378 self.dataOut.timeZone = self.basicHeaderObj.timeZone
1377 self.dataOut.timeZone = self.basicHeaderObj.timeZone
1379
1378
1380 self.dataOut.dstFlag = self.basicHeaderObj.dstFlag
1379 self.dataOut.dstFlag = self.basicHeaderObj.dstFlag
1381
1380
1382 self.dataOut.errorCount = self.basicHeaderObj.errorCount
1381 self.dataOut.errorCount = self.basicHeaderObj.errorCount
1383
1382
1384 self.dataOut.useLocalTime = self.basicHeaderObj.useLocalTime
1383 self.dataOut.useLocalTime = self.basicHeaderObj.useLocalTime
1385
1384
1386 self.dataOut.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs
1385 self.dataOut.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs
1387
1386
1388 # self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs
1387 # self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs
1389
1388
1390
1389
1391 def getFirstHeader(self):
1390 def getFirstHeader(self):
1392
1391
1393 raise NotImplementedError
1392 raise NotImplementedError
1394
1393
1395 def getData(self):
1394 def getData(self):
1396
1395
1397 raise NotImplementedError
1396 raise NotImplementedError
1398
1397
1399 def hasNotDataInBuffer(self):
1398 def hasNotDataInBuffer(self):
1400
1399
1401 raise NotImplementedError
1400 raise NotImplementedError
1402
1401
1403 def readBlock(self):
1402 def readBlock(self):
1404
1403
1405 raise NotImplementedError
1404 raise NotImplementedError
1406
1405
1407 def isEndProcess(self):
1406 def isEndProcess(self):
1408
1407
1409 return self.flagNoMoreFiles
1408 return self.flagNoMoreFiles
1410
1409
1411 def printReadBlocks(self):
1410 def printReadBlocks(self):
1412
1411
1413 print "[Reading] Number of read blocks per file %04d" %self.nReadBlocks
1412 print "[Reading] Number of read blocks per file %04d" %self.nReadBlocks
1414
1413
1415 def printTotalBlocks(self):
1414 def printTotalBlocks(self):
1416
1415
1417 print "[Reading] Number of read blocks %04d" %self.nTotalBlocks
1416 print "[Reading] Number of read blocks %04d" %self.nTotalBlocks
1418
1417
1419 def printNumberOfBlock(self):
1418 def printNumberOfBlock(self):
1420 'SPAM!'
1419 'SPAM!'
1421
1420
1422 # if self.flagIsNewBlock:
1421 # if self.flagIsNewBlock:
1423 # print "[Reading] Block No. %d/%d -> %s" %(self.nReadBlocks,
1422 # print "[Reading] Block No. %d/%d -> %s" %(self.nReadBlocks,
1424 # self.processingHeaderObj.dataBlocksPerFile,
1423 # self.processingHeaderObj.dataBlocksPerFile,
1425 # self.dataOut.datatime.ctime())
1424 # self.dataOut.datatime.ctime())
1426
1425
1427 def printInfo(self):
1426 def printInfo(self):
1428
1427
1429 if self.__printInfo == False:
1428 if self.__printInfo == False:
1430 return
1429 return
1431
1430
1432 self.basicHeaderObj.printInfo()
1431 self.basicHeaderObj.printInfo()
1433 self.systemHeaderObj.printInfo()
1432 self.systemHeaderObj.printInfo()
1434 self.radarControllerHeaderObj.printInfo()
1433 self.radarControllerHeaderObj.printInfo()
1435 self.processingHeaderObj.printInfo()
1434 self.processingHeaderObj.printInfo()
1436
1435
1437 self.__printInfo = False
1436 self.__printInfo = False
1438
1437
1439
1438
1440 def run(self,
1439 def run(self,
1441 path=None,
1440 path=None,
1442 startDate=None,
1441 startDate=None,
1443 endDate=None,
1442 endDate=None,
1444 startTime=datetime.time(0,0,0),
1443 startTime=datetime.time(0,0,0),
1445 endTime=datetime.time(23,59,59),
1444 endTime=datetime.time(23,59,59),
1446 set=None,
1445 set=None,
1447 expLabel = "",
1446 expLabel = "",
1448 ext = None,
1447 ext = None,
1449 online = False,
1448 online = False,
1450 delay = 60,
1449 delay = 60,
1451 walk = True,
1450 walk = True,
1452 getblock = False,
1451 getblock = False,
1453 nTxs = 1,
1452 nTxs = 1,
1454 realtime=False,
1453 realtime=False,
1455 blocksize=None,
1454 blocksize=None,
1456 blocktime=None,
1455 blocktime=None,
1457 queue=None,
1456 queue=None,
1458 skip=None,
1457 skip=None,
1459 cursor=None,
1458 cursor=None,
1460 warnings=True,
1459 warnings=True,
1461 verbose=True, **kwargs):
1460 verbose=True, **kwargs):
1462
1461
1463 if not(self.isConfig):
1462 if not(self.isConfig):
1464 # self.dataOut = dataOut
1463 # self.dataOut = dataOut
1465 self.setup( path=path,
1464 self.setup( path=path,
1466 startDate=startDate,
1465 startDate=startDate,
1467 endDate=endDate,
1466 endDate=endDate,
1468 startTime=startTime,
1467 startTime=startTime,
1469 endTime=endTime,
1468 endTime=endTime,
1470 set=set,
1469 set=set,
1471 expLabel=expLabel,
1470 expLabel=expLabel,
1472 ext=ext,
1471 ext=ext,
1473 online=online,
1472 online=online,
1474 delay=delay,
1473 delay=delay,
1475 walk=walk,
1474 walk=walk,
1476 getblock=getblock,
1475 getblock=getblock,
1477 nTxs=nTxs,
1476 nTxs=nTxs,
1478 realtime=realtime,
1477 realtime=realtime,
1479 blocksize=blocksize,
1478 blocksize=blocksize,
1480 blocktime=blocktime,
1479 blocktime=blocktime,
1481 queue=queue,
1480 queue=queue,
1482 skip=skip,
1481 skip=skip,
1483 cursor=cursor,
1482 cursor=cursor,
1484 warnings=warnings,
1483 warnings=warnings,
1485 verbose=verbose)
1484 verbose=verbose)
1486 self.isConfig = True
1485 self.isConfig = True
1487
1486
1488 self.getData()
1487 self.getData()
1489
1488
1490 class JRODataWriter(JRODataIO):
1489 class JRODataWriter(JRODataIO):
1491
1490
1492 """
1491 """
1493 Esta clase permite escribir datos a archivos procesados (.r o ,pdata). La escritura
1492 Esta clase permite escribir datos a archivos procesados (.r o ,pdata). La escritura
1494 de los datos siempre se realiza por bloques.
1493 de los datos siempre se realiza por bloques.
1495 """
1494 """
1496
1495
1497 blockIndex = 0
1496 blockIndex = 0
1498
1497
1499 path = None
1498 path = None
1500
1499
1501 setFile = None
1500 setFile = None
1502
1501
1503 profilesPerBlock = None
1502 profilesPerBlock = None
1504
1503
1505 blocksPerFile = None
1504 blocksPerFile = None
1506
1505
1507 nWriteBlocks = 0
1506 nWriteBlocks = 0
1508
1507
1509 fileDate = None
1508 fileDate = None
1510
1509
1511 def __init__(self, dataOut=None):
1510 def __init__(self, dataOut=None):
1512 raise NotImplementedError
1511 raise NotImplementedError
1513
1512
1514
1513
1515 def hasAllDataInBuffer(self):
1514 def hasAllDataInBuffer(self):
1516 raise NotImplementedError
1515 raise NotImplementedError
1517
1516
1518
1517
1519 def setBlockDimension(self):
1518 def setBlockDimension(self):
1520 raise NotImplementedError
1519 raise NotImplementedError
1521
1520
1522
1521
1523 def writeBlock(self):
1522 def writeBlock(self):
1524 raise NotImplementedError
1523 raise NotImplementedError
1525
1524
1526
1525
1527 def putData(self):
1526 def putData(self):
1528 raise NotImplementedError
1527 raise NotImplementedError
1529
1528
1530
1529
1531 def getProcessFlags(self):
1530 def getProcessFlags(self):
1532
1531
1533 processFlags = 0
1532 processFlags = 0
1534
1533
1535 dtype_index = get_dtype_index(self.dtype)
1534 dtype_index = get_dtype_index(self.dtype)
1536 procflag_dtype = get_procflag_dtype(dtype_index)
1535 procflag_dtype = get_procflag_dtype(dtype_index)
1537
1536
1538 processFlags += procflag_dtype
1537 processFlags += procflag_dtype
1539
1538
1540 if self.dataOut.flagDecodeData:
1539 if self.dataOut.flagDecodeData:
1541 processFlags += PROCFLAG.DECODE_DATA
1540 processFlags += PROCFLAG.DECODE_DATA
1542
1541
1543 if self.dataOut.flagDeflipData:
1542 if self.dataOut.flagDeflipData:
1544 processFlags += PROCFLAG.DEFLIP_DATA
1543 processFlags += PROCFLAG.DEFLIP_DATA
1545
1544
1546 if self.dataOut.code is not None:
1545 if self.dataOut.code is not None:
1547 processFlags += PROCFLAG.DEFINE_PROCESS_CODE
1546 processFlags += PROCFLAG.DEFINE_PROCESS_CODE
1548
1547
1549 if self.dataOut.nCohInt > 1:
1548 if self.dataOut.nCohInt > 1:
1550 processFlags += PROCFLAG.COHERENT_INTEGRATION
1549 processFlags += PROCFLAG.COHERENT_INTEGRATION
1551
1550
1552 if self.dataOut.type == "Spectra":
1551 if self.dataOut.type == "Spectra":
1553 if self.dataOut.nIncohInt > 1:
1552 if self.dataOut.nIncohInt > 1:
1554 processFlags += PROCFLAG.INCOHERENT_INTEGRATION
1553 processFlags += PROCFLAG.INCOHERENT_INTEGRATION
1555
1554
1556 if self.dataOut.data_dc is not None:
1555 if self.dataOut.data_dc is not None:
1557 processFlags += PROCFLAG.SAVE_CHANNELS_DC
1556 processFlags += PROCFLAG.SAVE_CHANNELS_DC
1558
1557
1559 if self.dataOut.flagShiftFFT:
1558 if self.dataOut.flagShiftFFT:
1560 processFlags += PROCFLAG.SHIFT_FFT_DATA
1559 processFlags += PROCFLAG.SHIFT_FFT_DATA
1561
1560
1562 return processFlags
1561 return processFlags
1563
1562
1564 def setBasicHeader(self):
1563 def setBasicHeader(self):
1565
1564
1566 self.basicHeaderObj.size = self.basicHeaderSize #bytes
1565 self.basicHeaderObj.size = self.basicHeaderSize #bytes
1567 self.basicHeaderObj.version = self.versionFile
1566 self.basicHeaderObj.version = self.versionFile
1568 self.basicHeaderObj.dataBlock = self.nTotalBlocks
1567 self.basicHeaderObj.dataBlock = self.nTotalBlocks
1569
1568
1570 utc = numpy.floor(self.dataOut.utctime)
1569 utc = numpy.floor(self.dataOut.utctime)
1571 milisecond = (self.dataOut.utctime - utc)* 1000.0
1570 milisecond = (self.dataOut.utctime - utc)* 1000.0
1572
1571
1573 self.basicHeaderObj.utc = utc
1572 self.basicHeaderObj.utc = utc
1574 self.basicHeaderObj.miliSecond = milisecond
1573 self.basicHeaderObj.miliSecond = milisecond
1575 self.basicHeaderObj.timeZone = self.dataOut.timeZone
1574 self.basicHeaderObj.timeZone = self.dataOut.timeZone
1576 self.basicHeaderObj.dstFlag = self.dataOut.dstFlag
1575 self.basicHeaderObj.dstFlag = self.dataOut.dstFlag
1577 self.basicHeaderObj.errorCount = self.dataOut.errorCount
1576 self.basicHeaderObj.errorCount = self.dataOut.errorCount
1578
1577
1579 def setFirstHeader(self):
1578 def setFirstHeader(self):
1580 """
1579 """
1581 Obtiene una copia del First Header
1580 Obtiene una copia del First Header
1582
1581
1583 Affected:
1582 Affected:
1584
1583
1585 self.basicHeaderObj
1584 self.basicHeaderObj
1586 self.systemHeaderObj
1585 self.systemHeaderObj
1587 self.radarControllerHeaderObj
1586 self.radarControllerHeaderObj
1588 self.processingHeaderObj self.
1587 self.processingHeaderObj self.
1589
1588
1590 Return:
1589 Return:
1591 None
1590 None
1592 """
1591 """
1593
1592
1594 raise NotImplementedError
1593 raise NotImplementedError
1595
1594
1596 def __writeFirstHeader(self):
1595 def __writeFirstHeader(self):
1597 """
1596 """
1598 Escribe el primer header del file es decir el Basic header y el Long header (SystemHeader, RadarControllerHeader, ProcessingHeader)
1597 Escribe el primer header del file es decir el Basic header y el Long header (SystemHeader, RadarControllerHeader, ProcessingHeader)
1599
1598
1600 Affected:
1599 Affected:
1601 __dataType
1600 __dataType
1602
1601
1603 Return:
1602 Return:
1604 None
1603 None
1605 """
1604 """
1606
1605
1607 # CALCULAR PARAMETROS
1606 # CALCULAR PARAMETROS
1608
1607
1609 sizeLongHeader = self.systemHeaderObj.size + self.radarControllerHeaderObj.size + self.processingHeaderObj.size
1608 sizeLongHeader = self.systemHeaderObj.size + self.radarControllerHeaderObj.size + self.processingHeaderObj.size
1610 self.basicHeaderObj.size = self.basicHeaderSize + sizeLongHeader
1609 self.basicHeaderObj.size = self.basicHeaderSize + sizeLongHeader
1611
1610
1612 self.basicHeaderObj.write(self.fp)
1611 self.basicHeaderObj.write(self.fp)
1613 self.systemHeaderObj.write(self.fp)
1612 self.systemHeaderObj.write(self.fp)
1614 self.radarControllerHeaderObj.write(self.fp)
1613 self.radarControllerHeaderObj.write(self.fp)
1615 self.processingHeaderObj.write(self.fp)
1614 self.processingHeaderObj.write(self.fp)
1616
1615
1617 def __setNewBlock(self):
1616 def __setNewBlock(self):
1618 """
1617 """
1619 Si es un nuevo file escribe el First Header caso contrario escribe solo el Basic Header
1618 Si es un nuevo file escribe el First Header caso contrario escribe solo el Basic Header
1620
1619
1621 Return:
1620 Return:
1622 0 : si no pudo escribir nada
1621 0 : si no pudo escribir nada
1623 1 : Si escribio el Basic el First Header
1622 1 : Si escribio el Basic el First Header
1624 """
1623 """
1625 if self.fp == None:
1624 if self.fp == None:
1626 self.setNextFile()
1625 self.setNextFile()
1627
1626
1628 if self.flagIsNewFile:
1627 if self.flagIsNewFile:
1629 return 1
1628 return 1
1630
1629
1631 if self.blockIndex < self.processingHeaderObj.dataBlocksPerFile:
1630 if self.blockIndex < self.processingHeaderObj.dataBlocksPerFile:
1632 self.basicHeaderObj.write(self.fp)
1631 self.basicHeaderObj.write(self.fp)
1633 return 1
1632 return 1
1634
1633
1635 if not( self.setNextFile() ):
1634 if not( self.setNextFile() ):
1636 return 0
1635 return 0
1637
1636
1638 return 1
1637 return 1
1639
1638
1640
1639
1641 def writeNextBlock(self):
1640 def writeNextBlock(self):
1642 """
1641 """
1643 Selecciona el bloque siguiente de datos y los escribe en un file
1642 Selecciona el bloque siguiente de datos y los escribe en un file
1644
1643
1645 Return:
1644 Return:
1646 0 : Si no hizo pudo escribir el bloque de datos
1645 0 : Si no hizo pudo escribir el bloque de datos
1647 1 : Si no pudo escribir el bloque de datos
1646 1 : Si no pudo escribir el bloque de datos
1648 """
1647 """
1649 if not( self.__setNewBlock() ):
1648 if not( self.__setNewBlock() ):
1650 return 0
1649 return 0
1651
1650
1652 self.writeBlock()
1651 self.writeBlock()
1653
1652
1654 print "[Writing] Block No. %d/%d" %(self.blockIndex,
1653 print "[Writing] Block No. %d/%d" %(self.blockIndex,
1655 self.processingHeaderObj.dataBlocksPerFile)
1654 self.processingHeaderObj.dataBlocksPerFile)
1656
1655
1657 return 1
1656 return 1
1658
1657
1659 def setNextFile(self):
1658 def setNextFile(self):
1660 """
1659 """
1661 Determina el siguiente file que sera escrito
1660 Determina el siguiente file que sera escrito
1662
1661
1663 Affected:
1662 Affected:
1664 self.filename
1663 self.filename
1665 self.subfolder
1664 self.subfolder
1666 self.fp
1665 self.fp
1667 self.setFile
1666 self.setFile
1668 self.flagIsNewFile
1667 self.flagIsNewFile
1669
1668
1670 Return:
1669 Return:
1671 0 : Si el archivo no puede ser escrito
1670 0 : Si el archivo no puede ser escrito
1672 1 : Si el archivo esta listo para ser escrito
1671 1 : Si el archivo esta listo para ser escrito
1673 """
1672 """
1674 ext = self.ext
1673 ext = self.ext
1675 path = self.path
1674 path = self.path
1676
1675
1677 if self.fp != None:
1676 if self.fp != None:
1678 self.fp.close()
1677 self.fp.close()
1679
1678
1680 timeTuple = time.localtime( self.dataOut.utctime)
1679 timeTuple = time.localtime( self.dataOut.utctime)
1681 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
1680 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
1682
1681
1683 fullpath = os.path.join( path, subfolder )
1682 fullpath = os.path.join( path, subfolder )
1684 setFile = self.setFile
1683 setFile = self.setFile
1685
1684
1686 if not( os.path.exists(fullpath) ):
1685 if not( os.path.exists(fullpath) ):
1687 os.mkdir(fullpath)
1686 os.mkdir(fullpath)
1688 setFile = -1 #inicializo mi contador de seteo
1687 setFile = -1 #inicializo mi contador de seteo
1689 else:
1688 else:
1690 filesList = os.listdir( fullpath )
1689 filesList = os.listdir( fullpath )
1691 if len( filesList ) > 0:
1690 if len( filesList ) > 0:
1692 filesList = sorted( filesList, key=str.lower )
1691 filesList = sorted( filesList, key=str.lower )
1693 filen = filesList[-1]
1692 filen = filesList[-1]
1694 # el filename debera tener el siguiente formato
1693 # el filename debera tener el siguiente formato
1695 # 0 1234 567 89A BCDE (hex)
1694 # 0 1234 567 89A BCDE (hex)
1696 # x YYYY DDD SSS .ext
1695 # x YYYY DDD SSS .ext
1697 if isNumber( filen[8:11] ):
1696 if isNumber( filen[8:11] ):
1698 setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file
1697 setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file
1699 else:
1698 else:
1700 setFile = -1
1699 setFile = -1
1701 else:
1700 else:
1702 setFile = -1 #inicializo mi contador de seteo
1701 setFile = -1 #inicializo mi contador de seteo
1703
1702
1704 setFile += 1
1703 setFile += 1
1705
1704
1706 #If this is a new day it resets some values
1705 #If this is a new day it resets some values
1707 if self.dataOut.datatime.date() > self.fileDate:
1706 if self.dataOut.datatime.date() > self.fileDate:
1708 setFile = 0
1707 setFile = 0
1709 self.nTotalBlocks = 0
1708 self.nTotalBlocks = 0
1710
1709
1711 filen = '%s%4.4d%3.3d%3.3d%s' % (self.optchar, timeTuple.tm_year, timeTuple.tm_yday, setFile, ext )
1710 filen = '%s%4.4d%3.3d%3.3d%s' % (self.optchar, timeTuple.tm_year, timeTuple.tm_yday, setFile, ext )
1712
1711
1713 filename = os.path.join( path, subfolder, filen )
1712 filename = os.path.join( path, subfolder, filen )
1714
1713
1715 fp = open( filename,'wb' )
1714 fp = open( filename,'wb' )
1716
1715
1717 self.blockIndex = 0
1716 self.blockIndex = 0
1718
1717
1719 #guardando atributos
1718 #guardando atributos
1720 self.filename = filename
1719 self.filename = filename
1721 self.subfolder = subfolder
1720 self.subfolder = subfolder
1722 self.fp = fp
1721 self.fp = fp
1723 self.setFile = setFile
1722 self.setFile = setFile
1724 self.flagIsNewFile = 1
1723 self.flagIsNewFile = 1
1725 self.fileDate = self.dataOut.datatime.date()
1724 self.fileDate = self.dataOut.datatime.date()
1726
1725
1727 self.setFirstHeader()
1726 self.setFirstHeader()
1728
1727
1729 print '[Writing] Opening file: %s'%self.filename
1728 print '[Writing] Opening file: %s'%self.filename
1730
1729
1731 self.__writeFirstHeader()
1730 self.__writeFirstHeader()
1732
1731
1733 return 1
1732 return 1
1734
1733
1735 def setup(self, dataOut, path, blocksPerFile, profilesPerBlock=64, set=None, ext=None, datatype=4):
1734 def setup(self, dataOut, path, blocksPerFile, profilesPerBlock=64, set=None, ext=None, datatype=4):
1736 """
1735 """
1737 Setea el tipo de formato en la cual sera guardada la data y escribe el First Header
1736 Setea el tipo de formato en la cual sera guardada la data y escribe el First Header
1738
1737
1739 Inputs:
1738 Inputs:
1740 path : directory where data will be saved
1739 path : directory where data will be saved
1741 profilesPerBlock : number of profiles per block
1740 profilesPerBlock : number of profiles per block
1742 set : initial file set
1741 set : initial file set
1743 datatype : An integer number that defines data type:
1742 datatype : An integer number that defines data type:
1744 0 : int8 (1 byte)
1743 0 : int8 (1 byte)
1745 1 : int16 (2 bytes)
1744 1 : int16 (2 bytes)
1746 2 : int32 (4 bytes)
1745 2 : int32 (4 bytes)
1747 3 : int64 (8 bytes)
1746 3 : int64 (8 bytes)
1748 4 : float32 (4 bytes)
1747 4 : float32 (4 bytes)
1749 5 : double64 (8 bytes)
1748 5 : double64 (8 bytes)
1750
1749
1751 Return:
1750 Return:
1752 0 : Si no realizo un buen seteo
1751 0 : Si no realizo un buen seteo
1753 1 : Si realizo un buen seteo
1752 1 : Si realizo un buen seteo
1754 """
1753 """
1755
1754
1756 if ext == None:
1755 if ext == None:
1757 ext = self.ext
1756 ext = self.ext
1758
1757
1759 self.ext = ext.lower()
1758 self.ext = ext.lower()
1760
1759
1761 self.path = path
1760 self.path = path
1762
1761
1763 if set is None:
1762 if set is None:
1764 self.setFile = -1
1763 self.setFile = -1
1765 else:
1764 else:
1766 self.setFile = set - 1
1765 self.setFile = set - 1
1767
1766
1768 self.blocksPerFile = blocksPerFile
1767 self.blocksPerFile = blocksPerFile
1769
1768
1770 self.profilesPerBlock = profilesPerBlock
1769 self.profilesPerBlock = profilesPerBlock
1771
1770
1772 self.dataOut = dataOut
1771 self.dataOut = dataOut
1773 self.fileDate = self.dataOut.datatime.date()
1772 self.fileDate = self.dataOut.datatime.date()
1774 #By default
1773 #By default
1775 self.dtype = self.dataOut.dtype
1774 self.dtype = self.dataOut.dtype
1776
1775
1777 if datatype is not None:
1776 if datatype is not None:
1778 self.dtype = get_numpy_dtype(datatype)
1777 self.dtype = get_numpy_dtype(datatype)
1779
1778
1780 if not(self.setNextFile()):
1779 if not(self.setNextFile()):
1781 print "[Writing] There isn't a next file"
1780 print "[Writing] There isn't a next file"
1782 return 0
1781 return 0
1783
1782
1784 self.setBlockDimension()
1783 self.setBlockDimension()
1785
1784
1786 return 1
1785 return 1
1787
1786
1788 def run(self, dataOut, path, blocksPerFile, profilesPerBlock=64, set=None, ext=None, datatype=4, **kwargs):
1787 def run(self, dataOut, path, blocksPerFile, profilesPerBlock=64, set=None, ext=None, datatype=4, **kwargs):
1789
1788
1790 if not(self.isConfig):
1789 if not(self.isConfig):
1791
1790
1792 self.setup(dataOut, path, blocksPerFile, profilesPerBlock=profilesPerBlock, set=set, ext=ext, datatype=datatype, **kwargs)
1791 self.setup(dataOut, path, blocksPerFile, profilesPerBlock=profilesPerBlock, set=set, ext=ext, datatype=datatype, **kwargs)
1793 self.isConfig = True
1792 self.isConfig = True
1794
1793
1795 self.putData()
1794 self.putData()
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,1193 +1,1154
1 import os, sys
1 import os, sys
2 import glob
2 import glob
3 import fnmatch
3 import fnmatch
4 import datetime
4 import datetime
5 import time
5 import time
6 import re
6 import re
7 import h5py
7 import h5py
8 import numpy
8 import numpy
9 import matplotlib.pyplot as plt
9 import matplotlib.pyplot as plt
10
10
11 import pylab as plb
11 import pylab as plb
12 from scipy.optimize import curve_fit
12 from scipy.optimize import curve_fit
13 from scipy import asarray as ar,exp
13 from scipy import asarray as ar, exp
14 from scipy import stats
14 from scipy import stats
15
15
16 from duplicity.path import Path
17 from numpy.ma.core import getdata
16 from numpy.ma.core import getdata
18
17
19 SPEED_OF_LIGHT = 299792458
18 SPEED_OF_LIGHT = 299792458
20 SPEED_OF_LIGHT = 3e8
19 SPEED_OF_LIGHT = 3e8
21
20
22 try:
21 try:
23 from gevent import sleep
22 from gevent import sleep
24 except:
23 except:
25 from time import sleep
24 from time import sleep
26
25
27 from schainpy.model.data.jrodata import Spectra
26 from schainpy.model.data.jrodata import Spectra
28 #from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader
27 #from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader
29 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
28 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
30 #from schainpy.model.io.jroIO_bltr import BLTRReader
29 #from schainpy.model.io.jroIO_bltr import BLTRReader
31 from numpy import imag, shape, NaN
30 from numpy import imag, shape, NaN
32
31
33 from jroIO_base import JRODataReader
32 from jroIO_base import JRODataReader
34
33
35
34
36 class Header(object):
35 class Header(object):
37
36
38 def __init__(self):
37 def __init__(self):
39 raise NotImplementedError
38 raise NotImplementedError
40
39
41
40
42 def read(self):
41 def read(self):
43
42
44 raise NotImplementedError
43 raise NotImplementedError
45
44
46 def write(self):
45 def write(self):
47
46
48 raise NotImplementedError
47 raise NotImplementedError
49
48
50 def printInfo(self):
49 def printInfo(self):
51
50
52 message = "#"*50 + "\n"
51 message = "#"*50 + "\n"
53 message += self.__class__.__name__.upper() + "\n"
52 message += self.__class__.__name__.upper() + "\n"
54 message += "#"*50 + "\n"
53 message += "#"*50 + "\n"
55
54
56 keyList = self.__dict__.keys()
55 keyList = self.__dict__.keys()
57 keyList.sort()
56 keyList.sort()
58
57
59 for key in keyList:
58 for key in keyList:
60 message += "%s = %s" %(key, self.__dict__[key]) + "\n"
59 message += "%s = %s" %(key, self.__dict__[key]) + "\n"
61
60
62 if "size" not in keyList:
61 if "size" not in keyList:
63 attr = getattr(self, "size")
62 attr = getattr(self, "size")
64
63
65 if attr:
64 if attr:
66 message += "%s = %s" %("size", attr) + "\n"
65 message += "%s = %s" %("size", attr) + "\n"
67
66
68 #print message
67 #print message
69
68
70
69
71
70
72
71
73
72
74 FILE_STRUCTURE = numpy.dtype([ #HEADER 48bytes
73 FILE_STRUCTURE = numpy.dtype([ #HEADER 48bytes
75 ('FileMgcNumber','<u4'), #0x23020100
74 ('FileMgcNumber','<u4'), #0x23020100
76 ('nFDTdataRecors','<u4'), #No Of FDT data records in this file (0 or more)
75 ('nFDTdataRecors','<u4'), #No Of FDT data records in this file (0 or more)
77 ('OffsetStartHeader','<u4'),
76 ('OffsetStartHeader','<u4'),
78 ('RadarUnitId','<u4'),
77 ('RadarUnitId','<u4'),
79 ('SiteName',numpy.str_,32), #Null terminated
78 ('SiteName',numpy.str_,32), #Null terminated
80 ])
79 ])
81
80
82 class FileHeaderBLTR(Header):
81 class FileHeaderBLTR(Header):
83
82
84 def __init__(self):
83 def __init__(self):
85
84
86 self.FileMgcNumber= 0 #0x23020100
85 self.FileMgcNumber= 0 #0x23020100
87 self.nFDTdataRecors=0 #No Of FDT data records in this file (0 or more)
86 self.nFDTdataRecors=0 #No Of FDT data records in this file (0 or more)
88 self.RadarUnitId= 0
87 self.RadarUnitId= 0
89 self.OffsetStartHeader=0
88 self.OffsetStartHeader=0
90 self.SiteName= ""
89 self.SiteName= ""
91 self.size = 48
90 self.size = 48
92
91
93 def FHread(self, fp):
92 def FHread(self, fp):
94 #try:
93 #try:
95 startFp = open(fp,"rb")
94 startFp = open(fp,"rb")
96
95
97 header = numpy.fromfile(startFp, FILE_STRUCTURE,1)
96 header = numpy.fromfile(startFp, FILE_STRUCTURE,1)
98
97
99 print ' '
98 print ' '
100 print 'puntero file header', startFp.tell()
99 print 'puntero file header', startFp.tell()
101 print ' '
100 print ' '
102
101
103
102
104 ''' numpy.fromfile(file, dtype, count, sep='')
103 ''' numpy.fromfile(file, dtype, count, sep='')
105 file : file or str
104 file : file or str
106 Open file object or filename.
105 Open file object or filename.
107
106
108 dtype : data-type
107 dtype : data-type
109 Data type of the returned array. For binary files, it is used to determine
108 Data type of the returned array. For binary files, it is used to determine
110 the size and byte-order of the items in the file.
109 the size and byte-order of the items in the file.
111
110
112 count : int
111 count : int
113 Number of items to read. -1 means all items (i.e., the complete file).
112 Number of items to read. -1 means all items (i.e., the complete file).
114
113
115 sep : str
114 sep : str
116 Separator between items if file is a text file. Empty ("") separator means
115 Separator between items if file is a text file. Empty ("") separator means
117 the file should be treated as binary. Spaces (" ") in the separator match zero
116 the file should be treated as binary. Spaces (" ") in the separator match zero
118 or more whitespace characters. A separator consisting only of spaces must match
117 or more whitespace characters. A separator consisting only of spaces must match
119 at least one whitespace.
118 at least one whitespace.
120
119
121 '''
120 '''
122
121
123
122
124
123
125 self.FileMgcNumber= hex(header['FileMgcNumber'][0])
124 self.FileMgcNumber= hex(header['FileMgcNumber'][0])
126 self.nFDTdataRecors=int(header['nFDTdataRecors'][0]) #No Of FDT data records in this file (0 or more)
125 self.nFDTdataRecors=int(header['nFDTdataRecors'][0]) #No Of FDT data records in this file (0 or more)
127 self.RadarUnitId= int(header['RadarUnitId'][0])
126 self.RadarUnitId= int(header['RadarUnitId'][0])
128 self.OffsetStartHeader= int(header['OffsetStartHeader'][0])
127 self.OffsetStartHeader= int(header['OffsetStartHeader'][0])
129 self.SiteName= str(header['SiteName'][0])
128 self.SiteName= str(header['SiteName'][0])
130
129
131 #print 'Numero de bloques', self.nFDTdataRecors
130 #print 'Numero de bloques', self.nFDTdataRecors
132
131
133
132
134 if self.size <48:
133 if self.size <48:
135 return 0
134 return 0
136
135
137 return 1
136 return 1
138
137
139
138
140 def write(self, fp):
139 def write(self, fp):
141
140
142 headerTuple = (self.FileMgcNumber,
141 headerTuple = (self.FileMgcNumber,
143 self.nFDTdataRecors,
142 self.nFDTdataRecors,
144 self.RadarUnitId,
143 self.RadarUnitId,
145 self.SiteName,
144 self.SiteName,
146 self.size)
145 self.size)
147
146
148
147
149 header = numpy.array(headerTuple, FILE_STRUCTURE)
148 header = numpy.array(headerTuple, FILE_STRUCTURE)
150 # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)
149 # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)
151 header.tofile(fp)
150 header.tofile(fp)
152 ''' ndarray.tofile(fid, sep, format) Write array to a file as text or binary (default).
151 ''' ndarray.tofile(fid, sep, format) Write array to a file as text or binary (default).
153
152
154 fid : file or str
153 fid : file or str
155 An open file object, or a string containing a filename.
154 An open file object, or a string containing a filename.
156
155
157 sep : str
156 sep : str
158 Separator between array items for text output. If "" (empty), a binary file is written,
157 Separator between array items for text output. If "" (empty), a binary file is written,
159 equivalent to file.write(a.tobytes()).
158 equivalent to file.write(a.tobytes()).
160
159
161 format : str
160 format : str
162 Format string for text file output. Each entry in the array is formatted to text by
161 Format string for text file output. Each entry in the array is formatted to text by
163 first converting it to the closest Python type, and then using "format" % item.
162 first converting it to the closest Python type, and then using "format" % item.
164
163
165 '''
164 '''
166
165
167 return 1
166 return 1
168
167
169
168
170
169
171
170
172
171
173 RECORD_STRUCTURE = numpy.dtype([ #RECORD HEADER 180+20N bytes
172 RECORD_STRUCTURE = numpy.dtype([ #RECORD HEADER 180+20N bytes
174 ('RecMgcNumber','<u4'), #0x23030001
173 ('RecMgcNumber','<u4'), #0x23030001
175 ('RecCounter','<u4'), #Record counter(0,1, ...)
174 ('RecCounter','<u4'), #Record counter(0,1, ...)
176 ('Off2StartNxtRec','<u4'), #Offset to start of next record form start of this record
175 ('Off2StartNxtRec','<u4'), #Offset to start of next record form start of this record
177 ('Off2StartData','<u4'), #Offset to start of data from start of this record
176 ('Off2StartData','<u4'), #Offset to start of data from start of this record
178 ('nUtime','<i4'), #Epoch time stamp of start of acquisition (seconds)
177 ('nUtime','<i4'), #Epoch time stamp of start of acquisition (seconds)
179 ('nMilisec','<u4'), #Millisecond component of time stamp (0,...,999)
178 ('nMilisec','<u4'), #Millisecond component of time stamp (0,...,999)
180 ('ExpTagName',numpy.str_,32), #Experiment tag name (null terminated)
179 ('ExpTagName',numpy.str_,32), #Experiment tag name (null terminated)
181 ('ExpComment',numpy.str_,32), #Experiment comment (null terminated)
180 ('ExpComment',numpy.str_,32), #Experiment comment (null terminated)
182 ('SiteLatDegrees','<f4'), #Site latitude (from GPS) in degrees (positive implies North)
181 ('SiteLatDegrees','<f4'), #Site latitude (from GPS) in degrees (positive implies North)
183 ('SiteLongDegrees','<f4'), #Site longitude (from GPS) in degrees (positive implies East)
182 ('SiteLongDegrees','<f4'), #Site longitude (from GPS) in degrees (positive implies East)
184 ('RTCgpsStatus','<u4'), #RTC GPS engine status (0=SEEK, 1=LOCK, 2=NOT FITTED, 3=UNAVAILABLE)
183 ('RTCgpsStatus','<u4'), #RTC GPS engine status (0=SEEK, 1=LOCK, 2=NOT FITTED, 3=UNAVAILABLE)
185 ('TransmitFrec','<u4'), #Transmit frequency (Hz)
184 ('TransmitFrec','<u4'), #Transmit frequency (Hz)
186 ('ReceiveFrec','<u4'), #Receive frequency
185 ('ReceiveFrec','<u4'), #Receive frequency
187 ('FirstOsciFrec','<u4'), #First local oscillator frequency (Hz)
186 ('FirstOsciFrec','<u4'), #First local oscillator frequency (Hz)
188 ('Polarisation','<u4'), #(0="O", 1="E", 2="linear 1", 3="linear2")
187 ('Polarisation','<u4'), #(0="O", 1="E", 2="linear 1", 3="linear2")
189 ('ReceiverFiltSett','<u4'), #Receiver filter settings (0,1,2,3)
188 ('ReceiverFiltSett','<u4'), #Receiver filter settings (0,1,2,3)
190 ('nModesInUse','<u4'), #Number of modes in use (1 or 2)
189 ('nModesInUse','<u4'), #Number of modes in use (1 or 2)
191 ('DualModeIndex','<u4'), #Dual Mode index number for these data (0 or 1)
190 ('DualModeIndex','<u4'), #Dual Mode index number for these data (0 or 1)
192 ('DualModeRange','<u4'), #Dual Mode range correction for these data (m)
191 ('DualModeRange','<u4'), #Dual Mode range correction for these data (m)
193 ('nDigChannels','<u4'), #Number of digital channels acquired (2*N)
192 ('nDigChannels','<u4'), #Number of digital channels acquired (2*N)
194 ('SampResolution','<u4'), #Sampling resolution (meters)
193 ('SampResolution','<u4'), #Sampling resolution (meters)
195 ('nHeights','<u4'), #Number of range gates sampled
194 ('nHeights','<u4'), #Number of range gates sampled
196 ('StartRangeSamp','<u4'), #Start range of sampling (meters)
195 ('StartRangeSamp','<u4'), #Start range of sampling (meters)
197 ('PRFhz','<u4'), #PRF (Hz)
196 ('PRFhz','<u4'), #PRF (Hz)
198 ('nCohInt','<u4'), #Integrations
197 ('nCohInt','<u4'), #Integrations
199 ('nProfiles','<u4'), #Number of data points transformed
198 ('nProfiles','<u4'), #Number of data points transformed
200 ('nChannels','<u4'), #Number of receive beams stored in file (1 or N)
199 ('nChannels','<u4'), #Number of receive beams stored in file (1 or N)
201 ('nIncohInt','<u4'), #Number of spectral averages
200 ('nIncohInt','<u4'), #Number of spectral averages
202 ('FFTwindowingInd','<u4'), #FFT windowing index (0 = no window)
201 ('FFTwindowingInd','<u4'), #FFT windowing index (0 = no window)
203 ('BeamAngleAzim','<f4'), #Beam steer angle (azimuth) in degrees (clockwise from true North)
202 ('BeamAngleAzim','<f4'), #Beam steer angle (azimuth) in degrees (clockwise from true North)
204 ('BeamAngleZen','<f4'), #Beam steer angle (zenith) in degrees (0=> vertical)
203 ('BeamAngleZen','<f4'), #Beam steer angle (zenith) in degrees (0=> vertical)
205 ('AntennaCoord0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
204 ('AntennaCoord0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
206 ('AntennaAngl0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
205 ('AntennaAngl0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
207 ('AntennaCoord1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
206 ('AntennaCoord1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
208 ('AntennaAngl1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
207 ('AntennaAngl1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
209 ('AntennaCoord2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
208 ('AntennaCoord2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
210 ('AntennaAngl2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
209 ('AntennaAngl2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
211 ('RecPhaseCalibr0','<f4'), #Receiver phase calibration (degrees) - N values
210 ('RecPhaseCalibr0','<f4'), #Receiver phase calibration (degrees) - N values
212 ('RecPhaseCalibr1','<f4'), #Receiver phase calibration (degrees) - N values
211 ('RecPhaseCalibr1','<f4'), #Receiver phase calibration (degrees) - N values
213 ('RecPhaseCalibr2','<f4'), #Receiver phase calibration (degrees) - N values
212 ('RecPhaseCalibr2','<f4'), #Receiver phase calibration (degrees) - N values
214 ('RecAmpCalibr0','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
213 ('RecAmpCalibr0','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
215 ('RecAmpCalibr1','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
214 ('RecAmpCalibr1','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
216 ('RecAmpCalibr2','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
215 ('RecAmpCalibr2','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
217 ('ReceiverGaindB0','<i4'), #Receiver gains in dB - N values
216 ('ReceiverGaindB0','<i4'), #Receiver gains in dB - N values
218 ('ReceiverGaindB1','<i4'), #Receiver gains in dB - N values
217 ('ReceiverGaindB1','<i4'), #Receiver gains in dB - N values
219 ('ReceiverGaindB2','<i4'), #Receiver gains in dB - N values
218 ('ReceiverGaindB2','<i4'), #Receiver gains in dB - N values
220 ])
219 ])
221
220
222
221
223 class RecordHeaderBLTR(Header):
222 class RecordHeaderBLTR(Header):
224
223
225 def __init__(self, RecMgcNumber=None, RecCounter= 0, Off2StartNxtRec= 811248,
224 def __init__(self, RecMgcNumber=None, RecCounter= 0, Off2StartNxtRec= 811248,
226 nUtime= 0, nMilisec= 0, ExpTagName= None,
225 nUtime= 0, nMilisec= 0, ExpTagName= None,
227 ExpComment=None, SiteLatDegrees=0, SiteLongDegrees= 0,
226 ExpComment=None, SiteLatDegrees=0, SiteLongDegrees= 0,
228 RTCgpsStatus= 0, TransmitFrec= 0, ReceiveFrec= 0,
227 RTCgpsStatus= 0, TransmitFrec= 0, ReceiveFrec= 0,
229 FirstOsciFrec= 0, Polarisation= 0, ReceiverFiltSett= 0,
228 FirstOsciFrec= 0, Polarisation= 0, ReceiverFiltSett= 0,
230 nModesInUse= 0, DualModeIndex= 0, DualModeRange= 0,
229 nModesInUse= 0, DualModeIndex= 0, DualModeRange= 0,
231 nDigChannels= 0, SampResolution= 0, nHeights= 0,
230 nDigChannels= 0, SampResolution= 0, nHeights= 0,
232 StartRangeSamp= 0, PRFhz= 0, nCohInt= 0,
231 StartRangeSamp= 0, PRFhz= 0, nCohInt= 0,
233 nProfiles= 0, nChannels= 0, nIncohInt= 0,
232 nProfiles= 0, nChannels= 0, nIncohInt= 0,
234 FFTwindowingInd= 0, BeamAngleAzim= 0, BeamAngleZen= 0,
233 FFTwindowingInd= 0, BeamAngleAzim= 0, BeamAngleZen= 0,
235 AntennaCoord0= 0, AntennaCoord1= 0, AntennaCoord2= 0,
234 AntennaCoord0= 0, AntennaCoord1= 0, AntennaCoord2= 0,
236 RecPhaseCalibr0= 0, RecPhaseCalibr1= 0, RecPhaseCalibr2= 0,
235 RecPhaseCalibr0= 0, RecPhaseCalibr1= 0, RecPhaseCalibr2= 0,
237 RecAmpCalibr0= 0, RecAmpCalibr1= 0, RecAmpCalibr2= 0,
236 RecAmpCalibr0= 0, RecAmpCalibr1= 0, RecAmpCalibr2= 0,
238 AntennaAngl0=0, AntennaAngl1=0, AntennaAngl2=0,
237 AntennaAngl0=0, AntennaAngl1=0, AntennaAngl2=0,
239 ReceiverGaindB0= 0, ReceiverGaindB1= 0, ReceiverGaindB2= 0, Off2StartData=0, OffsetStartHeader=0):
238 ReceiverGaindB0= 0, ReceiverGaindB1= 0, ReceiverGaindB2= 0, Off2StartData=0, OffsetStartHeader=0):
240
239
241 self.RecMgcNumber = RecMgcNumber #0x23030001
240 self.RecMgcNumber = RecMgcNumber #0x23030001
242 self.RecCounter = RecCounter
241 self.RecCounter = RecCounter
243 self.Off2StartNxtRec = Off2StartNxtRec
242 self.Off2StartNxtRec = Off2StartNxtRec
244 self.Off2StartData = Off2StartData
243 self.Off2StartData = Off2StartData
245 self.nUtime = nUtime
244 self.nUtime = nUtime
246 self.nMilisec = nMilisec
245 self.nMilisec = nMilisec
247 self.ExpTagName = ExpTagName
246 self.ExpTagName = ExpTagName
248 self.ExpComment = ExpComment
247 self.ExpComment = ExpComment
249 self.SiteLatDegrees = SiteLatDegrees
248 self.SiteLatDegrees = SiteLatDegrees
250 self.SiteLongDegrees = SiteLongDegrees
249 self.SiteLongDegrees = SiteLongDegrees
251 self.RTCgpsStatus = RTCgpsStatus
250 self.RTCgpsStatus = RTCgpsStatus
252 self.TransmitFrec = TransmitFrec
251 self.TransmitFrec = TransmitFrec
253 self.ReceiveFrec = ReceiveFrec
252 self.ReceiveFrec = ReceiveFrec
254 self.FirstOsciFrec = FirstOsciFrec
253 self.FirstOsciFrec = FirstOsciFrec
255 self.Polarisation = Polarisation
254 self.Polarisation = Polarisation
256 self.ReceiverFiltSett = ReceiverFiltSett
255 self.ReceiverFiltSett = ReceiverFiltSett
257 self.nModesInUse = nModesInUse
256 self.nModesInUse = nModesInUse
258 self.DualModeIndex = DualModeIndex
257 self.DualModeIndex = DualModeIndex
259 self.DualModeRange = DualModeRange
258 self.DualModeRange = DualModeRange
260 self.nDigChannels = nDigChannels
259 self.nDigChannels = nDigChannels
261 self.SampResolution = SampResolution
260 self.SampResolution = SampResolution
262 self.nHeights = nHeights
261 self.nHeights = nHeights
263 self.StartRangeSamp = StartRangeSamp
262 self.StartRangeSamp = StartRangeSamp
264 self.PRFhz = PRFhz
263 self.PRFhz = PRFhz
265 self.nCohInt = nCohInt
264 self.nCohInt = nCohInt
266 self.nProfiles = nProfiles
265 self.nProfiles = nProfiles
267 self.nChannels = nChannels
266 self.nChannels = nChannels
268 self.nIncohInt = nIncohInt
267 self.nIncohInt = nIncohInt
269 self.FFTwindowingInd = FFTwindowingInd
268 self.FFTwindowingInd = FFTwindowingInd
270 self.BeamAngleAzim = BeamAngleAzim
269 self.BeamAngleAzim = BeamAngleAzim
271 self.BeamAngleZen = BeamAngleZen
270 self.BeamAngleZen = BeamAngleZen
272 self.AntennaCoord0 = AntennaCoord0
271 self.AntennaCoord0 = AntennaCoord0
273 self.AntennaAngl0 = AntennaAngl0
272 self.AntennaAngl0 = AntennaAngl0
274 self.AntennaAngl1 = AntennaAngl1
273 self.AntennaAngl1 = AntennaAngl1
275 self.AntennaAngl2 = AntennaAngl2
274 self.AntennaAngl2 = AntennaAngl2
276 self.AntennaCoord1 = AntennaCoord1
275 self.AntennaCoord1 = AntennaCoord1
277 self.AntennaCoord2 = AntennaCoord2
276 self.AntennaCoord2 = AntennaCoord2
278 self.RecPhaseCalibr0 = RecPhaseCalibr0
277 self.RecPhaseCalibr0 = RecPhaseCalibr0
279 self.RecPhaseCalibr1 = RecPhaseCalibr1
278 self.RecPhaseCalibr1 = RecPhaseCalibr1
280 self.RecPhaseCalibr2 = RecPhaseCalibr2
279 self.RecPhaseCalibr2 = RecPhaseCalibr2
281 self.RecAmpCalibr0 = RecAmpCalibr0
280 self.RecAmpCalibr0 = RecAmpCalibr0
282 self.RecAmpCalibr1 = RecAmpCalibr1
281 self.RecAmpCalibr1 = RecAmpCalibr1
283 self.RecAmpCalibr2 = RecAmpCalibr2
282 self.RecAmpCalibr2 = RecAmpCalibr2
284 self.ReceiverGaindB0 = ReceiverGaindB0
283 self.ReceiverGaindB0 = ReceiverGaindB0
285 self.ReceiverGaindB1 = ReceiverGaindB1
284 self.ReceiverGaindB1 = ReceiverGaindB1
286 self.ReceiverGaindB2 = ReceiverGaindB2
285 self.ReceiverGaindB2 = ReceiverGaindB2
287 self.OffsetStartHeader = 48
286 self.OffsetStartHeader = 48
288
287
289
288
290
289
291 def RHread(self, fp):
290 def RHread(self, fp):
292 #print fp
291 #print fp
293 #startFp = open('/home/erick/Documents/Data/huancayo.20161019.22.fdt',"rb") #The method tell() returns the current position of the file read/write pointer within the file.
292 #startFp = open('/home/erick/Documents/Data/huancayo.20161019.22.fdt',"rb") #The method tell() returns the current position of the file read/write pointer within the file.
294 startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file.
293 startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file.
295 #RecCounter=0
294 #RecCounter=0
296 #Off2StartNxtRec=811248
295 #Off2StartNxtRec=811248
297 OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
296 OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
298 print ' '
297 print ' '
299 print 'puntero Record Header', startFp.tell()
298 print 'puntero Record Header', startFp.tell()
300 print ' '
299 print ' '
301
300
302
301
303 startFp.seek(OffRHeader, os.SEEK_SET)
302 startFp.seek(OffRHeader, os.SEEK_SET)
304
303
305 print ' '
304 print ' '
306 print 'puntero Record Header con seek', startFp.tell()
305 print 'puntero Record Header con seek', startFp.tell()
307 print ' '
306 print ' '
308
307
309 #print 'Posicion del bloque: ',OffRHeader
308 #print 'Posicion del bloque: ',OffRHeader
310
309
311 header = numpy.fromfile(startFp,RECORD_STRUCTURE,1)
310 header = numpy.fromfile(startFp,RECORD_STRUCTURE,1)
312
311
313 print ' '
312 print ' '
314 print 'puntero Record Header con seek', startFp.tell()
313 print 'puntero Record Header con seek', startFp.tell()
315 print ' '
314 print ' '
316
315
317 print ' '
316 print ' '
318 #
317 #
319 #print 'puntero Record Header despues de seek', header.tell()
318 #print 'puntero Record Header despues de seek', header.tell()
320 print ' '
319 print ' '
321
320
322 self.RecMgcNumber = hex(header['RecMgcNumber'][0]) #0x23030001
321 self.RecMgcNumber = hex(header['RecMgcNumber'][0]) #0x23030001
323 self.RecCounter = int(header['RecCounter'][0])
322 self.RecCounter = int(header['RecCounter'][0])
324 self.Off2StartNxtRec = int(header['Off2StartNxtRec'][0])
323 self.Off2StartNxtRec = int(header['Off2StartNxtRec'][0])
325 self.Off2StartData = int(header['Off2StartData'][0])
324 self.Off2StartData = int(header['Off2StartData'][0])
326 self.nUtime = header['nUtime'][0]
325 self.nUtime = header['nUtime'][0]
327 self.nMilisec = header['nMilisec'][0]
326 self.nMilisec = header['nMilisec'][0]
328 self.ExpTagName = str(header['ExpTagName'][0])
327 self.ExpTagName = str(header['ExpTagName'][0])
329 self.ExpComment = str(header['ExpComment'][0])
328 self.ExpComment = str(header['ExpComment'][0])
330 self.SiteLatDegrees = header['SiteLatDegrees'][0]
329 self.SiteLatDegrees = header['SiteLatDegrees'][0]
331 self.SiteLongDegrees = header['SiteLongDegrees'][0]
330 self.SiteLongDegrees = header['SiteLongDegrees'][0]
332 self.RTCgpsStatus = header['RTCgpsStatus'][0]
331 self.RTCgpsStatus = header['RTCgpsStatus'][0]
333 self.TransmitFrec = header['TransmitFrec'][0]
332 self.TransmitFrec = header['TransmitFrec'][0]
334 self.ReceiveFrec = header['ReceiveFrec'][0]
333 self.ReceiveFrec = header['ReceiveFrec'][0]
335 self.FirstOsciFrec = header['FirstOsciFrec'][0]
334 self.FirstOsciFrec = header['FirstOsciFrec'][0]
336 self.Polarisation = header['Polarisation'][0]
335 self.Polarisation = header['Polarisation'][0]
337 self.ReceiverFiltSett = header['ReceiverFiltSett'][0]
336 self.ReceiverFiltSett = header['ReceiverFiltSett'][0]
338 self.nModesInUse = header['nModesInUse'][0]
337 self.nModesInUse = header['nModesInUse'][0]
339 self.DualModeIndex = header['DualModeIndex'][0]
338 self.DualModeIndex = header['DualModeIndex'][0]
340 self.DualModeRange = header['DualModeRange'][0]
339 self.DualModeRange = header['DualModeRange'][0]
341 self.nDigChannels = header['nDigChannels'][0]
340 self.nDigChannels = header['nDigChannels'][0]
342 self.SampResolution = header['SampResolution'][0]
341 self.SampResolution = header['SampResolution'][0]
343 self.nHeights = header['nHeights'][0]
342 self.nHeights = header['nHeights'][0]
344 self.StartRangeSamp = header['StartRangeSamp'][0]
343 self.StartRangeSamp = header['StartRangeSamp'][0]
345 self.PRFhz = header['PRFhz'][0]
344 self.PRFhz = header['PRFhz'][0]
346 self.nCohInt = header['nCohInt'][0]
345 self.nCohInt = header['nCohInt'][0]
347 self.nProfiles = header['nProfiles'][0]
346 self.nProfiles = header['nProfiles'][0]
348 self.nChannels = header['nChannels'][0]
347 self.nChannels = header['nChannels'][0]
349 self.nIncohInt = header['nIncohInt'][0]
348 self.nIncohInt = header['nIncohInt'][0]
350 self.FFTwindowingInd = header['FFTwindowingInd'][0]
349 self.FFTwindowingInd = header['FFTwindowingInd'][0]
351 self.BeamAngleAzim = header['BeamAngleAzim'][0]
350 self.BeamAngleAzim = header['BeamAngleAzim'][0]
352 self.BeamAngleZen = header['BeamAngleZen'][0]
351 self.BeamAngleZen = header['BeamAngleZen'][0]
353 self.AntennaCoord0 = header['AntennaCoord0'][0]
352 self.AntennaCoord0 = header['AntennaCoord0'][0]
354 self.AntennaAngl0 = header['AntennaAngl0'][0]
353 self.AntennaAngl0 = header['AntennaAngl0'][0]
355 self.AntennaCoord1 = header['AntennaCoord1'][0]
354 self.AntennaCoord1 = header['AntennaCoord1'][0]
356 self.AntennaAngl1 = header['AntennaAngl1'][0]
355 self.AntennaAngl1 = header['AntennaAngl1'][0]
357 self.AntennaCoord2 = header['AntennaCoord2'][0]
356 self.AntennaCoord2 = header['AntennaCoord2'][0]
358 self.AntennaAngl2 = header['AntennaAngl2'][0]
357 self.AntennaAngl2 = header['AntennaAngl2'][0]
359 self.RecPhaseCalibr0 = header['RecPhaseCalibr0'][0]
358 self.RecPhaseCalibr0 = header['RecPhaseCalibr0'][0]
360 self.RecPhaseCalibr1 = header['RecPhaseCalibr1'][0]
359 self.RecPhaseCalibr1 = header['RecPhaseCalibr1'][0]
361 self.RecPhaseCalibr2 = header['RecPhaseCalibr2'][0]
360 self.RecPhaseCalibr2 = header['RecPhaseCalibr2'][0]
362 self.RecAmpCalibr0 = header['RecAmpCalibr0'][0]
361 self.RecAmpCalibr0 = header['RecAmpCalibr0'][0]
363 self.RecAmpCalibr1 = header['RecAmpCalibr1'][0]
362 self.RecAmpCalibr1 = header['RecAmpCalibr1'][0]
364 self.RecAmpCalibr2 = header['RecAmpCalibr2'][0]
363 self.RecAmpCalibr2 = header['RecAmpCalibr2'][0]
365 self.ReceiverGaindB0 = header['ReceiverGaindB0'][0]
364 self.ReceiverGaindB0 = header['ReceiverGaindB0'][0]
366 self.ReceiverGaindB1 = header['ReceiverGaindB1'][0]
365 self.ReceiverGaindB1 = header['ReceiverGaindB1'][0]
367 self.ReceiverGaindB2 = header['ReceiverGaindB2'][0]
366 self.ReceiverGaindB2 = header['ReceiverGaindB2'][0]
368
367
369 self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz)
368 self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz)
370
369
371 self.RHsize = 180+20*self.nChannels
370 self.RHsize = 180+20*self.nChannels
372 self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4
371 self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4
373 #print 'Datasize',self.Datasize
372 #print 'Datasize',self.Datasize
374 endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
373 endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
375
374
376 print '=============================================='
375 print '=============================================='
377 print 'RecMgcNumber ',self.RecMgcNumber
376 print 'RecMgcNumber ',self.RecMgcNumber
378 print 'RecCounter ',self.RecCounter
377 print 'RecCounter ',self.RecCounter
379 print 'Off2StartNxtRec ',self.Off2StartNxtRec
378 print 'Off2StartNxtRec ',self.Off2StartNxtRec
380 print 'Off2StartData ',self.Off2StartData
379 print 'Off2StartData ',self.Off2StartData
381 print 'Range Resolution ',self.SampResolution
380 print 'Range Resolution ',self.SampResolution
382 print 'First Height ',self.StartRangeSamp
381 print 'First Height ',self.StartRangeSamp
383 print 'PRF (Hz) ',self.PRFhz
382 print 'PRF (Hz) ',self.PRFhz
384 print 'Heights (K) ',self.nHeights
383 print 'Heights (K) ',self.nHeights
385 print 'Channels (N) ',self.nChannels
384 print 'Channels (N) ',self.nChannels
386 print 'Profiles (J) ',self.nProfiles
385 print 'Profiles (J) ',self.nProfiles
387 print 'iCoh ',self.nCohInt
386 print 'iCoh ',self.nCohInt
388 print 'iInCoh ',self.nIncohInt
387 print 'iInCoh ',self.nIncohInt
389 print 'BeamAngleAzim ',self.BeamAngleAzim
388 print 'BeamAngleAzim ',self.BeamAngleAzim
390 print 'BeamAngleZen ',self.BeamAngleZen
389 print 'BeamAngleZen ',self.BeamAngleZen
391
390
392 #print 'ModoEnUso ',self.DualModeIndex
391 #print 'ModoEnUso ',self.DualModeIndex
393 #print 'UtcTime ',self.nUtime
392 #print 'UtcTime ',self.nUtime
394 #print 'MiliSec ',self.nMilisec
393 #print 'MiliSec ',self.nMilisec
395 #print 'Exp TagName ',self.ExpTagName
394 #print 'Exp TagName ',self.ExpTagName
396 #print 'Exp Comment ',self.ExpComment
395 #print 'Exp Comment ',self.ExpComment
397 #print 'FFT Window Index ',self.FFTwindowingInd
396 #print 'FFT Window Index ',self.FFTwindowingInd
398 #print 'N Dig. Channels ',self.nDigChannels
397 #print 'N Dig. Channels ',self.nDigChannels
399 print 'Size de bloque ',self.RHsize
398 print 'Size de bloque ',self.RHsize
400 print 'DataSize ',self.Datasize
399 print 'DataSize ',self.Datasize
401 print 'BeamAngleAzim ',self.BeamAngleAzim
400 print 'BeamAngleAzim ',self.BeamAngleAzim
402 #print 'AntennaCoord0 ',self.AntennaCoord0
401 #print 'AntennaCoord0 ',self.AntennaCoord0
403 #print 'AntennaAngl0 ',self.AntennaAngl0
402 #print 'AntennaAngl0 ',self.AntennaAngl0
404 #print 'AntennaCoord1 ',self.AntennaCoord1
403 #print 'AntennaCoord1 ',self.AntennaCoord1
405 #print 'AntennaAngl1 ',self.AntennaAngl1
404 #print 'AntennaAngl1 ',self.AntennaAngl1
406 #print 'AntennaCoord2 ',self.AntennaCoord2
405 #print 'AntennaCoord2 ',self.AntennaCoord2
407 #print 'AntennaAngl2 ',self.AntennaAngl2
406 #print 'AntennaAngl2 ',self.AntennaAngl2
408 print 'RecPhaseCalibr0 ',self.RecPhaseCalibr0
407 print 'RecPhaseCalibr0 ',self.RecPhaseCalibr0
409 print 'RecPhaseCalibr1 ',self.RecPhaseCalibr1
408 print 'RecPhaseCalibr1 ',self.RecPhaseCalibr1
410 print 'RecPhaseCalibr2 ',self.RecPhaseCalibr2
409 print 'RecPhaseCalibr2 ',self.RecPhaseCalibr2
411 print 'RecAmpCalibr0 ',self.RecAmpCalibr0
410 print 'RecAmpCalibr0 ',self.RecAmpCalibr0
412 print 'RecAmpCalibr1 ',self.RecAmpCalibr1
411 print 'RecAmpCalibr1 ',self.RecAmpCalibr1
413 print 'RecAmpCalibr2 ',self.RecAmpCalibr2
412 print 'RecAmpCalibr2 ',self.RecAmpCalibr2
414 print 'ReceiverGaindB0 ',self.ReceiverGaindB0
413 print 'ReceiverGaindB0 ',self.ReceiverGaindB0
415 print 'ReceiverGaindB1 ',self.ReceiverGaindB1
414 print 'ReceiverGaindB1 ',self.ReceiverGaindB1
416 print 'ReceiverGaindB2 ',self.ReceiverGaindB2
415 print 'ReceiverGaindB2 ',self.ReceiverGaindB2
417 print '=============================================='
416 print '=============================================='
418
417
419 if OffRHeader > endFp:
418 if OffRHeader > endFp:
420 sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp)
419 sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp)
421 return 0
420 return 0
422
421
423 if OffRHeader < endFp:
422 if OffRHeader < endFp:
424 sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp)
423 sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp)
425 return 0
424 return 0
426
425
427 return 1
426 return 1
428
427
429
428
430 class BLTRReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODataReader):
429 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODataReader):
431
430
432 path = None
431 path = None
433 startDate = None
432 startDate = None
434 endDate = None
433 endDate = None
435 startTime = None
434 startTime = None
436 endTime = None
435 endTime = None
437 walk = None
436 walk = None
438 isConfig = False
437 isConfig = False
439
438
440
439
441 fileList= None
440 fileList= None
442
441
443 #metadata
442 #metadata
444 TimeZone= None
443 TimeZone= None
445 Interval= None
444 Interval= None
446 heightList= None
445 heightList= None
447
446
448 #data
447 #data
449 data= None
448 data= None
450 utctime= None
449 utctime= None
451
450
452
451
453
452
454 def __init__(self, **kwargs):
453 def __init__(self, **kwargs):
455
454
456 #Eliminar de la base la herencia
455 #Eliminar de la base la herencia
457 ProcessingUnit.__init__(self, **kwargs)
456 ProcessingUnit.__init__(self, **kwargs)
458
457
459 # self.isConfig = False
458 #self.isConfig = False
460
459
461 #self.pts2read_SelfSpectra = 0
460 #self.pts2read_SelfSpectra = 0
462 #self.pts2read_CrossSpectra = 0
461 #self.pts2read_CrossSpectra = 0
463 #self.pts2read_DCchannels = 0
462 #self.pts2read_DCchannels = 0
464 #self.datablock = None
463 #self.datablock = None
465 self.utc = None
464 self.utc = None
466 self.ext = ".fdt"
465 self.ext = ".fdt"
467 self.optchar = "P"
466 self.optchar = "P"
468 self.fpFile=None
467 self.fpFile=None
469 self.fp = None
468 self.fp = None
470 self.BlockCounter=0
469 self.BlockCounter=0
471 self.dtype = None
470 self.dtype = None
472 self.fileSizeByHeader = None
471 self.fileSizeByHeader = None
473 self.filenameList = []
472 self.filenameList = []
474 self.fileSelector = 0
473 self.fileSelector = 0
475 self.Off2StartNxtRec=0
474 self.Off2StartNxtRec=0
476 self.RecCounter=0
475 self.RecCounter=0
477 self.flagNoMoreFiles = 0
476 self.flagNoMoreFiles = 0
478 self.data_spc=None
477 self.data_spc=None
479 self.data_cspc=None
478 self.data_cspc=None
480 self.data_output=None
479 self.data_output=None
481 self.path = None
480 self.path = None
482 self.OffsetStartHeader=0
481 self.OffsetStartHeader=0
483 self.Off2StartData=0
482 self.Off2StartData=0
484 self.ipp = 0
483 self.ipp = 0
485 self.nFDTdataRecors=0
484 self.nFDTdataRecors=0
486 self.blocksize = 0
485 self.blocksize = 0
487 self.dataOut = Spectra()
486 self.dataOut = Spectra()
488 self.profileIndex = 1 #Always
487 self.profileIndex = 1 #Always
489 self.dataOut.flagNoData=False
488 self.dataOut.flagNoData=False
490 self.dataOut.nRdPairs = 0
489 self.dataOut.nRdPairs = 0
491 self.dataOut.pairsList = []
490 self.dataOut.pairsList = []
492 self.dataOut.data_spc=None
491 self.dataOut.data_spc=None
493 self.dataOut.noise=[]
492 self.dataOut.noise=[]
494 self.dataOut.velocityX=[]
493 self.dataOut.velocityX=[]
495 self.dataOut.velocityY=[]
494 self.dataOut.velocityY=[]
496 self.dataOut.velocityV=[]
495 self.dataOut.velocityV=[]
497
496
498
497
499
498
500 def Files2Read(self, fp):
499 def Files2Read(self, fp):
501 '''
500 '''
502 Function that indicates the number of .fdt files that exist in the folder to be read.
501 Function that indicates the number of .fdt files that exist in the folder to be read.
503 It also creates an organized list with the names of the files to read.
502 It also creates an organized list with the names of the files to read.
504 '''
503 '''
505 #self.__checkPath()
504 #self.__checkPath()
506
505
507 ListaData=os.listdir(fp) #Gets the list of files within the fp address
506 ListaData=os.listdir(fp) #Gets the list of files within the fp address
508 ListaData=sorted(ListaData) #Sort the list of files from least to largest by names
507 ListaData=sorted(ListaData) #Sort the list of files from least to largest by names
509 nFiles=0 #File Counter
508 nFiles=0 #File Counter
510 FileList=[] #A list is created that will contain the .fdt files
509 FileList=[] #A list is created that will contain the .fdt files
511 for IndexFile in ListaData :
510 for IndexFile in ListaData :
512 if '.fdt' in IndexFile:
511 if '.fdt' in IndexFile:
513 FileList.append(IndexFile)
512 FileList.append(IndexFile)
514 nFiles+=1
513 nFiles+=1
515
514
516 #print 'Files2Read'
515 #print 'Files2Read'
517 #print 'Existen '+str(nFiles)+' archivos .fdt'
516 #print 'Existen '+str(nFiles)+' archivos .fdt'
518
517
519 self.filenameList=FileList #List of files from least to largest by names
518 self.filenameList=FileList #List of files from least to largest by names
520
519
521
520
522 def run(self, **kwargs):
521 def run(self, **kwargs):
523 '''
522 '''
524 This method will be the one that will initiate the data entry, will be called constantly.
523 This method will be the one that will initiate the data entry, will be called constantly.
525 You should first verify that your Setup () is set up and then continue to acquire
524 You should first verify that your Setup () is set up and then continue to acquire
526 the data to be processed with getData ().
525 the data to be processed with getData ().
527 '''
526 '''
528 if not self.isConfig:
527 if not self.isConfig:
529 self.setup(**kwargs)
528 self.setup(**kwargs)
530 self.isConfig = True
529 self.isConfig = True
531
530
532 self.getData()
531 self.getData()
533 #print 'running'
532 #print 'running'
534
533
535
534
536 def setup(self, path=None,
535 def setup(self, path=None,
537 startDate=None,
536 startDate=None,
538 endDate=None,
537 endDate=None,
539 startTime=None,
538 startTime=None,
540 endTime=None,
539 endTime=None,
541 walk=True,
540 walk=True,
542 timezone='utc',
541 timezone='utc',
543 code = None,
542 code = None,
544 online=False,
543 online=False,
545 ReadMode=None,
544 ReadMode=None,
546 **kwargs):
545 **kwargs):
547
546
548 self.isConfig = True
547 self.isConfig = True
549
548
550 self.path=path
549 self.path=path
551 self.startDate=startDate
550 self.startDate=startDate
552 self.endDate=endDate
551 self.endDate=endDate
553 self.startTime=startTime
552 self.startTime=startTime
554 self.endTime=endTime
553 self.endTime=endTime
555 self.walk=walk
554 self.walk=walk
556 self.ReadMode=int(ReadMode)
555 self.ReadMode=int(ReadMode)
557
556
558 pass
557 pass
559
558
560
559
561 def getData(self):
560 def getData(self):
562 '''
561 '''
563 Before starting this function, you should check that there is still an unread file,
562 Before starting this function, you should check that there is still an unread file,
564 If there are still blocks to read or if the data block is empty.
563 If there are still blocks to read or if the data block is empty.
565
564
566 You should call the file "read".
565 You should call the file "read".
567
566
568 '''
567 '''
569
568
570 if self.flagNoMoreFiles:
569 if self.flagNoMoreFiles:
571 self.dataOut.flagNoData = True
570 self.dataOut.flagNoData = True
572 print 'NoData se vuelve true'
571 print 'NoData se vuelve true'
573 return 0
572 return 0
574
573
575 self.fp=self.path
574 self.fp=self.path
576 self.Files2Read(self.fp)
575 self.Files2Read(self.fp)
577 self.readFile(self.fp)
576 self.readFile(self.fp)
578 self.dataOut.data_spc = self.data_spc
577 self.dataOut.data_spc = self.data_spc
579 self.dataOut.data_cspc =self.data_cspc
578 self.dataOut.data_cspc =self.data_cspc
580 self.dataOut.data_output=self.data_output
579 self.dataOut.data_output=self.data_output
581
580
582 print 'self.dataOut.data_output', shape(self.dataOut.data_output)
581 print 'self.dataOut.data_output', shape(self.dataOut.data_output)
583
582
584 #self.removeDC()
583 #self.removeDC()
585 return self.dataOut.data_spc
584 return self.dataOut.data_spc
586
585
587
586
588 def readFile(self,fp):
587 def readFile(self,fp):
589 '''
588 '''
590 You must indicate if you are reading in Online or Offline mode and load the
589 You must indicate if you are reading in Online or Offline mode and load the
591 The parameters for this file reading mode.
590 The parameters for this file reading mode.
592
591
593 Then you must do 2 actions:
592 Then you must do 2 actions:
594
593
595 1. Get the BLTR FileHeader.
594 1. Get the BLTR FileHeader.
596 2. Start reading the first block.
595 2. Start reading the first block.
597 '''
596 '''
598
597
599 #The address of the folder is generated the name of the .fdt file that will be read
598 #The address of the folder is generated the name of the .fdt file that will be read
600 print "File: ",self.fileSelector+1
599 print "File: ",self.fileSelector+1
601
600
602 if self.fileSelector < len(self.filenameList):
601 if self.fileSelector < len(self.filenameList):
603
602
604 self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector])
603 self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector])
605 #print self.fpFile
604 #print self.fpFile
606 fheader = FileHeaderBLTR()
605 fheader = FileHeaderBLTR()
607 fheader.FHread(self.fpFile) #Bltr FileHeader Reading
606 fheader.FHread(self.fpFile) #Bltr FileHeader Reading
608 self.nFDTdataRecors=fheader.nFDTdataRecors
607 self.nFDTdataRecors=fheader.nFDTdataRecors
609
608
610 self.readBlock() #Block reading
609 self.readBlock() #Block reading
611 else:
610 else:
612 print 'readFile FlagNoData becomes true'
611 print 'readFile FlagNoData becomes true'
613 self.flagNoMoreFiles=True
612 self.flagNoMoreFiles=True
614 self.dataOut.flagNoData = True
613 self.dataOut.flagNoData = True
615 return 0
614 return 0
616
615
617 def getVelRange(self, extrapoints=0):
616 def getVelRange(self, extrapoints=0):
618 Lambda= SPEED_OF_LIGHT/50000000
617 Lambda= SPEED_OF_LIGHT/50000000
619 PRF = self.dataOut.PRF#1./(self.dataOut.ippSeconds * self.dataOut.nCohInt)
618 PRF = self.dataOut.PRF#1./(self.dataOut.ippSeconds * self.dataOut.nCohInt)
620 Vmax=-Lambda/(4.*(1./PRF)*self.dataOut.nCohInt*2.)
619 Vmax=-Lambda/(4.*(1./PRF)*self.dataOut.nCohInt*2.)
621 deltafreq = PRF / (self.nProfiles)
620 deltafreq = PRF / (self.nProfiles)
622 deltavel = (Vmax*2) / (self.nProfiles)
621 deltavel = (Vmax*2) / (self.nProfiles)
623 freqrange = deltafreq*(numpy.arange(self.nProfiles)-self.nProfiles/2.) - deltafreq/2
622 freqrange = deltafreq*(numpy.arange(self.nProfiles)-self.nProfiles/2.) - deltafreq/2
624 velrange = deltavel*(numpy.arange(self.nProfiles)-self.nProfiles/2.)
623 velrange = deltavel*(numpy.arange(self.nProfiles)-self.nProfiles/2.)
625 return velrange
624 return velrange
626
625
627 def readBlock(self):
626 def readBlock(self):
628 '''
627 '''
629 It should be checked if the block has data, if it is not passed to the next file.
628 It should be checked if the block has data, if it is not passed to the next file.
630
629
631 Then the following is done:
630 Then the following is done:
632
631
633 1. Read the RecordHeader
632 1. Read the RecordHeader
634 2. Fill the buffer with the current block number.
633 2. Fill the buffer with the current block number.
635
634
636 '''
635 '''
637
636
638 if self.BlockCounter < self.nFDTdataRecors-2:
637 if self.BlockCounter < self.nFDTdataRecors-2:
639 print self.nFDTdataRecors, 'CONDICION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
638 print self.nFDTdataRecors, 'CONDICION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
640 if self.ReadMode==1:
639 if self.ReadMode==1:
641 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter+1)
640 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter+1)
642 elif self.ReadMode==0:
641 elif self.ReadMode==0:
643 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter)
642 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter)
644
643
645 rheader.RHread(self.fpFile) #Bltr FileHeader Reading
644 rheader.RHread(self.fpFile) #Bltr FileHeader Reading
646
645
647 self.OffsetStartHeader=rheader.OffsetStartHeader
646 self.OffsetStartHeader=rheader.OffsetStartHeader
648 self.RecCounter=rheader.RecCounter
647 self.RecCounter=rheader.RecCounter
649 self.Off2StartNxtRec=rheader.Off2StartNxtRec
648 self.Off2StartNxtRec=rheader.Off2StartNxtRec
650 self.Off2StartData=rheader.Off2StartData
649 self.Off2StartData=rheader.Off2StartData
651 self.nProfiles=rheader.nProfiles
650 self.nProfiles=rheader.nProfiles
652 self.nChannels=rheader.nChannels
651 self.nChannels=rheader.nChannels
653 self.nHeights=rheader.nHeights
652 self.nHeights=rheader.nHeights
654 self.frequency=rheader.TransmitFrec
653 self.frequency=rheader.TransmitFrec
655 self.DualModeIndex=rheader.DualModeIndex
654 self.DualModeIndex=rheader.DualModeIndex
656
655
657 self.pairsList =[(0,1),(0,2),(1,2)]
656 self.pairsList =[(0,1),(0,2),(1,2)]
658 self.dataOut.pairsList = self.pairsList
657 self.dataOut.pairsList = self.pairsList
659
658
660 self.nRdPairs=len(self.dataOut.pairsList)
659 self.nRdPairs=len(self.dataOut.pairsList)
661 self.dataOut.nRdPairs = self.nRdPairs
660 self.dataOut.nRdPairs = self.nRdPairs
662
661
663 self.__firstHeigth=rheader.StartRangeSamp
662 self.__firstHeigth=rheader.StartRangeSamp
664 self.__deltaHeigth=rheader.SampResolution
663 self.__deltaHeigth=rheader.SampResolution
665 self.dataOut.heightList= self.__firstHeigth + numpy.array(range(self.nHeights))*self.__deltaHeigth
664 self.dataOut.heightList= self.__firstHeigth + numpy.array(range(self.nHeights))*self.__deltaHeigth
666 self.dataOut.channelList = range(self.nChannels)
665 self.dataOut.channelList = range(self.nChannels)
667 self.dataOut.nProfiles=rheader.nProfiles
666 self.dataOut.nProfiles=rheader.nProfiles
668 self.dataOut.nIncohInt=rheader.nIncohInt
667 self.dataOut.nIncohInt=rheader.nIncohInt
669 self.dataOut.nCohInt=rheader.nCohInt
668 self.dataOut.nCohInt=rheader.nCohInt
670 self.dataOut.ippSeconds= 1/float(rheader.PRFhz)
669 self.dataOut.ippSeconds= 1/float(rheader.PRFhz)
671 self.dataOut.PRF=rheader.PRFhz
670 self.dataOut.PRF=rheader.PRFhz
672 self.dataOut.nFFTPoints=rheader.nProfiles
671 self.dataOut.nFFTPoints=rheader.nProfiles
673 self.dataOut.utctime=rheader.nUtime
672 self.dataOut.utctime=rheader.nUtime
674 self.dataOut.timeZone=0
673 self.dataOut.timeZone=0
675 self.dataOut.normFactor= self.dataOut.nProfiles*self.dataOut.nIncohInt*self.dataOut.nCohInt
674 self.dataOut.normFactor= self.dataOut.nProfiles*self.dataOut.nIncohInt*self.dataOut.nCohInt
676 self.dataOut.outputInterval= self.dataOut.ippSeconds * self.dataOut.nCohInt * self.dataOut.nIncohInt * self.nProfiles
675 self.dataOut.outputInterval= self.dataOut.ippSeconds * self.dataOut.nCohInt * self.dataOut.nIncohInt * self.nProfiles
677
676
678 self.data_output=numpy.ones([3,rheader.nHeights])*numpy.NaN
677 self.data_output=numpy.ones([3,rheader.nHeights])*numpy.NaN
679 print 'self.data_output', shape(self.data_output)
678 print 'self.data_output', shape(self.data_output)
680 self.dataOut.velocityX=[]
679 self.dataOut.velocityX=[]
681 self.dataOut.velocityY=[]
680 self.dataOut.velocityY=[]
682 self.dataOut.velocityV=[]
681 self.dataOut.velocityV=[]
683
682
684 '''Block Reading, the Block Data is received and Reshape is used to give it
683 '''Block Reading, the Block Data is received and Reshape is used to give it
685 shape.
684 shape.
686 '''
685 '''
687
686
688 #Procedure to take the pointer to where the date block starts
687 #Procedure to take the pointer to where the date block starts
689 startDATA = open(self.fpFile,"rb")
688 startDATA = open(self.fpFile,"rb")
690 OffDATA= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec+self.Off2StartData
689 OffDATA= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec+self.Off2StartData
691 startDATA.seek(OffDATA, os.SEEK_SET)
690 startDATA.seek(OffDATA, os.SEEK_SET)
692
691
693 def moving_average(x, N=2):
692 def moving_average(x, N=2):
694 return numpy.convolve(x, numpy.ones((N,))/N)[(N-1):]
693 return numpy.convolve(x, numpy.ones((N,))/N)[(N-1):]
695
694
696 def gaus(xSamples,a,x0,sigma):
695 def gaus(xSamples,a,x0,sigma):
697 return a*exp(-(xSamples-x0)**2/(2*sigma**2))
696 return a*exp(-(xSamples-x0)**2/(2*sigma**2))
698
697
699 def Find(x,value):
698 def Find(x,value):
700 for index in range(len(x)):
699 for index in range(len(x)):
701 if x[index]==value:
700 if x[index]==value:
702 return index
701 return index
703
702
704 def pol2cart(rho, phi):
703 def pol2cart(rho, phi):
705 x = rho * numpy.cos(phi)
704 x = rho * numpy.cos(phi)
706 y = rho * numpy.sin(phi)
705 y = rho * numpy.sin(phi)
707 return(x, y)
706 return(x, y)
708
707
709
708
710
709
711
710
712 if self.DualModeIndex==self.ReadMode:
711 if self.DualModeIndex==self.ReadMode:
713
712
714 self.data_fft = numpy.fromfile( startDATA, [('complex','<c8')],self.nProfiles*self.nChannels*self.nHeights )
713 self.data_fft = numpy.fromfile( startDATA, [('complex','<c8')],self.nProfiles*self.nChannels*self.nHeights )
715
714
716 self.data_fft=self.data_fft.astype(numpy.dtype('complex'))
715 self.data_fft=self.data_fft.astype(numpy.dtype('complex'))
717
716
718 self.data_block=numpy.reshape(self.data_fft,(self.nHeights, self.nChannels, self.nProfiles ))
717 self.data_block=numpy.reshape(self.data_fft,(self.nHeights, self.nChannels, self.nProfiles ))
719
718
720 self.data_block = numpy.transpose(self.data_block, (1,2,0))
719 self.data_block = numpy.transpose(self.data_block, (1,2,0))
721
720
722 copy = self.data_block.copy()
721 copy = self.data_block.copy()
723 spc = copy * numpy.conjugate(copy)
722 spc = copy * numpy.conjugate(copy)
724
723
725 self.data_spc = numpy.absolute(spc) # valor absoluto o magnitud
724 self.data_spc = numpy.absolute(spc) # valor absoluto o magnitud
726
725
727 factor = self.dataOut.normFactor
726 factor = self.dataOut.normFactor
728
727
729
728
730 z = self.data_spc.copy()#/factor
729 z = self.data_spc.copy()#/factor
731 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
730 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
732 #zdB = 10*numpy.log10(z)
731 #zdB = 10*numpy.log10(z)
733 print ' '
732 print ' '
734 print 'Z: '
733 print 'Z: '
735 print shape(z)
734 print shape(z)
736 print ' '
735 print ' '
737 print ' '
736 print ' '
738
737
739 self.dataOut.data_spc=self.data_spc
738 self.dataOut.data_spc=self.data_spc
740
739
741 self.noise = self.dataOut.getNoise(ymin_index=80, ymax_index=132)#/factor
740 self.noise = self.dataOut.getNoise(ymin_index=80, ymax_index=132)#/factor
742 #noisedB = 10*numpy.log10(self.noise)
741 #noisedB = 10*numpy.log10(self.noise)
743
742
744
743
745 ySamples=numpy.ones([3,self.nProfiles])
744 ySamples=numpy.ones([3,self.nProfiles])
746 phase=numpy.ones([3,self.nProfiles])
745 phase=numpy.ones([3,self.nProfiles])
747 CSPCSamples=numpy.ones([3,self.nProfiles],dtype=numpy.complex_)
746 CSPCSamples=numpy.ones([3,self.nProfiles],dtype=numpy.complex_)
748 coherence=numpy.ones([3,self.nProfiles])
747 coherence=numpy.ones([3,self.nProfiles])
749 PhaseSlope=numpy.ones(3)
748 PhaseSlope=numpy.ones(3)
750 PhaseInter=numpy.ones(3)
749 PhaseInter=numpy.ones(3)
751
750
752 '''****** Getting CrossSpectra ******'''
751 '''****** Getting CrossSpectra ******'''
753 cspc=self.data_block.copy()
752 cspc=self.data_block.copy()
754 self.data_cspc=self.data_block.copy()
753 self.data_cspc=self.data_block.copy()
755
754
756 xFrec=self.getVelRange(1)
755 xFrec=self.getVelRange(1)
757 VelRange=self.getVelRange(1)
756 VelRange=self.getVelRange(1)
758 self.dataOut.VelRange=VelRange
757 self.dataOut.VelRange=VelRange
759 #print ' '
758 #print ' '
760 #print ' '
759 #print ' '
761 #print 'xFrec',xFrec
760 #print 'xFrec',xFrec
762 #print ' '
761 #print ' '
763 #print ' '
762 #print ' '
764 #Height=35
763 #Height=35
765 for i in range(self.nRdPairs):
764 for i in range(self.nRdPairs):
766
765
767 chan_index0 = self.dataOut.pairsList[i][0]
766 chan_index0 = self.dataOut.pairsList[i][0]
768 chan_index1 = self.dataOut.pairsList[i][1]
767 chan_index1 = self.dataOut.pairsList[i][1]
769
768
770 self.data_cspc[i,:,:]=cspc[chan_index0,:,:] * numpy.conjugate(cspc[chan_index1,:,:])
769 self.data_cspc[i,:,:]=cspc[chan_index0,:,:] * numpy.conjugate(cspc[chan_index1,:,:])
771
770
772
771
773 '''Getting Eij and Nij'''
772 '''Getting Eij and Nij'''
774 (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
773 (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
775 (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
774 (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
776 (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
775 (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
777
776
778 E01=AntennaX0-AntennaX1
777 E01=AntennaX0-AntennaX1
779 N01=AntennaY0-AntennaY1
778 N01=AntennaY0-AntennaY1
780
779
781 E02=AntennaX0-AntennaX2
780 E02=AntennaX0-AntennaX2
782 N02=AntennaY0-AntennaY2
781 N02=AntennaY0-AntennaY2
783
782
784 E12=AntennaX1-AntennaX2
783 E12=AntennaX1-AntennaX2
785 N12=AntennaY1-AntennaY2
784 N12=AntennaY1-AntennaY2
786
785
787 self.ChanDist= numpy.array([[E01, N01],[E02,N02],[E12,N12]])
786 self.ChanDist= numpy.array([[E01, N01],[E02,N02],[E12,N12]])
788
787
789 self.dataOut.ChanDist = self.ChanDist
788 self.dataOut.ChanDist = self.ChanDist
790
789
791
790
792 # for Height in range(self.nHeights):
791 # for Height in range(self.nHeights):
793 #
792 #
794 # for i in range(self.nRdPairs):
793 # for i in range(self.nRdPairs):
795 #
794 #
796 # '''****** Line of Data SPC ******'''
795 # '''****** Line of Data SPC ******'''
797 # zline=z[i,:,Height]
796 # zline=z[i,:,Height]
798 #
797 #
799 # '''****** DC is removed ******'''
798 # '''****** DC is removed ******'''
800 # DC=Find(zline,numpy.amax(zline))
799 # DC=Find(zline,numpy.amax(zline))
801 # zline[DC]=(zline[DC-1]+zline[DC+1])/2
800 # zline[DC]=(zline[DC-1]+zline[DC+1])/2
802 #
801 #
803 #
802 #
804 # '''****** SPC is normalized ******'''
803 # '''****** SPC is normalized ******'''
805 # FactNorm= zline.copy() / numpy.sum(zline.copy())
804 # FactNorm= zline.copy() / numpy.sum(zline.copy())
806 # FactNorm= FactNorm/numpy.sum(FactNorm)
805 # FactNorm= FactNorm/numpy.sum(FactNorm)
807 #
806 #
808 # SmoothSPC=moving_average(FactNorm,N=3)
807 # SmoothSPC=moving_average(FactNorm,N=3)
809 #
808 #
810 # xSamples = ar(range(len(SmoothSPC)))
809 # xSamples = ar(range(len(SmoothSPC)))
811 # ySamples[i] = SmoothSPC-self.noise[i]
810 # ySamples[i] = SmoothSPC-self.noise[i]
812 #
811 #
813 # for i in range(self.nRdPairs):
812 # for i in range(self.nRdPairs):
814 #
813 #
815 # '''****** Line of Data CSPC ******'''
814 # '''****** Line of Data CSPC ******'''
816 # cspcLine=self.data_cspc[i,:,Height].copy()
815 # cspcLine=self.data_cspc[i,:,Height].copy()
817 #
816 #
818 #
817 #
819 #
818 #
820 # '''****** CSPC is normalized ******'''
819 # '''****** CSPC is normalized ******'''
821 # chan_index0 = self.dataOut.pairsList[i][0]
820 # chan_index0 = self.dataOut.pairsList[i][0]
822 # chan_index1 = self.dataOut.pairsList[i][1]
821 # chan_index1 = self.dataOut.pairsList[i][1]
823 # CSPCFactor= numpy.sum(ySamples[chan_index0]) * numpy.sum(ySamples[chan_index1])
822 # CSPCFactor= numpy.sum(ySamples[chan_index0]) * numpy.sum(ySamples[chan_index1])
824 #
823 #
825 #
824 #
826 # CSPCNorm= cspcLine.copy() / numpy.sqrt(CSPCFactor)
825 # CSPCNorm= cspcLine.copy() / numpy.sqrt(CSPCFactor)
827 #
826 #
828 #
827 #
829 # CSPCSamples[i] = CSPCNorm-self.noise[i]
828 # CSPCSamples[i] = CSPCNorm-self.noise[i]
830 # coherence[i] = numpy.abs(CSPCSamples[i]) / numpy.sqrt(CSPCFactor)
829 # coherence[i] = numpy.abs(CSPCSamples[i]) / numpy.sqrt(CSPCFactor)
831 #
830 #
832 # '''****** DC is removed ******'''
831 # '''****** DC is removed ******'''
833 # DC=Find(coherence[i],numpy.amax(coherence[i]))
832 # DC=Find(coherence[i],numpy.amax(coherence[i]))
834 # coherence[i][DC]=(coherence[i][DC-1]+coherence[i][DC+1])/2
833 # coherence[i][DC]=(coherence[i][DC-1]+coherence[i][DC+1])/2
835 # coherence[i]= moving_average(coherence[i],N=2)
834 # coherence[i]= moving_average(coherence[i],N=2)
836 #
835 #
837 # phase[i] = moving_average( numpy.arctan2(CSPCSamples[i].imag, CSPCSamples[i].real),N=1)#*180/numpy.pi
836 # phase[i] = moving_average( numpy.arctan2(CSPCSamples[i].imag, CSPCSamples[i].real),N=1)#*180/numpy.pi
838 #
837 #
839 #
838 #
840 # '''****** Getting fij width ******'''
839 # '''****** Getting fij width ******'''
841 #
840 #
842 # yMean=[]
841 # yMean=[]
843 # yMean2=[]
842 # yMean2=[]
844 #
843 #
845 # for j in range(len(ySamples[1])):
844 # for j in range(len(ySamples[1])):
846 # yMean=numpy.append(yMean,numpy.average([ySamples[0,j],ySamples[1,j],ySamples[2,j]]))
845 # yMean=numpy.append(yMean,numpy.average([ySamples[0,j],ySamples[1,j],ySamples[2,j]]))
847 #
846 #
848 # '''******* Getting fitting Gaussian ******'''
847 # '''******* Getting fitting Gaussian ******'''
849 # meanGauss=sum(xSamples*yMean) / len(xSamples)
848 # meanGauss=sum(xSamples*yMean) / len(xSamples)
850 # sigma=sum(yMean*(xSamples-meanGauss)**2) / len(xSamples)
849 # sigma=sum(yMean*(xSamples-meanGauss)**2) / len(xSamples)
851 # #print 'Height',Height,'SNR', meanGauss/sigma**2
850 # #print 'Height',Height,'SNR', meanGauss/sigma**2
852 #
851 #
853 # if (abs(meanGauss/sigma**2) > 0.0001) :
852 # if (abs(meanGauss/sigma**2) > 0.0001) :
854 #
853 #
855 # try:
854 # try:
856 # popt,pcov = curve_fit(gaus,xSamples,yMean,p0=[1,meanGauss,sigma])
855 # popt,pcov = curve_fit(gaus,xSamples,yMean,p0=[1,meanGauss,sigma])
857 #
856 #
858 # if numpy.amax(popt)>numpy.amax(yMean)*0.3:
857 # if numpy.amax(popt)>numpy.amax(yMean)*0.3:
859 # FitGauss=gaus(xSamples,*popt)
858 # FitGauss=gaus(xSamples,*popt)
860 #
859 #
861 # else:
860 # else:
862 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
861 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
863 # print 'Verificador: Dentro', Height
862 # print 'Verificador: Dentro', Height
864 # except RuntimeError:
863 # except RuntimeError:
865 #
864 #
866 # try:
865 # try:
867 # for j in range(len(ySamples[1])):
866 # for j in range(len(ySamples[1])):
868 # yMean2=numpy.append(yMean2,numpy.average([ySamples[1,j],ySamples[2,j]]))
867 # yMean2=numpy.append(yMean2,numpy.average([ySamples[1,j],ySamples[2,j]]))
869 # popt,pcov = curve_fit(gaus,xSamples,yMean2,p0=[1,meanGauss,sigma])
868 # popt,pcov = curve_fit(gaus,xSamples,yMean2,p0=[1,meanGauss,sigma])
870 # FitGauss=gaus(xSamples,*popt)
869 # FitGauss=gaus(xSamples,*popt)
871 # print 'Verificador: Exepcion1', Height
870 # print 'Verificador: Exepcion1', Height
872 # except RuntimeError:
871 # except RuntimeError:
873 #
872 #
874 # try:
873 # try:
875 # popt,pcov = curve_fit(gaus,xSamples,ySamples[1],p0=[1,meanGauss,sigma])
874 # popt,pcov = curve_fit(gaus,xSamples,ySamples[1],p0=[1,meanGauss,sigma])
876 # FitGauss=gaus(xSamples,*popt)
875 # FitGauss=gaus(xSamples,*popt)
877 # print 'Verificador: Exepcion2', Height
876 # print 'Verificador: Exepcion2', Height
878 # except RuntimeError:
877 # except RuntimeError:
879 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
878 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
880 # print 'Verificador: Exepcion3', Height
879 # print 'Verificador: Exepcion3', Height
881 # else:
880 # else:
882 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
881 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
883 # #print 'Verificador: Fuera', Height
882 # #print 'Verificador: Fuera', Height
884 #
883 #
885 #
884 #
886 #
885 #
887 # Maximun=numpy.amax(yMean)
886 # Maximun=numpy.amax(yMean)
888 # eMinus1=Maximun*numpy.exp(-1)
887 # eMinus1=Maximun*numpy.exp(-1)
889 #
888 #
890 # HWpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-eMinus1)))
889 # HWpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-eMinus1)))
891 # HalfWidth= xFrec[HWpos]
890 # HalfWidth= xFrec[HWpos]
892 # GCpos=Find(FitGauss, numpy.amax(FitGauss))
891 # GCpos=Find(FitGauss, numpy.amax(FitGauss))
893 # Vpos=Find(FactNorm, numpy.amax(FactNorm))
892 # Vpos=Find(FactNorm, numpy.amax(FactNorm))
894 # #Vpos=numpy.sum(FactNorm)/len(FactNorm)
893 # #Vpos=numpy.sum(FactNorm)/len(FactNorm)
895 # #Vpos=Find(FactNorm, min(FactNorm, key=lambda value:abs(value- numpy.mean(FactNorm) )))
894 # #Vpos=Find(FactNorm, min(FactNorm, key=lambda value:abs(value- numpy.mean(FactNorm) )))
896 # #print 'GCpos',GCpos, numpy.amax(FitGauss), 'HWpos',HWpos
895 # #print 'GCpos',GCpos, numpy.amax(FitGauss), 'HWpos',HWpos
897 # '''****** Getting Fij ******'''
896 # '''****** Getting Fij ******'''
898 #
897 #
899 # GaussCenter=xFrec[GCpos]
898 # GaussCenter=xFrec[GCpos]
900 # if (GaussCenter<0 and HalfWidth>0) or (GaussCenter>0 and HalfWidth<0):
899 # if (GaussCenter<0 and HalfWidth>0) or (GaussCenter>0 and HalfWidth<0):
901 # Fij=abs(GaussCenter)+abs(HalfWidth)+0.0000001
900 # Fij=abs(GaussCenter)+abs(HalfWidth)+0.0000001
902 # else:
901 # else:
903 # Fij=abs(GaussCenter-HalfWidth)+0.0000001
902 # Fij=abs(GaussCenter-HalfWidth)+0.0000001
904 #
903 #
905 # '''****** Getting Frecuency range of significant data ******'''
904 # '''****** Getting Frecuency range of significant data ******'''
906 #
905 #
907 # Rangpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-Maximun*0.10)))
906 # Rangpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-Maximun*0.10)))
908 #
907 #
909 # if Rangpos<GCpos:
908 # if Rangpos<GCpos:
910 # Range=numpy.array([Rangpos,2*GCpos-Rangpos])
909 # Range=numpy.array([Rangpos,2*GCpos-Rangpos])
911 # else:
910 # else:
912 # Range=numpy.array([2*GCpos-Rangpos,Rangpos])
911 # Range=numpy.array([2*GCpos-Rangpos,Rangpos])
913 #
912 #
914 # FrecRange=xFrec[Range[0]:Range[1]]
913 # FrecRange=xFrec[Range[0]:Range[1]]
915 #
914 #
916 # #print 'FrecRange', FrecRange
915 # #print 'FrecRange', FrecRange
917 # '''****** Getting SCPC Slope ******'''
916 # '''****** Getting SCPC Slope ******'''
918 #
917 #
919 # for i in range(self.nRdPairs):
918 # for i in range(self.nRdPairs):
920 #
919 #
921 # if len(FrecRange)>5 and len(FrecRange)<self.nProfiles*0.5:
920 # if len(FrecRange)>5 and len(FrecRange)<self.nProfiles*0.5:
922 # PhaseRange=moving_average(phase[i,Range[0]:Range[1]],N=3)
921 # PhaseRange=moving_average(phase[i,Range[0]:Range[1]],N=3)
923 #
922 #
924 # slope, intercept, r_value, p_value, std_err = stats.linregress(FrecRange,PhaseRange)
923 # slope, intercept, r_value, p_value, std_err = stats.linregress(FrecRange,PhaseRange)
925 # PhaseSlope[i]=slope
924 # PhaseSlope[i]=slope
926 # PhaseInter[i]=intercept
925 # PhaseInter[i]=intercept
927 # else:
926 # else:
928 # PhaseSlope[i]=0
927 # PhaseSlope[i]=0
929 # PhaseInter[i]=0
928 # PhaseInter[i]=0
930 #
929 #
931 # # plt.figure(i+15)
930 # # plt.figure(i+15)
932 # # plt.title('FASE ( CH%s*CH%s )' %(self.dataOut.pairsList[i][0],self.dataOut.pairsList[i][1]))
931 # # plt.title('FASE ( CH%s*CH%s )' %(self.dataOut.pairsList[i][0],self.dataOut.pairsList[i][1]))
933 # # plt.xlabel('Frecuencia (KHz)')
932 # # plt.xlabel('Frecuencia (KHz)')
934 # # plt.ylabel('Magnitud')
933 # # plt.ylabel('Magnitud')
935 # # #plt.subplot(311+i)
934 # # #plt.subplot(311+i)
936 # # plt.plot(FrecRange,PhaseRange,'b')
935 # # plt.plot(FrecRange,PhaseRange,'b')
937 # # plt.plot(FrecRange,FrecRange*PhaseSlope[i]+PhaseInter[i],'r')
936 # # plt.plot(FrecRange,FrecRange*PhaseSlope[i]+PhaseInter[i],'r')
938 #
937 #
939 # #plt.axis([-0.6, 0.2, -3.2, 3.2])
938 # #plt.axis([-0.6, 0.2, -3.2, 3.2])
940 #
939 #
941 #
940 #
942 # '''Getting constant C'''
941 # '''Getting constant C'''
943 # cC=(Fij*numpy.pi)**2
942 # cC=(Fij*numpy.pi)**2
944 #
943 #
945 # # '''Getting Eij and Nij'''
944 # # '''Getting Eij and Nij'''
946 # # (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
945 # # (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
947 # # (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
946 # # (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
948 # # (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
947 # # (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
949 # #
948 # #
950 # # E01=AntennaX0-AntennaX1
949 # # E01=AntennaX0-AntennaX1
951 # # N01=AntennaY0-AntennaY1
950 # # N01=AntennaY0-AntennaY1
952 # #
951 # #
953 # # E02=AntennaX0-AntennaX2
952 # # E02=AntennaX0-AntennaX2
954 # # N02=AntennaY0-AntennaY2
953 # # N02=AntennaY0-AntennaY2
955 # #
954 # #
956 # # E12=AntennaX1-AntennaX2
955 # # E12=AntennaX1-AntennaX2
957 # # N12=AntennaY1-AntennaY2
956 # # N12=AntennaY1-AntennaY2
958 #
957 #
959 # '''****** Getting constants F and G ******'''
958 # '''****** Getting constants F and G ******'''
960 # MijEijNij=numpy.array([[E02,N02], [E12,N12]])
959 # MijEijNij=numpy.array([[E02,N02], [E12,N12]])
961 # MijResult0=(-PhaseSlope[1]*cC) / (2*numpy.pi)
960 # MijResult0=(-PhaseSlope[1]*cC) / (2*numpy.pi)
962 # MijResult1=(-PhaseSlope[2]*cC) / (2*numpy.pi)
961 # MijResult1=(-PhaseSlope[2]*cC) / (2*numpy.pi)
963 # MijResults=numpy.array([MijResult0,MijResult1])
962 # MijResults=numpy.array([MijResult0,MijResult1])
964 # (cF,cG) = numpy.linalg.solve(MijEijNij, MijResults)
963 # (cF,cG) = numpy.linalg.solve(MijEijNij, MijResults)
965 #
964 #
966 # '''****** Getting constants A, B and H ******'''
965 # '''****** Getting constants A, B and H ******'''
967 # W01=numpy.amax(coherence[0])
966 # W01=numpy.amax(coherence[0])
968 # W02=numpy.amax(coherence[1])
967 # W02=numpy.amax(coherence[1])
969 # W12=numpy.amax(coherence[2])
968 # W12=numpy.amax(coherence[2])
970 #
969 #
971 # WijResult0=((cF*E01+cG*N01)**2)/cC - numpy.log(W01 / numpy.sqrt(numpy.pi/cC))
970 # WijResult0=((cF*E01+cG*N01)**2)/cC - numpy.log(W01 / numpy.sqrt(numpy.pi/cC))
972 # WijResult1=((cF*E02+cG*N02)**2)/cC - numpy.log(W02 / numpy.sqrt(numpy.pi/cC))
971 # WijResult1=((cF*E02+cG*N02)**2)/cC - numpy.log(W02 / numpy.sqrt(numpy.pi/cC))
973 # WijResult2=((cF*E12+cG*N12)**2)/cC - numpy.log(W12 / numpy.sqrt(numpy.pi/cC))
972 # WijResult2=((cF*E12+cG*N12)**2)/cC - numpy.log(W12 / numpy.sqrt(numpy.pi/cC))
974 #
973 #
975 # WijResults=numpy.array([WijResult0, WijResult1, WijResult2])
974 # WijResults=numpy.array([WijResult0, WijResult1, WijResult2])
976 #
975 #
977 # WijEijNij=numpy.array([ [E01**2, N01**2, 2*E01*N01] , [E02**2, N02**2, 2*E02*N02] , [E12**2, N12**2, 2*E12*N12] ])
976 # WijEijNij=numpy.array([ [E01**2, N01**2, 2*E01*N01] , [E02**2, N02**2, 2*E02*N02] , [E12**2, N12**2, 2*E12*N12] ])
978 # (cA,cB,cH) = numpy.linalg.solve(WijEijNij, WijResults)
977 # (cA,cB,cH) = numpy.linalg.solve(WijEijNij, WijResults)
979 #
978 #
980 # VxVy=numpy.array([[cA,cH],[cH,cB]])
979 # VxVy=numpy.array([[cA,cH],[cH,cB]])
981 #
980 #
982 # VxVyResults=numpy.array([-cF,-cG])
981 # VxVyResults=numpy.array([-cF,-cG])
983 # (Vx,Vy) = numpy.linalg.solve(VxVy, VxVyResults)
982 # (Vx,Vy) = numpy.linalg.solve(VxVy, VxVyResults)
984 # Vzon = Vy
983 # Vzon = Vy
985 # Vmer = Vx
984 # Vmer = Vx
986 # Vmag=numpy.sqrt(Vzon**2+Vmer**2)
985 # Vmag=numpy.sqrt(Vzon**2+Vmer**2)
987 # Vang=numpy.arctan2(Vmer,Vzon)
986 # Vang=numpy.arctan2(Vmer,Vzon)
988 #
987 #
989 # if abs(Vy)<100 and abs(Vy)> 0.:
988 # if abs(Vy)<100 and abs(Vy)> 0.:
990 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, Vzon) #Vmag
989 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, Vzon) #Vmag
991 # #print 'Vmag',Vmag
990 # #print 'Vmag',Vmag
992 # else:
991 # else:
993 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, NaN)
992 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, NaN)
994 #
993 #
995 # if abs(Vx)<100 and abs(Vx) > 0.:
994 # if abs(Vx)<100 and abs(Vx) > 0.:
996 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, Vmer) #Vang
995 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, Vmer) #Vang
997 # #print 'Vang',Vang
996 # #print 'Vang',Vang
998 # else:
997 # else:
999 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, NaN)
998 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, NaN)
1000 #
999 #
1001 # if abs(GaussCenter)<2:
1000 # if abs(GaussCenter)<2:
1002 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, xFrec[Vpos])
1001 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, xFrec[Vpos])
1003 #
1002 #
1004 # else:
1003 # else:
1005 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, NaN)
1004 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, NaN)
1006 #
1005 #
1007 #
1006 #
1008 # # print '********************************************'
1007 # # print '********************************************'
1009 # # print 'HalfWidth ', HalfWidth
1008 # # print 'HalfWidth ', HalfWidth
1010 # # print 'Maximun ', Maximun
1009 # # print 'Maximun ', Maximun
1011 # # print 'eMinus1 ', eMinus1
1010 # # print 'eMinus1 ', eMinus1
1012 # # print 'Rangpos ', Rangpos
1011 # # print 'Rangpos ', Rangpos
1013 # # print 'GaussCenter ',GaussCenter
1012 # # print 'GaussCenter ',GaussCenter
1014 # # print 'E01 ',E01
1013 # # print 'E01 ',E01
1015 # # print 'N01 ',N01
1014 # # print 'N01 ',N01
1016 # # print 'E02 ',E02
1015 # # print 'E02 ',E02
1017 # # print 'N02 ',N02
1016 # # print 'N02 ',N02
1018 # # print 'E12 ',E12
1017 # # print 'E12 ',E12
1019 # # print 'N12 ',N12
1018 # # print 'N12 ',N12
1020 # #print 'self.dataOut.velocityX ', self.dataOut.velocityX
1019 # #print 'self.dataOut.velocityX ', self.dataOut.velocityX
1021 # # print 'Fij ', Fij
1020 # # print 'Fij ', Fij
1022 # # print 'cC ', cC
1021 # # print 'cC ', cC
1023 # # print 'cF ', cF
1022 # # print 'cF ', cF
1024 # # print 'cG ', cG
1023 # # print 'cG ', cG
1025 # # print 'cA ', cA
1024 # # print 'cA ', cA
1026 # # print 'cB ', cB
1025 # # print 'cB ', cB
1027 # # print 'cH ', cH
1026 # # print 'cH ', cH
1028 # # print 'Vx ', Vx
1027 # # print 'Vx ', Vx
1029 # # print 'Vy ', Vy
1028 # # print 'Vy ', Vy
1030 # # print 'Vmag ', Vmag
1029 # # print 'Vmag ', Vmag
1031 # # print 'Vang ', Vang*180/numpy.pi
1030 # # print 'Vang ', Vang*180/numpy.pi
1032 # # print 'PhaseSlope ',PhaseSlope[0]
1031 # # print 'PhaseSlope ',PhaseSlope[0]
1033 # # print 'PhaseSlope ',PhaseSlope[1]
1032 # # print 'PhaseSlope ',PhaseSlope[1]
1034 # # print 'PhaseSlope ',PhaseSlope[2]
1033 # # print 'PhaseSlope ',PhaseSlope[2]
1035 # # print '********************************************'
1034 # # print '********************************************'
1036 # #print 'data_output',shape(self.dataOut.velocityX), shape(self.dataOut.velocityY)
1035 # #print 'data_output',shape(self.dataOut.velocityX), shape(self.dataOut.velocityY)
1037 #
1036 #
1038 # #print 'self.dataOut.velocityX', len(self.dataOut.velocityX)
1037 # #print 'self.dataOut.velocityX', len(self.dataOut.velocityX)
1039 # #print 'self.dataOut.velocityY', len(self.dataOut.velocityY)
1038 # #print 'self.dataOut.velocityY', len(self.dataOut.velocityY)
1040 # #print 'self.dataOut.velocityV', self.dataOut.velocityV
1039 # #print 'self.dataOut.velocityV', self.dataOut.velocityV
1041 #
1040 #
1042 # self.data_output[0]=numpy.array(self.dataOut.velocityX)
1041 # self.data_output[0]=numpy.array(self.dataOut.velocityX)
1043 # self.data_output[1]=numpy.array(self.dataOut.velocityY)
1042 # self.data_output[1]=numpy.array(self.dataOut.velocityY)
1044 # self.data_output[2]=numpy.array(self.dataOut.velocityV)
1043 # self.data_output[2]=numpy.array(self.dataOut.velocityV)
1045 #
1044 #
1046 # prin= self.data_output[0][~numpy.isnan(self.data_output[0])]
1045 # prin= self.data_output[0][~numpy.isnan(self.data_output[0])]
1047 # print ' '
1046 # print ' '
1048 # print 'VmagAverage',numpy.mean(prin)
1047 # print 'VmagAverage',numpy.mean(prin)
1049 # print ' '
1048 # print ' '
1050 # # plt.figure(5)
1049 # # plt.figure(5)
1051 # # plt.subplot(211)
1050 # # plt.subplot(211)
1052 # # plt.plot(self.dataOut.velocityX,'yo:')
1051 # # plt.plot(self.dataOut.velocityX,'yo:')
1053 # # plt.subplot(212)
1052 # # plt.subplot(212)
1054 # # plt.plot(self.dataOut.velocityY,'yo:')
1053 # # plt.plot(self.dataOut.velocityY,'yo:')
1055 #
1054 #
1056 # # plt.figure(1)
1055 # # plt.figure(1)
1057 # # # plt.subplot(121)
1056 # # # plt.subplot(121)
1058 # # # plt.plot(xFrec,ySamples[0],'k',label='Ch0')
1057 # # # plt.plot(xFrec,ySamples[0],'k',label='Ch0')
1059 # # # plt.plot(xFrec,ySamples[1],'g',label='Ch1')
1058 # # # plt.plot(xFrec,ySamples[1],'g',label='Ch1')
1060 # # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1059 # # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1061 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1060 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1062 # # # plt.legend()
1061 # # # plt.legend()
1063 # # plt.title('DATOS A ALTURA DE 2850 METROS')
1062 # # plt.title('DATOS A ALTURA DE 2850 METROS')
1064 # #
1063 # #
1065 # # plt.xlabel('Frecuencia (KHz)')
1064 # # plt.xlabel('Frecuencia (KHz)')
1066 # # plt.ylabel('Magnitud')
1065 # # plt.ylabel('Magnitud')
1067 # # # plt.subplot(122)
1066 # # # plt.subplot(122)
1068 # # # plt.title('Fit for Time Constant')
1067 # # # plt.title('Fit for Time Constant')
1069 # # #plt.plot(xFrec,zline)
1068 # # #plt.plot(xFrec,zline)
1070 # # #plt.plot(xFrec,SmoothSPC,'g')
1069 # # #plt.plot(xFrec,SmoothSPC,'g')
1071 # # plt.plot(xFrec,FactNorm)
1070 # # plt.plot(xFrec,FactNorm)
1072 # # plt.axis([-4, 4, 0, 0.15])
1071 # # plt.axis([-4, 4, 0, 0.15])
1073 # # # plt.xlabel('SelfSpectra KHz')
1072 # # # plt.xlabel('SelfSpectra KHz')
1074 # #
1073 # #
1075 # # plt.figure(10)
1074 # # plt.figure(10)
1076 # # # plt.subplot(121)
1075 # # # plt.subplot(121)
1077 # # plt.plot(xFrec,ySamples[0],'b',label='Ch0')
1076 # # plt.plot(xFrec,ySamples[0],'b',label='Ch0')
1078 # # plt.plot(xFrec,ySamples[1],'y',label='Ch1')
1077 # # plt.plot(xFrec,ySamples[1],'y',label='Ch1')
1079 # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1078 # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1080 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1079 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1081 # # plt.legend()
1080 # # plt.legend()
1082 # # plt.title('SELFSPECTRA EN CANALES')
1081 # # plt.title('SELFSPECTRA EN CANALES')
1083 # #
1082 # #
1084 # # plt.xlabel('Frecuencia (KHz)')
1083 # # plt.xlabel('Frecuencia (KHz)')
1085 # # plt.ylabel('Magnitud')
1084 # # plt.ylabel('Magnitud')
1086 # # # plt.subplot(122)
1085 # # # plt.subplot(122)
1087 # # # plt.title('Fit for Time Constant')
1086 # # # plt.title('Fit for Time Constant')
1088 # # #plt.plot(xFrec,zline)
1087 # # #plt.plot(xFrec,zline)
1089 # # #plt.plot(xFrec,SmoothSPC,'g')
1088 # # #plt.plot(xFrec,SmoothSPC,'g')
1090 # # # plt.plot(xFrec,FactNorm)
1089 # # # plt.plot(xFrec,FactNorm)
1091 # # # plt.axis([-4, 4, 0, 0.15])
1090 # # # plt.axis([-4, 4, 0, 0.15])
1092 # # # plt.xlabel('SelfSpectra KHz')
1091 # # # plt.xlabel('SelfSpectra KHz')
1093 # #
1092 # #
1094 # # plt.figure(9)
1093 # # plt.figure(9)
1095 # #
1094 # #
1096 # #
1095 # #
1097 # # plt.title('DATOS SUAVIZADOS')
1096 # # plt.title('DATOS SUAVIZADOS')
1098 # # plt.xlabel('Frecuencia (KHz)')
1097 # # plt.xlabel('Frecuencia (KHz)')
1099 # # plt.ylabel('Magnitud')
1098 # # plt.ylabel('Magnitud')
1100 # # plt.plot(xFrec,SmoothSPC,'g')
1099 # # plt.plot(xFrec,SmoothSPC,'g')
1101 # #
1100 # #
1102 # # #plt.plot(xFrec,FactNorm)
1101 # # #plt.plot(xFrec,FactNorm)
1103 # # plt.axis([-4, 4, 0, 0.15])
1102 # # plt.axis([-4, 4, 0, 0.15])
1104 # # # plt.xlabel('SelfSpectra KHz')
1103 # # # plt.xlabel('SelfSpectra KHz')
1105 # # #
1104 # # #
1106 # # plt.figure(2)
1105 # # plt.figure(2)
1107 # # # #plt.subplot(121)
1106 # # # #plt.subplot(121)
1108 # # plt.plot(xFrec,yMean,'r',label='Mean SelfSpectra')
1107 # # plt.plot(xFrec,yMean,'r',label='Mean SelfSpectra')
1109 # # plt.plot(xFrec,FitGauss,'yo:',label='Ajuste Gaussiano')
1108 # # plt.plot(xFrec,FitGauss,'yo:',label='Ajuste Gaussiano')
1110 # # # plt.plot(xFrec[Rangpos],FitGauss[Find(FitGauss,min(FitGauss, key=lambda value:abs(value-Maximun*0.1)))],'bo')
1109 # # # plt.plot(xFrec[Rangpos],FitGauss[Find(FitGauss,min(FitGauss, key=lambda value:abs(value-Maximun*0.1)))],'bo')
1111 # # # #plt.plot(xFrec,phase)
1110 # # # #plt.plot(xFrec,phase)
1112 # # # plt.xlabel('Suavizado, promediado KHz')
1111 # # # plt.xlabel('Suavizado, promediado KHz')
1113 # # plt.title('SELFSPECTRA PROMEDIADO')
1112 # # plt.title('SELFSPECTRA PROMEDIADO')
1114 # # # #plt.subplot(122)
1113 # # # #plt.subplot(122)
1115 # # # #plt.plot(xSamples,zline)
1114 # # # #plt.plot(xSamples,zline)
1116 # # plt.xlabel('Frecuencia (KHz)')
1115 # # plt.xlabel('Frecuencia (KHz)')
1117 # # plt.ylabel('Magnitud')
1116 # # plt.ylabel('Magnitud')
1118 # # plt.legend()
1117 # # plt.legend()
1119 # # #
1118 # # #
1120 # # # plt.figure(3)
1119 # # # plt.figure(3)
1121 # # # plt.subplot(311)
1120 # # # plt.subplot(311)
1122 # # # #plt.plot(xFrec,phase[0])
1121 # # # #plt.plot(xFrec,phase[0])
1123 # # # plt.plot(xFrec,phase[0],'g')
1122 # # # plt.plot(xFrec,phase[0],'g')
1124 # # # plt.subplot(312)
1123 # # # plt.subplot(312)
1125 # # # plt.plot(xFrec,phase[1],'g')
1124 # # # plt.plot(xFrec,phase[1],'g')
1126 # # # plt.subplot(313)
1125 # # # plt.subplot(313)
1127 # # # plt.plot(xFrec,phase[2],'g')
1126 # # # plt.plot(xFrec,phase[2],'g')
1128 # # # #plt.plot(xFrec,phase[2])
1127 # # # #plt.plot(xFrec,phase[2])
1129 # # #
1128 # # #
1130 # # # plt.figure(4)
1129 # # # plt.figure(4)
1131 # # #
1130 # # #
1132 # # # plt.plot(xSamples,coherence[0],'b')
1131 # # # plt.plot(xSamples,coherence[0],'b')
1133 # # # plt.plot(xSamples,coherence[1],'r')
1132 # # # plt.plot(xSamples,coherence[1],'r')
1134 # # # plt.plot(xSamples,coherence[2],'g')
1133 # # # plt.plot(xSamples,coherence[2],'g')
1135 # # plt.show()
1134 # # plt.show()
1136 # # #
1135 # # #
1137 # # # plt.clf()
1136 # # # plt.clf()
1138 # # # plt.cla()
1137 # # # plt.cla()
1139 # # # plt.close()
1138 # # # plt.close()
1140 #
1139 #
1141 # print ' '
1140 # print ' '
1142
1141
1143
1142
1144
1143
1145 self.BlockCounter+=2
1144 self.BlockCounter+=2
1146
1145
1147 else:
1146 else:
1148 self.fileSelector+=1
1147 self.fileSelector+=1
1149 self.BlockCounter=0
1148 self.BlockCounter=0
1150 print "Next File"
1149 print "Next File"
1151
1150
1152
1151
1153
1152
1154 class BLTRWriter(ProcessingUnit):
1153
1155 '''
1156 classdocs
1157 '''
1158
1159 def __init__(self):
1160 '''
1161 Constructor
1162 '''
1163 self.dataOut = None
1164
1165 self.isConfig = False
1166
1167 def setup(self, dataIn, path, blocksPerFile, set=0, ext=None):
1168 '''
1169 In this method we should set all initial parameters.
1170
1171 Input:
1172 dataIn : Input data will also be outputa data
1173
1174 '''
1175 self.dataOut = dataIn
1176
1177 self.isConfig = True
1178
1179 return
1180
1181 def run(self, dataIn, **kwargs):
1182 '''
1183 This method will be called many times so here you should put all your code
1184
1185 Inputs:
1186
1187 dataIn : object with the data
1188
1189 '''
1190
1191 if not self.isConfig:
1192 self.setup(dataIn, **kwargs)
1193
1154
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,804 +1,803
1 import os, sys
1 import os, sys
2 import glob
2 import glob
3 import fnmatch
3 import fnmatch
4 import datetime
4 import datetime
5 import time
5 import time
6 import re
6 import re
7 import h5py
7 import h5py
8 import numpy
8 import numpy
9 import matplotlib.pyplot as plt
9 import matplotlib.pyplot as plt
10
10
11 import pylab as plb
11 import pylab as plb
12 from scipy.optimize import curve_fit
12 from scipy.optimize import curve_fit
13 from scipy import asarray as ar,exp
13 from scipy import asarray as ar,exp
14 from scipy import stats
14 from scipy import stats
15
15
16 from duplicity.path import Path
17 from numpy.ma.core import getdata
16 from numpy.ma.core import getdata
18
17
19 SPEED_OF_LIGHT = 299792458
18 SPEED_OF_LIGHT = 299792458
20 SPEED_OF_LIGHT = 3e8
19 SPEED_OF_LIGHT = 3e8
21
20
22 try:
21 try:
23 from gevent import sleep
22 from gevent import sleep
24 except:
23 except:
25 from time import sleep
24 from time import sleep
26
25
27 from schainpy.model.data.jrodata import Spectra
26 from schainpy.model.data.jrodata import Spectra
28 #from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader
27 #from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader
29 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
28 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
30 #from schainpy.model.io.jroIO_bltr import BLTRReader
29 #from schainpy.model.io.jroIO_bltr import BLTRReader
31 from numpy import imag, shape, NaN, empty
30 from numpy import imag, shape, NaN, empty
32
31
33
32
34
33
35 class Header(object):
34 class Header(object):
36
35
37 def __init__(self):
36 def __init__(self):
38 raise NotImplementedError
37 raise NotImplementedError
39
38
40
39
41 def read(self):
40 def read(self):
42
41
43 raise NotImplementedError
42 raise NotImplementedError
44
43
45 def write(self):
44 def write(self):
46
45
47 raise NotImplementedError
46 raise NotImplementedError
48
47
49 def printInfo(self):
48 def printInfo(self):
50
49
51 message = "#"*50 + "\n"
50 message = "#"*50 + "\n"
52 message += self.__class__.__name__.upper() + "\n"
51 message += self.__class__.__name__.upper() + "\n"
53 message += "#"*50 + "\n"
52 message += "#"*50 + "\n"
54
53
55 keyList = self.__dict__.keys()
54 keyList = self.__dict__.keys()
56 keyList.sort()
55 keyList.sort()
57
56
58 for key in keyList:
57 for key in keyList:
59 message += "%s = %s" %(key, self.__dict__[key]) + "\n"
58 message += "%s = %s" %(key, self.__dict__[key]) + "\n"
60
59
61 if "size" not in keyList:
60 if "size" not in keyList:
62 attr = getattr(self, "size")
61 attr = getattr(self, "size")
63
62
64 if attr:
63 if attr:
65 message += "%s = %s" %("size", attr) + "\n"
64 message += "%s = %s" %("size", attr) + "\n"
66
65
67 #print message
66 #print message
68
67
69
68
70 FILE_HEADER = numpy.dtype([ #HEADER 1024bytes
69 FILE_HEADER = numpy.dtype([ #HEADER 1024bytes
71 ('Hname','a32'), #Original file name
70 ('Hname','a32'), #Original file name
72 ('Htime',numpy.str_,32), #Date and time when the file was created
71 ('Htime',numpy.str_,32), #Date and time when the file was created
73 ('Hoper',numpy.str_,64), #Name of operator who created the file
72 ('Hoper',numpy.str_,64), #Name of operator who created the file
74 ('Hplace',numpy.str_,128), #Place where the measurements was carried out
73 ('Hplace',numpy.str_,128), #Place where the measurements was carried out
75 ('Hdescr',numpy.str_,256), #Description of measurements
74 ('Hdescr',numpy.str_,256), #Description of measurements
76 ('Hdummy',numpy.str_,512), #Reserved space
75 ('Hdummy',numpy.str_,512), #Reserved space
77 #Main chunk 8bytes
76 #Main chunk 8bytes
78 ('Msign',numpy.str_,4), #Main chunk signature FZKF or NUIG
77 ('Msign',numpy.str_,4), #Main chunk signature FZKF or NUIG
79 ('MsizeData','<i4'), #Size of data block main chunk
78 ('MsizeData','<i4'), #Size of data block main chunk
80 #Processing DSP parameters 36bytes
79 #Processing DSP parameters 36bytes
81 ('PPARsign',numpy.str_,4), #PPAR signature
80 ('PPARsign',numpy.str_,4), #PPAR signature
82 ('PPARsize','<i4'), #PPAR size of block
81 ('PPARsize','<i4'), #PPAR size of block
83 ('PPARprf','<i4'), #Pulse repetition frequency
82 ('PPARprf','<i4'), #Pulse repetition frequency
84 ('PPARpdr','<i4'), #Pulse duration
83 ('PPARpdr','<i4'), #Pulse duration
85 ('PPARsft','<i4'), #FFT length
84 ('PPARsft','<i4'), #FFT length
86 ('PPARavc','<i4'), #Number of spectral (in-coherent) averages
85 ('PPARavc','<i4'), #Number of spectral (in-coherent) averages
87 ('PPARihp','<i4'), #Number of lowest range gate for moment estimation
86 ('PPARihp','<i4'), #Number of lowest range gate for moment estimation
88 ('PPARchg','<i4'), #Count for gates for moment estimation
87 ('PPARchg','<i4'), #Count for gates for moment estimation
89 ('PPARpol','<i4'), #switch on/off polarimetric measurements. Should be 1.
88 ('PPARpol','<i4'), #switch on/off polarimetric measurements. Should be 1.
90 #Service DSP parameters 112bytes
89 #Service DSP parameters 112bytes
91 ('SPARatt','<i4'), #STC attenuation on the lowest ranges on/off
90 ('SPARatt','<i4'), #STC attenuation on the lowest ranges on/off
92 ('SPARtx','<i4'), #OBSOLETE
91 ('SPARtx','<i4'), #OBSOLETE
93 ('SPARaddGain0','<f4'), #OBSOLETE
92 ('SPARaddGain0','<f4'), #OBSOLETE
94 ('SPARaddGain1','<f4'), #OBSOLETE
93 ('SPARaddGain1','<f4'), #OBSOLETE
95 ('SPARwnd','<i4'), #Debug only. It normal mode it is 0.
94 ('SPARwnd','<i4'), #Debug only. It normal mode it is 0.
96 ('SPARpos','<i4'), #Delay between sync pulse and tx pulse for phase corr, ns
95 ('SPARpos','<i4'), #Delay between sync pulse and tx pulse for phase corr, ns
97 ('SPARadd','<i4'), #"add to pulse" to compensate for delay between the leading edge of driver pulse and envelope of the RF signal.
96 ('SPARadd','<i4'), #"add to pulse" to compensate for delay between the leading edge of driver pulse and envelope of the RF signal.
98 ('SPARlen','<i4'), #Time for measuring txn pulse phase. OBSOLETE
97 ('SPARlen','<i4'), #Time for measuring txn pulse phase. OBSOLETE
99 ('SPARcal','<i4'), #OBSOLETE
98 ('SPARcal','<i4'), #OBSOLETE
100 ('SPARnos','<i4'), #OBSOLETE
99 ('SPARnos','<i4'), #OBSOLETE
101 ('SPARof0','<i4'), #detection threshold
100 ('SPARof0','<i4'), #detection threshold
102 ('SPARof1','<i4'), #OBSOLETE
101 ('SPARof1','<i4'), #OBSOLETE
103 ('SPARswt','<i4'), #2nd moment estimation threshold
102 ('SPARswt','<i4'), #2nd moment estimation threshold
104 ('SPARsum','<i4'), #OBSOLETE
103 ('SPARsum','<i4'), #OBSOLETE
105 ('SPARosc','<i4'), #flag Oscillosgram mode
104 ('SPARosc','<i4'), #flag Oscillosgram mode
106 ('SPARtst','<i4'), #OBSOLETE
105 ('SPARtst','<i4'), #OBSOLETE
107 ('SPARcor','<i4'), #OBSOLETE
106 ('SPARcor','<i4'), #OBSOLETE
108 ('SPARofs','<i4'), #OBSOLETE
107 ('SPARofs','<i4'), #OBSOLETE
109 ('SPARhsn','<i4'), #Hildebrand div noise detection on noise gate
108 ('SPARhsn','<i4'), #Hildebrand div noise detection on noise gate
110 ('SPARhsa','<f4'), #Hildebrand div noise detection on all gates
109 ('SPARhsa','<f4'), #Hildebrand div noise detection on all gates
111 ('SPARcalibPow_M','<f4'), #OBSOLETE
110 ('SPARcalibPow_M','<f4'), #OBSOLETE
112 ('SPARcalibSNR_M','<f4'), #OBSOLETE
111 ('SPARcalibSNR_M','<f4'), #OBSOLETE
113 ('SPARcalibPow_S','<f4'), #OBSOLETE
112 ('SPARcalibPow_S','<f4'), #OBSOLETE
114 ('SPARcalibSNR_S','<f4'), #OBSOLETE
113 ('SPARcalibSNR_S','<f4'), #OBSOLETE
115 ('SPARrawGate1','<i4'), #Lowest range gate for spectra saving Raw_Gate1 >=5
114 ('SPARrawGate1','<i4'), #Lowest range gate for spectra saving Raw_Gate1 >=5
116 ('SPARrawGate2','<i4'), #Number of range gates with atmospheric signal
115 ('SPARrawGate2','<i4'), #Number of range gates with atmospheric signal
117 ('SPARraw','<i4'), #flag - IQ or spectra saving on/off
116 ('SPARraw','<i4'), #flag - IQ or spectra saving on/off
118 ('SPARprc','<i4'),]) #flag - Moment estimation switched on/off
117 ('SPARprc','<i4'),]) #flag - Moment estimation switched on/off
119
118
120
119
121
120
122 class FileHeaderMIRA35c(Header):
121 class FileHeaderMIRA35c(Header):
123
122
124 def __init__(self):
123 def __init__(self):
125
124
126 self.Hname= None
125 self.Hname= None
127 self.Htime= None
126 self.Htime= None
128 self.Hoper= None
127 self.Hoper= None
129 self.Hplace= None
128 self.Hplace= None
130 self.Hdescr= None
129 self.Hdescr= None
131 self.Hdummy= None
130 self.Hdummy= None
132
131
133 self.Msign=None
132 self.Msign=None
134 self.MsizeData=None
133 self.MsizeData=None
135
134
136 self.PPARsign=None
135 self.PPARsign=None
137 self.PPARsize=None
136 self.PPARsize=None
138 self.PPARprf=None
137 self.PPARprf=None
139 self.PPARpdr=None
138 self.PPARpdr=None
140 self.PPARsft=None
139 self.PPARsft=None
141 self.PPARavc=None
140 self.PPARavc=None
142 self.PPARihp=None
141 self.PPARihp=None
143 self.PPARchg=None
142 self.PPARchg=None
144 self.PPARpol=None
143 self.PPARpol=None
145 #Service DSP parameters
144 #Service DSP parameters
146 self.SPARatt=None
145 self.SPARatt=None
147 self.SPARtx=None
146 self.SPARtx=None
148 self.SPARaddGain0=None
147 self.SPARaddGain0=None
149 self.SPARaddGain1=None
148 self.SPARaddGain1=None
150 self.SPARwnd=None
149 self.SPARwnd=None
151 self.SPARpos=None
150 self.SPARpos=None
152 self.SPARadd=None
151 self.SPARadd=None
153 self.SPARlen=None
152 self.SPARlen=None
154 self.SPARcal=None
153 self.SPARcal=None
155 self.SPARnos=None
154 self.SPARnos=None
156 self.SPARof0=None
155 self.SPARof0=None
157 self.SPARof1=None
156 self.SPARof1=None
158 self.SPARswt=None
157 self.SPARswt=None
159 self.SPARsum=None
158 self.SPARsum=None
160 self.SPARosc=None
159 self.SPARosc=None
161 self.SPARtst=None
160 self.SPARtst=None
162 self.SPARcor=None
161 self.SPARcor=None
163 self.SPARofs=None
162 self.SPARofs=None
164 self.SPARhsn=None
163 self.SPARhsn=None
165 self.SPARhsa=None
164 self.SPARhsa=None
166 self.SPARcalibPow_M=None
165 self.SPARcalibPow_M=None
167 self.SPARcalibSNR_M=None
166 self.SPARcalibSNR_M=None
168 self.SPARcalibPow_S=None
167 self.SPARcalibPow_S=None
169 self.SPARcalibSNR_S=None
168 self.SPARcalibSNR_S=None
170 self.SPARrawGate1=None
169 self.SPARrawGate1=None
171 self.SPARrawGate2=None
170 self.SPARrawGate2=None
172 self.SPARraw=None
171 self.SPARraw=None
173 self.SPARprc=None
172 self.SPARprc=None
174
173
175 self.FHsize=1180
174 self.FHsize=1180
176
175
177 def FHread(self, fp):
176 def FHread(self, fp):
178
177
179 header = numpy.fromfile(fp, FILE_HEADER,1)
178 header = numpy.fromfile(fp, FILE_HEADER,1)
180 ''' numpy.fromfile(file, dtype, count, sep='')
179 ''' numpy.fromfile(file, dtype, count, sep='')
181 file : file or str
180 file : file or str
182 Open file object or filename.
181 Open file object or filename.
183
182
184 dtype : data-type
183 dtype : data-type
185 Data type of the returned array. For binary files, it is used to determine
184 Data type of the returned array. For binary files, it is used to determine
186 the size and byte-order of the items in the file.
185 the size and byte-order of the items in the file.
187
186
188 count : int
187 count : int
189 Number of items to read. -1 means all items (i.e., the complete file).
188 Number of items to read. -1 means all items (i.e., the complete file).
190
189
191 sep : str
190 sep : str
192 Separator between items if file is a text file. Empty ("") separator means
191 Separator between items if file is a text file. Empty ("") separator means
193 the file should be treated as binary. Spaces (" ") in the separator match zero
192 the file should be treated as binary. Spaces (" ") in the separator match zero
194 or more whitespace characters. A separator consisting only of spaces must match
193 or more whitespace characters. A separator consisting only of spaces must match
195 at least one whitespace.
194 at least one whitespace.
196
195
197 '''
196 '''
198
197
199
198
200 self.Hname= str(header['Hname'][0])
199 self.Hname= str(header['Hname'][0])
201 self.Htime= str(header['Htime'][0])
200 self.Htime= str(header['Htime'][0])
202 self.Hoper= str(header['Hoper'][0])
201 self.Hoper= str(header['Hoper'][0])
203 self.Hplace= str(header['Hplace'][0])
202 self.Hplace= str(header['Hplace'][0])
204 self.Hdescr= str(header['Hdescr'][0])
203 self.Hdescr= str(header['Hdescr'][0])
205 self.Hdummy= str(header['Hdummy'][0])
204 self.Hdummy= str(header['Hdummy'][0])
206 #1024
205 #1024
207
206
208 self.Msign=str(header['Msign'][0])
207 self.Msign=str(header['Msign'][0])
209 self.MsizeData=header['MsizeData'][0]
208 self.MsizeData=header['MsizeData'][0]
210 #8
209 #8
211
210
212 self.PPARsign=str(header['PPARsign'][0])
211 self.PPARsign=str(header['PPARsign'][0])
213 self.PPARsize=header['PPARsize'][0]
212 self.PPARsize=header['PPARsize'][0]
214 self.PPARprf=header['PPARprf'][0]
213 self.PPARprf=header['PPARprf'][0]
215 self.PPARpdr=header['PPARpdr'][0]
214 self.PPARpdr=header['PPARpdr'][0]
216 self.PPARsft=header['PPARsft'][0]
215 self.PPARsft=header['PPARsft'][0]
217 self.PPARavc=header['PPARavc'][0]
216 self.PPARavc=header['PPARavc'][0]
218 self.PPARihp=header['PPARihp'][0]
217 self.PPARihp=header['PPARihp'][0]
219 self.PPARchg=header['PPARchg'][0]
218 self.PPARchg=header['PPARchg'][0]
220 self.PPARpol=header['PPARpol'][0]
219 self.PPARpol=header['PPARpol'][0]
221 #Service DSP parameters
220 #Service DSP parameters
222 #36
221 #36
223
222
224 self.SPARatt=header['SPARatt'][0]
223 self.SPARatt=header['SPARatt'][0]
225 self.SPARtx=header['SPARtx'][0]
224 self.SPARtx=header['SPARtx'][0]
226 self.SPARaddGain0=header['SPARaddGain0'][0]
225 self.SPARaddGain0=header['SPARaddGain0'][0]
227 self.SPARaddGain1=header['SPARaddGain1'][0]
226 self.SPARaddGain1=header['SPARaddGain1'][0]
228 self.SPARwnd=header['SPARwnd'][0]
227 self.SPARwnd=header['SPARwnd'][0]
229 self.SPARpos=header['SPARpos'][0]
228 self.SPARpos=header['SPARpos'][0]
230 self.SPARadd=header['SPARadd'][0]
229 self.SPARadd=header['SPARadd'][0]
231 self.SPARlen=header['SPARlen'][0]
230 self.SPARlen=header['SPARlen'][0]
232 self.SPARcal=header['SPARcal'][0]
231 self.SPARcal=header['SPARcal'][0]
233 self.SPARnos=header['SPARnos'][0]
232 self.SPARnos=header['SPARnos'][0]
234 self.SPARof0=header['SPARof0'][0]
233 self.SPARof0=header['SPARof0'][0]
235 self.SPARof1=header['SPARof1'][0]
234 self.SPARof1=header['SPARof1'][0]
236 self.SPARswt=header['SPARswt'][0]
235 self.SPARswt=header['SPARswt'][0]
237 self.SPARsum=header['SPARsum'][0]
236 self.SPARsum=header['SPARsum'][0]
238 self.SPARosc=header['SPARosc'][0]
237 self.SPARosc=header['SPARosc'][0]
239 self.SPARtst=header['SPARtst'][0]
238 self.SPARtst=header['SPARtst'][0]
240 self.SPARcor=header['SPARcor'][0]
239 self.SPARcor=header['SPARcor'][0]
241 self.SPARofs=header['SPARofs'][0]
240 self.SPARofs=header['SPARofs'][0]
242 self.SPARhsn=header['SPARhsn'][0]
241 self.SPARhsn=header['SPARhsn'][0]
243 self.SPARhsa=header['SPARhsa'][0]
242 self.SPARhsa=header['SPARhsa'][0]
244 self.SPARcalibPow_M=header['SPARcalibPow_M'][0]
243 self.SPARcalibPow_M=header['SPARcalibPow_M'][0]
245 self.SPARcalibSNR_M=header['SPARcalibSNR_M'][0]
244 self.SPARcalibSNR_M=header['SPARcalibSNR_M'][0]
246 self.SPARcalibPow_S=header['SPARcalibPow_S'][0]
245 self.SPARcalibPow_S=header['SPARcalibPow_S'][0]
247 self.SPARcalibSNR_S=header['SPARcalibSNR_S'][0]
246 self.SPARcalibSNR_S=header['SPARcalibSNR_S'][0]
248 self.SPARrawGate1=header['SPARrawGate1'][0]
247 self.SPARrawGate1=header['SPARrawGate1'][0]
249 self.SPARrawGate2=header['SPARrawGate2'][0]
248 self.SPARrawGate2=header['SPARrawGate2'][0]
250 self.SPARraw=header['SPARraw'][0]
249 self.SPARraw=header['SPARraw'][0]
251 self.SPARprc=header['SPARprc'][0]
250 self.SPARprc=header['SPARprc'][0]
252 #112
251 #112
253 #1180
252 #1180
254 #print 'Pointer fp header', fp.tell()
253 #print 'Pointer fp header', fp.tell()
255 #print ' '
254 #print ' '
256 #print 'SPARrawGate'
255 #print 'SPARrawGate'
257 #print self.SPARrawGate2 - self.SPARrawGate1
256 #print self.SPARrawGate2 - self.SPARrawGate1
258
257
259 #print ' '
258 #print ' '
260 #print 'Hname'
259 #print 'Hname'
261 #print self.Hname
260 #print self.Hname
262
261
263 #print ' '
262 #print ' '
264 #print 'Msign'
263 #print 'Msign'
265 #print self.Msign
264 #print self.Msign
266
265
267 def write(self, fp):
266 def write(self, fp):
268
267
269 headerTuple = (self.Hname,
268 headerTuple = (self.Hname,
270 self.Htime,
269 self.Htime,
271 self.Hoper,
270 self.Hoper,
272 self.Hplace,
271 self.Hplace,
273 self.Hdescr,
272 self.Hdescr,
274 self.Hdummy)
273 self.Hdummy)
275
274
276
275
277 header = numpy.array(headerTuple, FILE_HEADER)
276 header = numpy.array(headerTuple, FILE_HEADER)
278 # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)
277 # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)
279 header.tofile(fp)
278 header.tofile(fp)
280 ''' ndarray.tofile(fid, sep, format) Write array to a file as text or binary (default).
279 ''' ndarray.tofile(fid, sep, format) Write array to a file as text or binary (default).
281
280
282 fid : file or str
281 fid : file or str
283 An open file object, or a string containing a filename.
282 An open file object, or a string containing a filename.
284
283
285 sep : str
284 sep : str
286 Separator between array items for text output. If "" (empty), a binary file is written,
285 Separator between array items for text output. If "" (empty), a binary file is written,
287 equivalent to file.write(a.tobytes()).
286 equivalent to file.write(a.tobytes()).
288
287
289 format : str
288 format : str
290 Format string for text file output. Each entry in the array is formatted to text by
289 Format string for text file output. Each entry in the array is formatted to text by
291 first converting it to the closest Python type, and then using "format" % item.
290 first converting it to the closest Python type, and then using "format" % item.
292
291
293 '''
292 '''
294
293
295 return 1
294 return 1
296
295
297 SRVI_HEADER = numpy.dtype([
296 SRVI_HEADER = numpy.dtype([
298 ('SignatureSRVI1',numpy.str_,4),#
297 ('SignatureSRVI1',numpy.str_,4),#
299 ('SizeOfDataBlock1','<i4'),#
298 ('SizeOfDataBlock1','<i4'),#
300 ('DataBlockTitleSRVI1',numpy.str_,4),#
299 ('DataBlockTitleSRVI1',numpy.str_,4),#
301 ('SizeOfSRVI1','<i4'),])#
300 ('SizeOfSRVI1','<i4'),])#
302
301
303 class SRVIHeader(Header):
302 class SRVIHeader(Header):
304 def __init__(self, SignatureSRVI1=0, SizeOfDataBlock1=0, DataBlockTitleSRVI1=0, SizeOfSRVI1=0):
303 def __init__(self, SignatureSRVI1=0, SizeOfDataBlock1=0, DataBlockTitleSRVI1=0, SizeOfSRVI1=0):
305
304
306 self.SignatureSRVI1 = SignatureSRVI1
305 self.SignatureSRVI1 = SignatureSRVI1
307 self.SizeOfDataBlock1 = SizeOfDataBlock1
306 self.SizeOfDataBlock1 = SizeOfDataBlock1
308 self.DataBlockTitleSRVI1 = DataBlockTitleSRVI1
307 self.DataBlockTitleSRVI1 = DataBlockTitleSRVI1
309 self.SizeOfSRVI1 = SizeOfSRVI1
308 self.SizeOfSRVI1 = SizeOfSRVI1
310
309
311 self.SRVIHsize=16
310 self.SRVIHsize=16
312
311
313 def SRVIread(self, fp):
312 def SRVIread(self, fp):
314
313
315 header = numpy.fromfile(fp, SRVI_HEADER,1)
314 header = numpy.fromfile(fp, SRVI_HEADER,1)
316
315
317 self.SignatureSRVI1 = str(header['SignatureSRVI1'][0])
316 self.SignatureSRVI1 = str(header['SignatureSRVI1'][0])
318 self.SizeOfDataBlock1 = header['SizeOfDataBlock1'][0]
317 self.SizeOfDataBlock1 = header['SizeOfDataBlock1'][0]
319 self.DataBlockTitleSRVI1 = str(header['DataBlockTitleSRVI1'][0])
318 self.DataBlockTitleSRVI1 = str(header['DataBlockTitleSRVI1'][0])
320 self.SizeOfSRVI1 = header['SizeOfSRVI1'][0]
319 self.SizeOfSRVI1 = header['SizeOfSRVI1'][0]
321 #16
320 #16
322 print 'Pointer fp SRVIheader', fp.tell()
321 print 'Pointer fp SRVIheader', fp.tell()
323
322
324
323
325 SRVI_STRUCTURE = numpy.dtype([
324 SRVI_STRUCTURE = numpy.dtype([
326 ('frame_cnt','<u4'),#
325 ('frame_cnt','<u4'),#
327 ('time_t','<u4'), #
326 ('time_t','<u4'), #
328 ('tpow','<f4'), #
327 ('tpow','<f4'), #
329 ('npw1','<f4'), #
328 ('npw1','<f4'), #
330 ('npw2','<f4'), #
329 ('npw2','<f4'), #
331 ('cpw1','<f4'), #
330 ('cpw1','<f4'), #
332 ('pcw2','<f4'), #
331 ('pcw2','<f4'), #
333 ('ps_err','<u4'), #
332 ('ps_err','<u4'), #
334 ('te_err','<u4'), #
333 ('te_err','<u4'), #
335 ('rc_err','<u4'), #
334 ('rc_err','<u4'), #
336 ('grs1','<u4'), #
335 ('grs1','<u4'), #
337 ('grs2','<u4'), #
336 ('grs2','<u4'), #
338 ('azipos','<f4'), #
337 ('azipos','<f4'), #
339 ('azivel','<f4'), #
338 ('azivel','<f4'), #
340 ('elvpos','<f4'), #
339 ('elvpos','<f4'), #
341 ('elvvel','<f4'), #
340 ('elvvel','<f4'), #
342 ('northAngle','<f4'), #
341 ('northAngle','<f4'), #
343 ('microsec','<u4'), #
342 ('microsec','<u4'), #
344 ('azisetvel','<f4'), #
343 ('azisetvel','<f4'), #
345 ('elvsetpos','<f4'), #
344 ('elvsetpos','<f4'), #
346 ('RadarConst','<f4'),]) #
345 ('RadarConst','<f4'),]) #
347
346
348
347
349
348
350
349
351 class RecordHeader(Header):
350 class RecordHeader(Header):
352
351
353
352
354 def __init__(self, frame_cnt=0, time_t= 0, tpow=0, npw1=0, npw2=0,
353 def __init__(self, frame_cnt=0, time_t= 0, tpow=0, npw1=0, npw2=0,
355 cpw1=0, pcw2=0, ps_err=0, te_err=0, rc_err=0, grs1=0,
354 cpw1=0, pcw2=0, ps_err=0, te_err=0, rc_err=0, grs1=0,
356 grs2=0, azipos=0, azivel=0, elvpos=0, elvvel=0, northangle=0,
355 grs2=0, azipos=0, azivel=0, elvpos=0, elvvel=0, northangle=0,
357 microsec=0, azisetvel=0, elvsetpos=0, RadarConst=0 , RecCounter=0, Off2StartNxtRec=0):
356 microsec=0, azisetvel=0, elvsetpos=0, RadarConst=0 , RecCounter=0, Off2StartNxtRec=0):
358
357
359
358
360 self.frame_cnt = frame_cnt
359 self.frame_cnt = frame_cnt
361 self.dwell = time_t
360 self.dwell = time_t
362 self.tpow = tpow
361 self.tpow = tpow
363 self.npw1 = npw1
362 self.npw1 = npw1
364 self.npw2 = npw2
363 self.npw2 = npw2
365 self.cpw1 = cpw1
364 self.cpw1 = cpw1
366 self.pcw2 = pcw2
365 self.pcw2 = pcw2
367 self.ps_err = ps_err
366 self.ps_err = ps_err
368 self.te_err = te_err
367 self.te_err = te_err
369 self.rc_err = rc_err
368 self.rc_err = rc_err
370 self.grs1 = grs1
369 self.grs1 = grs1
371 self.grs2 = grs2
370 self.grs2 = grs2
372 self.azipos = azipos
371 self.azipos = azipos
373 self.azivel = azivel
372 self.azivel = azivel
374 self.elvpos = elvpos
373 self.elvpos = elvpos
375 self.elvvel = elvvel
374 self.elvvel = elvvel
376 self.northAngle = northangle
375 self.northAngle = northangle
377 self.microsec = microsec
376 self.microsec = microsec
378 self.azisetvel = azisetvel
377 self.azisetvel = azisetvel
379 self.elvsetpos = elvsetpos
378 self.elvsetpos = elvsetpos
380 self.RadarConst = RadarConst
379 self.RadarConst = RadarConst
381 self.RHsize=84
380 self.RHsize=84
382 self.RecCounter = RecCounter
381 self.RecCounter = RecCounter
383 self.Off2StartNxtRec=Off2StartNxtRec
382 self.Off2StartNxtRec=Off2StartNxtRec
384
383
385 def RHread(self, fp):
384 def RHread(self, fp):
386
385
387 #startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file.
386 #startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file.
388
387
389 #OffRHeader= 1180 + self.RecCounter*(self.Off2StartNxtRec)
388 #OffRHeader= 1180 + self.RecCounter*(self.Off2StartNxtRec)
390 #startFp.seek(OffRHeader, os.SEEK_SET)
389 #startFp.seek(OffRHeader, os.SEEK_SET)
391
390
392 #print 'Posicion del bloque: ',OffRHeader
391 #print 'Posicion del bloque: ',OffRHeader
393
392
394 header = numpy.fromfile(fp,SRVI_STRUCTURE,1)
393 header = numpy.fromfile(fp,SRVI_STRUCTURE,1)
395
394
396 self.frame_cnt = header['frame_cnt'][0]#
395 self.frame_cnt = header['frame_cnt'][0]#
397 self.time_t = header['time_t'][0] #
396 self.time_t = header['time_t'][0] #
398 self.tpow = header['tpow'][0] #
397 self.tpow = header['tpow'][0] #
399 self.npw1 = header['npw1'][0] #
398 self.npw1 = header['npw1'][0] #
400 self.npw2 = header['npw2'][0] #
399 self.npw2 = header['npw2'][0] #
401 self.cpw1 = header['cpw1'][0] #
400 self.cpw1 = header['cpw1'][0] #
402 self.pcw2 = header['pcw2'][0] #
401 self.pcw2 = header['pcw2'][0] #
403 self.ps_err = header['ps_err'][0] #
402 self.ps_err = header['ps_err'][0] #
404 self.te_err = header['te_err'][0] #
403 self.te_err = header['te_err'][0] #
405 self.rc_err = header['rc_err'][0] #
404 self.rc_err = header['rc_err'][0] #
406 self.grs1 = header['grs1'][0] #
405 self.grs1 = header['grs1'][0] #
407 self.grs2 = header['grs2'][0] #
406 self.grs2 = header['grs2'][0] #
408 self.azipos = header['azipos'][0] #
407 self.azipos = header['azipos'][0] #
409 self.azivel = header['azivel'][0] #
408 self.azivel = header['azivel'][0] #
410 self.elvpos = header['elvpos'][0] #
409 self.elvpos = header['elvpos'][0] #
411 self.elvvel = header['elvvel'][0] #
410 self.elvvel = header['elvvel'][0] #
412 self.northAngle = header['northAngle'][0] #
411 self.northAngle = header['northAngle'][0] #
413 self.microsec = header['microsec'][0] #
412 self.microsec = header['microsec'][0] #
414 self.azisetvel = header['azisetvel'][0] #
413 self.azisetvel = header['azisetvel'][0] #
415 self.elvsetpos = header['elvsetpos'][0] #
414 self.elvsetpos = header['elvsetpos'][0] #
416 self.RadarConst = header['RadarConst'][0] #
415 self.RadarConst = header['RadarConst'][0] #
417 #84
416 #84
418
417
419 #print 'Pointer fp RECheader', fp.tell()
418 #print 'Pointer fp RECheader', fp.tell()
420
419
421 #self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz)
420 #self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz)
422
421
423 #self.RHsize = 180+20*self.nChannels
422 #self.RHsize = 180+20*self.nChannels
424 #self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4
423 #self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4
425 #print 'Datasize',self.Datasize
424 #print 'Datasize',self.Datasize
426 #endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
425 #endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
427
426
428 print '=============================================='
427 print '=============================================='
429
428
430 print '=============================================='
429 print '=============================================='
431
430
432
431
433 return 1
432 return 1
434
433
435 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader):
434 class MIRA35CReader (ProcessingUnit,FileHeaderMIRA35c,SRVIHeader,RecordHeader):
436
435
437 path = None
436 path = None
438 startDate = None
437 startDate = None
439 endDate = None
438 endDate = None
440 startTime = None
439 startTime = None
441 endTime = None
440 endTime = None
442 walk = None
441 walk = None
443 isConfig = False
442 isConfig = False
444
443
445
444
446 fileList= None
445 fileList= None
447
446
448 #metadata
447 #metadata
449 TimeZone= None
448 TimeZone= None
450 Interval= None
449 Interval= None
451 heightList= None
450 heightList= None
452
451
453 #data
452 #data
454 data= None
453 data= None
455 utctime= None
454 utctime= None
456
455
457
456
458
457
459 def __init__(self, **kwargs):
458 def __init__(self, **kwargs):
460
459
461 #Eliminar de la base la herencia
460 #Eliminar de la base la herencia
462 ProcessingUnit.__init__(self, **kwargs)
461 ProcessingUnit.__init__(self, **kwargs)
463 self.PointerReader = 0
462 self.PointerReader = 0
464 self.FileHeaderFlag = False
463 self.FileHeaderFlag = False
465 self.utc = None
464 self.utc = None
466 self.ext = ".zspca"
465 self.ext = ".zspca"
467 self.optchar = "P"
466 self.optchar = "P"
468 self.fpFile=None
467 self.fpFile=None
469 self.fp = None
468 self.fp = None
470 self.BlockCounter=0
469 self.BlockCounter=0
471 self.dtype = None
470 self.dtype = None
472 self.fileSizeByHeader = None
471 self.fileSizeByHeader = None
473 self.filenameList = []
472 self.filenameList = []
474 self.fileSelector = 0
473 self.fileSelector = 0
475 self.Off2StartNxtRec=0
474 self.Off2StartNxtRec=0
476 self.RecCounter=0
475 self.RecCounter=0
477 self.flagNoMoreFiles = 0
476 self.flagNoMoreFiles = 0
478 self.data_spc=None
477 self.data_spc=None
479 #self.data_cspc=None
478 #self.data_cspc=None
480 self.data_output=None
479 self.data_output=None
481 self.path = None
480 self.path = None
482 self.OffsetStartHeader=0
481 self.OffsetStartHeader=0
483 self.Off2StartData=0
482 self.Off2StartData=0
484 self.ipp = 0
483 self.ipp = 0
485 self.nFDTdataRecors=0
484 self.nFDTdataRecors=0
486 self.blocksize = 0
485 self.blocksize = 0
487 self.dataOut = Spectra()
486 self.dataOut = Spectra()
488 self.profileIndex = 1 #Always
487 self.profileIndex = 1 #Always
489 self.dataOut.flagNoData=False
488 self.dataOut.flagNoData=False
490 self.dataOut.nRdPairs = 0
489 self.dataOut.nRdPairs = 0
491 self.dataOut.pairsList = []
490 self.dataOut.pairsList = []
492 self.dataOut.data_spc=None
491 self.dataOut.data_spc=None
493
492
494 self.dataOut.normFactor=1
493 self.dataOut.normFactor=1
495 self.nextfileflag = True
494 self.nextfileflag = True
496 self.dataOut.RadarConst = 0
495 self.dataOut.RadarConst = 0
497 self.dataOut.HSDV = []
496 self.dataOut.HSDV = []
498 self.dataOut.NPW = []
497 self.dataOut.NPW = []
499 self.dataOut.COFA = []
498 self.dataOut.COFA = []
500 self.dataOut.noise = 0
499 self.dataOut.noise = 0
501
500
502
501
503 def Files2Read(self, fp):
502 def Files2Read(self, fp):
504 '''
503 '''
505 Function that indicates the number of .fdt files that exist in the folder to be read.
504 Function that indicates the number of .fdt files that exist in the folder to be read.
506 It also creates an organized list with the names of the files to read.
505 It also creates an organized list with the names of the files to read.
507 '''
506 '''
508 #self.__checkPath()
507 #self.__checkPath()
509
508
510 ListaData=os.listdir(fp) #Gets the list of files within the fp address
509 ListaData=os.listdir(fp) #Gets the list of files within the fp address
511 ListaData=sorted(ListaData) #Sort the list of files from least to largest by names
510 ListaData=sorted(ListaData) #Sort the list of files from least to largest by names
512 nFiles=0 #File Counter
511 nFiles=0 #File Counter
513 FileList=[] #A list is created that will contain the .fdt files
512 FileList=[] #A list is created that will contain the .fdt files
514 for IndexFile in ListaData :
513 for IndexFile in ListaData :
515 if '.zspca' in IndexFile and '.gz' not in IndexFile:
514 if '.zspca' in IndexFile and '.gz' not in IndexFile:
516 FileList.append(IndexFile)
515 FileList.append(IndexFile)
517 nFiles+=1
516 nFiles+=1
518
517
519 #print 'Files2Read'
518 #print 'Files2Read'
520 #print 'Existen '+str(nFiles)+' archivos .fdt'
519 #print 'Existen '+str(nFiles)+' archivos .fdt'
521
520
522 self.filenameList=FileList #List of files from least to largest by names
521 self.filenameList=FileList #List of files from least to largest by names
523
522
524
523
525 def run(self, **kwargs):
524 def run(self, **kwargs):
526 '''
525 '''
527 This method will be the one that will initiate the data entry, will be called constantly.
526 This method will be the one that will initiate the data entry, will be called constantly.
528 You should first verify that your Setup () is set up and then continue to acquire
527 You should first verify that your Setup () is set up and then continue to acquire
529 the data to be processed with getData ().
528 the data to be processed with getData ().
530 '''
529 '''
531 if not self.isConfig:
530 if not self.isConfig:
532 self.setup(**kwargs)
531 self.setup(**kwargs)
533 self.isConfig = True
532 self.isConfig = True
534
533
535 self.getData()
534 self.getData()
536
535
537
536
538 def setup(self, path=None,
537 def setup(self, path=None,
539 startDate=None,
538 startDate=None,
540 endDate=None,
539 endDate=None,
541 startTime=None,
540 startTime=None,
542 endTime=None,
541 endTime=None,
543 walk=True,
542 walk=True,
544 timezone='utc',
543 timezone='utc',
545 code = None,
544 code = None,
546 online=False,
545 online=False,
547 ReadMode=None, **kwargs):
546 ReadMode=None, **kwargs):
548
547
549 self.isConfig = True
548 self.isConfig = True
550
549
551 self.path=path
550 self.path=path
552 self.startDate=startDate
551 self.startDate=startDate
553 self.endDate=endDate
552 self.endDate=endDate
554 self.startTime=startTime
553 self.startTime=startTime
555 self.endTime=endTime
554 self.endTime=endTime
556 self.walk=walk
555 self.walk=walk
557 #self.ReadMode=int(ReadMode)
556 #self.ReadMode=int(ReadMode)
558
557
559 pass
558 pass
560
559
561
560
562 def getData(self):
561 def getData(self):
563 '''
562 '''
564 Before starting this function, you should check that there is still an unread file,
563 Before starting this function, you should check that there is still an unread file,
565 If there are still blocks to read or if the data block is empty.
564 If there are still blocks to read or if the data block is empty.
566
565
567 You should call the file "read".
566 You should call the file "read".
568
567
569 '''
568 '''
570
569
571 if self.flagNoMoreFiles:
570 if self.flagNoMoreFiles:
572 self.dataOut.flagNoData = True
571 self.dataOut.flagNoData = True
573 print 'NoData se vuelve true'
572 print 'NoData se vuelve true'
574 return 0
573 return 0
575
574
576 self.fp=self.path
575 self.fp=self.path
577 self.Files2Read(self.fp)
576 self.Files2Read(self.fp)
578 self.readFile(self.fp)
577 self.readFile(self.fp)
579
578
580 self.dataOut.data_spc = self.dataOut_spc#self.data_spc.copy()
579 self.dataOut.data_spc = self.dataOut_spc#self.data_spc.copy()
581 self.dataOut.RadarConst = self.RadarConst
580 self.dataOut.RadarConst = self.RadarConst
582 self.dataOut.data_output=self.data_output
581 self.dataOut.data_output=self.data_output
583 self.dataOut.noise = self.dataOut.getNoise()
582 self.dataOut.noise = self.dataOut.getNoise()
584 #print 'ACAAAAAA', self.dataOut.noise
583 #print 'ACAAAAAA', self.dataOut.noise
585 self.dataOut.data_spc = self.dataOut.data_spc+self.dataOut.noise
584 self.dataOut.data_spc = self.dataOut.data_spc+self.dataOut.noise
586 #print 'self.dataOut.noise',self.dataOut.noise
585 #print 'self.dataOut.noise',self.dataOut.noise
587
586
588
587
589 return self.dataOut.data_spc
588 return self.dataOut.data_spc
590
589
591
590
592 def readFile(self,fp):
591 def readFile(self,fp):
593 '''
592 '''
594 You must indicate if you are reading in Online or Offline mode and load the
593 You must indicate if you are reading in Online or Offline mode and load the
595 The parameters for this file reading mode.
594 The parameters for this file reading mode.
596
595
597 Then you must do 2 actions:
596 Then you must do 2 actions:
598
597
599 1. Get the BLTR FileHeader.
598 1. Get the BLTR FileHeader.
600 2. Start reading the first block.
599 2. Start reading the first block.
601 '''
600 '''
602
601
603 #The address of the folder is generated the name of the .fdt file that will be read
602 #The address of the folder is generated the name of the .fdt file that will be read
604 print "File: ",self.fileSelector+1
603 print "File: ",self.fileSelector+1
605
604
606 if self.fileSelector < len(self.filenameList):
605 if self.fileSelector < len(self.filenameList):
607
606
608 self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector])
607 self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector])
609
608
610 if self.nextfileflag==True:
609 if self.nextfileflag==True:
611 self.fp = open(self.fpFile,"rb")
610 self.fp = open(self.fpFile,"rb")
612 self.nextfileflag==False
611 self.nextfileflag==False
613
612
614 '''HERE STARTING THE FILE READING'''
613 '''HERE STARTING THE FILE READING'''
615
614
616
615
617 self.fheader = FileHeaderMIRA35c()
616 self.fheader = FileHeaderMIRA35c()
618 self.fheader.FHread(self.fp) #Bltr FileHeader Reading
617 self.fheader.FHread(self.fp) #Bltr FileHeader Reading
619
618
620
619
621 self.SPARrawGate1 = self.fheader.SPARrawGate1
620 self.SPARrawGate1 = self.fheader.SPARrawGate1
622 self.SPARrawGate2 = self.fheader.SPARrawGate2
621 self.SPARrawGate2 = self.fheader.SPARrawGate2
623 self.Num_Hei = self.SPARrawGate2 - self.SPARrawGate1
622 self.Num_Hei = self.SPARrawGate2 - self.SPARrawGate1
624 self.Num_Bins = self.fheader.PPARsft
623 self.Num_Bins = self.fheader.PPARsft
625 self.dataOut.nFFTPoints = self.fheader.PPARsft
624 self.dataOut.nFFTPoints = self.fheader.PPARsft
626
625
627
626
628 self.Num_inCoh = self.fheader.PPARavc
627 self.Num_inCoh = self.fheader.PPARavc
629 self.dataOut.PRF = self.fheader.PPARprf
628 self.dataOut.PRF = self.fheader.PPARprf
630 self.dataOut.frequency = 34.85*10**9
629 self.dataOut.frequency = 34.85*10**9
631 self.Lambda = SPEED_OF_LIGHT/self.dataOut.frequency
630 self.Lambda = SPEED_OF_LIGHT/self.dataOut.frequency
632 self.dataOut.ippSeconds= 1./float(self.dataOut.PRF)
631 self.dataOut.ippSeconds= 1./float(self.dataOut.PRF)
633
632
634 pulse_width = self.fheader.PPARpdr * 10**-9
633 pulse_width = self.fheader.PPARpdr * 10**-9
635 self.__deltaHeigth = 0.5 * SPEED_OF_LIGHT * pulse_width
634 self.__deltaHeigth = 0.5 * SPEED_OF_LIGHT * pulse_width
636
635
637 self.data_spc = numpy.zeros((self.Num_Hei, self.Num_Bins,2))#
636 self.data_spc = numpy.zeros((self.Num_Hei, self.Num_Bins,2))#
638 self.dataOut.HSDV = numpy.zeros((self.Num_Hei, 2))
637 self.dataOut.HSDV = numpy.zeros((self.Num_Hei, 2))
639
638
640 self.Ze = numpy.zeros(self.Num_Hei)
639 self.Ze = numpy.zeros(self.Num_Hei)
641 self.ETA = numpy.zeros(([2,self.Num_Hei]))
640 self.ETA = numpy.zeros(([2,self.Num_Hei]))
642
641
643
642
644
643
645 self.readBlock() #Block reading
644 self.readBlock() #Block reading
646
645
647 else:
646 else:
648 print 'readFile FlagNoData becomes true'
647 print 'readFile FlagNoData becomes true'
649 self.flagNoMoreFiles=True
648 self.flagNoMoreFiles=True
650 self.dataOut.flagNoData = True
649 self.dataOut.flagNoData = True
651 self.FileHeaderFlag == True
650 self.FileHeaderFlag == True
652 return 0
651 return 0
653
652
654
653
655
654
656 def readBlock(self):
655 def readBlock(self):
657 '''
656 '''
658 It should be checked if the block has data, if it is not passed to the next file.
657 It should be checked if the block has data, if it is not passed to the next file.
659
658
660 Then the following is done:
659 Then the following is done:
661
660
662 1. Read the RecordHeader
661 1. Read the RecordHeader
663 2. Fill the buffer with the current block number.
662 2. Fill the buffer with the current block number.
664
663
665 '''
664 '''
666
665
667 if self.PointerReader > 1180:
666 if self.PointerReader > 1180:
668 self.fp.seek(self.PointerReader , os.SEEK_SET)
667 self.fp.seek(self.PointerReader , os.SEEK_SET)
669 self.FirstPoint = self.PointerReader
668 self.FirstPoint = self.PointerReader
670
669
671 else :
670 else :
672 self.FirstPoint = 1180
671 self.FirstPoint = 1180
673
672
674
673
675
674
676 self.srviHeader = SRVIHeader()
675 self.srviHeader = SRVIHeader()
677
676
678 self.srviHeader.SRVIread(self.fp) #Se obtiene la cabecera del SRVI
677 self.srviHeader.SRVIread(self.fp) #Se obtiene la cabecera del SRVI
679
678
680 self.blocksize = self.srviHeader.SizeOfDataBlock1 # Se obtiene el tamao del bloque
679 self.blocksize = self.srviHeader.SizeOfDataBlock1 # Se obtiene el tamao del bloque
681
680
682 if self.blocksize == 148:
681 if self.blocksize == 148:
683 print 'blocksize == 148 bug'
682 print 'blocksize == 148 bug'
684 jump = numpy.fromfile(self.fp,[('jump',numpy.str_,140)] ,1)
683 jump = numpy.fromfile(self.fp,[('jump',numpy.str_,140)] ,1)
685
684
686 self.srviHeader.SRVIread(self.fp) #Se obtiene la cabecera del SRVI
685 self.srviHeader.SRVIread(self.fp) #Se obtiene la cabecera del SRVI
687
686
688 if not self.srviHeader.SizeOfSRVI1:
687 if not self.srviHeader.SizeOfSRVI1:
689 self.fileSelector+=1
688 self.fileSelector+=1
690 self.nextfileflag==True
689 self.nextfileflag==True
691 self.FileHeaderFlag == True
690 self.FileHeaderFlag == True
692
691
693 self.recordheader = RecordHeader()
692 self.recordheader = RecordHeader()
694 self.recordheader.RHread(self.fp)
693 self.recordheader.RHread(self.fp)
695 self.RadarConst = self.recordheader.RadarConst
694 self.RadarConst = self.recordheader.RadarConst
696 dwell = self.recordheader.time_t
695 dwell = self.recordheader.time_t
697 npw1 = self.recordheader.npw1
696 npw1 = self.recordheader.npw1
698 npw2 = self.recordheader.npw2
697 npw2 = self.recordheader.npw2
699
698
700
699
701 self.dataOut.channelList = range(1)
700 self.dataOut.channelList = range(1)
702 self.dataOut.nIncohInt = self.Num_inCoh
701 self.dataOut.nIncohInt = self.Num_inCoh
703 self.dataOut.nProfiles = self.Num_Bins
702 self.dataOut.nProfiles = self.Num_Bins
704 self.dataOut.nCohInt = 1
703 self.dataOut.nCohInt = 1
705 self.dataOut.windowOfFilter = 1
704 self.dataOut.windowOfFilter = 1
706 self.dataOut.utctime = dwell
705 self.dataOut.utctime = dwell
707 self.dataOut.timeZone=0
706 self.dataOut.timeZone=0
708
707
709 self.dataOut.outputInterval = self.dataOut.getTimeInterval()
708 self.dataOut.outputInterval = self.dataOut.getTimeInterval()
710 self.dataOut.heightList = self.SPARrawGate1*self.__deltaHeigth + numpy.array(range(self.Num_Hei))*self.__deltaHeigth
709 self.dataOut.heightList = self.SPARrawGate1*self.__deltaHeigth + numpy.array(range(self.Num_Hei))*self.__deltaHeigth
711
710
712
711
713
712
714 self.HSDVsign = numpy.fromfile( self.fp, [('HSDV',numpy.str_,4)],1)
713 self.HSDVsign = numpy.fromfile( self.fp, [('HSDV',numpy.str_,4)],1)
715 self.SizeHSDV = numpy.fromfile( self.fp, [('SizeHSDV','<i4')],1)
714 self.SizeHSDV = numpy.fromfile( self.fp, [('SizeHSDV','<i4')],1)
716 self.HSDV_Co = numpy.fromfile( self.fp, [('HSDV_Co','<f4')],self.Num_Hei)
715 self.HSDV_Co = numpy.fromfile( self.fp, [('HSDV_Co','<f4')],self.Num_Hei)
717 self.HSDV_Cx = numpy.fromfile( self.fp, [('HSDV_Cx','<f4')],self.Num_Hei)
716 self.HSDV_Cx = numpy.fromfile( self.fp, [('HSDV_Cx','<f4')],self.Num_Hei)
718
717
719 self.COFAsign = numpy.fromfile( self.fp, [('COFA',numpy.str_,4)],1)
718 self.COFAsign = numpy.fromfile( self.fp, [('COFA',numpy.str_,4)],1)
720 self.SizeCOFA = numpy.fromfile( self.fp, [('SizeCOFA','<i4')],1)
719 self.SizeCOFA = numpy.fromfile( self.fp, [('SizeCOFA','<i4')],1)
721 self.COFA_Co = numpy.fromfile( self.fp, [('COFA_Co','<f4')],self.Num_Hei)
720 self.COFA_Co = numpy.fromfile( self.fp, [('COFA_Co','<f4')],self.Num_Hei)
722 self.COFA_Cx = numpy.fromfile( self.fp, [('COFA_Cx','<f4')],self.Num_Hei)
721 self.COFA_Cx = numpy.fromfile( self.fp, [('COFA_Cx','<f4')],self.Num_Hei)
723
722
724 self.ZSPCsign = numpy.fromfile(self.fp, [('ZSPCsign',numpy.str_,4)],1)
723 self.ZSPCsign = numpy.fromfile(self.fp, [('ZSPCsign',numpy.str_,4)],1)
725 self.SizeZSPC = numpy.fromfile(self.fp, [('SizeZSPC','<i4')],1)
724 self.SizeZSPC = numpy.fromfile(self.fp, [('SizeZSPC','<i4')],1)
726
725
727 self.dataOut.HSDV[0]=self.HSDV_Co[:][0]
726 self.dataOut.HSDV[0]=self.HSDV_Co[:][0]
728 self.dataOut.HSDV[1]=self.HSDV_Cx[:][0]
727 self.dataOut.HSDV[1]=self.HSDV_Cx[:][0]
729
728
730 for irg in range(self.Num_Hei):
729 for irg in range(self.Num_Hei):
731 nspc = numpy.fromfile(self.fp, [('nspc','int16')],1)[0][0] # Number of spectral sub pieces containing significant power
730 nspc = numpy.fromfile(self.fp, [('nspc','int16')],1)[0][0] # Number of spectral sub pieces containing significant power
732
731
733 for k in range(nspc):
732 for k in range(nspc):
734 binIndex = numpy.fromfile(self.fp, [('binIndex','int16')],1)[0][0] # Index of the spectral bin where the piece is beginning
733 binIndex = numpy.fromfile(self.fp, [('binIndex','int16')],1)[0][0] # Index of the spectral bin where the piece is beginning
735 nbins = numpy.fromfile(self.fp, [('nbins','int16')],1)[0][0] # Number of bins of the piece
734 nbins = numpy.fromfile(self.fp, [('nbins','int16')],1)[0][0] # Number of bins of the piece
736
735
737 #Co_Channel
736 #Co_Channel
738 jbin = numpy.fromfile(self.fp, [('jbin','uint16')],nbins)[0][0] # Spectrum piece to be normaliced
737 jbin = numpy.fromfile(self.fp, [('jbin','uint16')],nbins)[0][0] # Spectrum piece to be normaliced
739 jmax = numpy.fromfile(self.fp, [('jmax','float32')],1)[0][0] # Maximun piece to be normaliced
738 jmax = numpy.fromfile(self.fp, [('jmax','float32')],1)[0][0] # Maximun piece to be normaliced
740
739
741
740
742 self.data_spc[irg,binIndex:binIndex+nbins,0] = self.data_spc[irg,binIndex:binIndex+nbins,0]+jbin/65530.*jmax
741 self.data_spc[irg,binIndex:binIndex+nbins,0] = self.data_spc[irg,binIndex:binIndex+nbins,0]+jbin/65530.*jmax
743
742
744 #Cx_Channel
743 #Cx_Channel
745 jbin = numpy.fromfile(self.fp, [('jbin','uint16')],nbins)[0][0]
744 jbin = numpy.fromfile(self.fp, [('jbin','uint16')],nbins)[0][0]
746 jmax = numpy.fromfile(self.fp, [('jmax','float32')],1)[0][0]
745 jmax = numpy.fromfile(self.fp, [('jmax','float32')],1)[0][0]
747
746
748
747
749 self.data_spc[irg,binIndex:binIndex+nbins,1] = self.data_spc[irg,binIndex:binIndex+nbins,1]+jbin/65530.*jmax
748 self.data_spc[irg,binIndex:binIndex+nbins,1] = self.data_spc[irg,binIndex:binIndex+nbins,1]+jbin/65530.*jmax
750
749
751 for bin in range(self.Num_Bins):
750 for bin in range(self.Num_Bins):
752
751
753 self.data_spc[:,bin,0] = self.data_spc[:,bin,0] - self.dataOut.HSDV[:,0]
752 self.data_spc[:,bin,0] = self.data_spc[:,bin,0] - self.dataOut.HSDV[:,0]
754
753
755 self.data_spc[:,bin,1] = self.data_spc[:,bin,1] - self.dataOut.HSDV[:,1]
754 self.data_spc[:,bin,1] = self.data_spc[:,bin,1] - self.dataOut.HSDV[:,1]
756
755
757
756
758 numpy.set_printoptions(threshold='nan')
757 numpy.set_printoptions(threshold='nan')
759
758
760 self.data_spc = numpy.where(self.data_spc > 0. , self.data_spc, 0)
759 self.data_spc = numpy.where(self.data_spc > 0. , self.data_spc, 0)
761
760
762 self.dataOut.COFA = numpy.array([self.COFA_Co , self.COFA_Cx])
761 self.dataOut.COFA = numpy.array([self.COFA_Co , self.COFA_Cx])
763
762
764 print ' '
763 print ' '
765 print 'SPC',numpy.shape(self.dataOut.data_spc)
764 print 'SPC',numpy.shape(self.dataOut.data_spc)
766 #print 'SPC',self.dataOut.data_spc
765 #print 'SPC',self.dataOut.data_spc
767
766
768 noinor1 = 713031680
767 noinor1 = 713031680
769 noinor2 = 30
768 noinor2 = 30
770
769
771 npw1 = 1#0**(npw1/10) * noinor1 * noinor2
770 npw1 = 1#0**(npw1/10) * noinor1 * noinor2
772 npw2 = 1#0**(npw2/10) * noinor1 * noinor2
771 npw2 = 1#0**(npw2/10) * noinor1 * noinor2
773 self.dataOut.NPW = numpy.array([npw1, npw2])
772 self.dataOut.NPW = numpy.array([npw1, npw2])
774
773
775 print ' '
774 print ' '
776
775
777 self.data_spc = numpy.transpose(self.data_spc, (2,1,0))
776 self.data_spc = numpy.transpose(self.data_spc, (2,1,0))
778 self.data_spc = numpy.fft.fftshift(self.data_spc, axes = 1)
777 self.data_spc = numpy.fft.fftshift(self.data_spc, axes = 1)
779
778
780 self.data_spc = numpy.fliplr(self.data_spc)
779 self.data_spc = numpy.fliplr(self.data_spc)
781
780
782 self.data_spc = numpy.where(self.data_spc > 0. , self.data_spc, 0)
781 self.data_spc = numpy.where(self.data_spc > 0. , self.data_spc, 0)
783 self.dataOut_spc= numpy.ones([1, self.Num_Bins , self.Num_Hei])
782 self.dataOut_spc= numpy.ones([1, self.Num_Bins , self.Num_Hei])
784 self.dataOut_spc[0,:,:] = self.data_spc[0,:,:]
783 self.dataOut_spc[0,:,:] = self.data_spc[0,:,:]
785 #print 'SHAPE', self.dataOut_spc.shape
784 #print 'SHAPE', self.dataOut_spc.shape
786 #For nyquist correction:
785 #For nyquist correction:
787 #fix = 20 # ~3m/s
786 #fix = 20 # ~3m/s
788 #shift = self.Num_Bins/2 + fix
787 #shift = self.Num_Bins/2 + fix
789 #self.data_spc = numpy.array([ self.data_spc[: , self.Num_Bins-shift+1: , :] , self.data_spc[: , 0:self.Num_Bins-shift , :]])
788 #self.data_spc = numpy.array([ self.data_spc[: , self.Num_Bins-shift+1: , :] , self.data_spc[: , 0:self.Num_Bins-shift , :]])
790
789
791
790
792
791
793 '''Block Reading, the Block Data is received and Reshape is used to give it
792 '''Block Reading, the Block Data is received and Reshape is used to give it
794 shape.
793 shape.
795 '''
794 '''
796
795
797 self.PointerReader = self.fp.tell()
796 self.PointerReader = self.fp.tell()
798
797
799
798
800
799
801
800
802
801
803
802
804 No newline at end of file
803
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,576 +1,564
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 class BLTRParametersProc(ProcessingUnit):
23
24 class BLTRProcess(ProcessingUnit):
25 isConfig = False
26 '''
23 '''
27 Processing unit for BLTR rawdata
24 Processing unit for BLTR parameters data (winds)
28
25
29 Inputs:
26 Inputs:
30 self.dataOut.nmodes - Number of operation modes
27 self.dataOut.nmodes - Number of operation modes
31 self.dataOut.nchannels - Number of channels
28 self.dataOut.nchannels - Number of channels
32 self.dataOut.nranges - Number of ranges
29 self.dataOut.nranges - Number of ranges
33
30
34 self.dataOut.data_SNR - SNR array
31 self.dataOut.data_SNR - SNR array
35 self.dataOut.data_output - Zonal, Vertical and Meridional velocity array
32 self.dataOut.data_output - Zonal, Vertical and Meridional velocity array
36 self.dataOut.height - Height array (km)
33 self.dataOut.height - Height array (km)
37 self.dataOut.time - Time array (seconds)
34 self.dataOut.time - Time array (seconds)
38
35
39 self.dataOut.fileIndex -Index of the file currently read
36 self.dataOut.fileIndex -Index of the file currently read
40 self.dataOut.lat - Latitude coordinate of BLTR location
37 self.dataOut.lat - Latitude coordinate of BLTR location
41
38
42 self.dataOut.doy - Experiment doy (number of the day in the current year)
39 self.dataOut.doy - Experiment doy (number of the day in the current year)
43 self.dataOut.month - Experiment month
40 self.dataOut.month - Experiment month
44 self.dataOut.day - Experiment day
41 self.dataOut.day - Experiment day
45 self.dataOut.year - Experiment year
42 self.dataOut.year - Experiment year
46 '''
43 '''
47
44
48 def __init__(self, **kwargs):
45 def __init__(self, **kwargs):
49 '''
46 '''
50 Inputs: None
47 Inputs: None
51
52 '''
48 '''
53 ProcessingUnit.__init__(self, **kwargs)
49 ProcessingUnit.__init__(self, **kwargs)
54 self.dataOut = Parameters()
50 self.dataOut = Parameters()
55
51
56 # Filters
52 def run (self, mode):
57 snr_val = None
53 '''
58 value = None
54 '''
59 svalue2 = None
60 method = None
61 factor = None
62 filter = None
63 npoints = None
64 status_value = None
65 width = None
66 self.flagfirstmode = 0
67
68 def run (self):
69 if self.dataIn.type == "Parameters":
55 if self.dataIn.type == "Parameters":
70 self.dataOut.copy(self.dataIn)
56 self.dataOut.copy(self.dataIn)
71
57
58 self.dataOut.data_output = self.dataOut.data_output[mode]
59 self.dataOut.heightList = self.dataOut.height[mode]
72
60
73 def TimeSelect(self):
61 def TimeSelect(self):
74 '''
62 '''
75 Selecting the time array according to the day of the experiment with a duration of 24 hours
63 Selecting the time array according to the day of the experiment with a duration of 24 hours
76 '''
64 '''
77
65
78 k1 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) - datetime.timedelta(hours=5)
66 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)
67 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())
68 limit_sec1 = time.mktime(k1.timetuple())
81 limit_sec2 = time.mktime(k2.timetuple())
69 limit_sec2 = time.mktime(k2.timetuple())
82 valid_data = 0
70 valid_data = 0
83
71
84 doy = self.dataOut.doy
72 doy = self.dataOut.doy
85 t1 = numpy.where(self.dataOut.time[0, :] >= limit_sec1)
73 t1 = numpy.where(self.dataOut.time[0, :] >= limit_sec1)
86 t2 = numpy.where(self.dataOut.time[0, :] < limit_sec2)
74 t2 = numpy.where(self.dataOut.time[0, :] < limit_sec2)
87 time_select = []
75 time_select = []
88 for val_sec in t1[0]:
76 for val_sec in t1[0]:
89 if val_sec in t2[0]:
77 if val_sec in t2[0]:
90 time_select.append(val_sec)
78 time_select.append(val_sec)
91
79
92 time_select = numpy.array(time_select, dtype='int')
80 time_select = numpy.array(time_select, dtype='int')
93 valid_data = valid_data + len(time_select)
81 valid_data = valid_data + len(time_select)
94
82
95
83
96 if len(time_select) > 0:
84 if len(time_select) > 0:
97 self.f_timesec = self.dataOut.time[:, time_select]
85 self.f_timesec = self.dataOut.time[:, time_select]
98 snr = self.dataOut.data_SNR[time_select, :, :, :]
86 snr = self.dataOut.data_SNR[time_select, :, :, :]
99 zon = self.dataOut.data_output[0][time_select, :, :]
87 zon = self.dataOut.data_output[0][time_select, :, :]
100 mer = self.dataOut.data_output[1][time_select, :, :]
88 mer = self.dataOut.data_output[1][time_select, :, :]
101 ver = self.dataOut.data_output[2][time_select, :, :]
89 ver = self.dataOut.data_output[2][time_select, :, :]
102
90
103 if valid_data > 0:
91 if valid_data > 0:
104 self.timesec1 = self.f_timesec[0, :]
92 self.timesec1 = self.f_timesec[0, :]
105 self.f_height = self.dataOut.height
93 self.f_height = self.dataOut.height
106 self.f_zon = zon
94 self.f_zon = zon
107 self.f_mer = mer
95 self.f_mer = mer
108 self.f_ver = ver
96 self.f_ver = ver
109 self.f_snr = snr
97 self.f_snr = snr
110 self.f_timedate = []
98 self.f_timedate = []
111 self.f_time = []
99 self.f_time = []
112
100
113 for valuet in self.timesec1:
101 for valuet in self.timesec1:
114 time_t = time.gmtime(valuet)
102 time_t = time.gmtime(valuet)
115 year = time_t.tm_year
103 year = time_t.tm_year
116 month = time_t.tm_mon
104 month = time_t.tm_mon
117 day = time_t.tm_mday
105 day = time_t.tm_mday
118 hour = time_t.tm_hour
106 hour = time_t.tm_hour
119 minute = time_t.tm_min
107 minute = time_t.tm_min
120 second = time_t.tm_sec
108 second = time_t.tm_sec
121 f_timedate_0 = datetime.datetime(year, month, day, hour, minute, second)
109 f_timedate_0 = datetime.datetime(year, month, day, hour, minute, second)
122 self.f_timedate.append(f_timedate_0)
110 self.f_timedate.append(f_timedate_0)
123
111
124 return self.f_timedate, self.f_timesec, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr
112 return self.f_timedate, self.f_timesec, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr
125
113
126 else:
114 else:
127 self.f_timesec = None
115 self.f_timesec = None
128 self.f_timedate = None
116 self.f_timedate = None
129 self.f_height = None
117 self.f_height = None
130 self.f_zon = None
118 self.f_zon = None
131 self.f_mer = None
119 self.f_mer = None
132 self.f_ver = None
120 self.f_ver = None
133 self.f_snr = None
121 self.f_snr = None
134 print 'Invalid time'
122 print 'Invalid time'
135
123
136 return self.f_timedate, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr
124 return self.f_timedate, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr
137
125
138 def SnrFilter(self, snr_val,modetofilter):
126 def SnrFilter(self, snr_val,modetofilter):
139 '''
127 '''
140 Inputs: snr_val - Threshold value
128 Inputs: snr_val - Threshold value
141
129
142 '''
130 '''
143 if modetofilter!=2 and modetofilter!=1 :
131 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)
132 raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter)
145 m = modetofilter-1
133 m = modetofilter-1
146
134
147 print ' SNR filter [mode {}]: SNR <= {}: data_output = NA'.format(modetofilter,snr_val)
135 print ' SNR filter [mode {}]: SNR <= {}: data_output = NA'.format(modetofilter,snr_val)
148 for k in range(self.dataOut.nchannels):
136 for k in range(self.dataOut.nchannels):
149 for r in range(self.dataOut.nranges):
137 for r in range(self.dataOut.nranges):
150 if self.dataOut.data_SNR[r,k,m] <= snr_val:
138 if self.dataOut.data_SNR[r,k,m] <= snr_val:
151 self.dataOut.data_output[2][r,m] = numpy.nan
139 self.dataOut.data_output[2][r,m] = numpy.nan
152 self.dataOut.data_output[1][r,m] = numpy.nan
140 self.dataOut.data_output[1][r,m] = numpy.nan
153 self.dataOut.data_output[0][r,m] = numpy.nan
141 self.dataOut.data_output[0][r,m] = numpy.nan
154
142
155
143
156
144
157 def OutliersFilter(self,modetofilter,svalue,svalue2,method,factor,filter,npoints):
145 def OutliersFilter(self,modetofilter,svalue,svalue2,method,factor,filter,npoints):
158 '''
146 '''
159 Inputs:
147 Inputs:
160 svalue - string to select array velocity
148 svalue - string to select array velocity
161 svalue2 - string to choose axis filtering
149 svalue2 - string to choose axis filtering
162 method - 0 for SMOOTH or 1 for MEDIAN
150 method - 0 for SMOOTH or 1 for MEDIAN
163 factor - number used to set threshold
151 factor - number used to set threshold
164 filter - 1 for data filtering using the standard deviation criteria else 0
152 filter - 1 for data filtering using the standard deviation criteria else 0
165 npoints - number of points for mask filter
153 npoints - number of points for mask filter
166
154
167 '''
155 '''
168 if modetofilter!=2 and modetofilter!=1 :
156 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)
157 raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter)
170
158
171 m = modetofilter-1
159 m = modetofilter-1
172
160
173 print ' Outliers Filter [mode {}]: {} {} / threshold = {}'.format(modetofilter,svalue,svalue,factor)
161 print ' Outliers Filter [mode {}]: {} {} / threshold = {}'.format(modetofilter,svalue,svalue,factor)
174
162
175 npoints = 9
163 npoints = 9
176 novalid = 0.1
164 novalid = 0.1
177 if svalue == 'zonal':
165 if svalue == 'zonal':
178 value = self.dataOut.data_output[0]
166 value = self.dataOut.data_output[0]
179
167
180 elif svalue == 'meridional':
168 elif svalue == 'meridional':
181 value = self.dataOut.data_output[1]
169 value = self.dataOut.data_output[1]
182
170
183 elif svalue == 'vertical':
171 elif svalue == 'vertical':
184 value = self.dataOut.data_output[2]
172 value = self.dataOut.data_output[2]
185
173
186 else:
174 else:
187 print 'value is not defined'
175 print 'value is not defined'
188 return
176 return
189
177
190 if svalue2 == 'inTime':
178 if svalue2 == 'inTime':
191 yaxis = self.dataOut.height
179 yaxis = self.dataOut.height
192 xaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]])
180 xaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]])
193
181
194 elif svalue2 == 'inHeight':
182 elif svalue2 == 'inHeight':
195 yaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]])
183 yaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]])
196 xaxis = self.dataOut.height
184 xaxis = self.dataOut.height
197
185
198 else:
186 else:
199 print 'svalue2 is required, either inHeight or inTime'
187 print 'svalue2 is required, either inHeight or inTime'
200 return
188 return
201
189
202 output_array = value
190 output_array = value
203
191
204 value_temp = value[:,m]
192 value_temp = value[:,m]
205 error = numpy.zeros(len(self.dataOut.time[m,:]))
193 error = numpy.zeros(len(self.dataOut.time[m,:]))
206 if svalue2 == 'inHeight':
194 if svalue2 == 'inHeight':
207 value_temp = numpy.transpose(value_temp)
195 value_temp = numpy.transpose(value_temp)
208 error = numpy.zeros(len(self.dataOut.height))
196 error = numpy.zeros(len(self.dataOut.height))
209
197
210 htemp = yaxis[m,:]
198 htemp = yaxis[m,:]
211 std = value_temp
199 std = value_temp
212 for h in range(len(htemp)):
200 for h in range(len(htemp)):
213 if filter: #standard deviation filtering
201 if filter: #standard deviation filtering
214 std[h] = numpy.std(value_temp[h],ddof = npoints)
202 std[h] = numpy.std(value_temp[h],ddof = npoints)
215 value_temp[numpy.where(std[h] > 5),h] = numpy.nan
203 value_temp[numpy.where(std[h] > 5),h] = numpy.nan
216 error[numpy.where(std[h] > 5)] = error[numpy.where(std[h] > 5)] + 1
204 error[numpy.where(std[h] > 5)] = error[numpy.where(std[h] > 5)] + 1
217
205
218
206
219 nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0])
207 nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0])
220 minvalid = novalid*len(xaxis[m,:])
208 minvalid = novalid*len(xaxis[m,:])
221 if minvalid <= npoints:
209 if minvalid <= npoints:
222 minvalid = npoints
210 minvalid = npoints
223
211
224 #only if valid values greater than the minimum required (10%)
212 #only if valid values greater than the minimum required (10%)
225 if nvalues_valid > minvalid:
213 if nvalues_valid > minvalid:
226
214
227 if method == 0:
215 if method == 0:
228 #SMOOTH
216 #SMOOTH
229 w = value_temp[h] - self.Smooth(input=value_temp[h], width=npoints, edge_truncate=1)
217 w = value_temp[h] - self.Smooth(input=value_temp[h], width=npoints, edge_truncate=1)
230
218
231
219
232 if method == 1:
220 if method == 1:
233 #MEDIAN
221 #MEDIAN
234 w = value_temp[h] - self.Median(input=value_temp[h], width = npoints)
222 w = value_temp[h] - self.Median(input=value_temp[h], width = npoints)
235
223
236 dw = numpy.std(w[numpy.where(numpy.isfinite(w))],ddof = 1)
224 dw = numpy.std(w[numpy.where(numpy.isfinite(w))],ddof = 1)
237
225
238 threshold = dw*factor
226 threshold = dw*factor
239 value_temp[numpy.where(w > threshold),h] = numpy.nan
227 value_temp[numpy.where(w > threshold),h] = numpy.nan
240 value_temp[numpy.where(w < -1*threshold),h] = numpy.nan
228 value_temp[numpy.where(w < -1*threshold),h] = numpy.nan
241
229
242
230
243 #At the end
231 #At the end
244 if svalue2 == 'inHeight':
232 if svalue2 == 'inHeight':
245 value_temp = numpy.transpose(value_temp)
233 value_temp = numpy.transpose(value_temp)
246 output_array[:,m] = value_temp
234 output_array[:,m] = value_temp
247
235
248 if svalue == 'zonal':
236 if svalue == 'zonal':
249 self.dataOut.data_output[0] = output_array
237 self.dataOut.data_output[0] = output_array
250
238
251 elif svalue == 'meridional':
239 elif svalue == 'meridional':
252 self.dataOut.data_output[1] = output_array
240 self.dataOut.data_output[1] = output_array
253
241
254 elif svalue == 'vertical':
242 elif svalue == 'vertical':
255 self.dataOut.data_output[2] = output_array
243 self.dataOut.data_output[2] = output_array
256
244
257 return self.dataOut.data_output
245 return self.dataOut.data_output
258
246
259
247
260 def Median(self,input,width):
248 def Median(self,input,width):
261 '''
249 '''
262 Inputs:
250 Inputs:
263 input - Velocity array
251 input - Velocity array
264 width - Number of points for mask filter
252 width - Number of points for mask filter
265
253
266 '''
254 '''
267
255
268 if numpy.mod(width,2) == 1:
256 if numpy.mod(width,2) == 1:
269 pc = int((width - 1) / 2)
257 pc = int((width - 1) / 2)
270 cont = 0
258 cont = 0
271 output = []
259 output = []
272
260
273 for i in range(len(input)):
261 for i in range(len(input)):
274 if i >= pc and i < len(input) - pc:
262 if i >= pc and i < len(input) - pc:
275 new2 = input[i-pc:i+pc+1]
263 new2 = input[i-pc:i+pc+1]
276 temp = numpy.where(numpy.isfinite(new2))
264 temp = numpy.where(numpy.isfinite(new2))
277 new = new2[temp]
265 new = new2[temp]
278 value = numpy.median(new)
266 value = numpy.median(new)
279 output.append(value)
267 output.append(value)
280
268
281 output = numpy.array(output)
269 output = numpy.array(output)
282 output = numpy.hstack((input[0:pc],output))
270 output = numpy.hstack((input[0:pc],output))
283 output = numpy.hstack((output,input[-pc:len(input)]))
271 output = numpy.hstack((output,input[-pc:len(input)]))
284
272
285 return output
273 return output
286
274
287 def Smooth(self,input,width,edge_truncate = None):
275 def Smooth(self,input,width,edge_truncate = None):
288 '''
276 '''
289 Inputs:
277 Inputs:
290 input - Velocity array
278 input - Velocity array
291 width - Number of points for mask filter
279 width - Number of points for mask filter
292 edge_truncate - 1 for truncate the convolution product else
280 edge_truncate - 1 for truncate the convolution product else
293
281
294 '''
282 '''
295
283
296 if numpy.mod(width,2) == 0:
284 if numpy.mod(width,2) == 0:
297 real_width = width + 1
285 real_width = width + 1
298 nzeros = width / 2
286 nzeros = width / 2
299 else:
287 else:
300 real_width = width
288 real_width = width
301 nzeros = (width - 1) / 2
289 nzeros = (width - 1) / 2
302
290
303 half_width = int(real_width)/2
291 half_width = int(real_width)/2
304 length = len(input)
292 length = len(input)
305
293
306 gate = numpy.ones(real_width,dtype='float')
294 gate = numpy.ones(real_width,dtype='float')
307 norm_of_gate = numpy.sum(gate)
295 norm_of_gate = numpy.sum(gate)
308
296
309 nan_process = 0
297 nan_process = 0
310 nan_id = numpy.where(numpy.isnan(input))
298 nan_id = numpy.where(numpy.isnan(input))
311 if len(nan_id[0]) > 0:
299 if len(nan_id[0]) > 0:
312 nan_process = 1
300 nan_process = 1
313 pb = numpy.zeros(len(input))
301 pb = numpy.zeros(len(input))
314 pb[nan_id] = 1.
302 pb[nan_id] = 1.
315 input[nan_id] = 0.
303 input[nan_id] = 0.
316
304
317 if edge_truncate == True:
305 if edge_truncate == True:
318 output = numpy.convolve(input/norm_of_gate,gate,mode='same')
306 output = numpy.convolve(input/norm_of_gate,gate,mode='same')
319 elif edge_truncate == False or edge_truncate == None:
307 elif edge_truncate == False or edge_truncate == None:
320 output = numpy.convolve(input/norm_of_gate,gate,mode='valid')
308 output = numpy.convolve(input/norm_of_gate,gate,mode='valid')
321 output = numpy.hstack((input[0:half_width],output))
309 output = numpy.hstack((input[0:half_width],output))
322 output = numpy.hstack((output,input[len(input)-half_width:len(input)]))
310 output = numpy.hstack((output,input[len(input)-half_width:len(input)]))
323
311
324 if nan_process:
312 if nan_process:
325 pb = numpy.convolve(pb/norm_of_gate,gate,mode='valid')
313 pb = numpy.convolve(pb/norm_of_gate,gate,mode='valid')
326 pb = numpy.hstack((numpy.zeros(half_width),pb))
314 pb = numpy.hstack((numpy.zeros(half_width),pb))
327 pb = numpy.hstack((pb,numpy.zeros(half_width)))
315 pb = numpy.hstack((pb,numpy.zeros(half_width)))
328 output[numpy.where(pb > 0.9999)] = numpy.nan
316 output[numpy.where(pb > 0.9999)] = numpy.nan
329 input[nan_id] = numpy.nan
317 input[nan_id] = numpy.nan
330 return output
318 return output
331
319
332 def Average(self,aver=0,nhaver=1):
320 def Average(self,aver=0,nhaver=1):
333 '''
321 '''
334 Inputs:
322 Inputs:
335 aver - Indicates the time period over which is averaged or consensus data
323 aver - Indicates the time period over which is averaged or consensus data
336 nhaver - Indicates the decimation factor in heights
324 nhaver - Indicates the decimation factor in heights
337
325
338 '''
326 '''
339 nhpoints = 48
327 nhpoints = 48
340
328
341 lat_piura = -5.17
329 lat_piura = -5.17
342 lat_huancayo = -12.04
330 lat_huancayo = -12.04
343 lat_porcuya = -5.8
331 lat_porcuya = -5.8
344
332
345 if '%2.2f'%self.dataOut.lat == '%2.2f'%lat_piura:
333 if '%2.2f'%self.dataOut.lat == '%2.2f'%lat_piura:
346 hcm = 3.
334 hcm = 3.
347 if self.dataOut.year == 2003 :
335 if self.dataOut.year == 2003 :
348 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
336 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
349 nhpoints = 12
337 nhpoints = 12
350
338
351 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_huancayo:
339 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_huancayo:
352 hcm = 3.
340 hcm = 3.
353 if self.dataOut.year == 2003 :
341 if self.dataOut.year == 2003 :
354 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
342 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
355 nhpoints = 12
343 nhpoints = 12
356
344
357
345
358 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_porcuya:
346 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_porcuya:
359 hcm = 5.#2
347 hcm = 5.#2
360
348
361 pdata = 0.2
349 pdata = 0.2
362 taver = [1,2,3,4,6,8,12,24]
350 taver = [1,2,3,4,6,8,12,24]
363 t0 = 0
351 t0 = 0
364 tf = 24
352 tf = 24
365 ntime =(tf-t0)/taver[aver]
353 ntime =(tf-t0)/taver[aver]
366 ti = numpy.arange(ntime)
354 ti = numpy.arange(ntime)
367 tf = numpy.arange(ntime) + taver[aver]
355 tf = numpy.arange(ntime) + taver[aver]
368
356
369
357
370 old_height = self.dataOut.heightList
358 old_height = self.dataOut.heightList
371
359
372 if nhaver > 1:
360 if nhaver > 1:
373 num_hei = len(self.dataOut.heightList)/nhaver/self.dataOut.nmodes
361 num_hei = len(self.dataOut.heightList)/nhaver/self.dataOut.nmodes
374 deltha = 0.05*nhaver
362 deltha = 0.05*nhaver
375 minhvalid = pdata*nhaver
363 minhvalid = pdata*nhaver
376 for im in range(self.dataOut.nmodes):
364 for im in range(self.dataOut.nmodes):
377 new_height = numpy.arange(num_hei)*deltha + self.dataOut.height[im,0] + deltha/2.
365 new_height = numpy.arange(num_hei)*deltha + self.dataOut.height[im,0] + deltha/2.
378
366
379
367
380 data_fHeigths_List = []
368 data_fHeigths_List = []
381 data_fZonal_List = []
369 data_fZonal_List = []
382 data_fMeridional_List = []
370 data_fMeridional_List = []
383 data_fVertical_List = []
371 data_fVertical_List = []
384 startDTList = []
372 startDTList = []
385
373
386
374
387 for i in range(ntime):
375 for i in range(ntime):
388 height = old_height
376 height = old_height
389
377
390 start = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(ti[i])) - datetime.timedelta(hours = 5)
378 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)
379 stop = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(tf[i])) - datetime.timedelta(hours = 5)
392
380
393
381
394 limit_sec1 = time.mktime(start.timetuple())
382 limit_sec1 = time.mktime(start.timetuple())
395 limit_sec2 = time.mktime(stop.timetuple())
383 limit_sec2 = time.mktime(stop.timetuple())
396
384
397 t1 = numpy.where(self.f_timesec >= limit_sec1)
385 t1 = numpy.where(self.f_timesec >= limit_sec1)
398 t2 = numpy.where(self.f_timesec < limit_sec2)
386 t2 = numpy.where(self.f_timesec < limit_sec2)
399 time_select = []
387 time_select = []
400 for val_sec in t1[0]:
388 for val_sec in t1[0]:
401 if val_sec in t2[0]:
389 if val_sec in t2[0]:
402 time_select.append(val_sec)
390 time_select.append(val_sec)
403
391
404
392
405 time_select = numpy.array(time_select,dtype = 'int')
393 time_select = numpy.array(time_select,dtype = 'int')
406 minvalid = numpy.ceil(pdata*nhpoints)
394 minvalid = numpy.ceil(pdata*nhpoints)
407
395
408 zon_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
396 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
397 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
398 ver_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
411
399
412 if nhaver > 1:
400 if nhaver > 1:
413 new_zon_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
401 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
402 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
403 new_ver_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
416
404
417 if len(time_select) > minvalid:
405 if len(time_select) > minvalid:
418 time_average = self.f_timesec[time_select]
406 time_average = self.f_timesec[time_select]
419
407
420 for im in range(self.dataOut.nmodes):
408 for im in range(self.dataOut.nmodes):
421
409
422 for ih in range(self.dataOut.nranges):
410 for ih in range(self.dataOut.nranges):
423 if numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im])) >= minvalid:
411 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]))
412 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
413
426 if numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im])) >= minvalid:
414 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]))
415 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
416
429 if numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im])) >= minvalid:
417 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]))
418 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
419
432 if nhaver > 1:
420 if nhaver > 1:
433 for ih in range(num_hei):
421 for ih in range(num_hei):
434 hvalid = numpy.arange(nhaver) + nhaver*ih
422 hvalid = numpy.arange(nhaver) + nhaver*ih
435
423
436 if numpy.sum(numpy.isfinite(zon_aver[hvalid,im])) >= minvalid:
424 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]))
425 new_zon_aver[ih,im] = numpy.nansum(zon_aver[hvalid,im]) / numpy.sum(numpy.isfinite(zon_aver[hvalid,im]))
438
426
439 if numpy.sum(numpy.isfinite(mer_aver[hvalid,im])) >= minvalid:
427 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]))
428 new_mer_aver[ih,im] = numpy.nansum(mer_aver[hvalid,im]) / numpy.sum(numpy.isfinite(mer_aver[hvalid,im]))
441
429
442 if numpy.sum(numpy.isfinite(ver_aver[hvalid,im])) >= minvalid:
430 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]))
431 new_ver_aver[ih,im] = numpy.nansum(ver_aver[hvalid,im]) / numpy.sum(numpy.isfinite(ver_aver[hvalid,im]))
444 if nhaver > 1:
432 if nhaver > 1:
445 zon_aver = new_zon_aver
433 zon_aver = new_zon_aver
446 mer_aver = new_mer_aver
434 mer_aver = new_mer_aver
447 ver_aver = new_ver_aver
435 ver_aver = new_ver_aver
448 height = new_height
436 height = new_height
449
437
450
438
451 tstart = time_average[0]
439 tstart = time_average[0]
452 tend = time_average[-1]
440 tend = time_average[-1]
453 startTime = time.gmtime(tstart)
441 startTime = time.gmtime(tstart)
454
442
455 year = startTime.tm_year
443 year = startTime.tm_year
456 month = startTime.tm_mon
444 month = startTime.tm_mon
457 day = startTime.tm_mday
445 day = startTime.tm_mday
458 hour = startTime.tm_hour
446 hour = startTime.tm_hour
459 minute = startTime.tm_min
447 minute = startTime.tm_min
460 second = startTime.tm_sec
448 second = startTime.tm_sec
461
449
462 startDTList.append(datetime.datetime(year,month,day,hour,minute,second))
450 startDTList.append(datetime.datetime(year,month,day,hour,minute,second))
463
451
464
452
465 o_height = numpy.array([])
453 o_height = numpy.array([])
466 o_zon_aver = numpy.array([])
454 o_zon_aver = numpy.array([])
467 o_mer_aver = numpy.array([])
455 o_mer_aver = numpy.array([])
468 o_ver_aver = numpy.array([])
456 o_ver_aver = numpy.array([])
469 if self.dataOut.nmodes > 1:
457 if self.dataOut.nmodes > 1:
470 for im in range(self.dataOut.nmodes):
458 for im in range(self.dataOut.nmodes):
471
459
472 if im == 0:
460 if im == 0:
473 h_select = numpy.where(numpy.bitwise_and(height[0,:] >=0,height[0,:] <= hcm,numpy.isfinite(height[0,:])))
461 h_select = numpy.where(numpy.bitwise_and(height[0,:] >=0,height[0,:] <= hcm,numpy.isfinite(height[0,:])))
474 else:
462 else:
475 h_select = numpy.where(numpy.bitwise_and(height[1,:] > hcm,height[1,:] < 20,numpy.isfinite(height[1,:])))
463 h_select = numpy.where(numpy.bitwise_and(height[1,:] > hcm,height[1,:] < 20,numpy.isfinite(height[1,:])))
476
464
477
465
478 ht = h_select[0]
466 ht = h_select[0]
479
467
480 o_height = numpy.hstack((o_height,height[im,ht]))
468 o_height = numpy.hstack((o_height,height[im,ht]))
481 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
469 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]))
470 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]))
471 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
484
472
485 data_fHeigths_List.append(o_height)
473 data_fHeigths_List.append(o_height)
486 data_fZonal_List.append(o_zon_aver)
474 data_fZonal_List.append(o_zon_aver)
487 data_fMeridional_List.append(o_mer_aver)
475 data_fMeridional_List.append(o_mer_aver)
488 data_fVertical_List.append(o_ver_aver)
476 data_fVertical_List.append(o_ver_aver)
489
477
490
478
491 else:
479 else:
492 h_select = numpy.where(numpy.bitwise_and(height[0,:] <= hcm,numpy.isfinite(height[0,:])))
480 h_select = numpy.where(numpy.bitwise_and(height[0,:] <= hcm,numpy.isfinite(height[0,:])))
493 ht = h_select[0]
481 ht = h_select[0]
494 o_height = numpy.hstack((o_height,height[im,ht]))
482 o_height = numpy.hstack((o_height,height[im,ht]))
495 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
483 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]))
484 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]))
485 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
498
486
499 data_fHeigths_List.append(o_height)
487 data_fHeigths_List.append(o_height)
500 data_fZonal_List.append(o_zon_aver)
488 data_fZonal_List.append(o_zon_aver)
501 data_fMeridional_List.append(o_mer_aver)
489 data_fMeridional_List.append(o_mer_aver)
502 data_fVertical_List.append(o_ver_aver)
490 data_fVertical_List.append(o_ver_aver)
503
491
504
492
505 return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List
493 return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List
506
494
507
495
508 def prePlot(self,modeselect=None):
496 def prePlot(self,modeselect=None):
509
497
510 '''
498 '''
511 Inputs:
499 Inputs:
512
500
513 self.dataOut.data_output - Zonal, Meridional and Vertical velocity array
501 self.dataOut.data_output - Zonal, Meridional and Vertical velocity array
514 self.dataOut.height - height array
502 self.dataOut.height - height array
515 self.dataOut.time - Time array (seconds)
503 self.dataOut.time - Time array (seconds)
516 self.dataOut.data_SNR - SNR array
504 self.dataOut.data_SNR - SNR array
517
505
518 '''
506 '''
519
507
520 m = modeselect -1
508 m = modeselect -1
521
509
522 print ' [Plotting mode {}]'.format(modeselect)
510 print ' [Plotting mode {}]'.format(modeselect)
523 if not (m ==1 or m==0):
511 if not (m ==1 or m==0):
524 raise IndexError("'Mode' must be egual to : 1 or 2")
512 raise IndexError("'Mode' must be egual to : 1 or 2")
525 #
513 #
526 if self.flagfirstmode==0:
514 if self.flagfirstmode==0:
527 #copy of the data
515 #copy of the data
528 self.data_output_copy = self.dataOut.data_output.copy()
516 self.data_output_copy = self.dataOut.data_output.copy()
529 self.data_height_copy = self.dataOut.height.copy()
517 self.data_height_copy = self.dataOut.height.copy()
530 self.data_time_copy = self.dataOut.time.copy()
518 self.data_time_copy = self.dataOut.time.copy()
531 self.data_SNR_copy = self.dataOut.data_SNR.copy()
519 self.data_SNR_copy = self.dataOut.data_SNR.copy()
532 self.flagfirstmode = 1
520 self.flagfirstmode = 1
533
521
534 else:
522 else:
535 self.dataOut.data_output = self.data_output_copy
523 self.dataOut.data_output = self.data_output_copy
536 self.dataOut.height = self.data_height_copy
524 self.dataOut.height = self.data_height_copy
537 self.dataOut.time = self.data_time_copy
525 self.dataOut.time = self.data_time_copy
538 self.dataOut.data_SNR = self.data_SNR_copy
526 self.dataOut.data_SNR = self.data_SNR_copy
539 self.flagfirstmode = 0
527 self.flagfirstmode = 0
540
528
541
529
542 #select data for mode m
530 #select data for mode m
543 #self.dataOut.data_output = self.dataOut.data_output[:,:,m]
531 #self.dataOut.data_output = self.dataOut.data_output[:,:,m]
544 self.dataOut.heightList = self.dataOut.height[0,:]
532 self.dataOut.heightList = self.dataOut.height[0,:]
545
533
546 data_SNR = self.dataOut.data_SNR[:,:,m]
534 data_SNR = self.dataOut.data_SNR[:,:,m]
547 self.dataOut.data_SNR= transpose(data_SNR)
535 self.dataOut.data_SNR= transpose(data_SNR)
548
536
549 if m==1 and self.dataOut.counter_records%2==0:
537 if m==1 and self.dataOut.counter_records%2==0:
550 print '*********'
538 print '*********'
551 print 'MODO 2'
539 print 'MODO 2'
552 #print 'Zonal', self.dataOut.data_output[0]
540 #print 'Zonal', self.dataOut.data_output[0]
553 #print 'Meridional', self.dataOut.data_output[1]
541 #print 'Meridional', self.dataOut.data_output[1]
554 #print 'Vertical', self.dataOut.data_output[2]
542 #print 'Vertical', self.dataOut.data_output[2]
555
543
556 print '*********'
544 print '*********'
557
545
558 Vx=self.dataOut.data_output[0,:,m]
546 Vx=self.dataOut.data_output[0,:,m]
559 Vy=self.dataOut.data_output[1,:,m]
547 Vy=self.dataOut.data_output[1,:,m]
560
548
561 Vmag=numpy.sqrt(Vx**2+Vy**2)
549 Vmag=numpy.sqrt(Vx**2+Vy**2)
562 Vang=numpy.arctan2(Vy,Vx)
550 Vang=numpy.arctan2(Vy,Vx)
563 #print 'Vmag', Vmag
551 #print 'Vmag', Vmag
564 #print 'Vang', Vang
552 #print 'Vang', Vang
565
553
566 self.dataOut.data_output[0,:,m]=Vmag
554 self.dataOut.data_output[0,:,m]=Vmag
567 self.dataOut.data_output[1,:,m]=Vang
555 self.dataOut.data_output[1,:,m]=Vang
568
556
569 prin= self.dataOut.data_output[0,:,m][~numpy.isnan(self.dataOut.data_output[0,:,m])]
557 prin= self.dataOut.data_output[0,:,m][~numpy.isnan(self.dataOut.data_output[0,:,m])]
570 print ' '
558 print ' '
571 print 'VmagAverage',numpy.mean(prin)
559 print 'VmagAverage',numpy.mean(prin)
572 print ' '
560 print ' '
573 self.dataOut.data_output = self.dataOut.data_output[:,:,m]
561 self.dataOut.data_output = self.dataOut.data_output[:,:,m]
574
562
575
563
576 No newline at end of file
564
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 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: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
This diff has been collapsed as it changes many lines, (950 lines changed) Show them Hide them
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now