@@ -1,861 +1,876 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author: murco $ |
|
3 | $Author: murco $ | |
4 | $Id: JROHeaderIO.py 151 2012-10-31 19:00:51Z murco $ |
|
4 | $Id: JROHeaderIO.py 151 2012-10-31 19:00:51Z murco $ | |
5 | ''' |
|
5 | ''' | |
6 | import sys |
|
6 | import sys | |
7 | import numpy |
|
7 | import numpy | |
8 | import copy |
|
8 | import copy | |
9 | import datetime |
|
9 | import datetime | |
10 | import inspect |
|
10 | import inspect | |
11 |
|
11 | |||
12 | SPEED_OF_LIGHT = 299792458 |
|
12 | SPEED_OF_LIGHT = 299792458 | |
13 | SPEED_OF_LIGHT = 3e8 |
|
13 | SPEED_OF_LIGHT = 3e8 | |
14 |
|
14 | |||
15 | BASIC_STRUCTURE = numpy.dtype([ |
|
15 | BASIC_STRUCTURE = numpy.dtype([ | |
16 | ('nSize','<u4'), |
|
16 | ('nSize','<u4'), | |
17 | ('nVersion','<u2'), |
|
17 | ('nVersion','<u2'), | |
18 | ('nDataBlockId','<u4'), |
|
18 | ('nDataBlockId','<u4'), | |
19 | ('nUtime','<u4'), |
|
19 | ('nUtime','<u4'), | |
20 | ('nMilsec','<u2'), |
|
20 | ('nMilsec','<u2'), | |
21 | ('nTimezone','<i2'), |
|
21 | ('nTimezone','<i2'), | |
22 | ('nDstflag','<i2'), |
|
22 | ('nDstflag','<i2'), | |
23 | ('nErrorCount','<u4') |
|
23 | ('nErrorCount','<u4') | |
24 | ]) |
|
24 | ]) | |
25 |
|
25 | |||
26 | SYSTEM_STRUCTURE = numpy.dtype([ |
|
26 | SYSTEM_STRUCTURE = numpy.dtype([ | |
27 | ('nSize','<u4'), |
|
27 | ('nSize','<u4'), | |
28 | ('nNumSamples','<u4'), |
|
28 | ('nNumSamples','<u4'), | |
29 | ('nNumProfiles','<u4'), |
|
29 | ('nNumProfiles','<u4'), | |
30 | ('nNumChannels','<u4'), |
|
30 | ('nNumChannels','<u4'), | |
31 | ('nADCResolution','<u4'), |
|
31 | ('nADCResolution','<u4'), | |
32 | ('nPCDIOBusWidth','<u4'), |
|
32 | ('nPCDIOBusWidth','<u4'), | |
33 | ]) |
|
33 | ]) | |
34 |
|
34 | |||
35 | RADAR_STRUCTURE = numpy.dtype([ |
|
35 | RADAR_STRUCTURE = numpy.dtype([ | |
36 | ('nSize','<u4'), |
|
36 | ('nSize','<u4'), | |
37 | ('nExpType','<u4'), |
|
37 | ('nExpType','<u4'), | |
38 | ('nNTx','<u4'), |
|
38 | ('nNTx','<u4'), | |
39 | ('fIpp','<f4'), |
|
39 | ('fIpp','<f4'), | |
40 | ('fTxA','<f4'), |
|
40 | ('fTxA','<f4'), | |
41 | ('fTxB','<f4'), |
|
41 | ('fTxB','<f4'), | |
42 | ('nNumWindows','<u4'), |
|
42 | ('nNumWindows','<u4'), | |
43 | ('nNumTaus','<u4'), |
|
43 | ('nNumTaus','<u4'), | |
44 | ('nCodeType','<u4'), |
|
44 | ('nCodeType','<u4'), | |
45 | ('nLine6Function','<u4'), |
|
45 | ('nLine6Function','<u4'), | |
46 | ('nLine5Function','<u4'), |
|
46 | ('nLine5Function','<u4'), | |
47 | ('fClock','<f4'), |
|
47 | ('fClock','<f4'), | |
48 | ('nPrePulseBefore','<u4'), |
|
48 | ('nPrePulseBefore','<u4'), | |
49 | ('nPrePulseAfter','<u4'), |
|
49 | ('nPrePulseAfter','<u4'), | |
50 | ('sRangeIPP','<a20'), |
|
50 | ('sRangeIPP','<a20'), | |
51 | ('sRangeTxA','<a20'), |
|
51 | ('sRangeTxA','<a20'), | |
52 | ('sRangeTxB','<a20'), |
|
52 | ('sRangeTxB','<a20'), | |
53 | ]) |
|
53 | ]) | |
54 |
|
54 | |||
55 | SAMPLING_STRUCTURE = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) |
|
55 | SAMPLING_STRUCTURE = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | PROCESSING_STRUCTURE = numpy.dtype([ |
|
58 | PROCESSING_STRUCTURE = numpy.dtype([ | |
59 | ('nSize','<u4'), |
|
59 | ('nSize','<u4'), | |
60 | ('nDataType','<u4'), |
|
60 | ('nDataType','<u4'), | |
61 | ('nSizeOfDataBlock','<u4'), |
|
61 | ('nSizeOfDataBlock','<u4'), | |
62 | ('nProfilesperBlock','<u4'), |
|
62 | ('nProfilesperBlock','<u4'), | |
63 | ('nDataBlocksperFile','<u4'), |
|
63 | ('nDataBlocksperFile','<u4'), | |
64 | ('nNumWindows','<u4'), |
|
64 | ('nNumWindows','<u4'), | |
65 | ('nProcessFlags','<u4'), |
|
65 | ('nProcessFlags','<u4'), | |
66 | ('nCoherentIntegrations','<u4'), |
|
66 | ('nCoherentIntegrations','<u4'), | |
67 | ('nIncoherentIntegrations','<u4'), |
|
67 | ('nIncoherentIntegrations','<u4'), | |
68 | ('nTotalSpectra','<u4') |
|
68 | ('nTotalSpectra','<u4') | |
69 | ]) |
|
69 | ]) | |
70 |
|
70 | |||
71 | class Header(object): |
|
71 | class Header(object): | |
72 |
|
72 | |||
73 | def __init__(self): |
|
73 | def __init__(self): | |
74 | raise NotImplementedError |
|
74 | raise NotImplementedError | |
75 |
|
75 | |||
76 | def copy(self): |
|
76 | def copy(self): | |
77 | return copy.deepcopy(self) |
|
77 | return copy.deepcopy(self) | |
78 |
|
78 | |||
79 | def read(self): |
|
79 | def read(self): | |
80 |
|
80 | |||
81 | raise NotImplementedError |
|
81 | raise NotImplementedError | |
82 |
|
82 | |||
83 | def write(self): |
|
83 | def write(self): | |
84 |
|
84 | |||
85 | raise NotImplementedError |
|
85 | raise NotImplementedError | |
86 |
|
86 | |||
87 | def getAllowedArgs(self): |
|
87 | def getAllowedArgs(self): | |
88 |
|
|
88 | args = inspect.getargspec(self.__init__).args | |
|
89 | try: | |||
|
90 | args.remove('self') | |||
|
91 | except: | |||
|
92 | pass | |||
|
93 | return args | |||
|
94 | ||||
|
95 | def getAsDict(self): | |||
|
96 | args = self.getAllowedArgs() | |||
|
97 | asDict = {} | |||
|
98 | for x in args: | |||
|
99 | asDict[x] = self[x] | |||
|
100 | return asDict | |||
|
101 | ||||
|
102 | def __getitem__(self, name): | |||
|
103 | return getattr(self, name) | |||
89 |
|
104 | |||
90 | def printInfo(self): |
|
105 | def printInfo(self): | |
91 |
|
106 | |||
92 | message = "#"*50 + "\n" |
|
107 | message = "#"*50 + "\n" | |
93 | message += self.__class__.__name__.upper() + "\n" |
|
108 | message += self.__class__.__name__.upper() + "\n" | |
94 | message += "#"*50 + "\n" |
|
109 | message += "#"*50 + "\n" | |
95 |
|
110 | |||
96 | keyList = self.__dict__.keys() |
|
111 | keyList = self.__dict__.keys() | |
97 | keyList.sort() |
|
112 | keyList.sort() | |
98 |
|
113 | |||
99 | for key in keyList: |
|
114 | for key in keyList: | |
100 | message += "%s = %s" %(key, self.__dict__[key]) + "\n" |
|
115 | message += "%s = %s" %(key, self.__dict__[key]) + "\n" | |
101 |
|
116 | |||
102 | if "size" not in keyList: |
|
117 | if "size" not in keyList: | |
103 | attr = getattr(self, "size") |
|
118 | attr = getattr(self, "size") | |
104 |
|
119 | |||
105 | if attr: |
|
120 | if attr: | |
106 | message += "%s = %s" %("size", attr) + "\n" |
|
121 | message += "%s = %s" %("size", attr) + "\n" | |
107 |
|
122 | |||
108 | print message |
|
123 | print message | |
109 |
|
124 | |||
110 | class BasicHeader(Header): |
|
125 | class BasicHeader(Header): | |
111 |
|
126 | |||
112 | size = None |
|
127 | size = None | |
113 | version = None |
|
128 | version = None | |
114 | dataBlock = None |
|
129 | dataBlock = None | |
115 | utc = None |
|
130 | utc = None | |
116 | ltc = None |
|
131 | ltc = None | |
117 | miliSecond = None |
|
132 | miliSecond = None | |
118 | timeZone = None |
|
133 | timeZone = None | |
119 | dstFlag = None |
|
134 | dstFlag = None | |
120 | errorCount = None |
|
135 | errorCount = None | |
121 | datatime = None |
|
136 | datatime = None | |
122 | structure = BASIC_STRUCTURE |
|
137 | structure = BASIC_STRUCTURE | |
123 | __LOCALTIME = None |
|
138 | __LOCALTIME = None | |
124 |
|
139 | |||
125 | def __init__(self, useLocalTime=True): |
|
140 | def __init__(self, useLocalTime=True): | |
126 |
|
141 | |||
127 | self.size = 24 |
|
142 | self.size = 24 | |
128 | self.version = 0 |
|
143 | self.version = 0 | |
129 | self.dataBlock = 0 |
|
144 | self.dataBlock = 0 | |
130 | self.utc = 0 |
|
145 | self.utc = 0 | |
131 | self.miliSecond = 0 |
|
146 | self.miliSecond = 0 | |
132 | self.timeZone = 0 |
|
147 | self.timeZone = 0 | |
133 | self.dstFlag = 0 |
|
148 | self.dstFlag = 0 | |
134 | self.errorCount = 0 |
|
149 | self.errorCount = 0 | |
135 |
|
150 | |||
136 | self.useLocalTime = useLocalTime |
|
151 | self.useLocalTime = useLocalTime | |
137 |
|
152 | |||
138 | def read(self, fp): |
|
153 | def read(self, fp): | |
139 |
|
154 | |||
140 | self.length = 0 |
|
155 | self.length = 0 | |
141 | try: |
|
156 | try: | |
142 | if hasattr(fp, 'read'): |
|
157 | if hasattr(fp, 'read'): | |
143 | header = numpy.fromfile(fp, BASIC_STRUCTURE,1) |
|
158 | header = numpy.fromfile(fp, BASIC_STRUCTURE,1) | |
144 | else: |
|
159 | else: | |
145 | header = numpy.fromstring(fp, BASIC_STRUCTURE,1) |
|
160 | header = numpy.fromstring(fp, BASIC_STRUCTURE,1) | |
146 | except Exception, e: |
|
161 | except Exception, e: | |
147 | print "BasicHeader: " |
|
162 | print "BasicHeader: " | |
148 | print e |
|
163 | print e | |
149 | return 0 |
|
164 | return 0 | |
150 |
|
165 | |||
151 | self.size = int(header['nSize'][0]) |
|
166 | self.size = int(header['nSize'][0]) | |
152 | self.version = int(header['nVersion'][0]) |
|
167 | self.version = int(header['nVersion'][0]) | |
153 | self.dataBlock = int(header['nDataBlockId'][0]) |
|
168 | self.dataBlock = int(header['nDataBlockId'][0]) | |
154 | self.utc = int(header['nUtime'][0]) |
|
169 | self.utc = int(header['nUtime'][0]) | |
155 | self.miliSecond = int(header['nMilsec'][0]) |
|
170 | self.miliSecond = int(header['nMilsec'][0]) | |
156 | self.timeZone = int(header['nTimezone'][0]) |
|
171 | self.timeZone = int(header['nTimezone'][0]) | |
157 | self.dstFlag = int(header['nDstflag'][0]) |
|
172 | self.dstFlag = int(header['nDstflag'][0]) | |
158 | self.errorCount = int(header['nErrorCount'][0]) |
|
173 | self.errorCount = int(header['nErrorCount'][0]) | |
159 |
|
174 | |||
160 | if self.size < 24: |
|
175 | if self.size < 24: | |
161 | return 0 |
|
176 | return 0 | |
162 |
|
177 | |||
163 | self.length = header.nbytes |
|
178 | self.length = header.nbytes | |
164 | return 1 |
|
179 | return 1 | |
165 |
|
180 | |||
166 | def write(self, fp): |
|
181 | def write(self, fp): | |
167 |
|
182 | |||
168 | headerTuple = (self.size,self.version,self.dataBlock,self.utc,self.miliSecond,self.timeZone,self.dstFlag,self.errorCount) |
|
183 | headerTuple = (self.size,self.version,self.dataBlock,self.utc,self.miliSecond,self.timeZone,self.dstFlag,self.errorCount) | |
169 | header = numpy.array(headerTuple, BASIC_STRUCTURE) |
|
184 | header = numpy.array(headerTuple, BASIC_STRUCTURE) | |
170 | header.tofile(fp) |
|
185 | header.tofile(fp) | |
171 |
|
186 | |||
172 | return 1 |
|
187 | return 1 | |
173 |
|
188 | |||
174 | def get_ltc(self): |
|
189 | def get_ltc(self): | |
175 |
|
190 | |||
176 | return self.utc - self.timeZone*60 |
|
191 | return self.utc - self.timeZone*60 | |
177 |
|
192 | |||
178 | def set_ltc(self, value): |
|
193 | def set_ltc(self, value): | |
179 |
|
194 | |||
180 | self.utc = value + self.timeZone*60 |
|
195 | self.utc = value + self.timeZone*60 | |
181 |
|
196 | |||
182 | def get_datatime(self): |
|
197 | def get_datatime(self): | |
183 |
|
198 | |||
184 | return datetime.datetime.utcfromtimestamp(self.ltc) |
|
199 | return datetime.datetime.utcfromtimestamp(self.ltc) | |
185 |
|
200 | |||
186 | ltc = property(get_ltc, set_ltc) |
|
201 | ltc = property(get_ltc, set_ltc) | |
187 | datatime = property(get_datatime) |
|
202 | datatime = property(get_datatime) | |
188 |
|
203 | |||
189 | class SystemHeader(Header): |
|
204 | class SystemHeader(Header): | |
190 |
|
205 | |||
191 | size = None |
|
206 | size = None | |
192 | nSamples = None |
|
207 | nSamples = None | |
193 | nProfiles = None |
|
208 | nProfiles = None | |
194 | nChannels = None |
|
209 | nChannels = None | |
195 | adcResolution = None |
|
210 | adcResolution = None | |
196 | pciDioBusWidth = None |
|
211 | pciDioBusWidth = None | |
197 | structure = SYSTEM_STRUCTURE |
|
212 | structure = SYSTEM_STRUCTURE | |
198 |
|
213 | |||
199 | def __init__(self, nSamples=0, nProfiles=0, nChannels=0, adcResolution=14, pciDioBusWith=0): |
|
214 | def __init__(self, nSamples=0, nProfiles=0, nChannels=0, adcResolution=14, pciDioBusWidth=0): | |
200 |
|
215 | |||
201 | self.size = 24 |
|
216 | self.size = 24 | |
202 | self.nSamples = nSamples |
|
217 | self.nSamples = nSamples | |
203 | self.nProfiles = nProfiles |
|
218 | self.nProfiles = nProfiles | |
204 | self.nChannels = nChannels |
|
219 | self.nChannels = nChannels | |
205 | self.adcResolution = adcResolution |
|
220 | self.adcResolution = adcResolution | |
206 | self.pciDioBusWidth = pciDioBusWith |
|
221 | self.pciDioBusWidth = pciDioBusWidth | |
207 |
|
222 | |||
208 | def read(self, fp): |
|
223 | def read(self, fp): | |
209 | self.length = 0 |
|
224 | self.length = 0 | |
210 | try: |
|
225 | try: | |
211 | startFp = fp.tell() |
|
226 | startFp = fp.tell() | |
212 | except Exception, e: |
|
227 | except Exception, e: | |
213 | startFp = None |
|
228 | startFp = None | |
214 | pass |
|
229 | pass | |
215 |
|
230 | |||
216 | try: |
|
231 | try: | |
217 | if hasattr(fp, 'read'): |
|
232 | if hasattr(fp, 'read'): | |
218 | header = numpy.fromfile(fp, SYSTEM_STRUCTURE,1) |
|
233 | header = numpy.fromfile(fp, SYSTEM_STRUCTURE,1) | |
219 | else: |
|
234 | else: | |
220 | header = numpy.fromstring(fp, SYSTEM_STRUCTURE,1) |
|
235 | header = numpy.fromstring(fp, SYSTEM_STRUCTURE,1) | |
221 | except Exception, e: |
|
236 | except Exception, e: | |
222 | print "System Header: " + str(e) |
|
237 | print "System Header: " + str(e) | |
223 | return 0 |
|
238 | return 0 | |
224 |
|
239 | |||
225 | self.size = header['nSize'][0] |
|
240 | self.size = header['nSize'][0] | |
226 | self.nSamples = header['nNumSamples'][0] |
|
241 | self.nSamples = header['nNumSamples'][0] | |
227 | self.nProfiles = header['nNumProfiles'][0] |
|
242 | self.nProfiles = header['nNumProfiles'][0] | |
228 | self.nChannels = header['nNumChannels'][0] |
|
243 | self.nChannels = header['nNumChannels'][0] | |
229 | self.adcResolution = header['nADCResolution'][0] |
|
244 | self.adcResolution = header['nADCResolution'][0] | |
230 | self.pciDioBusWidth = header['nPCDIOBusWidth'][0] |
|
245 | self.pciDioBusWidth = header['nPCDIOBusWidth'][0] | |
231 |
|
246 | |||
232 |
|
247 | |||
233 | if startFp is not None: |
|
248 | if startFp is not None: | |
234 | endFp = self.size + startFp |
|
249 | endFp = self.size + startFp | |
235 |
|
250 | |||
236 | if fp.tell() > endFp: |
|
251 | if fp.tell() > endFp: | |
237 | sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp.name) |
|
252 | sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp.name) | |
238 | return 0 |
|
253 | return 0 | |
239 |
|
254 | |||
240 | if fp.tell() < endFp: |
|
255 | if fp.tell() < endFp: | |
241 | sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp.name) |
|
256 | sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp.name) | |
242 | return 0 |
|
257 | return 0 | |
243 |
|
258 | |||
244 | self.length = header.nbytes |
|
259 | self.length = header.nbytes | |
245 | return 1 |
|
260 | return 1 | |
246 |
|
261 | |||
247 | def write(self, fp): |
|
262 | def write(self, fp): | |
248 |
|
263 | |||
249 | headerTuple = (self.size,self.nSamples,self.nProfiles,self.nChannels,self.adcResolution,self.pciDioBusWidth) |
|
264 | headerTuple = (self.size,self.nSamples,self.nProfiles,self.nChannels,self.adcResolution,self.pciDioBusWidth) | |
250 | header = numpy.array(headerTuple,SYSTEM_STRUCTURE) |
|
265 | header = numpy.array(headerTuple,SYSTEM_STRUCTURE) | |
251 | header.tofile(fp) |
|
266 | header.tofile(fp) | |
252 |
|
267 | |||
253 | return 1 |
|
268 | return 1 | |
254 |
|
269 | |||
255 | class RadarControllerHeader(Header): |
|
270 | class RadarControllerHeader(Header): | |
256 |
|
271 | |||
257 | expType = None |
|
272 | expType = None | |
258 | nTx = None |
|
273 | nTx = None | |
259 | ipp = None |
|
274 | ipp = None | |
260 | txA = None |
|
275 | txA = None | |
261 | txB = None |
|
276 | txB = None | |
262 | nWindows = None |
|
277 | nWindows = None | |
263 | numTaus = None |
|
278 | numTaus = None | |
264 | codeType = None |
|
279 | codeType = None | |
265 | line6Function = None |
|
280 | line6Function = None | |
266 | line5Function = None |
|
281 | line5Function = None | |
267 | fClock = None |
|
282 | fClock = None | |
268 | prePulseBefore = None |
|
283 | prePulseBefore = None | |
269 |
prePulse |
|
284 | prePulseAfter = None | |
270 | rangeIpp = None |
|
285 | rangeIpp = None | |
271 | rangeTxA = None |
|
286 | rangeTxA = None | |
272 | rangeTxB = None |
|
287 | rangeTxB = None | |
273 | structure = RADAR_STRUCTURE |
|
288 | structure = RADAR_STRUCTURE | |
274 | __size = None |
|
289 | __size = None | |
275 |
|
290 | |||
276 | def __init__(self, expType=2, nTx=1, |
|
291 | def __init__(self, expType=2, nTx=1, | |
277 |
ipp |
|
292 | ipp=None, txA=0, txB=0, | |
278 | nWindows=None, nHeights=None, firstHeight=None, deltaHeight=None, |
|
293 | nWindows=None, nHeights=None, firstHeight=None, deltaHeight=None, | |
279 | numTaus=0, line6Function=0, line5Function=0, fClock=None, |
|
294 | numTaus=0, line6Function=0, line5Function=0, fClock=None, | |
280 | prePulseBefore=0, prePulseAfter=0, |
|
295 | prePulseBefore=0, prePulseAfter=0, | |
281 | codeType=0, nCode=0, nBaud=0, code=None, |
|
296 | codeType=0, nCode=0, nBaud=0, code=None, | |
282 | flip1=0, flip2=0): |
|
297 | flip1=0, flip2=0): | |
283 |
|
298 | |||
284 | # self.size = 116 |
|
299 | # self.size = 116 | |
285 | self.expType = expType |
|
300 | self.expType = expType | |
286 | self.nTx = nTx |
|
301 | self.nTx = nTx | |
287 |
self.ipp = ipp |
|
302 | self.ipp = ipp | |
288 | self.txA = txA |
|
303 | self.txA = txA | |
289 | self.txB = txB |
|
304 | self.txB = txB | |
290 |
self.rangeIpp = ipp |
|
305 | self.rangeIpp = ipp | |
291 | self.rangeTxA = txA |
|
306 | self.rangeTxA = txA | |
292 | self.rangeTxB = txB |
|
307 | self.rangeTxB = txB | |
293 |
|
308 | |||
294 | self.nWindows = nWindows |
|
309 | self.nWindows = nWindows | |
295 | self.numTaus = numTaus |
|
310 | self.numTaus = numTaus | |
296 | self.codeType = codeType |
|
311 | self.codeType = codeType | |
297 | self.line6Function = line6Function |
|
312 | self.line6Function = line6Function | |
298 | self.line5Function = line5Function |
|
313 | self.line5Function = line5Function | |
299 | self.fClock = fClock |
|
314 | self.fClock = fClock | |
300 | self.prePulseBefore = prePulseBefore |
|
315 | self.prePulseBefore = prePulseBefore | |
301 |
self.prePulse |
|
316 | self.prePulseAfter = prePulseAfter | |
302 |
|
317 | |||
303 | self.nHeights = nHeights |
|
318 | self.nHeights = nHeights | |
304 | self.firstHeight = firstHeight |
|
319 | self.firstHeight = firstHeight | |
305 | self.deltaHeight = deltaHeight |
|
320 | self.deltaHeight = deltaHeight | |
306 | self.samplesWin = nHeights |
|
321 | self.samplesWin = nHeights | |
307 |
|
322 | |||
308 | self.nCode = nCode |
|
323 | self.nCode = nCode | |
309 | self.nBaud = nBaud |
|
324 | self.nBaud = nBaud | |
310 | self.code = code |
|
325 | self.code = code | |
311 | self.flip1 = flip1 |
|
326 | self.flip1 = flip1 | |
312 | self.flip2 = flip2 |
|
327 | self.flip2 = flip2 | |
313 |
|
328 | |||
314 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 |
|
329 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 | |
315 | # self.dynamic = numpy.array([],numpy.dtype('byte')) |
|
330 | # self.dynamic = numpy.array([],numpy.dtype('byte')) | |
316 |
|
331 | |||
317 | if self.fClock is None and self.deltaHeight is not None: |
|
332 | if self.fClock is None and self.deltaHeight is not None: | |
318 | self.fClock = 0.15/(deltaHeight*1e-6) #0.15Km / (height * 1u) |
|
333 | self.fClock = 0.15/(deltaHeight*1e-6) #0.15Km / (height * 1u) | |
319 |
|
334 | |||
320 | def read(self, fp): |
|
335 | def read(self, fp): | |
321 | self.length = 0 |
|
336 | self.length = 0 | |
322 | try: |
|
337 | try: | |
323 | startFp = fp.tell() |
|
338 | startFp = fp.tell() | |
324 | except Exception, e: |
|
339 | except Exception, e: | |
325 | startFp = None |
|
340 | startFp = None | |
326 | pass |
|
341 | pass | |
327 |
|
342 | |||
328 | try: |
|
343 | try: | |
329 | if hasattr(fp, 'read'): |
|
344 | if hasattr(fp, 'read'): | |
330 | header = numpy.fromfile(fp, RADAR_STRUCTURE,1) |
|
345 | header = numpy.fromfile(fp, RADAR_STRUCTURE,1) | |
331 | else: |
|
346 | else: | |
332 | header = numpy.fromstring(fp, RADAR_STRUCTURE,1) |
|
347 | header = numpy.fromstring(fp, RADAR_STRUCTURE,1) | |
333 | self.length += header.nbytes |
|
348 | self.length += header.nbytes | |
334 | except Exception, e: |
|
349 | except Exception, e: | |
335 | print "RadarControllerHeader: " + str(e) |
|
350 | print "RadarControllerHeader: " + str(e) | |
336 | return 0 |
|
351 | return 0 | |
337 |
|
352 | |||
338 | size = int(header['nSize'][0]) |
|
353 | size = int(header['nSize'][0]) | |
339 | self.expType = int(header['nExpType'][0]) |
|
354 | self.expType = int(header['nExpType'][0]) | |
340 | self.nTx = int(header['nNTx'][0]) |
|
355 | self.nTx = int(header['nNTx'][0]) | |
341 | self.ipp = float(header['fIpp'][0]) |
|
356 | self.ipp = float(header['fIpp'][0]) | |
342 | self.txA = float(header['fTxA'][0]) |
|
357 | self.txA = float(header['fTxA'][0]) | |
343 | self.txB = float(header['fTxB'][0]) |
|
358 | self.txB = float(header['fTxB'][0]) | |
344 | self.nWindows = int(header['nNumWindows'][0]) |
|
359 | self.nWindows = int(header['nNumWindows'][0]) | |
345 | self.numTaus = int(header['nNumTaus'][0]) |
|
360 | self.numTaus = int(header['nNumTaus'][0]) | |
346 | self.codeType = int(header['nCodeType'][0]) |
|
361 | self.codeType = int(header['nCodeType'][0]) | |
347 | self.line6Function = int(header['nLine6Function'][0]) |
|
362 | self.line6Function = int(header['nLine6Function'][0]) | |
348 | self.line5Function = int(header['nLine5Function'][0]) |
|
363 | self.line5Function = int(header['nLine5Function'][0]) | |
349 | self.fClock = float(header['fClock'][0]) |
|
364 | self.fClock = float(header['fClock'][0]) | |
350 | self.prePulseBefore = int(header['nPrePulseBefore'][0]) |
|
365 | self.prePulseBefore = int(header['nPrePulseBefore'][0]) | |
351 |
self.prePulse |
|
366 | self.prePulseAfter = int(header['nPrePulseAfter'][0]) | |
352 | self.rangeIpp = header['sRangeIPP'][0] |
|
367 | self.rangeIpp = header['sRangeIPP'][0] | |
353 | self.rangeTxA = header['sRangeTxA'][0] |
|
368 | self.rangeTxA = header['sRangeTxA'][0] | |
354 | self.rangeTxB = header['sRangeTxB'][0] |
|
369 | self.rangeTxB = header['sRangeTxB'][0] | |
355 |
|
370 | |||
356 | try: |
|
371 | try: | |
357 | if hasattr(fp, 'read'): |
|
372 | if hasattr(fp, 'read'): | |
358 | samplingWindow = numpy.fromfile(fp, SAMPLING_STRUCTURE, self.nWindows) |
|
373 | samplingWindow = numpy.fromfile(fp, SAMPLING_STRUCTURE, self.nWindows) | |
359 | else: |
|
374 | else: | |
360 | samplingWindow = numpy.fromstring(fp[self.length:], SAMPLING_STRUCTURE, self.nWindows) |
|
375 | samplingWindow = numpy.fromstring(fp[self.length:], SAMPLING_STRUCTURE, self.nWindows) | |
361 | self.length += samplingWindow.nbytes |
|
376 | self.length += samplingWindow.nbytes | |
362 | except Exception, e: |
|
377 | except Exception, e: | |
363 | print "RadarControllerHeader: " + str(e) |
|
378 | print "RadarControllerHeader: " + str(e) | |
364 | return 0 |
|
379 | return 0 | |
365 | self.nHeights = int(numpy.sum(samplingWindow['nsa'])) |
|
380 | self.nHeights = int(numpy.sum(samplingWindow['nsa'])) | |
366 | self.firstHeight = samplingWindow['h0'] |
|
381 | self.firstHeight = samplingWindow['h0'] | |
367 | self.deltaHeight = samplingWindow['dh'] |
|
382 | self.deltaHeight = samplingWindow['dh'] | |
368 | self.samplesWin = samplingWindow['nsa'] |
|
383 | self.samplesWin = samplingWindow['nsa'] | |
369 |
|
384 | |||
370 |
|
385 | |||
371 |
|
386 | |||
372 | try: |
|
387 | try: | |
373 | if hasattr(fp, 'read'): |
|
388 | if hasattr(fp, 'read'): | |
374 | self.Taus = numpy.fromfile(fp, '<f4', self.numTaus) |
|
389 | self.Taus = numpy.fromfile(fp, '<f4', self.numTaus) | |
375 | else: |
|
390 | else: | |
376 | self.Taus = numpy.fromstring(fp[self.length:], '<f4', self.numTaus) |
|
391 | self.Taus = numpy.fromstring(fp[self.length:], '<f4', self.numTaus) | |
377 | self.length += self.Taus.nbytes |
|
392 | self.length += self.Taus.nbytes | |
378 | except Exception, e: |
|
393 | except Exception, e: | |
379 | print "RadarControllerHeader: " + str(e) |
|
394 | print "RadarControllerHeader: " + str(e) | |
380 | return 0 |
|
395 | return 0 | |
381 |
|
396 | |||
382 |
|
397 | |||
383 |
|
398 | |||
384 | self.code_size = 0 |
|
399 | self.code_size = 0 | |
385 | if self.codeType != 0: |
|
400 | if self.codeType != 0: | |
386 |
|
401 | |||
387 | try: |
|
402 | try: | |
388 | if hasattr(fp, 'read'): |
|
403 | if hasattr(fp, 'read'): | |
389 | self.nCode = numpy.fromfile(fp, '<u4', 1) |
|
404 | self.nCode = numpy.fromfile(fp, '<u4', 1) | |
390 | self.length += self.nCode.nbytes |
|
405 | self.length += self.nCode.nbytes | |
391 | self.nBaud = numpy.fromfile(fp, '<u4', 1) |
|
406 | self.nBaud = numpy.fromfile(fp, '<u4', 1) | |
392 | self.length += self.nBaud.nbytes |
|
407 | self.length += self.nBaud.nbytes | |
393 | else: |
|
408 | else: | |
394 | self.nCode = numpy.fromstring(fp[self.length:], '<u4', 1)[0] |
|
409 | self.nCode = numpy.fromstring(fp[self.length:], '<u4', 1)[0] | |
395 | self.length += self.nCode.nbytes |
|
410 | self.length += self.nCode.nbytes | |
396 | self.nBaud = numpy.fromstring(fp[self.length:], '<u4', 1)[0] |
|
411 | self.nBaud = numpy.fromstring(fp[self.length:], '<u4', 1)[0] | |
397 | self.length += self.nBaud.nbytes |
|
412 | self.length += self.nBaud.nbytes | |
398 | except Exception, e: |
|
413 | except Exception, e: | |
399 | print "RadarControllerHeader: " + str(e) |
|
414 | print "RadarControllerHeader: " + str(e) | |
400 | return 0 |
|
415 | return 0 | |
401 | code = numpy.empty([self.nCode,self.nBaud],dtype='i1') |
|
416 | code = numpy.empty([self.nCode,self.nBaud],dtype='i1') | |
402 |
|
417 | |||
403 | for ic in range(self.nCode): |
|
418 | for ic in range(self.nCode): | |
404 | try: |
|
419 | try: | |
405 | if hasattr(fp, 'read'): |
|
420 | if hasattr(fp, 'read'): | |
406 | temp = numpy.fromfile(fp,'u4', int(numpy.ceil(self.nBaud/32.))) |
|
421 | temp = numpy.fromfile(fp,'u4', int(numpy.ceil(self.nBaud/32.))) | |
407 | else: |
|
422 | else: | |
408 | temp = numpy.fromstring(fp,'u4', int(numpy.ceil(self.nBaud/32.))) |
|
423 | temp = numpy.fromstring(fp,'u4', int(numpy.ceil(self.nBaud/32.))) | |
409 | self.length += temp.nbytes |
|
424 | self.length += temp.nbytes | |
410 | except Exception, e: |
|
425 | except Exception, e: | |
411 | print "RadarControllerHeader: " + str(e) |
|
426 | print "RadarControllerHeader: " + str(e) | |
412 | return 0 |
|
427 | return 0 | |
413 |
|
428 | |||
414 | for ib in range(self.nBaud-1,-1,-1): |
|
429 | for ib in range(self.nBaud-1,-1,-1): | |
415 | code[ic,ib] = temp[ib/32]%2 |
|
430 | code[ic,ib] = temp[ib/32]%2 | |
416 | temp[ib/32] = temp[ib/32]/2 |
|
431 | temp[ib/32] = temp[ib/32]/2 | |
417 |
|
432 | |||
418 | self.code = 2.0*code - 1.0 |
|
433 | self.code = 2.0*code - 1.0 | |
419 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 |
|
434 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 | |
420 |
|
435 | |||
421 | # if self.line5Function == RCfunction.FLIP: |
|
436 | # if self.line5Function == RCfunction.FLIP: | |
422 | # self.flip1 = numpy.fromfile(fp,'<u4',1) |
|
437 | # self.flip1 = numpy.fromfile(fp,'<u4',1) | |
423 | # |
|
438 | # | |
424 | # if self.line6Function == RCfunction.FLIP: |
|
439 | # if self.line6Function == RCfunction.FLIP: | |
425 | # self.flip2 = numpy.fromfile(fp,'<u4',1) |
|
440 | # self.flip2 = numpy.fromfile(fp,'<u4',1) | |
426 | if startFp is not None: |
|
441 | if startFp is not None: | |
427 | endFp = size + startFp |
|
442 | endFp = size + startFp | |
428 |
|
443 | |||
429 | if fp.tell() != endFp: |
|
444 | if fp.tell() != endFp: | |
430 | # fp.seek(endFp) |
|
445 | # fp.seek(endFp) | |
431 | print "%s: Radar Controller Header size is not consistent: from data [%d] != from header field [%d]" %(fp.name, fp.tell()-startFp, size) |
|
446 | print "%s: Radar Controller Header size is not consistent: from data [%d] != from header field [%d]" %(fp.name, fp.tell()-startFp, size) | |
432 | # return 0 |
|
447 | # return 0 | |
433 |
|
448 | |||
434 | if fp.tell() > endFp: |
|
449 | if fp.tell() > endFp: | |
435 | sys.stderr.write("Warning %s: Size value read from Radar Controller header is lower than it has to be\n" %fp.name) |
|
450 | sys.stderr.write("Warning %s: Size value read from Radar Controller header is lower than it has to be\n" %fp.name) | |
436 | # return 0 |
|
451 | # return 0 | |
437 |
|
452 | |||
438 | if fp.tell() < endFp: |
|
453 | if fp.tell() < endFp: | |
439 | sys.stderr.write("Warning %s: Size value read from Radar Controller header is greater than it has to be\n" %fp.name) |
|
454 | sys.stderr.write("Warning %s: Size value read from Radar Controller header is greater than it has to be\n" %fp.name) | |
440 |
|
455 | |||
441 |
|
456 | |||
442 | return 1 |
|
457 | return 1 | |
443 |
|
458 | |||
444 | def write(self, fp): |
|
459 | def write(self, fp): | |
445 |
|
460 | |||
446 | headerTuple = (self.size, |
|
461 | headerTuple = (self.size, | |
447 | self.expType, |
|
462 | self.expType, | |
448 | self.nTx, |
|
463 | self.nTx, | |
449 | self.ipp, |
|
464 | self.ipp, | |
450 | self.txA, |
|
465 | self.txA, | |
451 | self.txB, |
|
466 | self.txB, | |
452 | self.nWindows, |
|
467 | self.nWindows, | |
453 | self.numTaus, |
|
468 | self.numTaus, | |
454 | self.codeType, |
|
469 | self.codeType, | |
455 | self.line6Function, |
|
470 | self.line6Function, | |
456 | self.line5Function, |
|
471 | self.line5Function, | |
457 | self.fClock, |
|
472 | self.fClock, | |
458 | self.prePulseBefore, |
|
473 | self.prePulseBefore, | |
459 |
self.prePulse |
|
474 | self.prePulseAfter, | |
460 | self.rangeIpp, |
|
475 | self.rangeIpp, | |
461 | self.rangeTxA, |
|
476 | self.rangeTxA, | |
462 | self.rangeTxB) |
|
477 | self.rangeTxB) | |
463 |
|
478 | |||
464 | header = numpy.array(headerTuple,RADAR_STRUCTURE) |
|
479 | header = numpy.array(headerTuple,RADAR_STRUCTURE) | |
465 | header.tofile(fp) |
|
480 | header.tofile(fp) | |
466 |
|
481 | |||
467 | sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) |
|
482 | sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) | |
468 | samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE) |
|
483 | samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE) | |
469 | samplingWindow.tofile(fp) |
|
484 | samplingWindow.tofile(fp) | |
470 |
|
485 | |||
471 | if self.numTaus > 0: |
|
486 | if self.numTaus > 0: | |
472 | self.Taus.tofile(fp) |
|
487 | self.Taus.tofile(fp) | |
473 |
|
488 | |||
474 | if self.codeType !=0: |
|
489 | if self.codeType !=0: | |
475 | nCode = numpy.array(self.nCode, '<u4') |
|
490 | nCode = numpy.array(self.nCode, '<u4') | |
476 | nCode.tofile(fp) |
|
491 | nCode.tofile(fp) | |
477 | nBaud = numpy.array(self.nBaud, '<u4') |
|
492 | nBaud = numpy.array(self.nBaud, '<u4') | |
478 | nBaud.tofile(fp) |
|
493 | nBaud.tofile(fp) | |
479 | code1 = (self.code + 1.0)/2. |
|
494 | code1 = (self.code + 1.0)/2. | |
480 |
|
495 | |||
481 | for ic in range(self.nCode): |
|
496 | for ic in range(self.nCode): | |
482 | tempx = numpy.zeros(numpy.ceil(self.nBaud/32.)) |
|
497 | tempx = numpy.zeros(numpy.ceil(self.nBaud/32.)) | |
483 | start = 0 |
|
498 | start = 0 | |
484 | end = 32 |
|
499 | end = 32 | |
485 | for i in range(len(tempx)): |
|
500 | for i in range(len(tempx)): | |
486 | code_selected = code1[ic,start:end] |
|
501 | code_selected = code1[ic,start:end] | |
487 | for j in range(len(code_selected)-1,-1,-1): |
|
502 | for j in range(len(code_selected)-1,-1,-1): | |
488 | if code_selected[j] == 1: |
|
503 | if code_selected[j] == 1: | |
489 | tempx[i] = tempx[i] + 2**(len(code_selected)-1-j) |
|
504 | tempx[i] = tempx[i] + 2**(len(code_selected)-1-j) | |
490 | start = start + 32 |
|
505 | start = start + 32 | |
491 | end = end + 32 |
|
506 | end = end + 32 | |
492 |
|
507 | |||
493 | tempx = tempx.astype('u4') |
|
508 | tempx = tempx.astype('u4') | |
494 | tempx.tofile(fp) |
|
509 | tempx.tofile(fp) | |
495 |
|
510 | |||
496 | # if self.line5Function == RCfunction.FLIP: |
|
511 | # if self.line5Function == RCfunction.FLIP: | |
497 | # self.flip1.tofile(fp) |
|
512 | # self.flip1.tofile(fp) | |
498 | # |
|
513 | # | |
499 | # if self.line6Function == RCfunction.FLIP: |
|
514 | # if self.line6Function == RCfunction.FLIP: | |
500 | # self.flip2.tofile(fp) |
|
515 | # self.flip2.tofile(fp) | |
501 |
|
516 | |||
502 | return 1 |
|
517 | return 1 | |
503 |
|
518 | |||
504 | def get_ippSeconds(self): |
|
519 | def get_ippSeconds(self): | |
505 | ''' |
|
520 | ''' | |
506 | ''' |
|
521 | ''' | |
507 | ippSeconds = 2.0 * 1000 * self.ipp / SPEED_OF_LIGHT |
|
522 | ippSeconds = 2.0 * 1000 * self.ipp / SPEED_OF_LIGHT | |
508 |
|
523 | |||
509 | return ippSeconds |
|
524 | return ippSeconds | |
510 |
|
525 | |||
511 | def set_ippSeconds(self, ippSeconds): |
|
526 | def set_ippSeconds(self, ippSeconds): | |
512 | ''' |
|
527 | ''' | |
513 | ''' |
|
528 | ''' | |
514 |
|
529 | |||
515 | self.ipp = ippSeconds * SPEED_OF_LIGHT / (2.0*1000) |
|
530 | self.ipp = ippSeconds * SPEED_OF_LIGHT / (2.0*1000) | |
516 |
|
531 | |||
517 | return |
|
532 | return | |
518 |
|
533 | |||
519 | def get_size(self): |
|
534 | def get_size(self): | |
520 |
|
535 | |||
521 | self.__size = 116 + 12*self.nWindows + 4*self.numTaus |
|
536 | self.__size = 116 + 12*self.nWindows + 4*self.numTaus | |
522 |
|
537 | |||
523 | if self.codeType != 0: |
|
538 | if self.codeType != 0: | |
524 | self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.) |
|
539 | self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.) | |
525 |
|
540 | |||
526 | return self.__size |
|
541 | return self.__size | |
527 |
|
542 | |||
528 | def set_size(self, value): |
|
543 | def set_size(self, value): | |
529 |
|
544 | |||
530 | raise IOError, "size is a property and it cannot be set, just read" |
|
545 | raise IOError, "size is a property and it cannot be set, just read" | |
531 |
|
546 | |||
532 | return |
|
547 | return | |
533 |
|
548 | |||
534 | ippSeconds = property(get_ippSeconds, set_ippSeconds) |
|
549 | ippSeconds = property(get_ippSeconds, set_ippSeconds) | |
535 | size = property(get_size, set_size) |
|
550 | size = property(get_size, set_size) | |
536 |
|
551 | |||
537 | class ProcessingHeader(Header): |
|
552 | class ProcessingHeader(Header): | |
538 |
|
553 | |||
539 | # size = None |
|
554 | # size = None | |
540 | dtype = None |
|
555 | dtype = None | |
541 | blockSize = None |
|
556 | blockSize = None | |
542 | profilesPerBlock = None |
|
557 | profilesPerBlock = None | |
543 | dataBlocksPerFile = None |
|
558 | dataBlocksPerFile = None | |
544 | nWindows = None |
|
559 | nWindows = None | |
545 | processFlags = None |
|
560 | processFlags = None | |
546 | nCohInt = None |
|
561 | nCohInt = None | |
547 | nIncohInt = None |
|
562 | nIncohInt = None | |
548 | totalSpectra = None |
|
563 | totalSpectra = None | |
549 | structure = PROCESSING_STRUCTURE |
|
564 | structure = PROCESSING_STRUCTURE | |
550 | flag_dc = None |
|
565 | flag_dc = None | |
551 | flag_cspc = None |
|
566 | flag_cspc = None | |
552 |
|
567 | |||
553 | def __init__(self, dtype=0, blockSize=0, profilesPerBlock=0, dataBlocksPerFile=0, nWindows=0,processFlags=0, nCohInt=0, |
|
568 | def __init__(self, dtype=0, blockSize=0, profilesPerBlock=0, dataBlocksPerFile=0, nWindows=0,processFlags=0, nCohInt=0, | |
554 | nIncohInt=0, totalSpectra=0, nHeights=0, firstHeight=0, deltaHeight=0, samplesWin=0, spectraComb=0, nCode=0, |
|
569 | nIncohInt=0, totalSpectra=0, nHeights=0, firstHeight=0, deltaHeight=0, samplesWin=0, spectraComb=0, nCode=0, | |
555 | code=0, nBaud=None, shif_fft=False, flag_dc=False, flag_cspc=False, flag_decode=False, flag_deflip=False |
|
570 | code=0, nBaud=None, shif_fft=False, flag_dc=False, flag_cspc=False, flag_decode=False, flag_deflip=False | |
556 | ): |
|
571 | ): | |
557 |
|
572 | |||
558 | # self.size = 0 |
|
573 | # self.size = 0 | |
559 | self.dtype = dtype |
|
574 | self.dtype = dtype | |
560 | self.blockSize = blockSize |
|
575 | self.blockSize = blockSize | |
561 | self.profilesPerBlock = 0 |
|
576 | self.profilesPerBlock = 0 | |
562 | self.dataBlocksPerFile = 0 |
|
577 | self.dataBlocksPerFile = 0 | |
563 | self.nWindows = 0 |
|
578 | self.nWindows = 0 | |
564 | self.processFlags = 0 |
|
579 | self.processFlags = 0 | |
565 | self.nCohInt = 0 |
|
580 | self.nCohInt = 0 | |
566 | self.nIncohInt = 0 |
|
581 | self.nIncohInt = 0 | |
567 | self.totalSpectra = 0 |
|
582 | self.totalSpectra = 0 | |
568 |
|
583 | |||
569 | self.nHeights = 0 |
|
584 | self.nHeights = 0 | |
570 | self.firstHeight = 0 |
|
585 | self.firstHeight = 0 | |
571 | self.deltaHeight = 0 |
|
586 | self.deltaHeight = 0 | |
572 | self.samplesWin = 0 |
|
587 | self.samplesWin = 0 | |
573 | self.spectraComb = 0 |
|
588 | self.spectraComb = 0 | |
574 | self.nCode = None |
|
589 | self.nCode = None | |
575 | self.code = None |
|
590 | self.code = None | |
576 | self.nBaud = None |
|
591 | self.nBaud = None | |
577 |
|
592 | |||
578 | self.shif_fft = False |
|
593 | self.shif_fft = False | |
579 | self.flag_dc = False |
|
594 | self.flag_dc = False | |
580 | self.flag_cspc = False |
|
595 | self.flag_cspc = False | |
581 | self.flag_decode = False |
|
596 | self.flag_decode = False | |
582 | self.flag_deflip = False |
|
597 | self.flag_deflip = False | |
583 | self.length = 0 |
|
598 | self.length = 0 | |
584 |
|
599 | |||
585 | def read(self, fp): |
|
600 | def read(self, fp): | |
586 | self.length = 0 |
|
601 | self.length = 0 | |
587 | try: |
|
602 | try: | |
588 | startFp = fp.tell() |
|
603 | startFp = fp.tell() | |
589 | except Exception, e: |
|
604 | except Exception, e: | |
590 | startFp = None |
|
605 | startFp = None | |
591 | pass |
|
606 | pass | |
592 |
|
607 | |||
593 | try: |
|
608 | try: | |
594 | if hasattr(fp, 'read'): |
|
609 | if hasattr(fp, 'read'): | |
595 | header = numpy.fromfile(fp, PROCESSING_STRUCTURE, 1) |
|
610 | header = numpy.fromfile(fp, PROCESSING_STRUCTURE, 1) | |
596 | else: |
|
611 | else: | |
597 | header = numpy.fromstring(fp, PROCESSING_STRUCTURE, 1) |
|
612 | header = numpy.fromstring(fp, PROCESSING_STRUCTURE, 1) | |
598 | self.length += header.nbytes |
|
613 | self.length += header.nbytes | |
599 | except Exception, e: |
|
614 | except Exception, e: | |
600 | print "ProcessingHeader: " + str(e) |
|
615 | print "ProcessingHeader: " + str(e) | |
601 | return 0 |
|
616 | return 0 | |
602 |
|
617 | |||
603 | size = int(header['nSize'][0]) |
|
618 | size = int(header['nSize'][0]) | |
604 | self.dtype = int(header['nDataType'][0]) |
|
619 | self.dtype = int(header['nDataType'][0]) | |
605 | self.blockSize = int(header['nSizeOfDataBlock'][0]) |
|
620 | self.blockSize = int(header['nSizeOfDataBlock'][0]) | |
606 | self.profilesPerBlock = int(header['nProfilesperBlock'][0]) |
|
621 | self.profilesPerBlock = int(header['nProfilesperBlock'][0]) | |
607 | self.dataBlocksPerFile = int(header['nDataBlocksperFile'][0]) |
|
622 | self.dataBlocksPerFile = int(header['nDataBlocksperFile'][0]) | |
608 | self.nWindows = int(header['nNumWindows'][0]) |
|
623 | self.nWindows = int(header['nNumWindows'][0]) | |
609 | self.processFlags = header['nProcessFlags'] |
|
624 | self.processFlags = header['nProcessFlags'] | |
610 | self.nCohInt = int(header['nCoherentIntegrations'][0]) |
|
625 | self.nCohInt = int(header['nCoherentIntegrations'][0]) | |
611 | self.nIncohInt = int(header['nIncoherentIntegrations'][0]) |
|
626 | self.nIncohInt = int(header['nIncoherentIntegrations'][0]) | |
612 | self.totalSpectra = int(header['nTotalSpectra'][0]) |
|
627 | self.totalSpectra = int(header['nTotalSpectra'][0]) | |
613 |
|
628 | |||
614 | try: |
|
629 | try: | |
615 | if hasattr(fp, 'read'): |
|
630 | if hasattr(fp, 'read'): | |
616 | samplingWindow = numpy.fromfile(fp, SAMPLING_STRUCTURE, self.nWindows) |
|
631 | samplingWindow = numpy.fromfile(fp, SAMPLING_STRUCTURE, self.nWindows) | |
617 | else: |
|
632 | else: | |
618 | samplingWindow = numpy.fromstring(fp[self.length:], SAMPLING_STRUCTURE, self.nWindows) |
|
633 | samplingWindow = numpy.fromstring(fp[self.length:], SAMPLING_STRUCTURE, self.nWindows) | |
619 | self.length += samplingWindow.nbytes |
|
634 | self.length += samplingWindow.nbytes | |
620 | except Exception, e: |
|
635 | except Exception, e: | |
621 | print "ProcessingHeader: " + str(e) |
|
636 | print "ProcessingHeader: " + str(e) | |
622 | return 0 |
|
637 | return 0 | |
623 |
|
638 | |||
624 | self.nHeights = int(numpy.sum(samplingWindow['nsa'])) |
|
639 | self.nHeights = int(numpy.sum(samplingWindow['nsa'])) | |
625 | self.firstHeight = float(samplingWindow['h0'][0]) |
|
640 | self.firstHeight = float(samplingWindow['h0'][0]) | |
626 | self.deltaHeight = float(samplingWindow['dh'][0]) |
|
641 | self.deltaHeight = float(samplingWindow['dh'][0]) | |
627 | self.samplesWin = samplingWindow['nsa'][0] |
|
642 | self.samplesWin = samplingWindow['nsa'][0] | |
628 |
|
643 | |||
629 |
|
644 | |||
630 | try: |
|
645 | try: | |
631 | if hasattr(fp, 'read'): |
|
646 | if hasattr(fp, 'read'): | |
632 | self.spectraComb = numpy.fromfile(fp, 'u1', 2*self.totalSpectra) |
|
647 | self.spectraComb = numpy.fromfile(fp, 'u1', 2*self.totalSpectra) | |
633 | else: |
|
648 | else: | |
634 | self.spectraComb = numpy.fromstring(fp[self.length:], 'u1', 2*self.totalSpectra) |
|
649 | self.spectraComb = numpy.fromstring(fp[self.length:], 'u1', 2*self.totalSpectra) | |
635 | self.length += self.spectraComb.nbytes |
|
650 | self.length += self.spectraComb.nbytes | |
636 | except Exception, e: |
|
651 | except Exception, e: | |
637 | print "ProcessingHeader: " + str(e) |
|
652 | print "ProcessingHeader: " + str(e) | |
638 | return 0 |
|
653 | return 0 | |
639 |
|
654 | |||
640 | if ((self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE) == PROCFLAG.DEFINE_PROCESS_CODE): |
|
655 | if ((self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE) == PROCFLAG.DEFINE_PROCESS_CODE): | |
641 | self.nCode = int(numpy.fromfile(fp,'<u4',1)) |
|
656 | self.nCode = int(numpy.fromfile(fp,'<u4',1)) | |
642 | self.nBaud = int(numpy.fromfile(fp,'<u4',1)) |
|
657 | self.nBaud = int(numpy.fromfile(fp,'<u4',1)) | |
643 | self.code = numpy.fromfile(fp,'<f4',self.nCode*self.nBaud).reshape(self.nCode,self.nBaud) |
|
658 | self.code = numpy.fromfile(fp,'<f4',self.nCode*self.nBaud).reshape(self.nCode,self.nBaud) | |
644 |
|
659 | |||
645 | if ((self.processFlags & PROCFLAG.EXP_NAME_ESP) == PROCFLAG.EXP_NAME_ESP): |
|
660 | if ((self.processFlags & PROCFLAG.EXP_NAME_ESP) == PROCFLAG.EXP_NAME_ESP): | |
646 | exp_name_len = int(numpy.fromfile(fp,'<u4',1)) |
|
661 | exp_name_len = int(numpy.fromfile(fp,'<u4',1)) | |
647 | exp_name = numpy.fromfile(fp,'u1',exp_name_len+1) |
|
662 | exp_name = numpy.fromfile(fp,'u1',exp_name_len+1) | |
648 |
|
663 | |||
649 | if ((self.processFlags & PROCFLAG.SHIFT_FFT_DATA) == PROCFLAG.SHIFT_FFT_DATA): |
|
664 | if ((self.processFlags & PROCFLAG.SHIFT_FFT_DATA) == PROCFLAG.SHIFT_FFT_DATA): | |
650 | self.shif_fft = True |
|
665 | self.shif_fft = True | |
651 | else: |
|
666 | else: | |
652 | self.shif_fft = False |
|
667 | self.shif_fft = False | |
653 |
|
668 | |||
654 | if ((self.processFlags & PROCFLAG.SAVE_CHANNELS_DC) == PROCFLAG.SAVE_CHANNELS_DC): |
|
669 | if ((self.processFlags & PROCFLAG.SAVE_CHANNELS_DC) == PROCFLAG.SAVE_CHANNELS_DC): | |
655 | self.flag_dc = True |
|
670 | self.flag_dc = True | |
656 | else: |
|
671 | else: | |
657 | self.flag_dc = False |
|
672 | self.flag_dc = False | |
658 |
|
673 | |||
659 | if ((self.processFlags & PROCFLAG.DECODE_DATA) == PROCFLAG.DECODE_DATA): |
|
674 | if ((self.processFlags & PROCFLAG.DECODE_DATA) == PROCFLAG.DECODE_DATA): | |
660 | self.flag_decode = True |
|
675 | self.flag_decode = True | |
661 | else: |
|
676 | else: | |
662 | self.flag_decode = False |
|
677 | self.flag_decode = False | |
663 |
|
678 | |||
664 | if ((self.processFlags & PROCFLAG.DEFLIP_DATA) == PROCFLAG.DEFLIP_DATA): |
|
679 | if ((self.processFlags & PROCFLAG.DEFLIP_DATA) == PROCFLAG.DEFLIP_DATA): | |
665 | self.flag_deflip = True |
|
680 | self.flag_deflip = True | |
666 | else: |
|
681 | else: | |
667 | self.flag_deflip = False |
|
682 | self.flag_deflip = False | |
668 |
|
683 | |||
669 | nChannels = 0 |
|
684 | nChannels = 0 | |
670 | nPairs = 0 |
|
685 | nPairs = 0 | |
671 | pairList = [] |
|
686 | pairList = [] | |
672 |
|
687 | |||
673 | for i in range( 0, self.totalSpectra*2, 2 ): |
|
688 | for i in range( 0, self.totalSpectra*2, 2 ): | |
674 | if self.spectraComb[i] == self.spectraComb[i+1]: |
|
689 | if self.spectraComb[i] == self.spectraComb[i+1]: | |
675 | nChannels = nChannels + 1 #par de canales iguales |
|
690 | nChannels = nChannels + 1 #par de canales iguales | |
676 | else: |
|
691 | else: | |
677 | nPairs = nPairs + 1 #par de canales diferentes |
|
692 | nPairs = nPairs + 1 #par de canales diferentes | |
678 | pairList.append( (self.spectraComb[i], self.spectraComb[i+1]) ) |
|
693 | pairList.append( (self.spectraComb[i], self.spectraComb[i+1]) ) | |
679 |
|
694 | |||
680 | self.flag_cspc = False |
|
695 | self.flag_cspc = False | |
681 | if nPairs > 0: |
|
696 | if nPairs > 0: | |
682 | self.flag_cspc = True |
|
697 | self.flag_cspc = True | |
683 |
|
698 | |||
684 |
|
699 | |||
685 |
|
700 | |||
686 | if startFp is not None: |
|
701 | if startFp is not None: | |
687 | endFp = size + startFp |
|
702 | endFp = size + startFp | |
688 | if fp.tell() > endFp: |
|
703 | if fp.tell() > endFp: | |
689 | sys.stderr.write("Warning: Processing header size is lower than it has to be") |
|
704 | sys.stderr.write("Warning: Processing header size is lower than it has to be") | |
690 | return 0 |
|
705 | return 0 | |
691 |
|
706 | |||
692 | if fp.tell() < endFp: |
|
707 | if fp.tell() < endFp: | |
693 | sys.stderr.write("Warning: Processing header size is greater than it is considered") |
|
708 | sys.stderr.write("Warning: Processing header size is greater than it is considered") | |
694 |
|
709 | |||
695 | return 1 |
|
710 | return 1 | |
696 |
|
711 | |||
697 | def write(self, fp): |
|
712 | def write(self, fp): | |
698 | #Clear DEFINE_PROCESS_CODE |
|
713 | #Clear DEFINE_PROCESS_CODE | |
699 | self.processFlags = self.processFlags & (~PROCFLAG.DEFINE_PROCESS_CODE) |
|
714 | self.processFlags = self.processFlags & (~PROCFLAG.DEFINE_PROCESS_CODE) | |
700 |
|
715 | |||
701 | headerTuple = (self.size, |
|
716 | headerTuple = (self.size, | |
702 | self.dtype, |
|
717 | self.dtype, | |
703 | self.blockSize, |
|
718 | self.blockSize, | |
704 | self.profilesPerBlock, |
|
719 | self.profilesPerBlock, | |
705 | self.dataBlocksPerFile, |
|
720 | self.dataBlocksPerFile, | |
706 | self.nWindows, |
|
721 | self.nWindows, | |
707 | self.processFlags, |
|
722 | self.processFlags, | |
708 | self.nCohInt, |
|
723 | self.nCohInt, | |
709 | self.nIncohInt, |
|
724 | self.nIncohInt, | |
710 | self.totalSpectra) |
|
725 | self.totalSpectra) | |
711 |
|
726 | |||
712 | header = numpy.array(headerTuple,PROCESSING_STRUCTURE) |
|
727 | header = numpy.array(headerTuple,PROCESSING_STRUCTURE) | |
713 | header.tofile(fp) |
|
728 | header.tofile(fp) | |
714 |
|
729 | |||
715 | if self.nWindows != 0: |
|
730 | if self.nWindows != 0: | |
716 | sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) |
|
731 | sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) | |
717 | samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE) |
|
732 | samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE) | |
718 | samplingWindow.tofile(fp) |
|
733 | samplingWindow.tofile(fp) | |
719 |
|
734 | |||
720 | if self.totalSpectra != 0: |
|
735 | if self.totalSpectra != 0: | |
721 | # spectraComb = numpy.array([],numpy.dtype('u1')) |
|
736 | # spectraComb = numpy.array([],numpy.dtype('u1')) | |
722 | spectraComb = self.spectraComb |
|
737 | spectraComb = self.spectraComb | |
723 | spectraComb.tofile(fp) |
|
738 | spectraComb.tofile(fp) | |
724 |
|
739 | |||
725 | # if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: |
|
740 | # if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: | |
726 | # nCode = numpy.array([self.nCode], numpy.dtype('u4')) #Probar con un dato que almacene codigo, hasta el momento no se hizo la prueba |
|
741 | # nCode = numpy.array([self.nCode], numpy.dtype('u4')) #Probar con un dato que almacene codigo, hasta el momento no se hizo la prueba | |
727 | # nCode.tofile(fp) |
|
742 | # nCode.tofile(fp) | |
728 | # |
|
743 | # | |
729 | # nBaud = numpy.array([self.nBaud], numpy.dtype('u4')) |
|
744 | # nBaud = numpy.array([self.nBaud], numpy.dtype('u4')) | |
730 | # nBaud.tofile(fp) |
|
745 | # nBaud.tofile(fp) | |
731 | # |
|
746 | # | |
732 | # code = self.code.reshape(self.nCode*self.nBaud) |
|
747 | # code = self.code.reshape(self.nCode*self.nBaud) | |
733 | # code = code.astype(numpy.dtype('<f4')) |
|
748 | # code = code.astype(numpy.dtype('<f4')) | |
734 | # code.tofile(fp) |
|
749 | # code.tofile(fp) | |
735 |
|
750 | |||
736 | return 1 |
|
751 | return 1 | |
737 |
|
752 | |||
738 | def get_size(self): |
|
753 | def get_size(self): | |
739 |
|
754 | |||
740 | self.__size = 40 + 12*self.nWindows + 2*self.totalSpectra |
|
755 | self.__size = 40 + 12*self.nWindows + 2*self.totalSpectra | |
741 |
|
756 | |||
742 | # if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: |
|
757 | # if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: | |
743 | # self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.) |
|
758 | # self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.) | |
744 | # self.__size += 4 + 4 + 4 * self.nCode * self.nBaud |
|
759 | # self.__size += 4 + 4 + 4 * self.nCode * self.nBaud | |
745 |
|
760 | |||
746 | return self.__size |
|
761 | return self.__size | |
747 |
|
762 | |||
748 | def set_size(self, value): |
|
763 | def set_size(self, value): | |
749 |
|
764 | |||
750 | raise IOError, "size is a property and it cannot be set, just read" |
|
765 | raise IOError, "size is a property and it cannot be set, just read" | |
751 |
|
766 | |||
752 | return |
|
767 | return | |
753 |
|
768 | |||
754 | size = property(get_size, set_size) |
|
769 | size = property(get_size, set_size) | |
755 |
|
770 | |||
756 | class RCfunction: |
|
771 | class RCfunction: | |
757 | NONE=0 |
|
772 | NONE=0 | |
758 | FLIP=1 |
|
773 | FLIP=1 | |
759 | CODE=2 |
|
774 | CODE=2 | |
760 | SAMPLING=3 |
|
775 | SAMPLING=3 | |
761 | LIN6DIV256=4 |
|
776 | LIN6DIV256=4 | |
762 | SYNCHRO=5 |
|
777 | SYNCHRO=5 | |
763 |
|
778 | |||
764 | class nCodeType: |
|
779 | class nCodeType: | |
765 | NONE=0 |
|
780 | NONE=0 | |
766 | USERDEFINE=1 |
|
781 | USERDEFINE=1 | |
767 | BARKER2=2 |
|
782 | BARKER2=2 | |
768 | BARKER3=3 |
|
783 | BARKER3=3 | |
769 | BARKER4=4 |
|
784 | BARKER4=4 | |
770 | BARKER5=5 |
|
785 | BARKER5=5 | |
771 | BARKER7=6 |
|
786 | BARKER7=6 | |
772 | BARKER11=7 |
|
787 | BARKER11=7 | |
773 | BARKER13=8 |
|
788 | BARKER13=8 | |
774 | AC128=9 |
|
789 | AC128=9 | |
775 | COMPLEMENTARYCODE2=10 |
|
790 | COMPLEMENTARYCODE2=10 | |
776 | COMPLEMENTARYCODE4=11 |
|
791 | COMPLEMENTARYCODE4=11 | |
777 | COMPLEMENTARYCODE8=12 |
|
792 | COMPLEMENTARYCODE8=12 | |
778 | COMPLEMENTARYCODE16=13 |
|
793 | COMPLEMENTARYCODE16=13 | |
779 | COMPLEMENTARYCODE32=14 |
|
794 | COMPLEMENTARYCODE32=14 | |
780 | COMPLEMENTARYCODE64=15 |
|
795 | COMPLEMENTARYCODE64=15 | |
781 | COMPLEMENTARYCODE128=16 |
|
796 | COMPLEMENTARYCODE128=16 | |
782 | CODE_BINARY28=17 |
|
797 | CODE_BINARY28=17 | |
783 |
|
798 | |||
784 | class PROCFLAG: |
|
799 | class PROCFLAG: | |
785 |
|
800 | |||
786 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
|
801 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) | |
787 | DECODE_DATA = numpy.uint32(0x00000002) |
|
802 | DECODE_DATA = numpy.uint32(0x00000002) | |
788 | SPECTRA_CALC = numpy.uint32(0x00000004) |
|
803 | SPECTRA_CALC = numpy.uint32(0x00000004) | |
789 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) |
|
804 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) | |
790 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) |
|
805 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) | |
791 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) |
|
806 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) | |
792 |
|
807 | |||
793 | DATATYPE_CHAR = numpy.uint32(0x00000040) |
|
808 | DATATYPE_CHAR = numpy.uint32(0x00000040) | |
794 | DATATYPE_SHORT = numpy.uint32(0x00000080) |
|
809 | DATATYPE_SHORT = numpy.uint32(0x00000080) | |
795 | DATATYPE_LONG = numpy.uint32(0x00000100) |
|
810 | DATATYPE_LONG = numpy.uint32(0x00000100) | |
796 | DATATYPE_INT64 = numpy.uint32(0x00000200) |
|
811 | DATATYPE_INT64 = numpy.uint32(0x00000200) | |
797 | DATATYPE_FLOAT = numpy.uint32(0x00000400) |
|
812 | DATATYPE_FLOAT = numpy.uint32(0x00000400) | |
798 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) |
|
813 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) | |
799 |
|
814 | |||
800 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) |
|
815 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) | |
801 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) |
|
816 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) | |
802 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) |
|
817 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) | |
803 |
|
818 | |||
804 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) |
|
819 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) | |
805 | DEFLIP_DATA = numpy.uint32(0x00010000) |
|
820 | DEFLIP_DATA = numpy.uint32(0x00010000) | |
806 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) |
|
821 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) | |
807 |
|
822 | |||
808 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) |
|
823 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) | |
809 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) |
|
824 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) | |
810 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) |
|
825 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) | |
811 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) |
|
826 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) | |
812 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) |
|
827 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) | |
813 |
|
828 | |||
814 | EXP_NAME_ESP = numpy.uint32(0x00200000) |
|
829 | EXP_NAME_ESP = numpy.uint32(0x00200000) | |
815 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) |
|
830 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) | |
816 |
|
831 | |||
817 | OPERATION_MASK = numpy.uint32(0x0000003F) |
|
832 | OPERATION_MASK = numpy.uint32(0x0000003F) | |
818 | DATATYPE_MASK = numpy.uint32(0x00000FC0) |
|
833 | DATATYPE_MASK = numpy.uint32(0x00000FC0) | |
819 | DATAARRANGE_MASK = numpy.uint32(0x00007000) |
|
834 | DATAARRANGE_MASK = numpy.uint32(0x00007000) | |
820 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) |
|
835 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) | |
821 |
|
836 | |||
822 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
837 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
823 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
838 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
824 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
839 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
825 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
840 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
826 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
841 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
827 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
842 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
828 |
|
843 | |||
829 | NUMPY_DTYPE_LIST = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] |
|
844 | NUMPY_DTYPE_LIST = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
830 |
|
845 | |||
831 | PROCFLAG_DTYPE_LIST = [PROCFLAG.DATATYPE_CHAR, |
|
846 | PROCFLAG_DTYPE_LIST = [PROCFLAG.DATATYPE_CHAR, | |
832 | PROCFLAG.DATATYPE_SHORT, |
|
847 | PROCFLAG.DATATYPE_SHORT, | |
833 | PROCFLAG.DATATYPE_LONG, |
|
848 | PROCFLAG.DATATYPE_LONG, | |
834 | PROCFLAG.DATATYPE_INT64, |
|
849 | PROCFLAG.DATATYPE_INT64, | |
835 | PROCFLAG.DATATYPE_FLOAT, |
|
850 | PROCFLAG.DATATYPE_FLOAT, | |
836 | PROCFLAG.DATATYPE_DOUBLE] |
|
851 | PROCFLAG.DATATYPE_DOUBLE] | |
837 |
|
852 | |||
838 | DTYPE_WIDTH = [1, 2, 4, 8, 4, 8] |
|
853 | DTYPE_WIDTH = [1, 2, 4, 8, 4, 8] | |
839 |
|
854 | |||
840 | def get_dtype_index(numpy_dtype): |
|
855 | def get_dtype_index(numpy_dtype): | |
841 |
|
856 | |||
842 | index = None |
|
857 | index = None | |
843 |
|
858 | |||
844 | for i in range(len(NUMPY_DTYPE_LIST)): |
|
859 | for i in range(len(NUMPY_DTYPE_LIST)): | |
845 | if numpy_dtype == NUMPY_DTYPE_LIST[i]: |
|
860 | if numpy_dtype == NUMPY_DTYPE_LIST[i]: | |
846 | index = i |
|
861 | index = i | |
847 | break |
|
862 | break | |
848 |
|
863 | |||
849 | return index |
|
864 | return index | |
850 |
|
865 | |||
851 | def get_numpy_dtype(index): |
|
866 | def get_numpy_dtype(index): | |
852 |
|
867 | |||
853 | return NUMPY_DTYPE_LIST[index] |
|
868 | return NUMPY_DTYPE_LIST[index] | |
854 |
|
869 | |||
855 | def get_procflag_dtype(index): |
|
870 | def get_procflag_dtype(index): | |
856 |
|
871 | |||
857 | return PROCFLAG_DTYPE_LIST[index] |
|
872 | return PROCFLAG_DTYPE_LIST[index] | |
858 |
|
873 | |||
859 | def get_dtype_width(index): |
|
874 | def get_dtype_width(index): | |
860 |
|
875 | |||
861 | return DTYPE_WIDTH[index] No newline at end of file |
|
876 | return DTYPE_WIDTH[index] |
@@ -1,653 +1,661 | |||||
1 |
|
1 | |||
2 | ''' |
|
2 | ''' | |
3 | Created on Jul 3, 2014 |
|
3 | Created on Jul 3, 2014 | |
4 |
|
4 | |||
5 | @author: roj-idl71 |
|
5 | @author: roj-idl71 | |
6 | ''' |
|
6 | ''' | |
7 | import os |
|
7 | import os | |
8 | import datetime |
|
8 | import datetime | |
9 | import numpy |
|
9 | import numpy | |
10 | from profilehooks import coverage |
|
10 | from profilehooks import coverage, profile | |
11 | from fractions import Fraction |
|
11 | from fractions import Fraction | |
12 |
|
12 | |||
13 | try: |
|
13 | try: | |
14 | from gevent import sleep |
|
14 | from gevent import sleep | |
15 | except: |
|
15 | except: | |
16 | from time import sleep |
|
16 | from time import sleep | |
17 |
|
17 | |||
18 | from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader |
|
18 | from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader | |
19 | from schainpy.model.data.jrodata import Voltage |
|
19 | from schainpy.model.data.jrodata import Voltage | |
20 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
20 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation | |
21 |
|
21 | from time import time | ||
|
22 | import cPickle | |||
22 | try: |
|
23 | try: | |
23 | import digital_rf |
|
24 | import digital_rf | |
24 | except: |
|
25 | except: | |
25 | print 'You should install "digital_rf" module if you want to read Digital RF data' |
|
26 | print 'You should install "digital_rf" module if you want to read Digital RF data' | |
26 |
|
27 | |||
27 | class DigitalRFReader(ProcessingUnit): |
|
28 | class DigitalRFReader(ProcessingUnit): | |
28 | ''' |
|
29 | ''' | |
29 | classdocs |
|
30 | classdocs | |
30 | ''' |
|
31 | ''' | |
31 |
|
32 | |||
32 | def __init__(self, **kwargs): |
|
33 | def __init__(self, **kwargs): | |
33 | ''' |
|
34 | ''' | |
34 | Constructor |
|
35 | Constructor | |
35 | ''' |
|
36 | ''' | |
36 |
|
37 | |||
37 | ProcessingUnit.__init__(self, **kwargs) |
|
38 | ProcessingUnit.__init__(self, **kwargs) | |
38 |
|
39 | |||
39 | self.dataOut = Voltage() |
|
40 | self.dataOut = Voltage() | |
40 | self.__printInfo = True |
|
41 | self.__printInfo = True | |
41 | self.__flagDiscontinuousBlock = False |
|
42 | self.__flagDiscontinuousBlock = False | |
42 | self.__bufferIndex = 9999999 |
|
43 | self.__bufferIndex = 9999999 | |
43 |
|
||||
44 | self.__ippKm = None |
|
44 | self.__ippKm = None | |
45 | self.__codeType = 0 |
|
45 | self.__codeType = 0 | |
46 | self.__nCode = None |
|
46 | self.__nCode = None | |
47 | self.__nBaud = None |
|
47 | self.__nBaud = None | |
48 | self.__code = None |
|
48 | self.__code = None | |
49 |
|
49 | |||
50 | def __getCurrentSecond(self): |
|
50 | def __getCurrentSecond(self): | |
51 |
|
51 | |||
52 | return self.__thisUnixSample/self.__sample_rate |
|
52 | return self.__thisUnixSample/self.__sample_rate | |
53 |
|
53 | |||
54 | thisSecond = property(__getCurrentSecond, "I'm the 'thisSecond' property.") |
|
54 | thisSecond = property(__getCurrentSecond, "I'm the 'thisSecond' property.") | |
55 |
|
55 | |||
56 | def __setFileHeader(self): |
|
56 | def __setFileHeader(self): | |
57 | ''' |
|
57 | ''' | |
58 | In this method will be initialized every parameter of dataOut object (header, no data) |
|
58 | In this method will be initialized every parameter of dataOut object (header, no data) | |
59 | ''' |
|
59 | ''' | |
60 | ippSeconds = 1.0*self.__nSamples/self.__sample_rate |
|
60 | ippSeconds = 1.0*self.__nSamples/self.__sample_rate | |
61 |
|
61 | |||
62 | nProfiles = 1.0/ippSeconds #Number of profiles in one second |
|
62 | nProfiles = 1.0/ippSeconds # Number of profiles in one second | |
63 |
|
63 | |||
64 |
self.dataOut.radarControllerHeaderObj = RadarControllerHeader( |
|
64 | self.dataOut.radarControllerHeaderObj = RadarControllerHeader(self.__radarControllerHeader) | |
65 | txA=0, |
|
65 | ||
66 | txB=0, |
|
66 | self.dataOut.systemHeaderObj = SystemHeader(self.__systemHeader) | |
67 | nWindows=1, |
|
|||
68 | nHeights=self.__nSamples, |
|
|||
69 | firstHeight=self.__firstHeigth, |
|
|||
70 | deltaHeight=self.__deltaHeigth, |
|
|||
71 | codeType=self.__codeType, |
|
|||
72 | nCode=self.__nCode, nBaud=self.__nBaud, |
|
|||
73 | code = self.__code) |
|
|||
74 |
|
||||
75 | self.dataOut.systemHeaderObj = SystemHeader(nSamples=self.__nSamples, |
|
|||
76 | nProfiles=nProfiles, |
|
|||
77 | nChannels=len(self.__channelList), |
|
|||
78 | adcResolution=14) |
|
|||
79 |
|
67 | |||
80 | self.dataOut.type = "Voltage" |
|
68 | self.dataOut.type = "Voltage" | |
81 |
|
69 | |||
82 | self.dataOut.data = None |
|
70 | self.dataOut.data = None | |
83 |
|
71 | |||
84 |
self.dataOut.dtype = |
|
72 | self.dataOut.dtype = self.dtype | |
85 |
|
73 | |||
86 |
|
|
74 | # self.dataOut.nChannels = 0 | |
87 |
|
75 | |||
88 |
|
|
76 | # self.dataOut.nHeights = 0 | |
89 |
|
77 | |||
90 | self.dataOut.nProfiles = nProfiles |
|
78 | self.dataOut.nProfiles = nProfiles | |
91 |
|
79 | |||
92 | self.dataOut.heightList = self.__firstHeigth + numpy.arange(self.__nSamples, dtype = numpy.float)*self.__deltaHeigth |
|
80 | self.dataOut.heightList = self.__firstHeigth + numpy.arange(self.__nSamples, dtype = numpy.float)*self.__deltaHeigth | |
93 |
|
81 | |||
94 | self.dataOut.channelList = self.__channelList |
|
82 | self.dataOut.channelList = self.__channelList | |
95 |
|
83 | |||
96 | self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights() |
|
84 | self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights() | |
97 |
|
85 | |||
98 |
|
|
86 | # self.dataOut.channelIndexList = None | |
99 |
|
87 | |||
100 | self.dataOut.flagNoData = True |
|
88 | self.dataOut.flagNoData = True | |
101 |
|
89 | self.dataOut.flagDataAsBlock = False | ||
102 | #Set to TRUE if the data is discontinuous |
|
90 | # Set to TRUE if the data is discontinuous | |
103 | self.dataOut.flagDiscontinuousBlock = False |
|
91 | self.dataOut.flagDiscontinuousBlock = False | |
104 |
|
92 | |||
105 | self.dataOut.utctime = None |
|
93 | self.dataOut.utctime = None | |
106 |
|
94 | |||
107 | self.dataOut.timeZone = self.__timezone/60 #timezone like jroheader, difference in minutes between UTC and localtime |
|
95 | self.dataOut.timeZone = self.__timezone/60 # timezone like jroheader, difference in minutes between UTC and localtime | |
108 |
|
96 | |||
109 | self.dataOut.dstFlag = 0 |
|
97 | self.dataOut.dstFlag = 0 | |
110 |
|
98 | |||
111 | self.dataOut.errorCount = 0 |
|
99 | self.dataOut.errorCount = 0 | |
112 |
|
100 | |||
113 | self.dataOut.nCohInt = 1 |
|
101 | self.dataOut.nCohInt = 1 | |
114 |
|
102 | |||
115 | self.dataOut.flagDecodeData = False #asumo que la data esta decodificada |
|
103 | self.dataOut.flagDecodeData = False # asumo que la data esta decodificada | |
116 |
|
104 | |||
117 | self.dataOut.flagDeflipData = False #asumo que la data esta sin flip |
|
105 | self.dataOut.flagDeflipData = False # asumo que la data esta sin flip | |
118 |
|
106 | |||
119 | self.dataOut.flagShiftFFT = False |
|
107 | self.dataOut.flagShiftFFT = False | |
120 |
|
108 | |||
121 | self.dataOut.ippSeconds = ippSeconds |
|
109 | self.dataOut.ippSeconds = ippSeconds | |
122 |
|
110 | |||
123 | #Time interval between profiles |
|
111 | # Time interval between profiles | |
124 | #self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt |
|
112 | # self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt | |
125 |
|
113 | |||
126 | self.dataOut.frequency = self.__frequency |
|
114 | self.dataOut.frequency = self.__frequency | |
127 |
|
115 | |||
128 | self.dataOut.realtime = self.__online |
|
116 | self.dataOut.realtime = self.__online | |
129 |
|
117 | |||
130 | def findDatafiles(self, path, startDate=None, endDate=None): |
|
118 | def findDatafiles(self, path, startDate=None, endDate=None): | |
131 |
|
119 | |||
132 | if not os.path.isdir(path): |
|
120 | if not os.path.isdir(path): | |
133 | return [] |
|
121 | return [] | |
134 |
|
122 | |||
135 | try: |
|
123 | try: | |
136 | digitalReadObj = digital_rf.DigitalRFReader(path, load_all_metadata=True) |
|
124 | digitalReadObj = digital_rf.DigitalRFReader(path, load_all_metadata=True) | |
137 | except: |
|
125 | except: | |
138 | digitalReadObj = digital_rf.DigitalRFReader(path) |
|
126 | digitalReadObj = digital_rf.DigitalRFReader(path) | |
139 |
|
127 | |||
140 | channelNameList = digitalReadObj.get_channels() |
|
128 | channelNameList = digitalReadObj.get_channels() | |
141 |
|
129 | |||
142 | if not channelNameList: |
|
130 | if not channelNameList: | |
143 | return [] |
|
131 | return [] | |
144 |
|
132 | |||
145 | metadata_dict = digitalReadObj.get_rf_file_metadata(channelNameList[0]) |
|
133 | metadata_dict = digitalReadObj.get_rf_file_metadata(channelNameList[0]) | |
146 |
|
134 | |||
147 | sample_rate = metadata_dict['sample_rate'][0] |
|
135 | sample_rate = metadata_dict['sample_rate'][0] | |
148 |
|
136 | |||
149 | this_metadata_file = digitalReadObj.get_metadata(channelNameList[0]) |
|
137 | this_metadata_file = digitalReadObj.get_metadata(channelNameList[0]) | |
150 |
|
138 | |||
151 | try: |
|
139 | try: | |
152 | timezone = this_metadata_file['timezone'].value |
|
140 | timezone = this_metadata_file['timezone'].value | |
153 | except: |
|
141 | except: | |
154 | timezone = 0 |
|
142 | timezone = 0 | |
155 |
|
143 | |||
156 | startUTCSecond, endUTCSecond = digitalReadObj.get_bounds(channelNameList[0])/sample_rate - timezone |
|
144 | startUTCSecond, endUTCSecond = digitalReadObj.get_bounds(channelNameList[0])/sample_rate - timezone | |
157 |
|
145 | |||
158 | startDatetime = datetime.datetime.utcfromtimestamp(startUTCSecond) |
|
146 | startDatetime = datetime.datetime.utcfromtimestamp(startUTCSecond) | |
159 | endDatatime = datetime.datetime.utcfromtimestamp(endUTCSecond) |
|
147 | endDatatime = datetime.datetime.utcfromtimestamp(endUTCSecond) | |
160 |
|
148 | |||
161 | if not startDate: |
|
149 | if not startDate: | |
162 | startDate = startDatetime.date() |
|
150 | startDate = startDatetime.date() | |
163 |
|
151 | |||
164 | if not endDate: |
|
152 | if not endDate: | |
165 | endDate = endDatatime.date() |
|
153 | endDate = endDatatime.date() | |
166 |
|
154 | |||
167 | dateList = [] |
|
155 | dateList = [] | |
168 |
|
156 | |||
169 | thisDatetime = startDatetime |
|
157 | thisDatetime = startDatetime | |
170 |
|
158 | |||
171 | while(thisDatetime<=endDatatime): |
|
159 | while(thisDatetime<=endDatatime): | |
172 |
|
160 | |||
173 | thisDate = thisDatetime.date() |
|
161 | thisDate = thisDatetime.date() | |
174 |
|
162 | |||
175 | if thisDate < startDate: |
|
163 | if thisDate < startDate: | |
176 | continue |
|
164 | continue | |
177 |
|
165 | |||
178 | if thisDate > endDate: |
|
166 | if thisDate > endDate: | |
179 | break |
|
167 | break | |
180 |
|
168 | |||
181 | dateList.append(thisDate) |
|
169 | dateList.append(thisDate) | |
182 | thisDatetime += datetime.timedelta(1) |
|
170 | thisDatetime += datetime.timedelta(1) | |
183 |
|
171 | |||
184 | return dateList |
|
172 | return dateList | |
185 |
|
173 | |||
186 | def setup(self, path = None, |
|
174 | def setup(self, path = None, | |
187 | startDate = None, |
|
175 | startDate = None, | |
188 | endDate = None, |
|
176 | endDate = None, | |
189 | startTime = datetime.time(0,0,0), |
|
177 | startTime = datetime.time(0,0,0), | |
190 | endTime = datetime.time(23,59,59), |
|
178 | endTime = datetime.time(23,59,59), | |
191 | channelList = None, |
|
179 | channelList = None, | |
192 | nSamples = None, |
|
180 | nSamples = None, | |
193 | ippKm = 60, |
|
181 | ippKm = 60, | |
194 | online = False, |
|
182 | online = False, | |
195 | delay = 60, |
|
183 | delay = 60, | |
196 | buffer_size = 1024, |
|
184 | buffer_size = 1024, | |
197 | **kwargs): |
|
185 | **kwargs): | |
198 | ''' |
|
186 | ''' | |
199 | In this method we should set all initial parameters. |
|
187 | In this method we should set all initial parameters. | |
200 |
|
188 | |||
201 | Inputs: |
|
189 | Inputs: | |
202 | path |
|
190 | path | |
203 | startDate |
|
191 | startDate | |
204 | endDate |
|
192 | endDate | |
205 | startTime |
|
193 | startTime | |
206 | endTime |
|
194 | endTime | |
207 | set |
|
195 | set | |
208 | expLabel |
|
196 | expLabel | |
209 | ext |
|
197 | ext | |
210 | online |
|
198 | online | |
211 | delay |
|
199 | delay | |
212 | ''' |
|
200 | ''' | |
213 |
|
201 | |||
214 | if not os.path.isdir(path): |
|
202 | if not os.path.isdir(path): | |
215 | raise ValueError, "[Reading] Directory %s does not exist" %path |
|
203 | raise ValueError, "[Reading] Directory %s does not exist" %path | |
216 |
|
204 | |||
217 | try: |
|
205 | try: | |
218 | self.digitalReadObj = digital_rf.DigitalRFReader(path, load_all_metadata=True) |
|
206 | self.digitalReadObj = digital_rf.DigitalRFReader(path, load_all_metadata=True) | |
219 | except: |
|
207 | except: | |
220 | self.digitalReadObj = digital_rf.DigitalRFReader(path) |
|
208 | self.digitalReadObj = digital_rf.DigitalRFReader(path) | |
221 |
|
209 | |||
222 | channelNameList = self.digitalReadObj.get_channels() |
|
210 | channelNameList = self.digitalReadObj.get_channels() | |
223 |
|
211 | |||
224 | if not channelNameList: |
|
212 | if not channelNameList: | |
225 | raise ValueError, "[Reading] Directory %s does not have any files" %path |
|
213 | raise ValueError, "[Reading] Directory %s does not have any files" %path | |
226 |
|
214 | |||
227 | if not channelList: |
|
215 | if not channelList: | |
228 | channelList = range(len(channelNameList)) |
|
216 | channelList = range(len(channelNameList)) | |
229 |
|
217 | |||
|
218 | ||||
230 | ########## Reading metadata ###################### |
|
219 | ########## Reading metadata ###################### | |
231 |
|
220 | |||
232 |
|
|
221 | top_properties = self.digitalReadObj.get_properties(channelNameList[channelList[0]]) | |
233 |
|
222 | |||
234 |
self.__sample_rate = |
|
223 | self.__sample_rate = 1.0 * top_properties['sample_rate_numerator'] / top_properties['sample_rate_denominator'] | |
235 |
|
|
224 | # self.__samples_per_file = top_properties['samples_per_file'][0] | |
236 | self.__deltaHeigth = 1e6*0.15/self.__sample_rate ## why 0.15? |
|
225 | self.__deltaHeigth = 1e6*0.15/self.__sample_rate ## why 0.15? | |
237 |
|
226 | |||
238 | this_metadata_file = self.digitalReadObj.get_digital_metadata(channelNameList[channelList[0]]) |
|
227 | this_metadata_file = self.digitalReadObj.get_digital_metadata(channelNameList[channelList[0]]) | |
239 | metadata_bounds = this_metadata_file.get_bounds() |
|
228 | metadata_bounds = this_metadata_file.get_bounds() | |
240 | self.fixed_metadata_dict = this_metadata_file.read(metadata_bounds[0])[metadata_bounds[0]] ##GET FIRST HEADER |
|
229 | self.fixed_metadata_dict = this_metadata_file.read(metadata_bounds[0])[metadata_bounds[0]] ## GET FIRST HEADER | |
|
230 | self.__processingHeader = self.fixed_metadata_dict['processingHeader'] | |||
|
231 | self.__radarControllerHeader = self.fixed_metadata_dict['radarControllerHeader'] | |||
|
232 | self.__systemHeader = self.fixed_metadata_dict['systemHeader'] | |||
|
233 | self.dtype = cPickle.loads(self.fixed_metadata_dict['dtype']) | |||
241 |
|
234 | |||
242 | self.__frequency = None |
|
235 | self.__frequency = None | |
|
236 | ||||
243 | try: |
|
237 | try: | |
244 | self.__frequency = self.fixed_metadata_dict['frequency'] |
|
238 | self.__frequency = self.fixed_metadata_dict['frequency'] | |
245 | except: |
|
239 | except: | |
246 | self.__frequency = None |
|
240 | self.__frequency = None | |
247 |
|
241 | |||
248 | try: |
|
242 | try: | |
249 | self.__timezone = self.fixed_metadata_dict['timezone'] |
|
243 | self.__timezone = self.fixed_metadata_dict['timezone'] | |
250 | except: |
|
244 | except: | |
251 | self.__timezone = 0 |
|
245 | self.__timezone = 0 | |
252 |
|
246 | |||
|
247 | ||||
|
248 | try: | |||
|
249 | nSamples = self.__systemHeader['nSamples'] | |||
|
250 | except: | |||
|
251 | nSamples = None | |||
|
252 | ||||
253 | self.__firstHeigth = 0 |
|
253 | self.__firstHeigth = 0 | |
254 |
|
254 | |||
255 | try: |
|
255 | try: | |
256 |
codeType = self. |
|
256 | codeType = self.__radarControllerHeader['codeType'] | |
257 | except: |
|
257 | except: | |
258 | codeType = 0 |
|
258 | codeType = 0 | |
259 |
|
259 | |||
260 | nCode = 1 |
|
260 | nCode = 1 | |
261 | nBaud = 1 |
|
261 | nBaud = 1 | |
262 | code = numpy.ones((nCode, nBaud), dtype=numpy.int) |
|
262 | code = numpy.ones((nCode, nBaud), dtype=numpy.int) | |
263 |
|
263 | |||
264 | if codeType: |
|
264 | if codeType: | |
265 |
nCode = self. |
|
265 | nCode = self.__radarControllerHeader['nCode'] | |
266 |
nBaud = self. |
|
266 | nBaud = self.__radarControllerHeader['nBaud'] | |
267 |
code = self. |
|
267 | code = self.__radarControllerHeader['code'] | |
268 |
|
268 | |||
269 | if not ippKm: |
|
269 | if not ippKm: | |
270 | try: |
|
270 | try: | |
271 | #seconds to km |
|
271 | # seconds to km | |
272 |
ippKm = 1e6*0.15*self. |
|
272 | ippKm = 1e6*0.15*self.__radarControllerHeader['ipp'] | |
273 | except: |
|
273 | except: | |
274 | ippKm = None |
|
274 | ippKm = None | |
275 | #################################################### |
|
275 | #################################################### | |
276 | startUTCSecond = None |
|
276 | startUTCSecond = None | |
277 | endUTCSecond = None |
|
277 | endUTCSecond = None | |
278 |
|
278 | |||
279 | if startDate: |
|
279 | if startDate: | |
280 | startDatetime = datetime.datetime.combine(startDate, startTime) |
|
280 | startDatetime = datetime.datetime.combine(startDate, startTime) | |
281 | startUTCSecond = (startDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone |
|
281 | startUTCSecond = (startDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone | |
282 |
|
282 | |||
283 | if endDate: |
|
283 | if endDate: | |
284 | endDatetime = datetime.datetime.combine(endDate, endTime) |
|
284 | endDatetime = datetime.datetime.combine(endDate, endTime) | |
285 | endUTCSecond = (endDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone |
|
285 | endUTCSecond = (endDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone | |
286 |
|
286 | |||
287 | start_index, end_index = self.digitalReadObj.get_bounds(channelNameList[channelList[0]]) |
|
287 | start_index, end_index = self.digitalReadObj.get_bounds(channelNameList[channelList[0]]) | |
288 |
|
288 | |||
289 | if not startUTCSecond: |
|
289 | if not startUTCSecond: | |
290 | startUTCSecond = start_index/self.__sample_rate |
|
290 | startUTCSecond = start_index/self.__sample_rate | |
291 |
|
291 | |||
292 | if start_index > startUTCSecond*self.__sample_rate: |
|
292 | if start_index > startUTCSecond*self.__sample_rate: | |
293 | startUTCSecond = start_index/self.__sample_rate |
|
293 | startUTCSecond = start_index/self.__sample_rate | |
294 |
|
294 | |||
295 | if not endUTCSecond: |
|
295 | if not endUTCSecond: | |
296 | endUTCSecond = end_index/self.__sample_rate |
|
296 | endUTCSecond = end_index/self.__sample_rate | |
297 |
|
297 | |||
298 | if end_index < endUTCSecond*self.__sample_rate: |
|
298 | if end_index < endUTCSecond*self.__sample_rate: | |
299 | endUTCSecond = end_index/self.__sample_rate |
|
299 | endUTCSecond = end_index/self.__sample_rate | |
300 |
|
300 | |||
301 | if not nSamples: |
|
301 | if not nSamples: | |
302 | if not ippKm: |
|
302 | if not ippKm: | |
303 | raise ValueError, "[Reading] nSamples or ippKm should be defined" |
|
303 | raise ValueError, "[Reading] nSamples or ippKm should be defined" | |
304 | nSamples = int(ippKm / (1e6*0.15/self.__sample_rate)) |
|
304 | nSamples = int(ippKm / (1e6*0.15/self.__sample_rate)) | |
305 |
|
305 | |||
306 | channelBoundList = [] |
|
306 | channelBoundList = [] | |
307 | channelNameListFiltered = [] |
|
307 | channelNameListFiltered = [] | |
308 |
|
308 | |||
309 | for thisIndexChannel in channelList: |
|
309 | for thisIndexChannel in channelList: | |
310 | thisChannelName = channelNameList[thisIndexChannel] |
|
310 | thisChannelName = channelNameList[thisIndexChannel] | |
311 | start_index, end_index = self.digitalReadObj.get_bounds(thisChannelName) |
|
311 | start_index, end_index = self.digitalReadObj.get_bounds(thisChannelName) | |
312 | channelBoundList.append((start_index, end_index)) |
|
312 | channelBoundList.append((start_index, end_index)) | |
313 | channelNameListFiltered.append(thisChannelName) |
|
313 | channelNameListFiltered.append(thisChannelName) | |
314 |
|
314 | |||
315 | self.profileIndex = 0 |
|
315 | self.profileIndex = 0 | |
316 |
|
316 | self.i= 0 | ||
317 | self.__delay = delay |
|
317 | self.__delay = delay | |
318 | self.__ippKm = ippKm |
|
318 | self.__ippKm = ippKm | |
319 | self.__codeType = codeType |
|
319 | self.__codeType = codeType | |
320 | self.__nCode = nCode |
|
320 | self.__nCode = nCode | |
321 | self.__nBaud = nBaud |
|
321 | self.__nBaud = nBaud | |
322 | self.__code = code |
|
322 | self.__code = code | |
323 |
|
323 | |||
324 | self.__datapath = path |
|
324 | self.__datapath = path | |
325 | self.__online = online |
|
325 | self.__online = online | |
326 | self.__channelList = channelList |
|
326 | self.__channelList = channelList | |
327 | self.__channelNameList = channelNameListFiltered |
|
327 | self.__channelNameList = channelNameListFiltered | |
328 | self.__channelBoundList = channelBoundList |
|
328 | self.__channelBoundList = channelBoundList | |
329 | self.__nSamples = nSamples |
|
329 | self.__nSamples = nSamples | |
330 |
self.__samples_to_read = long( |
|
330 | self.__samples_to_read = long(nSamples) # FIJO: AHORA 40 | |
331 | self.__nChannels = len(self.__channelList) |
|
331 | self.__nChannels = len(self.__channelList) | |
332 |
|
332 | |||
333 | self.__startUTCSecond = startUTCSecond |
|
333 | self.__startUTCSecond = startUTCSecond | |
334 | self.__endUTCSecond = endUTCSecond |
|
334 | self.__endUTCSecond = endUTCSecond | |
335 |
|
335 | |||
336 | self.__timeInterval = 1.0 * self.__samples_to_read/self.__sample_rate #Time interval |
|
336 | self.__timeInterval = 1.0 * self.__samples_to_read/self.__sample_rate # Time interval | |
337 |
|
337 | |||
338 | if online: |
|
338 | if online: | |
339 |
|
|
339 | # self.__thisUnixSample = int(endUTCSecond*self.__sample_rate - 4*self.__samples_to_read) | |
340 | startUTCSecond = numpy.floor(endUTCSecond) |
|
340 | startUTCSecond = numpy.floor(endUTCSecond) | |
341 |
|
341 | |||
342 | self.__thisUnixSample = long(startUTCSecond*self.__sample_rate) - self.__samples_to_read ##por que en el otro metodo lo primero q se hace es sumar samplestoread |
|
342 | self.__thisUnixSample = long(startUTCSecond*self.__sample_rate) - self.__samples_to_read ## por que en el otro metodo lo primero q se hace es sumar samplestoread | |
343 |
|
343 | |||
344 | self.__data_buffer = numpy.zeros((self.__nChannels, self.__samples_to_read), dtype = numpy.complex) |
|
344 | self.__data_buffer = numpy.zeros((self.__nChannels, self.__samples_to_read), dtype = numpy.complex) | |
345 |
|
345 | |||
346 | self.__setFileHeader() |
|
346 | self.__setFileHeader() | |
347 | self.isConfig = True |
|
347 | self.isConfig = True | |
348 |
|
348 | |||
349 | print "[Reading] Digital RF Data was found from %s to %s " %( |
|
349 | print "[Reading] Digital RF Data was found from %s to %s " %( | |
350 | datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
350 | datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), | |
351 | datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
351 | datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) | |
352 | ) |
|
352 | ) | |
353 |
|
353 | |||
354 | print "[Reading] Starting process from %s to %s" %(datetime.datetime.utcfromtimestamp(startUTCSecond - self.__timezone), |
|
354 | print "[Reading] Starting process from %s to %s" %(datetime.datetime.utcfromtimestamp(startUTCSecond - self.__timezone), | |
355 | datetime.datetime.utcfromtimestamp(endUTCSecond - self.__timezone) |
|
355 | datetime.datetime.utcfromtimestamp(endUTCSecond - self.__timezone) | |
356 | ) |
|
356 | ) | |
357 |
|
357 | |||
358 | def __reload(self): |
|
358 | def __reload(self): | |
359 |
|
359 | |||
360 | # print "%s not in range [%s, %s]" %( |
|
360 | # print "%s not in range [%s, %s]" %( | |
361 | # datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), |
|
361 | # datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), | |
362 | # datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
362 | # datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), | |
363 | # datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
363 | # datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) | |
364 | # ) |
|
364 | # ) | |
365 | print "[Reading] reloading metadata ..." |
|
365 | print "[Reading] reloading metadata ..." | |
366 |
|
366 | |||
367 | try: |
|
367 | try: | |
368 | self.digitalReadObj.reload(complete_update=True) |
|
368 | self.digitalReadObj.reload(complete_update=True) | |
369 | except: |
|
369 | except: | |
370 | self.digitalReadObj.reload() |
|
370 | self.digitalReadObj.reload() | |
371 |
|
371 | |||
372 | start_index, end_index = self.digitalReadObj.get_bounds(self.__channelNameList[self.__channelList[0]]) |
|
372 | start_index, end_index = self.digitalReadObj.get_bounds(self.__channelNameList[self.__channelList[0]]) | |
373 |
|
373 | |||
374 | if start_index > self.__startUTCSecond*self.__sample_rate: |
|
374 | if start_index > self.__startUTCSecond*self.__sample_rate: | |
375 | self.__startUTCSecond = 1.0*start_index/self.__sample_rate |
|
375 | self.__startUTCSecond = 1.0*start_index/self.__sample_rate | |
376 |
|
376 | |||
377 | if end_index > self.__endUTCSecond*self.__sample_rate: |
|
377 | if end_index > self.__endUTCSecond*self.__sample_rate: | |
378 | self.__endUTCSecond = 1.0*end_index/self.__sample_rate |
|
378 | self.__endUTCSecond = 1.0*end_index/self.__sample_rate | |
379 |
|
379 | |||
380 | print "[Reading] New timerange found [%s, %s] " %( |
|
380 | print "[Reading] New timerange found [%s, %s] " %( | |
381 | datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), |
|
381 | datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone), | |
382 | datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) |
|
382 | datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone) | |
383 | ) |
|
383 | ) | |
384 |
|
384 | |||
385 | return True |
|
385 | return True | |
386 |
|
386 | |||
387 | return False |
|
387 | return False | |
388 |
|
388 | |||
389 | def __readNextBlock(self, seconds=30, volt_scale = 1): |
|
389 | def __readNextBlock(self, seconds=30, volt_scale = 1): | |
390 | ''' |
|
390 | ''' | |
391 | ''' |
|
391 | ''' | |
392 |
|
392 | |||
393 | #Set the next data |
|
393 | # Set the next data | |
394 | self.__flagDiscontinuousBlock = False |
|
394 | self.__flagDiscontinuousBlock = False | |
395 | self.__thisUnixSample += self.__samples_to_read |
|
395 | self.__thisUnixSample += self.__samples_to_read | |
396 |
|
396 | |||
397 | if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate: |
|
397 | if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate: | |
398 | print "[Reading] There are no more data into selected time-range" |
|
398 | print "[Reading] There are no more data into selected time-range" | |
399 | if self.__online: |
|
399 | if self.__online: | |
400 | self.__reload() |
|
400 | self.__reload() | |
401 | else: |
|
401 | else: | |
402 | return False |
|
402 | return False | |
403 |
|
403 | |||
404 | if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate: |
|
404 | if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate: | |
405 | return False |
|
405 | return False | |
406 | self.__thisUnixSample -= self.__samples_to_read |
|
406 | self.__thisUnixSample -= self.__samples_to_read | |
407 |
|
407 | |||
408 | indexChannel = 0 |
|
408 | indexChannel = 0 | |
409 |
|
409 | |||
410 | dataOk = False |
|
410 | dataOk = False | |
411 |
|
||||
412 | for thisChannelName in self.__channelNameList: ##TODO VARIOS CHANNELS? |
|
411 | for thisChannelName in self.__channelNameList: ##TODO VARIOS CHANNELS? | |
413 |
|
||||
414 | try: |
|
412 | try: | |
415 | result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample, |
|
413 | result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample, | |
416 | self.__samples_to_read, |
|
414 | self.__samples_to_read, | |
417 | thisChannelName) |
|
415 | thisChannelName) | |
418 | except IOError, e: |
|
416 | except IOError, e: | |
419 | #read next profile |
|
417 | #read next profile | |
420 | self.__flagDiscontinuousBlock = True |
|
418 | self.__flagDiscontinuousBlock = True | |
421 | print "[Reading] %s" %datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), e |
|
419 | print "[Reading] %s" %datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), e | |
422 | break |
|
420 | break | |
423 |
|
421 | |||
424 | if result.shape[0] != self.__samples_to_read: |
|
422 | if result.shape[0] != self.__samples_to_read: | |
425 | self.__flagDiscontinuousBlock = True |
|
423 | self.__flagDiscontinuousBlock = True | |
426 | print "[Reading] %s: Too few samples were found, just %d/%d samples" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), |
|
424 | print "[Reading] %s: Too few samples were found, just %d/%d samples" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), | |
427 | result.shape[0], |
|
425 | result.shape[0], | |
428 | self.__samples_to_read) |
|
426 | self.__samples_to_read) | |
429 | break |
|
427 | break | |
430 |
|
428 | |||
431 | self.__data_buffer[indexChannel,:] = result*volt_scale |
|
429 | self.__data_buffer[indexChannel,:] = result*volt_scale | |
432 |
|
430 | |||
433 | indexChannel += 1 |
|
431 | indexChannel += 1 | |
434 |
|
432 | |||
435 | dataOk = True |
|
433 | dataOk = True | |
436 |
|
434 | |||
437 | self.__utctime = self.__thisUnixSample/self.__sample_rate |
|
435 | self.__utctime = self.__thisUnixSample/self.__sample_rate | |
438 |
|
436 | |||
439 | if not dataOk: |
|
437 | if not dataOk: | |
440 | return False |
|
438 | return False | |
441 |
|
439 | |||
442 | print "[Reading] %s: %d samples <> %f sec" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), |
|
440 | print "[Reading] %s: %d samples <> %f sec" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), | |
443 | self.__samples_to_read, |
|
441 | self.__samples_to_read, | |
444 | self.__timeInterval) |
|
442 | self.__timeInterval) | |
445 |
|
443 | |||
446 | self.__bufferIndex = 0 |
|
444 | self.__bufferIndex = 0 | |
447 |
|
445 | |||
448 | return True |
|
446 | return True | |
449 |
|
447 | |||
450 | def __isBufferEmpty(self): |
|
448 | def __isBufferEmpty(self): | |
451 | return self.__bufferIndex > self.__samples_to_read - self.__nSamples #40960 - 40 |
|
449 | return self.__bufferIndex > self.__samples_to_read - self.__nSamples #40960 - 40 | |
452 |
|
450 | |||
453 | def getData(self, seconds=30, nTries=5): |
|
451 | def getData(self, seconds=30, nTries=5): | |
454 |
|
452 | |||
455 | ''' |
|
453 | ''' | |
456 | This method gets the data from files and put the data into the dataOut object |
|
454 | This method gets the data from files and put the data into the dataOut object | |
457 |
|
455 | |||
458 | In addition, increase el the buffer counter in one. |
|
456 | In addition, increase el the buffer counter in one. | |
459 |
|
457 | |||
460 | Return: |
|
458 | Return: | |
461 | data : retorna un perfil de voltages (alturas * canales) copiados desde el |
|
459 | data : retorna un perfil de voltages (alturas * canales) copiados desde el | |
462 | buffer. Si no hay mas archivos a leer retorna None. |
|
460 | buffer. Si no hay mas archivos a leer retorna None. | |
463 |
|
461 | |||
464 | Affected: |
|
462 | Affected: | |
465 | self.dataOut |
|
463 | self.dataOut | |
466 | self.profileIndex |
|
464 | self.profileIndex | |
467 | self.flagDiscontinuousBlock |
|
465 | self.flagDiscontinuousBlock | |
468 | self.flagIsNewBlock |
|
466 | self.flagIsNewBlock | |
469 | ''' |
|
467 | ''' | |
470 |
|
468 | |||
471 | err_counter = 0 |
|
469 | err_counter = 0 | |
472 | self.dataOut.flagNoData = True |
|
470 | self.dataOut.flagNoData = True | |
473 |
|
471 | |||
474 | if self.__isBufferEmpty(): |
|
472 | if self.__isBufferEmpty(): | |
475 |
|
||||
476 | self.__flagDiscontinuousBlock = False |
|
473 | self.__flagDiscontinuousBlock = False | |
477 |
|
474 | |||
478 | while True: |
|
475 | while True: | |
479 | if self.__readNextBlock(): |
|
476 | if self.__readNextBlock(): | |
480 | break |
|
477 | break | |
481 | if self.__thisUnixSample > self.__endUTCSecond*self.__sample_rate: |
|
478 | if self.__thisUnixSample > self.__endUTCSecond*self.__sample_rate: | |
482 | return False |
|
479 | return False | |
483 |
|
480 | |||
484 | if self.__flagDiscontinuousBlock: |
|
481 | if self.__flagDiscontinuousBlock: | |
485 | print '[Reading] discontinuous block found ... continue with the next block' |
|
482 | print '[Reading] discontinuous block found ... continue with the next block' | |
486 | continue |
|
483 | continue | |
487 |
|
484 | |||
488 | if not self.__online: |
|
485 | if not self.__online: | |
489 | return False |
|
486 | return False | |
490 |
|
487 | |||
491 | err_counter += 1 |
|
488 | err_counter += 1 | |
492 | if err_counter > nTries: |
|
489 | if err_counter > nTries: | |
493 | return False |
|
490 | return False | |
494 |
|
491 | |||
495 | print '[Reading] waiting %d seconds to read a new block' %seconds |
|
492 | print '[Reading] waiting %d seconds to read a new block' %seconds | |
496 | sleep(seconds) |
|
493 | sleep(seconds) | |
497 |
|
494 | |||
498 | self.dataOut.data = self.__data_buffer[:,self.__bufferIndex:self.__bufferIndex+self.__nSamples] |
|
495 | self.dataOut.data = self.__data_buffer[:,self.__bufferIndex:self.__bufferIndex+self.__nSamples] | |
499 | self.dataOut.utctime = (self.__thisUnixSample + self.__bufferIndex)/self.__sample_rate |
|
496 | self.dataOut.utctime = (self.__thisUnixSample + self.__bufferIndex)/self.__sample_rate | |
500 | self.dataOut.flagNoData = False |
|
497 | self.dataOut.flagNoData = False | |
501 | self.dataOut.flagDiscontinuousBlock = self.__flagDiscontinuousBlock |
|
498 | self.dataOut.flagDiscontinuousBlock = self.__flagDiscontinuousBlock | |
502 | self.dataOut.profileIndex = self.profileIndex |
|
499 | self.dataOut.profileIndex = self.profileIndex | |
503 |
|
500 | |||
504 | self.__bufferIndex += self.__nSamples |
|
501 | self.__bufferIndex += self.__nSamples | |
505 | self.profileIndex += 1 |
|
502 | self.profileIndex += 1 | |
506 |
|
503 | |||
507 | if self.profileIndex == self.dataOut.nProfiles: |
|
504 | if self.profileIndex == self.dataOut.nProfiles: | |
508 | self.profileIndex = 0 |
|
505 | self.profileIndex = 0 | |
509 |
|
506 | |||
510 | return True |
|
507 | return True | |
511 |
|
508 | |||
512 | def printInfo(self): |
|
509 | def printInfo(self): | |
513 | ''' |
|
510 | ''' | |
514 | ''' |
|
511 | ''' | |
515 | if self.__printInfo == False: |
|
512 | if self.__printInfo == False: | |
516 | return |
|
513 | return | |
517 |
|
514 | |||
518 |
|
|
515 | # self.systemHeaderObj.printInfo() | |
519 |
|
|
516 | # self.radarControllerHeaderObj.printInfo() | |
520 |
|
517 | |||
521 | self.__printInfo = False |
|
518 | self.__printInfo = False | |
522 |
|
519 | |||
523 | def printNumberOfBlock(self): |
|
520 | def printNumberOfBlock(self): | |
524 | ''' |
|
521 | ''' | |
525 | ''' |
|
522 | ''' | |
526 | return |
|
523 | return | |
527 | #print self.profileIndex |
|
524 | # print self.profileIndex | |
528 |
|
525 | |||
|
526 | ##@profile | |||
529 | def run(self, **kwargs): |
|
527 | def run(self, **kwargs): | |
530 | ''' |
|
528 | ''' | |
531 | This method will be called many times so here you should put all your code |
|
529 | This method will be called many times so here you should put all your code | |
532 | ''' |
|
530 | ''' | |
533 |
|
531 | |||
534 | if not self.isConfig: |
|
532 | if not self.isConfig: | |
535 | self.setup(**kwargs) |
|
533 | self.setup(**kwargs) | |
536 |
|
534 | print self.dataOut.dtype | ||
|
535 | self.i = self.i+1 | |||
537 | self.getData(seconds=self.__delay) |
|
536 | self.getData(seconds=self.__delay) | |
538 |
|
537 | |||
539 | return |
|
538 | return | |
540 |
|
539 | |||
541 | class DigitalRFWriter(Operation): |
|
540 | class DigitalRFWriter(Operation): | |
542 | ''' |
|
541 | ''' | |
543 | classdocs |
|
542 | classdocs | |
544 | ''' |
|
543 | ''' | |
545 |
|
544 | |||
546 | def __init__(self, **kwargs): |
|
545 | def __init__(self, **kwargs): | |
547 | ''' |
|
546 | ''' | |
548 | Constructor |
|
547 | Constructor | |
549 | ''' |
|
548 | ''' | |
550 | Operation.__init__(self, **kwargs) |
|
549 | Operation.__init__(self, **kwargs) | |
|
550 | self.metadata_dict = {} | |||
551 | self.dataOut = None |
|
551 | self.dataOut = None | |
552 |
|
552 | |||
553 | def setup(self, dataOut, path, set=0, metadataFile='metadata', ext='.h5'): |
|
553 | def setup(self, dataOut, path, frequency, set=0, metadataFile='metadata', ext='.h5'): | |
554 | ''' |
|
554 | ''' | |
555 | In this method we should set all initial parameters. |
|
555 | In this method we should set all initial parameters. | |
556 |
|
||||
557 | Input: |
|
556 | Input: | |
558 |
dataOut |
|
557 | dataOut: Input data will also be outputa data | |
559 |
|
||||
560 | ''' |
|
558 | ''' | |
|
559 | self.metadata_dict['frequency'] = frequency | |||
|
560 | self.metadata_dict['timezone'] = -5 * 60 * 60 | |||
|
561 | self.metadata_dict['dtype'] = cPickle.dumps(dataOut.dtype) | |||
561 |
|
562 | |||
562 | self.__ippSeconds = dataOut.ippSeconds |
|
563 | self.__ippSeconds = dataOut.ippSeconds | |
563 | self.__deltaH = dataOut.getDeltaH() |
|
564 | self.__deltaH = dataOut.getDeltaH() | |
564 | self.__sample_rate = 1e6*0.15/self.__deltaH |
|
565 | self.__sample_rate = 1e6*0.15/self.__deltaH | |
565 | self.__dtype = dataOut.dtype |
|
566 | self.__dtype = dataOut.dtype | |
566 | if len(dataOut.dtype) == 2: |
|
567 | if len(dataOut.dtype) == 2: | |
567 | self.__dtype = dataOut.dtype[0] |
|
568 | self.__dtype = dataOut.dtype[0] | |
568 | self.__nSamples = dataOut.systemHeaderObj.nSamples |
|
569 | self.__nSamples = dataOut.systemHeaderObj.nSamples | |
569 | self.__nProfiles = dataOut.nProfiles |
|
570 | self.__nProfiles = dataOut.nProfiles | |
570 | self.__blocks_per_file = dataOut.processingHeaderObj.dataBlocksPerFile |
|
571 | self.__blocks_per_file = dataOut.processingHeaderObj.dataBlocksPerFile | |
571 | self.arr_data = arr_data = numpy.ones((self.__nSamples, 1), dtype=[('r', self.__dtype), ('i', self.__dtype)]) |
|
572 | self.arr_data = arr_data = numpy.ones((self.__nSamples, 1), dtype=[('r', self.__dtype), ('i', self.__dtype)]) | |
572 |
|
573 | |||
573 |
file_cadence_millisecs = long(1.0 * self.__blocks_per_file * self.__nProfiles * self.__nSamples / self.__sample_rate * 1000 |
|
574 | file_cadence_millisecs = long(1.0 * self.__blocks_per_file * self.__nProfiles * self.__nSamples / self.__sample_rate) * 1000 | |
574 | sub_cadence_secs = file_cadence_millisecs |
|
575 | sub_cadence_secs = file_cadence_millisecs / 500 | |
575 |
|
576 | |||
576 |
|
|
577 | print file_cadence_millisecs | |
577 |
|
|
578 | print sub_cadence_secs | |
578 |
|
579 | |||
579 | sample_rate_fraction = Fraction(self.__sample_rate).limit_denominator() |
|
580 | sample_rate_fraction = Fraction(self.__sample_rate).limit_denominator() | |
580 | sample_rate_numerator = long(sample_rate_fraction.numerator) |
|
581 | sample_rate_numerator = long(sample_rate_fraction.numerator) | |
581 | sample_rate_denominator = long(sample_rate_fraction.denominator) |
|
582 | sample_rate_denominator = long(sample_rate_fraction.denominator) | |
582 | start_global_index = dataOut.utctime * self.__sample_rate |
|
583 | start_global_index = dataOut.utctime * self.__sample_rate | |
583 |
|
584 | |||
584 | uuid = 'prueba' |
|
585 | uuid = 'prueba' | |
585 | compression_level = 1 |
|
586 | compression_level = 1 | |
586 | checksum = False |
|
587 | checksum = False | |
587 | is_complex = True |
|
588 | is_complex = True | |
588 | num_subchannels = 1 |
|
589 | num_subchannels = 1 | |
589 | is_continuous = True |
|
590 | is_continuous = True | |
590 | marching_periods = False |
|
591 | marching_periods = False | |
591 |
|
592 | |||
592 |
self.digitalWriteObj = digital_rf.DigitalRFWriter(path, self.__dtype, |
|
593 | self.digitalWriteObj = digital_rf.DigitalRFWriter(path, self.__dtype, 100, | |
593 |
|
|
594 | 1000, start_global_index, | |
594 | sample_rate_numerator, sample_rate_denominator, uuid, compression_level, checksum, |
|
595 | sample_rate_numerator, sample_rate_denominator, uuid, compression_level, checksum, | |
595 | is_complex, num_subchannels, is_continuous, marching_periods) |
|
596 | is_complex, num_subchannels, is_continuous, marching_periods) | |
596 |
|
597 | |||
597 | metadata_dir = os.path.join(path, 'metadata') |
|
598 | metadata_dir = os.path.join(path, 'metadata') | |
598 | os.system('mkdir %s' % (metadata_dir)) |
|
599 | os.system('mkdir %s' % (metadata_dir)) | |
599 |
|
600 | |||
600 |
self.digitalMetadataWriteObj = digital_rf.DigitalMetadataWriter(metadata_dir, |
|
601 | self.digitalMetadataWriteObj = digital_rf.DigitalMetadataWriter(metadata_dir, 100, 1, ##236, file_cadence_millisecs / 1000 | |
601 | sample_rate_numerator, sample_rate_denominator, |
|
602 | sample_rate_numerator, sample_rate_denominator, | |
602 | metadataFile) |
|
603 | metadataFile) | |
603 |
|
604 | |||
604 |
|
605 | |||
605 | self.isConfig = True |
|
606 | self.isConfig = True | |
606 | self.currentSample = 0 |
|
607 | self.currentSample = 0 | |
607 | return |
|
608 | return | |
608 |
|
609 | |||
609 | @coverage |
|
610 | def writeMetadata(self): | |
610 | def run(self, dataOut, path=None, **kwargs): |
|
611 | print '[Writing] - Writing metadata' | |
|
612 | start_idx = self.__sample_rate * self.dataOut.utctime | |||
|
613 | ||||
|
614 | self.metadata_dict['processingHeader'] = self.dataOut.processingHeaderObj.getAsDict() | |||
|
615 | self.metadata_dict['radarControllerHeader'] = self.dataOut.radarControllerHeaderObj.getAsDict() | |||
|
616 | self.metadata_dict['systemHeader'] = self.dataOut.systemHeaderObj.getAsDict() | |||
|
617 | self.digitalMetadataWriteObj.write(start_idx, self.metadata_dict) | |||
|
618 | return | |||
|
619 | ||||
|
620 | ||||
|
621 | def writeData(self): | |||
|
622 | for i in range(self.dataOut.systemHeaderObj.nSamples): | |||
|
623 | self.arr_data[i]['r'] = self.dataOut.data[0][i].real | |||
|
624 | self.arr_data[i]['i'] = self.dataOut.data[0][i].imag | |||
|
625 | self.digitalWriteObj.rf_write(self.arr_data) | |||
|
626 | return | |||
|
627 | ||||
|
628 | def run(self, dataOut, frequency=49.92e6, path=None, **kwargs): | |||
611 | ''' |
|
629 | ''' | |
612 | This method will be called many times so here you should put all your code |
|
630 | This method will be called many times so here you should put all your code | |
613 |
|
||||
614 | Inputs: |
|
631 | Inputs: | |
615 |
|
||||
616 |
dataOut |
|
632 | dataOut: object with the data | |
617 |
|
||||
618 | ''' |
|
633 | ''' | |
619 | #print dataOut.__dict__ |
|
634 | # print dataOut.__dict__ | |
620 | self.dataOut = dataOut |
|
635 | self.dataOut = dataOut | |
621 |
|
||||
622 | if not self.isConfig: |
|
636 | if not self.isConfig: | |
623 | self.setup(dataOut, path, **kwargs) |
|
637 | self.setup(dataOut, path, frequency, **kwargs) | |
624 |
|
638 | |||
625 | samples = len(self.dataOut.data[0]) |
|
639 | self.writeData() | |
626 |
|
640 | |||
627 | for i in range(samples): |
|
|||
628 | self.arr_data[i]['r'] = dataOut.data[0][i].real |
|
|||
629 | self.arr_data[i]['i'] = dataOut.data[0][i].imag |
|
|||
630 | self.digitalWriteObj.rf_write(self.arr_data) |
|
|||
631 | start_idx = self.__sample_rate * dataOut.utctime |
|
|||
632 | metadata_dict = {} |
|
|||
633 | metadata_dict['frequency'] = 49.92e6 |
|
|||
634 | metadata_dict['blablabla'] = 49.92e6 |
|
|||
635 | self.currentSample += 1 |
|
641 | self.currentSample += 1 | |
636 | if self.dataOut.flagDataAsBlock: |
|
642 | if self.dataOut.flagDataAsBlock or self.currentSample == 1: | |
637 | self.digitalMetadataWriteObj.write(start_idx, metadata_dict) |
|
643 | self.writeMetadata() | |
638 | elif self.currentSample == 1: |
|
|||
639 | print '[Writing] - Writing metadata' |
|
|||
640 | self.digitalMetadataWriteObj.write(start_idx, metadata_dict) |
|
|||
641 | if self.currentSample == self.__nProfiles: self.currentSample = 0 |
|
644 | if self.currentSample == self.__nProfiles: self.currentSample = 0 | |
|
645 | ||||
642 | def close(self): |
|
646 | def close(self): | |
643 | print '[Writing] - Closing files ' |
|
647 | print '[Writing] - Closing files ' | |
|
648 | try: | |||
644 | self.digitalWriteObj.close() |
|
649 | self.digitalWriteObj.close() | |
|
650 | except: | |||
|
651 | pass | |||
|
652 | ||||
645 | #raise |
|
653 | # raise | |
646 | if __name__ == '__main__': |
|
654 | if __name__ == '__main__': | |
647 |
|
655 | |||
648 | readObj = DigitalRFReader() |
|
656 | readObj = DigitalRFReader() | |
649 |
|
657 | |||
650 | while True: |
|
658 | while True: | |
651 | readObj.run(path='/home/jchavez/jicamarca/mocked_data/') |
|
659 | readObj.run(path='/home/jchavez/jicamarca/mocked_data/') | |
652 |
|
|
660 | # readObj.printInfo() | |
653 | #readObj.printNumberOfBlock() |
|
661 | # readObj.printNumberOfBlock() |
@@ -1,1 +1,1 | |||||
1 | <Project description="Segundo Test" id="191" name="test01"><ReadUnit datatype="VoltageReader" id="1911" inputId="0" name="VoltageReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="VoltageReader" /><Parameter format="str" id="191112" name="path" value="/home/jchavez/jicamarca/jro_data/rawdata" /><Parameter format="date" id="191113" name="startDate" value="2010/10/28" /><Parameter format="date" id="191114" name="endDate" value="2017/10/28" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="online" value="0" /><Parameter format="int" id="191119" name="walk" value="0" /></Operation><Operation id="19112" name="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="VoltageProc" id="1912" inputId="1911" name="VoltageProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="DigitalRFWriter" priority="2" type="other"><Parameter format="str" id="191221" name="path" value="/home/jchavez/jicamarca/mocked_data/voltage" /></Operation></ProcUnit></Project> No newline at end of file |
|
1 | <Project description="Testing USRP data reader" id="191" name="test01"><ReadUnit datatype="DigitalRF" id="1911" inputId="0" name="DigitalRFReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="DigitalRF" /><Parameter format="str" id="191112" name="path" value="/home/jchavez/jicamarca/mocked_data" /><Parameter format="date" id="191113" name="startDate" value="2000/07/03" /><Parameter format="date" id="191114" name="endDate" value="2017/07/03" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="Voltage" id="1912" inputId="1911" name="VoltageProc"><Operation id="19121" name="run" priority="1" type="self" /></ProcUnit></Project> No newline at end of file |
@@ -1,118 +1,117 | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | ''' |
|
2 | ''' | |
3 | Created on Jul 7, 2014 |
|
3 | Created on Jul 7, 2014 | |
4 |
|
4 | |||
5 | @author: roj-idl71 |
|
5 | @author: roj-idl71 | |
6 | ''' |
|
6 | ''' | |
7 | import os, sys |
|
7 | import os, sys | |
8 |
|
8 | |||
9 | from schainpy.controller import Project |
|
9 | from schainpy.controller import Project | |
10 |
|
10 | |||
11 | def main(): |
|
11 | def main(): | |
12 |
|
12 | |||
13 | desc = "Testing USRP data reader" |
|
13 | desc = "Testing USRP data reader" | |
14 | filename = "schain.xml" |
|
14 | filename = "schain.xml" | |
15 | figpath = "./" |
|
15 | figpath = "./" | |
16 | remotefolder = "/home/wmaster/graficos" |
|
16 | remotefolder = "/home/wmaster/graficos" | |
17 |
|
17 | |||
18 | #this controller object save all user configuration and then execute each module |
|
18 | #this controller object save all user configuration and then execute each module | |
19 | #with their parameters. |
|
19 | #with their parameters. | |
20 | controllerObj = Project() |
|
20 | controllerObj = Project() | |
21 |
|
21 | |||
22 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
22 | controllerObj.setup(id = '191', name='test01', description=desc) | |
23 |
|
23 | |||
24 | #Creating a reader object with its parameters |
|
24 | #Creating a reader object with its parameters | |
25 | #schainpy.model.io.jroIO_usrp.USRPReader.setup() |
|
25 | #schainpy.model.io.jroIO_usrp.USRPReader.setup() | |
26 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRF', |
|
26 | readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRF', | |
27 | path='/home/jchavez/jicamarca/mocked_data/', |
|
27 | path='/home/jchavez/jicamarca/mocked_data/', | |
28 | startDate='2000/07/03', |
|
28 | startDate='2000/07/03', | |
29 | endDate='2017/07/03', |
|
29 | endDate='2017/07/03', | |
30 | startTime='00:00:00', |
|
30 | startTime='00:00:00', | |
31 | endTime='23:59:59', |
|
31 | endTime='23:59:59', | |
32 |
online=0 |
|
32 | online=0) | |
33 | ippKm = 60) |
|
|||
34 |
|
33 | |||
35 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', |
|
34 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', | |
36 | inputId=readUnitConfObj.getId()) |
|
35 | inputId=readUnitConfObj.getId()) | |
37 |
|
36 | |||
38 | # opObj10 = procUnitConfObj0.addOperation(name='selectHeights') |
|
37 | # opObj10 = procUnitConfObj0.addOperation(name='selectHeights') | |
39 | # opObj10.addParameter(name='minHei', value='0', format='float') |
|
38 | # opObj10.addParameter(name='minHei', value='0', format='float') | |
40 | # opObj10.addParameter(name='maxHei', value='8', format='float') |
|
39 | # opObj10.addParameter(name='maxHei', value='8', format='float') | |
41 |
|
40 | |||
42 | # opObj10 = procUnitConfObj0.addOperation(name='setH0') |
|
41 | # opObj10 = procUnitConfObj0.addOperation(name='setH0') | |
43 | # opObj10.addParameter(name='h0', value='5.4', format='float') |
|
42 | # opObj10.addParameter(name='h0', value='5.4', format='float') | |
44 |
|
43 | |||
45 | # opObj10 = procUnitConfObj0.addOperation(name='Decoder', optype='external') |
|
44 | # opObj10 = procUnitConfObj0.addOperation(name='Decoder', optype='external') | |
46 | # opObj10.addParameter(name='code', value='1,-1', format='intlist') |
|
45 | # opObj10.addParameter(name='code', value='1,-1', format='intlist') | |
47 | # opObj10.addParameter(name='nCode', value='2', format='float') |
|
46 | # opObj10.addParameter(name='nCode', value='2', format='float') | |
48 | # opObj10.addParameter(name='nBaud', value='1', format='float') |
|
47 | # opObj10.addParameter(name='nBaud', value='1', format='float') | |
49 |
|
48 | |||
50 | opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external') |
|
49 | # opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external') | |
51 | opObj10.addParameter(name='n', value='1', format='float') |
|
50 | # opObj10.addParameter(name='n', value='1', format='float') | |
52 |
|
51 | |||
53 | opObj11 = procUnitConfObj0.addOperation(name='Scope', optype='external') |
|
52 | # opObj11 = procUnitConfObj0.addOperation(name='Scope', optype='external') | |
54 | opObj11.addParameter(name='id', value='121', format='int') |
|
53 | # opObj11.addParameter(name='id', value='121', format='int') | |
55 | opObj11.addParameter(name='wintitle', value='Scope', format='str') |
|
54 | # opObj11.addParameter(name='wintitle', value='Scope', format='str') | |
56 |
|
55 | |||
57 | # procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', |
|
56 | # procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', | |
58 | # inputId=procUnitConfObj0.getId()) |
|
57 | # inputId=procUnitConfObj0.getId()) | |
59 |
|
58 | |||
60 | # #Creating a processing object with its parameters |
|
59 | # #Creating a processing object with its parameters | |
61 | # #schainpy.model.proc.jroproc_spectra.SpectraProc.run() |
|
60 | # #schainpy.model.proc.jroproc_spectra.SpectraProc.run() | |
62 | # #If you need to add more parameters can use the "addParameter method" |
|
61 | # #If you need to add more parameters can use the "addParameter method" | |
63 | # procUnitConfObj1.addParameter(name='nFFTPoints', value='8', format='int') |
|
62 | # procUnitConfObj1.addParameter(name='nFFTPoints', value='8', format='int') | |
64 | # procUnitConfObj1.addParameter(name='pairsList', value='(0,1)', format='pairslist') |
|
63 | # procUnitConfObj1.addParameter(name='pairsList', value='(0,1)', format='pairslist') | |
65 |
|
64 | |||
66 | # opObj10 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') |
|
65 | # opObj10 = procUnitConfObj1.addOperation(name='IncohInt', optype='external') | |
67 | # opObj10.addParameter(name='n', value='2', format='float') |
|
66 | # opObj10.addParameter(name='n', value='2', format='float') | |
68 | # |
|
67 | # | |
69 | #Using internal methods |
|
68 | #Using internal methods | |
70 | #schainpy.model.proc.jroproc_spectra.SpectraProc.selectChannels() |
|
69 | #schainpy.model.proc.jroproc_spectra.SpectraProc.selectChannels() | |
71 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') |
|
70 | # opObj10 = procUnitConfObj1.addOperation(name='selectChannels') | |
72 | # opObj10.addParameter(name='channelList', value='0,1', format='intlist') |
|
71 | # opObj10.addParameter(name='channelList', value='0,1', format='intlist') | |
73 |
|
72 | |||
74 | #Using internal methods |
|
73 | #Using internal methods | |
75 | #schainpy.model.proc.jroproc_spectra.SpectraProc.selectHeights() |
|
74 | #schainpy.model.proc.jroproc_spectra.SpectraProc.selectHeights() | |
76 | # opObj10 = procUnitConfObj1.addOperation(name='selectHeights') |
|
75 | # opObj10 = procUnitConfObj1.addOperation(name='selectHeights') | |
77 | # opObj10.addParameter(name='minHei', value='90', format='float') |
|
76 | # opObj10.addParameter(name='minHei', value='90', format='float') | |
78 | # opObj10.addParameter(name='maxHei', value='180', format='float') |
|
77 | # opObj10.addParameter(name='maxHei', value='180', format='float') | |
79 |
|
78 | |||
80 | #Using external methods (new modules) |
|
79 | #Using external methods (new modules) | |
81 | # #schainpy.model.proc.jroproc_spectra.IncohInt.setup() |
|
80 | # #schainpy.model.proc.jroproc_spectra.IncohInt.setup() | |
82 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') |
|
81 | # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
83 | # opObj12.addParameter(name='n', value='1', format='int') |
|
82 | # opObj12.addParameter(name='n', value='1', format='int') | |
84 |
|
83 | |||
85 | #Using external methods (new modules) |
|
84 | #Using external methods (new modules) | |
86 | #schainpy.model.graphics.jroplot_spectra.SpectraPlot.setup() |
|
85 | #schainpy.model.graphics.jroplot_spectra.SpectraPlot.setup() | |
87 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
86 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
88 | # opObj11.addParameter(name='id', value='11', format='int') |
|
87 | # opObj11.addParameter(name='id', value='11', format='int') | |
89 | # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') |
|
88 | # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') | |
90 | # opObj11.addParameter(name='zmin', value='0', format='int') |
|
89 | # opObj11.addParameter(name='zmin', value='0', format='int') | |
91 | # opObj11.addParameter(name='zmax', value='90', format='int') |
|
90 | # opObj11.addParameter(name='zmax', value='90', format='int') | |
92 | # opObj11.addParameter(name='save', value='1', format='int') |
|
91 | # opObj11.addParameter(name='save', value='1', format='int') | |
93 | # opObj11.addParameter(name='xmin', value='-20', format='float') |
|
92 | # opObj11.addParameter(name='xmin', value='-20', format='float') | |
94 | # opObj11.addParameter(name='xmax', value='20', format='float') |
|
93 | # opObj11.addParameter(name='xmax', value='20', format='float') | |
95 |
|
94 | |||
96 | #Using external methods (new modules) |
|
95 | #Using external methods (new modules) | |
97 | #schainpy.model.graphics.jroplot_spectra.RTIPlot.setup() |
|
96 | #schainpy.model.graphics.jroplot_spectra.RTIPlot.setup() | |
98 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') |
|
97 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |
99 | # opObj11.addParameter(name='id', value='30', format='int') |
|
98 | # opObj11.addParameter(name='id', value='30', format='int') | |
100 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') |
|
99 | # opObj11.addParameter(name='wintitle', value='RTI', format='str') | |
101 | # # opObj11.addParameter(name='zmin', value='0', format='int') |
|
100 | # # opObj11.addParameter(name='zmin', value='0', format='int') | |
102 | # # opObj11.addParameter(name='zmax', value='90', format='int') |
|
101 | # # opObj11.addParameter(name='zmax', value='90', format='int') | |
103 | # opObj11.addParameter(name='showprofile', value='1', format='int') |
|
102 | # opObj11.addParameter(name='showprofile', value='1', format='int') | |
104 | # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int') |
|
103 | # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int') | |
105 | # opObj11.addParameter(name='xmin', value='19.5', format='float') |
|
104 | # opObj11.addParameter(name='xmin', value='19.5', format='float') | |
106 | # opObj11.addParameter(name='xmax', value='20', format='float') |
|
105 | # opObj11.addParameter(name='xmax', value='20', format='float') | |
107 |
|
106 | |||
108 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other') |
|
107 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other') | |
109 | # opObj11.addParameter(name='id', value='3', format='int') |
|
108 | # opObj11.addParameter(name='id', value='3', format='int') | |
110 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') |
|
109 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') | |
111 | # opObj11.addParameter(name='zmin', value='30', format='int') |
|
110 | # opObj11.addParameter(name='zmin', value='30', format='int') | |
112 | # opObj11.addParameter(name='zmax', value='120', format='int') |
|
111 | # opObj11.addParameter(name='zmax', value='120', format='int') | |
113 | # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairslist') |
|
112 | # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairslist') | |
114 |
|
113 | |||
115 | controllerObj.start() |
|
114 | controllerObj.start() | |
116 |
|
115 | |||
117 | if __name__ == '__main__': |
|
116 | if __name__ == '__main__': | |
118 | main() |
|
117 | main() |
General Comments 0
You need to be logged in to leave comments.
Login now