@@ -1,661 +1,660 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Set 9, 2015 |
|
2 | Created on Set 9, 2015 | |
3 |
|
3 | |||
4 | @author: roj-idl71 Karim Kuyeng |
|
4 | @author: roj-idl71 Karim Kuyeng | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import os |
|
7 | import os | |
8 | import sys |
|
8 | import sys | |
9 | import glob |
|
9 | import glob | |
10 | import fnmatch |
|
10 | import fnmatch | |
11 | import datetime |
|
11 | import datetime | |
12 | import time |
|
12 | import time | |
13 | import re |
|
13 | import re | |
14 | import h5py |
|
14 | import h5py | |
15 | import numpy |
|
15 | import numpy | |
16 |
|
16 | |||
17 | try: |
|
17 | try: | |
18 | from gevent import sleep |
|
18 | from gevent import sleep | |
19 | except: |
|
19 | except: | |
20 | from time import sleep |
|
20 | from time import sleep | |
21 |
|
21 | |||
22 | from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader |
|
22 | from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader | |
23 | from schainpy.model.data.jrodata import Voltage |
|
23 | from schainpy.model.data.jrodata import Voltage | |
24 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator |
|
24 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator | |
25 | from numpy import imag |
|
25 | from numpy import imag | |
26 |
|
26 | |||
27 |
|
27 | |||
28 | class AMISRReader(ProcessingUnit): |
|
28 | class AMISRReader(ProcessingUnit): | |
29 | ''' |
|
29 | ''' | |
30 | classdocs |
|
30 | classdocs | |
31 | ''' |
|
31 | ''' | |
32 |
|
32 | |||
33 | def __init__(self): |
|
33 | def __init__(self): | |
34 | ''' |
|
34 | ''' | |
35 | Constructor |
|
35 | Constructor | |
36 | ''' |
|
36 | ''' | |
37 |
|
37 | |||
38 | ProcessingUnit.__init__(self) |
|
38 | ProcessingUnit.__init__(self) | |
39 |
|
39 | |||
40 | self.set = None |
|
40 | self.set = None | |
41 | self.subset = None |
|
41 | self.subset = None | |
42 | self.extension_file = '.h5' |
|
42 | self.extension_file = '.h5' | |
43 | self.dtc_str = 'dtc' |
|
43 | self.dtc_str = 'dtc' | |
44 | self.dtc_id = 0 |
|
44 | self.dtc_id = 0 | |
45 | self.status = True |
|
45 | self.status = True | |
46 | self.isConfig = False |
|
46 | self.isConfig = False | |
47 | self.dirnameList = [] |
|
47 | self.dirnameList = [] | |
48 | self.filenameList = [] |
|
48 | self.filenameList = [] | |
49 | self.fileIndex = None |
|
49 | self.fileIndex = None | |
50 | self.flagNoMoreFiles = False |
|
50 | self.flagNoMoreFiles = False | |
51 | self.flagIsNewFile = 0 |
|
51 | self.flagIsNewFile = 0 | |
52 | self.filename = '' |
|
52 | self.filename = '' | |
53 | self.amisrFilePointer = None |
|
53 | self.amisrFilePointer = None | |
54 | self.realBeamCode = [] |
|
54 | self.realBeamCode = [] | |
55 |
|
55 | |||
56 | self.dataShape = None |
|
56 | self.dataShape = None | |
57 |
|
57 | |||
58 |
|
58 | |||
59 |
|
59 | |||
60 | self.profileIndex = 0 |
|
60 | self.profileIndex = 0 | |
61 |
|
61 | |||
62 |
|
62 | |||
63 | self.beamCodeByFrame = None |
|
63 | self.beamCodeByFrame = None | |
64 | self.radacTimeByFrame = None |
|
64 | self.radacTimeByFrame = None | |
65 |
|
65 | |||
66 | self.dataset = None |
|
66 | self.dataset = None | |
67 |
|
67 | |||
68 |
|
68 | |||
69 |
|
69 | |||
70 |
|
70 | |||
71 | self.__firstFile = True |
|
71 | self.__firstFile = True | |
72 |
|
72 | |||
73 | self.buffer = None |
|
73 | self.buffer = None | |
74 |
|
74 | |||
75 |
|
75 | |||
76 | self.timezone = 'ut' |
|
76 | self.timezone = 'ut' | |
77 |
|
77 | |||
78 | self.__waitForNewFile = 20 |
|
78 | self.__waitForNewFile = 20 | |
79 | self.__filename_online = None |
|
79 | self.__filename_online = None | |
80 | #Is really necessary create the output object in the initializer |
|
80 | #Is really necessary create the output object in the initializer | |
81 | self.dataOut = Voltage() |
|
81 | self.dataOut = Voltage() | |
82 | self.dataOut.error=False |
|
82 | self.dataOut.error=False | |
83 |
|
83 | |||
84 |
|
84 | |||
85 | def setup(self,path=None, |
|
85 | def setup(self,path=None, | |
86 | startDate=None, |
|
86 | startDate=None, | |
87 | endDate=None, |
|
87 | endDate=None, | |
88 | startTime=None, |
|
88 | startTime=None, | |
89 | endTime=None, |
|
89 | endTime=None, | |
90 | walk=True, |
|
90 | walk=True, | |
91 | timezone='ut', |
|
91 | timezone='ut', | |
92 | all=0, |
|
92 | all=0, | |
93 | code = None, |
|
93 | code = None, | |
94 | nCode = 0, |
|
94 | nCode = 0, | |
95 | nBaud = 0, |
|
95 | nBaud = 0, | |
96 | online=False): |
|
96 | online=False): | |
97 |
|
97 | |||
98 |
|
98 | |||
99 |
|
99 | |||
100 | self.timezone = timezone |
|
100 | self.timezone = timezone | |
101 | self.all = all |
|
101 | self.all = all | |
102 | self.online = online |
|
102 | self.online = online | |
103 |
|
103 | |||
104 | self.code = code |
|
104 | self.code = code | |
105 | self.nCode = int(nCode) |
|
105 | self.nCode = int(nCode) | |
106 | self.nBaud = int(nBaud) |
|
106 | self.nBaud = int(nBaud) | |
107 |
|
107 | |||
108 |
|
108 | |||
109 |
|
109 | |||
110 | #self.findFiles() |
|
110 | #self.findFiles() | |
111 | if not(online): |
|
111 | if not(online): | |
112 | #Busqueda de archivos offline |
|
112 | #Busqueda de archivos offline | |
113 | self.searchFilesOffLine(path, startDate, endDate, startTime, endTime, walk) |
|
113 | self.searchFilesOffLine(path, startDate, endDate, startTime, endTime, walk) | |
114 | else: |
|
114 | else: | |
115 | self.searchFilesOnLine(path, startDate, endDate, startTime,endTime,walk) |
|
115 | self.searchFilesOnLine(path, startDate, endDate, startTime,endTime,walk) | |
116 |
|
116 | |||
117 | if not(self.filenameList): |
|
117 | if not(self.filenameList): | |
118 | print("There is no files into the folder: %s"%(path)) |
|
118 | print("There is no files into the folder: %s"%(path)) | |
119 |
sys.exit( |
|
119 | sys.exit() | |
120 |
|
120 | |||
121 | self.fileIndex = 0 |
|
121 | self.fileIndex = 0 | |
122 |
|
122 | |||
123 | self.readNextFile(online) |
|
123 | self.readNextFile(online) | |
124 |
|
124 | |||
125 | ''' |
|
125 | ''' | |
126 | Add code |
|
126 | Add code | |
127 | ''' |
|
127 | ''' | |
128 | self.isConfig = True |
|
128 | self.isConfig = True | |
129 | # print("Setup Done") |
|
129 | # print("Setup Done") | |
130 | pass |
|
130 | pass | |
131 |
|
131 | |||
132 |
|
132 | |||
133 | def readAMISRHeader(self,fp): |
|
133 | def readAMISRHeader(self,fp): | |
134 |
|
134 | |||
135 | if self.isConfig and (not self.flagNoMoreFiles): |
|
135 | if self.isConfig and (not self.flagNoMoreFiles): | |
136 | newShape = fp.get('Raw11/Data/Samples/Data').shape[1:] |
|
136 | newShape = fp.get('Raw11/Data/Samples/Data').shape[1:] | |
137 | if self.dataShape != newShape and newShape != None: |
|
137 | if self.dataShape != newShape and newShape != None: | |
138 | print("\nNEW FILE HAS A DIFFERENT SHAPE") |
|
138 | print("\nNEW FILE HAS A DIFFERENT SHAPE") | |
139 | print(self.dataShape,newShape,"\n") |
|
139 | print(self.dataShape,newShape,"\n") | |
140 | return 0 |
|
140 | return 0 | |
141 | else: |
|
141 | else: | |
142 | self.dataShape = fp.get('Raw11/Data/Samples/Data').shape[1:] |
|
142 | self.dataShape = fp.get('Raw11/Data/Samples/Data').shape[1:] | |
143 |
|
143 | |||
144 |
|
144 | |||
145 | header = 'Raw11/Data/RadacHeader' |
|
145 | header = 'Raw11/Data/RadacHeader' | |
146 | self.beamCodeByPulse = fp.get(header+'/BeamCode') # LIST OF BEAMS PER PROFILE, TO BE USED ON REARRANGE |
|
146 | self.beamCodeByPulse = fp.get(header+'/BeamCode') # LIST OF BEAMS PER PROFILE, TO BE USED ON REARRANGE | |
147 | if (self.startDate> datetime.date(2021, 7, 15)): #Se cambió la forma de extracción de Apuntes el 17 |
|
147 | if (self.startDate> datetime.date(2021, 7, 15)): #Se cambió la forma de extracción de Apuntes el 17 | |
148 | self.beamcodeFile = fp['Setup/Beamcodefile'][()].decode() |
|
148 | self.beamcodeFile = fp['Setup/Beamcodefile'][()].decode() | |
149 | self.trueBeams = self.beamcodeFile.split("\n") |
|
149 | self.trueBeams = self.beamcodeFile.split("\n") | |
150 | self.trueBeams.pop()#remove last |
|
150 | self.trueBeams.pop()#remove last | |
151 | [self.realBeamCode.append(x) for x in self.trueBeams if x not in self.realBeamCode] |
|
151 | [self.realBeamCode.append(x) for x in self.trueBeams if x not in self.realBeamCode] | |
152 | self.beamCode = [int(x, 16) for x in self.realBeamCode] |
|
152 | self.beamCode = [int(x, 16) for x in self.realBeamCode] | |
153 | else: |
|
153 | else: | |
154 | _beamCode= fp.get('Raw11/Data/Beamcodes') #se usa la manera previa al cambio de apuntes |
|
154 | _beamCode= fp.get('Raw11/Data/Beamcodes') #se usa la manera previa al cambio de apuntes | |
155 | self.beamCode = _beamCode[0,:] |
|
155 | self.beamCode = _beamCode[0,:] | |
156 |
|
156 | |||
157 |
|
157 | |||
158 | #self.code = fp.get(header+'/Code') # NOT USE FOR THIS |
|
158 | #self.code = fp.get(header+'/Code') # NOT USE FOR THIS | |
159 | self.frameCount = fp.get(header+'/FrameCount')# NOT USE FOR THIS |
|
159 | self.frameCount = fp.get(header+'/FrameCount')# NOT USE FOR THIS | |
160 | self.modeGroup = fp.get(header+'/ModeGroup')# NOT USE FOR THIS |
|
160 | self.modeGroup = fp.get(header+'/ModeGroup')# NOT USE FOR THIS | |
161 | self.nsamplesPulse = fp.get(header+'/NSamplesPulse')# TO GET NSA OR USING DATA FOR THAT |
|
161 | self.nsamplesPulse = fp.get(header+'/NSamplesPulse')# TO GET NSA OR USING DATA FOR THAT | |
162 | self.pulseCount = fp.get(header+'/PulseCount')# NOT USE FOR THIS |
|
162 | self.pulseCount = fp.get(header+'/PulseCount')# NOT USE FOR THIS | |
163 | self.radacTime = fp.get(header+'/RadacTime')# 1st TIME ON FILE ANDE CALCULATE THE REST WITH IPP*nindexprofile |
|
163 | self.radacTime = fp.get(header+'/RadacTime')# 1st TIME ON FILE ANDE CALCULATE THE REST WITH IPP*nindexprofile | |
164 | self.timeCount = fp.get(header+'/TimeCount')# NOT USE FOR THIS |
|
164 | self.timeCount = fp.get(header+'/TimeCount')# NOT USE FOR THIS | |
165 | self.timeStatus = fp.get(header+'/TimeStatus')# NOT USE FOR THIS |
|
165 | self.timeStatus = fp.get(header+'/TimeStatus')# NOT USE FOR THIS | |
166 | self.rangeFromFile = fp.get('Raw11/Data/Samples/Range') |
|
166 | self.rangeFromFile = fp.get('Raw11/Data/Samples/Range') | |
167 | self.frequency = fp.get('Rx/Frequency') |
|
167 | self.frequency = fp.get('Rx/Frequency') | |
168 | txAus = fp.get('Raw11/Data/Pulsewidth') |
|
168 | txAus = fp.get('Raw11/Data/Pulsewidth') | |
169 |
|
169 | |||
170 |
|
170 | |||
171 | self.nblocks = self.pulseCount.shape[0] #nblocks |
|
171 | self.nblocks = self.pulseCount.shape[0] #nblocks | |
172 |
|
172 | |||
173 | self.nprofiles = self.pulseCount.shape[1] #nprofile |
|
173 | self.nprofiles = self.pulseCount.shape[1] #nprofile | |
174 | self.nsa = self.nsamplesPulse[0,0] #ngates |
|
174 | self.nsa = self.nsamplesPulse[0,0] #ngates | |
175 | self.nchannels = len(self.beamCode) |
|
175 | self.nchannels = len(self.beamCode) | |
176 | self.ippSeconds = (self.radacTime[0][1] -self.radacTime[0][0]) #Ipp in seconds |
|
176 | self.ippSeconds = (self.radacTime[0][1] -self.radacTime[0][0]) #Ipp in seconds | |
177 | #self.__waitForNewFile = self.nblocks # wait depending on the number of blocks since each block is 1 sec |
|
177 | #self.__waitForNewFile = self.nblocks # wait depending on the number of blocks since each block is 1 sec | |
178 | self.__waitForNewFile = self.nblocks * self.nprofiles * self.ippSeconds # wait until new file is created |
|
178 | self.__waitForNewFile = self.nblocks * self.nprofiles * self.ippSeconds # wait until new file is created | |
179 |
|
179 | |||
180 | #filling radar controller header parameters |
|
180 | #filling radar controller header parameters | |
181 | self.__ippKm = self.ippSeconds *.15*1e6 # in km |
|
181 | self.__ippKm = self.ippSeconds *.15*1e6 # in km | |
182 | self.__txA = (txAus.value)*.15 #(ipp[us]*.15km/1us) in km |
|
182 | self.__txA = (txAus.value)*.15 #(ipp[us]*.15km/1us) in km | |
183 | self.__txB = 0 |
|
183 | self.__txB = 0 | |
184 | nWindows=1 |
|
184 | nWindows=1 | |
185 | self.__nSamples = self.nsa |
|
185 | self.__nSamples = self.nsa | |
186 | self.__firstHeight = self.rangeFromFile[0][0]/1000 #in km |
|
186 | self.__firstHeight = self.rangeFromFile[0][0]/1000 #in km | |
187 | self.__deltaHeight = (self.rangeFromFile[0][1] - self.rangeFromFile[0][0])/1000 |
|
187 | self.__deltaHeight = (self.rangeFromFile[0][1] - self.rangeFromFile[0][0])/1000 | |
188 |
|
188 | |||
189 | #for now until understand why the code saved is different (code included even though code not in tuf file) |
|
189 | #for now until understand why the code saved is different (code included even though code not in tuf file) | |
190 | #self.__codeType = 0 |
|
190 | #self.__codeType = 0 | |
191 | # self.__nCode = None |
|
191 | # self.__nCode = None | |
192 | # self.__nBaud = None |
|
192 | # self.__nBaud = None | |
193 | self.__code = self.code |
|
193 | self.__code = self.code | |
194 | self.__codeType = 0 |
|
194 | self.__codeType = 0 | |
195 | if self.code != None: |
|
195 | if self.code != None: | |
196 | self.__codeType = 1 |
|
196 | self.__codeType = 1 | |
197 | self.__nCode = self.nCode |
|
197 | self.__nCode = self.nCode | |
198 | self.__nBaud = self.nBaud |
|
198 | self.__nBaud = self.nBaud | |
199 | #self.__code = 0 |
|
199 | #self.__code = 0 | |
200 |
|
200 | |||
201 | #filling system header parameters |
|
201 | #filling system header parameters | |
202 | self.__nSamples = self.nsa |
|
202 | self.__nSamples = self.nsa | |
203 | self.newProfiles = self.nprofiles/self.nchannels |
|
203 | self.newProfiles = self.nprofiles/self.nchannels | |
204 | self.__channelList = list(range(self.nchannels)) |
|
204 | self.__channelList = list(range(self.nchannels)) | |
205 |
|
205 | |||
206 | self.__frequency = self.frequency[0][0] |
|
206 | self.__frequency = self.frequency[0][0] | |
207 |
|
207 | |||
208 |
|
208 | |||
209 | return 1 |
|
209 | return 1 | |
210 |
|
210 | |||
211 |
|
211 | |||
212 | def createBuffers(self): |
|
212 | def createBuffers(self): | |
213 |
|
213 | |||
214 | pass |
|
214 | pass | |
215 |
|
215 | |||
216 | def __setParameters(self,path='', startDate='',endDate='',startTime='', endTime='', walk=''): |
|
216 | def __setParameters(self,path='', startDate='',endDate='',startTime='', endTime='', walk=''): | |
217 | self.path = path |
|
217 | self.path = path | |
218 | self.startDate = startDate |
|
218 | self.startDate = startDate | |
219 | self.endDate = endDate |
|
219 | self.endDate = endDate | |
220 | self.startTime = startTime |
|
220 | self.startTime = startTime | |
221 | self.endTime = endTime |
|
221 | self.endTime = endTime | |
222 | self.walk = walk |
|
222 | self.walk = walk | |
223 |
|
223 | |||
224 | def __checkPath(self): |
|
224 | def __checkPath(self): | |
225 | if os.path.exists(self.path): |
|
225 | if os.path.exists(self.path): | |
226 | self.status = 1 |
|
226 | self.status = 1 | |
227 | else: |
|
227 | else: | |
228 | self.status = 0 |
|
228 | self.status = 0 | |
229 | print('Path:%s does not exists'%self.path) |
|
229 | print('Path:%s does not exists'%self.path) | |
230 |
|
230 | |||
231 | return |
|
231 | return | |
232 |
|
232 | |||
233 |
|
233 | |||
234 | def __selDates(self, amisr_dirname_format): |
|
234 | def __selDates(self, amisr_dirname_format): | |
235 | try: |
|
235 | try: | |
236 | year = int(amisr_dirname_format[0:4]) |
|
236 | year = int(amisr_dirname_format[0:4]) | |
237 | month = int(amisr_dirname_format[4:6]) |
|
237 | month = int(amisr_dirname_format[4:6]) | |
238 | dom = int(amisr_dirname_format[6:8]) |
|
238 | dom = int(amisr_dirname_format[6:8]) | |
239 | thisDate = datetime.date(year,month,dom) |
|
239 | thisDate = datetime.date(year,month,dom) | |
240 |
|
240 | |||
241 | if (thisDate>=self.startDate and thisDate <= self.endDate): |
|
241 | if (thisDate>=self.startDate and thisDate <= self.endDate): | |
242 | return amisr_dirname_format |
|
242 | return amisr_dirname_format | |
243 | except: |
|
243 | except: | |
244 | return None |
|
244 | return None | |
245 |
|
245 | |||
246 |
|
246 | |||
247 | def __findDataForDates(self,online=False): |
|
247 | def __findDataForDates(self,online=False): | |
248 |
|
248 | |||
249 | if not(self.status): |
|
249 | if not(self.status): | |
250 | return None |
|
250 | return None | |
251 |
|
251 | |||
252 | pat = '\d+.\d+' |
|
252 | pat = '\d+.\d+' | |
253 | dirnameList = [re.search(pat,x) for x in os.listdir(self.path)] |
|
253 | dirnameList = [re.search(pat,x) for x in os.listdir(self.path)] | |
254 | dirnameList = [x for x in dirnameList if x!=None] |
|
254 | dirnameList = [x for x in dirnameList if x!=None] | |
255 | dirnameList = [x.string for x in dirnameList] |
|
255 | dirnameList = [x.string for x in dirnameList] | |
256 | if not(online): |
|
256 | if not(online): | |
257 | dirnameList = [self.__selDates(x) for x in dirnameList] |
|
257 | dirnameList = [self.__selDates(x) for x in dirnameList] | |
258 | dirnameList = [x for x in dirnameList if x!=None] |
|
258 | dirnameList = [x for x in dirnameList if x!=None] | |
259 | if len(dirnameList)>0: |
|
259 | if len(dirnameList)>0: | |
260 | self.status = 1 |
|
260 | self.status = 1 | |
261 | self.dirnameList = dirnameList |
|
261 | self.dirnameList = dirnameList | |
262 | self.dirnameList.sort() |
|
262 | self.dirnameList.sort() | |
263 | else: |
|
263 | else: | |
264 | self.status = 0 |
|
264 | self.status = 0 | |
265 | return None |
|
265 | return None | |
266 |
|
266 | |||
267 | def __getTimeFromData(self): |
|
267 | def __getTimeFromData(self): | |
268 | startDateTime_Reader = datetime.datetime.combine(self.startDate,self.startTime) |
|
268 | startDateTime_Reader = datetime.datetime.combine(self.startDate,self.startTime) | |
269 | endDateTime_Reader = datetime.datetime.combine(self.endDate,self.endTime) |
|
269 | endDateTime_Reader = datetime.datetime.combine(self.endDate,self.endTime) | |
270 |
|
270 | |||
271 | print('Filtering Files from %s to %s'%(startDateTime_Reader, endDateTime_Reader)) |
|
271 | print('Filtering Files from %s to %s'%(startDateTime_Reader, endDateTime_Reader)) | |
272 | print('........................................') |
|
272 | print('........................................') | |
273 | filter_filenameList = [] |
|
273 | filter_filenameList = [] | |
274 | self.filenameList.sort() |
|
274 | self.filenameList.sort() | |
275 | #for i in range(len(self.filenameList)-1): |
|
275 | #for i in range(len(self.filenameList)-1): | |
276 | for i in range(len(self.filenameList)): |
|
276 | for i in range(len(self.filenameList)): | |
277 | filename = self.filenameList[i] |
|
277 | filename = self.filenameList[i] | |
278 | fp = h5py.File(filename,'r') |
|
278 | fp = h5py.File(filename,'r') | |
279 | time_str = fp.get('Time/RadacTimeString') |
|
279 | time_str = fp.get('Time/RadacTimeString') | |
280 |
|
280 | |||
281 | startDateTimeStr_File = time_str[0][0].decode('UTF-8').split('.')[0] |
|
281 | startDateTimeStr_File = time_str[0][0].decode('UTF-8').split('.')[0] | |
282 | #startDateTimeStr_File = "2019-12-16 09:21:11" |
|
282 | #startDateTimeStr_File = "2019-12-16 09:21:11" | |
283 | junk = time.strptime(startDateTimeStr_File, '%Y-%m-%d %H:%M:%S') |
|
283 | junk = time.strptime(startDateTimeStr_File, '%Y-%m-%d %H:%M:%S') | |
284 | startDateTime_File = datetime.datetime(junk.tm_year,junk.tm_mon,junk.tm_mday,junk.tm_hour, junk.tm_min, junk.tm_sec) |
|
284 | startDateTime_File = datetime.datetime(junk.tm_year,junk.tm_mon,junk.tm_mday,junk.tm_hour, junk.tm_min, junk.tm_sec) | |
285 |
|
285 | |||
286 | #endDateTimeStr_File = "2019-12-16 11:10:11" |
|
286 | #endDateTimeStr_File = "2019-12-16 11:10:11" | |
287 | endDateTimeStr_File = time_str[-1][-1].decode('UTF-8').split('.')[0] |
|
287 | endDateTimeStr_File = time_str[-1][-1].decode('UTF-8').split('.')[0] | |
288 | junk = time.strptime(endDateTimeStr_File, '%Y-%m-%d %H:%M:%S') |
|
288 | junk = time.strptime(endDateTimeStr_File, '%Y-%m-%d %H:%M:%S') | |
289 | endDateTime_File = datetime.datetime(junk.tm_year,junk.tm_mon,junk.tm_mday,junk.tm_hour, junk.tm_min, junk.tm_sec) |
|
289 | endDateTime_File = datetime.datetime(junk.tm_year,junk.tm_mon,junk.tm_mday,junk.tm_hour, junk.tm_min, junk.tm_sec) | |
290 |
|
290 | |||
291 | fp.close() |
|
291 | fp.close() | |
292 |
|
292 | |||
293 | #print("check time", startDateTime_File) |
|
293 | #print("check time", startDateTime_File) | |
294 | if self.timezone == 'lt': |
|
294 | if self.timezone == 'lt': | |
295 | startDateTime_File = startDateTime_File - datetime.timedelta(minutes = 300) |
|
295 | startDateTime_File = startDateTime_File - datetime.timedelta(minutes = 300) | |
296 | endDateTime_File = endDateTime_File - datetime.timedelta(minutes = 300) |
|
296 | endDateTime_File = endDateTime_File - datetime.timedelta(minutes = 300) | |
297 | if (endDateTime_File>=startDateTime_Reader and endDateTime_File<endDateTime_Reader): |
|
297 | if (endDateTime_File>=startDateTime_Reader and endDateTime_File<=endDateTime_Reader): | |
298 | #self.filenameList.remove(filename) |
|
|||
299 | filter_filenameList.append(filename) |
|
298 | filter_filenameList.append(filename) | |
300 |
|
299 | |||
301 |
if (endDateTime_File> |
|
300 | if (endDateTime_File>endDateTime_Reader): | |
302 | break |
|
301 | break | |
303 |
|
302 | |||
304 |
|
303 | |||
305 | filter_filenameList.sort() |
|
304 | filter_filenameList.sort() | |
306 | self.filenameList = filter_filenameList |
|
305 | self.filenameList = filter_filenameList | |
307 | return 1 |
|
306 | return 1 | |
308 |
|
307 | |||
309 | def __filterByGlob1(self, dirName): |
|
308 | def __filterByGlob1(self, dirName): | |
310 | filter_files = glob.glob1(dirName, '*.*%s'%self.extension_file) |
|
309 | filter_files = glob.glob1(dirName, '*.*%s'%self.extension_file) | |
311 | filter_files.sort() |
|
310 | filter_files.sort() | |
312 | filterDict = {} |
|
311 | filterDict = {} | |
313 | filterDict.setdefault(dirName) |
|
312 | filterDict.setdefault(dirName) | |
314 | filterDict[dirName] = filter_files |
|
313 | filterDict[dirName] = filter_files | |
315 | return filterDict |
|
314 | return filterDict | |
316 |
|
315 | |||
317 | def __getFilenameList(self, fileListInKeys, dirList): |
|
316 | def __getFilenameList(self, fileListInKeys, dirList): | |
318 | for value in fileListInKeys: |
|
317 | for value in fileListInKeys: | |
319 | dirName = list(value.keys())[0] |
|
318 | dirName = list(value.keys())[0] | |
320 | for file in value[dirName]: |
|
319 | for file in value[dirName]: | |
321 | filename = os.path.join(dirName, file) |
|
320 | filename = os.path.join(dirName, file) | |
322 | self.filenameList.append(filename) |
|
321 | self.filenameList.append(filename) | |
323 |
|
322 | |||
324 |
|
323 | |||
325 | def __selectDataForTimes(self, online=False): |
|
324 | def __selectDataForTimes(self, online=False): | |
326 | #aun no esta implementado el filtro for tiempo |
|
325 | #aun no esta implementado el filtro for tiempo | |
327 | if not(self.status): |
|
326 | if not(self.status): | |
328 | return None |
|
327 | return None | |
329 |
|
328 | |||
330 | dirList = [os.path.join(self.path,x) for x in self.dirnameList] |
|
329 | dirList = [os.path.join(self.path,x) for x in self.dirnameList] | |
331 |
|
330 | |||
332 | fileListInKeys = [self.__filterByGlob1(x) for x in dirList] |
|
331 | fileListInKeys = [self.__filterByGlob1(x) for x in dirList] | |
333 |
|
332 | |||
334 | self.__getFilenameList(fileListInKeys, dirList) |
|
333 | self.__getFilenameList(fileListInKeys, dirList) | |
335 | if not(online): |
|
334 | if not(online): | |
336 | #filtro por tiempo |
|
335 | #filtro por tiempo | |
337 | if not(self.all): |
|
336 | if not(self.all): | |
338 | self.__getTimeFromData() |
|
337 | self.__getTimeFromData() | |
339 |
|
338 | |||
340 | if len(self.filenameList)>0: |
|
339 | if len(self.filenameList)>0: | |
341 | self.status = 1 |
|
340 | self.status = 1 | |
342 | self.filenameList.sort() |
|
341 | self.filenameList.sort() | |
343 | else: |
|
342 | else: | |
344 | self.status = 0 |
|
343 | self.status = 0 | |
345 | return None |
|
344 | return None | |
346 |
|
345 | |||
347 | else: |
|
346 | else: | |
348 | #get the last file - 1 |
|
347 | #get the last file - 1 | |
349 |
self.filenameList = [self.filenameList[- |
|
348 | self.filenameList = [self.filenameList[-1]] | |
350 | new_dirnameList = [] |
|
349 | new_dirnameList = [] | |
351 | for dirname in self.dirnameList: |
|
350 | for dirname in self.dirnameList: | |
352 | junk = numpy.array([dirname in x for x in self.filenameList]) |
|
351 | junk = numpy.array([dirname in x for x in self.filenameList]) | |
353 | junk_sum = junk.sum() |
|
352 | junk_sum = junk.sum() | |
354 | if junk_sum > 0: |
|
353 | if junk_sum > 0: | |
355 | new_dirnameList.append(dirname) |
|
354 | new_dirnameList.append(dirname) | |
356 | self.dirnameList = new_dirnameList |
|
355 | self.dirnameList = new_dirnameList | |
357 | return 1 |
|
356 | return 1 | |
358 |
|
357 | |||
359 | def searchFilesOnLine(self, path, startDate, endDate, startTime=datetime.time(0,0,0), |
|
358 | def searchFilesOnLine(self, path, startDate, endDate, startTime=datetime.time(0,0,0), | |
360 | endTime=datetime.time(23,59,59),walk=True): |
|
359 | endTime=datetime.time(23,59,59),walk=True): | |
361 |
|
360 | |||
362 | if endDate ==None: |
|
361 | if endDate ==None: | |
363 | startDate = datetime.datetime.utcnow().date() |
|
362 | startDate = datetime.datetime.utcnow().date() | |
364 | endDate = datetime.datetime.utcnow().date() |
|
363 | endDate = datetime.datetime.utcnow().date() | |
365 |
|
364 | |||
366 | self.__setParameters(path=path, startDate=startDate, endDate=endDate,startTime = startTime,endTime=endTime, walk=walk) |
|
365 | self.__setParameters(path=path, startDate=startDate, endDate=endDate,startTime = startTime,endTime=endTime, walk=walk) | |
367 |
|
366 | |||
368 | self.__checkPath() |
|
367 | self.__checkPath() | |
369 |
|
368 | |||
370 | self.__findDataForDates(online=True) |
|
369 | self.__findDataForDates(online=True) | |
371 |
|
370 | |||
372 | self.dirnameList = [self.dirnameList[-1]] |
|
371 | self.dirnameList = [self.dirnameList[-1]] | |
373 |
|
372 | |||
374 | self.__selectDataForTimes(online=True) |
|
373 | self.__selectDataForTimes(online=True) | |
375 |
|
374 | |||
376 | return |
|
375 | return | |
377 |
|
376 | |||
378 |
|
377 | |||
379 | def searchFilesOffLine(self, |
|
378 | def searchFilesOffLine(self, | |
380 | path, |
|
379 | path, | |
381 | startDate, |
|
380 | startDate, | |
382 | endDate, |
|
381 | endDate, | |
383 | startTime=datetime.time(0,0,0), |
|
382 | startTime=datetime.time(0,0,0), | |
384 | endTime=datetime.time(23,59,59), |
|
383 | endTime=datetime.time(23,59,59), | |
385 | walk=True): |
|
384 | walk=True): | |
386 |
|
385 | |||
387 | self.__setParameters(path, startDate, endDate, startTime, endTime, walk) |
|
386 | self.__setParameters(path, startDate, endDate, startTime, endTime, walk) | |
388 |
|
387 | |||
389 | self.__checkPath() |
|
388 | self.__checkPath() | |
390 |
|
389 | |||
391 | self.__findDataForDates() |
|
390 | self.__findDataForDates() | |
392 |
|
391 | |||
393 | self.__selectDataForTimes() |
|
392 | self.__selectDataForTimes() | |
394 |
|
393 | |||
395 | for i in range(len(self.filenameList)): |
|
394 | for i in range(len(self.filenameList)): | |
396 | print("%s" %(self.filenameList[i])) |
|
395 | print("%s" %(self.filenameList[i])) | |
397 |
|
396 | |||
398 | return |
|
397 | return | |
399 |
|
398 | |||
400 | def __setNextFileOffline(self): |
|
399 | def __setNextFileOffline(self): | |
401 |
|
400 | |||
402 | try: |
|
401 | try: | |
403 | self.filename = self.filenameList[self.fileIndex] |
|
402 | self.filename = self.filenameList[self.fileIndex] | |
404 | self.amisrFilePointer = h5py.File(self.filename,'r') |
|
403 | self.amisrFilePointer = h5py.File(self.filename,'r') | |
405 | self.fileIndex += 1 |
|
404 | self.fileIndex += 1 | |
406 | except: |
|
405 | except: | |
407 | self.flagNoMoreFiles = 1 |
|
406 | self.flagNoMoreFiles = 1 | |
408 | print("No more Files") |
|
407 | print("No more Files") | |
409 | return 0 |
|
408 | return 0 | |
410 |
|
409 | |||
411 | self.flagIsNewFile = 1 |
|
410 | self.flagIsNewFile = 1 | |
412 | print("Setting the file: %s"%self.filename) |
|
411 | print("Setting the file: %s"%self.filename) | |
413 |
|
412 | |||
414 | return 1 |
|
413 | return 1 | |
415 |
|
414 | |||
416 |
|
415 | |||
417 | def __setNextFileOnline(self): |
|
416 | def __setNextFileOnline(self): | |
418 | filename = self.filenameList[0] |
|
417 | filename = self.filenameList[0] | |
419 | if self.__filename_online != None: |
|
418 | if self.__filename_online != None: | |
420 | self.__selectDataForTimes(online=True) |
|
419 | self.__selectDataForTimes(online=True) | |
421 | filename = self.filenameList[0] |
|
420 | filename = self.filenameList[0] | |
422 | wait = 0 |
|
421 | wait = 0 | |
423 |
|
|
422 | self.__waitForNewFile=180 ## DEBUG: | |
424 | while self.__filename_online == filename: |
|
423 | while self.__filename_online == filename: | |
425 | print('waiting %d seconds to get a new file...'%(self.__waitForNewFile)) |
|
424 | print('waiting %d seconds to get a new file...'%(self.__waitForNewFile)) | |
426 | if wait == 5: |
|
425 | if wait == 5: | |
427 | self.flagNoMoreFiles = 1 |
|
426 | self.flagNoMoreFiles = 1 | |
428 | return 0 |
|
427 | return 0 | |
429 | sleep(self.__waitForNewFile) |
|
428 | sleep(self.__waitForNewFile) | |
430 | self.__selectDataForTimes(online=True) |
|
429 | self.__selectDataForTimes(online=True) | |
431 | filename = self.filenameList[0] |
|
430 | filename = self.filenameList[0] | |
432 | wait += 1 |
|
431 | wait += 1 | |
433 |
|
432 | |||
434 | self.__filename_online = filename |
|
433 | self.__filename_online = filename | |
435 |
|
434 | |||
436 | self.amisrFilePointer = h5py.File(filename,'r') |
|
435 | self.amisrFilePointer = h5py.File(filename,'r') | |
437 | self.flagIsNewFile = 1 |
|
436 | self.flagIsNewFile = 1 | |
438 | self.filename = filename |
|
437 | self.filename = filename | |
439 | print("Setting the file: %s"%self.filename) |
|
438 | print("Setting the file: %s"%self.filename) | |
440 | return 1 |
|
439 | return 1 | |
441 |
|
440 | |||
442 |
|
441 | |||
443 | def readData(self): |
|
442 | def readData(self): | |
444 | buffer = self.amisrFilePointer.get('Raw11/Data/Samples/Data') |
|
443 | buffer = self.amisrFilePointer.get('Raw11/Data/Samples/Data') | |
445 | re = buffer[:,:,:,0] |
|
444 | re = buffer[:,:,:,0] | |
446 | im = buffer[:,:,:,1] |
|
445 | im = buffer[:,:,:,1] | |
447 | dataset = re + im*1j |
|
446 | dataset = re + im*1j | |
448 |
|
447 | |||
449 | self.radacTime = self.amisrFilePointer.get('Raw11/Data/RadacHeader/RadacTime') |
|
448 | self.radacTime = self.amisrFilePointer.get('Raw11/Data/RadacHeader/RadacTime') | |
450 | timeset = self.radacTime[:,0] |
|
449 | timeset = self.radacTime[:,0] | |
451 |
|
450 | |||
452 | return dataset,timeset |
|
451 | return dataset,timeset | |
453 |
|
452 | |||
454 | def reshapeData(self): |
|
453 | def reshapeData(self): | |
455 | #self.beamCodeByPulse, self.beamCode, self.nblocks, self.nprofiles, self.nsa, |
|
454 | #self.beamCodeByPulse, self.beamCode, self.nblocks, self.nprofiles, self.nsa, | |
456 | channels = self.beamCodeByPulse[0,:] |
|
455 | channels = self.beamCodeByPulse[0,:] | |
457 | nchan = self.nchannels |
|
456 | nchan = self.nchannels | |
458 | #self.newProfiles = self.nprofiles/nchan #must be defined on filljroheader |
|
457 | #self.newProfiles = self.nprofiles/nchan #must be defined on filljroheader | |
459 | nblocks = self.nblocks |
|
458 | nblocks = self.nblocks | |
460 | nsamples = self.nsa |
|
459 | nsamples = self.nsa | |
461 |
|
460 | |||
462 | #Dimensions : nChannels, nProfiles, nSamples |
|
461 | #Dimensions : nChannels, nProfiles, nSamples | |
463 | new_block = numpy.empty((nblocks, nchan, numpy.int_(self.newProfiles), nsamples), dtype="complex64") |
|
462 | new_block = numpy.empty((nblocks, nchan, numpy.int_(self.newProfiles), nsamples), dtype="complex64") | |
464 | ############################################ |
|
463 | ############################################ | |
465 |
|
464 | |||
466 | for thisChannel in range(nchan): |
|
465 | for thisChannel in range(nchan): | |
467 | new_block[:,thisChannel,:,:] = self.dataset[:,numpy.where(channels==self.beamCode[thisChannel])[0],:] |
|
466 | new_block[:,thisChannel,:,:] = self.dataset[:,numpy.where(channels==self.beamCode[thisChannel])[0],:] | |
468 |
|
467 | |||
469 |
|
468 | |||
470 | new_block = numpy.transpose(new_block, (1,0,2,3)) |
|
469 | new_block = numpy.transpose(new_block, (1,0,2,3)) | |
471 | new_block = numpy.reshape(new_block, (nchan,-1, nsamples)) |
|
470 | new_block = numpy.reshape(new_block, (nchan,-1, nsamples)) | |
472 |
|
471 | |||
473 | return new_block |
|
472 | return new_block | |
474 |
|
473 | |||
475 | def updateIndexes(self): |
|
474 | def updateIndexes(self): | |
476 |
|
475 | |||
477 | pass |
|
476 | pass | |
478 |
|
477 | |||
479 | def fillJROHeader(self): |
|
478 | def fillJROHeader(self): | |
480 |
|
479 | |||
481 | #fill radar controller header |
|
480 | #fill radar controller header | |
482 | self.dataOut.radarControllerHeaderObj = RadarControllerHeader(ipp=self.__ippKm, |
|
481 | self.dataOut.radarControllerHeaderObj = RadarControllerHeader(ipp=self.__ippKm, | |
483 | txA=self.__txA, |
|
482 | txA=self.__txA, | |
484 | txB=0, |
|
483 | txB=0, | |
485 | nWindows=1, |
|
484 | nWindows=1, | |
486 | nHeights=self.__nSamples, |
|
485 | nHeights=self.__nSamples, | |
487 | firstHeight=self.__firstHeight, |
|
486 | firstHeight=self.__firstHeight, | |
488 | deltaHeight=self.__deltaHeight, |
|
487 | deltaHeight=self.__deltaHeight, | |
489 | codeType=self.__codeType, |
|
488 | codeType=self.__codeType, | |
490 | nCode=self.__nCode, nBaud=self.__nBaud, |
|
489 | nCode=self.__nCode, nBaud=self.__nBaud, | |
491 | code = self.__code, |
|
490 | code = self.__code, | |
492 | fClock=1) |
|
491 | fClock=1) | |
493 |
|
492 | |||
494 | #fill system header |
|
493 | #fill system header | |
495 | self.dataOut.systemHeaderObj = SystemHeader(nSamples=self.__nSamples, |
|
494 | self.dataOut.systemHeaderObj = SystemHeader(nSamples=self.__nSamples, | |
496 | nProfiles=self.newProfiles, |
|
495 | nProfiles=self.newProfiles, | |
497 | nChannels=len(self.__channelList), |
|
496 | nChannels=len(self.__channelList), | |
498 | adcResolution=14, |
|
497 | adcResolution=14, | |
499 | pciDioBusWidth=32) |
|
498 | pciDioBusWidth=32) | |
500 |
|
499 | |||
501 | self.dataOut.type = "Voltage" |
|
500 | self.dataOut.type = "Voltage" | |
502 |
|
501 | |||
503 | self.dataOut.data = None |
|
502 | self.dataOut.data = None | |
504 |
|
503 | |||
505 | self.dataOut.dtype = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
504 | self.dataOut.dtype = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
506 |
|
505 | |||
507 | # self.dataOut.nChannels = 0 |
|
506 | # self.dataOut.nChannels = 0 | |
508 |
|
507 | |||
509 | # self.dataOut.nHeights = 0 |
|
508 | # self.dataOut.nHeights = 0 | |
510 |
|
509 | |||
511 | self.dataOut.nProfiles = self.newProfiles*self.nblocks |
|
510 | self.dataOut.nProfiles = self.newProfiles*self.nblocks | |
512 |
|
511 | |||
513 | #self.dataOut.heightList = self.__firstHeigth + numpy.arange(self.__nSamples, dtype = numpy.float)*self.__deltaHeigth |
|
512 | #self.dataOut.heightList = self.__firstHeigth + numpy.arange(self.__nSamples, dtype = numpy.float)*self.__deltaHeigth | |
514 | ranges = numpy.reshape(self.rangeFromFile.value,(-1)) |
|
513 | ranges = numpy.reshape(self.rangeFromFile.value,(-1)) | |
515 | self.dataOut.heightList = ranges/1000.0 #km |
|
514 | self.dataOut.heightList = ranges/1000.0 #km | |
516 |
|
515 | |||
517 |
|
516 | |||
518 | self.dataOut.channelList = self.__channelList |
|
517 | self.dataOut.channelList = self.__channelList | |
519 |
|
518 | |||
520 | self.dataOut.blocksize = self.dataOut.nChannels * self.dataOut.nHeights |
|
519 | self.dataOut.blocksize = self.dataOut.nChannels * self.dataOut.nHeights | |
521 |
|
520 | |||
522 | # self.dataOut.channelIndexList = None |
|
521 | # self.dataOut.channelIndexList = None | |
523 |
|
522 | |||
524 | self.dataOut.flagNoData = True |
|
523 | self.dataOut.flagNoData = True | |
525 |
|
524 | |||
526 | #Set to TRUE if the data is discontinuous |
|
525 | #Set to TRUE if the data is discontinuous | |
527 | self.dataOut.flagDiscontinuousBlock = False |
|
526 | self.dataOut.flagDiscontinuousBlock = False | |
528 |
|
527 | |||
529 | self.dataOut.utctime = None |
|
528 | self.dataOut.utctime = None | |
530 |
|
529 | |||
531 | #self.dataOut.timeZone = -5 #self.__timezone/60 #timezone like jroheader, difference in minutes between UTC and localtime |
|
530 | #self.dataOut.timeZone = -5 #self.__timezone/60 #timezone like jroheader, difference in minutes between UTC and localtime | |
532 | if self.timezone == 'lt': |
|
531 | if self.timezone == 'lt': | |
533 | self.dataOut.timeZone = time.timezone / 60. #get the timezone in minutes |
|
532 | self.dataOut.timeZone = time.timezone / 60. #get the timezone in minutes | |
534 | else: |
|
533 | else: | |
535 | self.dataOut.timeZone = 0 #by default time is UTC |
|
534 | self.dataOut.timeZone = 0 #by default time is UTC | |
536 |
|
535 | |||
537 | self.dataOut.dstFlag = 0 |
|
536 | self.dataOut.dstFlag = 0 | |
538 |
|
537 | |||
539 | self.dataOut.errorCount = 0 |
|
538 | self.dataOut.errorCount = 0 | |
540 |
|
539 | |||
541 | self.dataOut.nCohInt = 1 |
|
540 | self.dataOut.nCohInt = 1 | |
542 |
|
541 | |||
543 | self.dataOut.flagDecodeData = False #asumo que la data esta decodificada |
|
542 | self.dataOut.flagDecodeData = False #asumo que la data esta decodificada | |
544 |
|
543 | |||
545 | self.dataOut.flagDeflipData = False #asumo que la data esta sin flip |
|
544 | self.dataOut.flagDeflipData = False #asumo que la data esta sin flip | |
546 |
|
545 | |||
547 | self.dataOut.flagShiftFFT = False |
|
546 | self.dataOut.flagShiftFFT = False | |
548 |
|
547 | |||
549 | self.dataOut.ippSeconds = self.ippSeconds |
|
548 | self.dataOut.ippSeconds = self.ippSeconds | |
550 |
|
549 | |||
551 | #Time interval between profiles |
|
550 | #Time interval between profiles | |
552 | #self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt |
|
551 | #self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt | |
553 |
|
552 | |||
554 | self.dataOut.frequency = self.__frequency |
|
553 | self.dataOut.frequency = self.__frequency | |
555 | self.dataOut.realtime = self.online |
|
554 | self.dataOut.realtime = self.online | |
556 | pass |
|
555 | pass | |
557 |
|
556 | |||
558 | def readNextFile(self,online=False): |
|
557 | def readNextFile(self,online=False): | |
559 |
|
558 | |||
560 | if not(online): |
|
559 | if not(online): | |
561 | newFile = self.__setNextFileOffline() |
|
560 | newFile = self.__setNextFileOffline() | |
562 | else: |
|
561 | else: | |
563 | newFile = self.__setNextFileOnline() |
|
562 | newFile = self.__setNextFileOnline() | |
564 |
|
563 | |||
565 | if not(newFile): |
|
564 | if not(newFile): | |
566 | self.dataOut.error = True |
|
565 | self.dataOut.error = True | |
567 | return 0 |
|
566 | return 0 | |
568 |
|
567 | |||
569 | if not self.readAMISRHeader(self.amisrFilePointer): |
|
568 | if not self.readAMISRHeader(self.amisrFilePointer): | |
570 | self.dataOut.error = True |
|
569 | self.dataOut.error = True | |
571 | return 0 |
|
570 | return 0 | |
572 |
|
571 | |||
573 | self.createBuffers() |
|
572 | self.createBuffers() | |
574 | self.fillJROHeader() |
|
573 | self.fillJROHeader() | |
575 |
|
574 | |||
576 | #self.__firstFile = False |
|
575 | #self.__firstFile = False | |
577 |
|
576 | |||
578 |
|
577 | |||
579 |
|
578 | |||
580 | self.dataset,self.timeset = self.readData() |
|
579 | self.dataset,self.timeset = self.readData() | |
581 |
|
580 | |||
582 | if self.endDate!=None: |
|
581 | if self.endDate!=None: | |
583 | endDateTime_Reader = datetime.datetime.combine(self.endDate,self.endTime) |
|
582 | endDateTime_Reader = datetime.datetime.combine(self.endDate,self.endTime) | |
584 | time_str = self.amisrFilePointer.get('Time/RadacTimeString') |
|
583 | time_str = self.amisrFilePointer.get('Time/RadacTimeString') | |
585 | startDateTimeStr_File = time_str[0][0].decode('UTF-8').split('.')[0] |
|
584 | startDateTimeStr_File = time_str[0][0].decode('UTF-8').split('.')[0] | |
586 | junk = time.strptime(startDateTimeStr_File, '%Y-%m-%d %H:%M:%S') |
|
585 | junk = time.strptime(startDateTimeStr_File, '%Y-%m-%d %H:%M:%S') | |
587 | startDateTime_File = datetime.datetime(junk.tm_year,junk.tm_mon,junk.tm_mday,junk.tm_hour, junk.tm_min, junk.tm_sec) |
|
586 | startDateTime_File = datetime.datetime(junk.tm_year,junk.tm_mon,junk.tm_mday,junk.tm_hour, junk.tm_min, junk.tm_sec) | |
588 | if self.timezone == 'lt': |
|
587 | if self.timezone == 'lt': | |
589 | startDateTime_File = startDateTime_File - datetime.timedelta(minutes = 300) |
|
588 | startDateTime_File = startDateTime_File - datetime.timedelta(minutes = 300) | |
590 | if (startDateTime_File>endDateTime_Reader): |
|
589 | if (startDateTime_File>endDateTime_Reader): | |
591 | return 0 |
|
590 | return 0 | |
592 |
|
591 | |||
593 | self.jrodataset = self.reshapeData() |
|
592 | self.jrodataset = self.reshapeData() | |
594 | #----self.updateIndexes() |
|
593 | #----self.updateIndexes() | |
595 | self.profileIndex = 0 |
|
594 | self.profileIndex = 0 | |
596 |
|
595 | |||
597 | return 1 |
|
596 | return 1 | |
598 |
|
597 | |||
599 |
|
598 | |||
600 | def __hasNotDataInBuffer(self): |
|
599 | def __hasNotDataInBuffer(self): | |
601 | if self.profileIndex >= (self.newProfiles*self.nblocks): |
|
600 | if self.profileIndex >= (self.newProfiles*self.nblocks): | |
602 | return 1 |
|
601 | return 1 | |
603 | return 0 |
|
602 | return 0 | |
604 |
|
603 | |||
605 |
|
604 | |||
606 | def getData(self): |
|
605 | def getData(self): | |
607 |
|
606 | |||
608 | if self.flagNoMoreFiles: |
|
607 | if self.flagNoMoreFiles: | |
609 | self.dataOut.flagNoData = True |
|
608 | self.dataOut.flagNoData = True | |
610 | return 0 |
|
609 | return 0 | |
611 |
|
610 | |||
612 | if self.__hasNotDataInBuffer(): |
|
611 | if self.__hasNotDataInBuffer(): | |
613 | if not (self.readNextFile(self.online)): |
|
612 | if not (self.readNextFile(self.online)): | |
614 | return 0 |
|
613 | return 0 | |
615 |
|
614 | |||
616 |
|
615 | |||
617 | if self.dataset is None: # setear esta condicion cuando no hayan datos por leer |
|
616 | if self.dataset is None: # setear esta condicion cuando no hayan datos por leer | |
618 | self.dataOut.flagNoData = True |
|
617 | self.dataOut.flagNoData = True | |
619 | return 0 |
|
618 | return 0 | |
620 |
|
619 | |||
621 | #self.dataOut.data = numpy.reshape(self.jrodataset[self.profileIndex,:],(1,-1)) |
|
620 | #self.dataOut.data = numpy.reshape(self.jrodataset[self.profileIndex,:],(1,-1)) | |
622 |
|
621 | |||
623 | self.dataOut.data = self.jrodataset[:,self.profileIndex,:] |
|
622 | self.dataOut.data = self.jrodataset[:,self.profileIndex,:] | |
624 |
|
623 | |||
625 | #print("R_t",self.timeset) |
|
624 | #print("R_t",self.timeset) | |
626 |
|
625 | |||
627 | #self.dataOut.utctime = self.jrotimeset[self.profileIndex] |
|
626 | #self.dataOut.utctime = self.jrotimeset[self.profileIndex] | |
628 | #verificar basic header de jro data y ver si es compatible con este valor |
|
627 | #verificar basic header de jro data y ver si es compatible con este valor | |
629 | #self.dataOut.utctime = self.timeset + (self.profileIndex * self.ippSeconds * self.nchannels) |
|
628 | #self.dataOut.utctime = self.timeset + (self.profileIndex * self.ippSeconds * self.nchannels) | |
630 | indexprof = numpy.mod(self.profileIndex, self.newProfiles) |
|
629 | indexprof = numpy.mod(self.profileIndex, self.newProfiles) | |
631 | indexblock = self.profileIndex/self.newProfiles |
|
630 | indexblock = self.profileIndex/self.newProfiles | |
632 | #print (indexblock, indexprof) |
|
631 | #print (indexblock, indexprof) | |
633 | diffUTC = 1.8e4 #UTC diference from peru in seconds --Joab |
|
632 | diffUTC = 1.8e4 #UTC diference from peru in seconds --Joab | |
634 | diffUTC = 0 |
|
633 | diffUTC = 0 | |
635 | t_comp = (indexprof * self.ippSeconds * self.nchannels) + diffUTC # |
|
634 | t_comp = (indexprof * self.ippSeconds * self.nchannels) + diffUTC # | |
636 |
|
635 | |||
637 | #print("utc :",indexblock," __ ",t_comp) |
|
636 | #print("utc :",indexblock," __ ",t_comp) | |
638 | #print(numpy.shape(self.timeset)) |
|
637 | #print(numpy.shape(self.timeset)) | |
639 | self.dataOut.utctime = self.timeset[numpy.int_(indexblock)] + t_comp |
|
638 | self.dataOut.utctime = self.timeset[numpy.int_(indexblock)] + t_comp | |
640 | #self.dataOut.utctime = self.timeset[self.profileIndex] + t_comp |
|
639 | #self.dataOut.utctime = self.timeset[self.profileIndex] + t_comp | |
641 | #print(self.dataOut.utctime) |
|
640 | #print(self.dataOut.utctime) | |
642 | self.dataOut.profileIndex = self.profileIndex |
|
641 | self.dataOut.profileIndex = self.profileIndex | |
643 | self.dataOut.flagNoData = False |
|
642 | self.dataOut.flagNoData = False | |
644 | # if indexprof == 0: |
|
643 | # if indexprof == 0: | |
645 | # print self.dataOut.utctime |
|
644 | # print self.dataOut.utctime | |
646 |
|
645 | |||
647 | self.profileIndex += 1 |
|
646 | self.profileIndex += 1 | |
648 |
|
647 | |||
649 | return self.dataOut.data |
|
648 | return self.dataOut.data | |
650 |
|
649 | |||
651 |
|
650 | |||
652 | def run(self, **kwargs): |
|
651 | def run(self, **kwargs): | |
653 | ''' |
|
652 | ''' | |
654 | This method will be called many times so here you should put all your code |
|
653 | This method will be called many times so here you should put all your code | |
655 | ''' |
|
654 | ''' | |
656 | #print("running kamisr") |
|
655 | #print("running kamisr") | |
657 | if not self.isConfig: |
|
656 | if not self.isConfig: | |
658 | self.setup(**kwargs) |
|
657 | self.setup(**kwargs) | |
659 | self.isConfig = True |
|
658 | self.isConfig = True | |
660 |
|
659 | |||
661 | self.getData() |
|
660 | self.getData() |
@@ -1,25 +1,24 | |||||
1 | #!/bin/bash |
|
1 | #!/bin/bash | |
2 | #source ~/virtuals/virtual_schain3x/bin/activate |
|
2 | #source ~/virtuals/virtual_schain3x/bin/activate | |
3 | echo "Amisr EEJ Online simulation" |
|
3 | echo "Amisr EEJ Online simulation" | |
4 |
|
4 | |||
5 |
PATH_IN=/ |
|
5 | PATH_IN=/media/soporte/DATA/dataAMISR/20210717.001/ | |
6 |
PATH_OUT=/home/soporte/ |
|
6 | PATH_OUT=/home/soporte/Data/OutTest/ONLINE/20210717.001/ | |
7 | count=0 |
|
7 | count=0 | |
8 | for f in $PATH_IN* |
|
8 | for f in $PATH_IN* | |
9 | do |
|
9 | do | |
10 | if [ ${f: -3} == ".h5" ] |
|
10 | if [ ${f: -3} == ".h5" ] | |
11 | then |
|
11 | then | |
12 | echo "coping $f" |
|
12 | echo "copying $f" | |
13 | cp ${f} $PATH_OUT |
|
13 | cp ${f} $PATH_OUT | |
14 | sleep 5m #it takes about 5 minutes to generate new data in AMISR radar |
|
14 | echo "waiting new file..." | |
|
15 | sleep 1m #it takes about 5 minutes to generate new data in AMISR radar | |||
15 | fi |
|
16 | fi | |
16 | ((count=count+1)) |
|
17 | ((count=count+1)) | |
17 |
|
18 | |||
18 |
if [ $count -eq |
|
19 | if [ $count -eq 10 ] #only transfer 20 files | |
19 | then |
|
20 | then | |
20 | echo " finish simulation" |
|
21 | echo " finish simulation" | |
21 | break |
|
22 | break | |
22 | fi |
|
23 | fi | |
23 | done |
|
24 | done | |
24 |
|
||||
25 |
|
@@ -1,25 +1,24 | |||||
1 | #!/bin/bash |
|
1 | #!/bin/bash | |
2 |
|
2 | |||
3 | echo "Amisr ESF Online simulation" |
|
3 | echo "Amisr ESF Online simulation" | |
4 |
|
4 | |||
5 |
PATH_IN=/ |
|
5 | PATH_IN=/media/soporte/DATA/dataAMISR/20210716.003/ | |
6 |
PATH_OUT=/home/soporte/ |
|
6 | PATH_OUT=/home/soporte/Data/OutTest/ONLINE/20210716.003/ | |
7 | count=0 |
|
7 | count=0 | |
8 | for f in $PATH_IN* |
|
8 | for f in $PATH_IN* | |
9 | do |
|
9 | do | |
10 | if [ ${f: -3} == ".h5" ] |
|
10 | if [ ${f: -3} == ".h5" ] | |
11 | then |
|
11 | then | |
12 | echo "coping $f" |
|
12 | echo "copying $f" | |
13 | cp ${f} $PATH_OUT |
|
13 | cp ${f} $PATH_OUT | |
14 | sleep 5m #it takes about 5 minutes to generate new data in AMISR radar |
|
14 | echo "waiting new file..." | |
|
15 | sleep 3m #it takes about 5 minutes to generate new data in AMISR radar | |||
15 | fi |
|
16 | fi | |
16 | ((count=count+1)) |
|
17 | ((count=count+1)) | |
17 |
|
18 | |||
18 |
if [ $count -eq |
|
19 | if [ $count -eq 10 ] #only transfer 20 files | |
19 | then |
|
20 | then | |
20 | echo " finish simulation" |
|
21 | echo " finish simulation" | |
21 | break |
|
22 | break | |
22 | fi |
|
23 | fi | |
23 | done |
|
24 | done | |
24 |
|
||||
25 |
|
@@ -1,204 +1,202 | |||||
1 |
|
1 | |||
2 | import os, sys |
|
2 | import os, sys | |
3 | import time |
|
3 | import time | |
4 | import datetime |
|
4 | import datetime | |
5 |
|
5 | |||
6 | path = os.path.dirname(os.getcwd()) |
|
6 | path = os.path.dirname(os.getcwd()) | |
7 | path = os.path.dirname(path) |
|
7 | path = os.path.dirname(path) | |
8 | sys.path.insert(0, path) |
|
8 | sys.path.insert(0, path) | |
9 |
|
9 | |||
10 | from schainpy.controller import Project |
|
10 | from schainpy.controller import Project | |
11 |
|
11 | |||
12 | def main(): |
|
12 | def main(): | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | desc = "AMISR EEJ Experiment" |
|
15 | desc = "AMISR EEJ Experiment" | |
16 | filename = "amisr_reader.xml" |
|
16 | filename = "amisr_reader.xml" | |
17 | xmin = '07' |
|
17 | xmin = '07' | |
18 | xmax = '18' |
|
18 | xmax = '18' | |
19 | xrange = int(xmax)-int(xmin) |
|
19 | xrange = int(xmax)-int(xmin) | |
20 | ymin = '0' |
|
20 | ||
21 | ymax = '300' |
|
|||
22 | dbmin = '45' #'60'#'55' #'40' #noise esf eej |
|
21 | dbmin = '45' #'60'#'55' #'40' #noise esf eej | |
23 | dbmax = '65' #'70' #'55' |
|
22 | dbmax = '65' #'70' #'55' | |
24 | showSPC = '0' #view plot Spectra |
|
23 | showSPC = '0' #view plot Spectra | |
25 | showRTI = '0' #view plot RTI |
|
24 | showRTI = '0' #view plot RTI | |
26 | showNOISE = '0' #view plot NOISE |
|
25 | showNOISE = '0' #view plot NOISE | |
27 | localtime='1' #para ajustar el horario en las gráficas '0' para dejar en utc |
|
26 | localtime='1' #para ajustar el horario en las gráficas '0' para dejar en utc | |
28 | code = '1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,1,-1,1' |
|
27 | code = '1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,1,-1,1' | |
29 | nCode = '1' |
|
28 | nCode = '1' | |
30 | nBaud = '28' |
|
29 | nBaud = '28' | |
31 | nosamp = '1' # oversample for EEJ |
|
30 | nosamp = '1' # oversample for EEJ | |
32 | today = time.strftime("%Y/%m/%d") |
|
31 | today = time.strftime("%Y/%m/%d") | |
33 | startDate=today |
|
32 | startDate=today | |
34 | endDate=today |
|
33 | endDate=today | |
35 |
#startDate='2021/07/1 |
|
34 | #startDate='2021/07/17' | |
36 |
#endDate='2021/07/1 |
|
35 | #endDate='2021/07/17' | |
37 | #inPath= '/home/soporte/dataAMISR_test/' |
|
36 | #inPath= '/home/soporte/dataAMISR_test/' | |
38 | inPath= '/home/soporte/dataAMISR/' |
|
37 | inPath= '/home/soporte/dataAMISR/' | |
39 | inPath= '/media/soporte/UARS_4T_D02/AMISR_DATA/2021/' |
|
38 | #inPath= '/media/soporte/UARS_4T_D02/AMISR_DATA/2021/' | |
40 | #inPath = '/home/soporte/' |
|
39 | #inPath = '/home/soporte/' | |
41 | outPath = '/home/soporte/Data/EEJ' |
|
40 | outPath = '/home/soporte/Data/EEJ' | |
42 |
|
41 | |||
43 | ##....................................................................................... |
|
42 | ##....................................................................................... | |
44 | ##....................................................................................... |
|
43 | ##....................................................................................... | |
45 |
|
44 | |||
46 | #l = startDate.split('/') #adding day of the year to outPath |
|
45 | #l = startDate.split('/') #adding day of the year to outPath | |
47 | l = startDate.split('/') |
|
46 | l = startDate.split('/') | |
48 | datelist = datetime.date(int(l[0]),int(l[1]),int(l[2])) |
|
47 | datelist = datetime.date(int(l[0]),int(l[1]),int(l[2])) | |
49 | DOY = datelist.timetuple().tm_yday |
|
48 | DOY = datelist.timetuple().tm_yday | |
50 | outPath= outPath+"/EEJ"+l[0]+str(DOY) |
|
49 | outPath= outPath+"/EEJ"+l[0]+str(DOY) | |
51 | if os.path.exists(outPath): |
|
50 | if os.path.exists(outPath): | |
52 | print("outPath", outPath) |
|
51 | print("outPath", outPath) | |
53 | else : |
|
52 | else : | |
54 | os.mkdir(outPath) |
|
53 | os.mkdir(outPath) | |
55 | print("Creating...", outPath) |
|
54 | print("Creating...", outPath) | |
56 |
|
55 | |||
57 | ##....................................................................................... |
|
56 | ##....................................................................................... | |
58 | ##....................................................................................... |
|
57 | ##....................................................................................... | |
59 | controllerObj = Project() |
|
58 | controllerObj = Project() | |
60 | controllerObj.setup(id = '11', name='eej_proc', description=desc) |
|
59 | controllerObj.setup(id = '11', name='eej_proc', description=desc) | |
61 | ##....................................................................................... |
|
60 | ##....................................................................................... | |
62 | ##....................................................................................... |
|
61 | ##....................................................................................... | |
63 | readUnitConfObj = controllerObj.addReadUnit(datatype='AMISRReader', |
|
62 | readUnitConfObj = controllerObj.addReadUnit(datatype='AMISRReader', | |
64 | path=inPath, |
|
63 | path=inPath, | |
65 | startDate=startDate,#startDate, #'2014/10/07', |
|
64 | startDate=startDate,#startDate, #'2014/10/07', | |
66 | endDate=endDate, #endDate '2014/10/07', |
|
65 | endDate=endDate, #endDate '2014/10/07', | |
67 |
startTime='07:00: |
|
66 | startTime='07:00:30',#'07:00:00', | |
68 |
endTime='18:00: |
|
67 | endTime='18:00:10',#'15:00:00', | |
69 | walk=1, |
|
68 | walk=1, | |
70 | code = code, |
|
69 | code = code, | |
71 | nCode = nCode, |
|
70 | nCode = nCode, | |
72 | nBaud = nBaud, |
|
71 | nBaud = nBaud, | |
73 | timezone='lt', |
|
72 | timezone='lt', | |
74 | online=0) |
|
73 | online=0) | |
75 |
|
74 | |||
76 |
|
75 | |||
77 | # #AMISR Processing Unit |
|
76 | # #AMISR Processing Unit | |
78 | # ##....................................................................................... |
|
77 | # ##....................................................................................... | |
79 | # ##....................................................................................... |
|
78 | # ##....................................................................................... | |
80 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
79 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
81 | opObj10 = procUnitConfObj0.addOperation(name='setAttribute') |
|
80 | opObj10 = procUnitConfObj0.addOperation(name='setAttribute') | |
82 | opObj10.addParameter(name='frequency', value='445.09e6') |
|
81 | opObj10.addParameter(name='frequency', value='445.09e6') | |
83 | # opObj10 = procUnitConfObj0.addOperation(name='setRadarFrequency') |
|
82 | # opObj10 = procUnitConfObj0.addOperation(name='setRadarFrequency') | |
84 | # opObj10.addParameter(name='frequency', value='445e6', format='float') |
|
83 | # opObj10.addParameter(name='frequency', value='445e6', format='float') | |
85 |
|
84 | |||
86 |
|
85 | |||
87 | opObj01 = procUnitConfObj0.addOperation(name='Decoder', optype='other') |
|
86 | opObj01 = procUnitConfObj0.addOperation(name='Decoder', optype='other') | |
88 | opObj01.addParameter(name='code', value=code, format='floatlist') |
|
87 | opObj01.addParameter(name='code', value=code, format='floatlist') | |
89 | opObj01.addParameter(name='nCode', value=nCode, format='int') |
|
88 | opObj01.addParameter(name='nCode', value=nCode, format='int') | |
90 | opObj01.addParameter(name='nBaud', value=nBaud, format='int') |
|
89 | opObj01.addParameter(name='nBaud', value=nBaud, format='int') | |
91 | opObj01.addParameter(name='osamp', value=nosamp, format='int') |
|
90 | opObj01.addParameter(name='osamp', value=nosamp, format='int') | |
92 |
|
91 | |||
93 |
|
92 | |||
94 | # opObj02 = procUnitConfObj0.addOperation(name='CohInt', optype='other') |
|
93 | # opObj02 = procUnitConfObj0.addOperation(name='CohInt', optype='other') | |
95 | # opObj02.addParameter(name='n', value='2', format='int') |
|
94 | # opObj02.addParameter(name='n', value='2', format='int') | |
96 |
|
95 | |||
97 | # |
|
96 | # | |
98 | # |
|
97 | # | |
99 | # ##....................................................................................... |
|
98 | # ##....................................................................................... | |
100 | # ##....................................................................................... |
|
99 | # ##....................................................................................... | |
101 |
|
100 | |||
102 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId()) |
|
101 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId()) | |
103 | procUnitConfObj1.addParameter(name='nFFTPoints', value='16', format='int') |
|
102 | procUnitConfObj1.addParameter(name='nFFTPoints', value='16', format='int') | |
104 |
|
103 | |||
105 |
|
104 | |||
106 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') |
|
105 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
107 | opObj11.addParameter(name='n', value='150', format='int') #300? |
|
106 | opObj11.addParameter(name='n', value='150', format='int') #300? | |
108 |
|
107 | |||
109 | ## Remove DC signal |
|
108 | ## Remove DC signal | |
110 | opObj11 = procUnitConfObj1.addOperation(name='removeDC') |
|
109 | ##opObj11 = procUnitConfObj1.addOperation(name='removeDC') | |
111 | ##....................................................................................... |
|
110 | ##....................................................................................... | |
112 | ##....................................................................................... |
|
111 | ##....................................................................................... | |
113 |
|
112 | |||
114 | # opObj13 = procUnitConfObj1.addOperation(name='getNoise' , optype ='self') |
|
113 | # opObj13 = procUnitConfObj1.addOperation(name='getNoise' , optype ='self') | |
115 | # opObj13.addParameter(name='minHei', value='100', format='float') |
|
114 | # opObj13.addParameter(name='minHei', value='100', format='float') | |
116 | # opObj13.addParameter(name='maxHei', value='280', format='float') |
|
115 | # opObj13.addParameter(name='maxHei', value='280', format='float') | |
117 |
|
116 | |||
118 |
|
117 | |||
119 | # |
|
118 | # | |
120 | opObj12 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
119 | opObj12 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
121 | opObj12.addParameter(name='id', value='21', format='int') |
|
120 | opObj12.addParameter(name='id', value='21', format='int') | |
122 | opObj12.addParameter(name= 'xaxis', value='velocity') |
|
121 | opObj12.addParameter(name= 'xaxis', value='velocity') | |
123 | opObj12.addParameter(name='ymax', value=ymax, format='int') |
|
|||
124 | opObj12.addParameter(name='showprofile', value='1', format='int') |
|
122 | opObj12.addParameter(name='showprofile', value='1', format='int') | |
125 | opObj12.addParameter(name='wintitle', value='AMISR Beam 0', format='str') |
|
123 | opObj12.addParameter(name='wintitle', value='AMISR Beam 0', format='str') | |
126 | opObj12.addParameter(name='zmin', value=dbmin, format='int') |
|
124 | opObj12.addParameter(name='zmin', value=dbmin, format='int') | |
127 | opObj12.addParameter(name='zmax', value=dbmax, format='int') |
|
125 | opObj12.addParameter(name='zmax', value=dbmax, format='int') | |
128 | opObj12.addParameter(name='save', value=outPath+'/plots', format='str') |
|
126 | opObj12.addParameter(name='save', value=outPath+'/plots', format='str') | |
129 | opObj12.addParameter(name='colormap', value='jet', format='str') |
|
127 | opObj12.addParameter(name='colormap', value='jet', format='str') | |
130 | opObj12.addParameter(name='localtime', value=localtime,format='int') |
|
128 | opObj12.addParameter(name='localtime', value=localtime,format='int') | |
131 | opObj12.addParameter(name='show', value = showSPC, format='int') |
|
129 | opObj12.addParameter(name='show', value = showSPC, format='int') | |
132 |
|
130 | |||
133 |
|
131 | |||
134 | ##Generate *.pdata from AMISR data |
|
132 | ##Generate *.pdata from AMISR data | |
135 | ##....................................................................................... |
|
133 | ##....................................................................................... | |
136 | ##....................................................................................... |
|
134 | ##....................................................................................... | |
137 | opObj13 = procUnitConfObj1.addOperation(name='SpectraWriter', optype='external') |
|
135 | opObj13 = procUnitConfObj1.addOperation(name='SpectraWriter', optype='external') | |
138 | opObj13.addParameter(name='path', value=outPath) |
|
136 | opObj13.addParameter(name='path', value=outPath) | |
139 | opObj13.addParameter(name='blocksPerFile', value='10', format='int') |
|
137 | opObj13.addParameter(name='blocksPerFile', value='10', format='int') | |
140 |
|
138 | |||
141 |
|
139 | |||
142 | opObj14 = procUnitConfObj1.addOperation(name='NoisePlot', optype='external') |
|
140 | opObj14 = procUnitConfObj1.addOperation(name='NoisePlot', optype='external') | |
143 | opObj14.addParameter(name='id', value='3', format='int') |
|
141 | opObj14.addParameter(name='id', value='3', format='int') | |
144 | opObj14.addParameter(name='wintitle', value='title0', format='str') |
|
142 | opObj14.addParameter(name='wintitle', value='title0', format='str') | |
145 | opObj14.addParameter(name='showprofile', value='0', format='int') |
|
143 | opObj14.addParameter(name='showprofile', value='0', format='int') | |
146 | opObj14.addParameter(name='tmin', value=xmin, format='int') |
|
144 | opObj14.addParameter(name='tmin', value=xmin, format='int') | |
147 | opObj14.addParameter(name='xrange', value=xrange, format='int') |
|
145 | opObj14.addParameter(name='xrange', value=xrange, format='int') | |
148 | opObj14.addParameter(name='ymin', value=dbmin, format='int') |
|
146 | opObj14.addParameter(name='ymin', value=dbmin, format='int') | |
149 | opObj14.addParameter(name='ymax', value=dbmax, format='int') |
|
147 | opObj14.addParameter(name='ymax', value=dbmax, format='int') | |
150 | opObj14.addParameter(name='save', value=outPath+'/plots', format='str') |
|
148 | opObj14.addParameter(name='save', value=outPath+'/plots', format='str') | |
151 | opObj14.addParameter(name='localtime', value=localtime,format='int') |
|
149 | opObj14.addParameter(name='localtime', value=localtime,format='int') | |
152 | opObj14.addParameter(name='show', value = showNOISE, format='int') |
|
150 | opObj14.addParameter(name='show', value = showNOISE, format='int') | |
153 |
|
151 | |||
154 | # # |
|
152 | # # | |
155 | opObj15 = procUnitConfObj1.addOperation(name='RTIPlot', optype='external') |
|
153 | opObj15 = procUnitConfObj1.addOperation(name='RTIPlot', optype='external') | |
156 | opObj15.addParameter(name='id', value='2', format='int') |
|
154 | opObj15.addParameter(name='id', value='2', format='int') | |
157 | opObj15.addParameter(name='localtime', value=localtime,format='int') |
|
155 | opObj15.addParameter(name='localtime', value=localtime,format='int') | |
158 | opObj15.addParameter(name='wintitle', value='RTI', format='str') |
|
156 | opObj15.addParameter(name='wintitle', value='RTI', format='str') | |
159 | opObj15.addParameter(name='tmin', value=xmin, format='int') |
|
157 | opObj15.addParameter(name='tmin', value=xmin, format='int') | |
160 | opObj15.addParameter(name='xrange', value=xrange, format='int') |
|
158 | opObj15.addParameter(name='xrange', value=xrange, format='int') | |
161 | opObj15.addParameter(name='ymin', value=ymin, format='int') |
|
159 | opObj15.addParameter(name='ymin', value=ymin, format='int') | |
162 | opObj15.addParameter(name='zmin', value=dbmin, format='int') |
|
160 | opObj15.addParameter(name='zmin', value=dbmin, format='int') | |
163 | opObj15.addParameter(name='zmax', value=dbmax, format='int') |
|
161 | opObj15.addParameter(name='zmax', value=dbmax, format='int') | |
164 | opObj15.addParameter(name='showprofile', value='0', format='int') |
|
162 | opObj15.addParameter(name='showprofile', value='0', format='int') | |
165 | opObj15.addParameter(name='save', value=outPath+'/plots', format='str') |
|
163 | opObj15.addParameter(name='save', value=outPath+'/plots', format='str') | |
166 | opObj15.addParameter(name='colormap', value='jet', format='str') |
|
164 | opObj15.addParameter(name='colormap', value='jet', format='str') | |
167 | opObj15.addParameter(name='show', value = showRTI, format='int') |
|
165 | opObj15.addParameter(name='show', value = showRTI, format='int') | |
168 |
|
166 | |||
169 |
|
167 | |||
170 |
|
168 | |||
171 | ##....................................................................................... |
|
169 | ##....................................................................................... | |
172 | ##....................................................................................... |
|
170 | ##....................................................................................... | |
173 | # |
|
171 | # | |
174 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj1.getId()) |
|
172 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj1.getId()) | |
175 | # opObj16 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other') |
|
173 | # opObj16 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other') | |
176 |
|
174 | |||
177 |
|
175 | |||
178 | #Using HDFWriter:::: |
|
176 | #Using HDFWriter:::: | |
179 | #....................................................................................... |
|
177 | #....................................................................................... | |
180 | #....................................................................................... |
|
178 | #....................................................................................... | |
181 | # opObj17 = procUnitConfObj2.addOperation(name='HDFWriter', optype='external') |
|
179 | # opObj17 = procUnitConfObj2.addOperation(name='HDFWriter', optype='external') | |
182 | # opObj17.addParameter(name='path', value=outPath) |
|
180 | # opObj17.addParameter(name='path', value=outPath) | |
183 | # opObj17.addParameter(name='blocksPerFile', value='10', format='int') |
|
181 | # opObj17.addParameter(name='blocksPerFile', value='10', format='int') | |
184 | # opObj17.addParameter(name='metadataList',value='type,inputUnit,heightList',format='list') |
|
182 | # opObj17.addParameter(name='metadataList',value='type,inputUnit,heightList',format='list') | |
185 | # opObj17.addParameter(name='dataList',value='moments,data_SNR,utctime',format='list') |
|
183 | # opObj17.addParameter(name='dataList',value='moments,data_SNR,utctime',format='list') | |
186 |
|
184 | |||
187 |
|
185 | |||
188 |
|
186 | |||
189 | ##....................................................................................... |
|
187 | ##....................................................................................... | |
190 | ##....................................................................................... |
|
188 | ##....................................................................................... | |
191 | #print("Escribiendo el archivo XML",controllerObj.writeXml(outPath +'/'+filename)) |
|
189 | #print("Escribiendo el archivo XML",controllerObj.writeXml(outPath +'/'+filename)) | |
192 |
|
190 | |||
193 | controllerObj.start() |
|
191 | controllerObj.start() | |
194 |
|
192 | |||
195 | #print("Leyendo el archivo XML",controllerObj.readXml(outPath +'/'+filename)) |
|
193 | #print("Leyendo el archivo XML",controllerObj.readXml(outPath +'/'+filename)) | |
196 |
|
194 | |||
197 | ##....................................................................................... |
|
195 | ##....................................................................................... | |
198 | ##....................................................................................... |
|
196 | ##....................................................................................... | |
199 |
|
197 | |||
200 | if __name__ == '__main__': |
|
198 | if __name__ == '__main__': | |
201 | import time |
|
199 | import time | |
202 | start_time = time.time() |
|
200 | start_time = time.time() | |
203 | main() |
|
201 | main() | |
204 | print("--- %s seconds ---" % (time.time() - start_time)) |
|
202 | print("--- %s seconds ---" % (time.time() - start_time)) |
@@ -1,161 +1,169 | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | import os, sys |
|
2 | import os, sys | |
3 | import time |
|
3 | import time | |
4 | import datetime |
|
4 | import datetime | |
5 |
|
5 | |||
6 | path = os.path.dirname(os.getcwd()) |
|
6 | path = os.path.dirname(os.getcwd()) | |
7 | path = os.path.dirname(path) |
|
7 | path = os.path.dirname(path) | |
8 | sys.path.insert(0, path) |
|
8 | sys.path.insert(0, path) | |
9 |
|
9 | |||
10 | from schainpy.controller import Project |
|
10 | from schainpy.controller import Project | |
11 |
|
11 | |||
12 | def main(): |
|
12 | def main(): | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | desc = "AMISR EEJ Experiment" |
|
15 | desc = "AMISR EEJ Experiment" | |
16 | filename = "amisr_reader.xml" |
|
16 | filename = "amisr_reader.xml" | |
17 | xmin = '07' |
|
17 | xmin = '07' | |
18 | xmax = '18' # |
|
18 | xmax = '18' # | |
19 | xrange = int(xmax)-int(xmin) |
|
19 | xrange = int(xmax)-int(xmin) | |
20 |
|
20 | |||
21 | dbmin = '45' #'60'#'55' #'40' #noise esf eej |
|
21 | dbmin = '45' #'60'#'55' #'40' #noise esf eej | |
22 | dbmax = '65' #'70' #'55' |
|
22 | dbmax = '65' #'70' #'55' | |
23 |
showSPC = ' |
|
23 | showSPC = '0' #view plot Spectra | |
24 |
showRTI = ' |
|
24 | showRTI = '0' #view plot RTI | |
25 |
showNOISE = ' |
|
25 | showNOISE = '0' #view plot NOISE | |
26 | localtime='1' #para ajustar el horario en las gráficas '0' para dejar en utc |
|
26 | localtime='1' #para ajustar el horario en las gráficas '0' para dejar en utc | |
27 | code = '1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,1,-1,1' |
|
27 | code = '1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,1,-1,1' | |
28 | nCode = '1' |
|
28 | nCode = '1' | |
29 | nBaud = '28' |
|
29 | nBaud = '28' | |
30 | nosamp = '1' # oversample for EEJ |
|
30 | nosamp = '1' # oversample for EEJ | |
31 | str0 = datetime.date.today() |
|
31 | str0 = datetime.date.today() | |
32 | today = str0.strftime("%Y/%m/%d") |
|
32 | today = str0.strftime("%Y/%m/%d") | |
33 | startDate=today |
|
33 | startDate=today | |
34 | endDate=today |
|
34 | endDate=today | |
35 |
#startDate='20 |
|
35 | #startDate='2021/07/17' | |
36 |
#endDate='20 |
|
36 | #endDate='2021/07/17' | |
37 |
#inPath= '/home/soporte/ |
|
37 | #inPath= '/home/soporte/Data/OutTest/ONLINE/' | |
38 | #inPath= '/home/soporte/dataAMISR/' |
|
38 | #inPath= '/home/soporte/dataAMISR/' | |
39 | inPath = '/mnt/data_amisr' |
|
39 | inPath = '/mnt/data_amisr' | |
40 | outPath = '/home/soporte/Data/EEJ' |
|
40 | outPath = '/home/soporte/Data/EEJ' | |
41 |
|
41 | |||
42 | ##....................................................................................... |
|
42 | ##....................................................................................... | |
43 | ##....................................................................................... |
|
43 | ##....................................................................................... | |
44 |
|
44 | |||
45 | l = startDate.split('/') #adding day of the year to outPath |
|
45 | l = startDate.split('/') #adding day of the year to outPath | |
46 | datelist = datetime.date(int(l[0]),int(l[1]),int(l[2])) |
|
46 | datelist = datetime.date(int(l[0]),int(l[1]),int(l[2])) | |
47 | DOY = datelist.timetuple().tm_yday |
|
47 | DOY = datelist.timetuple().tm_yday | |
48 | outPath= outPath+"/EEJ"+l[0]+str(DOY) |
|
48 | outPath= outPath+"/EEJ"+l[0]+str(DOY) | |
49 | if os.path.exists(outPath): |
|
49 | if os.path.exists(outPath): | |
50 | print("outPath", outPath) |
|
50 | print("outPath", outPath) | |
51 | else : |
|
51 | else : | |
52 | os.mkdir(outPath) |
|
52 | os.mkdir(outPath) | |
53 | print("Creating...", outPath) |
|
53 | print("Creating...", outPath) | |
54 | ##....................................................................................... |
|
54 | ##....................................................................................... | |
55 | ##....................................................................................... |
|
55 | ##....................................................................................... | |
56 | controllerObj = Project() |
|
56 | controllerObj = Project() | |
57 | controllerObj.setup(id = '10', name='eej_proc', description=desc) |
|
57 | controllerObj.setup(id = '10', name='eej_proc', description=desc) | |
58 | ##....................................................................................... |
|
58 | ##....................................................................................... | |
59 | ##....................................................................................... |
|
59 | ##....................................................................................... | |
60 | readUnitConfObj = controllerObj.addReadUnit(datatype='AMISRReader', |
|
60 | readUnitConfObj = controllerObj.addReadUnit(datatype='AMISRReader', | |
61 | path=inPath, |
|
61 | path=inPath, | |
62 | startDate=startDate, |
|
62 | startDate=startDate, | |
63 | endDate=endDate, |
|
63 | endDate=endDate, | |
64 |
startTime='07:01: |
|
64 | startTime='07:01:00',#'07:00:00', | |
65 | endTime='17:55:00',#'15:00:00', |
|
65 | endTime='17:55:00',#'15:00:00', | |
66 | walk=0, |
|
66 | walk=0, | |
67 | code = code, |
|
67 | code = code, | |
68 | nCode = nCode, |
|
68 | nCode = nCode, | |
69 | nBaud = nBaud, |
|
69 | nBaud = nBaud, | |
70 | timezone='lt', |
|
70 | timezone='lt', | |
71 | online=1) |
|
71 | online=1) | |
72 |
|
72 | |||
73 | #AMISR Processing Unit |
|
73 | #AMISR Processing Unit | |
74 | ##....................................................................................... |
|
74 | ##....................................................................................... | |
75 | ##....................................................................................... |
|
75 | ##....................................................................................... | |
76 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
76 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
77 | opObj10 = procUnitConfObj0.addOperation(name='setAttribute') |
|
77 | opObj10 = procUnitConfObj0.addOperation(name='setAttribute') | |
78 | opObj10.addParameter(name='frequency', value='445.0e6') |
|
78 | opObj10.addParameter(name='frequency', value='445.0e6') | |
79 |
|
79 | |||
80 |
|
80 | |||
81 | opObj01 = procUnitConfObj0.addOperation(name='Decoder', optype='other') |
|
81 | opObj01 = procUnitConfObj0.addOperation(name='Decoder', optype='other') | |
82 | opObj01.addParameter(name='code', value=code, format='floatlist') |
|
82 | opObj01.addParameter(name='code', value=code, format='floatlist') | |
83 | opObj01.addParameter(name='nCode', value=nCode, format='int') |
|
83 | opObj01.addParameter(name='nCode', value=nCode, format='int') | |
84 | opObj01.addParameter(name='nBaud', value=nBaud, format='int') |
|
84 | opObj01.addParameter(name='nBaud', value=nBaud, format='int') | |
85 | opObj01.addParameter(name='osamp', value=nosamp, format='int') |
|
85 | opObj01.addParameter(name='osamp', value=nosamp, format='int') | |
86 |
|
86 | |||
87 |
|
87 | |||
88 |
|
88 | |||
89 |
|
89 | |||
90 |
|
90 | |||
91 | ##....................................................................................... |
|
91 | ##....................................................................................... | |
92 | ##....................................................................................... |
|
92 | ##....................................................................................... | |
93 |
|
93 | |||
94 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId()) |
|
94 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId()) | |
95 | procUnitConfObj1.addParameter(name='nFFTPoints', value='16', format='int') |
|
95 | procUnitConfObj1.addParameter(name='nFFTPoints', value='16', format='int') | |
96 |
|
96 | |||
97 |
|
97 | |||
98 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') |
|
98 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
99 | opObj11.addParameter(name='n', value='150', format='int') #300 normal value |
|
99 | opObj11.addParameter(name='n', value='150', format='int') #300 normal value | |
100 |
|
100 | |||
101 | ##....................................................................................... |
|
101 | ##....................................................................................... | |
102 | ##....................................................................................... |
|
102 | ##....................................................................................... | |
103 |
|
103 | |||
104 |
|
104 | |||
105 | # |
|
105 | # | |
106 | opObj12 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') |
|
106 | opObj12 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external') | |
107 | opObj12.addParameter(name='id', value='21', format='int') |
|
107 | opObj12.addParameter(name='id', value='21', format='int') | |
108 | opObj12.addParameter(name= 'xaxis', value='velocity') |
|
108 | opObj12.addParameter(name= 'xaxis', value='velocity') | |
109 | opObj12.addParameter(name='ymax', value=ymax, format='int') |
|
|||
110 | opObj12.addParameter(name='showprofile', value='1', format='int') |
|
109 | opObj12.addParameter(name='showprofile', value='1', format='int') | |
111 | opObj12.addParameter(name='wintitle', value='AMISR Beam 0', format='str') |
|
110 | opObj12.addParameter(name='wintitle', value='AMISR Beam 0', format='str') | |
112 | opObj12.addParameter(name='zmin', value=dbmin, format='int') |
|
111 | opObj12.addParameter(name='zmin', value=dbmin, format='int') | |
113 | opObj12.addParameter(name='zmax', value=dbmax, format='int') |
|
112 | opObj12.addParameter(name='zmax', value=dbmax, format='int') | |
114 | opObj12.addParameter(name='save', value=outPath+'/plots', format='str') |
|
113 | opObj12.addParameter(name='save', value=outPath+'/plots', format='str') | |
115 | opObj12.addParameter(name='colormap', value='jet', format='str') |
|
114 | opObj12.addParameter(name='colormap', value='jet', format='str') | |
116 | opObj12.addParameter(name='localtime', value=localtime,format='int') |
|
115 | opObj12.addParameter(name='localtime', value=localtime,format='int') | |
117 | opObj12.addParameter(name='show', value = showSPC, format='int') |
|
116 | opObj12.addParameter(name='show', value = showSPC, format='int') | |
118 |
|
117 | opObj12.addParameter(name='exp_code', value='206', format='int') | ||
|
118 | opObj12.addParameter(name='server', value='jro-realtime.igp.gob.pe:4444') | |||
|
119 | opObj12.addParameter(name='sender_period', value='120') | |||
|
120 | opObj12.addParameter(name='tag', value='AMISR') | |||
119 |
|
121 | |||
120 | opObj14 = procUnitConfObj1.addOperation(name='NoisePlot', optype='external') |
|
122 | opObj14 = procUnitConfObj1.addOperation(name='NoisePlot', optype='external') | |
121 | opObj14.addParameter(name='id', value='3', format='int') |
|
123 | opObj14.addParameter(name='id', value='3', format='int') | |
122 | opObj14.addParameter(name='wintitle', value='title0', format='str') |
|
124 | opObj14.addParameter(name='wintitle', value='title0', format='str') | |
123 | opObj14.addParameter(name='showprofile', value='0', format='int') |
|
125 | opObj14.addParameter(name='showprofile', value='0', format='int') | |
124 | opObj14.addParameter(name='tmin', value=xmin, format='int') |
|
126 | opObj14.addParameter(name='tmin', value=xmin, format='int') | |
125 | opObj14.addParameter(name='xrange', value=xrange, format='int') |
|
127 | opObj14.addParameter(name='xrange', value=xrange, format='int') | |
126 | opObj14.addParameter(name='ymin', value=dbmin, format='int') |
|
128 | opObj14.addParameter(name='ymin', value=dbmin, format='int') | |
127 | opObj14.addParameter(name='ymax', value=dbmax, format='int') |
|
129 | opObj14.addParameter(name='ymax', value=dbmax, format='int') | |
128 | opObj14.addParameter(name='save', value=outPath+'/plots', format='str') |
|
130 | opObj14.addParameter(name='save', value=outPath+'/plots', format='str') | |
129 | opObj14.addParameter(name='localtime', value=localtime,format='int') |
|
131 | opObj14.addParameter(name='localtime', value=localtime,format='int') | |
130 | opObj14.addParameter(name='show', value = showNOISE, format='int') |
|
132 | opObj14.addParameter(name='show', value = showNOISE, format='int') | |
131 |
|
133 | opObj14.addParameter(name='exp_code', value='206', format='int') | ||
|
134 | opObj14.addParameter(name='server', value='jro-realtime.igp.gob.pe:4444') | |||
|
135 | opObj14.addParameter(name='sender_period', value='120') | |||
|
136 | opObj14.addParameter(name='tag', value='AMISR') | |||
132 |
|
137 | |||
133 | opObj15 = procUnitConfObj1.addOperation(name='RTIPlot', optype='external') |
|
138 | opObj15 = procUnitConfObj1.addOperation(name='RTIPlot', optype='external') | |
134 | opObj15.addParameter(name='id', value='2', format='int') |
|
139 | opObj15.addParameter(name='id', value='2', format='int') | |
135 | opObj15.addParameter(name='localtime', value=localtime,format='int') |
|
140 | opObj15.addParameter(name='localtime', value=localtime,format='int') | |
136 | opObj15.addParameter(name='wintitle', value='RTI', format='str') |
|
141 | opObj15.addParameter(name='wintitle', value='RTI', format='str') | |
137 | opObj15.addParameter(name='tmin', value=xmin, format='int') |
|
142 | opObj15.addParameter(name='tmin', value=xmin, format='int') | |
138 | opObj15.addParameter(name='xrange', value=xrange, format='int') |
|
143 | opObj15.addParameter(name='xrange', value=xrange, format='int') | |
139 | opObj15.addParameter(name='zmin', value=dbmin, format='int') |
|
144 | opObj15.addParameter(name='zmin', value=dbmin, format='int') | |
140 | opObj15.addParameter(name='zmax', value=dbmax, format='int') |
|
145 | opObj15.addParameter(name='zmax', value=dbmax, format='int') | |
141 | opObj15.addParameter(name='showprofile', value='1', format='int') |
|
146 | opObj15.addParameter(name='showprofile', value='1', format='int') | |
142 | opObj15.addParameter(name='save', value=outPath+'/plots', format='str') |
|
147 | opObj15.addParameter(name='save', value=outPath+'/plots', format='str') | |
143 | opObj15.addParameter(name='colormap', value='jet', format='str') |
|
148 | opObj15.addParameter(name='colormap', value='jet', format='str') | |
144 | opObj15.addParameter(name='show', value = showRTI, format='int') |
|
149 | opObj15.addParameter(name='show', value = showRTI, format='int') | |
145 |
|
150 | opObj15.addParameter(name='exp_code', value='206', format='int') | ||
|
151 | opObj15.addParameter(name='server', value='jro-realtime.igp.gob.pe:4444') | |||
|
152 | opObj15.addParameter(name='sender_period', value='120') | |||
|
153 | opObj15.addParameter(name='tag', value='AMISR') | |||
146 |
|
154 | |||
147 |
|
155 | |||
148 | ##....................................................................................... |
|
156 | ##....................................................................................... | |
149 | ##....................................................................................... |
|
157 | ##....................................................................................... | |
150 | # |
|
158 | # | |
151 |
|
159 | |||
152 | controllerObj.start() |
|
160 | controllerObj.start() | |
153 |
|
161 | |||
154 | ##....................................................................................... |
|
162 | ##....................................................................................... | |
155 | ##....................................................................................... |
|
163 | ##....................................................................................... | |
156 |
|
164 | |||
157 | if __name__ == '__main__': |
|
165 | if __name__ == '__main__': | |
158 | import time |
|
166 | import time | |
159 | start_time = time.time() |
|
167 | start_time = time.time() | |
160 | main() |
|
168 | main() | |
161 | print("--- %s seconds ---" % (time.time() - start_time)) |
|
169 | print("--- %s seconds ---" % (time.time() - start_time)) |
@@ -1,232 +1,224 | |||||
1 | #!/usr/bin/env python |
|
1 | ||
2 | import os, sys |
|
2 | import os, sys | |
3 | import time |
|
3 | import time | |
4 | import datetime |
|
4 | import datetime | |
5 |
|
5 | |||
6 | ''' |
|
6 | ''' | |
7 | ESF 10 BEAM OFFLINE |
|
7 | ESF 10 BEAM OFFLINE | |
8 | ''' |
|
8 | ''' | |
9 | path = os.path.dirname(os.getcwd()) |
|
9 | path = os.path.dirname(os.getcwd()) | |
10 | path = os.path.dirname(path) |
|
10 | path = os.path.dirname(path) | |
11 | sys.path.insert(0, path) |
|
11 | sys.path.insert(0, path) | |
12 |
|
12 | |||
13 | from schainpy.controller import Project |
|
13 | from schainpy.controller import Project | |
14 |
|
14 | |||
15 |
|
15 | |||
16 | def main(): |
|
16 | def main(): | |
17 | desc = "AMISR ESF 10 Beam Experiment" |
|
17 | desc = "AMISR ESF 10 Beam Experiment" | |
18 |
|
18 | |||
19 | filename = "amisr_esf_reader.xml" |
|
19 | filename = "amisr_esf_reader.xml" | |
20 |
|
20 | |||
21 |
|
21 | |||
22 |
|
22 | |||
23 | #path = os.path.join(os.environ['HOME'],'amisr') |
|
23 | #path = os.path.join(os.environ['HOME'],'amisr') | |
24 | inPath = '/mnt/data_amisr' |
|
24 | inPath = '/mnt/data_amisr' | |
25 | inPath= '/home/soporte/dataAMISR/' |
|
25 | inPath= '/home/soporte/dataAMISR/' | |
26 | inPath= '/media/soporte/DATA/dataAMISR/' |
|
26 | inPath= '/media/soporte/DATA/dataAMISR/' | |
27 |
|
27 | |||
28 | outPath = '/home/soporte/Data/ESF' |
|
28 | outPath = '/home/soporte/Data/ESF' | |
29 | remotefolder = "/home/wmaster/graficos" |
|
29 | remotefolder = "/home/wmaster/graficos" | |
30 | xmin = '18' |
|
30 | xmin = '18' | |
31 | xmax = '31' |
|
31 | xmax = '31' | |
32 | xrange = int(xmax)-int(xmin) |
|
32 | xrange = int(xmax)-int(xmin) | |
33 | dbmin = '60' #'60'#'55' #'40' #noise esf eej |
|
33 | dbmin = '60' #'60'#'55' #'40' #noise esf eej | |
34 | dbmax = '75' #'70' #'55' |
|
34 | dbmax = '75' #'70' #'55' | |
35 |
showSPC = ' |
|
35 | showSPC = '0' #view plot Spectra | |
36 | showRTI = '0' #view plot RTI |
|
36 | showRTI = '0' #view plot RTI | |
37 |
showNOISE = ' |
|
37 | showNOISE = '0' #view plot NOISE | |
38 | # # code = '1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1' |
|
38 | # # code = '1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1' | |
39 | # # code = '1,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,0,0,0' |
|
39 | # # code = '1,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,0,0,0' | |
40 | code = '1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,1,-1,1' |
|
40 | code = '1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,1,-1,1' | |
41 | nCode = '1' |
|
41 | nCode = '1' | |
42 | nBaud = '28' |
|
42 | nBaud = '28' | |
43 | nosamp = '2' # oversample |
|
43 | nosamp = '2' # oversample | |
44 | localtime='1' #para ajustar el horario en las gráficas '0' para dejar en utc |
|
44 | localtime='1' #para ajustar el horario en las gráficas '0' para dejar en utc | |
45 |
|
45 | |||
46 | str0 = datetime.date.today() |
|
46 | str0 = datetime.date.today() | |
47 | str1 = str0 + datetime.timedelta(days=1) |
|
47 | str1 = str0 + datetime.timedelta(days=1) | |
48 | str2 = str0 - datetime.timedelta(days=1) |
|
48 | str2 = str0 - datetime.timedelta(days=1) | |
49 | today = str0.strftime("%Y/%m/%d") |
|
49 | today = str0.strftime("%Y/%m/%d") | |
50 | tomorrow = str1.strftime("%Y/%m/%d") |
|
50 | tomorrow = str1.strftime("%Y/%m/%d") | |
51 | yesterday = str2.strftime("%Y/%m/%d") |
|
51 | yesterday = str2.strftime("%Y/%m/%d") | |
52 |
|
52 | |||
53 | startDate=yesterday |
|
53 | startDate=yesterday | |
54 | endDate=today |
|
54 | endDate=today | |
55 |
|
55 | |||
56 |
startDate='20 |
|
56 | #startDate='2021/07/16' | |
57 |
endDate='20 |
|
57 | #endDate='2021/07/17' | |
58 | ##....................................................................................... |
|
58 | ##....................................................................................... | |
59 | ##....................................................................................... |
|
59 | ##....................................................................................... | |
60 | l = startDate.split('/') #adding day of the year to outPath |
|
60 | l = startDate.split('/') #adding day of the year to outPath | |
61 | datelist = datetime.date(int(l[0]),int(l[1]),int(l[2])) |
|
61 | datelist = datetime.date(int(l[0]),int(l[1]),int(l[2])) | |
62 | DOY = datelist.timetuple().tm_yday |
|
62 | DOY = datelist.timetuple().tm_yday | |
63 | outPath= outPath+"/ESF"+l[0]+str(DOY) |
|
63 | outPath= outPath+"/ESF"+l[0]+str(DOY) | |
64 | if os.path.exists(outPath): |
|
64 | if os.path.exists(outPath): | |
65 | print("outPath", outPath) |
|
65 | print("outPath", outPath) | |
66 | else : |
|
66 | else : | |
67 | os.mkdir(outPath) |
|
67 | os.mkdir(outPath) | |
68 | print("Creating...", outPath) |
|
68 | print("Creating...", outPath) | |
69 | ##....................................................................................... |
|
69 | ##....................................................................................... | |
70 | ##....................................................................................... |
|
70 | ##....................................................................................... | |
71 |
|
71 | |||
72 | controllerObj = Project() |
|
72 | controllerObj = Project() | |
73 | controllerObj.setup(id = '20', name='esf_proc', description=desc) |
|
73 | controllerObj.setup(id = '20', name='esf_proc', description=desc) | |
74 | ##....................................................................................... |
|
74 | ##....................................................................................... | |
75 | ##....................................................................................... |
|
75 | ##....................................................................................... | |
76 |
|
76 | |||
77 | readUnitConfObj = controllerObj.addReadUnit(datatype='AMISRReader', |
|
77 | readUnitConfObj = controllerObj.addReadUnit(datatype='AMISRReader', | |
78 | path=inPath, |
|
78 | path=inPath, | |
79 | startDate=startDate,#startDate,#'2016/07/12', |
|
79 | startDate=startDate,#startDate,#'2016/07/12', | |
80 | endDate=endDate,#endDate,#'2016/07/13', |
|
80 | endDate=endDate,#endDate,#'2016/07/13', | |
81 |
startTime=' |
|
81 | startTime='18:00:10',#'07:00:00', | |
82 |
endTime='07:00: |
|
82 | endTime='07:00:10',#'15:00:00', | |
83 | walk=0, |
|
83 | walk=0, | |
84 | code = code, |
|
84 | code = code, | |
85 | nCode = nCode, |
|
85 | nCode = nCode, | |
86 | nBaud = nBaud, |
|
86 | nBaud = nBaud, | |
87 | timezone='lt', |
|
87 | timezone='lt', | |
88 | online=0) |
|
88 | online=0) | |
89 |
|
89 | |||
90 | #AMISR Processing Unit |
|
90 | #AMISR Processing Unit | |
91 | ##....................................................................................... |
|
91 | ##....................................................................................... | |
92 | ##....................................................................................... |
|
92 | ##....................................................................................... | |
93 |
|
93 | |||
94 | #Voltage Processing Unit |
|
94 | #Voltage Processing Unit | |
95 | procUnitConfObjBeam0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
95 | procUnitConfObjBeam0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
96 | opObj10 = procUnitConfObjBeam0.addOperation(name='setAttribute') |
|
96 | opObj10 = procUnitConfObjBeam0.addOperation(name='setAttribute') | |
97 | opObj10.addParameter(name='frequency', value='445.09e6') |
|
97 | opObj10.addParameter(name='frequency', value='445.09e6') | |
98 |
|
98 | |||
99 | ''' |
|
99 | ||
100 | #Noise--> no code |
|
100 | #Noise--> no code | |
101 |
|
101 | |||
102 | opObj11 = procUnitConfObjBeam0.addOperation(name='Decoder', optype='other') |
|
102 | opObj11 = procUnitConfObjBeam0.addOperation(name='Decoder', optype='other') | |
103 | opObj11.addParameter(name='code', value=code, format='floatlist') |
|
103 | opObj11.addParameter(name='code', value=code, format='floatlist') | |
104 | opObj11.addParameter(name='nCode', value=nCode, format='int') |
|
104 | opObj11.addParameter(name='nCode', value=nCode, format='int') | |
105 | opObj11.addParameter(name='nBaud', value=nBaud, format='int') |
|
105 | opObj11.addParameter(name='nBaud', value=nBaud, format='int') | |
106 | opObj11.addParameter(name='osamp', value=nosamp, format='int') |
|
106 | opObj11.addParameter(name='osamp', value=nosamp, format='int') | |
107 |
|
107 | |||
108 |
|
108 | |||
109 | # opObj12 = procUnitConfObjBeam0.addOperation(name='selectHeights') |
|
109 | # opObj12 = procUnitConfObjBeam0.addOperation(name='selectHeights') | |
110 | # opObj12.addParameter(name='minHei', value='50', format='float') |
|
110 | # opObj12.addParameter(name='minHei', value='50', format='float') | |
111 | # opObj12.addParameter(name='maxHei', value='150', format='float') |
|
111 | # opObj12.addParameter(name='maxHei', value='150', format='float') | |
112 |
|
112 | |||
113 | # #Coherent Integration |
|
113 | # #Coherent Integration | |
114 | # opObj11 = procUnitConfObjBeam0.addOperation(name='CohInt', optype='other') |
|
114 | # opObj11 = procUnitConfObjBeam0.addOperation(name='CohInt', optype='other') | |
115 | # opObj11.addParameter(name='n', value='2', format='int') |
|
115 | # opObj11.addParameter(name='n', value='2', format='int') | |
116 |
|
116 | |||
117 | ##....................................................................................... |
|
117 | ##....................................................................................... | |
118 | ##....................................................................................... |
|
118 | ##....................................................................................... | |
119 |
|
119 | |||
120 | #Spectra Unit Processing, getting spectras with nProfiles and nFFTPoints |
|
120 | #Spectra Unit Processing, getting spectras with nProfiles and nFFTPoints | |
121 | procUnitConfObjSpectraBeam0 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjBeam0.getId()) |
|
121 | procUnitConfObjSpectraBeam0 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjBeam0.getId()) | |
122 | procUnitConfObjSpectraBeam0.addParameter(name='nFFTPoints', value=16, format='int') |
|
122 | procUnitConfObjSpectraBeam0.addParameter(name='nFFTPoints', value=16, format='int') | |
123 | # |
|
123 | # | |
124 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='IncohInt', optype='other') |
|
124 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='IncohInt', optype='other') | |
125 |
opObj11.addParameter(name='n', value=' |
|
125 | opObj11.addParameter(name='n', value='60', format='int') | |
126 | #opObj11.addParameter(name='timeInterval', value='30', format='int') |
|
126 | #opObj11.addParameter(name='timeInterval', value='30', format='int') | |
127 | # |
|
127 | # | |
128 | # |
|
128 | # | |
129 | # # # #RemoveDc |
|
129 | # # # #RemoveDc | |
130 | #opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='removeDC') |
|
130 | #opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='removeDC') | |
131 | # |
|
131 | # | |
132 | # ##Noise Estimation #so reconoce nueva version |
|
132 | # ##Noise Estimation #so reconoce nueva version | |
133 | # opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='getNoise', optype='self') |
|
133 | ## opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='getNoise', optype='self') | |
134 | # opObj11.addParameter(name='minHei', value='100', format='int') |
|
134 | ## opObj11.addParameter(name='minHei', value='100', format='int') | |
135 | # opObj11.addParameter(name='maxHei', value='280', format='int') |
|
135 | ## opObj11.addParameter(name='maxHei', value='280', format='int') | |
136 | # #opObj11.addParameter(name='minHei', value='15', format='int') |
|
136 | ## #opObj11.addParameter(name='minHei', value='15', format='int') | |
137 | # #opObj11.addParameter(name='maxHei', value='20', format='int') |
|
137 | ## #opObj11.addParameter(name='maxHei', value='20', format='int') | |
138 |
|
138 | |||
139 | #--- |
|
139 | #--- | |
140 | # opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='selectChannels') |
|
140 | # opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='selectChannels') | |
141 | # opObj11.addParameter(name='channelList', value='7,8,9', format='intlist') |
|
141 | # opObj11.addParameter(name='channelList', value='7,8,9', format='intlist') | |
142 |
|
142 | |||
143 | ##....................................................................................... |
|
143 | ##....................................................................................... | |
144 | ##....................................................................................... |
|
144 | ##....................................................................................... | |
145 |
|
145 | |||
146 | #SpectraPlot |
|
146 | #SpectraPlot | |
147 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='SpectraPlot', optype='external') |
|
147 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='SpectraPlot', optype='external') | |
148 | opObj11.addParameter(name='id', value='1', format='int') |
|
148 | opObj11.addParameter(name='id', value='1', format='int') | |
149 | opObj11.addParameter(name='wintitle', value='ESF AMISR', format='str') |
|
149 | opObj11.addParameter(name='wintitle', value='ESF AMISR', format='str') | |
150 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
150 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
151 | opObj11.addParameter(name='zmin', value=dbmin, format='int') |
|
151 | opObj11.addParameter(name='zmin', value=dbmin, format='int') | |
152 | opObj11.addParameter(name='zmax', value=dbmax, format='int') |
|
152 | opObj11.addParameter(name='zmax', value=dbmax, format='int') | |
153 | opObj11.addParameter(name='save', value=outPath+'/plots', format='str') |
|
153 | opObj11.addParameter(name='save', value=outPath+'/plots', format='str') | |
154 | opObj11.addParameter(name='ftp', value='1', format='int') |
|
154 | opObj11.addParameter(name='ftp', value='1', format='int') | |
155 | # opObj11.addParameter(name='wr_period', value='2', format='int') |
|
155 | ||
156 | # opObj11.addParameter(name='exp_code', value='21', format='int') |
|
|||
157 | # opObj11.addParameter(name='sub_exp_code', value='4', format='int') |
|
|||
158 | # opObj11.addParameter(name='ftp_wei', value='0', format='int') |
|
|||
159 | # opObj11.addParameter(name='plot_pos', value='0', format='int') |
|
|||
160 | opObj11.addParameter(name='localtime', value=localtime,format='int') |
|
156 | opObj11.addParameter(name='localtime', value=localtime,format='int') | |
161 | opObj11.addParameter(name='show', value = showSPC, format='int') |
|
157 | opObj11.addParameter(name='show', value = showSPC, format='int') | |
162 |
|
158 | |||
163 | #RTIPlot |
|
159 | #RTIPlot | |
164 | #title0 = 'RTI AMISR Beam 0' |
|
160 | #title0 = 'RTI AMISR Beam 0' | |
165 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='RTIPlot', optype='external') |
|
161 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='RTIPlot', optype='external') | |
166 | opObj11.addParameter(name='id', value='2', format='int') |
|
162 | opObj11.addParameter(name='id', value='2', format='int') | |
167 | opObj11.addParameter(name='wintitle', value='ESF AMISR', format='str') |
|
163 | opObj11.addParameter(name='wintitle', value='ESF AMISR', format='str') | |
168 | opObj11.addParameter(name='showprofile', value='0', format='int') |
|
164 | opObj11.addParameter(name='showprofile', value='0', format='int') | |
169 | opObj11.addParameter(name='tmin', value=xmin, format='int') |
|
165 | opObj11.addParameter(name='tmin', value=xmin, format='int') | |
170 | opObj11.addParameter(name='xrange', value=xrange, format='int') |
|
166 | opObj11.addParameter(name='xrange', value=xrange, format='int') | |
171 | opObj11.addParameter(name='zmin', value=dbmin, format='int') |
|
167 | opObj11.addParameter(name='zmin', value=dbmin, format='int') | |
172 | opObj11.addParameter(name='zmax', value=dbmax, format='int') |
|
168 | opObj11.addParameter(name='zmax', value=dbmax, format='int') | |
173 | opObj11.addParameter(name='save', value=outPath+'/plots', format='str') |
|
169 | opObj11.addParameter(name='save', value=outPath+'/plots', format='str') | |
174 | opObj11.addParameter(name='ftp', value='1', format='int') |
|
170 | opObj11.addParameter(name='ftp', value='1', format='int') | |
175 | opObj11.addParameter(name='wr_period', value='2', format='int') |
|
171 | opObj11.addParameter(name='wr_period', value='2', format='int') | |
176 | # opObj11.addParameter(name='exp_code', value='21', format='int') |
|
|||
177 | # opObj11.addParameter(name='sub_exp_code', value='4', format='int') |
|
|||
178 | # opObj11.addParameter(name='ftp_wei', value='0', format='int') |
|
|||
179 | # opObj11.addParameter(name='plot_pos', value='0', format='int') |
|
|||
180 | opObj11.addParameter(name='localtime', value=localtime,format='int') |
|
172 | opObj11.addParameter(name='localtime', value=localtime,format='int') | |
181 | opObj11.addParameter(name='show', value = showRTI, format='int') |
|
173 | opObj11.addParameter(name='show', value = showRTI, format='int') | |
182 |
|
174 | |||
183 |
|
175 | |||
184 | # # # |
|
176 | # # # | |
185 | # #Noise |
|
177 | # #Noise | |
186 | #title0 = 'RTI AMISR Beam 0' |
|
178 | #title0 = 'RTI AMISR Beam 0' | |
187 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='NoisePlot', optype='external') |
|
179 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='NoisePlot', optype='external') | |
188 | opObj11.addParameter(name='id', value='3', format='int') |
|
180 | opObj11.addParameter(name='id', value='3', format='int') | |
189 | opObj11.addParameter(name='wintitle', value='ESF AMISR', format='str') |
|
181 | opObj11.addParameter(name='wintitle', value='ESF AMISR', format='str') | |
190 | opObj11.addParameter(name='showprofile', value='0', format='int') |
|
182 | opObj11.addParameter(name='showprofile', value='0', format='int') | |
191 | opObj11.addParameter(name='tmin', value=xmin, format='int') |
|
183 | opObj11.addParameter(name='tmin', value=xmin, format='int') | |
192 | opObj11.addParameter(name='xrange', value=xrange, format='int') |
|
184 | opObj11.addParameter(name='xrange', value=xrange, format='int') | |
193 | #opObj11.addParameter(name='ymin', value=dbmin, format='int') |
|
185 | #opObj11.addParameter(name='ymin', value=dbmin, format='int') | |
194 | #opObj11.addParameter(name='ymax', value=dbmax, format='int') |
|
186 | #opObj11.addParameter(name='ymax', value=dbmax, format='int') | |
195 | opObj11.addParameter(name='save', value=outPath+'/plots', format='str') |
|
187 | opObj11.addParameter(name='save', value=outPath+'/plots', format='str') | |
196 | opObj11.addParameter(name='show', value = showNOISE, format='int') |
|
188 | opObj11.addParameter(name='show', value = showNOISE, format='int') | |
197 | opObj11.addParameter(name='localtime', value=localtime,format='int') |
|
189 | opObj11.addParameter(name='localtime', value=localtime,format='int') | |
198 |
|
190 | |||
199 | #Generate *.pdata from AMISR data |
|
191 | #Generate *.pdata from AMISR data | |
200 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='SpectraWriter', optype='external') |
|
192 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='SpectraWriter', optype='external') | |
201 | opObj11.addParameter(name='path', value=outPath) |
|
193 | opObj11.addParameter(name='path', value=outPath) | |
202 | opObj11.addParameter(name='blocksPerFile', value='10', format='int') |
|
194 | opObj11.addParameter(name='blocksPerFile', value='10', format='int') | |
203 | ''' |
|
195 | ||
204 | ##....................................................................................... |
|
196 | ##....................................................................................... | |
205 | ##....................................................................................... |
|
197 | ##....................................................................................... | |
206 |
|
198 | |||
207 | # #generate moments |
|
199 | # #generate moments | |
208 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObjSpectraBeam0.getId()) |
|
200 | # procUnitConfObj2 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObjSpectraBeam0.getId()) | |
209 | # opObj20 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other') |
|
201 | # opObj20 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other') | |
210 | # |
|
202 | # | |
211 | # opObj12 = procUnitConfObj2.addOperation(name='ParamWriter', optype='external') |
|
203 | # opObj12 = procUnitConfObj2.addOperation(name='ParamWriter', optype='external') | |
212 | # opObj12.addParameter(name='path', value=outPath) |
|
204 | # opObj12.addParameter(name='path', value=outPath) | |
213 | # opObj12.addParameter(name='blocksPerFile', value='10', format='int') |
|
205 | # opObj12.addParameter(name='blocksPerFile', value='10', format='int') | |
214 | # opObj12.addParameter(name='metadataList',value='type,inputUnit,heightList',format='list') |
|
206 | # opObj12.addParameter(name='metadataList',value='type,inputUnit,heightList',format='list') | |
215 | # opObj12.addParameter(name='dataList',value='moments,data_SNR,utctime',format='list') |
|
207 | # opObj12.addParameter(name='dataList',value='moments,data_SNR,utctime',format='list') | |
216 | # opObj12.addParameter(name='mode',value='1',format='int') |
|
208 | # opObj12.addParameter(name='mode',value='1',format='int') | |
217 | # |
|
209 | # | |
218 | # |
|
210 | # | |
219 | # ---- |
|
211 | # ---- | |
220 |
|
212 | |||
221 |
|
213 | |||
222 | # print "Escribiendo el archivo XML" |
|
214 | # print "Escribiendo el archivo XML" | |
223 | # controllerObj.writeXml(outPath+"/"filename) |
|
215 | # controllerObj.writeXml(outPath+"/"filename) | |
224 | controllerObj.start() |
|
216 | controllerObj.start() | |
225 | # print "Leyendo el archivo XML" |
|
217 | # print "Leyendo el archivo XML" | |
226 | # controllerObj.readXml(outPath+"/"filename) |
|
218 | # controllerObj.readXml(outPath+"/"filename) | |
227 |
|
219 | |||
228 | if __name__ == '__main__': |
|
220 | if __name__ == '__main__': | |
229 | import time |
|
221 | import time | |
230 | start_time = time.time() |
|
222 | start_time = time.time() | |
231 | main() |
|
223 | main() | |
232 | print("--- %s seconds ---" % (time.time() - start_time)) |
|
224 | print("--- %s seconds ---" % (time.time() - start_time)) |
@@ -1,203 +1,220 | |||||
1 | #!/usr/bin/env python |
|
1 | ||
2 | import os, sys |
|
2 | import os, sys | |
3 | import time |
|
3 | import time | |
4 | import datetime |
|
4 | import datetime | |
5 |
|
5 | |||
6 | ''' |
|
6 | ''' | |
7 | ESF 10 BEAM ONLINE |
|
7 | ESF EW 10 BEAM ONLINE | |
8 | ''' |
|
8 | ''' | |
9 | path = os.path.dirname(os.getcwd()) |
|
9 | path = os.path.dirname(os.getcwd()) | |
10 | path = os.path.dirname(path) |
|
10 | path = os.path.dirname(path) | |
11 | sys.path.insert(0, path) |
|
11 | sys.path.insert(0, path) | |
12 |
|
12 | |||
13 | from schainpy.controller import Project |
|
13 | from schainpy.controller import Project | |
14 |
|
14 | |||
15 |
|
15 | |||
16 | def main(): |
|
16 | def main(): | |
17 | desc = "AMISR ESF 10 Beam Experiment" |
|
17 | desc = "AMISR ESF 10 Beam Experiment" | |
18 |
|
18 | |||
19 | filename = "amisr_esf_reader.xml" |
|
19 | filename = "amisr_esf_reader.xml" | |
20 |
|
20 | |||
21 |
|
21 | |||
22 |
|
22 | |||
23 | #path = os.path.join(os.environ['HOME'],'amisr') |
|
23 | #path = os.path.join(os.environ['HOME'],'amisr') | |
24 | inPath = '/mnt/data_amisr' |
|
24 | inPath= '/home/soporte/Data/OutTest/ONLINE/' | |
|
25 | #inPath = '/mnt/data_amisr' | |||
25 | #path= '/home/soporte/dataAMISR/' |
|
26 | #path= '/home/soporte/dataAMISR/' | |
26 | #inPath= '/home/soporte/dataAMISR_test/' |
|
27 | #inPath= '/home/soporte/dataAMISR_test/' | |
27 | outPath = '/home/soporte/Data/ESF' |
|
28 | outPath = '/home/soporte/Data/ESF' | |
28 | remotefolder = "/home/wmaster/graficos" |
|
29 | remotefolder = "/home/wmaster/test/graficos" | |
29 | xmin = '18' |
|
30 | xmin = '18' | |
30 |
xmax = ' |
|
31 | xmax = '31' | |
|
32 | xrange = int(xmax)-int(xmin) | |||
31 | dbmin = '60' #'60'#'55' #'40' #noise esf eej |
|
33 | dbmin = '60' #'60'#'55' #'40' #noise esf eej | |
32 | dbmax = '75' #'70' #'55' |
|
34 | dbmax = '75' #'70' #'55' | |
33 |
showSPC = ' |
|
35 | showSPC = '0' #view plot Spectra | |
34 |
showRTI = ' |
|
36 | showRTI = '0' #view plot RTI | |
35 |
showNOISE = ' |
|
37 | showNOISE = '0' #view plot NOISE | |
36 | # # code = '1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1' |
|
38 | # # code = '1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1' | |
37 | # # code = '1,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,0,0,0' |
|
39 | # # code = '1,1,0,1,1,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,0,0,0' | |
38 | code = '1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,1,-1,1' |
|
40 | code = '1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,1,-1,1' | |
39 | nCode = '1' |
|
41 | nCode = '1' | |
40 | nBaud = '28' |
|
42 | nBaud = '28' | |
41 | nosamp = '2' # oversample |
|
43 | nosamp = '2' # oversample | |
42 |
localtime=' |
|
44 | localtime='1' #para ajustar el horario en las gráficas '0' para dejar en utc | |
43 |
|
45 | |||
44 | dty = datetime.date.today() #ONLINE |
|
46 | dty = datetime.date.today() #ONLINE | |
45 | str1 = dty + datetime.timedelta(days=1) |
|
47 | str1 = dty + datetime.timedelta(days=1) | |
46 | str2 = dty - datetime.timedelta(days=1) |
|
48 | str2 = dty - datetime.timedelta(days=1) | |
47 | today = dty.strftime("%Y/%m/%d") |
|
49 | today = dty.strftime("%Y/%m/%d") | |
48 | tomorrow = str1.strftime("%Y/%m/%d") |
|
50 | tomorrow = str1.strftime("%Y/%m/%d") | |
49 | yesterday = str2.strftime("%Y/%m/%d") |
|
51 | yesterday = str2.strftime("%Y/%m/%d") | |
50 | startDate=today |
|
52 | startDate=today | |
51 | endDate=tomorrow |
|
53 | endDate=tomorrow | |
52 |
#startDate='20 |
|
54 | #startDate='2021/07/16' | |
53 |
#endDate='20 |
|
55 | #endDate='2021/07/17' | |
54 | ##....................................................................................... |
|
56 | ##....................................................................................... | |
55 | ##....................................................................................... |
|
57 | ##....................................................................................... | |
56 | l = startDate.split('/') #adding day of the year to outPath |
|
58 | l = startDate.split('/') #adding day of the year to outPath | |
57 | datelist = datetime.date(int(l[0]),int(l[1]),int(l[2])) |
|
59 | datelist = datetime.date(int(l[0]),int(l[1]),int(l[2])) | |
58 | DOY = datelist.timetuple().tm_yday |
|
60 | DOY = datelist.timetuple().tm_yday | |
59 | outPath= outPath+"/ESF"+l[0]+str(DOY) |
|
61 | outPath= outPath+"/ESF"+l[0]+str(DOY) | |
60 | if os.path.exists(outPath): |
|
62 | if os.path.exists(outPath): | |
61 | print("outPath", outPath) |
|
63 | print("outPath", outPath) | |
62 | else : |
|
64 | else : | |
63 | os.mkdir(outPath) |
|
65 | os.mkdir(outPath) | |
64 | print("Creating...", outPath) |
|
66 | print("Creating...", outPath) | |
65 | ##....................................................................................... |
|
67 | ##....................................................................................... | |
66 | ##....................................................................................... |
|
68 | ##....................................................................................... | |
67 |
|
69 | |||
68 | controllerObj = Project() |
|
70 | controllerObj = Project() | |
69 | controllerObj.setup(id = '21', name='esf_proc', description=desc) |
|
71 | controllerObj.setup(id = '21', name='esf_proc', description=desc) | |
70 | ##....................................................................................... |
|
72 | ##....................................................................................... | |
71 | ##....................................................................................... |
|
73 | ##....................................................................................... | |
72 |
|
74 | |||
73 | readUnitConfObj = controllerObj.addReadUnit(datatype='AMISRReader', |
|
75 | readUnitConfObj = controllerObj.addReadUnit(datatype='AMISRReader', | |
74 | path=inPath, |
|
76 | path=inPath, | |
75 | startDate=startDate,#'2016/07/12', |
|
77 | startDate=startDate,#'2016/07/12', | |
76 | endDate=endDate,#'2016/07/13', |
|
78 | endDate=endDate,#'2016/07/13', | |
77 |
startTime='1 |
|
79 | startTime='18:01:00',#'07:00:00', | |
78 |
endTime='0 |
|
80 | endTime='06:55:00',#'15:00:00', | |
79 | walk=0, |
|
81 | walk=0, | |
80 | code = code, |
|
82 | code = code, | |
81 | nCode = nCode, |
|
83 | nCode = nCode, | |
82 | nBaud = nBaud, |
|
84 | nBaud = nBaud, | |
83 | timezone='lt', |
|
85 | timezone='lt', | |
84 | online=1) |
|
86 | online=1) | |
85 |
|
87 | |||
86 | #AMISR Processing Unit |
|
88 | #AMISR Processing Unit | |
87 | ##....................................................................................... |
|
89 | ##....................................................................................... | |
88 | ##....................................................................................... |
|
90 | ##....................................................................................... | |
89 |
|
91 | |||
90 | #Voltage Processing Unit |
|
92 | #Voltage Processing Unit | |
91 | procUnitConfObjBeam0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
93 | procUnitConfObjBeam0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
92 |
opObj10 = procUnitConfObjBeam0.addOperation(name='set |
|
94 | opObj10 = procUnitConfObjBeam0.addOperation(name='setAttribute') | |
|
95 | opObj10.addParameter(name='frequency', value='445.0e6') | |||
|
96 | ||||
93 | #opObj10.addParameter(name='frequency', value='445e6', format='int') #changed on Dec 3, 15:40h |
|
97 | #opObj10.addParameter(name='frequency', value='445e6', format='int') #changed on Dec 3, 15:40h | |
94 |
|
98 | |||
95 |
|
99 | |||
96 | #Noise--> no code |
|
100 | #Noise--> no code | |
97 |
|
101 | |||
98 | opObj11 = procUnitConfObjBeam0.addOperation(name='Decoder', optype='other') |
|
102 | opObj11 = procUnitConfObjBeam0.addOperation(name='Decoder', optype='other') | |
99 | opObj11.addParameter(name='code', value=code, format='floatlist') |
|
103 | opObj11.addParameter(name='code', value=code, format='floatlist') | |
100 | opObj11.addParameter(name='nCode', value=nCode, format='int') |
|
104 | opObj11.addParameter(name='nCode', value=nCode, format='int') | |
101 | opObj11.addParameter(name='nBaud', value=nBaud, format='int') |
|
105 | opObj11.addParameter(name='nBaud', value=nBaud, format='int') | |
102 | opObj11.addParameter(name='osamp', value=nosamp, format='int') |
|
106 | opObj11.addParameter(name='osamp', value=nosamp, format='int') | |
103 |
|
107 | |||
104 |
|
108 | |||
105 | # opObj12 = procUnitConfObjBeam0.addOperation(name='selectHeights') |
|
109 | # opObj12 = procUnitConfObjBeam0.addOperation(name='selectHeights') | |
106 | # opObj12.addParameter(name='minHei', value='50', format='float') |
|
110 | # opObj12.addParameter(name='minHei', value='50', format='float') | |
107 | # opObj12.addParameter(name='maxHei', value='150', format='float') |
|
111 | # opObj12.addParameter(name='maxHei', value='150', format='float') | |
108 |
|
112 | |||
109 | # #Coherent Integration |
|
113 | # #Coherent Integration | |
110 | # opObj11 = procUnitConfObjBeam0.addOperation(name='CohInt', optype='other') |
|
114 | # opObj11 = procUnitConfObjBeam0.addOperation(name='CohInt', optype='other') | |
111 | # opObj11.addParameter(name='n', value='2', format='int') |
|
115 | # opObj11.addParameter(name='n', value='2', format='int') | |
112 |
|
116 | |||
113 | ##....................................................................................... |
|
117 | ##....................................................................................... | |
114 | ##....................................................................................... |
|
118 | ##....................................................................................... | |
115 |
|
119 | |||
116 | #Spectra Unit Processing, getting spectras with nProfiles and nFFTPoints |
|
120 | #Spectra Unit Processing, getting spectras with nProfiles and nFFTPoints | |
117 | procUnitConfObjSpectraBeam0 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjBeam0.getId()) |
|
121 | procUnitConfObjSpectraBeam0 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjBeam0.getId()) | |
118 | procUnitConfObjSpectraBeam0.addParameter(name='nFFTPoints', value=16, format='int') |
|
122 | procUnitConfObjSpectraBeam0.addParameter(name='nFFTPoints', value=16, format='int') | |
119 | # |
|
123 | # | |
120 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='IncohInt', optype='other') |
|
124 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='IncohInt', optype='other') | |
121 | opObj11.addParameter(name='n', value='60', format='int') |
|
125 | opObj11.addParameter(name='n', value='60', format='int') | |
122 | #opObj11.addParameter(name='timeInterval', value='30', format='int') |
|
126 | #opObj11.addParameter(name='timeInterval', value='30', format='int') | |
123 |
|
127 | |||
124 |
|
128 | |||
125 | # # #RemoveDc |
|
129 | # # #RemoveDc | |
126 | #opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='removeDC') |
|
130 | #opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='removeDC') | |
127 |
|
131 | |||
128 |
|
132 | |||
129 | #--- |
|
133 | #--- | |
130 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='selectChannels') |
|
134 | #opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='selectChannels') | |
131 | opObj11.addParameter(name='channelList', value='0,2,4,6,8', format='intlist') |
|
135 | #opObj11.addParameter(name='channelList', value='0,2,4,6,8', format='intlist') | |
132 |
|
136 | |||
133 | ##....................................................................................... |
|
137 | ##....................................................................................... | |
134 | ##....................................................................................... |
|
138 | ##....................................................................................... | |
135 |
|
139 | |||
136 | #SpectraPlot |
|
140 | #SpectraPlot | |
137 |
opObj1 |
|
141 | opObj12 = procUnitConfObjSpectraBeam0.addOperation(name='SpectraPlot', optype='external') | |
138 |
opObj1 |
|
142 | opObj12.addParameter(name='id', value='1', format='int') | |
139 |
opObj1 |
|
143 | opObj12.addParameter(name='wintitle', value='ESF AMISR', format='str') | |
140 |
opObj1 |
|
144 | opObj12.addParameter(name='showprofile', value='1', format='int') | |
141 |
opObj1 |
|
145 | opObj12.addParameter(name='zmin', value=dbmin, format='int') | |
142 |
opObj1 |
|
146 | opObj12.addParameter(name='zmax', value=dbmax, format='int') | |
143 |
opObj1 |
|
147 | opObj12.addParameter(name='save', value=outPath+'/plots', format='str') | |
144 |
|
|
148 | opObj12.addParameter(name='localtime', value=localtime,format='int') | |
145 |
|
|
149 | opObj12.addParameter(name='show', value = showSPC, format='int') | |
146 |
|
|
150 | opObj12.addParameter(name='colormap', value='jet', format='str') | |
147 |
|
|
151 | opObj12.addParameter(name='exp_code', value='207', format='int') | |
148 |
|
|
152 | opObj12.addParameter(name='server', value='jro-realtime.igp.gob.pe:4444') | |
149 |
|
|
153 | opObj12.addParameter(name='sender_period', value='120') | |
150 |
opObj1 |
|
154 | opObj12.addParameter(name='tag', value='AMISR') | |
151 | opObj11.addParameter(name='show', value = showSPC, format='int') |
|
|||
152 | opObj11.addParameter(name='colormap', value='jet', format='str') |
|
|||
153 |
|
||||
154 |
|
155 | |||
155 | #RTIPlot |
|
156 | #RTIPlot | |
156 | #title0 = 'RTI AMISR Beam 0' |
|
157 | #title0 = 'RTI AMISR Beam 0' | |
157 |
opObj1 |
|
158 | opObj13 = procUnitConfObjSpectraBeam0.addOperation(name='RTIPlot', optype='external') | |
158 |
opObj1 |
|
159 | opObj13.addParameter(name='id', value='2', format='int') | |
159 |
opObj1 |
|
160 | opObj13.addParameter(name='wintitle', value='ESF AMISR', format='str') | |
160 |
opObj1 |
|
161 | opObj13.addParameter(name='showprofile', value='0', format='int') | |
161 |
opObj1 |
|
162 | opObj13.addParameter(name='tmin', value=xmin, format='int') | |
162 |
opObj1 |
|
163 | opObj13.addParameter(name='xrange', value=xrange,format='int') | |
163 |
opObj1 |
|
164 | opObj13.addParameter(name='zmin', value=dbmin, format='int') | |
164 |
opObj1 |
|
165 | opObj13.addParameter(name='zmax', value=dbmax, format='int') | |
165 |
opObj1 |
|
166 | opObj13.addParameter(name='save', value=outPath+'/plots', format='str') | |
166 |
|
|
167 | opObj13.addParameter(name='localtime', value=localtime,format='int') | |
167 |
|
|
168 | opObj13.addParameter(name='show', value = showRTI, format='int') | |
168 |
|
|
169 | opObj13.addParameter(name='colormap', value='jet', format='str') | |
169 |
|
|
170 | opObj13.addParameter(name='exp_code', value='207', format='int') | |
170 |
|
|
171 | opObj13.addParameter(name='server', value='jro-realtime.igp.gob.pe:4444') | |
171 |
|
|
172 | opObj13.addParameter(name='sender_period', value='120') | |
172 |
opObj1 |
|
173 | opObj13.addParameter(name='tag', value='AMISR') | |
173 | opObj11.addParameter(name='show', value = showRTI, format='int') |
|
|||
174 | opObj11.addParameter(name='colormap', value='jet', format='str') |
|
|||
175 |
|
174 | |||
176 | # # # |
|
175 | # # # | |
177 | # #Noise |
|
176 | # #Noise | |
178 | #title0 = 'RTI AMISR Beam 0' |
|
177 | #title0 = 'RTI AMISR Beam 0' | |
179 |
opObj1 |
|
178 | opObj14 = procUnitConfObjSpectraBeam0.addOperation(name='NoisePlot', optype='external') | |
180 |
opObj1 |
|
179 | opObj14.addParameter(name='id', value='3', format='int') | |
181 |
opObj1 |
|
180 | opObj14.addParameter(name='wintitle', value='ESF AMISR', format='str') | |
182 |
opObj1 |
|
181 | opObj14.addParameter(name='showprofile', value='0', format='int') | |
183 |
opObj1 |
|
182 | opObj14.addParameter(name='tmin', value=xmin, format='int') | |
184 |
opObj1 |
|
183 | opObj14.addParameter(name='tmax', value=xmax, format='int') | |
185 | ##opObj11.addParameter(name='ymin', value=dbmin, format='int') |
|
184 | ##opObj11.addParameter(name='ymin', value=dbmin, format='int') | |
186 | ##opObj11.addParameter(name='ymax', value=dbmax, format='int') |
|
185 | ##opObj11.addParameter(name='ymax', value=dbmax, format='int') | |
187 |
opObj1 |
|
186 | opObj14.addParameter(name='save', value=outPath+'/plots', format='str') | |
188 |
opObj1 |
|
187 | opObj14.addParameter(name='show', value = showNOISE, format='int') | |
189 |
opObj1 |
|
188 | opObj14.addParameter(name='localtime', value=localtime,format='int') | |
190 |
|
189 | opObj14.addParameter(name='exp_code', value='207', format='int') | ||
|
190 | opObj14.addParameter(name='server', value='jro-realtime.igp.gob.pe:4444') | |||
|
191 | opObj14.addParameter(name='sender_period', value='120') | |||
|
192 | opObj14.addParameter(name='tag', value='AMISR') | |||
|
193 | ''' | |||
|
194 | patternX : list | |||
|
195 | detail of files to be send must have the following order: local, remote | |||
|
196 | ext, period, exp_code, sub_exp_code | |||
|
197 | ''' | |||
|
198 | # ftp = procUnitConfObjSpectraBeam0.addOperation(name='SendToFTP', optype='external') | |||
|
199 | # ftp.addParameter(name='server', value='jro-app.igp.gob.pe') | |||
|
200 | # ftp.addParameter(name='username', value='wmaster') | |||
|
201 | # ftp.addParameter(name='password', value='mst2010vhf') | |||
|
202 | # ftp.addParameter(name='pattern1', | |||
|
203 | # value=outPath+'/plots/rti,/home/wmaster/graficos,png,60,1,1', | |||
|
204 | # format='list') | |||
|
205 | # ftp.addParameter(name='pattern2', | |||
|
206 | # value=outPath+'/plots/rti,/home/wmaster/graficos,png,300,1,1', | |||
|
207 | # format='list') | |||
191 |
|
208 | |||
192 |
|
209 | |||
193 | # print "Escribiendo el archivo XML" |
|
210 | # print "Escribiendo el archivo XML" | |
194 | # controllerObj.writeXml(filename) |
|
211 | # controllerObj.writeXml(filename) | |
195 | controllerObj.start() |
|
212 | controllerObj.start() | |
196 | # print "Leyendo el archivo XML" |
|
213 | # print "Leyendo el archivo XML" | |
197 | # controllerObj.readXml(filename) |
|
214 | # controllerObj.readXml(filename) | |
198 |
|
215 | |||
199 | if __name__ == '__main__': |
|
216 | if __name__ == '__main__': | |
200 | import time |
|
217 | import time | |
201 | start_time = time.time() |
|
218 | start_time = time.time() | |
202 | main() |
|
219 | main() | |
203 | print("--- %s seconds ---" % (time.time() - start_time)) |
|
220 | print("--- %s seconds ---" % (time.time() - start_time)) |
1 | NO CONTENT: file was removed, binary diff hidden |
|
NO CONTENT: file was removed, binary diff hidden |
General Comments 0
You need to be logged in to leave comments.
Login now