@@ -0,0 +1,17 | |||||
|
1 | ''' | |||
|
2 | Created on Feb 7, 2012 | |||
|
3 | ||||
|
4 | @author: roj-idl71 | |||
|
5 | ''' | |||
|
6 | ||||
|
7 | class Correlation(Data): | |||
|
8 | ''' | |||
|
9 | classdocs | |||
|
10 | ''' | |||
|
11 | ||||
|
12 | ||||
|
13 | def __init__(self): | |||
|
14 | ''' | |||
|
15 | Constructor | |||
|
16 | ''' | |||
|
17 | pass No newline at end of file |
@@ -0,0 +1,18 | |||||
|
1 | ''' | |||
|
2 | Created on Feb 7, 2012 | |||
|
3 | ||||
|
4 | @author: roj-idl71 | |||
|
5 | ''' | |||
|
6 | ||||
|
7 | class Data: | |||
|
8 | ''' | |||
|
9 | classdocs | |||
|
10 | ''' | |||
|
11 | ||||
|
12 | ||||
|
13 | def __init__(self): | |||
|
14 | ''' | |||
|
15 | Constructor | |||
|
16 | ''' | |||
|
17 | pass | |||
|
18 | No newline at end of file |
@@ -0,0 +1,18 | |||||
|
1 | ''' | |||
|
2 | Created on Feb 7, 2012 | |||
|
3 | ||||
|
4 | @author: roj-idl71 | |||
|
5 | ''' | |||
|
6 | ||||
|
7 | class Noise: | |||
|
8 | ''' | |||
|
9 | classdocs | |||
|
10 | ''' | |||
|
11 | ||||
|
12 | ||||
|
13 | def __init__(self): | |||
|
14 | ''' | |||
|
15 | Constructor | |||
|
16 | ''' | |||
|
17 | pass | |||
|
18 | No newline at end of file |
@@ -0,0 +1,18 | |||||
|
1 | ''' | |||
|
2 | Created on Feb 7, 2012 | |||
|
3 | ||||
|
4 | @author: roj-idl71 | |||
|
5 | ''' | |||
|
6 | ||||
|
7 | class Spectra(Data): | |||
|
8 | ''' | |||
|
9 | classdocs | |||
|
10 | ''' | |||
|
11 | ||||
|
12 | ||||
|
13 | def __init__(self): | |||
|
14 | ''' | |||
|
15 | Constructor | |||
|
16 | ''' | |||
|
17 | pass | |||
|
18 | No newline at end of file |
@@ -0,0 +1,18 | |||||
|
1 | ''' | |||
|
2 | Created on Feb 7, 2012 | |||
|
3 | ||||
|
4 | @author: roj-idl71 | |||
|
5 | ''' | |||
|
6 | ||||
|
7 | class Voltage(Data): | |||
|
8 | ''' | |||
|
9 | classdocs | |||
|
10 | ''' | |||
|
11 | ||||
|
12 | ||||
|
13 | def __init__(self): | |||
|
14 | ''' | |||
|
15 | Constructor | |||
|
16 | ''' | |||
|
17 | pass | |||
|
18 | No newline at end of file |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 |
@@ -0,0 +1,17 | |||||
|
1 | ''' | |||
|
2 | Created on Feb 7, 2012 | |||
|
3 | ||||
|
4 | @author: roj-idl71 | |||
|
5 | ''' | |||
|
6 | ||||
|
7 | class CorrelationProcessor(): | |||
|
8 | ''' | |||
|
9 | classdocs | |||
|
10 | ''' | |||
|
11 | ||||
|
12 | ||||
|
13 | def __init__(self): | |||
|
14 | ''' | |||
|
15 | Constructor | |||
|
16 | ''' | |||
|
17 | pass No newline at end of file |
@@ -0,0 +1,17 | |||||
|
1 | ''' | |||
|
2 | Created on Feb 7, 2012 | |||
|
3 | ||||
|
4 | @author: roj-idl71 | |||
|
5 | ''' | |||
|
6 | ||||
|
7 | class SpectraProcessor(): | |||
|
8 | ''' | |||
|
9 | classdocs | |||
|
10 | ''' | |||
|
11 | ||||
|
12 | ||||
|
13 | def __init__(self): | |||
|
14 | ''' | |||
|
15 | Constructor | |||
|
16 | ''' | |||
|
17 | pass No newline at end of file |
@@ -0,0 +1,17 | |||||
|
1 | ''' | |||
|
2 | Created on Feb 7, 2012 | |||
|
3 | ||||
|
4 | @author: roj-idl71 | |||
|
5 | ''' | |||
|
6 | ||||
|
7 | class VoltageProcessor(): | |||
|
8 | ''' | |||
|
9 | classdocs | |||
|
10 | ''' | |||
|
11 | ||||
|
12 | ||||
|
13 | def __init__(self): | |||
|
14 | ''' | |||
|
15 | Constructor | |||
|
16 | ''' | |||
|
17 | pass No newline at end of file |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 |
@@ -0,0 +1,18 | |||||
|
1 | ''' | |||
|
2 | Created on Feb 7, 2012 | |||
|
3 | ||||
|
4 | @author: roj-idl71 | |||
|
5 | ''' | |||
|
6 | ||||
|
7 | class FtpServer(): | |||
|
8 | ''' | |||
|
9 | classdocs | |||
|
10 | ''' | |||
|
11 | ||||
|
12 | ||||
|
13 | def __init__(self): | |||
|
14 | ''' | |||
|
15 | Constructor | |||
|
16 | ''' | |||
|
17 | pass | |||
|
18 | No newline at end of file |
@@ -0,0 +1,17 | |||||
|
1 | ''' | |||
|
2 | Created on Feb 7, 2012 | |||
|
3 | ||||
|
4 | @author: roj-idl71 | |||
|
5 | ''' | |||
|
6 | ||||
|
7 | class FtpServerList(): | |||
|
8 | ''' | |||
|
9 | classdocs | |||
|
10 | ''' | |||
|
11 | ||||
|
12 | ||||
|
13 | def __init__(self): | |||
|
14 | ''' | |||
|
15 | Constructor | |||
|
16 | ''' | |||
|
17 | pass No newline at end of file |
1 | NO CONTENT: new file 100644 |
|
NO CONTENT: new file 100644 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -1,237 +1,245 | |||||
1 | import numpy |
|
1 | import numpy | |
2 |
|
2 | |||
3 | class PROCFLAG: |
|
3 | class PROCFLAG: | |
4 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
|
4 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) | |
5 | DECODE_DATA = numpy.uint32(0x00000002) |
|
5 | DECODE_DATA = numpy.uint32(0x00000002) | |
6 | SPECTRA_CALC = numpy.uint32(0x00000004) |
|
6 | SPECTRA_CALC = numpy.uint32(0x00000004) | |
7 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) |
|
7 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) | |
8 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) |
|
8 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) | |
9 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) |
|
9 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) | |
10 |
|
10 | |||
11 | DATATYPE_CHAR = numpy.uint32(0x00000040) |
|
11 | DATATYPE_CHAR = numpy.uint32(0x00000040) | |
12 | DATATYPE_SHORT = numpy.uint32(0x00000080) |
|
12 | DATATYPE_SHORT = numpy.uint32(0x00000080) | |
13 | DATATYPE_LONG = numpy.uint32(0x00000100) |
|
13 | DATATYPE_LONG = numpy.uint32(0x00000100) | |
14 | DATATYPE_INT64 = numpy.uint32(0x00000200) |
|
14 | DATATYPE_INT64 = numpy.uint32(0x00000200) | |
15 | DATATYPE_FLOAT = numpy.uint32(0x00000400) |
|
15 | DATATYPE_FLOAT = numpy.uint32(0x00000400) | |
16 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) |
|
16 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) | |
17 |
|
17 | |||
18 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) |
|
18 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) | |
19 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) |
|
19 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) | |
20 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) |
|
20 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) | |
21 |
|
21 | |||
22 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) |
|
22 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) | |
23 | DEFLIP_DATA = numpy.uint32(0x00010000) |
|
23 | DEFLIP_DATA = numpy.uint32(0x00010000) | |
24 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) |
|
24 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) | |
25 |
|
25 | |||
26 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) |
|
26 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) | |
27 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) |
|
27 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) | |
28 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) |
|
28 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) | |
29 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) |
|
29 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) | |
30 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) |
|
30 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) | |
31 |
|
31 | |||
32 | EXP_NAME_ESP = numpy.uint32(0x00200000) |
|
32 | EXP_NAME_ESP = numpy.uint32(0x00200000) | |
33 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) |
|
33 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) | |
34 |
|
34 | |||
35 | OPERATION_MASK = numpy.uint32(0x0000003F) |
|
35 | OPERATION_MASK = numpy.uint32(0x0000003F) | |
36 | DATATYPE_MASK = numpy.uint32(0x00000FC0) |
|
36 | DATATYPE_MASK = numpy.uint32(0x00000FC0) | |
37 | DATAARRANGE_MASK = numpy.uint32(0x00007000) |
|
37 | DATAARRANGE_MASK = numpy.uint32(0x00007000) | |
38 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) |
|
38 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) | |
39 |
|
39 | |||
40 | class BasicHeader: |
|
40 | class BasicHeader: | |
41 |
|
41 | |||
42 | size = 0 |
|
42 | size = 0 | |
43 | version = 0 |
|
43 | version = 0 | |
44 | dataBlock = 0 |
|
44 | dataBlock = 0 | |
45 | utc = 0 |
|
45 | utc = 0 | |
46 | miliSecond = 0 |
|
46 | miliSecond = 0 | |
47 | timeZone = 0 |
|
47 | timeZone = 0 | |
48 | dstFlag = 0 |
|
48 | dstFlag = 0 | |
49 | errorCount = 0 |
|
49 | errorCount = 0 | |
50 | struct = numpy.dtype([ |
|
50 | struct = numpy.dtype([ | |
51 | ('nSize','<u4'), |
|
51 | ('nSize','<u4'), | |
52 | ('nVersion','<u2'), |
|
52 | ('nVersion','<u2'), | |
53 | ('nDataBlockId','<u4'), |
|
53 | ('nDataBlockId','<u4'), | |
54 | ('nUtime','<u4'), |
|
54 | ('nUtime','<u4'), | |
55 | ('nMilsec','<u2'), |
|
55 | ('nMilsec','<u2'), | |
56 | ('nTimezone','<i2'), |
|
56 | ('nTimezone','<i2'), | |
57 | ('nDstflag','<i2'), |
|
57 | ('nDstflag','<i2'), | |
58 | ('nErrorCount','<u4') |
|
58 | ('nErrorCount','<u4') | |
59 | ]) |
|
59 | ]) | |
60 |
|
60 | |||
61 | def __init__(self): |
|
61 | def __init__(self): | |
62 | pass |
|
62 | pass | |
63 |
|
63 | |||
64 | def read(self, fp): |
|
64 | def read(self, fp): | |
65 |
|
65 | |||
66 | header = numpy.fromfile(fp, self.struct,1) |
|
66 | header = numpy.fromfile(fp, self.struct,1) | |
67 | self.size = header['nSize'][0] |
|
67 | self.size = header['nSize'][0] | |
68 | self.version = header['nVersion'][0] |
|
68 | self.version = header['nVersion'][0] | |
69 | self.dataBlock = header['nDataBlockId'][0] |
|
69 | self.dataBlock = header['nDataBlockId'][0] | |
70 | self.utc = header['nUtime'][0] |
|
70 | self.utc = header['nUtime'][0] | |
71 | self.miliSecond = header['nMilsec'][0] |
|
71 | self.miliSecond = header['nMilsec'][0] | |
72 | self.timeZone = header['nTimezone'][0] |
|
72 | self.timeZone = header['nTimezone'][0] | |
73 | self.dstFlag = header['nDstflag'][0] |
|
73 | self.dstFlag = header['nDstflag'][0] | |
74 | self.errorCount = header['nErrorCount'][0] |
|
74 | self.errorCount = header['nErrorCount'][0] | |
75 |
|
75 | |||
76 | return 1 |
|
76 | return 1 | |
77 |
|
77 | |||
|
78 | def copy(self): | |||
|
79 | ||||
|
80 | obj = BasicHeader() | |||
|
81 | obj.size = self.size | |||
|
82 | ||||
|
83 | ||||
|
84 | return obj | |||
|
85 | ||||
78 | class SystemHeader: |
|
86 | class SystemHeader: | |
79 | size = 0 |
|
87 | size = 0 | |
80 | numSamples = 0 |
|
88 | numSamples = 0 | |
81 | numProfiles = 0 |
|
89 | numProfiles = 0 | |
82 | numChannels = 0 |
|
90 | numChannels = 0 | |
83 | adcResolution = 0 |
|
91 | adcResolution = 0 | |
84 | pciDioBusWidth = 0 |
|
92 | pciDioBusWidth = 0 | |
85 | struct = numpy.dtype([ |
|
93 | struct = numpy.dtype([ | |
86 | ('nSize','<u4'), |
|
94 | ('nSize','<u4'), | |
87 | ('nNumSamples','<u4'), |
|
95 | ('nNumSamples','<u4'), | |
88 | ('nNumProfiles','<u4'), |
|
96 | ('nNumProfiles','<u4'), | |
89 | ('nNumChannels','<u4'), |
|
97 | ('nNumChannels','<u4'), | |
90 | ('nADCResolution','<u4'), |
|
98 | ('nADCResolution','<u4'), | |
91 | ('nPCDIOBusWidth','<u4'), |
|
99 | ('nPCDIOBusWidth','<u4'), | |
92 | ]) |
|
100 | ]) | |
93 |
|
101 | |||
94 | def __init__(self): |
|
102 | def __init__(self): | |
95 | pass |
|
103 | pass | |
96 |
|
104 | |||
97 | def read(self, fp): |
|
105 | def read(self, fp): | |
98 | header = numpy.fromfile(fp,self.struct,1) |
|
106 | header = numpy.fromfile(fp,self.struct,1) | |
99 | self.size = header['nSize'][0] |
|
107 | self.size = header['nSize'][0] | |
100 | self.numSamples = header['nNumSamples'][0] |
|
108 | self.numSamples = header['nNumSamples'][0] | |
101 | self.numProfiles = header['nNumProfiles'][0] |
|
109 | self.numProfiles = header['nNumProfiles'][0] | |
102 | self.numChannels = header['nNumChannels'][0] |
|
110 | self.numChannels = header['nNumChannels'][0] | |
103 | self.adcResolution = header['nADCResolution'][0] |
|
111 | self.adcResolution = header['nADCResolution'][0] | |
104 | self.pciDioBusWidth = header['nPCDIOBusWidth'][0] |
|
112 | self.pciDioBusWidth = header['nPCDIOBusWidth'][0] | |
105 |
|
113 | |||
106 |
|
114 | |||
107 | return 1 |
|
115 | return 1 | |
108 |
|
116 | |||
109 | class RadarControllerHeader: |
|
117 | class RadarControllerHeader: | |
110 | size = 0 |
|
118 | size = 0 | |
111 | expType = 0 |
|
119 | expType = 0 | |
112 | nTx = 0 |
|
120 | nTx = 0 | |
113 | ipp = 0 |
|
121 | ipp = 0 | |
114 | txA = 0 |
|
122 | txA = 0 | |
115 | txB = 0 |
|
123 | txB = 0 | |
116 | numWindows = 0 |
|
124 | numWindows = 0 | |
117 | numTaus = 0 |
|
125 | numTaus = 0 | |
118 | codeType = 0 |
|
126 | codeType = 0 | |
119 | line6Function = 0 |
|
127 | line6Function = 0 | |
120 | line5Fuction = 0 |
|
128 | line5Fuction = 0 | |
121 | fClock = 0 |
|
129 | fClock = 0 | |
122 | prePulseBefore = 0 |
|
130 | prePulseBefore = 0 | |
123 | prePulserAfter = 0 |
|
131 | prePulserAfter = 0 | |
124 | rangeIpp = 0 |
|
132 | rangeIpp = 0 | |
125 | rangeTxA = 0 |
|
133 | rangeTxA = 0 | |
126 | rangeTxB = 0 |
|
134 | rangeTxB = 0 | |
127 | struct = numpy.dtype([ |
|
135 | struct = numpy.dtype([ | |
128 | ('nSize','<u4'), |
|
136 | ('nSize','<u4'), | |
129 | ('nExpType','<u4'), |
|
137 | ('nExpType','<u4'), | |
130 | ('nNTx','<u4'), |
|
138 | ('nNTx','<u4'), | |
131 | ('fIpp','<f4'), |
|
139 | ('fIpp','<f4'), | |
132 | ('fTxA','<f4'), |
|
140 | ('fTxA','<f4'), | |
133 | ('fTxB','<f4'), |
|
141 | ('fTxB','<f4'), | |
134 | ('nNumWindows','<u4'), |
|
142 | ('nNumWindows','<u4'), | |
135 | ('nNumTaus','<u4'), |
|
143 | ('nNumTaus','<u4'), | |
136 | ('nCodeType','<u4'), |
|
144 | ('nCodeType','<u4'), | |
137 | ('nLine6Function','<u4'), |
|
145 | ('nLine6Function','<u4'), | |
138 | ('nLine5Function','<u4'), |
|
146 | ('nLine5Function','<u4'), | |
139 | ('fClock','<f4'), |
|
147 | ('fClock','<f4'), | |
140 | ('nPrePulseBefore','<u4'), |
|
148 | ('nPrePulseBefore','<u4'), | |
141 | ('nPrePulseAfter','<u4'), |
|
149 | ('nPrePulseAfter','<u4'), | |
142 | ('sRangeIPP','<a20'), |
|
150 | ('sRangeIPP','<a20'), | |
143 | ('sRangeTxA','<a20'), |
|
151 | ('sRangeTxA','<a20'), | |
144 | ('sRangeTxB','<a20'), |
|
152 | ('sRangeTxB','<a20'), | |
145 | ]) |
|
153 | ]) | |
146 |
|
154 | |||
147 |
|
155 | |||
148 | def __init__(self): |
|
156 | def __init__(self): | |
149 | pass |
|
157 | pass | |
150 |
|
158 | |||
151 | def read(self, fp): |
|
159 | def read(self, fp): | |
152 | header = numpy.fromfile(fp,self.struct,1) |
|
160 | header = numpy.fromfile(fp,self.struct,1) | |
153 | self.size = header['nSize'][0] |
|
161 | self.size = header['nSize'][0] | |
154 | self.expType = header['nExpType'][0] |
|
162 | self.expType = header['nExpType'][0] | |
155 | self.nTx = header['nNTx'][0] |
|
163 | self.nTx = header['nNTx'][0] | |
156 | self.ipp = header['fIpp'][0] |
|
164 | self.ipp = header['fIpp'][0] | |
157 | self.txA = header['fTxA'][0] |
|
165 | self.txA = header['fTxA'][0] | |
158 | self.txB = header['fTxB'][0] |
|
166 | self.txB = header['fTxB'][0] | |
159 | self.numWindows = header['nNumWindows'][0] |
|
167 | self.numWindows = header['nNumWindows'][0] | |
160 | self.numTaus = header['nNumTaus'][0] |
|
168 | self.numTaus = header['nNumTaus'][0] | |
161 | self.codeType = header['nCodeType'][0] |
|
169 | self.codeType = header['nCodeType'][0] | |
162 | self.line6Function = header['nLine6Function'][0] |
|
170 | self.line6Function = header['nLine6Function'][0] | |
163 | self.line5Fuction = header['nLine5Function'][0] |
|
171 | self.line5Fuction = header['nLine5Function'][0] | |
164 | self.fClock = header['fClock'][0] |
|
172 | self.fClock = header['fClock'][0] | |
165 | self.prePulseBefore = header['nPrePulseBefore'][0] |
|
173 | self.prePulseBefore = header['nPrePulseBefore'][0] | |
166 | self.prePulserAfter = header['nPrePulseAfter'][0] |
|
174 | self.prePulserAfter = header['nPrePulseAfter'][0] | |
167 | self.rangeIpp = header['sRangeIPP'][0] |
|
175 | self.rangeIpp = header['sRangeIPP'][0] | |
168 | self.rangeTxA = header['sRangeTxA'][0] |
|
176 | self.rangeTxA = header['sRangeTxA'][0] | |
169 | self.rangeTxB = header['sRangeTxB'][0] |
|
177 | self.rangeTxB = header['sRangeTxB'][0] | |
170 | # jump Dynamic Radar Controller Header |
|
178 | # jump Dynamic Radar Controller Header | |
171 | jumpHeader = self.size - 116 |
|
179 | jumpHeader = self.size - 116 | |
172 | fp.seek(fp.tell() + jumpHeader) |
|
180 | fp.seek(fp.tell() + jumpHeader) | |
173 |
|
181 | |||
174 | return 1 |
|
182 | return 1 | |
175 |
|
183 | |||
176 | class ProcessingHeader: |
|
184 | class ProcessingHeader: | |
177 | size = 0 |
|
185 | size = 0 | |
178 | dataType = 0 |
|
186 | dataType = 0 | |
179 | blockSize = 0 |
|
187 | blockSize = 0 | |
180 | profilesPerBlock = 0 |
|
188 | profilesPerBlock = 0 | |
181 | dataBlocksPerFile = 0 |
|
189 | dataBlocksPerFile = 0 | |
182 | numWindows = 0 |
|
190 | numWindows = 0 | |
183 | processFlags = 0 |
|
191 | processFlags = 0 | |
184 | coherentInt = 0 |
|
192 | coherentInt = 0 | |
185 | incoherentInt = 0 |
|
193 | incoherentInt = 0 | |
186 | totalSpectra = 0 |
|
194 | totalSpectra = 0 | |
187 | struct = numpy.dtype([ |
|
195 | struct = numpy.dtype([ | |
188 | ('nSize','<u4'), |
|
196 | ('nSize','<u4'), | |
189 | ('nDataType','<u4'), |
|
197 | ('nDataType','<u4'), | |
190 | ('nSizeOfDataBlock','<u4'), |
|
198 | ('nSizeOfDataBlock','<u4'), | |
191 | ('nProfilesperBlock','<u4'), |
|
199 | ('nProfilesperBlock','<u4'), | |
192 | ('nDataBlocksperFile','<u4'), |
|
200 | ('nDataBlocksperFile','<u4'), | |
193 | ('nNumWindows','<u4'), |
|
201 | ('nNumWindows','<u4'), | |
194 | ('nProcessFlags','<u4'), |
|
202 | ('nProcessFlags','<u4'), | |
195 | ('nCoherentIntegrations','<u4'), |
|
203 | ('nCoherentIntegrations','<u4'), | |
196 | ('nIncoherentIntegrations','<u4'), |
|
204 | ('nIncoherentIntegrations','<u4'), | |
197 | ('nTotalSpectra','<u4') |
|
205 | ('nTotalSpectra','<u4') | |
198 | ]) |
|
206 | ]) | |
199 | samplingWindow = 0 |
|
207 | samplingWindow = 0 | |
200 | structSamplingWindow = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) |
|
208 | structSamplingWindow = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) | |
201 | numHeights = 0 |
|
209 | numHeights = 0 | |
202 | firstHeight = 0 |
|
210 | firstHeight = 0 | |
203 | deltaHeight = 0 |
|
211 | deltaHeight = 0 | |
204 | samplesWin = 0 |
|
212 | samplesWin = 0 | |
205 | spectraComb = 0 |
|
213 | spectraComb = 0 | |
206 | numCode = 0 |
|
214 | numCode = 0 | |
207 | codes = 0 |
|
215 | codes = 0 | |
208 | numBaud = 0 |
|
216 | numBaud = 0 | |
209 |
|
217 | |||
210 | def __init__(self): |
|
218 | def __init__(self): | |
211 | pass |
|
219 | pass | |
212 |
|
220 | |||
213 | def read(self, fp): |
|
221 | def read(self, fp): | |
214 | header = numpy.fromfile(fp,self.struct,1) |
|
222 | header = numpy.fromfile(fp,self.struct,1) | |
215 | self.size = header['nSize'][0] |
|
223 | self.size = header['nSize'][0] | |
216 | self.dataType = header['nDataType'][0] |
|
224 | self.dataType = header['nDataType'][0] | |
217 | self.blockSize = header['nSizeOfDataBlock'][0] |
|
225 | self.blockSize = header['nSizeOfDataBlock'][0] | |
218 | self.profilesPerBlock = header['nProfilesperBlock'][0] |
|
226 | self.profilesPerBlock = header['nProfilesperBlock'][0] | |
219 | self.dataBlocksPerFile = header['nDataBlocksperFile'][0] |
|
227 | self.dataBlocksPerFile = header['nDataBlocksperFile'][0] | |
220 | self.numWindows = header['nNumWindows'][0] |
|
228 | self.numWindows = header['nNumWindows'][0] | |
221 | self.processFlags = header['nProcessFlags'] |
|
229 | self.processFlags = header['nProcessFlags'] | |
222 | self.coherentInt = header['nCoherentIntegrations'][0] |
|
230 | self.coherentInt = header['nCoherentIntegrations'][0] | |
223 | self.incoherentInt = header['nIncoherentIntegrations'][0] |
|
231 | self.incoherentInt = header['nIncoherentIntegrations'][0] | |
224 | self.totalSpectra = header['nTotalSpectra'][0] |
|
232 | self.totalSpectra = header['nTotalSpectra'][0] | |
225 | self.samplingWindow = numpy.fromfile(fp,self.structSamplingWindow,self.numWindows) |
|
233 | self.samplingWindow = numpy.fromfile(fp,self.structSamplingWindow,self.numWindows) | |
226 | self.numHeights = numpy.sum(self.samplingWindow['nsa']) |
|
234 | self.numHeights = numpy.sum(self.samplingWindow['nsa']) | |
227 | self.firstHeight = self.samplingWindow['h0'] |
|
235 | self.firstHeight = self.samplingWindow['h0'] | |
228 | self.deltaHeight = self.samplingWindow['dh'] |
|
236 | self.deltaHeight = self.samplingWindow['dh'] | |
229 | self.samplesWin = self.samplingWindow['nsa'] |
|
237 | self.samplesWin = self.samplingWindow['nsa'] | |
230 | self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra) |
|
238 | self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra) | |
231 | if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: |
|
239 | if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: | |
232 | self.numCode = numpy.fromfile(fp,'<u4',1) |
|
240 | self.numCode = numpy.fromfile(fp,'<u4',1) | |
233 | self.numBaud = numpy.fromfile(fp,'<u4',1) |
|
241 | self.numBaud = numpy.fromfile(fp,'<u4',1) | |
234 | self.codes = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode) |
|
242 | self.codes = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode) | |
235 |
|
243 | |||
236 |
|
244 | |||
237 | return 1 No newline at end of file |
|
245 | return 1 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -1,385 +1,414 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on 23/01/2012 |
|
2 | Created on 23/01/2012 | |
3 |
|
3 | |||
4 | @author: danielangelsuarezmunoz |
|
4 | @author: danielangelsuarezmunoz | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
|
7 | ||||
|
8 | import os, sys | |||
7 | import numpy |
|
9 | import numpy | |
8 | import os.path |
|
|||
9 | import glob |
|
10 | import glob | |
10 | import fnmatch |
|
11 | import fnmatch | |
11 | import time |
|
12 | import time | |
12 | import datetime |
|
13 | import datetime | |
13 |
|
14 | |||
14 | from Header import * |
|
15 | from Header import * | |
15 | from Data import DataReader |
|
16 | from Data import DataReader | |
16 | from Data import DataWriter |
|
17 | from Data import DataWriter | |
17 |
|
18 | |||
|
19 | path = os.path.split(os.getcwd())[0] | |||
|
20 | sys.path.append(os.path.join(path,"Model")) | |||
|
21 | ||||
|
22 | from Voltage import Voltage | |||
|
23 | ||||
18 | class VoltageReader(DataReader): |
|
24 | class VoltageReader(DataReader): | |
19 |
|
25 | |||
20 | __idFile = 0 |
|
26 | __idFile = 0 | |
21 |
|
27 | |||
22 | __fp = 0 |
|
28 | __fp = 0 | |
23 |
|
29 | |||
24 | __startDateTime = 0 |
|
30 | __startDateTime = 0 | |
25 |
|
31 | |||
26 | __endDateTime = 0 |
|
32 | __endDateTime = 0 | |
27 |
|
33 | |||
28 | __dataType = 0 |
|
34 | __dataType = 0 | |
29 |
|
35 | |||
30 | __sizeOfFileByHeader = 0 |
|
36 | __sizeOfFileByHeader = 0 | |
31 |
|
37 | |||
32 | __pathList = [] |
|
38 | __pathList = [] | |
33 |
|
39 | |||
34 | filenameList = [] |
|
40 | filenameList = [] | |
35 |
|
41 | |||
36 | __lastUTTime = 0 |
|
42 | __lastUTTime = 0 | |
37 |
|
43 | |||
38 | __maxTimeStep = 5 |
|
44 | __maxTimeStep = 5 | |
39 |
|
45 | |||
40 | flagResetProcessing = 0 |
|
46 | flagResetProcessing = 0 | |
41 |
|
47 | |||
42 | __flagIsNewFile = 0 |
|
48 | __flagIsNewFile = 0 | |
43 |
|
49 | |||
44 | noMoreFiles = 0 |
|
50 | noMoreFiles = 0 | |
45 |
|
51 | |||
46 | online = 0 |
|
52 | online = 0 | |
47 |
|
53 | |||
48 | filename = '' |
|
54 | filename = '' | |
49 |
|
55 | |||
50 | fileSize = 0 |
|
56 | fileSize = 0 | |
51 |
|
57 | |||
52 | firstHeaderSize = 0 |
|
58 | firstHeaderSize = 0 | |
53 |
|
59 | |||
54 | basicHeaderSize = 24 |
|
60 | basicHeaderSize = 24 | |
55 |
|
61 | |||
56 |
|
|
62 | m_BasicHeader = BasicHeader() | |
|
63 | ||||
|
64 | m_SystemHeader = SystemHeader() | |||
57 |
|
65 | |||
58 | systemHeaderObj = SystemHeader() |
|
66 | m_RadarControllerHeader = RadarControllerHeader() | |
59 |
|
67 | |||
60 | radarControllerHeaderObj = RadarControllerHeader() |
|
68 | m_ProcessingHeader = ProcessingHeader() | |
61 |
|
69 | |||
62 | processingHeaderObj = ProcessingHeader() |
|
70 | m_Voltage = None | |
63 |
|
71 | |||
64 | __buffer = 0 |
|
72 | __buffer = 0 | |
65 |
|
73 | |||
66 | __buffer_id = 9999 |
|
74 | __buffer_id = 9999 | |
67 | #m_Voltage= Voltage() |
|
|||
68 |
|
75 | |||
|
76 | def __init__(self, m_Voltage): | |||
69 |
|
77 | |||
70 | def __init__(self): |
|
78 | self.m_Voltage = m_Voltage | |
71 | pass |
|
|||
72 |
|
79 | |||
73 | def __rdSystemHeader(self,fp=None): |
|
80 | def __rdSystemHeader(self,fp=None): | |
74 | if fp == None: |
|
81 | if fp == None: | |
75 | fp = self.__fp |
|
82 | fp = self.__fp | |
76 |
|
83 | |||
77 |
self. |
|
84 | self.m_SystemHeader.read(fp) | |
78 |
|
85 | |||
79 | def __rdRadarControllerHeader(self,fp=None): |
|
86 | def __rdRadarControllerHeader(self,fp=None): | |
80 | if fp == None: |
|
87 | if fp == None: | |
81 | fp = self.__fp |
|
88 | fp = self.__fp | |
82 |
|
89 | |||
83 |
self. |
|
90 | self.m_RadarControllerHeader.read(fp) | |
84 |
|
91 | |||
85 | def __rdProcessingHeader(self,fp=None): |
|
92 | def __rdProcessingHeader(self,fp=None): | |
86 | if fp == None: |
|
93 | if fp == None: | |
87 | fp = self.__fp |
|
94 | fp = self.__fp | |
88 |
|
95 | |||
89 |
self. |
|
96 | self.m_ProcessingHeader.read(fp) | |
90 |
|
97 | |||
91 | def __searchFiles(self,path, startDateTime, endDateTime, set=None, expLabel = "", ext = "*.r"): |
|
98 | def __searchFiles(self,path, startDateTime, endDateTime, set=None, expLabel = "", ext = "*.r"): | |
92 |
|
99 | |||
93 | startUtSeconds = time.mktime(startDateTime.timetuple()) |
|
100 | startUtSeconds = time.mktime(startDateTime.timetuple()) | |
94 | endUtSeconds = time.mktime(endDateTime.timetuple()) |
|
101 | endUtSeconds = time.mktime(endDateTime.timetuple()) | |
95 |
|
102 | |||
96 | startYear = startDateTime.timetuple().tm_year |
|
103 | startYear = startDateTime.timetuple().tm_year | |
97 | endYear = endDateTime.timetuple().tm_year |
|
104 | endYear = endDateTime.timetuple().tm_year | |
98 |
|
105 | |||
99 | startDoy = startDateTime.timetuple().tm_yday |
|
106 | startDoy = startDateTime.timetuple().tm_yday | |
100 | endDoy = endDateTime.timetuple().tm_yday |
|
107 | endDoy = endDateTime.timetuple().tm_yday | |
101 |
|
108 | |||
102 | rangeOfYears = range(startYear,endYear+1) |
|
109 | rangeOfYears = range(startYear,endYear+1) | |
103 |
|
110 | |||
104 | listOfListDoys = [] |
|
111 | listOfListDoys = [] | |
105 | if startYear == endYear: |
|
112 | if startYear == endYear: | |
106 | doyList = range(startDoy,endDoy+1) |
|
113 | doyList = range(startDoy,endDoy+1) | |
107 | else: |
|
114 | else: | |
108 | for year in rangeOfYears: |
|
115 | for year in rangeOfYears: | |
109 | if (year == startYear): |
|
116 | if (year == startYear): | |
110 | listOfListDoys.append(range(startDoy,365+1)) |
|
117 | listOfListDoys.append(range(startDoy,365+1)) | |
111 | elif (year == endYear): |
|
118 | elif (year == endYear): | |
112 | listOfListDoys.append(range(1,endDoy+1)) |
|
119 | listOfListDoys.append(range(1,endDoy+1)) | |
113 | else: |
|
120 | else: | |
114 | listOfListDoys.append(range(1,365+1)) |
|
121 | listOfListDoys.append(range(1,365+1)) | |
115 | doyList = [] |
|
122 | doyList = [] | |
116 | for list in listOfListDoys: |
|
123 | for list in listOfListDoys: | |
117 | doyList = doyList + list |
|
124 | doyList = doyList + list | |
118 |
|
125 | |||
119 | folders = [] |
|
126 | folders = [] | |
120 | for thisPath in os.listdir(path): |
|
127 | for thisPath in os.listdir(path): | |
121 | if os.path.isdir(os.path.join(path,thisPath)): |
|
128 | if os.path.isdir(os.path.join(path,thisPath)): | |
122 | #folders.append(os.path.join(path,thisPath)) |
|
129 | #folders.append(os.path.join(path,thisPath)) | |
123 | folders.append(thisPath) |
|
130 | folders.append(thisPath) | |
124 |
|
131 | |||
125 | pathList = [] |
|
132 | pathList = [] | |
126 | dicOfPath = {} |
|
133 | dicOfPath = {} | |
127 | for year in rangeOfYears: |
|
134 | for year in rangeOfYears: | |
128 | for doy in doyList: |
|
135 | for doy in doyList: | |
129 | tmp = fnmatch.filter(folders, 'D' + '%4.4d%3.3d' % (year,doy)) |
|
136 | tmp = fnmatch.filter(folders, 'D' + '%4.4d%3.3d' % (year,doy)) | |
130 | if len(tmp) == 0: |
|
137 | if len(tmp) == 0: | |
131 | continue |
|
138 | continue | |
132 | if expLabel == '': |
|
139 | if expLabel == '': | |
133 | pathList.append(os.path.join(path,tmp[0])) |
|
140 | pathList.append(os.path.join(path,tmp[0])) | |
134 | dicOfPath.setdefault(os.path.join(path,tmp[0])) |
|
141 | dicOfPath.setdefault(os.path.join(path,tmp[0])) | |
135 | dicOfPath[os.path.join(path,tmp[0])] = [] |
|
142 | dicOfPath[os.path.join(path,tmp[0])] = [] | |
136 | else: |
|
143 | else: | |
137 | pathList.append(os.path.join(path,os.path.join(tmp[0],expLabel))) |
|
144 | pathList.append(os.path.join(path,os.path.join(tmp[0],expLabel))) | |
138 | dicOfPath.setdefault(os.path.join(path,os.path.join(tmp[0],expLabel))) |
|
145 | dicOfPath.setdefault(os.path.join(path,os.path.join(tmp[0],expLabel))) | |
139 | dicOfPath[os.path.join(path,os.path.join(tmp[0],expLabel))] = [] |
|
146 | dicOfPath[os.path.join(path,os.path.join(tmp[0],expLabel))] = [] | |
140 |
|
147 | |||
141 |
|
148 | |||
142 | filenameList = [] |
|
149 | filenameList = [] | |
143 | for thisPath in pathList: |
|
150 | for thisPath in pathList: | |
144 | fileList = glob.glob1(thisPath, ext) |
|
151 | fileList = glob.glob1(thisPath, ext) | |
145 | #dicOfPath[thisPath].append(fileList) |
|
152 | #dicOfPath[thisPath].append(fileList) | |
146 | fileList.sort() |
|
153 | fileList.sort() | |
147 | for file in fileList: |
|
154 | for file in fileList: | |
148 | filename = os.path.join(thisPath,file) |
|
155 | filename = os.path.join(thisPath,file) | |
149 | if self.isThisFileinRange(filename, startUtSeconds, endUtSeconds): |
|
156 | if self.isThisFileinRange(filename, startUtSeconds, endUtSeconds): | |
150 | filenameList.append(filename) |
|
157 | filenameList.append(filename) | |
151 |
|
158 | |||
152 | self.filenameList = filenameList |
|
159 | self.filenameList = filenameList | |
153 |
|
160 | |||
154 | return pathList, filenameList |
|
161 | return pathList, filenameList | |
155 |
|
162 | |||
156 | def isThisFileinRange(self, filename, startUTSeconds=None, endUTSeconds=None): |
|
163 | def isThisFileinRange(self, filename, startUTSeconds=None, endUTSeconds=None): | |
157 |
|
164 | |||
158 | try: |
|
165 | try: | |
159 | fp = open(filename,'rb') |
|
166 | fp = open(filename,'rb') | |
160 | except: |
|
167 | except: | |
161 | raise IOError, "The file %s can't be opened" %(filename) |
|
168 | raise IOError, "The file %s can't be opened" %(filename) | |
162 |
|
169 | |||
163 | if startUTSeconds==None: |
|
170 | if startUTSeconds==None: | |
164 | startUTSeconds = self.startUTCSeconds |
|
171 | startUTSeconds = self.startUTCSeconds | |
165 |
|
172 | |||
166 | if endUTSeconds==None: |
|
173 | if endUTSeconds==None: | |
167 | endUTSeconds = self.endUTCSeconds |
|
174 | endUTSeconds = self.endUTCSeconds | |
168 |
|
175 | |||
169 |
|
|
176 | m_BasicHeader = BasicHeader() | |
170 |
|
177 | |||
171 |
if not( |
|
178 | if not(m_BasicHeader.read(fp)): | |
172 | return 0 |
|
179 | return 0 | |
173 |
|
180 | |||
174 | fp.close() |
|
181 | fp.close() | |
175 |
|
182 | |||
176 |
if not ((startUTSeconds <= |
|
183 | if not ((startUTSeconds <= m_BasicHeader.utc) and (endUTSeconds >= m_BasicHeader.utc)): | |
177 | return 0 |
|
184 | return 0 | |
178 |
|
185 | |||
179 | return 1 |
|
186 | return 1 | |
180 |
|
187 | |||
181 | def __readBasicHeader(self, fp=None): |
|
188 | def __readBasicHeader(self, fp=None): | |
182 |
|
189 | |||
183 | if fp == None: |
|
190 | if fp == None: | |
184 | fp = self.__fp |
|
191 | fp = self.__fp | |
185 |
|
192 | |||
186 |
self. |
|
193 | self.m_BasicHeader.read(fp) | |
187 |
|
194 | |||
188 | def __readFirstHeader(self): |
|
195 | def __readFirstHeader(self): | |
189 |
|
196 | |||
190 | self.__readBasicHeader() |
|
197 | self.__readBasicHeader() | |
191 | self.__rdSystemHeader() |
|
198 | self.__rdSystemHeader() | |
192 | self.__rdRadarControllerHeader() |
|
199 | self.__rdRadarControllerHeader() | |
193 | self.__rdProcessingHeader() |
|
200 | self.__rdProcessingHeader() | |
194 |
self.firstHeaderSize = self. |
|
201 | self.firstHeaderSize = self.m_BasicHeader.size | |
195 |
|
202 | |||
196 |
data_type=int(numpy.log2((self. |
|
203 | data_type=int(numpy.log2((self.m_ProcessingHeader.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR)) | |
197 | if data_type == 0: |
|
204 | if data_type == 0: | |
198 | tmp=numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
205 | tmp=numpy.dtype([('real','<i1'),('imag','<i1')]) | |
199 | elif data_type == 1: |
|
206 | elif data_type == 1: | |
200 | tmp=numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
207 | tmp=numpy.dtype([('real','<i2'),('imag','<i2')]) | |
201 | elif data_type == 2: |
|
208 | elif data_type == 2: | |
202 | tmp=numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
209 | tmp=numpy.dtype([('real','<i4'),('imag','<i4')]) | |
203 | elif data_type == 3: |
|
210 | elif data_type == 3: | |
204 | tmp=numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
211 | tmp=numpy.dtype([('real','<i8'),('imag','<i8')]) | |
205 | elif data_type == 4: |
|
212 | elif data_type == 4: | |
206 | tmp=numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
213 | tmp=numpy.dtype([('real','<f4'),('imag','<f4')]) | |
207 | elif data_type == 5: |
|
214 | elif data_type == 5: | |
208 | tmp=numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
215 | tmp=numpy.dtype([('real','<f8'),('imag','<f8')]) | |
209 | else: |
|
216 | else: | |
210 | print 'no define data type' |
|
217 | print 'no define data type' | |
211 | tmp = 0 |
|
218 | tmp = 0 | |
212 |
|
219 | |||
213 | self.__dataType = tmp |
|
220 | self.__dataType = tmp | |
214 |
self.__sizeOfFileByHeader = self. |
|
221 | self.__sizeOfFileByHeader = self.m_ProcessingHeader.dataBlocksPerFile * self.m_ProcessingHeader.blockSize + self.firstHeaderSize + self.basicHeaderSize*(self.m_ProcessingHeader.dataBlocksPerFile - 1) | |
215 |
|
222 | |||
216 | def __setNextFileOnline(self): |
|
223 | def __setNextFileOnline(self): | |
217 | return 0 |
|
224 | return 0 | |
218 |
|
225 | |||
219 | def __setNextFileOffline(self): |
|
226 | def __setNextFileOffline(self): | |
220 |
|
227 | |||
221 | idFile = self.__idFile |
|
228 | idFile = self.__idFile | |
222 | while(True): |
|
229 | while(True): | |
223 |
|
230 | |||
224 | idFile += 1 |
|
231 | idFile += 1 | |
225 |
|
232 | |||
226 | if not(idFile < len(self.filenameList)): |
|
233 | if not(idFile < len(self.filenameList)): | |
227 | self.noMoreFiles = 1 |
|
234 | self.noMoreFiles = 1 | |
228 | return 0 |
|
235 | return 0 | |
229 |
|
236 | |||
230 | filename = self.filenameList[idFile] |
|
237 | filename = self.filenameList[idFile] | |
231 | fileSize = os.path.getsize(filename) |
|
238 | fileSize = os.path.getsize(filename) | |
232 | fp = open(filename,'rb') |
|
239 | fp = open(filename,'rb') | |
233 |
|
240 | |||
234 | currentSize = fileSize - fp.tell() |
|
241 | currentSize = fileSize - fp.tell() | |
235 |
neededSize = self. |
|
242 | neededSize = self.m_ProcessingHeader.blockSize + self.firstHeaderSize | |
236 |
|
243 | |||
237 | if (currentSize < neededSize): |
|
244 | if (currentSize < neededSize): | |
238 | continue |
|
245 | continue | |
239 |
|
246 | |||
240 | break |
|
247 | break | |
241 |
|
248 | |||
242 | self.__flagIsNewFile = 1 |
|
249 | self.__flagIsNewFile = 1 | |
243 | self.__idFile = idFile |
|
250 | self.__idFile = idFile | |
244 | self.filename = filename |
|
251 | self.filename = filename | |
245 | self.fileSize = fileSize |
|
252 | self.fileSize = fileSize | |
246 | self.__fp = fp |
|
253 | self.__fp = fp | |
247 |
|
254 | |||
248 | print 'Setting the file: %s'%self.filename |
|
255 | print 'Setting the file: %s'%self.filename | |
249 |
|
256 | |||
250 | return 1 |
|
257 | return 1 | |
251 |
|
258 | |||
252 | def __setNextFile(self): |
|
259 | def __setNextFile(self): | |
253 |
|
260 | |||
254 | if self.online: |
|
261 | if self.online: | |
255 | return self.__setNextFileOnline() |
|
262 | return self.__setNextFileOnline() | |
256 | else: |
|
263 | else: | |
257 | return self.__setNextFileOffline() |
|
264 | return self.__setNextFileOffline() | |
258 |
|
265 | |||
259 | def __setNewBlock(self): |
|
266 | def __setNewBlock(self): | |
260 |
|
267 | |||
261 | if self.__flagIsNewFile: |
|
268 | if self.__flagIsNewFile: | |
262 | return 1 |
|
269 | return 1 | |
263 |
|
270 | |||
264 | currentSize = self.fileSize - self.__fp.tell() |
|
271 | currentSize = self.fileSize - self.__fp.tell() | |
265 |
neededSize = self. |
|
272 | neededSize = self.m_ProcessingHeader.blockSize + self.basicHeaderSize | |
266 |
|
273 | |||
267 | # Bloque Completo |
|
274 | # Bloque Completo | |
268 | if (currentSize >= neededSize): |
|
275 | if (currentSize >= neededSize): | |
269 | self.__readBasicHeader() |
|
276 | self.__readBasicHeader() | |
270 | return 1 |
|
277 | return 1 | |
271 |
|
278 | |||
272 | if not(self.__setNextFile()): |
|
279 | if not(self.__setNextFile()): | |
273 | return 0 |
|
280 | return 0 | |
274 |
|
281 | |||
275 | self.__readFirstHeader() |
|
282 | self.__readFirstHeader() | |
276 |
|
283 | |||
277 |
deltaTime = self. |
|
284 | deltaTime = self.m_BasicHeader.utc - self.__lastUTTime # check this | |
278 |
|
285 | |||
279 | self.flagResetProcessing = 0 |
|
286 | self.flagResetProcessing = 0 | |
280 | if deltaTime > self.__maxTimeStep: |
|
287 | if deltaTime > self.__maxTimeStep: | |
281 | self.flagResetProcessing = 1 |
|
288 | self.flagResetProcessing = 1 | |
282 |
|
289 | |||
283 | return 1 |
|
290 | return 1 | |
284 |
|
291 | |||
285 | def __readBlock(self): |
|
292 | def __readBlock(self): | |
286 | """Lee el bloque de datos desde la posicion actual del puntero del archivo y |
|
293 | """Lee el bloque de datos desde la posicion actual del puntero del archivo y | |
287 | actualiza todos los parametros relacionados al bloque de datos (data, time, |
|
294 | actualiza todos los parametros relacionados al bloque de datos (data, time, | |
288 | etc). La data leida es almacenada en el buffer y el contador de datos leidos es |
|
295 | etc). La data leida es almacenada en el buffer y el contador de datos leidos es | |
289 | seteado a 0 |
|
296 | seteado a 0 | |
290 | """ |
|
297 | """ | |
291 |
|
298 | |||
292 |
pts2read = self. |
|
299 | pts2read = self.m_ProcessingHeader.profilesPerBlock*self.m_ProcessingHeader.numHeights*self.m_SystemHeader.numChannels | |
293 |
|
300 | |||
294 | data = numpy.fromfile(self.__fp,self.__dataType,pts2read) |
|
301 | data = numpy.fromfile(self.__fp,self.__dataType,pts2read) | |
295 |
|
302 | |||
296 |
data = data.reshape((self. |
|
303 | data = data.reshape((self.m_ProcessingHeader.profilesPerBlock, self.m_ProcessingHeader.numHeights, self.m_SystemHeader.numChannels)) | |
297 |
|
304 | |||
298 | self.__flagIsNewFile = 0 |
|
305 | self.__flagIsNewFile = 0 | |
299 |
|
306 | |||
300 | self.__buffer = data |
|
307 | self.__buffer = data | |
301 |
|
308 | |||
302 | self.__buffer_id = 0 |
|
309 | self.__buffer_id = 0 | |
303 |
|
310 | |||
304 | def readNextBlock(self): |
|
311 | def readNextBlock(self): | |
305 |
|
312 | |||
306 | if not(self.__setNewBlock()): |
|
313 | if not(self.__setNewBlock()): | |
307 | return 0 |
|
314 | return 0 | |
308 |
|
315 | |||
309 | self.__readBlock() |
|
316 | self.__readBlock() | |
310 |
|
317 | |||
311 |
self.__lastUTTime = self. |
|
318 | self.__lastUTTime = self.m_BasicHeader.utc | |
312 |
|
319 | |||
313 | return 1 |
|
320 | return 1 | |
314 |
|
321 | |||
315 | def __hasNotDataInBuffer(self): |
|
322 | def __hasNotDataInBuffer(self): | |
316 |
if self.__buffer_id >= self. |
|
323 | if self.__buffer_id >= self.m_ProcessingHeader.profilesPerBlock: | |
317 | return 1 |
|
324 | return 1 | |
318 |
|
325 | |||
319 | return 0 |
|
326 | return 0 | |
320 |
|
327 | |||
321 | def getData(self): |
|
328 | def getData(self): | |
322 | """Obtiene un unidad de datos del buffer de lectura y es copiada a la clase "Data" |
|
329 | """Obtiene un unidad de datos del buffer de lectura y es copiada a la clase "Data" | |
323 | con todos los parametros asociados a este. cuando no hay datos en el buffer de |
|
330 | con todos los parametros asociados a este. cuando no hay datos en el buffer de | |
324 | lectura es necesario hacer una nueva lectura de los bloques de datos |
|
331 | lectura es necesario hacer una nueva lectura de los bloques de datos | |
325 | "__readBlock" |
|
332 | "__readBlock" | |
326 | """ |
|
333 | """ | |
327 | self.flagResetProcessing = 0 |
|
334 | self.flagResetProcessing = 0 | |
328 |
|
335 | |||
329 | if self.__hasNotDataInBuffer(): |
|
336 | if self.__hasNotDataInBuffer(): | |
330 | self.readNextBlock() |
|
337 | self.readNextBlock() | |
331 |
|
338 | |||
332 | if self.noMoreFiles == 1: |
|
339 | if self.noMoreFiles == 1: | |
333 | print 'read finished' |
|
340 | print 'read finished' | |
334 | return None |
|
341 | return None | |
335 |
|
342 | |||
336 | data = self.__buffer[self.__buffer_id,:,:] |
|
343 | data = self.__buffer[self.__buffer_id,:,:] | |
337 | #time = timeblock + n*ipp |
|
344 | time = 111 | |
338 | #print self.__buffer_id |
|
345 | ||
|
346 | self.m_Voltage.data = data | |||
|
347 | self.m_Voltage.timeProfile = time | |||
|
348 | self.m_Voltage.m_BasicHeader = self.m_BasicHeader.copy() | |||
|
349 | self.m_Voltage.m_ProcessingHeader = self.m_ProcessingHeader.copy() | |||
|
350 | self.m_Voltage.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() | |||
|
351 | self.m_Voltage.m_SystemHeader = self.m_systemHeader.copy() | |||
339 |
|
352 | |||
340 | self.__buffer_id += 1 |
|
353 | self.__buffer_id += 1 | |
341 |
|
354 | |||
342 | #call setData - to Data Object |
|
355 | #call setData - to Data Object | |
343 |
|
356 | |||
344 | return data |
|
357 | return data | |
345 |
|
358 | |||
346 |
|
359 | |||
347 | def setup(self, path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r", online = 0): |
|
360 | def setup(self, path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r", online = 0): | |
348 |
|
361 | |||
349 | if online == 0: |
|
362 | if online == 0: | |
350 | pathList, filenameList = self.__searchFiles(path, startDateTime, endDateTime, set, expLabel, ext) |
|
363 | pathList, filenameList = self.__searchFiles(path, startDateTime, endDateTime, set, expLabel, ext) | |
351 |
|
364 | |||
352 | if len(filenameList) == 0: |
|
365 | if len(filenameList) == 0: | |
353 | print 'Do not exist files in range: %s - %s'%(startDateTime.ctime(), endDateTime.ctime()) |
|
366 | print 'Do not exist files in range: %s - %s'%(startDateTime.ctime(), endDateTime.ctime()) | |
354 | return 0 |
|
367 | return 0 | |
355 |
|
368 | |||
356 | # for thisFile in filenameList: |
|
369 | # for thisFile in filenameList: | |
357 | # print thisFile |
|
370 | # print thisFile | |
358 |
|
371 | |||
359 | self.__idFile = -1 |
|
372 | self.__idFile = -1 | |
360 |
|
373 | |||
361 | if not(self.__setNextFile()): |
|
374 | if not(self.__setNextFile()): | |
362 | print "No more files" |
|
375 | print "No more files" | |
363 | return 0 |
|
376 | return 0 | |
364 |
|
377 | |||
365 | self.__readFirstHeader() |
|
378 | self.__readFirstHeader() | |
366 |
|
379 | |||
367 | self.startUTCSeconds = time.mktime(startDateTime.timetuple()) |
|
380 | self.startUTCSeconds = time.mktime(startDateTime.timetuple()) | |
368 | self.endUTCSeconds = time.mktime(endDateTime.timetuple()) |
|
381 | self.endUTCSeconds = time.mktime(endDateTime.timetuple()) | |
369 |
|
382 | |||
370 | self.startYear = startDateTime.timetuple().tm_year |
|
383 | self.startYear = startDateTime.timetuple().tm_year | |
371 | self.endYear = endDateTime.timetuple().tm_year |
|
384 | self.endYear = endDateTime.timetuple().tm_year | |
372 |
|
385 | |||
373 | self.startDoy = startDateTime.timetuple().tm_yday |
|
386 | self.startDoy = startDateTime.timetuple().tm_yday | |
374 | self.endDoy = endDateTime.timetuple().tm_yday |
|
387 | self.endDoy = endDateTime.timetuple().tm_yday | |
375 | #call fillHeaderValues() - to Data Object |
|
388 | #call fillHeaderValues() - to Data Object | |
376 |
|
389 | |||
377 | self.__pathList = pathList |
|
390 | self.__pathList = pathList | |
378 | self.filenameList = filenameList |
|
391 | self.filenameList = filenameList | |
379 | self.online = online |
|
392 | self.online = online | |
380 |
|
393 | |||
381 | class VoltageWriter(DataWriter): |
|
394 | class VoltageWriter(DataWriter): | |
382 |
|
395 | |||
383 | def __init__(self): |
|
396 | m_BasicHeader= BasicHeader() | |
384 | pass |
|
397 | ||
|
398 | ||||
|
399 | m_SystemHeader = SystemHeader() | |||
|
400 | ||||
|
401 | ||||
|
402 | m_RadarControllerHeader = RadarControllerHeader() | |||
|
403 | ||||
|
404 | ||||
|
405 | m_ProcessingHeader = ProcessingHeader() | |||
|
406 | ||||
|
407 | m_Voltage = None | |||
|
408 | ||||
|
409 | def __init__(self, m_Voltage): | |||
|
410 | ||||
|
411 | self.m_Voltage = m_Voltage | |||
|
412 | ||||
|
413 | ||||
385 | No newline at end of file |
|
414 |
General Comments 0
You need to be logged in to leave comments.
Login now