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