180 fillerDate = datetime.datetime(2000, 1, 1, 1, 1, 1, 1)
181 returnList = [fillerDate, fillerDate, fillerDate,
False,
"LI_S00_0_M0"]
183 homeDirectory = os.path.expanduser(
184 '/eos/atlas/user/j/jdickins/Pixel/LeakageCurrent/')
187 dataFolder = homeDirectory +
"/IBLData/processedData/"
188 inputFolder = homeDirectory +
"/IBLData/rawData/"+dataType+
"/"
189 entriesFolder = homeDirectory +
"/IBLData/rawData/entriesPerDay/" + dataType +
"/"
192 if not os.path.exists(dataFolder+dataType):
193 os.mkdir(dataFolder+dataType)
195 if not os.path.exists(entriesFolder):
196 os.mkdir(entriesFolder)
204 smallestEndDate = fillerDate
207 if not os.path.exists(dataFolder+dataType+
".txt"):
210 print(
"No any file found! at " + dataFolder +
211 dataType +
" Making default values")
214 with open(dataFolder+dataType+
".txt",
'w')
as datesFile:
215 firstTempDate = datetime.datetime(2015, 5, 1, 0, 0, 0, 0)
216 lastTempDate = datetime.datetime(2015, 5, 1, 0, 0, 0, 1)
217 smallestEndDate = lastTempDate
219 for stave
in range(1, 15):
220 staveString =
str(stave)
222 staveString =
"0"+
str(stave)
223 for side
in [
'A',
'C']:
224 moduleName =
'LI_S' +
str(staveString) +
'_' + side
226 moduleName +
" " +
str(firstTempDate) +
" " +
str(lastTempDate) +
" 0 0\n")
227 startingDates.append(firstTempDate)
228 endDates.append(lastTempDate)
229 filesProcessed.append(0)
231 dailyPoints.append(0)
234 print(
"Found " + dataFolder+dataType+
".txt")
235 with open(dataFolder+dataType+
".txt",
'r')
as datesFile:
239 for dateLine
in datesFile:
241 tempDatesLine = dateLine.split()
242 filesProcessed.append(
int(tempDatesLine[5]))
243 dataPoints.append(
int(tempDatesLine[6]))
244 dailyPoints.append(0)
246 firstTemp = tempDatesLine[1].
split(
'-')
247 lastTemp = tempDatesLine[3].
split(
'-')
249 firstTempTime = tempDatesLine[2].
split(
':')
250 lastTempTime = tempDatesLine[4].
split(
':')
252 firstTempTimes = firstTempTime[2].
split(
'.')
253 lastTempTimes = lastTempTime[2].
split(
'.')
255 if len(firstTempTimes) < 2:
256 firstTempTimes.append(0)
257 if len(lastTempTimes) < 2:
258 lastTempTimes.append(0)
260 firstTempDate = datetime.datetime(
int(firstTemp[0]),
int(firstTemp[1]),
int(firstTemp[2]),
int(
261 firstTempTime[0]),
int(firstTempTime[1]),
int(firstTempTimes[0]),
int(firstTempTimes[1]))
262 lastTempDate = datetime.datetime(
int(lastTemp[0]),
int(lastTemp[1]),
int(lastTemp[2]),
int(
263 lastTempTime[0]),
int(lastTempTime[1]),
int(lastTempTimes[0]),
int(lastTempTimes[1]))
265 startingDates.append(firstTempDate)
266 endDates.append(lastTempDate)
269 returnList[0] = firstTempDate
270 returnList[1] = lastTempDate
271 smallestEndDate = lastTempDate
274 if firstTempDate < returnList[0]:
275 returnList[0] = firstTempDate
276 if lastTempDate > returnList[1]:
277 returnList[1] = lastTempDate
278 if lastTempDate < smallestEndDate:
279 smallestEndDate = lastTempDate
283 print(
"Investigating " + dataType +
" from " +
str(smallestEndDate))
290 firstTempDate = startingDates[0]
291 lastTempDate = endDates[0]
295 for fileName
in fileList:
300 endDate1 = fileName[end-4:end]
301 endDate2 = fileName[end-7:end-6]
304 if endDate1 ==
'.txt' and endDate2 ==
'_':
306 startDate = fileName[end-23:end-15]
307 endDate = fileName[end-12:end-4]
308 endDateSplit = endDate.split(
'_')
309 endDateFile = datetime.datetime(
310 2000+
int(endDateSplit[0]),
int(endDateSplit[1]),
int(endDateSplit[2]), 0, 0, 0, 1)
312 startDateSplit = startDate.split(
'_')
313 startDateFile = datetime.datetime(
314 2000+
int(startDateSplit[0]),
int(startDateSplit[1]),
int(startDateSplit[2]), 0, 0, 0, 1)
316 if endDateFile > smallestEndDate:
319 lastTempDate = endDateFile
320 [firstTempDate, endDates, fillerDate, tempDataNumbers, smallestEndDate] =
appendEntries(
321 fileName, dataType, dataFolder, dailyPoints, endDates, startDateFile, endDateFile, fillerDate)
325 for i
in range(0, 28):
326 filesProcessed[i] += 1
328 dataPoints[i] += tempDataNumbers[i]
333 for stave
in range(1, 15):
334 staveString =
str(stave)
336 staveString =
"0"+
str(stave)
337 for side
in [
'A',
'C']:
338 moduleName =
'LI_S' +
str(staveString) +
'_' + side
339 outName = entriesFolder + moduleName +
".txt"
340 dataLine =
str(startDate) +
" " + \
341 str(tempDataNumbers[holderX]) +
"\n"
342 tempDataNumbers[holderX] = 0
344 mode =
'a' if os.path.isfile(outName)
else 'w'
345 with open(outName, mode)
as output:
346 output.write(dataLine)
350 if returnList[2] != fillerDate:
351 returnList[2] = fillerDate
352 with open(dataFolder+dataType+
".txt",
'w')
as datesFile:
354 for stave
in range(1, 15):
355 staveString =
str(stave)
357 staveString =
"0"+
str(stave)
358 for side
in [
'A',
'C']:
359 moduleName =
'LI_S' + \
360 str(staveString) +
'_' + side
361 datesFile.write(moduleName +
" " +
str(startingDates[tempHolder]) +
" " +
str(
362 endDates[tempHolder]) +
" " +
str(filesProcessed[tempHolder]) +
" " +
str(dataPoints[tempHolder]) +
"\n")
377 with open(dataFolder+dataType+
".txt",
'w')
as datesFile:
379 for staveX
in range(1, 15):
380 staveStringX =
str(staveX)
382 staveStringX =
"0"+
str(staveX)
383 for sideX
in [
'A',
'C']:
384 moduleNameX =
'LI_S' +
str(staveStringX) +
'_' + sideX
385 datesFile.write(moduleNameX +
" " +
str(startingDates[tempHolder]) +
" " +
str(
386 endDates[tempHolder]) +
" " +
str(filesProcessed[tempHolder]) +
" " +
str(dataPoints[tempHolder]) +
"\n")