##// END OF EJS Templates
Multiprocessing for voltage (all operations) working
George Yong -
r1173:0148df60175f
parent child
Show More
@@ -26,6 +26,7 from schainpy.model.graphics import *
26 from schainpy.model.proc.jroproc_base import *
26 from schainpy.model.proc.jroproc_base import *
27 from schainpy.model.proc.bltrproc_parameters import *
27 from schainpy.model.proc.bltrproc_parameters import *
28 from schainpy.model.proc.jroproc_spectra import *
28 from schainpy.model.proc.jroproc_spectra import *
29 from schainpy.model.proc.jroproc_voltage import *
29 from schainpy.model.proc.jroproc_parameters import *
30 from schainpy.model.proc.jroproc_parameters import *
30 from schainpy.model.utils.jroutils_publish import *
31 from schainpy.model.utils.jroutils_publish import *
31 from schainpy.utils import log
32 from schainpy.utils import log
@@ -6,15 +6,18 Created on Jul 9, 2014
6 import os
6 import os
7 import datetime
7 import datetime
8 import numpy
8 import numpy
9
9 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG
10 from schainpy.utils import log
10 from .figure import Figure
11 from .figure import Figure
11
12
13
14 @MPDecorator
12 class Scope(Figure):
15 class Scope(Figure):
13
16
14 isConfig = None
17 isConfig = None
15
18
16 def __init__(self, **kwargs):
19 def __init__(self):#, **kwargs): #YONG
17 Figure.__init__(self, **kwargs)
20 Figure.__init__(self)#, **kwargs)
18 self.isConfig = False
21 self.isConfig = False
19 self.WIDTH = 300
22 self.WIDTH = 300
20 self.HEIGHT = 200
23 self.HEIGHT = 200
@@ -127,6 +130,8 class Scope(Figure):
127 ymin : None,
130 ymin : None,
128 ymax : None,
131 ymax : None,
129 """
132 """
133 if dataOut.flagNoData:
134 return dataOut
130
135
131 if channelList == None:
136 if channelList == None:
132 channelIndexList = dataOut.channelIndexList
137 channelIndexList = dataOut.channelIndexList
@@ -222,4 +227,6 class Scope(Figure):
222 save=save,
227 save=save,
223 ftp=ftp,
228 ftp=ftp,
224 wr_period=wr_period,
229 wr_period=wr_period,
225 thisDatetime=thisDatetime) No newline at end of file
230 thisDatetime=thisDatetime)
231
232 return dataOut No newline at end of file
@@ -7,7 +7,7 Created on Jul 2, 2014
7 import numpy
7 import numpy
8
8
9 from .jroIO_base import LOCALTIME, JRODataReader, JRODataWriter
9 from .jroIO_base import LOCALTIME, JRODataReader, JRODataWriter
10 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
10 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator
11 from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader
11 from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader
12 from schainpy.model.data.jrodata import Voltage
12 from schainpy.model.data.jrodata import Voltage
13 import zmq
13 import zmq
@@ -15,7 +15,7 import tempfile
15 from io import StringIO
15 from io import StringIO
16 # from _sha import blocksize
16 # from _sha import blocksize
17
17
18
18 @MPDecorator
19 class VoltageReader(JRODataReader, ProcessingUnit):
19 class VoltageReader(JRODataReader, ProcessingUnit):
20 """
20 """
21 Esta clase permite leer datos de voltage desde archivos en formato rawdata (.r). La lectura
21 Esta clase permite leer datos de voltage desde archivos en formato rawdata (.r). La lectura
@@ -62,7 +62,7 class VoltageReader(JRODataReader, ProcessingUnit):
62 optchar = "D"
62 optchar = "D"
63 dataOut = None
63 dataOut = None
64
64
65 def __init__(self, **kwargs):
65 def __init__(self):#, **kwargs):
66 """
66 """
67 Inicializador de la clase VoltageReader para la lectura de datos de voltage.
67 Inicializador de la clase VoltageReader para la lectura de datos de voltage.
68
68
@@ -81,7 +81,7 class VoltageReader(JRODataReader, ProcessingUnit):
81 None
81 None
82 """
82 """
83
83
84 ProcessingUnit.__init__(self, **kwargs)
84 ProcessingUnit.__init__(self)#, **kwargs)
85
85
86 self.isConfig = False
86 self.isConfig = False
87
87
@@ -761,4 +761,5 class VoltageWriter(JRODataWriter, Operation):
761
761
762 self.processingHeaderObj.processFlags = self.getProcessFlags()
762 self.processingHeaderObj.processFlags = self.getProcessFlags()
763
763
764 self.setBasicHeader() No newline at end of file
764 self.setBasicHeader()
765 No newline at end of file
@@ -428,7 +428,7 def MPDecorator(BaseClass):
428 if self.dataOut.flagNoData:
428 if self.dataOut.flagNoData:
429 continue
429 continue
430
430
431 print("Publishing data...")
431 #print("Publishing data...")
432 self.publishProc(self.socket_p, self.dataOut)
432 self.publishProc(self.socket_p, self.dataOut)
433 # time.sleep(2)
433 # time.sleep(2)
434
434
@@ -445,7 +445,7 def MPDecorator(BaseClass):
445
445
446 while True:
446 while True:
447 self.dataIn = self.listenProc(self.socket_l)
447 self.dataIn = self.listenProc(self.socket_l)
448 print("%s received data" %BaseClass.__name__)
448 #print("%s received data" %BaseClass.__name__)
449
449
450 if self.dataIn == "Finish":
450 if self.dataIn == "Finish":
451 break
451 break
@@ -3,24 +3,28 import numpy
3 from scipy import interpolate
3 from scipy import interpolate
4 #TODO
4 #TODO
5 #from schainpy import cSchain
5 #from schainpy import cSchain
6 from .jroproc_base import ProcessingUnit, Operation
6 from schainpy.model.proc.jroproc_base import ProcessingUnit, MPDecorator, Operation
7 from schainpy.model.data.jrodata import Voltage
7 from schainpy.model.data.jrodata import Voltage
8 from time import time
9 from schainpy.utils import log
8 from schainpy.utils import log
9 from time import time
10
10
11
11
12 @MPDecorator
12 class VoltageProc(ProcessingUnit):
13 class VoltageProc(ProcessingUnit):
14
15 METHODS = {} #yong
13
16
17 def __init__(self):#, **kwargs): #yong
14
18
15 def __init__(self, **kwargs):
19 ProcessingUnit.__init__(self)#, **kwargs)
16
17 ProcessingUnit.__init__(self, **kwargs)
18
20
19 # self.objectDict = {}
21 # self.objectDict = {}
20 self.dataOut = Voltage()
22 self.dataOut = Voltage()
21 self.flip = 1
23 self.flip = 1
24 self.setupReq = False #yong
22
25
23 def run(self):
26 def run(self):
27
24 if self.dataIn.type == 'AMISR':
28 if self.dataIn.type == 'AMISR':
25 self.__updateObjFromAmisrInput()
29 self.__updateObjFromAmisrInput()
26
30
@@ -317,7 +321,7 class VoltageProc(ProcessingUnit):
317 self.dataOut.data[:,:,botLim:topLim+1] = ynew
321 self.dataOut.data[:,:,botLim:topLim+1] = ynew
318
322
319 # import collections
323 # import collections
320
324 @MPDecorator
321 class CohInt(Operation):
325 class CohInt(Operation):
322
326
323 isConfig = False
327 isConfig = False
@@ -333,9 +337,9 class CohInt(Operation):
333 __dataToPutStride = False
337 __dataToPutStride = False
334 n = None
338 n = None
335
339
336 def __init__(self, **kwargs):
340 def __init__(self):#, **kwargs):
337
341
338 Operation.__init__(self, **kwargs)
342 Operation.__init__(self)#, **kwargs)
339
343
340 # self.isConfig = False
344 # self.isConfig = False
341
345
@@ -549,6 +553,7 class CohInt(Operation):
549 return avgdata, avgdatatime
553 return avgdata, avgdatatime
550
554
551 def run(self, dataOut, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False, **kwargs):
555 def run(self, dataOut, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False, **kwargs):
556
552 if not self.isConfig:
557 if not self.isConfig:
553 self.setup(n=n, stride=stride, timeInterval=timeInterval, overlapping=overlapping, byblock=byblock, **kwargs)
558 self.setup(n=n, stride=stride, timeInterval=timeInterval, overlapping=overlapping, byblock=byblock, **kwargs)
554 self.isConfig = True
559 self.isConfig = True
@@ -577,7 +582,8 class CohInt(Operation):
577 # raise
582 # raise
578 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt
583 # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt
579 dataOut.flagNoData = False
584 dataOut.flagNoData = False
580
585 return dataOut
586 @MPDecorator
581 class Decoder(Operation):
587 class Decoder(Operation):
582
588
583 isConfig = False
589 isConfig = False
@@ -588,15 +594,15 class Decoder(Operation):
588 nCode = None
594 nCode = None
589 nBaud = None
595 nBaud = None
590
596
591 def __init__(self, **kwargs):
597 def __init__(self):#, **kwargs):
592
598
593 Operation.__init__(self, **kwargs)
599 Operation.__init__(self)#, **kwargs)
594
600
595 self.times = None
601 self.times = None
596 self.osamp = None
602 self.osamp = None
597 # self.__setValues = False
603 # self.__setValues = False
598 self.isConfig = False
604 # self.isConfig = False
599
605 self.setupReq = False
600 def setup(self, code, osamp, dataOut):
606 def setup(self, code, osamp, dataOut):
601
607
602 self.__profIndex = 0
608 self.__profIndex = 0
@@ -763,22 +769,22 class Decoder(Operation):
763
769
764 if self.__profIndex == self.nCode-1:
770 if self.__profIndex == self.nCode-1:
765 self.__profIndex = 0
771 self.__profIndex = 0
766 return 1
772 return dataOut
767
773
768 self.__profIndex += 1
774 self.__profIndex += 1
769
775
770 return 1
776 return dataOut
771 # dataOut.flagDeflipData = True #asumo q la data no esta sin flip
777 # dataOut.flagDeflipData = True #asumo q la data no esta sin flip
772
778
773
779 @MPDecorator
774 class ProfileConcat(Operation):
780 class ProfileConcat(Operation):
775
781
776 isConfig = False
782 isConfig = False
777 buffer = None
783 buffer = None
778
784
779 def __init__(self, **kwargs):
785 def __init__(self):#, **kwargs):
780
786
781 Operation.__init__(self, **kwargs)
787 Operation.__init__(self)#, **kwargs)
782 self.profileIndex = 0
788 self.profileIndex = 0
783
789
784 def reset(self):
790 def reset(self):
@@ -820,16 +826,17 class ProfileConcat(Operation):
820 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m
826 xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m
821 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight)
827 dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight)
822 dataOut.ippSeconds *= m
828 dataOut.ippSeconds *= m
823
829 return dataOut
830 @MPDecorator
824 class ProfileSelector(Operation):
831 class ProfileSelector(Operation):
825
832
826 profileIndex = None
833 profileIndex = None
827 # Tamanho total de los perfiles
834 # Tamanho total de los perfiles
828 nProfiles = None
835 nProfiles = None
829
836
830 def __init__(self, **kwargs):
837 def __init__(self):#, **kwargs):
831
838
832 Operation.__init__(self, **kwargs)
839 Operation.__init__(self)#, **kwargs)
833 self.profileIndex = 0
840 self.profileIndex = 0
834
841
835 def incProfileIndex(self):
842 def incProfileIndex(self):
@@ -979,13 +986,14 class ProfileSelector(Operation):
979
986
980 raise ValueError("ProfileSelector needs profileList, profileRangeList or rangeList parameter")
987 raise ValueError("ProfileSelector needs profileList, profileRangeList or rangeList parameter")
981
988
982 return False
989 #return False
983
990 return dataOut
991 @MPDecorator
984 class Reshaper(Operation):
992 class Reshaper(Operation):
985
993
986 def __init__(self, **kwargs):
994 def __init__(self):#, **kwargs):
987
995
988 Operation.__init__(self, **kwargs)
996 Operation.__init__(self)#, **kwargs)
989
997
990 self.__buffer = None
998 self.__buffer = None
991 self.__nitems = 0
999 self.__nitems = 0
@@ -1084,11 +1092,13 class Reshaper(Operation):
1084
1092
1085 dataOut.ippSeconds /= self.__nTxs
1093 dataOut.ippSeconds /= self.__nTxs
1086
1094
1095 return dataOut
1096 @MPDecorator
1087 class SplitProfiles(Operation):
1097 class SplitProfiles(Operation):
1088
1098
1089 def __init__(self, **kwargs):
1099 def __init__(self):#, **kwargs):
1090
1100
1091 Operation.__init__(self, **kwargs)
1101 Operation.__init__(self)#, **kwargs)
1092
1102
1093 def run(self, dataOut, n):
1103 def run(self, dataOut, n):
1094
1104
@@ -1102,8 +1112,9 class SplitProfiles(Operation):
1102
1112
1103 if shape[2] % n != 0:
1113 if shape[2] % n != 0:
1104 raise ValueError("Could not split the data, n=%d has to be multiple of %d" %(n, shape[2]))
1114 raise ValueError("Could not split the data, n=%d has to be multiple of %d" %(n, shape[2]))
1105
1115
1106 new_shape = shape[0], shape[1]*n, int(shape[2]/n)
1116 new_shape = shape[0], shape[1]*n, int(shape[2]/n)
1117
1107 dataOut.data = numpy.reshape(dataOut.data, new_shape)
1118 dataOut.data = numpy.reshape(dataOut.data, new_shape)
1108 dataOut.flagNoData = False
1119 dataOut.flagNoData = False
1109
1120
@@ -1123,10 +1134,12 class SplitProfiles(Operation):
1123
1134
1124 dataOut.ippSeconds /= n
1135 dataOut.ippSeconds /= n
1125
1136
1137 return dataOut
1138 @MPDecorator
1126 class CombineProfiles(Operation):
1139 class CombineProfiles(Operation):
1127 def __init__(self, **kwargs):
1140 def __init__(self):#, **kwargs):
1128
1141
1129 Operation.__init__(self, **kwargs)
1142 Operation.__init__(self)#, **kwargs)
1130
1143
1131 self.__remData = None
1144 self.__remData = None
1132 self.__profileIndex = 0
1145 self.__profileIndex = 0
@@ -1184,6 +1197,7 class CombineProfiles(Operation):
1184
1197
1185 dataOut.ippSeconds *= n
1198 dataOut.ippSeconds *= n
1186
1199
1200 return dataOut
1187 # import collections
1201 # import collections
1188 # from scipy.stats import mode
1202 # from scipy.stats import mode
1189 #
1203 #
@@ -1318,4 +1332,4 class CombineProfiles(Operation):
1318 #
1332 #
1319 # self.__startIndex += self.__newNSamples
1333 # self.__startIndex += self.__newNSamples
1320 #
1334 #
1321 # return No newline at end of file
1335 # return
General Comments 0
You need to be logged in to leave comments. Login now