-
Notifications
You must be signed in to change notification settings - Fork 0
/
reporter.py
147 lines (137 loc) · 7.06 KB
/
reporter.py
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
# -*- coding: utf-8 -*-
import reportlab.lib.fonts
from datetime import datetime
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.units import inch
class Reporter(object):
def __init__(self,vapp):
self.dataApp = vapp
path = self.dataApp.repoPath + self.dataApp.rdataName + '.pdf'
self.canvas = Canvas(path)
self.page = 1
def header(self):
self.canvas.setFont("Helvetica", 10)
self.canvas.drawCentredString(4.135*inch, 10.74*inch, 'Copyright@2015 : ycroft.net')
self.canvas.setFont("Helvetica", 11.5)
self.canvas.line(1*inch, 10.69*inch, 7.27*inch, 10.69*inch)
def footer(self):
self.canvas.setFont("Helvetica", 11.5)
self.canvas.line(1*inch, 1*inch, 7.27*inch, 1*inch)
self.canvas.setFont("Helvetica", 10)
self.canvas.drawCentredString(4.135*inch, 0.83*inch, '- '+str(self.page)+' -')
def cover(self,coverInfo):
dataName = coverInfo.get('dataName','no name')
author = coverInfo.get('author','no name')
version = coverInfo.get('version','unknown')
self.header()
self.footer()
self.canvas.setFont("Helvetica-Bold", 40)
self.canvas.drawCentredString(4.135*inch, 7.5*inch, 'Analysis Report')
self.canvas.setFont("Helvetica", 20)
self.canvas.drawCentredString(4.135*inch, 6.8*inch, 'for data \'' + dataName + '\'')
self.canvas.setFont("Helvetica", 15)
self.canvas.drawRightString(3.935*inch, 4.4*inch, 'author:')
self.canvas.drawRightString(3.935*inch, 3.9*inch, 'date:')
self.canvas.drawRightString(3.935*inch, 3.4*inch, 'version:')
self.canvas.drawString(4.335*inch, 4.4*inch, author)
self.canvas.drawString(4.335*inch, 3.9*inch, str(datetime.now().strftime('%a, %b %d %H:%M')))
self.canvas.drawString(4.335*inch, 3.4*inch, version)
self.canvas.showPage()
self.page += 1
def body(self):
self.header()
self.footer()
sdataName = self.dataApp.sdataName
rdataName = self.dataApp.rdataName
imgPath = './spec_data/img/'
self.canvas.setFont("Helvetica-Bold", 15)
self.canvas.drawString(1.25*inch, 10*inch, 'I. Modulation Factors ')
self.canvas.setFont("Helvetica", 12)
self.canvas.drawString(1.5*inch, 9.7*inch, 'These factors are derived from the file \''+sdataName+'\'')
self.canvas.drawInlineImage(imgPath + sdataName + '_cs0.jpg',1.25*inch,5.3*inch,5.77*inch,4.33*inch)
self.canvas.drawInlineImage(imgPath + sdataName + '_cs1.jpg',1.25*inch,1.2*inch,5.77*inch,4.33*inch)
self.canvas.showPage()
self.page += 1
self.header()
self.footer()
self.canvas.drawInlineImage(imgPath + sdataName + '_cs2.jpg',1.25*inch,5.3*inch,5.77*inch,4.33*inch)
self.canvas.drawInlineImage(imgPath + sdataName + '_cs3.jpg',1.25*inch,1.2*inch,5.77*inch,4.33*inch)
self.canvas.showPage()
self.page += 1
self.header()
self.footer()
self.canvas.setFont("Helvetica-Bold", 15)
self.canvas.drawString(1.25*inch, 10*inch, 'II. Measured Data & FFT ')
self.canvas.setFont("Helvetica", 12)
self.canvas.drawString(1.5*inch, 9.7*inch, 'The data is derived from the file \''+rdataName+'\', and each fft channel has been filtered.')
self.canvas.drawInlineImage(imgPath + rdataName + '_rd.jpg',1.25*inch,5.3*inch,5.77*inch,4.33*inch)
self.canvas.drawInlineImage(imgPath + rdataName + '_fft.jpg',1.25*inch,1.2*inch,5.77*inch,4.33*inch)
self.canvas.showPage()
self.page += 1
self.header()
self.footer()
self.canvas.setFont("Helvetica-Bold", 15)
self.canvas.drawString(1.25*inch, 10*inch, 'III. Modulation Signals ')
self.canvas.setFont("Helvetica", 12)
self.canvas.drawString(1.5*inch, 9.7*inch, 'These signals are derived by ifft on the corresponding channel.')
self.canvas.drawInlineImage(imgPath + rdataName + '_fa0.jpg',1.25*inch,5.3*inch,5.77*inch,4.33*inch)
self.canvas.drawInlineImage(imgPath + rdataName + '_fa1.jpg',1.25*inch,1.2*inch,5.77*inch,4.33*inch)
self.canvas.showPage()
self.page += 1
self.header()
self.footer()
self.canvas.drawInlineImage(imgPath + rdataName + '_fa2.jpg',1.25*inch,5.3*inch,5.77*inch,4.33*inch)
self.canvas.drawInlineImage(imgPath + rdataName + '_fa3.jpg',1.25*inch,1.2*inch,5.77*inch,4.33*inch)
self.canvas.showPage()
self.page += 1
self.header()
self.footer()
self.canvas.setFont("Helvetica-Bold", 15)
self.canvas.drawString(1.25*inch, 10*inch, 'IV. Stokes Vectors ')
self.canvas.setFont("Helvetica", 12)
self.canvas.drawString(1.5*inch, 9.7*inch, 'This can be figured out using modulation signals and modulation factors.')
self.canvas.drawInlineImage(imgPath + rdataName + '_s0.jpg',1.25*inch,5.3*inch,5.77*inch,4.33*inch)
self.canvas.drawInlineImage(imgPath + rdataName + '_s1.jpg',1.25*inch,1.2*inch,5.77*inch,4.33*inch)
self.canvas.showPage()
self.page += 1
self.header()
self.footer()
self.canvas.drawInlineImage(imgPath + rdataName + '_s2.jpg',1.25*inch,5.3*inch,5.77*inch,4.33*inch)
self.canvas.drawInlineImage(imgPath + rdataName + '_s3.jpg',1.25*inch,1.2*inch,5.77*inch,4.33*inch)
self.canvas.showPage()
self.page += 1
self.header()
self.footer()
self.canvas.setFont("Helvetica-Bold", 15)
self.canvas.drawString(1.25*inch, 10*inch, 'IV. Degree of Polarization ')
self.canvas.setFont("Helvetica", 12)
self.canvas.drawString(1.5*inch, 9.7*inch, 'This was figured out using four Stokes vectors.')
self.canvas.drawInlineImage(imgPath + rdataName + '_dop.jpg',1.25*inch,5.3*inch,5.77*inch,4.33*inch)
self.canvas.showPage()
self.page += 1
self.header()
self.footer()
windows = self.dataApp.windows
self.canvas.setFont("Helvetica-Bold", 15)
self.canvas.drawString(1.25*inch, 10*inch, 'V. Data Analysis ')
self.canvas.setFont("Helvetica", 12)
self.canvas.drawString(1.5*inch, 9.7*inch, 'This was automatically generated by program.')
self.canvas.drawString(1.5*inch, 9.0*inch, '-The number of the peaks recognized in `FFT` datagram:')
self.canvas.drawString(2.0*inch, 8.7*inch, str(len(windows)) + ' peaks')
self.canvas.drawString(1.5*inch, 8.4*inch, '-The range of the peaks recognized in `FFT` datagram:')
for i in range(0,len(windows)):
self.canvas.drawString(2.0*inch, (8.1-i*0.3)*inch, '[' + str(i)+ '] ' +str(windows[i][0]))
self.canvas.drawString(3.9*inch, (8.1-i*0.3)*inch, '~ ' + str(windows[i][1]))
self.canvas.showPage()
self.page += 1
def gen(self):
self.cover({
'dataName' : self.dataApp.rdataName + '`C spec',
'author' : 'ycroft',
'version' : 'v0.1'
})
self.body()
self.canvas.save()
if __name__ == "__main__":
reporter = Reporter('report.pdf')
reporter.gen()