##// END OF EJS Templates
Fix searching files correctly in jroIO_base & Spectra shift
jespinoza -
r1270:8e736242aff9
parent child
Show More
@@ -591,6 +591,7 class Reader(object):
591 def setNextFile(self):
591 def setNextFile(self):
592 """Set the next file to be readed open it and parse de file header"""
592 """Set the next file to be readed open it and parse de file header"""
593
593
594 while True:
594 if self.fp != None:
595 if self.fp != None:
595 self.fp.close()
596 self.fp.close()
596
597
@@ -608,8 +609,8 class Reader(object):
608 else:
609 else:
609 raise schainpy.admin.SchainWarning('No more files to read')
610 raise schainpy.admin.SchainWarning('No more files to read')
610
611
611 if not(self.verifyFile(self.filename)):
612 if self.verifyFile(self.filename):
612 self.setNextFile()
613 break
613
614
614 log.log('Opening file: %s' % self.filename, self.name)
615 log.log('Opening file: %s' % self.filename, self.name)
615
616
@@ -683,6 +684,15 class Reader(object):
683
684
684 return 1
685 return 1
685
686
687 @staticmethod
688 def isDateTimeInRange(dt, startDate, endDate, startTime, endTime):
689 """Check if the given datetime is in range"""
690
691 if startDate <= dt.date() <= endDate:
692 if startTime <= dt.time() <= endTime:
693 return True
694 return False
695
686 def verifyFile(self, filename):
696 def verifyFile(self, filename):
687 """Check for a valid file
697 """Check for a valid file
688
698
@@ -893,7 +903,8 class JRODataReader(Reader):
893 return 0
903 return 0
894
904
895 self.getBasicHeader()
905 self.getBasicHeader()
896 if (self.dataOut.datatime < datetime.datetime.combine(self.startDate, self.startTime)) or (self.dataOut.datatime > datetime.datetime.combine(self.endDate, self.endTime)):
906
907 if not self.isDateTimeInRange(self.dataOut.datatime, self.startDate, self.endDate, self.startTime, self.endTime):
897 print("[Reading] Block No. %d/%d -> %s [Skipping]" % (self.nReadBlocks,
908 print("[Reading] Block No. %d/%d -> %s [Skipping]" % (self.nReadBlocks,
898 self.processingHeaderObj.dataBlocksPerFile,
909 self.processingHeaderObj.dataBlocksPerFile,
899 self.dataOut.datatime.ctime()))
910 self.dataOut.datatime.ctime()))
@@ -954,10 +965,7 class JRODataReader(Reader):
954
965
955 return False
966 return False
956
967
957 currentPosition = fp.tell()
968 if self.waitDataBlock(0):
958 neededSize = self.processingHeaderObj.blockSize + self.firstHeaderSize
959
960 if neededSize == 0:
961 basicHeaderObj = BasicHeader(LOCALTIME)
969 basicHeaderObj = BasicHeader(LOCALTIME)
962 systemHeaderObj = SystemHeader()
970 systemHeaderObj = SystemHeader()
963 radarControllerHeaderObj = RadarControllerHeader()
971 radarControllerHeaderObj = RadarControllerHeader()
@@ -979,19 +987,18 class JRODataReader(Reader):
979 fp.close()
987 fp.close()
980 return False
988 return False
981
989
982 neededSize = processingHeaderObj.blockSize + basicHeaderObj.size
990 if not self.online:
983 else:
991 dt1 = basicHeaderObj.datatime
984 msg = "[Reading] Skipping the file %s due to it hasn't enough data" % filename
992 fp.seek(self.fileSize-processingHeaderObj.blockSize-24)
985
993 if not(basicHeaderObj.read(fp)):
986 fp.close()
994 fp.close()
987
988 fileSize = os.path.getsize(filename)
989 currentSize = fileSize - currentPosition
990
991 if currentSize < neededSize:
992 if msgFlag and (msg != None):
993 print(msg)
994 return False
995 return False
996 dt2 = basicHeaderObj.datatime
997 if not self.isDateTimeInRange(dt1, self.startDate, self.endDate, self.startTime, self.endTime) and not \
998 self.isDateTimeInRange(dt2, self.startDate, self.endDate, self.startTime, self.endTime):
999 return False
1000
1001 fp.close()
995
1002
996 return True
1003 return True
997
1004
@@ -211,11 +211,11 class InputQueue(Thread):
211
211
212 def get(self):
212 def get(self):
213
213
214 if not self.islocked and self.size/1000000 > 512:
214 if not self.islocked and self.size/1000000 > 1024:
215 self.lock.n.value += 1
215 self.lock.n.value += 1
216 self.islocked = True
216 self.islocked = True
217 self.lock.clear()
217 self.lock.clear()
218 elif self.islocked and self.size/1000000 <= 512:
218 elif self.islocked and self.size/1000000 <= 1024:
219 self.islocked = False
219 self.islocked = False
220 self.lock.n.value -= 1
220 self.lock.n.value -= 1
221 if self.lock.n.value == 0:
221 if self.lock.n.value == 0:
@@ -117,7 +117,7 class SpectraProc(ProcessingUnit):
117 self.dataOut.data_cspc = cspc
117 self.dataOut.data_cspc = cspc
118 self.dataOut.data_dc = dc
118 self.dataOut.data_dc = dc
119 self.dataOut.blockSize = blocksize
119 self.dataOut.blockSize = blocksize
120 self.dataOut.flagShiftFFT = True
120 self.dataOut.flagShiftFFT = False
121
121
122 def run(self, nProfiles=None, nFFTPoints=None, pairsList=[], ippFactor=None, shift_fft=False):
122 def run(self, nProfiles=None, nFFTPoints=None, pairsList=[], ippFactor=None, shift_fft=False):
123
123
General Comments 0
You need to be logged in to leave comments. Login now