@@ -24,6 +24,7 DTYPES = { | |||||
24 | 'Spectra': '.pdata' |
|
24 | 'Spectra': '.pdata' | |
25 | } |
|
25 | } | |
26 |
|
26 | |||
|
27 | ||||
27 | def MPProject(project, n=cpu_count()): |
|
28 | def MPProject(project, n=cpu_count()): | |
28 | ''' |
|
29 | ''' | |
29 | Project wrapper to run schain in n processes |
|
30 | Project wrapper to run schain in n processes | |
@@ -72,6 +73,7 def MPProject(project, n=cpu_count()): | |||||
72 |
|
73 | |||
73 | time.sleep(3) |
|
74 | time.sleep(3) | |
74 |
|
75 | |||
|
76 | ||||
75 | class ParameterConf(): |
|
77 | class ParameterConf(): | |
76 |
|
78 | |||
77 | id = None |
|
79 | id = None | |
@@ -261,6 +263,7 class ParameterConf(): | |||||
261 |
|
263 | |||
262 | print 'Parameter[%s]: name = %s, value = %s, format = %s' %(self.id, self.name, self.value, self.format) |
|
264 | print 'Parameter[%s]: name = %s, value = %s, format = %s' % (self.id, self.name, self.value, self.format) | |
263 |
|
265 | |||
|
266 | ||||
264 | class OperationConf(): |
|
267 | class OperationConf(): | |
265 |
|
268 | |||
266 | id = None |
|
269 | id = None | |
@@ -279,7 +282,6 class OperationConf(): | |||||
279 | self.priority = None |
|
282 | self.priority = None | |
280 | self.type = 'self' |
|
283 | self.type = 'self' | |
281 |
|
284 | |||
282 |
|
||||
283 | def __getNewId(self): |
|
285 | def __getNewId(self): | |
284 |
|
286 | |||
285 | return int(self.id)*10 + len(self.parmConfObjList) + 1 |
|
287 | return int(self.id) * 10 + len(self.parmConfObjList) + 1 | |
@@ -337,7 +339,6 class OperationConf(): | |||||
337 |
|
339 | |||
338 | return value |
|
340 | return value | |
339 |
|
341 | |||
340 |
|
||||
341 | def getKwargs(self): |
|
342 | def getKwargs(self): | |
342 |
|
343 | |||
343 | kwargs = {} |
|
344 | kwargs = {} | |
@@ -440,7 +441,6 class OperationConf(): | |||||
440 |
|
441 | |||
441 | def createObject(self, plotter_queue=None): |
|
442 | def createObject(self, plotter_queue=None): | |
442 |
|
443 | |||
443 |
|
||||
444 | if self.type == 'self': |
|
444 | if self.type == 'self': | |
445 | raise ValueError, 'This operation type cannot be created' |
|
445 | raise ValueError, 'This operation type cannot be created' | |
446 |
|
446 | |||
@@ -505,7 +505,6 class ProcUnitConf(): | |||||
505 |
|
505 | |||
506 | def updateId(self, new_id, parentId=parentId): |
|
506 | def updateId(self, new_id, parentId=parentId): | |
507 |
|
507 | |||
508 |
|
||||
509 | new_id = int(parentId)*10 + (int(self.id) % 10) |
|
508 | new_id = int(parentId) * 10 + (int(self.id) % 10) | |
510 | new_inputId = int(parentId)*10 + (int(self.inputId) % 10) |
|
509 | new_inputId = int(parentId) * 10 + (int(self.inputId) % 10) | |
511 |
|
510 | |||
@@ -525,7 +524,6 class ProcUnitConf(): | |||||
525 | self.id = str(new_id) |
|
524 | self.id = str(new_id) | |
526 | self.inputId = str(new_inputId) |
|
525 | self.inputId = str(new_inputId) | |
527 |
|
526 | |||
528 |
|
||||
529 | def getInputId(self): |
|
527 | def getInputId(self): | |
530 |
|
528 | |||
531 | return self.inputId |
|
529 | return self.inputId | |
@@ -659,7 +657,6 class ProcUnitConf(): | |||||
659 | for opConfObj in self.opConfObjList: |
|
657 | for opConfObj in self.opConfObjList: | |
660 | opConfObj.printattr() |
|
658 | opConfObj.printattr() | |
661 |
|
659 | |||
662 |
|
||||
663 | def getKwargs(self): |
|
660 | def getKwargs(self): | |
664 |
|
661 | |||
665 | opObj = self.opConfObjList[0] |
|
662 | opObj = self.opConfObjList[0] | |
@@ -678,7 +675,8 class ProcUnitConf(): | |||||
678 | if opConfObj.type=='self' and self.name=='run': |
|
675 | if opConfObj.type == 'self' and self.name == 'run': | |
679 | continue |
|
676 | continue | |
680 | elif opConfObj.type=='self': |
|
677 | elif opConfObj.type == 'self': | |
681 |
procUnitObj.addOperationKwargs( |
|
678 | procUnitObj.addOperationKwargs( | |
|
679 | opConfObj.id, **opConfObj.getKwargs()) | |||
682 | continue |
|
680 | continue | |
683 |
|
681 | |||
684 | opObj = opConfObj.createObject(plotter_queue) |
|
682 | opObj = opConfObj.createObject(plotter_queue) | |
@@ -725,6 +723,7 class ProcUnitConf(): | |||||
725 |
|
723 | |||
726 | return |
|
724 | return | |
727 |
|
725 | |||
|
726 | ||||
728 | class ReadUnitConf(ProcUnitConf): |
|
727 | class ReadUnitConf(ProcUnitConf): | |
729 |
|
728 | |||
730 | path = None |
|
729 | path = None | |
@@ -790,7 +789,8 class ReadUnitConf(ProcUnitConf): | |||||
790 | self.name = '%sReader' %(datatype) |
|
789 | self.name = '%sReader' % (datatype) | |
791 | self.datatype = self.name.replace('Reader', '') |
|
790 | self.datatype = self.name.replace('Reader', '') | |
792 |
|
791 | |||
793 |
attrs = ('path', 'startDate', 'endDate', |
|
792 | attrs = ('path', 'startDate', 'endDate', | |
|
793 | 'startTime', 'endTime', 'parentId') | |||
794 |
|
794 | |||
795 | for attr in attrs: |
|
795 | for attr in attrs: | |
796 | if attr in kwargs: |
|
796 | if attr in kwargs: | |
@@ -811,19 +811,24 class ReadUnitConf(ProcUnitConf): | |||||
811 |
opObj = self.addOperation(name |
|
811 | opObj = self.addOperation(name='run', optype='self') | |
812 |
|
812 | |||
813 | if self.server is None: |
|
813 | if self.server is None: | |
814 | opObj.addParameter(name='datatype', value=self.datatype, format='str') |
|
814 | opObj.addParameter( | |
|
815 | name='datatype', value=self.datatype, format='str') | |||
815 | opObj.addParameter(name='path', value=self.path, format='str') |
|
816 | opObj.addParameter(name='path', value=self.path, format='str') | |
816 | opObj.addParameter(name='startDate', value=self.startDate, format='date') |
|
817 | opObj.addParameter( | |
817 |
|
|
818 | name='startDate', value=self.startDate, format='date') | |
818 | opObj.addParameter(name='startTime', value=self.startTime, format='time') |
|
819 | opObj.addParameter( | |
819 |
|
|
820 | name='endDate', value=self.endDate, format='date') | |
|
821 | opObj.addParameter( | |||
|
822 | name='startTime', value=self.startTime, format='time') | |||
|
823 | opObj.addParameter( | |||
|
824 | name='endTime', value=self.endTime, format='time') | |||
820 |
|
825 | |||
821 | for key, value in kwargs.items(): |
|
826 | for key, value in kwargs.items(): | |
822 |
opObj.addParameter(name=key, value=value, |
|
827 | opObj.addParameter(name=key, value=value, | |
|
828 | format=type(value).__name__) | |||
823 | else: |
|
829 | else: | |
824 |
opObj.addParameter(name='server' |
|
830 | opObj.addParameter(name='server', value=self.server, format='str') | |
825 |
|
831 | |||
826 |
|
||||
827 | return opObj |
|
832 | return opObj | |
828 |
|
833 | |||
829 | def updateRunOperation(self, **kwargs): |
|
834 | def updateRunOperation(self, **kwargs): | |
@@ -833,13 +838,16 class ReadUnitConf(ProcUnitConf): | |||||
833 |
|
838 | |||
834 | opObj.addParameter(name='datatype', value=self.datatype, format='str') |
|
839 | opObj.addParameter(name='datatype', value=self.datatype, format='str') | |
835 | opObj.addParameter(name='path', value=self.path, format='str') |
|
840 | opObj.addParameter(name='path', value=self.path, format='str') | |
836 | opObj.addParameter(name='startDate', value=self.startDate, format='date') |
|
841 | opObj.addParameter( | |
|
842 | name='startDate', value=self.startDate, format='date') | |||
837 | opObj.addParameter(name='endDate', value=self.endDate, format='date') |
|
843 | opObj.addParameter(name='endDate', value=self.endDate, format='date') | |
838 | opObj.addParameter(name='startTime', value=self.startTime, format='time') |
|
844 | opObj.addParameter( | |
|
845 | name='startTime', value=self.startTime, format='time') | |||
839 | opObj.addParameter(name='endTime', value=self.endTime, format='time') |
|
846 | opObj.addParameter(name='endTime', value=self.endTime, format='time') | |
840 |
|
847 | |||
841 | for key, value in kwargs.items(): |
|
848 | for key, value in kwargs.items(): | |
842 |
opObj.addParameter(name=key, value=value, |
|
849 | opObj.addParameter(name=key, value=value, | |
|
850 | format=type(value).__name__) | |||
843 |
|
851 | |||
844 | return opObj |
|
852 | return opObj | |
845 |
|
853 | |||
@@ -872,6 +880,7 class ReadUnitConf(ProcUnitConf): | |||||
872 | self.startTime = opConfObj.getParameterValue('startTime') |
|
880 | self.startTime = opConfObj.getParameterValue('startTime') | |
873 | self.endTime = opConfObj.getParameterValue('endTime') |
|
881 | self.endTime = opConfObj.getParameterValue('endTime') | |
874 |
|
882 | |||
|
883 | ||||
875 | class Project(Process): |
|
884 | class Project(Process): | |
876 |
|
885 | |||
877 | id = None |
|
886 | id = None | |
@@ -969,7 +978,8 class Project(Process): | |||||
969 | idReadUnit = str(id) |
|
978 | idReadUnit = str(id) | |
970 |
|
979 | |||
971 | readUnitConfObj = ReadUnitConf() |
|
980 | readUnitConfObj = ReadUnitConf() | |
972 |
readUnitConfObj.setup(idReadUnit, name, datatype, |
|
981 | readUnitConfObj.setup(idReadUnit, name, datatype, | |
|
982 | parentId=self.id, **kwargs) | |||
973 |
|
983 | |||
974 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
984 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
975 |
|
985 | |||
@@ -980,7 +990,8 class Project(Process): | |||||
980 | idProcUnit = self.__getNewId() |
|
990 | idProcUnit = self.__getNewId() | |
981 |
|
991 | |||
982 | procUnitConfObj = ProcUnitConf() |
|
992 | procUnitConfObj = ProcUnitConf() | |
983 |
procUnitConfObj.setup(idProcUnit, name, datatype, |
|
993 | procUnitConfObj.setup(idProcUnit, name, datatype, | |
|
994 | inputId, parentId=self.id) | |||
984 |
|
995 | |||
985 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj |
|
996 | self.procUnitConfObjDict[procUnitConfObj.getId()] = procUnitConfObj | |
986 |
|
997 | |||
@@ -1096,7 +1107,8 class Project(Process): | |||||
1096 | self.name = self.projectElement.get('name') |
|
1107 | self.name = self.projectElement.get('name') | |
1097 |
self.description = self.projectElement.get('description') |
|
1108 | self.description = self.projectElement.get('description') | |
1098 |
|
1109 | |||
1099 |
readUnitElementList = self.projectElement.iter( |
|
1110 | readUnitElementList = self.projectElement.iter( | |
|
1111 | ReadUnitConf().getElementName()) | |||
1100 |
|
1112 | |||
1101 | for readUnitElement in readUnitElementList: |
|
1113 | for readUnitElement in readUnitElementList: | |
1102 | readUnitConfObj = ReadUnitConf() |
|
1114 | readUnitConfObj = ReadUnitConf() | |
@@ -1107,7 +1119,8 class Project(Process): | |||||
1107 |
|
1119 | |||
1108 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj |
|
1120 | self.procUnitConfObjDict[readUnitConfObj.getId()] = readUnitConfObj | |
1109 |
|
1121 | |||
1110 |
procUnitElementList = self.projectElement.iter( |
|
1122 | procUnitElementList = self.projectElement.iter( | |
|
1123 | ProcUnitConf().getElementName()) | |||
1111 |
|
1124 | |||
1112 | for procUnitElement in procUnitElementList: |
|
1125 | for procUnitElement in procUnitElementList: | |
1113 | procUnitConfObj = ProcUnitConf() |
|
1126 | procUnitConfObj = ProcUnitConf() | |
@@ -1176,10 +1189,13 class Project(Process): | |||||
1176 | if not send_email: |
|
1189 | if not send_email: | |
1177 | return |
|
1190 | return | |
1178 |
|
1191 | |||
1179 |
subject = |
|
1192 | subject = 'SChain v%s: Error running %s\n' % ( | |
|
1193 | schainpy.__version__, procUnitConfObj.name) | |||
1180 |
|
1194 | |||
1181 | subtitle = '%s: %s\n' %(procUnitConfObj.getElementName() ,procUnitConfObj.name) |
|
1195 | subtitle = '%s: %s\n' % ( | |
1182 | subtitle += 'Hostname: %s\n' %socket.gethostbyname(socket.gethostname()) |
|
1196 | procUnitConfObj.getElementName(), procUnitConfObj.name) | |
|
1197 | subtitle += 'Hostname: %s\n' % socket.gethostbyname( | |||
|
1198 | socket.gethostname()) | |||
1183 | subtitle += 'Working directory: %s\n' %os.path.abspath('./') |
|
1199 | subtitle += 'Working directory: %s\n' % os.path.abspath('./') | |
1184 | subtitle += 'Configuration file: %s\n' %self.filename |
|
1200 | subtitle += 'Configuration file: %s\n' % self.filename | |
1185 | subtitle += 'Time: %s\n' %str(datetime.datetime.now()) |
|
1201 | subtitle += 'Time: %s\n' % str(datetime.datetime.now()) |
@@ -15,6 +15,7 import tempfile | |||||
15 | from StringIO import StringIO |
|
15 | from StringIO import StringIO | |
16 | # from _sha import blocksize |
|
16 | # from _sha import blocksize | |
17 |
|
17 | |||
|
18 | ||||
18 | class VoltageReader(JRODataReader, ProcessingUnit): |
|
19 | class VoltageReader(JRODataReader, ProcessingUnit): | |
19 | """ |
|
20 | """ | |
20 | 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 | |
@@ -177,7 +178,6 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
177 |
|
178 | |||
178 | return 0 |
|
179 | return 0 | |
179 |
|
180 | |||
180 |
|
||||
181 | def getBlockDimension(self): |
|
181 | def getBlockDimension(self): | |
182 | """ |
|
182 | """ | |
183 | Obtiene la cantidad de puntos a leer por cada bloque de datos |
|
183 | Obtiene la cantidad de puntos a leer por cada bloque de datos | |
@@ -188,11 +188,10 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
188 | Return: |
|
188 | Return: | |
189 | None |
|
189 | None | |
190 | """ |
|
190 | """ | |
191 |
pts2read = self.processingHeaderObj.profilesPerBlock * |
|
191 | pts2read = self.processingHeaderObj.profilesPerBlock * \ | |
|
192 | self.processingHeaderObj.nHeights * self.systemHeaderObj.nChannels | |||
192 | self.blocksize = pts2read |
|
193 | self.blocksize = pts2read | |
193 |
|
194 | |||
194 |
|
||||
195 |
|
||||
196 | def readBlock(self): |
|
195 | def readBlock(self): | |
197 | """ |
|
196 | """ | |
198 | readBlock lee el bloque de datos desde la posicion actual del puntero del archivo |
|
197 | readBlock lee el bloque de datos desde la posicion actual del puntero del archivo | |
@@ -230,13 +229,15 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
230 |
junk = numpy.fromfile( |
|
229 | junk = numpy.fromfile(self.fp, self.dtype, self.blocksize) | |
231 |
|
230 | |||
232 | try: |
|
231 | try: | |
233 |
junk = junk.reshape( |
|
232 | junk = junk.reshape((self.processingHeaderObj.profilesPerBlock, | |
|
233 | self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels)) | |||
234 | except: |
|
234 | except: | |
235 | #print "The read block (%3d) has not enough data" %self.nReadBlocks |
|
235 | # print "The read block (%3d) has not enough data" %self.nReadBlocks | |
236 |
|
236 | |||
237 | if self.waitDataBlock(pointer_location=current_pointer_location): |
|
237 | if self.waitDataBlock(pointer_location=current_pointer_location): | |
238 |
junk = numpy.fromfile( |
|
238 | junk = numpy.fromfile(self.fp, self.dtype, self.blocksize) | |
239 |
junk = junk.reshape( |
|
239 | junk = junk.reshape((self.processingHeaderObj.profilesPerBlock, | |
|
240 | self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels)) | |||
240 | # return 0 |
|
241 | # return 0 | |
241 |
|
242 | |||
242 | #Dimensions : nChannels, nProfiles, nSamples |
|
243 | # Dimensions : nChannels, nProfiles, nSamples | |
@@ -280,15 +281,18 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
280 |
|
281 | |||
281 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock |
|
282 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock | |
282 |
|
283 | |||
283 | self.dataOut.heightList = numpy.arange(self.processingHeaderObj.nHeights) *self.processingHeaderObj.deltaHeight + self.processingHeaderObj.firstHeight |
|
284 | self.dataOut.heightList = numpy.arange( | |
|
285 | self.processingHeaderObj.nHeights) * self.processingHeaderObj.deltaHeight + self.processingHeaderObj.firstHeight | |||
284 |
|
286 | |||
285 | self.dataOut.channelList = range(self.systemHeaderObj.nChannels) |
|
287 | self.dataOut.channelList = range(self.systemHeaderObj.nChannels) | |
286 |
|
288 | |||
287 | self.dataOut.nCohInt = self.processingHeaderObj.nCohInt |
|
289 | self.dataOut.nCohInt = self.processingHeaderObj.nCohInt | |
288 |
|
290 | |||
289 | self.dataOut.flagDecodeData = self.processingHeaderObj.flag_decode #asumo q la data no esta decodificada |
|
291 | # asumo q la data no esta decodificada | |
|
292 | self.dataOut.flagDecodeData = self.processingHeaderObj.flag_decode | |||
290 |
|
293 | |||
291 | self.dataOut.flagDeflipData = self.processingHeaderObj.flag_deflip #asumo q la data no esta sin flip |
|
294 | # asumo q la data no esta sin flip | |
|
295 | self.dataOut.flagDeflipData = self.processingHeaderObj.flag_deflip | |||
292 |
|
296 | |||
293 | self.dataOut.flagShiftFFT = self.processingHeaderObj.shif_fft |
|
297 | self.dataOut.flagShiftFFT = self.processingHeaderObj.shif_fft | |
294 |
|
298 | |||
@@ -301,15 +305,19 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
301 | return |
|
305 | return | |
302 |
|
306 | |||
303 | if self.nTxs < 1 and self.processingHeaderObj.profilesPerBlock % (1./self.nTxs) != 0: |
|
307 | if self.nTxs < 1 and self.processingHeaderObj.profilesPerBlock % (1. / self.nTxs) != 0: | |
304 |
raise ValueError, "1./nTxs (=%f), should be a multiple of nProfiles (=%d)" %( |
|
308 | raise ValueError, "1./nTxs (=%f), should be a multiple of nProfiles (=%d)" % ( | |
|
309 | 1. / self.nTxs, self.processingHeaderObj.profilesPerBlock) | |||
305 |
|
310 | |||
306 | if self.nTxs > 1 and self.processingHeaderObj.nHeights % self.nTxs != 0: |
|
311 | if self.nTxs > 1 and self.processingHeaderObj.nHeights % self.nTxs != 0: | |
307 |
raise ValueError, "nTxs (=%d), should be a multiple of nHeights (=%d)" %( |
|
312 | raise ValueError, "nTxs (=%d), should be a multiple of nHeights (=%d)" % ( | |
|
313 | self.nTxs, self.processingHeaderObj.nHeights) | |||
308 |
|
314 | |||
309 | self.datablock = self.datablock.reshape((self.systemHeaderObj.nChannels, self.processingHeaderObj.profilesPerBlock*self.nTxs, self.processingHeaderObj.nHeights/self.nTxs)) |
|
315 | self.datablock = self.datablock.reshape( | |
|
316 | (self.systemHeaderObj.nChannels, self.processingHeaderObj.profilesPerBlock * self.nTxs, self.processingHeaderObj.nHeights / self.nTxs)) | |||
310 |
|
317 | |||
311 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs |
|
318 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock * self.nTxs | |
312 |
self.dataOut.heightList = numpy.arange(self.processingHeaderObj.nHeights/self.nTxs) * |
|
319 | self.dataOut.heightList = numpy.arange(self.processingHeaderObj.nHeights / self.nTxs) * \ | |
|
320 | self.processingHeaderObj.deltaHeight + self.processingHeaderObj.firstHeight | |||
313 | self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs |
|
321 | self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds / self.nTxs | |
314 |
|
322 | |||
315 | return |
|
323 | return | |
@@ -320,7 +328,8 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
320 |
|
328 | |||
321 | self.firstHeaderSize = self.basicHeaderObj.size |
|
329 | self.firstHeaderSize = self.basicHeaderObj.size | |
322 |
|
330 | |||
323 |
datatype = int(numpy.log2((self.processingHeaderObj.processFlags & |
|
331 | datatype = int(numpy.log2((self.processingHeaderObj.processFlags & | |
|
332 | PROCFLAG.DATATYPE_MASK)) - numpy.log2(PROCFLAG.DATATYPE_CHAR)) | |||
324 | if datatype == 0: |
|
333 | if datatype == 0: | |
325 | datatype_str = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
334 | datatype_str = numpy.dtype([('real', '<i1'), ('imag', '<i1')]) | |
326 | elif datatype == 1: |
|
335 | elif datatype == 1: | |
@@ -338,12 +347,13 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
338 |
|
347 | |||
339 | self.dtype = datatype_str |
|
348 | self.dtype = datatype_str | |
340 | #self.ippSeconds = 2 * 1000 * self.radarControllerHeaderObj.ipp / self.c |
|
349 | #self.ippSeconds = 2 * 1000 * self.radarControllerHeaderObj.ipp / self.c | |
341 |
self.fileSizeByHeader = self.processingHeaderObj.dataBlocksPerFile * self.processingHeaderObj.blockSize + |
|
350 | self.fileSizeByHeader = self.processingHeaderObj.dataBlocksPerFile * self.processingHeaderObj.blockSize + \ | |
|
351 | self.firstHeaderSize + self.basicHeaderSize * \ | |||
|
352 | (self.processingHeaderObj.dataBlocksPerFile - 1) | |||
342 | # self.dataOut.channelList = numpy.arange(self.systemHeaderObj.numChannels) |
|
353 | # self.dataOut.channelList = numpy.arange(self.systemHeaderObj.numChannels) | |
343 | # self.dataOut.channelIndexList = numpy.arange(self.systemHeaderObj.numChannels) |
|
354 | # self.dataOut.channelIndexList = numpy.arange(self.systemHeaderObj.numChannels) | |
344 | self.getBlockDimension() |
|
355 | self.getBlockDimension() | |
345 |
|
356 | |||
346 |
|
||||
347 |
def getFromServer(self): |
|
357 | def getFromServer(self): | |
348 | self.flagDiscontinuousBlock = 0 |
|
358 | self.flagDiscontinuousBlock = 0 | |
349 | self.profileIndex = 0 |
|
359 | self.profileIndex = 0 | |
@@ -368,15 +378,19 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
368 | timestamp = self.basicHeaderObj.get_datatime() |
|
378 | timestamp = self.basicHeaderObj.get_datatime() | |
369 | print '[Reading] - Block {} - {}'.format(self.nTotalBlocks, timestamp) |
|
379 | print '[Reading] - Block {} - {}'.format(self.nTotalBlocks, timestamp) | |
370 | current_pointer_location = self.blockPointer |
|
380 | current_pointer_location = self.blockPointer | |
371 | junk = numpy.fromstring( block[self.blockPointer:], self.dtype, self.blocksize ) |
|
381 | junk = numpy.fromstring( | |
|
382 | block[self.blockPointer:], self.dtype, self.blocksize) | |||
372 |
|
383 | |||
373 | try: |
|
384 | try: | |
374 |
junk = junk.reshape( |
|
385 | junk = junk.reshape((self.processingHeaderObj.profilesPerBlock, | |
|
386 | self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels)) | |||
375 | except: |
|
387 | except: | |
376 | #print "The read block (%3d) has not enough data" %self.nReadBlocks |
|
388 | # print "The read block (%3d) has not enough data" %self.nReadBlocks | |
377 | if self.waitDataBlock(pointer_location=current_pointer_location): |
|
389 | if self.waitDataBlock(pointer_location=current_pointer_location): | |
378 | junk = numpy.fromstring( block[self.blockPointer:], self.dtype, self.blocksize ) |
|
390 | junk = numpy.fromstring( | |
379 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) |
|
391 | block[self.blockPointer:], self.dtype, self.blocksize) | |
|
392 | junk = junk.reshape((self.processingHeaderObj.profilesPerBlock, | |||
|
393 | self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels)) | |||
380 | # return 0 |
|
394 | # return 0 | |
381 |
|
395 | |||
382 | #Dimensions : nChannels, nProfiles, nSamples |
|
396 | # Dimensions : nChannels, nProfiles, nSamples | |
@@ -384,17 +398,21 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
384 | junk = numpy.transpose(junk, (2,0,1)) |
|
398 | junk = numpy.transpose(junk, (2, 0, 1)) | |
385 |
self.datablock = junk['real'] + junk['imag'] * 1j |
|
399 | self.datablock = junk['real'] + junk['imag'] * 1j | |
386 | self.profileIndex = 0 |
|
400 | self.profileIndex = 0 | |
387 |
if self.selBlocksize == None: |
|
401 | if self.selBlocksize == None: | |
|
402 | self.selBlocksize = self.dataOut.nProfiles | |||
388 | if self.selBlocktime != None: |
|
403 | if self.selBlocktime != None: | |
389 | if self.dataOut.nCohInt is not None: |
|
404 | if self.dataOut.nCohInt is not None: | |
390 | nCohInt = self.dataOut.nCohInt |
|
405 | nCohInt = self.dataOut.nCohInt | |
391 | else: |
|
406 | else: | |
392 | nCohInt = 1 |
|
407 | nCohInt = 1 | |
393 |
self.selBlocksize = int(self.dataOut.nProfiles*round(self.selBlocktime/( |
|
408 | self.selBlocksize = int(self.dataOut.nProfiles * round(self.selBlocktime / ( | |
394 | self.dataOut.data = self.datablock[:,self.profileIndex:self.profileIndex+self.selBlocksize,:] |
|
409 | nCohInt * self.dataOut.ippSeconds * self.dataOut.nProfiles))) | |
|
410 | self.dataOut.data = self.datablock[:, | |||
|
411 | self.profileIndex:self.profileIndex + self.selBlocksize, :] | |||
395 | datasize = self.dataOut.data.shape[1] |
|
412 | datasize = self.dataOut.data.shape[1] | |
396 | if datasize < self.selBlocksize: |
|
413 | if datasize < self.selBlocksize: | |
397 | buffer = numpy.zeros((self.dataOut.data.shape[0], self.selBlocksize, self.dataOut.data.shape[2]), dtype = 'complex') |
|
414 | buffer = numpy.zeros( | |
|
415 | (self.dataOut.data.shape[0], self.selBlocksize, self.dataOut.data.shape[2]), dtype='complex') | |||
398 | buffer[:,:datasize,:] = self.dataOut.data |
|
416 | buffer[:, :datasize, :] = self.dataOut.data | |
399 | self.dataOut.data = buffer |
|
417 | self.dataOut.data = buffer | |
400 | self.profileIndex = blockIndex |
|
418 | self.profileIndex = blockIndex | |
@@ -486,20 +504,24 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
486 | """ |
|
504 | """ | |
487 | Return a block |
|
505 | Return a block | |
488 | """ |
|
506 | """ | |
489 |
if self.selBlocksize == None: |
|
507 | if self.selBlocksize == None: | |
|
508 | self.selBlocksize = self.dataOut.nProfiles | |||
490 | if self.selBlocktime != None: |
|
509 | if self.selBlocktime != None: | |
491 | if self.dataOut.nCohInt is not None: |
|
510 | if self.dataOut.nCohInt is not None: | |
492 | nCohInt = self.dataOut.nCohInt |
|
511 | nCohInt = self.dataOut.nCohInt | |
493 | else: |
|
512 | else: | |
494 | nCohInt = 1 |
|
513 | nCohInt = 1 | |
495 |
self.selBlocksize = int(self.dataOut.nProfiles*round(self.selBlocktime/( |
|
514 | self.selBlocksize = int(self.dataOut.nProfiles * round(self.selBlocktime / ( | |
|
515 | nCohInt * self.dataOut.ippSeconds * self.dataOut.nProfiles))) | |||
496 |
|
516 | |||
497 |
self.dataOut.data = self.datablock[:, |
|
517 | self.dataOut.data = self.datablock[:, | |
|
518 | self.profileIndex:self.profileIndex + self.selBlocksize, :] | |||
498 | self.profileIndex += self.selBlocksize |
|
519 | self.profileIndex += self.selBlocksize | |
499 | datasize = self.dataOut.data.shape[1] |
|
520 | datasize = self.dataOut.data.shape[1] | |
500 |
|
521 | |||
501 | if datasize < self.selBlocksize: |
|
522 | if datasize < self.selBlocksize: | |
502 | buffer = numpy.zeros((self.dataOut.data.shape[0],self.selBlocksize,self.dataOut.data.shape[2]), dtype = 'complex') |
|
523 | buffer = numpy.zeros( | |
|
524 | (self.dataOut.data.shape[0], self.selBlocksize, self.dataOut.data.shape[2]), dtype='complex') | |||
503 | buffer[:,:datasize,:] = self.dataOut.data |
|
525 | buffer[:, :datasize, :] = self.dataOut.data | |
504 |
|
526 | |||
505 | while datasize < self.selBlocksize: #Not enough profiles to fill the block |
|
527 | while datasize < self.selBlocksize: # Not enough profiles to fill the block | |
@@ -514,7 +536,8 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
514 | blockIndex = self.selBlocksize - datasize |
|
536 | blockIndex = self.selBlocksize - datasize | |
515 | datablock1 = self.datablock[:,:blockIndex,:] |
|
537 | datablock1 = self.datablock[:, :blockIndex, :] | |
516 |
|
538 | |||
517 |
buffer[:,datasize:datasize+ |
|
539 | buffer[:, datasize:datasize + | |
|
540 | datablock1.shape[1], :] = datablock1 | |||
518 | datasize += datablock1.shape[1] |
|
541 | datasize += datablock1.shape[1] | |
519 |
|
542 | |||
520 | self.dataOut.data = buffer |
|
543 | self.dataOut.data = buffer | |
@@ -531,6 +554,7 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
531 |
|
554 | |||
532 | return self.dataOut.data |
|
555 | return self.dataOut.data | |
533 |
|
556 | |||
|
557 | ||||
534 | class VoltageWriter(JRODataWriter, Operation): |
|
558 | class VoltageWriter(JRODataWriter, Operation): | |
535 | """ |
|
559 | """ | |
536 | Esta clase permite escribir datos de voltajes a archivos procesados (.r). La escritura |
|
560 | Esta clase permite escribir datos de voltajes a archivos procesados (.r). La escritura | |
@@ -543,7 +567,6 class VoltageWriter(JRODataWriter, Operation): | |||||
543 |
|
567 | |||
544 | shapeBuffer = None |
|
568 | shapeBuffer = None | |
545 |
|
569 | |||
546 |
|
||||
547 | def __init__(self, **kwargs): |
|
570 | def __init__(self, **kwargs): | |
548 | """ |
|
571 | """ | |
549 | Inicializador de la clase VoltageWriter para la escritura de datos de espectros. |
|
572 | Inicializador de la clase VoltageWriter para la escritura de datos de espectros. | |
@@ -590,7 +613,6 class VoltageWriter(JRODataWriter, Operation): | |||||
590 | return 1 |
|
613 | return 1 | |
591 | return 0 |
|
614 | return 0 | |
592 |
|
615 | |||
593 |
|
||||
594 | def setBlockDimension(self): |
|
616 | def setBlockDimension(self): | |
595 | """ |
|
617 | """ | |
596 | Obtiene las formas dimensionales del los subbloques de datos que componen un bloque |
|
618 | Obtiene las formas dimensionales del los subbloques de datos que componen un bloque | |
@@ -689,12 +711,12 class VoltageWriter(JRODataWriter, Operation): | |||||
689 |
|
711 | |||
690 | dtype_width = self.getDtypeWidth() |
|
712 | dtype_width = self.getDtypeWidth() | |
691 |
|
713 | |||
692 |
blocksize = int(self.dataOut.nHeights * self.dataOut.nChannels * |
|
714 | blocksize = int(self.dataOut.nHeights * self.dataOut.nChannels * | |
|
715 | self.profilesPerBlock * dtype_width * 2) | |||
693 |
|
716 | |||
694 | return blocksize |
|
717 | return blocksize | |
695 |
|
718 | |||
696 | def setFirstHeader(self): |
|
719 | def setFirstHeader(self): | |
697 |
|
||||
698 | """ |
|
720 | """ | |
699 | Obtiene una copia del First Header |
|
721 | Obtiene una copia del First Header | |
700 |
|
722 | |||
@@ -715,10 +737,13 class VoltageWriter(JRODataWriter, Operation): | |||||
715 | self.processingHeaderObj.blockSize = self.__getBlockSize() |
|
737 | self.processingHeaderObj.blockSize = self.__getBlockSize() | |
716 | self.processingHeaderObj.profilesPerBlock = self.profilesPerBlock |
|
738 | self.processingHeaderObj.profilesPerBlock = self.profilesPerBlock | |
717 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile |
|
739 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile | |
718 |
|
|
740 | # podria ser 1 o self.dataOut.processingHeaderObj.nWindows | |
|
741 | self.processingHeaderObj.nWindows = 1 | |||
719 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt |
|
742 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt | |
720 |
|
|
743 | # Cuando la data de origen es de tipo Voltage | |
721 | self.processingHeaderObj.totalSpectra = 0 # Cuando la data de origen es de tipo Voltage |
|
744 | self.processingHeaderObj.nIncohInt = 1 | |
|
745 | # Cuando la data de origen es de tipo Voltage | |||
|
746 | self.processingHeaderObj.totalSpectra = 0 | |||
722 |
|
747 | |||
723 | if self.dataOut.code is not None: |
|
748 | if self.dataOut.code is not None: | |
724 | self.processingHeaderObj.code = self.dataOut.code |
|
749 | self.processingHeaderObj.code = self.dataOut.code | |
@@ -727,7 +752,8 class VoltageWriter(JRODataWriter, Operation): | |||||
727 |
|
752 | |||
728 | if self.processingHeaderObj.nWindows != 0: |
|
753 | if self.processingHeaderObj.nWindows != 0: | |
729 | self.processingHeaderObj.firstHeight = self.dataOut.heightList[0] |
|
754 | self.processingHeaderObj.firstHeight = self.dataOut.heightList[0] | |
730 |
self.processingHeaderObj.deltaHeight = self.dataOut.heightList[1] - |
|
755 | self.processingHeaderObj.deltaHeight = self.dataOut.heightList[1] - \ | |
|
756 | self.dataOut.heightList[0] | |||
731 | self.processingHeaderObj.nHeights = self.dataOut.nHeights |
|
757 | self.processingHeaderObj.nHeights = self.dataOut.nHeights | |
732 | self.processingHeaderObj.samplesWin = self.dataOut.nHeights |
|
758 | self.processingHeaderObj.samplesWin = self.dataOut.nHeights | |
733 |
|
759 |
General Comments 0
You need to be logged in to leave comments.
Login now