##// END OF EJS Templates
Multiprocessing for heispectra (Fits) all working
George Yong -
r1191:f1f11d1fc586
parent child
Show More
@@ -18,19 +18,9 from xml.dom import minidom
18
18
19
19
20 from schainpy.admin import Alarm, SchainWarning
20 from schainpy.admin import Alarm, SchainWarning
21
21 from schainpy.model import *
22 ### Temporary imports!!!
23 # from schainpy.model import *
24 from schainpy.model.io import *
25 from schainpy.model.graphics import *
26 from schainpy.model.proc.jroproc_base import *
27 from schainpy.model.proc.bltrproc_parameters import *
28 from schainpy.model.proc.jroproc_spectra import *
29 from schainpy.model.proc.jroproc_voltage import *
30 from schainpy.model.proc.jroproc_parameters import *
31 from schainpy.model.utils.jroutils_publish import *
32 from schainpy.utils import log
22 from schainpy.utils import log
33 ###
23
34
24
35 DTYPES = {
25 DTYPES = {
36 'Voltage': '.r',
26 'Voltage': '.r',
@@ -683,6 +673,7 class ProcUnitConf():
683 '''
673 '''
684 Instancia de unidades de procesamiento.
674 Instancia de unidades de procesamiento.
685 '''
675 '''
676
686 className = eval(self.name)
677 className = eval(self.name)
687 kwargs = self.getKwargs()
678 kwargs = self.getKwargs()
688 procUnitObj = className(self.id, self.inputId, self.project_id, **kwargs) # necesitan saber su id y su entrada por fines de ipc
679 procUnitObj = className(self.id, self.inputId, self.project_id, **kwargs) # necesitan saber su id y su entrada por fines de ipc
@@ -368,7 +368,7 class Voltage(JROData):
368 # self.nChannels = 0
368 # self.nChannels = 0
369 # self.nHeights = 0
369 # self.nHeights = 0
370 self.nProfiles = None
370 self.nProfiles = None
371 self.heightList = Non
371 self.heightList = None
372 self.channelList = None
372 self.channelList = None
373 # self.channelIndexList = None
373 # self.channelIndexList = None
374 self.flagNoData = True
374 self.flagNoData = True
@@ -848,6 +848,12 class Fits(JROData):
848
848
849 return timeInterval
849 return timeInterval
850
850
851 def get_ippSeconds(self):
852 '''
853 '''
854 return self.ipp_sec
855
856
851 datatime = property(getDatatime, "I'm the 'datatime' property")
857 datatime = property(getDatatime, "I'm the 'datatime' property")
852 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
858 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
853 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
859 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
@@ -857,7 +863,7 class Fits(JROData):
857
863
858 ltctime = property(getltctime, "I'm the 'ltctime' property")
864 ltctime = property(getltctime, "I'm the 'ltctime' property")
859 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
865 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
860
866 ippSeconds = property(get_ippSeconds, '')
861
867
862 class Correlation(JROData):
868 class Correlation(JROData):
863
869
@@ -9,7 +9,10 import numpy
9
9
10 from .figure import Figure, isRealtime
10 from .figure import Figure, isRealtime
11 from .plotting_codes import *
11 from .plotting_codes import *
12 from schainpy.model.proc.jroproc_base import MPDecorator
12
13
14
15 @MPDecorator
13 class SpectraHeisScope_(Figure):
16 class SpectraHeisScope_(Figure):
14
17
15
18
@@ -20,9 +23,9 class SpectraHeisScope_(Figure):
20 HEIGHTPROF = None
23 HEIGHTPROF = None
21 PREFIX = 'spc'
24 PREFIX = 'spc'
22
25
23 def __init__(self, **kwargs):
26 def __init__(self):#, **kwargs):
24
27
25 Figure.__init__(self, **kwargs)
28 Figure.__init__(self)#, **kwargs)
26 self.isConfig = False
29 self.isConfig = False
27 self.__nsubplots = 1
30 self.__nsubplots = 1
28
31
@@ -96,6 +99,9 class SpectraHeisScope_(Figure):
96 ymax : None,
99 ymax : None,
97 """
100 """
98
101
102 if dataOut.flagNoData:
103 return dataOut
104
99 if dataOut.realtime:
105 if dataOut.realtime:
100 if not(isRealtime(utcdatatime = dataOut.utctime)):
106 if not(isRealtime(utcdatatime = dataOut.utctime)):
101 print('Skipping this plot function')
107 print('Skipping this plot function')
@@ -173,6 +179,9 class SpectraHeisScope_(Figure):
173 wr_period=wr_period,
179 wr_period=wr_period,
174 thisDatetime=thisDatetime)
180 thisDatetime=thisDatetime)
175
181
182 return dataOut
183
184 @MPDecorator
176 class RTIfromSpectraHeis_(Figure):
185 class RTIfromSpectraHeis_(Figure):
177
186
178 isConfig = None
187 isConfig = None
@@ -180,8 +189,8 class RTIfromSpectraHeis_(Figure):
180
189
181 PREFIX = 'rtinoise'
190 PREFIX = 'rtinoise'
182
191
183 def __init__(self, **kwargs):
192 def __init__(self):#, **kwargs):
184 Figure.__init__(self, **kwargs)
193 Figure.__init__(self)#, **kwargs)
185 self.timerange = 24*60*60
194 self.timerange = 24*60*60
186 self.isConfig = False
195 self.isConfig = False
187 self.__nsubplots = 1
196 self.__nsubplots = 1
@@ -231,6 +240,10 class RTIfromSpectraHeis_(Figure):
231 server=None, folder=None, username=None, password=None,
240 server=None, folder=None, username=None, password=None,
232 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
241 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
233
242
243 if dataOut.flagNoData:
244 return dataOut
245
246
234 if channelList == None:
247 if channelList == None:
235 channelIndexList = dataOut.channelIndexList
248 channelIndexList = dataOut.channelIndexList
236 channelList = dataOut.channelList
249 channelList = dataOut.channelList
@@ -326,4 +339,7 class RTIfromSpectraHeis_(Figure):
326 ftp=ftp,
339 ftp=ftp,
327 wr_period=wr_period,
340 wr_period=wr_period,
328 thisDatetime=thisDatetime,
341 thisDatetime=thisDatetime,
329 update_figfile=update_figfile) No newline at end of file
342 update_figfile=update_figfile)
343
344
345 return dataOut No newline at end of file
@@ -20,7 +20,9 from xml.etree.ElementTree import ElementTree
20
20
21 from .jroIO_base import isRadarFolder, isNumber
21 from .jroIO_base import isRadarFolder, isNumber
22 from schainpy.model.data.jrodata import Fits
22 from schainpy.model.data.jrodata import Fits
23 from schainpy.model.proc.jroproc_base import Operation, ProcessingUnit
23 from schainpy.model.proc.jroproc_base import Operation, ProcessingUnit, MPDecorator
24 from schainpy.utils import log
25
24
26
25 class PyFits(object):
27 class PyFits(object):
26 name=None
28 name=None
@@ -281,7 +283,7 class FitsWriter(Operation):
281 self.isConfig = True
283 self.isConfig = True
282 self.putData()
284 self.putData()
283
285
284
286 @MPDecorator
285 class FitsReader(ProcessingUnit):
287 class FitsReader(ProcessingUnit):
286
288
287 # __TIMEZONE = time.timezone
289 # __TIMEZONE = time.timezone
@@ -298,8 +300,8 class FitsReader(ProcessingUnit):
298 data = None
300 data = None
299 data_header_dict = None
301 data_header_dict = None
300
302
301 def __init__(self, **kwargs):
303 def __init__(self):#, **kwargs):
302 ProcessingUnit.__init__(self, **kwargs)
304 ProcessingUnit.__init__(self)#, **kwargs)
303 self.isConfig = False
305 self.isConfig = False
304 self.ext = '.fits'
306 self.ext = '.fits'
305 self.setFile = 0
307 self.setFile = 0
@@ -391,8 +393,7 class FitsReader(ProcessingUnit):
391
393
392 self.dataOut.nCohInt = self.nCohInt
394 self.dataOut.nCohInt = self.nCohInt
393 self.dataOut.nIncohInt = self.nIncohInt
395 self.dataOut.nIncohInt = self.nIncohInt
394
396 self.dataOut.ipp_sec = self.ippSeconds
395 self.dataOut.ippSeconds = self.ippSeconds
396
397
397 def readHeader(self):
398 def readHeader(self):
398 headerObj = self.fitsObj[0]
399 headerObj = self.fitsObj[0]
@@ -691,18 +692,17 class FitsReader(ProcessingUnit):
691
692
692 if self.flagNoMoreFiles:
693 if self.flagNoMoreFiles:
693 self.dataOut.flagNoData = True
694 self.dataOut.flagNoData = True
694 print('Process finished')
695 return (0, 'No more files')
695 return 0
696
696
697 self.flagDiscontinuousBlock = 0
697 self.flagDiscontinuousBlock = 0
698 self.flagIsNewBlock = 0
698 self.flagIsNewBlock = 0
699
699
700 if not(self.readNextBlock()):
700 if not(self.readNextBlock()):
701 return 0
701 return (1, 'Error reading data')
702
702
703 if self.data is None:
703 if self.data is None:
704 self.dataOut.flagNoData = True
704 self.dataOut.flagNoData = True
705 return 0
705 return (0, 'No more data')
706
706
707 self.dataOut.data = self.data
707 self.dataOut.data = self.data
708 self.dataOut.data_header = self.data_header_dict
708 self.dataOut.data_header = self.data_header_dict
@@ -718,8 +718,7 class FitsReader(ProcessingUnit):
718 # self.dataOut.channelList = self.channelList
718 # self.dataOut.channelList = self.channelList
719 # self.dataOut.heightList = self.heightList
719 # self.dataOut.heightList = self.heightList
720 self.dataOut.flagNoData = False
720 self.dataOut.flagNoData = False
721
721 # return self.dataOut.data
722 return self.dataOut.data
723
722
724 def run(self, **kwargs):
723 def run(self, **kwargs):
725
724
@@ -729,6 +728,7 class FitsReader(ProcessingUnit):
729
728
730 self.getData()
729 self.getData()
731
730
731 @MPDecorator
732 class SpectraHeisWriter(Operation):
732 class SpectraHeisWriter(Operation):
733 # set = None
733 # set = None
734 setFile = None
734 setFile = None
@@ -736,8 +736,8 class SpectraHeisWriter(Operation):
736 doypath = None
736 doypath = None
737 subfolder = None
737 subfolder = None
738
738
739 def __init__(self, **kwargs):
739 def __init__(self):#, **kwargs):
740 Operation.__init__(self, **kwargs)
740 Operation.__init__(self)#, **kwargs)
741 self.wrObj = PyFits()
741 self.wrObj = PyFits()
742 # self.dataOut = dataOut
742 # self.dataOut = dataOut
743 self.nTotalBlocks=0
743 self.nTotalBlocks=0
@@ -845,4 +845,5 class SpectraHeisWriter(Operation):
845 self.setup(dataOut, **kwargs)
845 self.setup(dataOut, **kwargs)
846 self.isConfig = True
846 self.isConfig = True
847
847
848 self.putData() No newline at end of file
848 self.putData()
849 return dataOut No newline at end of file
@@ -214,14 +214,14 def MPDecorator(BaseClass):
214 self.receiver.connect(
214 self.receiver.connect(
215 'ipc:///tmp/schain/{}_pub'.format(self.project_id))
215 'ipc:///tmp/schain/{}_pub'.format(self.project_id))
216 self.receiver.setsockopt(zmq.SUBSCRIBE, self.inputId.encode())
216 self.receiver.setsockopt(zmq.SUBSCRIBE, self.inputId.encode())
217
217
218 def listen(self):
218 def listen(self):
219 '''
219 '''
220 This function waits for objects and deserialize using pickle
220 This function waits for objects and deserialize using pickle
221 '''
221 '''
222
222
223 data = pickle.loads(self.receiver.recv_multipart()[1])
223 data = pickle.loads(self.receiver.recv_multipart()[1])
224
224
225 return data
225 return data
226
226
227 def set_publisher(self):
227 def set_publisher(self):
@@ -278,13 +278,16 def MPDecorator(BaseClass):
278 '''
278 '''
279
279
280 while True:
280 while True:
281 self.dataIn = self.listen()
281 self.dataIn = self.listen()
282
282
283 if self.dataIn.flagNoData and self.dataIn.error is None:
283 if self.dataIn.flagNoData and self.dataIn.error is None:
284 continue
284 continue
285
285
286 BaseClass.run(self, **self.kwargs)
286 BaseClass.run(self, **self.kwargs)
287
287
288 if self.dataOut.flagNoData:
289 continue
290
288 for op, optype, opId, kwargs in self.operations:
291 for op, optype, opId, kwargs in self.operations:
289 if optype == 'self':
292 if optype == 'self':
290 op(**kwargs)
293 op(**kwargs)
@@ -304,7 +307,7 def MPDecorator(BaseClass):
304 Run function for external operations (this operations just receive data
307 Run function for external operations (this operations just receive data
305 ex: plots, writers, publishers)
308 ex: plots, writers, publishers)
306 '''
309 '''
307
310
308 while True:
311 while True:
309
312
310 dataOut = self.listen()
313 dataOut = self.listen()
@@ -316,11 +319,12 def MPDecorator(BaseClass):
316 time.sleep(1)
319 time.sleep(1)
317
320
318 def run(self):
321 def run(self):
319
320 if self.typeProc is "ProcUnit":
322 if self.typeProc is "ProcUnit":
321
323
322 if self.inputId is not None:
324 if self.inputId is not None:
325
323 self.subscribe()
326 self.subscribe()
327
324 self.set_publisher()
328 self.set_publisher()
325
329
326 if 'Reader' not in BaseClass.__name__:
330 if 'Reader' not in BaseClass.__name__:
@@ -1,13 +1,16
1 import numpy
1 import numpy
2
2
3 from .jroproc_base import ProcessingUnit, Operation
3 from .jroproc_base import ProcessingUnit, Operation, MPDecorator
4 from schainpy.model.data.jrodata import SpectraHeis
4 from schainpy.model.data.jrodata import SpectraHeis
5 from schainpy.utils import log
5
6
7
8 @MPDecorator
6 class SpectraHeisProc(ProcessingUnit):
9 class SpectraHeisProc(ProcessingUnit):
7
10
8 def __init__(self, **kwargs):
11 def __init__(self):#, **kwargs):
9
12
10 ProcessingUnit.__init__(self, **kwargs)
13 ProcessingUnit.__init__(self)#, **kwargs)
11
14
12 # self.buffer = None
15 # self.buffer = None
13 # self.firstdatatime = None
16 # self.firstdatatime = None
@@ -86,7 +89,7 class SpectraHeisProc(ProcessingUnit):
86 if self.dataIn.type == "Fits":
89 if self.dataIn.type == "Fits":
87 self.__updateObjFromFits()
90 self.__updateObjFromFits()
88 self.dataOut.flagNoData = False
91 self.dataOut.flagNoData = False
89 return
92 return
90
93
91 if self.dataIn.type == "SpectraHeis":
94 if self.dataIn.type == "SpectraHeis":
92 self.dataOut.copy(self.dataIn)
95 self.dataOut.copy(self.dataIn)
@@ -145,6 +148,7 class SpectraHeisProc(ProcessingUnit):
145
148
146 return 1
149 return 1
147
150
151
148 class IncohInt4SpectraHeis(Operation):
152 class IncohInt4SpectraHeis(Operation):
149
153
150 isConfig = False
154 isConfig = False
@@ -163,9 +167,9 class IncohInt4SpectraHeis(Operation):
163
167
164 n = None
168 n = None
165
169
166 def __init__(self, **kwargs):
170 def __init__(self):#, **kwargs):
167
171
168 Operation.__init__(self, **kwargs)
172 Operation.__init__(self)#, **kwargs)
169 # self.isConfig = False
173 # self.isConfig = False
170
174
171 def setup(self, n=None, timeInterval=None, overlapping=False):
175 def setup(self, n=None, timeInterval=None, overlapping=False):
@@ -341,4 +345,6 class IncohInt4SpectraHeis(Operation):
341 dataOut.utctime = avgdatatime
345 dataOut.utctime = avgdatatime
342 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nIncohInt
346 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nIncohInt
343 # dataOut.timeInterval = self.__timeInterval*self.n
347 # dataOut.timeInterval = self.__timeInterval*self.n
344 dataOut.flagNoData = False No newline at end of file
348 dataOut.flagNoData = False
349
350 return dataOut No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now