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