|
@@
-1,795
+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 numpy.ma.core import getdata
|
|
16
|
from numpy.ma.core import getdata
|
|
17
|
|
|
17
|
|
|
18
|
SPEED_OF_LIGHT = 299792458
|
|
18
|
SPEED_OF_LIGHT = 299792458
|
|
19
|
SPEED_OF_LIGHT = 3e8
|
|
19
|
SPEED_OF_LIGHT = 3e8
|
|
20
|
|
|
20
|
|
|
21
|
try:
|
|
21
|
try:
|
|
22
|
from gevent import sleep
|
|
22
|
from gevent import sleep
|
|
23
|
except:
|
|
23
|
except:
|
|
24
|
from time import sleep
|
|
24
|
from time import sleep
|
|
25
|
|
|
25
|
|
|
26
|
from schainpy.model.data.jrodata import Spectra
|
|
26
|
from schainpy.model.data.jrodata import Spectra
|
|
27
|
#from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader
|
|
27
|
#from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader
|
|
28
|
from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
|
|
28
|
from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
|
|
29
|
#from schainpy.model.io.jroIO_bltr import BLTRReader
|
|
29
|
#from schainpy.model.io.jroIO_bltr import BLTRReader
|
|
30
|
from numpy import imag, shape, NaN
|
|
30
|
from numpy import imag, shape, NaN
|
|
31
|
|
|
31
|
|
|
32
|
from jroIO_base import JRODataReader
|
|
32
|
from jroIO_base import JRODataReader
|
|
33
|
|
|
33
|
|
|
34
|
|
|
34
|
|
|
35
|
class Header(object):
|
|
35
|
class Header(object):
|
|
36
|
|
|
36
|
|
|
37
|
def __init__(self):
|
|
37
|
def __init__(self):
|
|
38
|
raise NotImplementedError
|
|
38
|
raise NotImplementedError
|
|
39
|
|
|
39
|
|
|
40
|
|
|
40
|
|
|
41
|
def read(self):
|
|
41
|
def read(self):
|
|
42
|
|
|
42
|
|
|
43
|
raise NotImplementedError
|
|
43
|
raise NotImplementedError
|
|
44
|
|
|
44
|
|
|
45
|
def write(self):
|
|
45
|
def write(self):
|
|
46
|
|
|
46
|
|
|
47
|
raise NotImplementedError
|
|
47
|
raise NotImplementedError
|
|
48
|
|
|
48
|
|
|
49
|
def printInfo(self):
|
|
49
|
def printInfo(self):
|
|
50
|
|
|
50
|
|
|
51
|
message = "#"*50 + "\n"
|
|
51
|
message = "#"*50 + "\n"
|
|
52
|
message += self.__class__.__name__.upper() + "\n"
|
|
52
|
message += self.__class__.__name__.upper() + "\n"
|
|
53
|
message += "#"*50 + "\n"
|
|
53
|
message += "#"*50 + "\n"
|
|
54
|
|
|
54
|
|
|
55
|
keyList = self.__dict__.keys()
|
|
55
|
keyList = self.__dict__.keys()
|
|
56
|
keyList.sort()
|
|
56
|
keyList.sort()
|
|
57
|
|
|
57
|
|
|
58
|
for key in keyList:
|
|
58
|
for key in keyList:
|
|
59
|
message += "%s = %s" %(key, self.__dict__[key]) + "\n"
|
|
59
|
message += "%s = %s" %(key, self.__dict__[key]) + "\n"
|
|
60
|
|
|
60
|
|
|
61
|
if "size" not in keyList:
|
|
61
|
if "size" not in keyList:
|
|
62
|
attr = getattr(self, "size")
|
|
62
|
attr = getattr(self, "size")
|
|
63
|
|
|
63
|
|
|
64
|
if attr:
|
|
64
|
if attr:
|
|
65
|
message += "%s = %s" %("size", attr) + "\n"
|
|
65
|
message += "%s = %s" %("size", attr) + "\n"
|
|
66
|
|
|
66
|
|
|
67
|
#print message
|
|
67
|
#print message
|
|
68
|
|
|
68
|
|
|
69
|
|
|
69
|
|
|
70
|
|
|
70
|
|
|
71
|
|
|
71
|
|
|
72
|
|
|
72
|
|
|
73
|
FILE_STRUCTURE = numpy.dtype([ #HEADER 48bytes
|
|
73
|
FILE_STRUCTURE = numpy.dtype([ #HEADER 48bytes
|
|
74
|
('FileMgcNumber','<u4'), #0x23020100
|
|
74
|
('FileMgcNumber','<u4'), #0x23020100
|
|
75
|
('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)
|
|
76
|
('OffsetStartHeader','<u4'),
|
|
76
|
('OffsetStartHeader','<u4'),
|
|
77
|
('RadarUnitId','<u4'),
|
|
77
|
('RadarUnitId','<u4'),
|
|
78
|
('SiteName',numpy.str_,32), #Null terminated
|
|
78
|
('SiteName',numpy.str_,32), #Null terminated
|
|
79
|
])
|
|
79
|
])
|
|
80
|
|
|
80
|
|
|
81
|
class FileHeaderBLTR(Header):
|
|
81
|
class FileHeaderBLTR(Header):
|
|
82
|
|
|
82
|
|
|
83
|
def __init__(self):
|
|
83
|
def __init__(self):
|
|
84
|
|
|
84
|
|
|
85
|
self.FileMgcNumber= 0 #0x23020100
|
|
85
|
self.FileMgcNumber= 0 #0x23020100
|
|
86
|
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)
|
|
87
|
self.RadarUnitId= 0
|
|
87
|
self.RadarUnitId= 0
|
|
88
|
self.OffsetStartHeader=0
|
|
88
|
self.OffsetStartHeader=0
|
|
89
|
self.SiteName= ""
|
|
89
|
self.SiteName= ""
|
|
90
|
self.size = 48
|
|
90
|
self.size = 48
|
|
91
|
|
|
91
|
|
|
92
|
def FHread(self, fp):
|
|
92
|
def FHread(self, fp):
|
|
93
|
#try:
|
|
93
|
#try:
|
|
94
|
startFp = open(fp,"rb")
|
|
94
|
startFp = open(fp,"rb")
|
|
95
|
|
|
95
|
|
|
96
|
header = numpy.fromfile(startFp, FILE_STRUCTURE,1)
|
|
96
|
header = numpy.fromfile(startFp, FILE_STRUCTURE,1)
|
|
97
|
|
|
97
|
|
|
98
|
print ' '
|
|
98
|
print ' '
|
|
99
|
print 'puntero file header', startFp.tell()
|
|
99
|
print 'puntero file header', startFp.tell()
|
|
100
|
print ' '
|
|
100
|
print ' '
|
|
101
|
|
|
101
|
|
|
102
|
|
|
102
|
|
|
103
|
''' numpy.fromfile(file, dtype, count, sep='')
|
|
103
|
''' numpy.fromfile(file, dtype, count, sep='')
|
|
104
|
file : file or str
|
|
104
|
file : file or str
|
|
105
|
Open file object or filename.
|
|
105
|
Open file object or filename.
|
|
106
|
|
|
106
|
|
|
107
|
dtype : data-type
|
|
107
|
dtype : data-type
|
|
108
|
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
|
|
109
|
the size and byte-order of the items in the file.
|
|
109
|
the size and byte-order of the items in the file.
|
|
110
|
|
|
110
|
|
|
111
|
count : int
|
|
111
|
count : int
|
|
112
|
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).
|
|
113
|
|
|
113
|
|
|
114
|
sep : str
|
|
114
|
sep : str
|
|
115
|
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
|
|
116
|
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
|
|
117
|
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
|
|
118
|
at least one whitespace.
|
|
118
|
at least one whitespace.
|
|
119
|
|
|
119
|
|
|
120
|
'''
|
|
120
|
'''
|
|
121
|
|
|
121
|
|
|
122
|
|
|
122
|
|
|
123
|
|
|
123
|
|
|
124
|
self.FileMgcNumber= hex(header['FileMgcNumber'][0])
|
|
124
|
self.FileMgcNumber= hex(header['FileMgcNumber'][0])
|
|
125
|
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)
|
|
126
|
self.RadarUnitId= int(header['RadarUnitId'][0])
|
|
126
|
self.RadarUnitId= int(header['RadarUnitId'][0])
|
|
127
|
self.OffsetStartHeader= int(header['OffsetStartHeader'][0])
|
|
127
|
self.OffsetStartHeader= int(header['OffsetStartHeader'][0])
|
|
128
|
self.SiteName= str(header['SiteName'][0])
|
|
128
|
self.SiteName= str(header['SiteName'][0])
|
|
129
|
|
|
129
|
|
|
130
|
#print 'Numero de bloques', self.nFDTdataRecors
|
|
130
|
#print 'Numero de bloques', self.nFDTdataRecors
|
|
131
|
|
|
131
|
|
|
132
|
|
|
132
|
|
|
133
|
if self.size <48:
|
|
133
|
if self.size <48:
|
|
134
|
return 0
|
|
134
|
return 0
|
|
135
|
|
|
135
|
|
|
136
|
return 1
|
|
136
|
return 1
|
|
137
|
|
|
137
|
|
|
138
|
|
|
138
|
|
|
139
|
def write(self, fp):
|
|
139
|
def write(self, fp):
|
|
140
|
|
|
140
|
|
|
141
|
headerTuple = (self.FileMgcNumber,
|
|
141
|
headerTuple = (self.FileMgcNumber,
|
|
142
|
self.nFDTdataRecors,
|
|
142
|
self.nFDTdataRecors,
|
|
143
|
self.RadarUnitId,
|
|
143
|
self.RadarUnitId,
|
|
144
|
self.SiteName,
|
|
144
|
self.SiteName,
|
|
145
|
self.size)
|
|
145
|
self.size)
|
|
146
|
|
|
146
|
|
|
147
|
|
|
147
|
|
|
148
|
header = numpy.array(headerTuple, FILE_STRUCTURE)
|
|
148
|
header = numpy.array(headerTuple, FILE_STRUCTURE)
|
|
149
|
# 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)
|
|
150
|
header.tofile(fp)
|
|
150
|
header.tofile(fp)
|
|
151
|
''' 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).
|
|
152
|
|
|
152
|
|
|
153
|
fid : file or str
|
|
153
|
fid : file or str
|
|
154
|
An open file object, or a string containing a filename.
|
|
154
|
An open file object, or a string containing a filename.
|
|
155
|
|
|
155
|
|
|
156
|
sep : str
|
|
156
|
sep : str
|
|
157
|
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,
|
|
158
|
equivalent to file.write(a.tobytes()).
|
|
158
|
equivalent to file.write(a.tobytes()).
|
|
159
|
|
|
159
|
|
|
160
|
format : str
|
|
160
|
format : str
|
|
161
|
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
|
|
162
|
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.
|
|
163
|
|
|
163
|
|
|
164
|
'''
|
|
164
|
'''
|
|
165
|
|
|
165
|
|
|
166
|
return 1
|
|
166
|
return 1
|
|
167
|
|
|
167
|
|
|
168
|
|
|
168
|
|
|
169
|
|
|
169
|
|
|
170
|
|
|
170
|
|
|
171
|
|
|
171
|
|
|
172
|
RECORD_STRUCTURE = numpy.dtype([ #RECORD HEADER 180+20N bytes
|
|
172
|
RECORD_STRUCTURE = numpy.dtype([ #RECORD HEADER 180+20N bytes
|
|
173
|
('RecMgcNumber','<u4'), #0x23030001
|
|
173
|
('RecMgcNumber','<u4'), #0x23030001
|
|
174
|
('RecCounter','<u4'), #Record counter(0,1, ...)
|
|
174
|
('RecCounter','<u4'), #Record counter(0,1, ...)
|
|
175
|
('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
|
|
176
|
('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
|
|
177
|
('nUtime','<i4'), #Epoch time stamp of start of acquisition (seconds)
|
|
177
|
('nUtime','<i4'), #Epoch time stamp of start of acquisition (seconds)
|
|
178
|
('nMilisec','<u4'), #Millisecond component of time stamp (0,...,999)
|
|
178
|
('nMilisec','<u4'), #Millisecond component of time stamp (0,...,999)
|
|
179
|
('ExpTagName',numpy.str_,32), #Experiment tag name (null terminated)
|
|
179
|
('ExpTagName',numpy.str_,32), #Experiment tag name (null terminated)
|
|
180
|
('ExpComment',numpy.str_,32), #Experiment comment (null terminated)
|
|
180
|
('ExpComment',numpy.str_,32), #Experiment comment (null terminated)
|
|
181
|
('SiteLatDegrees','<f4'), #Site latitude (from GPS) in degrees (positive implies North)
|
|
181
|
('SiteLatDegrees','<f4'), #Site latitude (from GPS) in degrees (positive implies North)
|
|
182
|
('SiteLongDegrees','<f4'), #Site longitude (from GPS) in degrees (positive implies East)
|
|
182
|
('SiteLongDegrees','<f4'), #Site longitude (from GPS) in degrees (positive implies East)
|
|
183
|
('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)
|
|
184
|
('TransmitFrec','<u4'), #Transmit frequency (Hz)
|
|
184
|
('TransmitFrec','<u4'), #Transmit frequency (Hz)
|
|
185
|
('ReceiveFrec','<u4'), #Receive frequency
|
|
185
|
('ReceiveFrec','<u4'), #Receive frequency
|
|
186
|
('FirstOsciFrec','<u4'), #First local oscillator frequency (Hz)
|
|
186
|
('FirstOsciFrec','<u4'), #First local oscillator frequency (Hz)
|
|
187
|
('Polarisation','<u4'), #(0="O", 1="E", 2="linear 1", 3="linear2")
|
|
187
|
('Polarisation','<u4'), #(0="O", 1="E", 2="linear 1", 3="linear2")
|
|
188
|
('ReceiverFiltSett','<u4'), #Receiver filter settings (0,1,2,3)
|
|
188
|
('ReceiverFiltSett','<u4'), #Receiver filter settings (0,1,2,3)
|
|
189
|
('nModesInUse','<u4'), #Number of modes in use (1 or 2)
|
|
189
|
('nModesInUse','<u4'), #Number of modes in use (1 or 2)
|
|
190
|
('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)
|
|
191
|
('DualModeRange','<u4'), #Dual Mode range correction for these data (m)
|
|
191
|
('DualModeRange','<u4'), #Dual Mode range correction for these data (m)
|
|
192
|
('nDigChannels','<u4'), #Number of digital channels acquired (2*N)
|
|
192
|
('nDigChannels','<u4'), #Number of digital channels acquired (2*N)
|
|
193
|
('SampResolution','<u4'), #Sampling resolution (meters)
|
|
193
|
('SampResolution','<u4'), #Sampling resolution (meters)
|
|
194
|
('nHeights','<u4'), #Number of range gates sampled
|
|
194
|
('nHeights','<u4'), #Number of range gates sampled
|
|
195
|
('StartRangeSamp','<u4'), #Start range of sampling (meters)
|
|
195
|
('StartRangeSamp','<u4'), #Start range of sampling (meters)
|
|
196
|
('PRFhz','<u4'), #PRF (Hz)
|
|
196
|
('PRFhz','<u4'), #PRF (Hz)
|
|
197
|
('nCohInt','<u4'), #Integrations
|
|
197
|
('nCohInt','<u4'), #Integrations
|
|
198
|
('nProfiles','<u4'), #Number of data points transformed
|
|
198
|
('nProfiles','<u4'), #Number of data points transformed
|
|
199
|
('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)
|
|
200
|
('nIncohInt','<u4'), #Number of spectral averages
|
|
200
|
('nIncohInt','<u4'), #Number of spectral averages
|
|
201
|
('FFTwindowingInd','<u4'), #FFT windowing index (0 = no window)
|
|
201
|
('FFTwindowingInd','<u4'), #FFT windowing index (0 = no window)
|
|
202
|
('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)
|
|
203
|
('BeamAngleZen','<f4'), #Beam steer angle (zenith) in degrees (0=> vertical)
|
|
203
|
('BeamAngleZen','<f4'), #Beam steer angle (zenith) in degrees (0=> vertical)
|
|
204
|
('AntennaCoord0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
204
|
('AntennaCoord0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
205
|
('AntennaAngl0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
205
|
('AntennaAngl0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
206
|
('AntennaCoord1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
206
|
('AntennaCoord1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
207
|
('AntennaAngl1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
207
|
('AntennaAngl1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
208
|
('AntennaCoord2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
208
|
('AntennaCoord2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
209
|
('AntennaAngl2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
209
|
('AntennaAngl2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
|
|
210
|
('RecPhaseCalibr0','<f4'), #Receiver phase calibration (degrees) - N values
|
|
210
|
('RecPhaseCalibr0','<f4'), #Receiver phase calibration (degrees) - N values
|
|
211
|
('RecPhaseCalibr1','<f4'), #Receiver phase calibration (degrees) - N values
|
|
211
|
('RecPhaseCalibr1','<f4'), #Receiver phase calibration (degrees) - N values
|
|
212
|
('RecPhaseCalibr2','<f4'), #Receiver phase calibration (degrees) - N values
|
|
212
|
('RecPhaseCalibr2','<f4'), #Receiver phase calibration (degrees) - N values
|
|
213
|
('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
|
|
214
|
('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
|
|
215
|
('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
|
|
216
|
('ReceiverGaindB0','<i4'), #Receiver gains in dB - N values
|
|
216
|
('ReceiverGaindB0','<i4'), #Receiver gains in dB - N values
|
|
217
|
('ReceiverGaindB1','<i4'), #Receiver gains in dB - N values
|
|
217
|
('ReceiverGaindB1','<i4'), #Receiver gains in dB - N values
|
|
218
|
('ReceiverGaindB2','<i4'), #Receiver gains in dB - N values
|
|
218
|
('ReceiverGaindB2','<i4'), #Receiver gains in dB - N values
|
|
219
|
])
|
|
219
|
])
|
|
220
|
|
|
220
|
|
|
221
|
|
|
221
|
|
|
222
|
class RecordHeaderBLTR(Header):
|
|
222
|
class RecordHeaderBLTR(Header):
|
|
223
|
|
|
223
|
|
|
224
|
def __init__(self, RecMgcNumber=None, RecCounter= 0, Off2StartNxtRec= 811248,
|
|
224
|
def __init__(self, RecMgcNumber=None, RecCounter= 0, Off2StartNxtRec= 811248,
|
|
225
|
nUtime= 0, nMilisec= 0, ExpTagName= None,
|
|
225
|
nUtime= 0, nMilisec= 0, ExpTagName= None,
|
|
226
|
ExpComment=None, SiteLatDegrees=0, SiteLongDegrees= 0,
|
|
226
|
ExpComment=None, SiteLatDegrees=0, SiteLongDegrees= 0,
|
|
227
|
RTCgpsStatus= 0, TransmitFrec= 0, ReceiveFrec= 0,
|
|
227
|
RTCgpsStatus= 0, TransmitFrec= 0, ReceiveFrec= 0,
|
|
228
|
FirstOsciFrec= 0, Polarisation= 0, ReceiverFiltSett= 0,
|
|
228
|
FirstOsciFrec= 0, Polarisation= 0, ReceiverFiltSett= 0,
|
|
229
|
nModesInUse= 0, DualModeIndex= 0, DualModeRange= 0,
|
|
229
|
nModesInUse= 0, DualModeIndex= 0, DualModeRange= 0,
|
|
230
|
nDigChannels= 0, SampResolution= 0, nHeights= 0,
|
|
230
|
nDigChannels= 0, SampResolution= 0, nHeights= 0,
|
|
231
|
StartRangeSamp= 0, PRFhz= 0, nCohInt= 0,
|
|
231
|
StartRangeSamp= 0, PRFhz= 0, nCohInt= 0,
|
|
232
|
nProfiles= 0, nChannels= 0, nIncohInt= 0,
|
|
232
|
nProfiles= 0, nChannels= 0, nIncohInt= 0,
|
|
233
|
FFTwindowingInd= 0, BeamAngleAzim= 0, BeamAngleZen= 0,
|
|
233
|
FFTwindowingInd= 0, BeamAngleAzim= 0, BeamAngleZen= 0,
|
|
234
|
AntennaCoord0= 0, AntennaCoord1= 0, AntennaCoord2= 0,
|
|
234
|
AntennaCoord0= 0, AntennaCoord1= 0, AntennaCoord2= 0,
|
|
235
|
RecPhaseCalibr0= 0, RecPhaseCalibr1= 0, RecPhaseCalibr2= 0,
|
|
235
|
RecPhaseCalibr0= 0, RecPhaseCalibr1= 0, RecPhaseCalibr2= 0,
|
|
236
|
RecAmpCalibr0= 0, RecAmpCalibr1= 0, RecAmpCalibr2= 0,
|
|
236
|
RecAmpCalibr0= 0, RecAmpCalibr1= 0, RecAmpCalibr2= 0,
|
|
237
|
AntennaAngl0=0, AntennaAngl1=0, AntennaAngl2=0,
|
|
237
|
AntennaAngl0=0, AntennaAngl1=0, AntennaAngl2=0,
|
|
238
|
ReceiverGaindB0= 0, ReceiverGaindB1= 0, ReceiverGaindB2= 0, Off2StartData=0, OffsetStartHeader=0):
|
|
238
|
ReceiverGaindB0= 0, ReceiverGaindB1= 0, ReceiverGaindB2= 0, Off2StartData=0, OffsetStartHeader=0):
|
|
239
|
|
|
239
|
|
|
240
|
self.RecMgcNumber = RecMgcNumber #0x23030001
|
|
240
|
self.RecMgcNumber = RecMgcNumber #0x23030001
|
|
241
|
self.RecCounter = RecCounter
|
|
241
|
self.RecCounter = RecCounter
|
|
242
|
self.Off2StartNxtRec = Off2StartNxtRec
|
|
242
|
self.Off2StartNxtRec = Off2StartNxtRec
|
|
243
|
self.Off2StartData = Off2StartData
|
|
243
|
self.Off2StartData = Off2StartData
|
|
244
|
self.nUtime = nUtime
|
|
244
|
self.nUtime = nUtime
|
|
245
|
self.nMilisec = nMilisec
|
|
245
|
self.nMilisec = nMilisec
|
|
246
|
self.ExpTagName = ExpTagName
|
|
246
|
self.ExpTagName = ExpTagName
|
|
247
|
self.ExpComment = ExpComment
|
|
247
|
self.ExpComment = ExpComment
|
|
248
|
self.SiteLatDegrees = SiteLatDegrees
|
|
248
|
self.SiteLatDegrees = SiteLatDegrees
|
|
249
|
self.SiteLongDegrees = SiteLongDegrees
|
|
249
|
self.SiteLongDegrees = SiteLongDegrees
|
|
250
|
self.RTCgpsStatus = RTCgpsStatus
|
|
250
|
self.RTCgpsStatus = RTCgpsStatus
|
|
251
|
self.TransmitFrec = TransmitFrec
|
|
251
|
self.TransmitFrec = TransmitFrec
|
|
252
|
self.ReceiveFrec = ReceiveFrec
|
|
252
|
self.ReceiveFrec = ReceiveFrec
|
|
253
|
self.FirstOsciFrec = FirstOsciFrec
|
|
253
|
self.FirstOsciFrec = FirstOsciFrec
|
|
254
|
self.Polarisation = Polarisation
|
|
254
|
self.Polarisation = Polarisation
|
|
255
|
self.ReceiverFiltSett = ReceiverFiltSett
|
|
255
|
self.ReceiverFiltSett = ReceiverFiltSett
|
|
256
|
self.nModesInUse = nModesInUse
|
|
256
|
self.nModesInUse = nModesInUse
|
|
257
|
self.DualModeIndex = DualModeIndex
|
|
257
|
self.DualModeIndex = DualModeIndex
|
|
258
|
self.DualModeRange = DualModeRange
|
|
258
|
self.DualModeRange = DualModeRange
|
|
259
|
self.nDigChannels = nDigChannels
|
|
259
|
self.nDigChannels = nDigChannels
|
|
260
|
self.SampResolution = SampResolution
|
|
260
|
self.SampResolution = SampResolution
|
|
261
|
self.nHeights = nHeights
|
|
261
|
self.nHeights = nHeights
|
|
262
|
self.StartRangeSamp = StartRangeSamp
|
|
262
|
self.StartRangeSamp = StartRangeSamp
|
|
263
|
self.PRFhz = PRFhz
|
|
263
|
self.PRFhz = PRFhz
|
|
264
|
self.nCohInt = nCohInt
|
|
264
|
self.nCohInt = nCohInt
|
|
265
|
self.nProfiles = nProfiles
|
|
265
|
self.nProfiles = nProfiles
|
|
266
|
self.nChannels = nChannels
|
|
266
|
self.nChannels = nChannels
|
|
267
|
self.nIncohInt = nIncohInt
|
|
267
|
self.nIncohInt = nIncohInt
|
|
268
|
self.FFTwindowingInd = FFTwindowingInd
|
|
268
|
self.FFTwindowingInd = FFTwindowingInd
|
|
269
|
self.BeamAngleAzim = BeamAngleAzim
|
|
269
|
self.BeamAngleAzim = BeamAngleAzim
|
|
270
|
self.BeamAngleZen = BeamAngleZen
|
|
270
|
self.BeamAngleZen = BeamAngleZen
|
|
271
|
self.AntennaCoord0 = AntennaCoord0
|
|
271
|
self.AntennaCoord0 = AntennaCoord0
|
|
272
|
self.AntennaAngl0 = AntennaAngl0
|
|
272
|
self.AntennaAngl0 = AntennaAngl0
|
|
273
|
self.AntennaAngl1 = AntennaAngl1
|
|
273
|
self.AntennaAngl1 = AntennaAngl1
|
|
274
|
self.AntennaAngl2 = AntennaAngl2
|
|
274
|
self.AntennaAngl2 = AntennaAngl2
|
|
275
|
self.AntennaCoord1 = AntennaCoord1
|
|
275
|
self.AntennaCoord1 = AntennaCoord1
|
|
276
|
self.AntennaCoord2 = AntennaCoord2
|
|
276
|
self.AntennaCoord2 = AntennaCoord2
|
|
277
|
self.RecPhaseCalibr0 = RecPhaseCalibr0
|
|
277
|
self.RecPhaseCalibr0 = RecPhaseCalibr0
|
|
278
|
self.RecPhaseCalibr1 = RecPhaseCalibr1
|
|
278
|
self.RecPhaseCalibr1 = RecPhaseCalibr1
|
|
279
|
self.RecPhaseCalibr2 = RecPhaseCalibr2
|
|
279
|
self.RecPhaseCalibr2 = RecPhaseCalibr2
|
|
280
|
self.RecAmpCalibr0 = RecAmpCalibr0
|
|
280
|
self.RecAmpCalibr0 = RecAmpCalibr0
|
|
281
|
self.RecAmpCalibr1 = RecAmpCalibr1
|
|
281
|
self.RecAmpCalibr1 = RecAmpCalibr1
|
|
282
|
self.RecAmpCalibr2 = RecAmpCalibr2
|
|
282
|
self.RecAmpCalibr2 = RecAmpCalibr2
|
|
283
|
self.ReceiverGaindB0 = ReceiverGaindB0
|
|
283
|
self.ReceiverGaindB0 = ReceiverGaindB0
|
|
284
|
self.ReceiverGaindB1 = ReceiverGaindB1
|
|
284
|
self.ReceiverGaindB1 = ReceiverGaindB1
|
|
285
|
self.ReceiverGaindB2 = ReceiverGaindB2
|
|
285
|
self.ReceiverGaindB2 = ReceiverGaindB2
|
|
286
|
self.OffsetStartHeader = 48
|
|
286
|
self.OffsetStartHeader = 48
|
|
287
|
|
|
287
|
|
|
288
|
|
|
288
|
|
|
289
|
|
|
289
|
|
|
290
|
def RHread(self, fp):
|
|
290
|
def RHread(self, fp):
|
|
291
|
#print fp
|
|
291
|
#print fp
|
|
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.
|
|
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
|
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.
|
|
294
|
#RecCounter=0
|
|
294
|
#RecCounter=0
|
|
295
|
#Off2StartNxtRec=811248
|
|
295
|
#Off2StartNxtRec=811248
|
|
296
|
OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
|
|
296
|
OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
|
|
297
|
print ' '
|
|
297
|
print ' '
|
|
298
|
print 'puntero Record Header', startFp.tell()
|
|
298
|
print 'puntero Record Header', startFp.tell()
|
|
299
|
print ' '
|
|
299
|
print ' '
|
|
300
|
|
|
300
|
|
|
301
|
|
|
301
|
|
|
302
|
startFp.seek(OffRHeader, os.SEEK_SET)
|
|
302
|
startFp.seek(OffRHeader, os.SEEK_SET)
|
|
303
|
|
|
303
|
|
|
304
|
print ' '
|
|
304
|
print ' '
|
|
305
|
print 'puntero Record Header con seek', startFp.tell()
|
|
305
|
print 'puntero Record Header con seek', startFp.tell()
|
|
306
|
print ' '
|
|
306
|
print ' '
|
|
307
|
|
|
307
|
|
|
308
|
#print 'Posicion del bloque: ',OffRHeader
|
|
308
|
#print 'Posicion del bloque: ',OffRHeader
|
|
309
|
|
|
309
|
|
|
310
|
header = numpy.fromfile(startFp,RECORD_STRUCTURE,1)
|
|
310
|
header = numpy.fromfile(startFp,RECORD_STRUCTURE,1)
|
|
311
|
|
|
311
|
|
|
312
|
print ' '
|
|
312
|
print ' '
|
|
313
|
print 'puntero Record Header con seek', startFp.tell()
|
|
313
|
print 'puntero Record Header con seek', startFp.tell()
|
|
314
|
print ' '
|
|
314
|
print ' '
|
|
315
|
|
|
315
|
|
|
316
|
print ' '
|
|
316
|
print ' '
|
|
317
|
#
|
|
317
|
#
|
|
318
|
#print 'puntero Record Header despues de seek', header.tell()
|
|
318
|
#print 'puntero Record Header despues de seek', header.tell()
|
|
319
|
print ' '
|
|
319
|
print ' '
|
|
320
|
|
|
320
|
|
|
321
|
self.RecMgcNumber = hex(header['RecMgcNumber'][0]) #0x23030001
|
|
321
|
self.RecMgcNumber = hex(header['RecMgcNumber'][0]) #0x23030001
|
|
322
|
self.RecCounter = int(header['RecCounter'][0])
|
|
322
|
self.RecCounter = int(header['RecCounter'][0])
|
|
323
|
self.Off2StartNxtRec = int(header['Off2StartNxtRec'][0])
|
|
323
|
self.Off2StartNxtRec = int(header['Off2StartNxtRec'][0])
|
|
324
|
self.Off2StartData = int(header['Off2StartData'][0])
|
|
324
|
self.Off2StartData = int(header['Off2StartData'][0])
|
|
325
|
self.nUtime = header['nUtime'][0]
|
|
325
|
self.nUtime = header['nUtime'][0]
|
|
326
|
self.nMilisec = header['nMilisec'][0]
|
|
326
|
self.nMilisec = header['nMilisec'][0]
|
|
327
|
self.ExpTagName = str(header['ExpTagName'][0])
|
|
327
|
self.ExpTagName = str(header['ExpTagName'][0])
|
|
328
|
self.ExpComment = str(header['ExpComment'][0])
|
|
328
|
self.ExpComment = str(header['ExpComment'][0])
|
|
329
|
self.SiteLatDegrees = header['SiteLatDegrees'][0]
|
|
329
|
self.SiteLatDegrees = header['SiteLatDegrees'][0]
|
|
330
|
self.SiteLongDegrees = header['SiteLongDegrees'][0]
|
|
330
|
self.SiteLongDegrees = header['SiteLongDegrees'][0]
|
|
331
|
self.RTCgpsStatus = header['RTCgpsStatus'][0]
|
|
331
|
self.RTCgpsStatus = header['RTCgpsStatus'][0]
|
|
332
|
self.TransmitFrec = header['TransmitFrec'][0]
|
|
332
|
self.TransmitFrec = header['TransmitFrec'][0]
|
|
333
|
self.ReceiveFrec = header['ReceiveFrec'][0]
|
|
333
|
self.ReceiveFrec = header['ReceiveFrec'][0]
|
|
334
|
self.FirstOsciFrec = header['FirstOsciFrec'][0]
|
|
334
|
self.FirstOsciFrec = header['FirstOsciFrec'][0]
|
|
335
|
self.Polarisation = header['Polarisation'][0]
|
|
335
|
self.Polarisation = header['Polarisation'][0]
|
|
336
|
self.ReceiverFiltSett = header['ReceiverFiltSett'][0]
|
|
336
|
self.ReceiverFiltSett = header['ReceiverFiltSett'][0]
|
|
337
|
self.nModesInUse = header['nModesInUse'][0]
|
|
337
|
self.nModesInUse = header['nModesInUse'][0]
|
|
338
|
self.DualModeIndex = header['DualModeIndex'][0]
|
|
338
|
self.DualModeIndex = header['DualModeIndex'][0]
|
|
339
|
self.DualModeRange = header['DualModeRange'][0]
|
|
339
|
self.DualModeRange = header['DualModeRange'][0]
|
|
340
|
self.nDigChannels = header['nDigChannels'][0]
|
|
340
|
self.nDigChannels = header['nDigChannels'][0]
|
|
341
|
self.SampResolution = header['SampResolution'][0]
|
|
341
|
self.SampResolution = header['SampResolution'][0]
|
|
342
|
self.nHeights = header['nHeights'][0]
|
|
342
|
self.nHeights = header['nHeights'][0]
|
|
343
|
self.StartRangeSamp = header['StartRangeSamp'][0]
|
|
343
|
self.StartRangeSamp = header['StartRangeSamp'][0]
|
|
344
|
self.PRFhz = header['PRFhz'][0]
|
|
344
|
self.PRFhz = header['PRFhz'][0]
|
|
345
|
self.nCohInt = header['nCohInt'][0]
|
|
345
|
self.nCohInt = header['nCohInt'][0]
|
|
346
|
self.nProfiles = header['nProfiles'][0]
|
|
346
|
self.nProfiles = header['nProfiles'][0]
|
|
347
|
self.nChannels = header['nChannels'][0]
|
|
347
|
self.nChannels = header['nChannels'][0]
|
|
348
|
self.nIncohInt = header['nIncohInt'][0]
|
|
348
|
self.nIncohInt = header['nIncohInt'][0]
|
|
349
|
self.FFTwindowingInd = header['FFTwindowingInd'][0]
|
|
349
|
self.FFTwindowingInd = header['FFTwindowingInd'][0]
|
|
350
|
self.BeamAngleAzim = header['BeamAngleAzim'][0]
|
|
350
|
self.BeamAngleAzim = header['BeamAngleAzim'][0]
|
|
351
|
self.BeamAngleZen = header['BeamAngleZen'][0]
|
|
351
|
self.BeamAngleZen = header['BeamAngleZen'][0]
|
|
352
|
self.AntennaCoord0 = header['AntennaCoord0'][0]
|
|
352
|
self.AntennaCoord0 = header['AntennaCoord0'][0]
|
|
353
|
self.AntennaAngl0 = header['AntennaAngl0'][0]
|
|
353
|
self.AntennaAngl0 = header['AntennaAngl0'][0]
|
|
354
|
self.AntennaCoord1 = header['AntennaCoord1'][0]
|
|
354
|
self.AntennaCoord1 = header['AntennaCoord1'][0]
|
|
355
|
self.AntennaAngl1 = header['AntennaAngl1'][0]
|
|
355
|
self.AntennaAngl1 = header['AntennaAngl1'][0]
|
|
356
|
self.AntennaCoord2 = header['AntennaCoord2'][0]
|
|
356
|
self.AntennaCoord2 = header['AntennaCoord2'][0]
|
|
357
|
self.AntennaAngl2 = header['AntennaAngl2'][0]
|
|
357
|
self.AntennaAngl2 = header['AntennaAngl2'][0]
|
|
358
|
self.RecPhaseCalibr0 = header['RecPhaseCalibr0'][0]
|
|
358
|
self.RecPhaseCalibr0 = header['RecPhaseCalibr0'][0]
|
|
359
|
self.RecPhaseCalibr1 = header['RecPhaseCalibr1'][0]
|
|
359
|
self.RecPhaseCalibr1 = header['RecPhaseCalibr1'][0]
|
|
360
|
self.RecPhaseCalibr2 = header['RecPhaseCalibr2'][0]
|
|
360
|
self.RecPhaseCalibr2 = header['RecPhaseCalibr2'][0]
|
|
361
|
self.RecAmpCalibr0 = header['RecAmpCalibr0'][0]
|
|
361
|
self.RecAmpCalibr0 = header['RecAmpCalibr0'][0]
|
|
362
|
self.RecAmpCalibr1 = header['RecAmpCalibr1'][0]
|
|
362
|
self.RecAmpCalibr1 = header['RecAmpCalibr1'][0]
|
|
363
|
self.RecAmpCalibr2 = header['RecAmpCalibr2'][0]
|
|
363
|
self.RecAmpCalibr2 = header['RecAmpCalibr2'][0]
|
|
364
|
self.ReceiverGaindB0 = header['ReceiverGaindB0'][0]
|
|
364
|
self.ReceiverGaindB0 = header['ReceiverGaindB0'][0]
|
|
365
|
self.ReceiverGaindB1 = header['ReceiverGaindB1'][0]
|
|
365
|
self.ReceiverGaindB1 = header['ReceiverGaindB1'][0]
|
|
366
|
self.ReceiverGaindB2 = header['ReceiverGaindB2'][0]
|
|
366
|
self.ReceiverGaindB2 = header['ReceiverGaindB2'][0]
|
|
367
|
|
|
367
|
|
|
368
|
self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz)
|
|
368
|
self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz)
|
|
369
|
|
|
369
|
|
|
370
|
self.RHsize = 180+20*self.nChannels
|
|
370
|
self.RHsize = 180+20*self.nChannels
|
|
371
|
self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4
|
|
371
|
self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4
|
|
372
|
#print 'Datasize',self.Datasize
|
|
372
|
#print 'Datasize',self.Datasize
|
|
373
|
endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
|
|
373
|
endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
|
|
374
|
|
|
374
|
|
|
375
|
print '=============================================='
|
|
375
|
print '=============================================='
|
|
376
|
print 'RecMgcNumber ',self.RecMgcNumber
|
|
376
|
print 'RecMgcNumber ',self.RecMgcNumber
|
|
377
|
print 'RecCounter ',self.RecCounter
|
|
377
|
print 'RecCounter ',self.RecCounter
|
|
378
|
print 'Off2StartNxtRec ',self.Off2StartNxtRec
|
|
378
|
print 'Off2StartNxtRec ',self.Off2StartNxtRec
|
|
379
|
print 'Off2StartData ',self.Off2StartData
|
|
379
|
print 'Off2StartData ',self.Off2StartData
|
|
380
|
print 'Range Resolution ',self.SampResolution
|
|
380
|
print 'Range Resolution ',self.SampResolution
|
|
381
|
print 'First Height ',self.StartRangeSamp
|
|
381
|
print 'First Height ',self.StartRangeSamp
|
|
382
|
print 'PRF (Hz) ',self.PRFhz
|
|
382
|
print 'PRF (Hz) ',self.PRFhz
|
|
383
|
print 'Heights (K) ',self.nHeights
|
|
383
|
print 'Heights (K) ',self.nHeights
|
|
384
|
print 'Channels (N) ',self.nChannels
|
|
384
|
print 'Channels (N) ',self.nChannels
|
|
385
|
print 'Profiles (J) ',self.nProfiles
|
|
385
|
print 'Profiles (J) ',self.nProfiles
|
|
386
|
print 'iCoh ',self.nCohInt
|
|
386
|
print 'iCoh ',self.nCohInt
|
|
387
|
print 'iInCoh ',self.nIncohInt
|
|
387
|
print 'iInCoh ',self.nIncohInt
|
|
388
|
print 'BeamAngleAzim ',self.BeamAngleAzim
|
|
388
|
print 'BeamAngleAzim ',self.BeamAngleAzim
|
|
389
|
print 'BeamAngleZen ',self.BeamAngleZen
|
|
389
|
print 'BeamAngleZen ',self.BeamAngleZen
|
|
390
|
|
|
390
|
|
|
391
|
#print 'ModoEnUso ',self.DualModeIndex
|
|
391
|
#print 'ModoEnUso ',self.DualModeIndex
|
|
392
|
#print 'UtcTime ',self.nUtime
|
|
392
|
#print 'UtcTime ',self.nUtime
|
|
393
|
#print 'MiliSec ',self.nMilisec
|
|
393
|
#print 'MiliSec ',self.nMilisec
|
|
394
|
#print 'Exp TagName ',self.ExpTagName
|
|
394
|
#print 'Exp TagName ',self.ExpTagName
|
|
395
|
#print 'Exp Comment ',self.ExpComment
|
|
395
|
#print 'Exp Comment ',self.ExpComment
|
|
396
|
#print 'FFT Window Index ',self.FFTwindowingInd
|
|
396
|
#print 'FFT Window Index ',self.FFTwindowingInd
|
|
397
|
#print 'N Dig. Channels ',self.nDigChannels
|
|
397
|
#print 'N Dig. Channels ',self.nDigChannels
|
|
398
|
print 'Size de bloque ',self.RHsize
|
|
398
|
print 'Size de bloque ',self.RHsize
|
|
399
|
print 'DataSize ',self.Datasize
|
|
399
|
print 'DataSize ',self.Datasize
|
|
400
|
print 'BeamAngleAzim ',self.BeamAngleAzim
|
|
400
|
print 'BeamAngleAzim ',self.BeamAngleAzim
|
|
401
|
#print 'AntennaCoord0 ',self.AntennaCoord0
|
|
401
|
#print 'AntennaCoord0 ',self.AntennaCoord0
|
|
402
|
#print 'AntennaAngl0 ',self.AntennaAngl0
|
|
402
|
#print 'AntennaAngl0 ',self.AntennaAngl0
|
|
403
|
#print 'AntennaCoord1 ',self.AntennaCoord1
|
|
403
|
#print 'AntennaCoord1 ',self.AntennaCoord1
|
|
404
|
#print 'AntennaAngl1 ',self.AntennaAngl1
|
|
404
|
#print 'AntennaAngl1 ',self.AntennaAngl1
|
|
405
|
#print 'AntennaCoord2 ',self.AntennaCoord2
|
|
405
|
#print 'AntennaCoord2 ',self.AntennaCoord2
|
|
406
|
#print 'AntennaAngl2 ',self.AntennaAngl2
|
|
406
|
#print 'AntennaAngl2 ',self.AntennaAngl2
|
|
407
|
print 'RecPhaseCalibr0 ',self.RecPhaseCalibr0
|
|
407
|
print 'RecPhaseCalibr0 ',self.RecPhaseCalibr0
|
|
408
|
print 'RecPhaseCalibr1 ',self.RecPhaseCalibr1
|
|
408
|
print 'RecPhaseCalibr1 ',self.RecPhaseCalibr1
|
|
409
|
print 'RecPhaseCalibr2 ',self.RecPhaseCalibr2
|
|
409
|
print 'RecPhaseCalibr2 ',self.RecPhaseCalibr2
|
|
410
|
print 'RecAmpCalibr0 ',self.RecAmpCalibr0
|
|
410
|
print 'RecAmpCalibr0 ',self.RecAmpCalibr0
|
|
411
|
print 'RecAmpCalibr1 ',self.RecAmpCalibr1
|
|
411
|
print 'RecAmpCalibr1 ',self.RecAmpCalibr1
|
|
412
|
print 'RecAmpCalibr2 ',self.RecAmpCalibr2
|
|
412
|
print 'RecAmpCalibr2 ',self.RecAmpCalibr2
|
|
413
|
print 'ReceiverGaindB0 ',self.ReceiverGaindB0
|
|
413
|
print 'ReceiverGaindB0 ',self.ReceiverGaindB0
|
|
414
|
print 'ReceiverGaindB1 ',self.ReceiverGaindB1
|
|
414
|
print 'ReceiverGaindB1 ',self.ReceiverGaindB1
|
|
415
|
print 'ReceiverGaindB2 ',self.ReceiverGaindB2
|
|
415
|
print 'ReceiverGaindB2 ',self.ReceiverGaindB2
|
|
416
|
print '=============================================='
|
|
416
|
print '=============================================='
|
|
417
|
|
|
417
|
|
|
418
|
if OffRHeader > endFp:
|
|
418
|
if OffRHeader > endFp:
|
|
419
|
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)
|
|
420
|
return 0
|
|
420
|
return 0
|
|
421
|
|
|
421
|
|
|
422
|
if OffRHeader < endFp:
|
|
422
|
if OffRHeader < endFp:
|
|
423
|
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)
|
|
424
|
return 0
|
|
424
|
return 0
|
|
425
|
|
|
425
|
|
|
426
|
return 1
|
|
426
|
return 1
|
|
427
|
|
|
427
|
|
|
428
|
|
|
428
|
|
|
429
|
class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODataReader):
|
|
429
|
class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODataReader):
|
|
430
|
|
|
430
|
|
|
431
|
path = None
|
|
431
|
path = None
|
|
432
|
startDate = None
|
|
432
|
startDate = None
|
|
433
|
endDate = None
|
|
433
|
endDate = None
|
|
434
|
startTime = None
|
|
434
|
startTime = None
|
|
435
|
endTime = None
|
|
435
|
endTime = None
|
|
436
|
walk = None
|
|
436
|
walk = None
|
|
437
|
isConfig = False
|
|
437
|
isConfig = False
|
|
438
|
|
|
438
|
|
|
439
|
|
|
439
|
|
|
440
|
fileList= None
|
|
440
|
fileList= None
|
|
441
|
|
|
441
|
|
|
442
|
#metadata
|
|
442
|
#metadata
|
|
443
|
TimeZone= None
|
|
443
|
TimeZone= None
|
|
444
|
Interval= None
|
|
444
|
Interval= None
|
|
445
|
heightList= None
|
|
445
|
heightList= None
|
|
446
|
|
|
446
|
|
|
447
|
#data
|
|
447
|
#data
|
|
448
|
data= None
|
|
448
|
data= None
|
|
449
|
utctime= None
|
|
449
|
utctime= None
|
|
450
|
|
|
450
|
|
|
451
|
|
|
451
|
|
|
452
|
|
|
452
|
|
|
453
|
def __init__(self, **kwargs):
|
|
453
|
def __init__(self, **kwargs):
|
|
454
|
|
|
454
|
|
|
455
|
#Eliminar de la base la herencia
|
|
455
|
#Eliminar de la base la herencia
|
|
456
|
ProcessingUnit.__init__(self, **kwargs)
|
|
456
|
ProcessingUnit.__init__(self, **kwargs)
|
|
457
|
|
|
457
|
|
|
458
|
#self.isConfig = False
|
|
458
|
#self.isConfig = False
|
|
459
|
|
|
459
|
|
|
460
|
#self.pts2read_SelfSpectra = 0
|
|
460
|
#self.pts2read_SelfSpectra = 0
|
|
461
|
#self.pts2read_CrossSpectra = 0
|
|
461
|
#self.pts2read_CrossSpectra = 0
|
|
462
|
#self.pts2read_DCchannels = 0
|
|
462
|
#self.pts2read_DCchannels = 0
|
|
463
|
#self.datablock = None
|
|
463
|
#self.datablock = None
|
|
464
|
self.utc = None
|
|
464
|
self.utc = None
|
|
465
|
self.ext = ".fdt"
|
|
465
|
self.ext = ".fdt"
|
|
466
|
self.optchar = "P"
|
|
466
|
self.optchar = "P"
|
|
467
|
self.fpFile=None
|
|
467
|
self.fpFile=None
|
|
468
|
self.fp = None
|
|
468
|
self.fp = None
|
|
469
|
self.BlockCounter=0
|
|
469
|
self.BlockCounter=0
|
|
470
|
self.dtype = None
|
|
470
|
self.dtype = None
|
|
471
|
self.fileSizeByHeader = None
|
|
471
|
self.fileSizeByHeader = None
|
|
472
|
self.filenameList = []
|
|
472
|
self.filenameList = []
|
|
473
|
self.fileSelector = 0
|
|
473
|
self.fileSelector = 0
|
|
474
|
self.Off2StartNxtRec=0
|
|
474
|
self.Off2StartNxtRec=0
|
|
475
|
self.RecCounter=0
|
|
475
|
self.RecCounter=0
|
|
476
|
self.flagNoMoreFiles = 0
|
|
476
|
self.flagNoMoreFiles = 0
|
|
477
|
self.data_spc=None
|
|
477
|
self.data_spc=None
|
|
478
|
self.data_cspc=None
|
|
478
|
self.data_cspc=None
|
|
479
|
self.data_output=None
|
|
479
|
self.data_output=None
|
|
480
|
self.path = None
|
|
480
|
self.path = None
|
|
481
|
self.OffsetStartHeader=0
|
|
481
|
self.OffsetStartHeader=0
|
|
482
|
self.Off2StartData=0
|
|
482
|
self.Off2StartData=0
|
|
483
|
self.ipp = 0
|
|
483
|
self.ipp = 0
|
|
484
|
self.nFDTdataRecors=0
|
|
484
|
self.nFDTdataRecors=0
|
|
485
|
self.blocksize = 0
|
|
485
|
self.blocksize = 0
|
|
486
|
self.dataOut = Spectra()
|
|
486
|
self.dataOut = Spectra()
|
|
487
|
self.profileIndex = 1 #Always
|
|
487
|
self.profileIndex = 1 #Always
|
|
488
|
self.dataOut.flagNoData=False
|
|
488
|
self.dataOut.flagNoData=False
|
|
489
|
self.dataOut.nRdPairs = 0
|
|
489
|
self.dataOut.nRdPairs = 0
|
|
490
|
self.dataOut.pairsList = []
|
|
490
|
self.dataOut.pairsList = []
|
|
491
|
self.dataOut.data_spc=None
|
|
491
|
self.dataOut.data_spc=None
|
|
492
|
self.dataOut.noise=[]
|
|
492
|
self.dataOut.noise=[]
|
|
493
|
self.dataOut.velocityX=[]
|
|
493
|
self.dataOut.velocityX=[]
|
|
494
|
self.dataOut.velocityY=[]
|
|
494
|
self.dataOut.velocityY=[]
|
|
495
|
self.dataOut.velocityV=[]
|
|
495
|
self.dataOut.velocityV=[]
|
|
496
|
|
|
496
|
|
|
497
|
|
|
497
|
|
|
498
|
|
|
498
|
|
|
499
|
def Files2Read(self, fp):
|
|
499
|
def Files2Read(self, fp):
|
|
500
|
'''
|
|
500
|
'''
|
|
501
|
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.
|
|
502
|
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.
|
|
503
|
'''
|
|
503
|
'''
|
|
504
|
#self.__checkPath()
|
|
504
|
#self.__checkPath()
|
|
505
|
|
|
505
|
|
|
506
|
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
|
|
507
|
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
|
|
508
|
nFiles=0 #File Counter
|
|
508
|
nFiles=0 #File Counter
|
|
509
|
FileList=[] #A list is created that will contain the .fdt files
|
|
509
|
FileList=[] #A list is created that will contain the .fdt files
|
|
510
|
for IndexFile in ListaData :
|
|
510
|
for IndexFile in ListaData :
|
|
511
|
if '.fdt' in IndexFile:
|
|
511
|
if '.fdt' in IndexFile:
|
|
512
|
FileList.append(IndexFile)
|
|
512
|
FileList.append(IndexFile)
|
|
513
|
nFiles+=1
|
|
513
|
nFiles+=1
|
|
514
|
|
|
514
|
|
|
515
|
#print 'Files2Read'
|
|
515
|
#print 'Files2Read'
|
|
516
|
#print 'Existen '+str(nFiles)+' archivos .fdt'
|
|
516
|
#print 'Existen '+str(nFiles)+' archivos .fdt'
|
|
517
|
|
|
517
|
|
|
518
|
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
|
|
519
|
|
|
519
|
|
|
520
|
|
|
520
|
|
|
521
|
def run(self, **kwargs):
|
|
521
|
def run(self, **kwargs):
|
|
522
|
'''
|
|
522
|
'''
|
|
523
|
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.
|
|
524
|
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
|
|
525
|
the data to be processed with getData ().
|
|
525
|
the data to be processed with getData ().
|
|
526
|
'''
|
|
526
|
'''
|
|
527
|
if not self.isConfig:
|
|
527
|
if not self.isConfig:
|
|
528
|
self.setup(**kwargs)
|
|
528
|
self.setup(**kwargs)
|
|
529
|
self.isConfig = True
|
|
529
|
self.isConfig = True
|
|
530
|
|
|
530
|
|
|
531
|
self.getData()
|
|
531
|
self.getData()
|
|
532
|
#print 'running'
|
|
532
|
#print 'running'
|
|
533
|
|
|
533
|
|
|
534
|
|
|
534
|
|
|
535
|
def setup(self, path=None,
|
|
535
|
def setup(self, path=None,
|
|
536
|
startDate=None,
|
|
536
|
startDate=None,
|
|
537
|
endDate=None,
|
|
537
|
endDate=None,
|
|
538
|
startTime=None,
|
|
538
|
startTime=None,
|
|
539
|
endTime=None,
|
|
539
|
endTime=None,
|
|
540
|
walk=True,
|
|
540
|
walk=True,
|
|
541
|
timezone='utc',
|
|
541
|
timezone='utc',
|
|
542
|
code = None,
|
|
542
|
code = None,
|
|
543
|
online=False,
|
|
543
|
online=False,
|
|
544
|
ReadMode=None,
|
|
544
|
ReadMode=None,
|
|
545
|
**kwargs):
|
|
545
|
**kwargs):
|
|
546
|
|
|
546
|
|
|
547
|
self.isConfig = True
|
|
547
|
self.isConfig = True
|
|
548
|
|
|
548
|
|
|
549
|
self.path=path
|
|
549
|
self.path=path
|
|
550
|
self.startDate=startDate
|
|
550
|
self.startDate=startDate
|
|
551
|
self.endDate=endDate
|
|
551
|
self.endDate=endDate
|
|
552
|
self.startTime=startTime
|
|
552
|
self.startTime=startTime
|
|
553
|
self.endTime=endTime
|
|
553
|
self.endTime=endTime
|
|
554
|
self.walk=walk
|
|
554
|
self.walk=walk
|
|
555
|
self.ReadMode=int(ReadMode)
|
|
555
|
self.ReadMode=int(ReadMode)
|
|
556
|
|
|
556
|
|
|
557
|
pass
|
|
557
|
pass
|
|
558
|
|
|
558
|
|
|
559
|
|
|
559
|
|
|
560
|
def getData(self):
|
|
560
|
def getData(self):
|
|
561
|
'''
|
|
561
|
'''
|
|
562
|
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,
|
|
563
|
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.
|
|
564
|
|
|
564
|
|
|
565
|
You should call the file "read".
|
|
565
|
You should call the file "read".
|
|
566
|
|
|
566
|
|
|
567
|
'''
|
|
567
|
'''
|
|
568
|
|
|
568
|
|
|
569
|
if self.flagNoMoreFiles:
|
|
569
|
if self.flagNoMoreFiles:
|
|
570
|
self.dataOut.flagNoData = True
|
|
570
|
self.dataOut.flagNoData = True
|
|
571
|
#print 'NoData se vuelve true'
|
|
571
|
#print 'NoData se vuelve true'
|
|
572
|
return 0
|
|
572
|
return 0
|
|
573
|
|
|
573
|
|
|
574
|
self.fp=self.path
|
|
574
|
self.fp=self.path
|
|
575
|
self.Files2Read(self.fp)
|
|
575
|
self.Files2Read(self.fp)
|
|
576
|
self.readFile(self.fp)
|
|
576
|
self.readFile(self.fp)
|
|
577
|
self.dataOut.data_spc = self.data_spc
|
|
577
|
self.dataOut.data_spc = self.data_spc
|
|
578
|
self.dataOut.data_cspc =self.data_cspc
|
|
578
|
self.dataOut.data_cspc =self.data_cspc
|
|
579
|
self.dataOut.data_output=self.data_output
|
|
579
|
self.dataOut.data_output=self.data_output
|
|
580
|
|
|
580
|
|
|
581
|
#print 'self.dataOut.data_output', shape(self.dataOut.data_output)
|
|
581
|
#print 'self.dataOut.data_output', shape(self.dataOut.data_output)
|
|
582
|
|
|
582
|
|
|
583
|
#self.removeDC()
|
|
583
|
#self.removeDC()
|
|
584
|
return self.dataOut.data_spc
|
|
584
|
return self.dataOut.data_spc
|
|
585
|
|
|
585
|
|
|
586
|
|
|
586
|
|
|
587
|
def readFile(self,fp):
|
|
587
|
def readFile(self,fp):
|
|
588
|
'''
|
|
588
|
'''
|
|
589
|
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
|
|
590
|
The parameters for this file reading mode.
|
|
590
|
The parameters for this file reading mode.
|
|
591
|
|
|
591
|
|
|
592
|
Then you must do 2 actions:
|
|
592
|
Then you must do 2 actions:
|
|
593
|
|
|
593
|
|
|
594
|
1. Get the BLTR FileHeader.
|
|
594
|
1. Get the BLTR FileHeader.
|
|
595
|
2. Start reading the first block.
|
|
595
|
2. Start reading the first block.
|
|
596
|
'''
|
|
596
|
'''
|
|
597
|
|
|
597
|
|
|
598
|
#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
|
|
599
|
#print "File: ",self.fileSelector+1
|
|
599
|
#print "File: ",self.fileSelector+1
|
|
600
|
|
|
600
|
|
|
601
|
if self.fileSelector < len(self.filenameList):
|
|
601
|
if self.fileSelector < len(self.filenameList):
|
|
602
|
|
|
602
|
|
|
603
|
self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector])
|
|
603
|
self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector])
|
|
604
|
#print self.fpFile
|
|
604
|
#print self.fpFile
|
|
605
|
fheader = FileHeaderBLTR()
|
|
605
|
fheader = FileHeaderBLTR()
|
|
606
|
fheader.FHread(self.fpFile) #Bltr FileHeader Reading
|
|
606
|
fheader.FHread(self.fpFile) #Bltr FileHeader Reading
|
|
607
|
self.nFDTdataRecors=fheader.nFDTdataRecors
|
|
607
|
self.nFDTdataRecors=fheader.nFDTdataRecors
|
|
608
|
|
|
608
|
|
|
609
|
self.readBlock() #Block reading
|
|
609
|
self.readBlock() #Block reading
|
|
610
|
else:
|
|
610
|
else:
|
|
611
|
#print 'readFile FlagNoData becomes true'
|
|
611
|
#print 'readFile FlagNoData becomes true'
|
|
612
|
self.flagNoMoreFiles=True
|
|
612
|
self.flagNoMoreFiles=True
|
|
613
|
self.dataOut.flagNoData = True
|
|
613
|
self.dataOut.flagNoData = True
|
|
614
|
return 0
|
|
614
|
return 0
|
|
615
|
|
|
615
|
|
|
616
|
def getVelRange(self, extrapoints=0):
|
|
616
|
def getVelRange(self, extrapoints=0):
|
|
617
|
Lambda= SPEED_OF_LIGHT/50000000
|
|
617
|
Lambda= SPEED_OF_LIGHT/50000000
|
|
618
|
PRF = self.dataOut.PRF#1./(self.dataOut.ippSeconds * self.dataOut.nCohInt)
|
|
618
|
PRF = self.dataOut.PRF#1./(self.dataOut.ippSeconds * self.dataOut.nCohInt)
|
|
619
|
Vmax=-Lambda/(4.*(1./PRF)*self.dataOut.nCohInt*2.)
|
|
619
|
Vmax=-Lambda/(4.*(1./PRF)*self.dataOut.nCohInt*2.)
|
|
620
|
deltafreq = PRF / (self.nProfiles)
|
|
620
|
deltafreq = PRF / (self.nProfiles)
|
|
621
|
deltavel = (Vmax*2) / (self.nProfiles)
|
|
621
|
deltavel = (Vmax*2) / (self.nProfiles)
|
|
622
|
freqrange = deltafreq*(numpy.arange(self.nProfiles)-self.nProfiles/2.) - deltafreq/2
|
|
622
|
freqrange = deltafreq*(numpy.arange(self.nProfiles)-self.nProfiles/2.) - deltafreq/2
|
|
623
|
velrange = deltavel*(numpy.arange(self.nProfiles)-self.nProfiles/2.)
|
|
623
|
velrange = deltavel*(numpy.arange(self.nProfiles)-self.nProfiles/2.)
|
|
624
|
return velrange
|
|
624
|
return velrange
|
|
625
|
|
|
625
|
|
|
626
|
def readBlock(self):
|
|
626
|
def readBlock(self):
|
|
627
|
'''
|
|
627
|
'''
|
|
628
|
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.
|
|
629
|
|
|
629
|
|
|
630
|
Then the following is done:
|
|
630
|
Then the following is done:
|
|
631
|
|
|
631
|
|
|
632
|
1. Read the RecordHeader
|
|
632
|
1. Read the RecordHeader
|
|
633
|
2. Fill the buffer with the current block number.
|
|
633
|
2. Fill the buffer with the current block number.
|
|
634
|
|
|
634
|
|
|
635
|
'''
|
|
635
|
'''
|
|
636
|
|
|
636
|
|
|
637
|
if self.BlockCounter < self.nFDTdataRecors-1:
|
|
637
|
if self.BlockCounter < self.nFDTdataRecors-1:
|
|
638
|
#print self.nFDTdataRecors, 'CONDICION'
|
|
638
|
#print self.nFDTdataRecors, 'CONDICION'
|
|
639
|
if self.ReadMode==1:
|
|
639
|
if self.ReadMode==1:
|
|
640
|
rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter+1)
|
|
640
|
rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter+1)
|
|
641
|
elif self.ReadMode==0:
|
|
641
|
elif self.ReadMode==0:
|
|
642
|
rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter)
|
|
642
|
rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter)
|
|
643
|
|
|
643
|
|
|
644
|
rheader.RHread(self.fpFile) #Bltr FileHeader Reading
|
|
644
|
rheader.RHread(self.fpFile) #Bltr FileHeader Reading
|
|
645
|
|
|
645
|
|
|
646
|
self.OffsetStartHeader=rheader.OffsetStartHeader
|
|
646
|
self.OffsetStartHeader=rheader.OffsetStartHeader
|
|
647
|
self.RecCounter=rheader.RecCounter
|
|
647
|
self.RecCounter=rheader.RecCounter
|
|
648
|
self.Off2StartNxtRec=rheader.Off2StartNxtRec
|
|
648
|
self.Off2StartNxtRec=rheader.Off2StartNxtRec
|
|
649
|
self.Off2StartData=rheader.Off2StartData
|
|
649
|
self.Off2StartData=rheader.Off2StartData
|
|
650
|
self.nProfiles=rheader.nProfiles
|
|
650
|
self.nProfiles=rheader.nProfiles
|
|
651
|
self.nChannels=rheader.nChannels
|
|
651
|
self.nChannels=rheader.nChannels
|
|
652
|
self.nHeights=rheader.nHeights
|
|
652
|
self.nHeights=rheader.nHeights
|
|
653
|
self.frequency=rheader.TransmitFrec
|
|
653
|
self.frequency=rheader.TransmitFrec
|
|
654
|
self.DualModeIndex=rheader.DualModeIndex
|
|
654
|
self.DualModeIndex=rheader.DualModeIndex
|
|
655
|
|
|
655
|
|
|
656
|
self.pairsList =[(0,1),(0,2),(1,2)]
|
|
656
|
self.pairsList =[(0,1),(0,2),(1,2)]
|
|
657
|
self.dataOut.pairsList = self.pairsList
|
|
657
|
self.dataOut.pairsList = self.pairsList
|
|
658
|
|
|
658
|
|
|
659
|
self.nRdPairs=len(self.dataOut.pairsList)
|
|
659
|
self.nRdPairs=len(self.dataOut.pairsList)
|
|
660
|
self.dataOut.nRdPairs = self.nRdPairs
|
|
660
|
self.dataOut.nRdPairs = self.nRdPairs
|
|
661
|
|
|
661
|
|
|
662
|
self.__firstHeigth=rheader.StartRangeSamp
|
|
662
|
self.__firstHeigth=rheader.StartRangeSamp
|
|
663
|
self.__deltaHeigth=rheader.SampResolution
|
|
663
|
self.__deltaHeigth=rheader.SampResolution
|
|
664
|
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
|
|
665
|
self.dataOut.channelList = range(self.nChannels)
|
|
665
|
self.dataOut.channelList = range(self.nChannels)
|
|
666
|
self.dataOut.nProfiles=rheader.nProfiles
|
|
666
|
self.dataOut.nProfiles=rheader.nProfiles
|
|
667
|
self.dataOut.nIncohInt=rheader.nIncohInt
|
|
667
|
self.dataOut.nIncohInt=rheader.nIncohInt
|
|
668
|
self.dataOut.nCohInt=rheader.nCohInt
|
|
668
|
self.dataOut.nCohInt=rheader.nCohInt
|
|
669
|
self.dataOut.ippSeconds= 1/float(rheader.PRFhz)
|
|
669
|
self.dataOut.ippSeconds= 1/float(rheader.PRFhz)
|
|
670
|
self.dataOut.PRF=rheader.PRFhz
|
|
670
|
self.dataOut.PRF=rheader.PRFhz
|
|
671
|
self.dataOut.nFFTPoints=rheader.nProfiles
|
|
671
|
self.dataOut.nFFTPoints=rheader.nProfiles
|
|
672
|
self.dataOut.utctime=rheader.nUtime
|
|
672
|
self.dataOut.utctime=rheader.nUtime
|
|
673
|
self.dataOut.timeZone=0
|
|
673
|
self.dataOut.timeZone=0
|
|
674
|
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
|
|
675
|
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
|
|
676
|
|
|
676
|
|
|
677
|
self.data_output=numpy.ones([3,rheader.nHeights])*numpy.NaN
|
|
677
|
self.data_output=numpy.ones([3,rheader.nHeights])*numpy.NaN
|
|
678
|
#print 'self.data_output', shape(self.data_output)
|
|
678
|
#print 'self.data_output', shape(self.data_output)
|
|
679
|
self.dataOut.velocityX=[]
|
|
679
|
self.dataOut.velocityX=[]
|
|
680
|
self.dataOut.velocityY=[]
|
|
680
|
self.dataOut.velocityY=[]
|
|
681
|
self.dataOut.velocityV=[]
|
|
681
|
self.dataOut.velocityV=[]
|
|
682
|
|
|
682
|
|
|
683
|
'''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
|
|
684
|
shape.
|
|
684
|
shape.
|
|
685
|
'''
|
|
685
|
'''
|
|
686
|
|
|
686
|
|
|
687
|
#Procedure to take the pointer to where the date block starts
|
|
687
|
#Procedure to take the pointer to where the date block starts
|
|
688
|
startDATA = open(self.fpFile,"rb")
|
|
688
|
startDATA = open(self.fpFile,"rb")
|
|
689
|
OffDATA= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec+self.Off2StartData
|
|
689
|
OffDATA= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec+self.Off2StartData
|
|
690
|
startDATA.seek(OffDATA, os.SEEK_SET)
|
|
690
|
startDATA.seek(OffDATA, os.SEEK_SET)
|
|
691
|
|
|
691
|
|
|
692
|
def moving_average(x, N=2):
|
|
692
|
def moving_average(x, N=2):
|
|
693
|
return numpy.convolve(x, numpy.ones((N,))/N)[(N-1):]
|
|
693
|
return numpy.convolve(x, numpy.ones((N,))/N)[(N-1):]
|
|
694
|
|
|
694
|
|
|
695
|
def gaus(xSamples,a,x0,sigma):
|
|
695
|
def gaus(xSamples,a,x0,sigma):
|
|
696
|
return a*exp(-(xSamples-x0)**2/(2*sigma**2))
|
|
696
|
return a*exp(-(xSamples-x0)**2/(2*sigma**2))
|
|
697
|
|
|
697
|
|
|
698
|
def Find(x,value):
|
|
698
|
def Find(x,value):
|
|
699
|
for index in range(len(x)):
|
|
699
|
for index in range(len(x)):
|
|
700
|
if x[index]==value:
|
|
700
|
if x[index]==value:
|
|
701
|
return index
|
|
701
|
return index
|
|
702
|
|
|
702
|
|
|
703
|
def pol2cart(rho, phi):
|
|
703
|
def pol2cart(rho, phi):
|
|
704
|
x = rho * numpy.cos(phi)
|
|
704
|
x = rho * numpy.cos(phi)
|
|
705
|
y = rho * numpy.sin(phi)
|
|
705
|
y = rho * numpy.sin(phi)
|
|
706
|
return(x, y)
|
|
706
|
return(x, y)
|
|
707
|
|
|
707
|
|
|
708
|
|
|
708
|
|
|
709
|
|
|
709
|
|
|
710
|
|
|
710
|
|
|
711
|
if self.DualModeIndex==self.ReadMode:
|
|
711
|
if self.DualModeIndex==self.ReadMode:
|
|
712
|
|
|
712
|
|
|
713
|
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 )
|
|
714
|
#
|
|
714
|
#
|
|
715
|
# if len(self.data_fft) is not 101376:
|
|
715
|
# if len(self.data_fft) is not 101376:
|
|
716
|
#
|
|
716
|
#
|
|
717
|
# self.data_fft = numpy.empty(101376)
|
|
717
|
# self.data_fft = numpy.empty(101376)
|
|
718
|
|
|
718
|
|
|
719
|
self.data_fft=self.data_fft.astype(numpy.dtype('complex'))
|
|
719
|
self.data_fft=self.data_fft.astype(numpy.dtype('complex'))
|
|
720
|
|
|
720
|
|
|
721
|
|
|
721
|
|
|
722
|
|
|
722
|
|
|
723
|
|
|
723
|
|
|
724
|
|
|
724
|
|
|
725
|
self.data_block=numpy.reshape(self.data_fft,(self.nHeights, self.nChannels, self.nProfiles ))
|
|
725
|
self.data_block=numpy.reshape(self.data_fft,(self.nHeights, self.nChannels, self.nProfiles ))
|
|
726
|
|
|
726
|
|
|
727
|
self.data_block = numpy.transpose(self.data_block, (1,2,0))
|
|
727
|
self.data_block = numpy.transpose(self.data_block, (1,2,0))
|
|
728
|
|
|
728
|
|
|
729
|
copy = self.data_block.copy()
|
|
729
|
copy = self.data_block.copy()
|
|
730
|
spc = copy * numpy.conjugate(copy)
|
|
730
|
spc = copy * numpy.conjugate(copy)
|
|
731
|
|
|
731
|
|
|
732
|
self.data_spc = numpy.absolute(spc) # valor absoluto o magnitud
|
|
732
|
self.data_spc = numpy.absolute(spc) # valor absoluto o magnitud
|
|
733
|
|
|
733
|
|
|
734
|
factor = self.dataOut.normFactor
|
|
734
|
factor = self.dataOut.normFactor
|
|
735
|
|
|
735
|
|
|
736
|
|
|
736
|
|
|
737
|
z = self.data_spc.copy()#/factor
|
|
737
|
z = self.data_spc.copy()#/factor
|
|
738
|
z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
|
|
738
|
z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
|
|
739
|
#zdB = 10*numpy.log10(z)
|
|
739
|
#zdB = 10*numpy.log10(z)
|
|
740
|
|
|
740
|
|
|
741
|
|
|
741
|
|
|
742
|
self.dataOut.data_spc=self.data_spc
|
|
742
|
self.dataOut.data_spc=self.data_spc
|
|
743
|
|
|
743
|
|
|
744
|
self.noise = self.dataOut.getNoise(ymin_index=80, ymax_index=132)#/factor
|
|
744
|
self.noise = self.dataOut.getNoise(ymin_index=80, ymax_index=132)#/factor
|
|
745
|
#noisedB = 10*numpy.log10(self.noise)
|
|
745
|
#noisedB = 10*numpy.log10(self.noise)
|
|
746
|
|
|
746
|
|
|
747
|
|
|
747
|
|
|
748
|
ySamples=numpy.ones([3,self.nProfiles])
|
|
748
|
ySamples=numpy.ones([3,self.nProfiles])
|
|
749
|
phase=numpy.ones([3,self.nProfiles])
|
|
749
|
phase=numpy.ones([3,self.nProfiles])
|
|
750
|
CSPCSamples=numpy.ones([3,self.nProfiles],dtype=numpy.complex_)
|
|
750
|
CSPCSamples=numpy.ones([3,self.nProfiles],dtype=numpy.complex_)
|
|
751
|
coherence=numpy.ones([3,self.nProfiles])
|
|
751
|
coherence=numpy.ones([3,self.nProfiles])
|
|
752
|
PhaseSlope=numpy.ones(3)
|
|
752
|
PhaseSlope=numpy.ones(3)
|
|
753
|
PhaseInter=numpy.ones(3)
|
|
753
|
PhaseInter=numpy.ones(3)
|
|
754
|
|
|
754
|
|
|
755
|
'''****** Getting CrossSpectra ******'''
|
|
755
|
'''****** Getting CrossSpectra ******'''
|
|
756
|
cspc=self.data_block.copy()
|
|
756
|
cspc=self.data_block.copy()
|
|
757
|
self.data_cspc=self.data_block.copy()
|
|
757
|
self.data_cspc=self.data_block.copy()
|
|
758
|
|
|
758
|
|
|
759
|
xFrec=self.getVelRange(1)
|
|
759
|
xFrec=self.getVelRange(1)
|
|
760
|
VelRange=self.getVelRange(1)
|
|
760
|
VelRange=self.getVelRange(1)
|
|
761
|
self.dataOut.VelRange=VelRange
|
|
761
|
self.dataOut.VelRange=VelRange
|
|
762
|
#print ' '
|
|
762
|
#print ' '
|
|
763
|
#print ' '
|
|
763
|
#print ' '
|
|
764
|
#print 'xFrec',xFrec
|
|
764
|
#print 'xFrec',xFrec
|
|
765
|
#print ' '
|
|
765
|
#print ' '
|
|
766
|
#print ' '
|
|
766
|
#print ' '
|
|
767
|
#Height=35
|
|
767
|
#Height=35
|
|
768
|
|
|
768
|
|
|
769
|
for i in range(self.nRdPairs):
|
|
769
|
for i in range(self.nRdPairs):
|
|
770
|
|
|
770
|
|
|
771
|
chan_index0 = self.dataOut.pairsList[i][0]
|
|
771
|
chan_index0 = self.dataOut.pairsList[i][0]
|
|
772
|
chan_index1 = self.dataOut.pairsList[i][1]
|
|
772
|
chan_index1 = self.dataOut.pairsList[i][1]
|
|
773
|
|
|
773
|
|
|
774
|
self.data_cspc[i,:,:]=cspc[chan_index0,:,:] * numpy.conjugate(cspc[chan_index1,:,:])
|
|
774
|
self.data_cspc[i,:,:]=cspc[chan_index0,:,:] * numpy.conjugate(cspc[chan_index1,:,:])
|
|
775
|
|
|
775
|
|
|
776
|
|
|
776
|
|
|
777
|
'''Getting Eij and Nij'''
|
|
777
|
'''Getting Eij and Nij'''
|
|
778
|
(AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
|
|
778
|
(AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
|
|
779
|
(AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
|
|
779
|
(AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
|
|
780
|
(AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
|
|
780
|
(AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
|
|
781
|
|
|
781
|
|
|
782
|
E01=AntennaX0-AntennaX1
|
|
782
|
E01=AntennaX0-AntennaX1
|
|
783
|
N01=AntennaY0-AntennaY1
|
|
783
|
N01=AntennaY0-AntennaY1
|
|
784
|
|
|
784
|
|
|
785
|
E02=AntennaX0-AntennaX2
|
|
785
|
E02=AntennaX0-AntennaX2
|
|
786
|
N02=AntennaY0-AntennaY2
|
|
786
|
N02=AntennaY0-AntennaY2
|
|
787
|
|
|
787
|
|
|
788
|
E12=AntennaX1-AntennaX2
|
|
788
|
E12=AntennaX1-AntennaX2
|
|
789
|
N12=AntennaY1-AntennaY2
|
|
789
|
N12=AntennaY1-AntennaY2
|
|
790
|
|
|
790
|
|
|
791
|
self.ChanDist= numpy.array([[E01, N01],[E02,N02],[E12,N12]])
|
|
791
|
self.ChanDist= numpy.array([[E01, N01],[E02,N02],[E12,N12]])
|
|
792
|
|
|
792
|
|
|
793
|
self.dataOut.ChanDist = self.ChanDist
|
|
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
|