The requested changes are too big and content was truncated. Show full diff
@@ -1,795 +1,803 | |||
|
1 | 1 | import os, sys |
|
2 | 2 | import glob |
|
3 | 3 | import fnmatch |
|
4 | 4 | import datetime |
|
5 | 5 | import time |
|
6 | 6 | import re |
|
7 | 7 | import h5py |
|
8 | 8 | import numpy |
|
9 | 9 | import matplotlib.pyplot as plt |
|
10 | 10 | |
|
11 | 11 | import pylab as plb |
|
12 | 12 | from scipy.optimize import curve_fit |
|
13 | 13 | from scipy import asarray as ar, exp |
|
14 | 14 | from scipy import stats |
|
15 | 15 | |
|
16 | 16 | from numpy.ma.core import getdata |
|
17 | 17 | |
|
18 | 18 | SPEED_OF_LIGHT = 299792458 |
|
19 | 19 | SPEED_OF_LIGHT = 3e8 |
|
20 | 20 | |
|
21 | 21 | try: |
|
22 | 22 | from gevent import sleep |
|
23 | 23 | except: |
|
24 | 24 | from time import sleep |
|
25 | 25 | |
|
26 | 26 | from schainpy.model.data.jrodata import Spectra |
|
27 | 27 | #from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader |
|
28 | 28 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
29 | 29 | #from schainpy.model.io.jroIO_bltr import BLTRReader |
|
30 | 30 | from numpy import imag, shape, NaN |
|
31 | 31 | |
|
32 | 32 | from jroIO_base import JRODataReader |
|
33 | 33 | |
|
34 | 34 | |
|
35 | 35 | class Header(object): |
|
36 | 36 | |
|
37 | 37 | def __init__(self): |
|
38 | 38 | raise NotImplementedError |
|
39 | 39 | |
|
40 | 40 | |
|
41 | 41 | def read(self): |
|
42 | 42 | |
|
43 | 43 | raise NotImplementedError |
|
44 | 44 | |
|
45 | 45 | def write(self): |
|
46 | 46 | |
|
47 | 47 | raise NotImplementedError |
|
48 | 48 | |
|
49 | 49 | def printInfo(self): |
|
50 | 50 | |
|
51 | 51 | message = "#"*50 + "\n" |
|
52 | 52 | message += self.__class__.__name__.upper() + "\n" |
|
53 | 53 | message += "#"*50 + "\n" |
|
54 | 54 | |
|
55 | 55 | keyList = self.__dict__.keys() |
|
56 | 56 | keyList.sort() |
|
57 | 57 | |
|
58 | 58 | for key in keyList: |
|
59 | 59 | message += "%s = %s" %(key, self.__dict__[key]) + "\n" |
|
60 | 60 | |
|
61 | 61 | if "size" not in keyList: |
|
62 | 62 | attr = getattr(self, "size") |
|
63 | 63 | |
|
64 | 64 | if attr: |
|
65 | 65 | message += "%s = %s" %("size", attr) + "\n" |
|
66 | 66 | |
|
67 | 67 | #print message |
|
68 | 68 | |
|
69 | 69 | |
|
70 | 70 | |
|
71 | 71 | |
|
72 | 72 | |
|
73 | 73 | FILE_STRUCTURE = numpy.dtype([ #HEADER 48bytes |
|
74 | 74 | ('FileMgcNumber','<u4'), #0x23020100 |
|
75 | 75 | ('nFDTdataRecors','<u4'), #No Of FDT data records in this file (0 or more) |
|
76 | 76 | ('OffsetStartHeader','<u4'), |
|
77 | 77 | ('RadarUnitId','<u4'), |
|
78 | 78 | ('SiteName',numpy.str_,32), #Null terminated |
|
79 | 79 | ]) |
|
80 | 80 | |
|
81 | 81 | class FileHeaderBLTR(Header): |
|
82 | 82 | |
|
83 | 83 | def __init__(self): |
|
84 | 84 | |
|
85 | 85 | self.FileMgcNumber= 0 #0x23020100 |
|
86 | 86 | self.nFDTdataRecors=0 #No Of FDT data records in this file (0 or more) |
|
87 | 87 | self.RadarUnitId= 0 |
|
88 | 88 | self.OffsetStartHeader=0 |
|
89 | 89 | self.SiteName= "" |
|
90 | 90 | self.size = 48 |
|
91 | 91 | |
|
92 | 92 | def FHread(self, fp): |
|
93 | 93 | #try: |
|
94 | 94 | startFp = open(fp,"rb") |
|
95 | 95 | |
|
96 | 96 | header = numpy.fromfile(startFp, FILE_STRUCTURE,1) |
|
97 | 97 | |
|
98 | 98 | print ' ' |
|
99 | 99 | print 'puntero file header', startFp.tell() |
|
100 | 100 | print ' ' |
|
101 | 101 | |
|
102 | 102 | |
|
103 | 103 | ''' numpy.fromfile(file, dtype, count, sep='') |
|
104 | 104 | file : file or str |
|
105 | 105 | Open file object or filename. |
|
106 | 106 | |
|
107 | 107 | dtype : data-type |
|
108 | 108 | Data type of the returned array. For binary files, it is used to determine |
|
109 | 109 | the size and byte-order of the items in the file. |
|
110 | 110 | |
|
111 | 111 | count : int |
|
112 | 112 | Number of items to read. -1 means all items (i.e., the complete file). |
|
113 | 113 | |
|
114 | 114 | sep : str |
|
115 | 115 | Separator between items if file is a text file. Empty ("") separator means |
|
116 | 116 | the file should be treated as binary. Spaces (" ") in the separator match zero |
|
117 | 117 | or more whitespace characters. A separator consisting only of spaces must match |
|
118 | 118 | at least one whitespace. |
|
119 | 119 | |
|
120 | 120 | ''' |
|
121 | 121 | |
|
122 | 122 | |
|
123 | 123 | |
|
124 | 124 | self.FileMgcNumber= hex(header['FileMgcNumber'][0]) |
|
125 | 125 | self.nFDTdataRecors=int(header['nFDTdataRecors'][0]) #No Of FDT data records in this file (0 or more) |
|
126 | 126 | self.RadarUnitId= int(header['RadarUnitId'][0]) |
|
127 | 127 | self.OffsetStartHeader= int(header['OffsetStartHeader'][0]) |
|
128 | 128 | self.SiteName= str(header['SiteName'][0]) |
|
129 | 129 | |
|
130 | 130 | #print 'Numero de bloques', self.nFDTdataRecors |
|
131 | 131 | |
|
132 | 132 | |
|
133 | 133 | if self.size <48: |
|
134 | 134 | return 0 |
|
135 | 135 | |
|
136 | 136 | return 1 |
|
137 | 137 | |
|
138 | 138 | |
|
139 | 139 | def write(self, fp): |
|
140 | 140 | |
|
141 | 141 | headerTuple = (self.FileMgcNumber, |
|
142 | 142 | self.nFDTdataRecors, |
|
143 | 143 | self.RadarUnitId, |
|
144 | 144 | self.SiteName, |
|
145 | 145 | self.size) |
|
146 | 146 | |
|
147 | 147 | |
|
148 | 148 | header = numpy.array(headerTuple, FILE_STRUCTURE) |
|
149 | 149 | # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0) |
|
150 | 150 | header.tofile(fp) |
|
151 | 151 | ''' ndarray.tofile(fid, sep, format) Write array to a file as text or binary (default). |
|
152 | 152 | |
|
153 | 153 | fid : file or str |
|
154 | 154 | An open file object, or a string containing a filename. |
|
155 | 155 | |
|
156 | 156 | sep : str |
|
157 | 157 | Separator between array items for text output. If "" (empty), a binary file is written, |
|
158 | 158 | equivalent to file.write(a.tobytes()). |
|
159 | 159 | |
|
160 | 160 | format : str |
|
161 | 161 | Format string for text file output. Each entry in the array is formatted to text by |
|
162 | 162 | first converting it to the closest Python type, and then using "format" % item. |
|
163 | 163 | |
|
164 | 164 | ''' |
|
165 | 165 | |
|
166 | 166 | return 1 |
|
167 | 167 | |
|
168 | 168 | |
|
169 | 169 | |
|
170 | 170 | |
|
171 | 171 | |
|
172 | 172 | RECORD_STRUCTURE = numpy.dtype([ #RECORD HEADER 180+20N bytes |
|
173 | 173 | ('RecMgcNumber','<u4'), #0x23030001 |
|
174 | 174 | ('RecCounter','<u4'), #Record counter(0,1, ...) |
|
175 | 175 | ('Off2StartNxtRec','<u4'), #Offset to start of next record form start of this record |
|
176 | 176 | ('Off2StartData','<u4'), #Offset to start of data from start of this record |
|
177 | 177 | ('nUtime','<i4'), #Epoch time stamp of start of acquisition (seconds) |
|
178 | 178 | ('nMilisec','<u4'), #Millisecond component of time stamp (0,...,999) |
|
179 | 179 | ('ExpTagName',numpy.str_,32), #Experiment tag name (null terminated) |
|
180 | 180 | ('ExpComment',numpy.str_,32), #Experiment comment (null terminated) |
|
181 | 181 | ('SiteLatDegrees','<f4'), #Site latitude (from GPS) in degrees (positive implies North) |
|
182 | 182 | ('SiteLongDegrees','<f4'), #Site longitude (from GPS) in degrees (positive implies East) |
|
183 | 183 | ('RTCgpsStatus','<u4'), #RTC GPS engine status (0=SEEK, 1=LOCK, 2=NOT FITTED, 3=UNAVAILABLE) |
|
184 | 184 | ('TransmitFrec','<u4'), #Transmit frequency (Hz) |
|
185 | 185 | ('ReceiveFrec','<u4'), #Receive frequency |
|
186 | 186 | ('FirstOsciFrec','<u4'), #First local oscillator frequency (Hz) |
|
187 | 187 | ('Polarisation','<u4'), #(0="O", 1="E", 2="linear 1", 3="linear2") |
|
188 | 188 | ('ReceiverFiltSett','<u4'), #Receiver filter settings (0,1,2,3) |
|
189 | 189 | ('nModesInUse','<u4'), #Number of modes in use (1 or 2) |
|
190 | 190 | ('DualModeIndex','<u4'), #Dual Mode index number for these data (0 or 1) |
|
191 | 191 | ('DualModeRange','<u4'), #Dual Mode range correction for these data (m) |
|
192 | 192 | ('nDigChannels','<u4'), #Number of digital channels acquired (2*N) |
|
193 | 193 | ('SampResolution','<u4'), #Sampling resolution (meters) |
|
194 | 194 | ('nHeights','<u4'), #Number of range gates sampled |
|
195 | 195 | ('StartRangeSamp','<u4'), #Start range of sampling (meters) |
|
196 | 196 | ('PRFhz','<u4'), #PRF (Hz) |
|
197 | 197 | ('nCohInt','<u4'), #Integrations |
|
198 | 198 | ('nProfiles','<u4'), #Number of data points transformed |
|
199 | 199 | ('nChannels','<u4'), #Number of receive beams stored in file (1 or N) |
|
200 | 200 | ('nIncohInt','<u4'), #Number of spectral averages |
|
201 | 201 | ('FFTwindowingInd','<u4'), #FFT windowing index (0 = no window) |
|
202 | 202 | ('BeamAngleAzim','<f4'), #Beam steer angle (azimuth) in degrees (clockwise from true North) |
|
203 | 203 | ('BeamAngleZen','<f4'), #Beam steer angle (zenith) in degrees (0=> vertical) |
|
204 | 204 | ('AntennaCoord0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs |
|
205 | 205 | ('AntennaAngl0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs |
|
206 | 206 | ('AntennaCoord1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs |
|
207 | 207 | ('AntennaAngl1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs |
|
208 | 208 | ('AntennaCoord2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs |
|
209 | 209 | ('AntennaAngl2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs |
|
210 | 210 | ('RecPhaseCalibr0','<f4'), #Receiver phase calibration (degrees) - N values |
|
211 | 211 | ('RecPhaseCalibr1','<f4'), #Receiver phase calibration (degrees) - N values |
|
212 | 212 | ('RecPhaseCalibr2','<f4'), #Receiver phase calibration (degrees) - N values |
|
213 | 213 | ('RecAmpCalibr0','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values |
|
214 | 214 | ('RecAmpCalibr1','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values |
|
215 | 215 | ('RecAmpCalibr2','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values |
|
216 | 216 | ('ReceiverGaindB0','<i4'), #Receiver gains in dB - N values |
|
217 | 217 | ('ReceiverGaindB1','<i4'), #Receiver gains in dB - N values |
|
218 | 218 | ('ReceiverGaindB2','<i4'), #Receiver gains in dB - N values |
|
219 | 219 | ]) |
|
220 | 220 | |
|
221 | 221 | |
|
222 | 222 | class RecordHeaderBLTR(Header): |
|
223 | 223 | |
|
224 | 224 | def __init__(self, RecMgcNumber=None, RecCounter= 0, Off2StartNxtRec= 811248, |
|
225 | 225 | nUtime= 0, nMilisec= 0, ExpTagName= None, |
|
226 | 226 | ExpComment=None, SiteLatDegrees=0, SiteLongDegrees= 0, |
|
227 | 227 | RTCgpsStatus= 0, TransmitFrec= 0, ReceiveFrec= 0, |
|
228 | 228 | FirstOsciFrec= 0, Polarisation= 0, ReceiverFiltSett= 0, |
|
229 | 229 | nModesInUse= 0, DualModeIndex= 0, DualModeRange= 0, |
|
230 | 230 | nDigChannels= 0, SampResolution= 0, nHeights= 0, |
|
231 | 231 | StartRangeSamp= 0, PRFhz= 0, nCohInt= 0, |
|
232 | 232 | nProfiles= 0, nChannels= 0, nIncohInt= 0, |
|
233 | 233 | FFTwindowingInd= 0, BeamAngleAzim= 0, BeamAngleZen= 0, |
|
234 | 234 | AntennaCoord0= 0, AntennaCoord1= 0, AntennaCoord2= 0, |
|
235 | 235 | RecPhaseCalibr0= 0, RecPhaseCalibr1= 0, RecPhaseCalibr2= 0, |
|
236 | 236 | RecAmpCalibr0= 0, RecAmpCalibr1= 0, RecAmpCalibr2= 0, |
|
237 | 237 | AntennaAngl0=0, AntennaAngl1=0, AntennaAngl2=0, |
|
238 | 238 | ReceiverGaindB0= 0, ReceiverGaindB1= 0, ReceiverGaindB2= 0, Off2StartData=0, OffsetStartHeader=0): |
|
239 | 239 | |
|
240 | 240 | self.RecMgcNumber = RecMgcNumber #0x23030001 |
|
241 | 241 | self.RecCounter = RecCounter |
|
242 | 242 | self.Off2StartNxtRec = Off2StartNxtRec |
|
243 | 243 | self.Off2StartData = Off2StartData |
|
244 | 244 | self.nUtime = nUtime |
|
245 | 245 | self.nMilisec = nMilisec |
|
246 | 246 | self.ExpTagName = ExpTagName |
|
247 | 247 | self.ExpComment = ExpComment |
|
248 | 248 | self.SiteLatDegrees = SiteLatDegrees |
|
249 | 249 | self.SiteLongDegrees = SiteLongDegrees |
|
250 | 250 | self.RTCgpsStatus = RTCgpsStatus |
|
251 | 251 | self.TransmitFrec = TransmitFrec |
|
252 | 252 | self.ReceiveFrec = ReceiveFrec |
|
253 | 253 | self.FirstOsciFrec = FirstOsciFrec |
|
254 | 254 | self.Polarisation = Polarisation |
|
255 | 255 | self.ReceiverFiltSett = ReceiverFiltSett |
|
256 | 256 | self.nModesInUse = nModesInUse |
|
257 | 257 | self.DualModeIndex = DualModeIndex |
|
258 | 258 | self.DualModeRange = DualModeRange |
|
259 | 259 | self.nDigChannels = nDigChannels |
|
260 | 260 | self.SampResolution = SampResolution |
|
261 | 261 | self.nHeights = nHeights |
|
262 | 262 | self.StartRangeSamp = StartRangeSamp |
|
263 | 263 | self.PRFhz = PRFhz |
|
264 | 264 | self.nCohInt = nCohInt |
|
265 | 265 | self.nProfiles = nProfiles |
|
266 | 266 | self.nChannels = nChannels |
|
267 | 267 | self.nIncohInt = nIncohInt |
|
268 | 268 | self.FFTwindowingInd = FFTwindowingInd |
|
269 | 269 | self.BeamAngleAzim = BeamAngleAzim |
|
270 | 270 | self.BeamAngleZen = BeamAngleZen |
|
271 | 271 | self.AntennaCoord0 = AntennaCoord0 |
|
272 | 272 | self.AntennaAngl0 = AntennaAngl0 |
|
273 | 273 | self.AntennaAngl1 = AntennaAngl1 |
|
274 | 274 | self.AntennaAngl2 = AntennaAngl2 |
|
275 | 275 | self.AntennaCoord1 = AntennaCoord1 |
|
276 | 276 | self.AntennaCoord2 = AntennaCoord2 |
|
277 | 277 | self.RecPhaseCalibr0 = RecPhaseCalibr0 |
|
278 | 278 | self.RecPhaseCalibr1 = RecPhaseCalibr1 |
|
279 | 279 | self.RecPhaseCalibr2 = RecPhaseCalibr2 |
|
280 | 280 | self.RecAmpCalibr0 = RecAmpCalibr0 |
|
281 | 281 | self.RecAmpCalibr1 = RecAmpCalibr1 |
|
282 | 282 | self.RecAmpCalibr2 = RecAmpCalibr2 |
|
283 | 283 | self.ReceiverGaindB0 = ReceiverGaindB0 |
|
284 | 284 | self.ReceiverGaindB1 = ReceiverGaindB1 |
|
285 | 285 | self.ReceiverGaindB2 = ReceiverGaindB2 |
|
286 | 286 | self.OffsetStartHeader = 48 |
|
287 | 287 | |
|
288 | 288 | |
|
289 | 289 | |
|
290 | 290 | def RHread(self, fp): |
|
291 | 291 | #print fp |
|
292 | 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. |
|
293 | 293 | startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file. |
|
294 | 294 | #RecCounter=0 |
|
295 | 295 | #Off2StartNxtRec=811248 |
|
296 | 296 | OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec |
|
297 | 297 | print ' ' |
|
298 | 298 | print 'puntero Record Header', startFp.tell() |
|
299 | 299 | print ' ' |
|
300 | 300 | |
|
301 | 301 | |
|
302 | 302 | startFp.seek(OffRHeader, os.SEEK_SET) |
|
303 | 303 | |
|
304 | 304 | print ' ' |
|
305 | 305 | print 'puntero Record Header con seek', startFp.tell() |
|
306 | 306 | print ' ' |
|
307 | 307 | |
|
308 | 308 | #print 'Posicion del bloque: ',OffRHeader |
|
309 | 309 | |
|
310 | 310 | header = numpy.fromfile(startFp,RECORD_STRUCTURE,1) |
|
311 | 311 | |
|
312 | 312 | print ' ' |
|
313 | 313 | print 'puntero Record Header con seek', startFp.tell() |
|
314 | 314 | print ' ' |
|
315 | 315 | |
|
316 | 316 | print ' ' |
|
317 | 317 | # |
|
318 | 318 | #print 'puntero Record Header despues de seek', header.tell() |
|
319 | 319 | print ' ' |
|
320 | 320 | |
|
321 | 321 | self.RecMgcNumber = hex(header['RecMgcNumber'][0]) #0x23030001 |
|
322 | 322 | self.RecCounter = int(header['RecCounter'][0]) |
|
323 | 323 | self.Off2StartNxtRec = int(header['Off2StartNxtRec'][0]) |
|
324 | 324 | self.Off2StartData = int(header['Off2StartData'][0]) |
|
325 | 325 | self.nUtime = header['nUtime'][0] |
|
326 | 326 | self.nMilisec = header['nMilisec'][0] |
|
327 | 327 | self.ExpTagName = str(header['ExpTagName'][0]) |
|
328 | 328 | self.ExpComment = str(header['ExpComment'][0]) |
|
329 | 329 | self.SiteLatDegrees = header['SiteLatDegrees'][0] |
|
330 | 330 | self.SiteLongDegrees = header['SiteLongDegrees'][0] |
|
331 | 331 | self.RTCgpsStatus = header['RTCgpsStatus'][0] |
|
332 | 332 | self.TransmitFrec = header['TransmitFrec'][0] |
|
333 | 333 | self.ReceiveFrec = header['ReceiveFrec'][0] |
|
334 | 334 | self.FirstOsciFrec = header['FirstOsciFrec'][0] |
|
335 | 335 | self.Polarisation = header['Polarisation'][0] |
|
336 | 336 | self.ReceiverFiltSett = header['ReceiverFiltSett'][0] |
|
337 | 337 | self.nModesInUse = header['nModesInUse'][0] |
|
338 | 338 | self.DualModeIndex = header['DualModeIndex'][0] |
|
339 | 339 | self.DualModeRange = header['DualModeRange'][0] |
|
340 | 340 | self.nDigChannels = header['nDigChannels'][0] |
|
341 | 341 | self.SampResolution = header['SampResolution'][0] |
|
342 | 342 | self.nHeights = header['nHeights'][0] |
|
343 | 343 | self.StartRangeSamp = header['StartRangeSamp'][0] |
|
344 | 344 | self.PRFhz = header['PRFhz'][0] |
|
345 | 345 | self.nCohInt = header['nCohInt'][0] |
|
346 | 346 | self.nProfiles = header['nProfiles'][0] |
|
347 | 347 | self.nChannels = header['nChannels'][0] |
|
348 | 348 | self.nIncohInt = header['nIncohInt'][0] |
|
349 | 349 | self.FFTwindowingInd = header['FFTwindowingInd'][0] |
|
350 | 350 | self.BeamAngleAzim = header['BeamAngleAzim'][0] |
|
351 | 351 | self.BeamAngleZen = header['BeamAngleZen'][0] |
|
352 | 352 | self.AntennaCoord0 = header['AntennaCoord0'][0] |
|
353 | 353 | self.AntennaAngl0 = header['AntennaAngl0'][0] |
|
354 | 354 | self.AntennaCoord1 = header['AntennaCoord1'][0] |
|
355 | 355 | self.AntennaAngl1 = header['AntennaAngl1'][0] |
|
356 | 356 | self.AntennaCoord2 = header['AntennaCoord2'][0] |
|
357 | 357 | self.AntennaAngl2 = header['AntennaAngl2'][0] |
|
358 | 358 | self.RecPhaseCalibr0 = header['RecPhaseCalibr0'][0] |
|
359 | 359 | self.RecPhaseCalibr1 = header['RecPhaseCalibr1'][0] |
|
360 | 360 | self.RecPhaseCalibr2 = header['RecPhaseCalibr2'][0] |
|
361 | 361 | self.RecAmpCalibr0 = header['RecAmpCalibr0'][0] |
|
362 | 362 | self.RecAmpCalibr1 = header['RecAmpCalibr1'][0] |
|
363 | 363 | self.RecAmpCalibr2 = header['RecAmpCalibr2'][0] |
|
364 | 364 | self.ReceiverGaindB0 = header['ReceiverGaindB0'][0] |
|
365 | 365 | self.ReceiverGaindB1 = header['ReceiverGaindB1'][0] |
|
366 | 366 | self.ReceiverGaindB2 = header['ReceiverGaindB2'][0] |
|
367 | 367 | |
|
368 | 368 | self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz) |
|
369 | 369 | |
|
370 | 370 | self.RHsize = 180+20*self.nChannels |
|
371 | 371 | self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4 |
|
372 | 372 | #print 'Datasize',self.Datasize |
|
373 | 373 | endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec |
|
374 | 374 | |
|
375 | 375 | print '==============================================' |
|
376 | 376 | print 'RecMgcNumber ',self.RecMgcNumber |
|
377 | 377 | print 'RecCounter ',self.RecCounter |
|
378 | 378 | print 'Off2StartNxtRec ',self.Off2StartNxtRec |
|
379 | 379 | print 'Off2StartData ',self.Off2StartData |
|
380 | 380 | print 'Range Resolution ',self.SampResolution |
|
381 | 381 | print 'First Height ',self.StartRangeSamp |
|
382 | 382 | print 'PRF (Hz) ',self.PRFhz |
|
383 | 383 | print 'Heights (K) ',self.nHeights |
|
384 | 384 | print 'Channels (N) ',self.nChannels |
|
385 | 385 | print 'Profiles (J) ',self.nProfiles |
|
386 | 386 | print 'iCoh ',self.nCohInt |
|
387 | 387 | print 'iInCoh ',self.nIncohInt |
|
388 | 388 | print 'BeamAngleAzim ',self.BeamAngleAzim |
|
389 | 389 | print 'BeamAngleZen ',self.BeamAngleZen |
|
390 | 390 | |
|
391 | 391 | #print 'ModoEnUso ',self.DualModeIndex |
|
392 | 392 | #print 'UtcTime ',self.nUtime |
|
393 | 393 | #print 'MiliSec ',self.nMilisec |
|
394 | 394 | #print 'Exp TagName ',self.ExpTagName |
|
395 | 395 | #print 'Exp Comment ',self.ExpComment |
|
396 | 396 | #print 'FFT Window Index ',self.FFTwindowingInd |
|
397 | 397 | #print 'N Dig. Channels ',self.nDigChannels |
|
398 | 398 | print 'Size de bloque ',self.RHsize |
|
399 | 399 | print 'DataSize ',self.Datasize |
|
400 | 400 | print 'BeamAngleAzim ',self.BeamAngleAzim |
|
401 | 401 | #print 'AntennaCoord0 ',self.AntennaCoord0 |
|
402 | 402 | #print 'AntennaAngl0 ',self.AntennaAngl0 |
|
403 | 403 | #print 'AntennaCoord1 ',self.AntennaCoord1 |
|
404 | 404 | #print 'AntennaAngl1 ',self.AntennaAngl1 |
|
405 | 405 | #print 'AntennaCoord2 ',self.AntennaCoord2 |
|
406 | 406 | #print 'AntennaAngl2 ',self.AntennaAngl2 |
|
407 | 407 | print 'RecPhaseCalibr0 ',self.RecPhaseCalibr0 |
|
408 | 408 | print 'RecPhaseCalibr1 ',self.RecPhaseCalibr1 |
|
409 | 409 | print 'RecPhaseCalibr2 ',self.RecPhaseCalibr2 |
|
410 | 410 | print 'RecAmpCalibr0 ',self.RecAmpCalibr0 |
|
411 | 411 | print 'RecAmpCalibr1 ',self.RecAmpCalibr1 |
|
412 | 412 | print 'RecAmpCalibr2 ',self.RecAmpCalibr2 |
|
413 | 413 | print 'ReceiverGaindB0 ',self.ReceiverGaindB0 |
|
414 | 414 | print 'ReceiverGaindB1 ',self.ReceiverGaindB1 |
|
415 | 415 | print 'ReceiverGaindB2 ',self.ReceiverGaindB2 |
|
416 | 416 | print '==============================================' |
|
417 | 417 | |
|
418 | 418 | if OffRHeader > endFp: |
|
419 | 419 | sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp) |
|
420 | 420 | return 0 |
|
421 | 421 | |
|
422 | 422 | if OffRHeader < endFp: |
|
423 | 423 | sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp) |
|
424 | 424 | return 0 |
|
425 | 425 | |
|
426 | 426 | return 1 |
|
427 | 427 | |
|
428 | 428 | |
|
429 | 429 | class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODataReader): |
|
430 | 430 | |
|
431 | 431 | path = None |
|
432 | 432 | startDate = None |
|
433 | 433 | endDate = None |
|
434 | 434 | startTime = None |
|
435 | 435 | endTime = None |
|
436 | 436 | walk = None |
|
437 | 437 | isConfig = False |
|
438 | 438 | |
|
439 | 439 | |
|
440 | 440 | fileList= None |
|
441 | 441 | |
|
442 | 442 | #metadata |
|
443 | 443 | TimeZone= None |
|
444 | 444 | Interval= None |
|
445 | 445 | heightList= None |
|
446 | 446 | |
|
447 | 447 | #data |
|
448 | 448 | data= None |
|
449 | 449 | utctime= None |
|
450 | 450 | |
|
451 | 451 | |
|
452 | 452 | |
|
453 | 453 | def __init__(self, **kwargs): |
|
454 | 454 | |
|
455 | 455 | #Eliminar de la base la herencia |
|
456 | 456 | ProcessingUnit.__init__(self, **kwargs) |
|
457 | 457 | |
|
458 | 458 | #self.isConfig = False |
|
459 | 459 | |
|
460 | 460 | #self.pts2read_SelfSpectra = 0 |
|
461 | 461 | #self.pts2read_CrossSpectra = 0 |
|
462 | 462 | #self.pts2read_DCchannels = 0 |
|
463 | 463 | #self.datablock = None |
|
464 | 464 | self.utc = None |
|
465 | 465 | self.ext = ".fdt" |
|
466 | 466 | self.optchar = "P" |
|
467 | 467 | self.fpFile=None |
|
468 | 468 | self.fp = None |
|
469 | 469 | self.BlockCounter=0 |
|
470 | 470 | self.dtype = None |
|
471 | 471 | self.fileSizeByHeader = None |
|
472 | 472 | self.filenameList = [] |
|
473 | 473 | self.fileSelector = 0 |
|
474 | 474 | self.Off2StartNxtRec=0 |
|
475 | 475 | self.RecCounter=0 |
|
476 | 476 | self.flagNoMoreFiles = 0 |
|
477 | 477 | self.data_spc=None |
|
478 | 478 | self.data_cspc=None |
|
479 | 479 | self.data_output=None |
|
480 | 480 | self.path = None |
|
481 | 481 | self.OffsetStartHeader=0 |
|
482 | 482 | self.Off2StartData=0 |
|
483 | 483 | self.ipp = 0 |
|
484 | 484 | self.nFDTdataRecors=0 |
|
485 | 485 | self.blocksize = 0 |
|
486 | 486 | self.dataOut = Spectra() |
|
487 | 487 | self.profileIndex = 1 #Always |
|
488 | 488 | self.dataOut.flagNoData=False |
|
489 | 489 | self.dataOut.nRdPairs = 0 |
|
490 | 490 | self.dataOut.pairsList = [] |
|
491 | 491 | self.dataOut.data_spc=None |
|
492 | 492 | self.dataOut.noise=[] |
|
493 | 493 | self.dataOut.velocityX=[] |
|
494 | 494 | self.dataOut.velocityY=[] |
|
495 | 495 | self.dataOut.velocityV=[] |
|
496 | 496 | |
|
497 | 497 | |
|
498 | 498 | |
|
499 | 499 | def Files2Read(self, fp): |
|
500 | 500 | ''' |
|
501 | 501 | Function that indicates the number of .fdt files that exist in the folder to be read. |
|
502 | 502 | It also creates an organized list with the names of the files to read. |
|
503 | 503 | ''' |
|
504 | 504 | #self.__checkPath() |
|
505 | 505 | |
|
506 | 506 | ListaData=os.listdir(fp) #Gets the list of files within the fp address |
|
507 | 507 | ListaData=sorted(ListaData) #Sort the list of files from least to largest by names |
|
508 | 508 | nFiles=0 #File Counter |
|
509 | 509 | FileList=[] #A list is created that will contain the .fdt files |
|
510 | 510 | for IndexFile in ListaData : |
|
511 | 511 | if '.fdt' in IndexFile: |
|
512 | 512 | FileList.append(IndexFile) |
|
513 | 513 | nFiles+=1 |
|
514 | 514 | |
|
515 | 515 | #print 'Files2Read' |
|
516 | 516 | #print 'Existen '+str(nFiles)+' archivos .fdt' |
|
517 | 517 | |
|
518 | 518 | self.filenameList=FileList #List of files from least to largest by names |
|
519 | 519 | |
|
520 | 520 | |
|
521 | 521 | def run(self, **kwargs): |
|
522 | 522 | ''' |
|
523 | 523 | This method will be the one that will initiate the data entry, will be called constantly. |
|
524 | 524 | You should first verify that your Setup () is set up and then continue to acquire |
|
525 | 525 | the data to be processed with getData (). |
|
526 | 526 | ''' |
|
527 | 527 | if not self.isConfig: |
|
528 | 528 | self.setup(**kwargs) |
|
529 | 529 | self.isConfig = True |
|
530 | 530 | |
|
531 | 531 | self.getData() |
|
532 | 532 | #print 'running' |
|
533 | 533 | |
|
534 | 534 | |
|
535 | 535 | def setup(self, path=None, |
|
536 | 536 | startDate=None, |
|
537 | 537 | endDate=None, |
|
538 | 538 | startTime=None, |
|
539 | 539 | endTime=None, |
|
540 | 540 | walk=True, |
|
541 | 541 | timezone='utc', |
|
542 | 542 | code = None, |
|
543 | 543 | online=False, |
|
544 | 544 | ReadMode=None, |
|
545 | 545 | **kwargs): |
|
546 | 546 | |
|
547 | 547 | self.isConfig = True |
|
548 | 548 | |
|
549 | 549 | self.path=path |
|
550 | 550 | self.startDate=startDate |
|
551 | 551 | self.endDate=endDate |
|
552 | 552 | self.startTime=startTime |
|
553 | 553 | self.endTime=endTime |
|
554 | 554 | self.walk=walk |
|
555 | 555 | self.ReadMode=int(ReadMode) |
|
556 | 556 | |
|
557 | 557 | pass |
|
558 | 558 | |
|
559 | 559 | |
|
560 | 560 | def getData(self): |
|
561 | 561 | ''' |
|
562 | 562 | Before starting this function, you should check that there is still an unread file, |
|
563 | 563 | If there are still blocks to read or if the data block is empty. |
|
564 | 564 | |
|
565 | 565 | You should call the file "read". |
|
566 | 566 | |
|
567 | 567 | ''' |
|
568 | 568 | |
|
569 | 569 | if self.flagNoMoreFiles: |
|
570 | 570 | self.dataOut.flagNoData = True |
|
571 | 571 | #print 'NoData se vuelve true' |
|
572 | 572 | return 0 |
|
573 | 573 | |
|
574 | 574 | self.fp=self.path |
|
575 | 575 | self.Files2Read(self.fp) |
|
576 | 576 | self.readFile(self.fp) |
|
577 | 577 | self.dataOut.data_spc = self.data_spc |
|
578 | 578 | self.dataOut.data_cspc =self.data_cspc |
|
579 | 579 | self.dataOut.data_output=self.data_output |
|
580 | 580 | |
|
581 | 581 | #print 'self.dataOut.data_output', shape(self.dataOut.data_output) |
|
582 | 582 | |
|
583 | 583 | #self.removeDC() |
|
584 | 584 | return self.dataOut.data_spc |
|
585 | 585 | |
|
586 | 586 | |
|
587 | 587 | def readFile(self,fp): |
|
588 | 588 | ''' |
|
589 | 589 | You must indicate if you are reading in Online or Offline mode and load the |
|
590 | 590 | The parameters for this file reading mode. |
|
591 | 591 | |
|
592 | 592 | Then you must do 2 actions: |
|
593 | 593 | |
|
594 | 594 | 1. Get the BLTR FileHeader. |
|
595 | 595 | 2. Start reading the first block. |
|
596 | 596 | ''' |
|
597 | 597 | |
|
598 | 598 | #The address of the folder is generated the name of the .fdt file that will be read |
|
599 | 599 | #print "File: ",self.fileSelector+1 |
|
600 | 600 | |
|
601 | 601 | if self.fileSelector < len(self.filenameList): |
|
602 | 602 | |
|
603 | 603 | self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector]) |
|
604 | 604 | #print self.fpFile |
|
605 | 605 | fheader = FileHeaderBLTR() |
|
606 | 606 | fheader.FHread(self.fpFile) #Bltr FileHeader Reading |
|
607 | 607 | self.nFDTdataRecors=fheader.nFDTdataRecors |
|
608 | 608 | |
|
609 | 609 | self.readBlock() #Block reading |
|
610 | 610 | else: |
|
611 | 611 | #print 'readFile FlagNoData becomes true' |
|
612 | 612 | self.flagNoMoreFiles=True |
|
613 | 613 | self.dataOut.flagNoData = True |
|
614 | 614 | return 0 |
|
615 | 615 | |
|
616 | 616 | def getVelRange(self, extrapoints=0): |
|
617 | 617 | Lambda= SPEED_OF_LIGHT/50000000 |
|
618 | 618 | PRF = self.dataOut.PRF#1./(self.dataOut.ippSeconds * self.dataOut.nCohInt) |
|
619 | 619 | Vmax=-Lambda/(4.*(1./PRF)*self.dataOut.nCohInt*2.) |
|
620 | 620 | deltafreq = PRF / (self.nProfiles) |
|
621 | 621 | deltavel = (Vmax*2) / (self.nProfiles) |
|
622 | 622 | freqrange = deltafreq*(numpy.arange(self.nProfiles)-self.nProfiles/2.) - deltafreq/2 |
|
623 | 623 | velrange = deltavel*(numpy.arange(self.nProfiles)-self.nProfiles/2.) |
|
624 | 624 | return velrange |
|
625 | 625 | |
|
626 | 626 | def readBlock(self): |
|
627 | 627 | ''' |
|
628 | 628 | It should be checked if the block has data, if it is not passed to the next file. |
|
629 | 629 | |
|
630 | 630 | Then the following is done: |
|
631 | 631 | |
|
632 | 632 | 1. Read the RecordHeader |
|
633 | 633 | 2. Fill the buffer with the current block number. |
|
634 | 634 | |
|
635 | 635 | ''' |
|
636 | 636 | |
|
637 | 637 | if self.BlockCounter < self.nFDTdataRecors-1: |
|
638 | 638 | #print self.nFDTdataRecors, 'CONDICION' |
|
639 | 639 | if self.ReadMode==1: |
|
640 | 640 | rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter+1) |
|
641 | 641 | elif self.ReadMode==0: |
|
642 | 642 | rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter) |
|
643 | 643 | |
|
644 | 644 | rheader.RHread(self.fpFile) #Bltr FileHeader Reading |
|
645 | 645 | |
|
646 | 646 | self.OffsetStartHeader=rheader.OffsetStartHeader |
|
647 | 647 | self.RecCounter=rheader.RecCounter |
|
648 | 648 | self.Off2StartNxtRec=rheader.Off2StartNxtRec |
|
649 | 649 | self.Off2StartData=rheader.Off2StartData |
|
650 | 650 | self.nProfiles=rheader.nProfiles |
|
651 | 651 | self.nChannels=rheader.nChannels |
|
652 | 652 | self.nHeights=rheader.nHeights |
|
653 | 653 | self.frequency=rheader.TransmitFrec |
|
654 | 654 | self.DualModeIndex=rheader.DualModeIndex |
|
655 | 655 | |
|
656 | 656 | self.pairsList =[(0,1),(0,2),(1,2)] |
|
657 | 657 | self.dataOut.pairsList = self.pairsList |
|
658 | 658 | |
|
659 | 659 | self.nRdPairs=len(self.dataOut.pairsList) |
|
660 | 660 | self.dataOut.nRdPairs = self.nRdPairs |
|
661 | 661 | |
|
662 | 662 | self.__firstHeigth=rheader.StartRangeSamp |
|
663 | 663 | self.__deltaHeigth=rheader.SampResolution |
|
664 | 664 | self.dataOut.heightList= self.__firstHeigth + numpy.array(range(self.nHeights))*self.__deltaHeigth |
|
665 | 665 | self.dataOut.channelList = range(self.nChannels) |
|
666 | 666 | self.dataOut.nProfiles=rheader.nProfiles |
|
667 | 667 | self.dataOut.nIncohInt=rheader.nIncohInt |
|
668 | 668 | self.dataOut.nCohInt=rheader.nCohInt |
|
669 | 669 | self.dataOut.ippSeconds= 1/float(rheader.PRFhz) |
|
670 | 670 | self.dataOut.PRF=rheader.PRFhz |
|
671 | 671 | self.dataOut.nFFTPoints=rheader.nProfiles |
|
672 | 672 | self.dataOut.utctime=rheader.nUtime |
|
673 | 673 | self.dataOut.timeZone=0 |
|
674 | 674 | self.dataOut.normFactor= self.dataOut.nProfiles*self.dataOut.nIncohInt*self.dataOut.nCohInt |
|
675 | 675 | self.dataOut.outputInterval= self.dataOut.ippSeconds * self.dataOut.nCohInt * self.dataOut.nIncohInt * self.nProfiles |
|
676 | 676 | |
|
677 | 677 | self.data_output=numpy.ones([3,rheader.nHeights])*numpy.NaN |
|
678 | 678 | #print 'self.data_output', shape(self.data_output) |
|
679 | 679 | self.dataOut.velocityX=[] |
|
680 | 680 | self.dataOut.velocityY=[] |
|
681 | 681 | self.dataOut.velocityV=[] |
|
682 | 682 | |
|
683 | 683 | '''Block Reading, the Block Data is received and Reshape is used to give it |
|
684 | 684 | shape. |
|
685 | 685 | ''' |
|
686 | 686 | |
|
687 | 687 | #Procedure to take the pointer to where the date block starts |
|
688 | 688 | startDATA = open(self.fpFile,"rb") |
|
689 | 689 | OffDATA= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec+self.Off2StartData |
|
690 | 690 | startDATA.seek(OffDATA, os.SEEK_SET) |
|
691 | 691 | |
|
692 | 692 | def moving_average(x, N=2): |
|
693 | 693 | return numpy.convolve(x, numpy.ones((N,))/N)[(N-1):] |
|
694 | 694 | |
|
695 | 695 | def gaus(xSamples,a,x0,sigma): |
|
696 | 696 | return a*exp(-(xSamples-x0)**2/(2*sigma**2)) |
|
697 | 697 | |
|
698 | 698 | def Find(x,value): |
|
699 | 699 | for index in range(len(x)): |
|
700 | 700 | if x[index]==value: |
|
701 | 701 | return index |
|
702 | 702 | |
|
703 | 703 | def pol2cart(rho, phi): |
|
704 | 704 | x = rho * numpy.cos(phi) |
|
705 | 705 | y = rho * numpy.sin(phi) |
|
706 | 706 | return(x, y) |
|
707 | 707 | |
|
708 | 708 | |
|
709 | 709 | |
|
710 | 710 | |
|
711 | 711 | if self.DualModeIndex==self.ReadMode: |
|
712 | 712 | |
|
713 | 713 | self.data_fft = numpy.fromfile( startDATA, [('complex','<c8')],self.nProfiles*self.nChannels*self.nHeights ) |
|
714 | 714 | # |
|
715 | 715 | # if len(self.data_fft) is not 101376: |
|
716 | 716 | # |
|
717 | 717 | # self.data_fft = numpy.empty(101376) |
|
718 | 718 | |
|
719 | 719 | self.data_fft=self.data_fft.astype(numpy.dtype('complex')) |
|
720 | 720 | |
|
721 | 721 | |
|
722 | 722 | |
|
723 | 723 | |
|
724 | 724 | |
|
725 | 725 | self.data_block=numpy.reshape(self.data_fft,(self.nHeights, self.nChannels, self.nProfiles )) |
|
726 | 726 | |
|
727 | 727 | self.data_block = numpy.transpose(self.data_block, (1,2,0)) |
|
728 | 728 | |
|
729 | 729 | copy = self.data_block.copy() |
|
730 | 730 | spc = copy * numpy.conjugate(copy) |
|
731 | 731 | |
|
732 | 732 | self.data_spc = numpy.absolute(spc) # valor absoluto o magnitud |
|
733 | 733 | |
|
734 | 734 | factor = self.dataOut.normFactor |
|
735 | 735 | |
|
736 | 736 | |
|
737 | 737 | z = self.data_spc.copy()#/factor |
|
738 | 738 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
739 | 739 | #zdB = 10*numpy.log10(z) |
|
740 | 740 | |
|
741 | 741 | |
|
742 | 742 | self.dataOut.data_spc=self.data_spc |
|
743 | 743 | |
|
744 | 744 | self.noise = self.dataOut.getNoise(ymin_index=80, ymax_index=132)#/factor |
|
745 | 745 | #noisedB = 10*numpy.log10(self.noise) |
|
746 | 746 | |
|
747 | 747 | |
|
748 | 748 | ySamples=numpy.ones([3,self.nProfiles]) |
|
749 | 749 | phase=numpy.ones([3,self.nProfiles]) |
|
750 | 750 | CSPCSamples=numpy.ones([3,self.nProfiles],dtype=numpy.complex_) |
|
751 | 751 | coherence=numpy.ones([3,self.nProfiles]) |
|
752 | 752 | PhaseSlope=numpy.ones(3) |
|
753 | 753 | PhaseInter=numpy.ones(3) |
|
754 | 754 | |
|
755 | 755 | '''****** Getting CrossSpectra ******''' |
|
756 | 756 | cspc=self.data_block.copy() |
|
757 | 757 | self.data_cspc=self.data_block.copy() |
|
758 | 758 | |
|
759 | 759 | xFrec=self.getVelRange(1) |
|
760 | 760 | VelRange=self.getVelRange(1) |
|
761 | 761 | self.dataOut.VelRange=VelRange |
|
762 | 762 | #print ' ' |
|
763 | 763 | #print ' ' |
|
764 | 764 | #print 'xFrec',xFrec |
|
765 | 765 | #print ' ' |
|
766 | 766 | #print ' ' |
|
767 | 767 | #Height=35 |
|
768 | 768 | |
|
769 | 769 | for i in range(self.nRdPairs): |
|
770 | 770 | |
|
771 | 771 | chan_index0 = self.dataOut.pairsList[i][0] |
|
772 | 772 | chan_index1 = self.dataOut.pairsList[i][1] |
|
773 | 773 | |
|
774 | 774 | self.data_cspc[i,:,:]=cspc[chan_index0,:,:] * numpy.conjugate(cspc[chan_index1,:,:]) |
|
775 | 775 | |
|
776 | 776 | |
|
777 | 777 | '''Getting Eij and Nij''' |
|
778 | 778 | (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180) |
|
779 | 779 | (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180) |
|
780 | 780 | (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180) |
|
781 | 781 | |
|
782 | 782 | E01=AntennaX0-AntennaX1 |
|
783 | 783 | N01=AntennaY0-AntennaY1 |
|
784 | 784 | |
|
785 | 785 | E02=AntennaX0-AntennaX2 |
|
786 | 786 | N02=AntennaY0-AntennaY2 |
|
787 | 787 | |
|
788 | 788 | E12=AntennaX1-AntennaX2 |
|
789 | 789 | N12=AntennaY1-AntennaY2 |
|
790 | 790 | |
|
791 | 791 | self.ChanDist= numpy.array([[E01, N01],[E02,N02],[E12,N12]]) |
|
792 | 792 | |
|
793 | 793 | self.dataOut.ChanDist = self.ChanDist |
|
794 | 794 | |
|
795 | 795 | |
|
796 | ||
|
797 | ||
|
798 | self.BlockCounter+=2 | |
|
799 | ||
|
800 | else: | |
|
801 | self.fileSelector+=1 | |
|
802 | self.BlockCounter=0 | |
|
803 | print "Next File" No newline at end of file |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
@@ -1,1 +1,1 | |||
|
1 | <Project description="Segundo Test" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/Extra" /><Parameter format="date" id="191113" name="startDate" value="2018/02/23" /><Parameter format="date" id="191114" name="endDate" value="2018/02/23" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="03:59:50" /><Parameter format="int" id="191118" name="online" value="0" /><Parameter format="int" id="191119" name="walk" value="1" /></Operation><Operation id="19112" name="printInfo" priority="2" type="self" /><Operation id="19113" name="printNumberOfBlock" priority="3" type="self" /></ReadUnit><ProcUnit datatype="Parameters" id="1913" inputId="1912" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralFilters" priority="2" type="other"><Parameter format="float" id="191321" name="PositiveLimit" value="1.5" /><Parameter format="float" id="191322" name="NegativeLimit" value="12.5" /></Operation><Operation id="19133" name="FullSpectralAnalysis" priority="3" type="other"><Parameter format="float" id="191331" name="SNRlimit" value="-16" /><Parameter format="float" id="191332" name="Xi01" value="1.500" /><Parameter format="float" id="191333" name="Xi02" value="1.500" /><Parameter format="float" id="191334" name="Xi12" value="0" /><Parameter format="float" id="191335" name="Eta01" value="0.875" /><Parameter format="float" id="191336" name="Eta02" value="-0.875" /><Parameter format="float" id="191337" name="Eta12" value="-1.750" /></Operation><Operation id="19134" name="WindProfilerPlot" priority="4" type="other"><Parameter format="int" id="191341" name="id" value="4" /><Parameter format="str" id="191342" name="wintitle" value="Wind Profiler" /><Parameter format="float" id="191343" name="xmin" value="0" /><Parameter format="float" id="191344" name="xmax" value="4" /><Parameter format="float" id="191345" name="ymin" value="0" /><Parameter format="int" id="191346" name="ymax" value="4" /><Parameter format="float" id="191347" name="zmin" value="-20" /><Parameter format="float" id="191348" name="zmax" value="20" /><Parameter format="float" id="191349" name="SNRmin" value="-20" /><Parameter format="float" id="191350" name="SNRmax" value="20" /><Parameter format="float" id="191351" name="zmin_ver" value="-200" /><Parameter format="float" id="191352" name="zmax_ver" value="200" /><Parameter format="float" id="191353" name="SNRthresh" value="-20" /><Parameter format="int" id="191354" name="save" value="1" /><Parameter format="str" id="191355" name="figpath" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/ImagenesTesis" /></Operation><Operation id="19135" name="ParamWriter" priority="5" type="other"><Parameter format="str" id="191351" name="path" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/ImagenesTesis" /><Parameter format="int" id="191352" name="blocksPerFile" value="500" /><Parameter format="list" id="191353" name="metadataList" value="heightList,timeZone,paramInterval" /><Parameter format="list" id="191354" name="dataList" value="data_output,utctime,utctimeInit" /></Operation></ProcUnit><ProcUnit datatype="SpectraProc" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="setRadarFrequency" priority="2" type="self"><Parameter format="float" id="191221" name="frequency" value="445.09e6" /></Operation><Operation id="19123" name="setH0" priority="3" type="self"><Parameter format="float" id="191231" name="h0" value="0.500" /></Operation></ProcUnit></Project> No newline at end of file | |
|
1 | <Project description="ProcBLTR Test" id="191" name="test01"><ReadUnit datatype="BLTRSpectraReader" id="1911" inputId="0" name="BLTRSpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="BLTRSpectraReader" /><Parameter format="str" id="191112" name="path" value="/data/BLTR/2018/enero" /><Parameter format="date" id="191113" name="startDate" value="2016/11/01" /><Parameter format="date" id="191114" name="endDate" value="2016/11/01" /><Parameter format="time" id="191115" name="startTime" value="0:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="walk" value="0" /><Parameter format="str" id="191119" name="ReadMode" value="1" /><Parameter format="int" id="191120" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="Parameters" id="1913" inputId="1912" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="FullSpectralAnalysis" priority="2" type="other"><Parameter format="float" id="191321" name="SNRlimit" value="2" /></Operation><Operation id="19133" name="WindProfilerPlot" priority="3" type="other"><Parameter format="int" id="191331" name="id" value="4" /><Parameter format="str" id="191332" name="wintitle" value="Wind Profiler" /><Parameter format="int" id="191333" name="zmin" value="-20" /><Parameter format="int" id="191334" name="zmax" value="20" /><Parameter format="float" id="191335" name="zmin_ver" value="-300" /><Parameter format="float" id="191336" name="zmax_ver" value="300" /><Parameter format="int" id="191337" name="SNRmin" value="-5" /><Parameter format="int" id="191338" name="SNRmax" value="30" /><Parameter format="float" id="191339" name="xmin" value="4" /><Parameter format="float" id="191340" name="xmax" value="9" /><Parameter format="float" id="191341" name="ymin" value="0" /><Parameter format="float" id="191342" name="ymax" value="4000" /><Parameter format="int" id="191343" name="save" value="1" /><Parameter format="str" id="191344" name="figpath" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/2018" /></Operation></ProcUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="IncohInt" priority="2" type="other"><Parameter format="float" id="191221" name="n" value="2" /></Operation><Operation id="19123" name="removeDC" priority="3" type="self" /></ProcUnit></Project> No newline at end of file |
@@ -1,152 +1,153 | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | import os, sys |
|
3 | 3 | |
|
4 | 4 | # path = os.path.dirname(os.getcwd()) |
|
5 | 5 | # path = os.path.join(path, 'source') |
|
6 | 6 | # sys.path.insert(0, '../') |
|
7 | 7 | |
|
8 | 8 | from schainpy.controller import Project |
|
9 | 9 | |
|
10 | 10 | xmin = '15.5' |
|
11 | 11 | xmax = '24' |
|
12 | 12 | |
|
13 | 13 | |
|
14 | 14 | desc = "ProcBLTR Test" |
|
15 | 15 | filename = "ProcBLTR.xml" |
|
16 | 16 | figpath = '/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/2018' |
|
17 | 17 | |
|
18 | 18 | controllerObj = Project() |
|
19 | 19 | |
|
20 | 20 | |
|
21 | 21 | controllerObj.setup(id='191', name='test01', description=desc) |
|
22 | 22 | |
|
23 | 23 | readUnitConfObj = controllerObj.addReadUnit(datatype='BLTRSpectraReader', |
|
24 | 24 | #path='/media/erick/6F60F7113095A154/BLTR/', |
|
25 | 25 | #path='/data/BLTR', |
|
26 |
path='/ |
|
|
26 | path = '/data/BLTR/2018/enero', | |
|
27 | #path='/home/erick/Documents/Data/BLTR_Data/fdt/', | |
|
27 | 28 | endDate='2016/11/01', |
|
28 | 29 | startTime='0:00:00', |
|
29 | 30 | startDate='2016/11/01', |
|
30 | 31 | endTime='23:59:59', |
|
31 | 32 | |
|
32 | 33 | |
|
33 | 34 | online=0, |
|
34 | 35 | walk=0, |
|
35 | 36 | ReadMode='1') |
|
36 | 37 | # expLabel='') |
|
37 | 38 | |
|
38 | 39 | # opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
39 | 40 | |
|
40 | 41 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId()) |
|
41 | 42 | |
|
42 | 43 | |
|
43 | 44 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') |
|
44 | 45 | opObj11.addParameter(name='n', value='2', format='float') |
|
45 | 46 | |
|
46 | 47 | opObj10 = procUnitConfObj1.addOperation(name='removeDC') |
|
47 | 48 | #opObj10 = procUnitConfObj1.addOperation(name='removeInterference2') |
|
48 | 49 | |
|
49 | 50 | # opObj10 = procUnitConfObj1.addOperation(name='calcMag') |
|
50 | 51 | |
|
51 | 52 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
52 | 53 | # opObj11.addParameter(name='id', value='21', format='int') |
|
53 | 54 | # opObj11.addParameter(name='wintitle', value='SpectraCutPlot', format='str') |
|
54 | 55 | # opObj11.addParameter(name='xaxis', value='frequency', format='str') |
|
55 | 56 | # opObj11.addParameter(name='colormap', value='winter', format='str') |
|
56 | 57 | # opObj11.addParameter(name='xmin', value='-0.005', format='float') |
|
57 | 58 | # opObj11.addParameter(name='xmax', value='0.005', format='float') |
|
58 | 59 | # #opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
59 | 60 | # #opObj10.addParameter(name='channelList', value='0,1', format='intlist') |
|
60 | 61 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
61 | 62 | # opObj11.addParameter(name='id', value='21', format='int') |
|
62 | 63 | # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') |
|
63 | 64 | # #opObj11.addParameter(name='xaxis', value='Velocity', format='str') |
|
64 | 65 | |
|
65 | 66 | # opObj11.addParameter(name='xaxis', value='velocity', format='str') |
|
66 | 67 | # opObj11.addParameter(name='xmin', value='-0.005', format='float') |
|
67 | 68 | # opObj11.addParameter(name='xmax', value='0.005', format='float') |
|
68 | 69 | |
|
69 | 70 | # opObj11.addParameter(name='ymin', value='225', format='float') |
|
70 | 71 | # opObj11.addParameter(name='ymax', value='3000', format='float') |
|
71 | 72 | # opObj11.addParameter(name='zmin', value='-100', format='int') |
|
72 | 73 | # opObj11.addParameter(name='zmax', value='-65', format='int') |
|
73 | 74 | |
|
74 | 75 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
75 | 76 | # opObj11.addParameter(name='id', value='10', format='int') |
|
76 | 77 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') |
|
77 | 78 | # opObj11.addParameter(name='ymin', value='0', format='float') |
|
78 | 79 | # opObj11.addParameter(name='ymax', value='4000', format='float') |
|
79 | 80 | # #opObj11.addParameter(name='zmin', value='-100', format='int') |
|
80 | 81 | # #opObj11.addParameter(name='zmax', value='-70', format='int') |
|
81 | 82 | # opObj11.addParameter(name='zmin', value='-90', format='int') |
|
82 | 83 | # opObj11.addParameter(name='zmax', value='-40', format='int') |
|
83 | 84 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
84 | 85 | # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int') |
|
85 | 86 | |
|
86 | 87 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other') |
|
87 | 88 | # procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList') |
|
88 | 89 | # opObj11.addParameter(name='id', value='2005', format='int') |
|
89 | 90 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str') |
|
90 | 91 | # # opObj11.addParameter(name='exp_code', value='13', format='int') |
|
91 | 92 | # opObj11.addParameter(name='xaxis', value='Velocity', format='str') |
|
92 | 93 | #opObj11.addParameter(name='xmin', value='-10', format='float') |
|
93 | 94 | #opObj11.addParameter(name='xmax', value='10', format='float') |
|
94 | 95 | #opObj11.addParameter(name='ymin', value='225', format='float') |
|
95 | 96 | #opObj11.addParameter(name='ymax', value='3000', format='float') |
|
96 | 97 | #opObj11.addParameter(name='phase_min', value='-4', format='int') |
|
97 | 98 | #opObj11.addParameter(name='phase_max', value='4', format='int') |
|
98 | 99 | |
|
99 | 100 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj1.getId()) |
|
100 | 101 | # procUnitConfObj2.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList') |
|
101 | 102 | |
|
102 | 103 | procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId()) |
|
103 | 104 | #opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other') |
|
104 | 105 | opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other') |
|
105 | 106 | opObj22.addParameter(name='SNRlimit', value='2', format='float') |
|
106 | 107 | |
|
107 | 108 | opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other') |
|
108 | 109 | opObj22.addParameter(name='id', value='4', format='int') |
|
109 | 110 | opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str') |
|
110 | 111 | #opObj22.addParameter(name='save', value='1', format='bool') |
|
111 | 112 | # opObj22.addParameter(name='figpath', value = '/home/erick/Pictures', format='str') |
|
112 | 113 | |
|
113 | 114 | opObj22.addParameter(name='zmin', value='-20', format='int') |
|
114 | 115 | opObj22.addParameter(name='zmax', value='20', format='int') |
|
115 | 116 | opObj22.addParameter(name='zmin_ver', value='-300', format='float') |
|
116 | 117 | opObj22.addParameter(name='zmax_ver', value='300', format='float') |
|
117 | 118 | opObj22.addParameter(name='SNRmin', value='-5', format='int') |
|
118 | 119 | opObj22.addParameter(name='SNRmax', value='30', format='int') |
|
119 | 120 | # opObj22.addParameter(name='SNRthresh', value='-3.5', format='float') |
|
120 |
opObj22.addParameter(name='xmin', value=' |
|
|
121 |
opObj22.addParameter(name='xmax', value=' |
|
|
122 |
opObj22.addParameter(name='ymin', value=' |
|
|
123 |
|
|
|
121 | opObj22.addParameter(name='xmin', value='4', format='float') | |
|
122 | opObj22.addParameter(name='xmax', value='9', format='float') | |
|
123 | opObj22.addParameter(name='ymin', value='0', format='float') | |
|
124 | opObj22.addParameter(name='ymax', value='4000', format='float') | |
|
124 | 125 | opObj22.addParameter(name='save', value='1', format='int') |
|
125 | 126 | opObj22.addParameter(name='figpath', value=figpath, format='str') |
|
126 | 127 | |
|
127 | 128 | |
|
128 | 129 | # opObj11.addParameter(name='pairlist', value='(1,0),(0,2),(1,2)', format='pairsList') |
|
129 | 130 | #opObj10 = procUnitConfObj1.addOperation(name='selectHeights') |
|
130 | 131 | #opObj10.addParameter(name='minHei', value='225', format='float') |
|
131 | 132 | #opObj10.addParameter(name='maxHei', value='1000', format='float') |
|
132 | 133 | |
|
133 | 134 | # opObj11 = procUnitConfObj1.addOperation(name='CoherenceMap', optype='other') |
|
134 | 135 | # opObj11.addParameter(name='id', value='102', format='int') |
|
135 | 136 | # opObj11.addParameter(name='wintitle', value='Coherence', format='str') |
|
136 | 137 | # opObj11.addParameter(name='ymin', value='225', format='float') |
|
137 | 138 | # opObj11.addParameter(name='ymax', value='4000', format='float') |
|
138 | 139 | |
|
139 | 140 | # opObj11.addParameter(name='phase_cmap', value='jet', format='str') |
|
140 | 141 | # opObj11.addParameter(name='xmin', value='8.5', format='float') |
|
141 | 142 | # opObj11.addParameter(name='xmax', value='9.5', format='float') |
|
142 | 143 | # opObj11.addParameter(name='figpath', value=figpath, format='str') |
|
143 | 144 | # opObj11.addParameter(name='save', value=1, format='bool') |
|
144 | 145 | # opObj11.addParameter(name='pairsList', value='(1,0),(3,2)', format='pairsList') |
|
145 | 146 | |
|
146 | 147 | # opObj12 = procUnitConfObj1.addOperation(name='PublishData', optype='other') |
|
147 | 148 | # opObj12.addParameter(name='zeromq', value=1, format='int') |
|
148 | 149 | # opObj12.addParameter(name='verbose', value=0, format='bool') |
|
149 | 150 | # opObj12.addParameter(name='server', value='erick2', format='str') |
|
150 | 151 | controllerObj.start() |
|
151 | 152 | |
|
152 | 153 |
General Comments 0
You need to be logged in to leave comments.
Login now