##// END OF EJS Templates
-Using ValueError raises instead of IOError...
Miguel Valdez -
r684:ab5af7e4405a
parent child
Show More
@@ -112,7 +112,7 class GenericData(object):
112
112
113 def __init__(self):
113 def __init__(self):
114
114
115 raise ValueError, "This class has not been implemented"
115 raise NotImplementedError
116
116
117 def copy(self, inputObj=None):
117 def copy(self, inputObj=None):
118
118
@@ -216,11 +216,11 class JROData(GenericData):
216
216
217 def __init__(self):
217 def __init__(self):
218
218
219 raise ValueError, "This class has not been implemented"
219 raise NotImplementedError
220
220
221 def getNoise(self):
221 def getNoise(self):
222
222
223 raise ValueError, "Not implemented"
223 raise NotImplementedError
224
224
225 def getNChannels(self):
225 def getNChannels(self):
226
226
@@ -341,9 +341,6 class JROData(GenericData):
341 self.radarControllerHeaderObj.nBaud = nBaud
341 self.radarControllerHeaderObj.nBaud = nBaud
342
342
343 return
343 return
344 # def getTimeInterval(self):
345 #
346 # raise IOError, "This method should be implemented inside each Class"
347
344
348 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
345 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
349 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
346 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
@@ -69,18 +69,18 PROCESSING_STRUCTURE = numpy.dtype([
69 class Header(object):
69 class Header(object):
70
70
71 def __init__(self):
71 def __init__(self):
72 raise
72 raise NotImplementedError
73
73
74 def copy(self):
74 def copy(self):
75 return copy.deepcopy(self)
75 return copy.deepcopy(self)
76
76
77 def read(self):
77 def read(self):
78
78
79 raise ValueError
79 raise NotImplementedError
80
80
81 def write(self):
81 def write(self):
82
82
83 raise ValueError
83 raise NotImplementedError
84
84
85 def printInfo(self):
85 def printInfo(self):
86
86
@@ -122,24 +122,24 class BasicHeader(Header):
122 self.useLocalTime = useLocalTime
122 self.useLocalTime = useLocalTime
123
123
124 def read(self, fp):
124 def read(self, fp):
125
125 try:
126 try:
126
127 header = numpy.fromfile(fp, BASIC_STRUCTURE,1)
127 header = numpy.fromfile(fp, BASIC_STRUCTURE,1)
128
128
129 self.size = int(header['nSize'][0])
130 self.version = int(header['nVersion'][0])
131 self.dataBlock = int(header['nDataBlockId'][0])
132 self.utc = int(header['nUtime'][0])
133 self.miliSecond = int(header['nMilsec'][0])
134 self.timeZone = int(header['nTimezone'][0])
135 self.dstFlag = int(header['nDstflag'][0])
136 self.errorCount = int(header['nErrorCount'][0])
137
138 except Exception, e:
129 except Exception, e:
139 print "BasicHeader: "
130 print "BasicHeader: "
140 print e
131 print e
141 return 0
132 return 0
142
133
134 self.size = int(header['nSize'][0])
135 self.version = int(header['nVersion'][0])
136 self.dataBlock = int(header['nDataBlockId'][0])
137 self.utc = int(header['nUtime'][0])
138 self.miliSecond = int(header['nMilsec'][0])
139 self.timeZone = int(header['nTimezone'][0])
140 self.dstFlag = int(header['nDstflag'][0])
141 self.errorCount = int(header['nErrorCount'][0])
142
143 return 1
143 return 1
144
144
145 def write(self, fp):
145 def write(self, fp):
@@ -189,22 +189,22 class SystemHeader(Header):
189
189
190 try:
190 try:
191 header = numpy.fromfile(fp,SYSTEM_STRUCTURE,1)
191 header = numpy.fromfile(fp,SYSTEM_STRUCTURE,1)
192
193 self.size = header['nSize'][0]
194 self.nSamples = header['nNumSamples'][0]
195 self.nProfiles = header['nNumProfiles'][0]
196 self.nChannels = header['nNumChannels'][0]
197 self.adcResolution = header['nADCResolution'][0]
198 self.pciDioBusWidth = header['nPCDIOBusWidth'][0]
199
200 except Exception, e:
192 except Exception, e:
201 print "SystemHeader: " + e
193 print "SystemHeader: " + e
202 return 0
194 return 0
203
195
196 self.size = header['nSize'][0]
197 self.nSamples = header['nNumSamples'][0]
198 self.nProfiles = header['nNumProfiles'][0]
199 self.nChannels = header['nNumChannels'][0]
200 self.adcResolution = header['nADCResolution'][0]
201 self.pciDioBusWidth = header['nPCDIOBusWidth'][0]
202
204 endFp = self.size + startFp
203 endFp = self.size + startFp
205
204
206 if fp.tell() != endFp:
205 if fp.tell() != endFp:
207 raise IOError, "System Header is not consistent"
206 print "System Header is not consistent"
207 return 0
208
208
209 return 1
209 return 1
210
210
@@ -286,7 +286,11 class RadarControllerHeader(Header):
286
286
287
287
288 startFp = fp.tell()
288 startFp = fp.tell()
289 header = numpy.fromfile(fp,RADAR_STRUCTURE,1)
289 try:
290 header = numpy.fromfile(fp,RADAR_STRUCTURE,1)
291 except Exception, e:
292 print "RadarControllerHeader: " + e
293 return 0
290
294
291 size = int(header['nSize'][0])
295 size = int(header['nSize'][0])
292 self.expType = int(header['nExpType'][0])
296 self.expType = int(header['nExpType'][0])
@@ -339,7 +343,8 class RadarControllerHeader(Header):
339 endFp = size + startFp
343 endFp = size + startFp
340
344
341 if fp.tell() != endFp:
345 if fp.tell() != endFp:
342 raise IOError, "Radar Controller Header is not consistent"
346 print "Radar Controller Header is not consistent"
347 return 0
343
348
344 return 1
349 return 1
345
350
@@ -484,7 +489,11 class ProcessingHeader(Header):
484
489
485 startFp = fp.tell()
490 startFp = fp.tell()
486
491
487 header = numpy.fromfile(fp,PROCESSING_STRUCTURE,1)
492 try:
493 header = numpy.fromfile(fp,PROCESSING_STRUCTURE,1)
494 except Exception, e:
495 print "ProcessingHeader: " + e
496 return 0
488
497
489 size = int(header['nSize'][0])
498 size = int(header['nSize'][0])
490 self.dtype = int(header['nDataType'][0])
499 self.dtype = int(header['nDataType'][0])
@@ -553,7 +562,8 class ProcessingHeader(Header):
553 endFp = size + startFp
562 endFp = size + startFp
554
563
555 if fp.tell() != endFp:
564 if fp.tell() != endFp:
556 raise IOError, "Processing Header is not consistent"
565 print "Processing Header is not consistent"
566 return 0
557
567
558 return 1
568 return 1
559
569
@@ -258,8 +258,8 class HDF5Reader(ProcessingUnit):
258 try:
258 try:
259 fp = fp = h5py.File(filename,'r')
259 fp = fp = h5py.File(filename,'r')
260 except IOError:
260 except IOError:
261 traceback.print_exc()
261 print "File %s can't be opened" %(filename)
262 raise IOError, "The file %s can't be opened" %(filename)
262 return None
263
263
264 grp = fp['Data']
264 grp = fp['Data']
265 timeAux = grp['time']
265 timeAux = grp['time']
@@ -68,8 +68,8 def isFileInEpoch(filename, startUTSeconds, endUTSeconds):
68 try:
68 try:
69 fp = open(filename,'rb')
69 fp = open(filename,'rb')
70 except IOError:
70 except IOError:
71 traceback.print_exc()
71 print "The file %s can't be opened" %(filename)
72 raise IOError, "The file %s can't be opened" %(filename)
72 return 0
73
73
74 sts = basicHeaderObj.read(fp)
74 sts = basicHeaderObj.read(fp)
75 fp.close()
75 fp.close()
@@ -112,8 +112,8 def isFileInTimeRange(filename, startDate, endDate, startTime, endTime):
112 try:
112 try:
113 fp = open(filename,'rb')
113 fp = open(filename,'rb')
114 except IOError:
114 except IOError:
115 traceback.print_exc()
115 print "The file %s can't be opened" %(filename)
116 raise IOError, "The file %s can't be opened" %(filename)
116 return None
117
117
118 basicHeaderObj = BasicHeader(LOCALTIME)
118 basicHeaderObj = BasicHeader(LOCALTIME)
119 sts = basicHeaderObj.read(fp)
119 sts = basicHeaderObj.read(fp)
@@ -182,7 +182,8 def isFolderInDateRange(folder, startDate=None, endDate=None):
182 basename = os.path.basename(folder)
182 basename = os.path.basename(folder)
183
183
184 if not isRadarFolder(basename):
184 if not isRadarFolder(basename):
185 raise IOError, "The folder %s has not the rigth format" %folder
185 print "The folder %s has not the rigth format" %folder
186 return 0
186
187
187 if startDate and endDate:
188 if startDate and endDate:
188 thisDate = getDateFromRadarFolder(basename)
189 thisDate = getDateFromRadarFolder(basename)
@@ -223,7 +224,8 def isFileInDateRange(filename, startDate=None, endDate=None):
223 basename = os.path.basename(filename)
224 basename = os.path.basename(filename)
224
225
225 if not isRadarFile(basename):
226 if not isRadarFile(basename):
226 raise IOError, "The filename %s has not the rigth format" %filename
227 print "The filename %s has not the rigth format" %filename
228 return 0
227
229
228 if startDate and endDate:
230 if startDate and endDate:
229 thisDate = getDateFromRadarFile(basename)
231 thisDate = getDateFromRadarFile(basename)
@@ -477,11 +479,11 class JRODataIO:
477
479
478 def __init__(self):
480 def __init__(self):
479
481
480 raise ValueError, "Not implemented"
482 raise NotImplementedError
481
483
482 def run(self):
484 def run(self):
483
485
484 raise ValueError, "Not implemented"
486 raise NotImplementedError
485
487
486 def getDtypeWidth(self):
488 def getDtypeWidth(self):
487
489
@@ -526,21 +528,25 class JRODataReader(JRODataIO):
526 def __init__(self):
528 def __init__(self):
527
529
528 """
530 """
529
531 This class is used to find data files
530 """
531
532
532 # raise NotImplementedError, "This method has not been implemented"
533 Example:
534 reader = JRODataReader()
535 fileList = reader.findDataFiles()
536
537 """
538 pass
533
539
534
540
535 def createObjByDefault(self):
541 def createObjByDefault(self):
536 """
542 """
537
543
538 """
544 """
539 raise NotImplementedError, "This method has not been implemented"
545 raise NotImplementedError
540
546
541 def getBlockDimension(self):
547 def getBlockDimension(self):
542
548
543 raise NotImplementedError, "No implemented"
549 raise NotImplementedError
544
550
545 def __searchFilesOffLine(self,
551 def __searchFilesOffLine(self,
546 path,
552 path,
@@ -561,9 +567,9 class JRODataReader(JRODataIO):
561 dateList, pathList = self.findDatafiles(path, startDate, endDate, expLabel, ext, walk, include_path=True)
567 dateList, pathList = self.findDatafiles(path, startDate, endDate, expLabel, ext, walk, include_path=True)
562
568
563 if dateList == []:
569 if dateList == []:
564 print "[Reading] No *%s files in %s from %s to %s)"%(ext, path,
570 # print "[Reading] No *%s files in %s from %s to %s)"%(ext, path,
565 datetime.datetime.combine(startDate,startTime).ctime(),
571 # datetime.datetime.combine(startDate,startTime).ctime(),
566 datetime.datetime.combine(endDate,endTime).ctime())
572 # datetime.datetime.combine(endDate,endTime).ctime())
567
573
568 return None, None
574 return None, None
569
575
@@ -1006,16 +1012,19 class JRODataReader(JRODataIO):
1006 self.getBlockDimension()
1012 self.getBlockDimension()
1007
1013
1008 def __verifyFile(self, filename, msgFlag=True):
1014 def __verifyFile(self, filename, msgFlag=True):
1015
1009 msg = None
1016 msg = None
1017
1010 try:
1018 try:
1011 fp = open(filename, 'rb')
1019 fp = open(filename, 'rb')
1012 currentPosition = fp.tell()
1013 except IOError:
1020 except IOError:
1014 traceback.print_exc()
1021
1015 if msgFlag:
1022 if msgFlag:
1016 print "[Reading] The file %s can't be opened" % (filename)
1023 print "[Reading] File %s can't be opened" % (filename)
1024
1017 return False
1025 return False
1018
1026
1027 currentPosition = fp.tell()
1019 neededSize = self.processingHeaderObj.blockSize + self.firstHeaderSize
1028 neededSize = self.processingHeaderObj.blockSize + self.firstHeaderSize
1020
1029
1021 if neededSize == 0:
1030 if neededSize == 0:
@@ -1023,34 +1032,35 class JRODataReader(JRODataIO):
1023 systemHeaderObj = SystemHeader()
1032 systemHeaderObj = SystemHeader()
1024 radarControllerHeaderObj = RadarControllerHeader()
1033 radarControllerHeaderObj = RadarControllerHeader()
1025 processingHeaderObj = ProcessingHeader()
1034 processingHeaderObj = ProcessingHeader()
1026
1035
1027 try:
1036 if not( basicHeaderObj.read(fp) ):
1028 if not( basicHeaderObj.read(fp) ): raise IOError
1037 fp.close()
1029 if not( systemHeaderObj.read(fp) ): raise IOError
1038 return False
1030 if not( radarControllerHeaderObj.read(fp) ): raise IOError
1039
1031 if not( processingHeaderObj.read(fp) ): raise IOError
1040 if not( systemHeaderObj.read(fp) ):
1032 # data_type = int(numpy.log2((processingHeaderObj.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR))
1033
1034 neededSize = processingHeaderObj.blockSize + basicHeaderObj.size
1035
1036 except IOError:
1037 traceback.print_exc()
1038 # sys.exit(0)
1039
1040 if msgFlag:
1041 print "[Reading] The file %s is empty or it hasn't enough data" % filename
1042
1043 fp.close()
1041 fp.close()
1044 return False
1042 return False
1043
1044 if not( radarControllerHeaderObj.read(fp) ):
1045 fp.close()
1046 return False
1047
1048 if not( processingHeaderObj.read(fp) ):
1049 fp.close()
1050 return False
1051
1052 neededSize = processingHeaderObj.blockSize + basicHeaderObj.size
1045 else:
1053 else:
1046 msg = "[Reading] Skipping the file %s due to it hasn't enough data" %filename
1054 msg = "[Reading] Skipping the file %s due to it hasn't enough data" %filename
1047
1055
1048 fp.close()
1056 fp.close()
1057
1049 fileSize = os.path.getsize(filename)
1058 fileSize = os.path.getsize(filename)
1050 currentSize = fileSize - currentPosition
1059 currentSize = fileSize - currentPosition
1060
1051 if currentSize < neededSize:
1061 if currentSize < neededSize:
1052 if msgFlag and (msg != None):
1062 if msgFlag and (msg != None):
1053 print msg #print"\tSkipping the file %s due to it hasn't enough data" %filename
1063 print msg
1054 return False
1064 return False
1055
1065
1056 return True
1066 return True
@@ -1129,6 +1139,14 class JRODataReader(JRODataIO):
1129
1139
1130 dateList.sort()
1140 dateList.sort()
1131
1141
1142 if walk:
1143 pattern_path = os.path.join(multi_path[0], "[dYYYYDDD]", expLabel)
1144 else:
1145 pattern_path = multi_path[0]
1146
1147 if not dateList:
1148 print "[Reading] No *%s files in %s from %s to %s" %(ext, pattern_path, startDate, endDate)
1149
1132 if include_path:
1150 if include_path:
1133 return dateList, pathList
1151 return dateList, pathList
1134
1152
@@ -1187,9 +1205,9 class JRODataReader(JRODataIO):
1187 walk=walk)
1205 walk=walk)
1188
1206
1189 if not(pathList):
1207 if not(pathList):
1190 print "[Reading] No *%s files in %s (%s - %s)"%(ext, path,
1208 # print "[Reading] No *%s files in %s (%s - %s)"%(ext, path,
1191 datetime.datetime.combine(startDate,startTime).ctime(),
1209 # datetime.datetime.combine(startDate,startTime).ctime(),
1192 datetime.datetime.combine(endDate,endTime).ctime())
1210 # datetime.datetime.combine(endDate,endTime).ctime())
1193
1211
1194 # sys.exit(-1)
1212 # sys.exit(-1)
1195
1213
@@ -1253,19 +1271,19 class JRODataReader(JRODataIO):
1253
1271
1254 def getFirstHeader(self):
1272 def getFirstHeader(self):
1255
1273
1256 raise ValueError, "This method has not been implemented"
1274 raise NotImplementedError
1257
1275
1258 def getData(self):
1276 def getData(self):
1259
1277
1260 raise ValueError, "This method has not been implemented"
1278 raise NotImplementedError
1261
1279
1262 def hasNotDataInBuffer(self):
1280 def hasNotDataInBuffer(self):
1263
1281
1264 raise ValueError, "This method has not been implemented"
1282 raise NotImplementedError
1265
1283
1266 def readBlock(self):
1284 def readBlock(self):
1267
1285
1268 raise ValueError, "This method has not been implemented"
1286 raise NotImplementedError
1269
1287
1270 def isEndProcess(self):
1288 def isEndProcess(self):
1271
1289
@@ -1331,23 +1349,23 class JRODataWriter(JRODataIO):
1331 fileDate = None
1349 fileDate = None
1332
1350
1333 def __init__(self, dataOut=None):
1351 def __init__(self, dataOut=None):
1334 raise ValueError, "Not implemented"
1352 raise NotImplementedError
1335
1353
1336
1354
1337 def hasAllDataInBuffer(self):
1355 def hasAllDataInBuffer(self):
1338 raise ValueError, "Not implemented"
1356 raise NotImplementedError
1339
1357
1340
1358
1341 def setBlockDimension(self):
1359 def setBlockDimension(self):
1342 raise ValueError, "Not implemented"
1360 raise NotImplementedError
1343
1361
1344
1362
1345 def writeBlock(self):
1363 def writeBlock(self):
1346 raise ValueError, "No implemented"
1364 raise NotImplementedError
1347
1365
1348
1366
1349 def putData(self):
1367 def putData(self):
1350 raise ValueError, "No implemented"
1368 raise NotImplementedError
1351
1369
1352
1370
1353 def getProcessFlags(self):
1371 def getProcessFlags(self):
@@ -1413,7 +1431,7 class JRODataWriter(JRODataIO):
1413 None
1431 None
1414 """
1432 """
1415
1433
1416 raise ValueError, "No implemented"
1434 raise NotImplementedError
1417
1435
1418 def __writeFirstHeader(self):
1436 def __writeFirstHeader(self):
1419 """
1437 """
@@ -326,7 +326,8 class FitsReader(ProcessingUnit):
326 try:
326 try:
327 fitsObj = pyfits.open(filename,'readonly')
327 fitsObj = pyfits.open(filename,'readonly')
328 except:
328 except:
329 raise IOError, "The file %s can't be opened" %(filename)
329 print "File %s can't be opened" %(filename)
330 return None
330
331
331 header = fitsObj[0].header
332 header = fitsObj[0].header
332 struct_time = time.strptime(header['DATETIME'], "%b %d %Y %H:%M:%S")
333 struct_time = time.strptime(header['DATETIME'], "%b %d %Y %H:%M:%S")
@@ -344,7 +345,7 class FitsReader(ProcessingUnit):
344 return thisDatetime
345 return thisDatetime
345
346
346 def __setNextFileOnline(self):
347 def __setNextFileOnline(self):
347 raise ValueError, "No implemented"
348 raise NotImplementedError
348
349
349 def __setNextFileOffline(self):
350 def __setNextFileOffline(self):
350 idFile = self.fileIndex
351 idFile = self.fileIndex
@@ -605,7 +606,7 class FitsReader(ProcessingUnit):
605 return 1
606 return 1
606
607
607 def __jumpToLastBlock(self):
608 def __jumpToLastBlock(self):
608 raise ValueError, "No implemented"
609 raise NotImplementedError
609
610
610 def __waitNewBlock(self):
611 def __waitNewBlock(self):
611 """
612 """
@@ -211,7 +211,7 class USRPReader(ProcessingUnit):
211 buffer_size = nbuffer
211 buffer_size = nbuffer
212
212
213 if not os.path.isdir(path):
213 if not os.path.isdir(path):
214 raise ValueError, "[Reading] This path %s does not exist" %path
214 raise ValueError, "[Reading] Directory %s does not exist" %path
215
215
216 try:
216 try:
217 self.digitalReadObj = digital_rf_hdf5.read_hdf5(path, load_all_metadata=True)
217 self.digitalReadObj = digital_rf_hdf5.read_hdf5(path, load_all_metadata=True)
@@ -221,7 +221,7 class USRPReader(ProcessingUnit):
221 channelNameList = self.digitalReadObj.get_channels()
221 channelNameList = self.digitalReadObj.get_channels()
222
222
223 if not channelNameList:
223 if not channelNameList:
224 raise IOError, "[Reading] The path doesn,t have any files .. "
224 raise ValueError, "[Reading] Directory %s does not have any files" %path
225
225
226 if not channelList:
226 if not channelList:
227 channelList = range(len(channelNameList))
227 channelList = range(len(channelNameList))
@@ -249,9 +249,9 class USRPReader(ProcessingUnit):
249 except:
249 except:
250 codeType = 0
250 codeType = 0
251
251
252 nCode = 0
252 nCode = 1
253 nBaud = 0
253 nBaud = 1
254 code = None
254 code = [1]
255
255
256 if codeType:
256 if codeType:
257 nCode = this_metadata_file['nCode'].value
257 nCode = this_metadata_file['nCode'].value
@@ -109,7 +109,7 class USRPReaderAPI(USRPReader, threading.Thread):
109 '''
109 '''
110
110
111 if not self.isConfig:
111 if not self.isConfig:
112 raise IOError, 'setup() method has to be called before start()'
112 raise RuntimeError, 'setup() method has to be called before start()'
113
113
114 while True:
114 while True:
115
115
@@ -75,7 +75,7 class ProcessingUnit(object):
75 **kwargs : Diccionario de argumentos de la funcion a ejecutar
75 **kwargs : Diccionario de argumentos de la funcion a ejecutar
76 """
76 """
77
77
78 raise ValueError, "ImplementedError"
78 raise NotImplementedError
79
79
80 def callMethod(self, name, **kwargs):
80 def callMethod(self, name, **kwargs):
81
81
@@ -187,17 +187,17 class ProcessingUnit(object):
187 if opType == 'self':
187 if opType == 'self':
188
188
189 if not opName:
189 if not opName:
190 raise IOError, "opName parameter should be defined"
190 raise ValueError, "opName parameter should be defined"
191
191
192 sts = self.callMethod(opName, **kwargs)
192 sts = self.callMethod(opName, **kwargs)
193
193
194 if opType == 'other' or opType == 'external':
194 if opType == 'other' or opType == 'external':
195
195
196 if not opId:
196 if not opId:
197 raise IOError, "opId parameter should be defined"
197 raise ValueError, "opId parameter should be defined"
198
198
199 if opId not in self.operations2RunDict.keys():
199 if opId not in self.operations2RunDict.keys():
200 raise IOError, "This id operation have not been registered"
200 raise ValueError, "Id operation has not been registered"
201
201
202 sts = self.callObject(opId, **kwargs)
202 sts = self.callObject(opId, **kwargs)
203
203
@@ -223,11 +223,11 class ProcessingUnit(object):
223
223
224 def setup(self):
224 def setup(self):
225
225
226 raise ValueError, "Not implemented"
226 raise NotImplementedError
227
227
228 def run(self):
228 def run(self):
229
229
230 raise ValueError, "Not implemented"
230 raise NotImplementedError
231
231
232 def close(self):
232 def close(self):
233 #Close every thread, queue or any other object here is it is neccesary.
233 #Close every thread, queue or any other object here is it is neccesary.
@@ -256,7 +256,7 class Operation(object):
256
256
257 self.isConfig = True
257 self.isConfig = True
258
258
259 raise ValueError, "Not implemented"
259 raise NotImplementedError
260
260
261 def run(self, dataIn, **kwargs):
261 def run(self, dataIn, **kwargs):
262
262
@@ -279,7 +279,7 class Operation(object):
279 if not self.isConfig:
279 if not self.isConfig:
280 self.setup(**kwargs)
280 self.setup(**kwargs)
281
281
282 raise ValueError, "ImplementedError"
282 raise NotImplementedError
283
283
284 def close(self):
284 def close(self):
285
285
@@ -119,7 +119,6 class SpectraProc(ProcessingUnit):
119
119
120 if nProfiles == None:
120 if nProfiles == None:
121 nProfiles = nFFTPoints
121 nProfiles = nFFTPoints
122 # raise ValueError, "This SpectraProc.run() need nProfiles input variable"
123
122
124 if ippFactor == None:
123 if ippFactor == None:
125 ippFactor = 1
124 ippFactor = 1
@@ -272,7 +271,6 class SpectraProc(ProcessingUnit):
272
271
273 if (maxHei > self.dataOut.heightList[-1]):
272 if (maxHei > self.dataOut.heightList[-1]):
274 maxHei = self.dataOut.heightList[-1]
273 maxHei = self.dataOut.heightList[-1]
275 # raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
276
274
277 minIndex = 0
275 minIndex = 0
278 maxIndex = 0
276 maxIndex = 0
@@ -359,9 +357,6 class SpectraProc(ProcessingUnit):
359
357
360 if (maxIndex >= self.dataOut.nHeights):
358 if (maxIndex >= self.dataOut.nHeights):
361 maxIndex = self.dataOut.nHeights-1
359 maxIndex = self.dataOut.nHeights-1
362 # raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
363
364 # nHeights = maxIndex - minIndex + 1
365
360
366 #Spectra
361 #Spectra
367 data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]
362 data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]
@@ -99,7 +99,6 class VoltageProc(ProcessingUnit):
99 print channelIndexList
99 print channelIndexList
100 raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex
100 raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex
101
101
102 # nChannels = len(channelIndexList)
103 if self.dataOut.flagDataAsBlock:
102 if self.dataOut.flagDataAsBlock:
104 """
103 """
105 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
104 Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis]
@@ -138,15 +137,10 class VoltageProc(ProcessingUnit):
138
137
139 if (minHei < self.dataOut.heightList[0]):
138 if (minHei < self.dataOut.heightList[0]):
140 minHei = self.dataOut.heightList[0]
139 minHei = self.dataOut.heightList[0]
141 # raise ValueError, "height range [%d,%d] is not valid. Data height range is [%d, %d]" % (minHei,
140
142 # maxHei,
143 # self.dataOut.heightList[0],
144 # self.dataOut.heightList[-1])
145
146 if (maxHei > self.dataOut.heightList[-1]):
141 if (maxHei > self.dataOut.heightList[-1]):
147 maxHei = self.dataOut.heightList[-1]
142 maxHei = self.dataOut.heightList[-1]
148 # raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei)
143
149
150 minIndex = 0
144 minIndex = 0
151 maxIndex = 0
145 maxIndex = 0
152 heights = self.dataOut.heightList
146 heights = self.dataOut.heightList
@@ -187,14 +181,11 class VoltageProc(ProcessingUnit):
187 """
181 """
188
182
189 if (minIndex < 0) or (minIndex > maxIndex):
183 if (minIndex < 0) or (minIndex > maxIndex):
190 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
184 raise ValueError, "Height index range (%d,%d) is not valid" % (minIndex, maxIndex)
191
185
192 if (maxIndex >= self.dataOut.nHeights):
186 if (maxIndex >= self.dataOut.nHeights):
193 maxIndex = self.dataOut.nHeights
187 maxIndex = self.dataOut.nHeights
194 # raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
188
195
196 # nHeights = maxIndex - minIndex + 1
197
198 #voltage
189 #voltage
199 if self.dataOut.flagDataAsBlock:
190 if self.dataOut.flagDataAsBlock:
200 """
191 """
@@ -563,8 +554,7 class Decoder(Operation):
563 self.__nHeis = dataOut.nHeights
554 self.__nHeis = dataOut.nHeights
564
555
565 if self.__nHeis < self.nBaud:
556 if self.__nHeis < self.nBaud:
566 print 'IOError: Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
557 raise ValueError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
567 raise IOError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud)
568
558
569 #Frequency
559 #Frequency
570 __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex)
560 __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex)
@@ -602,14 +592,6 class Decoder(Operation):
602
592
603 raise NotImplementedError
593 raise NotImplementedError
604
594
605 # fft_code = self.fft_code[self.__profIndex].reshape(1,-1)
606 #
607 # data = cfunctions.decoder(fft_code, data)
608 #
609 # datadec = data#[:,:]
610 #
611 # return datadec
612
613 def __convolutionInTime(self, data):
595 def __convolutionInTime(self, data):
614
596
615 code = self.code[self.__profIndex]
597 code = self.code[self.__profIndex]
@@ -654,8 +636,7 class Decoder(Operation):
654
636
655 if code is None:
637 if code is None:
656 if dataOut.code is None:
638 if dataOut.code is None:
657 print "Code is not defined"
639 raise ValueError, "Code could not be read from %s instance. Enter a value in Code parameter" %dataOut.type
658 raise ValueError, "Code could not be read from %s object. Enter a value in Code parameter" %dataOut.type
659
640
660 code = dataOut.code
641 code = dataOut.code
661 else:
642 else:
@@ -750,7 +731,6 class ProfileConcat(Operation):
750 self.isConfig = True
731 self.isConfig = True
751
732
752 if dataOut.flagDataAsBlock:
733 if dataOut.flagDataAsBlock:
753
754 raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False"
734 raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False"
755
735
756 else:
736 else:
General Comments 0
You need to be logged in to leave comments. Login now