-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmerge_plot2.py
More file actions
179 lines (149 loc) · 8.07 KB
/
merge_plot2.py
File metadata and controls
179 lines (149 loc) · 8.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#-*- coding: utf-8 -*-
import codecs
import os, sys, string
from io import open
from glob import glob
import glob
# 1. Szukanie plikow .plt w glownym katalogu oraz podkatalogach
PLTfilesMain = []
PLTfilesMain = glob.glob("*.plt")
PLTfilesMain.sort()
PLTfilesSub = []
start_dir = os.getcwd()
file_name = '*.plt'
pattern = file_name
for dir,_,_ in os.walk(start_dir):
PLTfilesSub.extend(glob.glob(os.path.join(dir,pattern)))
NoOfItems = len(PLTfilesMain)
del PLTfilesSub[:NoOfItems]
PLTfilesSub.sort()
# 2. wybor plotow
NList = [0, 2, 3, 4, 5, 7, 8, 9]
N = int()
resultsLaTeX = open('Tabele_LateX_APR1400_B2.tex', 'a+')
for N in NList:
ResultsTable = []
MainFile = PLTfilesMain[N]
SubFileList = [s for s in PLTfilesSub if MainFile in s]
SubFileList.sort()
MainFileRead = open(MainFile)
MainListOfLines = MainFileRead.readlines()[5:]
#czytaj pierwsza linie z MainFile:
FirstLine = MainListOfLines[0]
FirstLineSplit = FirstLine.split()
firstWord = "Izotop"
FirstLineSplit.insert(0,firstWord)
ResultsTable.insert(0,FirstLineSplit)
LastTime = float(FirstLineSplit[-1])
#czytaj kloejne linie z MainFile:
MainListOfLines.pop(0)
for item in MainListOfLines:
TLine = item.split()
ResultsTable.append(TLine)
#czytaj pierwsza linie z SubFile:
for subfile in SubFileList:
SubFileRead = open(subfile)
SubListOfLines = SubFileRead.readlines()[5:]
FirstLineSub = SubListOfLines[0]
FirstLineSubSplit = FirstLineSub.split()
toAppend = float(FirstLineSubSplit[2])
TimeToAppend = str(LastTime + toAppend)
ResultsTable[0].append(TimeToAppend)
SubListOfLines.pop(0)
for item in SubListOfLines:
indx = SubListOfLines.index(item)
Place = indx + 1
TLine = item.split()
ValueToAppend = TLine[3]
ResultsTable[Place].append(ValueToAppend)
#zapis do pliku
firstFile = PLTfilesMain[N]
f1 = open(firstFile).readlines()
line1 = f1[0]
line2 = f1[1]
line3 = f1[2]
resultsFileName = 'ResultsTable_Case'+str(N)+'.txt'
resultsFile = open(resultsFileName, 'a+')
resultsFile.write(unicode(line1))
resultsFile.write(unicode(line2))
resultsFile.write(unicode(line3))
col_width = max(len(word) for item in ResultsTable for word in item) + 2
for item in ResultsTable:
resultsFile.write("".join(word.ljust(col_width) for word in item))
resultsFile.write(unicode('\n'))
resultsFile.close()
#tabela do LaTeX:
# - nowa tabela
ResultsTableLaTeX = []
firstTxT = ResultsTable[0][0]
FirstLine = ResultsTable[0][-8:]
FirstLine.insert(0,firstTxT)
FirstLine[0] = ' '
BurnTime = FirstLine[1]
FirstLine[1] = str(float(BurnTime))+' d'
FirstLine[1] = FirstLine[1].replace('.',',')
FirstLine[2] = '1 y'
FirstLine[3] = '10 y'
FirstLine[4] = '100 y'
FirstLine[5] = '1.000 y'
FirstLine[6] = '10.000 y'
FirstLine[7] = '100.000 y'
FirstLine[8] = '1 mln y'
ResultsTable.pop(0)
for item in ResultsTable:
ix = ResultsTable.index(item)
firstColumn = '\\textbf{'+str(ResultsTable[ix][0])+'}'
lastColumns = ResultsTable[ix][-8:]
lastColumns.insert(0,firstColumn)
ResultsTableLaTeX.append(lastColumns)
del ResultsTableLaTeX[-2:]
ResultsTableLaTeX = [[x.replace('.',',') for x in l] for l in ResultsTableLaTeX]
# - captions
caption = str()
if N == 0:
caption = "\\textbf{Reaktor APR1400 - Kaseta B2} - Zale\\.zno\\'s\\'c masy [g] wybranych aktywnowc\\'ow od czasu - od momentu zako\\'nczenia wypalania do miliona lat składowania paliwa (d - dni, y - lata)".decode("utf8")
if N == 1:
caption = "\\textbf{Reaktor APR1400 - Kaseta B2} - Zale\\.zno\\'s\\'c masy [kg] wybranych aktywnowc\\'ow od czasu - od momentu zako\\'nczenia wypalania do miliona lat składowania paliwa (d - dni, y - lata)".decode("utf8")
if N == 2:
caption = "\\textbf{Reaktor APR1400 - Kaseta B2} - Zale\\.zno\\'s\\'c aktywno\\'sci [Bq] wybranych aktywnowc\\'ow od czasu - od momentu zako\\'nczenia wypalania do miliona lat składowania paliwa (d - dni, y - lata)".decode("utf8")
if N == 3:
caption = "\\textbf{Reaktor APR1400 - Kaseta B2} - Zale\\.zno\\'s\\'c radiotoksyczno\\'sci [H2OM - ilo\\'s\\'c metr\\'ow sze\\'sciennych wody, aby rozcie\\'nczy\\'c izotop do poziomu okre\\'slonego w \\textit{Radioactivity Concentration Guide}] wybranych aktywnowc\\'ow od czasu - od momentu zako\\'nczenia wypalania do miliona lat składowania paliwa (d - dni, y - lata)".decode("utf8")
if N == 4:
caption = "\\textbf{Reaktor APR1400 - Kaseta B2} - Zale\\.zno\\'s\\'c mocy cieplnej [W] wybranych aktywnowc\\'ow od czasu - od momentu zako\\'nczenia wypalania do miliona lat składowania paliwa (d - dni, y - lata)".decode("utf8")
if N == 5:
caption = "\\textbf{Reaktor APR1400 - Kaseta B2} - Zale\\.zno\\'s\\'c masy [g] wybranych produkt\\'ow rozszczepienia od czasu - od momentu zako\\'nczenia wypalania do miliona lat składowania paliwa (d - dni, y - lata)".decode("utf8")
if N == 6:
caption = "\\textbf{Reaktor APR1400 - Kaseta B2} - Zale\\.zno\\'s\\'c masy [kg] wybranych produkt\\'ow rozszczepienia od czasu - od momentu zako\\'nczenia wypalania do miliona lat składowania paliwa (d - dni, y - lata)".decode("utf8")
if N == 7:
caption = "\\textbf{Reaktor APR1400 - Kaseta B2} - Zale\\.zno\\'s\\'c aktywno\\'sci [Bq] wybranych produkt\\'ow rozszczepienia od czasu - od momentu zako\\'nczenia wypalania do miliona lat składowania paliwa (d - dni, y - lata)".decode("utf8")
if N == 8:
caption = "\\textbf{Reaktor APR1400 - Kaseta B2} - Zale\\.zno\\'s\\'c radiotoksyczno\\'sci [H2OM - ilo\\'s\\'c metr\\'ow sze\\'sciennych wody, aby rozcie\\'czy\\'c izotop do poziomu okre\\'slonego w \\textit{Radioactivity Concentration Guide}] wybranych produkt\\'ow rozszczepienia od czasu - od momentu zako\\'nczenia wypalania do miliona lat składowania paliwa (d - dni, y - lata)".decode("utf8")
if N == 9:
caption = "\\textbf{Reaktor APR1400 - Kaseta B2} - Zale\\.zno\\'s\\'c mocy cieplnej [W] wybranych produkt\\'ow rozszczepienia od czasu - od momentu zako\\'nczenia wypalania (d - dni, y - lata)".decode("utf8")
label = 'EPR_A1_'+str(N)
#zapis tabel
L1 = '\\begin{landscape}'+'\n'+'\\begin{longtable}[h]{rllllllll}'+'\n'
# L2 = '\\centering'+'\n'
L2 = '\\caption{'+caption+' \\label{tab:'+label+'}} \\\\'+'\n'
# L4 = '\\begin{tabularx}{\\textwidth}{rllllllll}'+'\n'
L3 = '\\toprule'+'\n'
L4 = '\\textbf{'+FirstLine[0]+'} & '+ '\\textbf{'+FirstLine[1]+'} & '+'\\textbf{'+FirstLine[2]+'} & '+'\\textbf{'+FirstLine[3]+'} & '+'\\textbf{'+FirstLine[4]+'} & '+'\\textbf{'+FirstLine[5]+'} & '+'\\textbf{'+FirstLine[6]+'} & '+'\\textbf{'+FirstLine[7]+'} & '+'\\textbf{'+FirstLine[8]+'}'+'\\\\'+'\n'
L5 = '\\toprule'+'\n'+'\\endfirsthead'+'\n'+'\\multicolumn{9}{c}{\\tablename\\ \\thetable\\ -- \\textit{Kontynuacja z poprzedniej strony}} \\\\'+'\n'+'\\midrule'+'\n'
L6 = '\\textbf{'+FirstLine[0]+'} & '+ '\\textbf{'+FirstLine[1]+'} & '+'\\textbf{'+FirstLine[2]+'} & '+'\\textbf{'+FirstLine[3]+'} & '+'\\textbf{'+FirstLine[4]+'} & '+'\\textbf{'+FirstLine[5]+'} & '+'\\textbf{'+FirstLine[6]+'} & '+'\\textbf{'+FirstLine[7]+'} & '+'\\textbf{'+FirstLine[8]+'}'+'\\\\'+'\n'
L7 = '\\endhead'+'\n'+'\\hline \\multicolumn{9}{c}{\\textit{Kontynuacja na nast\\k{e}pnej stronie}} \\\\'+'\n'+'\\endfoot'+'\n'+'\\bottomrule'+'\n'+'\\endlastfoot'+'\n'
resultsLaTeX.write(unicode(L1))
resultsLaTeX.write(unicode(L2))
resultsLaTeX.write(unicode(L3))
resultsLaTeX.write(unicode(L4))
resultsLaTeX.write(unicode(L5))
resultsLaTeX.write(unicode(L6))
resultsLaTeX.write(unicode(L7))
for item in ResultsTableLaTeX:
LineFromTable = ' & '.join(item)
LineToWrite = LineFromTable + '\\\\ \\hline'+'\n'
resultsLaTeX.write(LineToWrite)
# L8 = '\\end{tabularx}'+'\n'
L9 = '\\end{longtable}'+'\n'+'\\end{landscape}'+'\n'+'\n'
# resultsLaTeX.write(unicode(L8))
resultsLaTeX.write(unicode(L9))
resultsLaTeX.close()