1 |
02b38c6f
|
Alessandro_N
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
html_template = """
|
8 |
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
9 |
|
|
<html>
|
10 |
|
|
<head>
|
11 |
|
|
<!--<link rel="stylesheet" type="text/css" href="style.css"/>-->
|
12 |
|
|
<!--Original dark blue: #005fbf-->
|
13 |
|
|
<!--Original light blue: #aad4ff-->
|
14 |
|
|
<style type="text/css">
|
15 |
|
|
body {
|
16 |
|
|
background: #FFFFFF;
|
17 |
|
|
color: #EEE;
|
18 |
|
|
text-align: center;
|
19 |
|
|
font: normal 9pt Verdana;
|
20 |
|
|
}
|
21 |
|
|
img {
|
22 |
|
|
border: none;
|
23 |
|
|
}
|
24 |
|
|
#normal2, #normal3, #normal4, #normal5 {
|
25 |
|
|
display: none;
|
26 |
|
|
}
|
27 |
|
|
#gallery {
|
28 |
|
|
margin:1%% auto;
|
29 |
|
|
}
|
30 |
|
|
.album{
|
31 |
|
|
width:55%%;
|
32 |
|
|
float:left;
|
33 |
|
|
margin-left: 5%%
|
34 |
|
|
}
|
35 |
|
|
#thumbs {
|
36 |
|
|
margin-right: 10%%;
|
37 |
|
|
width: 5%%;
|
38 |
|
|
height: 60%%;
|
39 |
|
|
float: left;
|
40 |
|
|
}
|
41 |
|
|
#thumbs img {
|
42 |
|
|
width: 248%%;
|
43 |
|
|
height: 248%%;
|
44 |
|
|
margin: 2%%;
|
45 |
|
|
box-shadow: 3px 3px 1px #ccc;
|
46 |
|
|
}
|
47 |
|
|
#thumbs a:hover {
|
48 |
|
|
margin: 0 0 0 2%%;
|
49 |
|
|
}
|
50 |
|
|
.big{
|
51 |
|
|
margin-bottom: 5%%;
|
52 |
|
|
}
|
53 |
|
|
#bigimages {
|
54 |
|
|
}
|
55 |
|
|
#bigimages img {
|
56 |
|
|
width: 63%%;
|
57 |
|
|
height:63%%;
|
58 |
|
|
box-shadow: 3px 3px 1px #ccc;
|
59 |
|
|
float:left;
|
60 |
|
|
}
|
61 |
|
|
#arrow {
|
62 |
|
|
margin-top: 27%%;
|
63 |
|
|
width: 10%%;
|
64 |
|
|
float: left;
|
65 |
|
|
}
|
66 |
|
|
#arrow img {
|
67 |
|
|
width: 100%%;
|
68 |
|
|
}
|
69 |
|
|
#cds{
|
70 |
|
|
text-align:center;
|
71 |
|
|
}
|
72 |
|
|
#cds img {
|
73 |
|
|
width: 20%%;
|
74 |
|
|
}
|
75 |
|
|
#information {
|
76 |
|
|
float:left;
|
77 |
|
|
padding:0px;
|
78 |
|
|
width:26%%;
|
79 |
|
|
border:1px solid #000000;
|
80 |
|
|
margin-left: 5%%;
|
81 |
|
|
}#information table{
|
82 |
|
|
border-spacing: 0;
|
83 |
|
|
width:100%%;
|
84 |
|
|
margin:0px;padding:0px;
|
85 |
|
|
}
|
86 |
|
|
#information tr:nth-child(odd){ background-color:#F0F0F0; }
|
87 |
|
|
#information tr:nth-child(even){ background-color:#ffffff; }
|
88 |
|
|
#information td{
|
89 |
|
|
vertical-align:middle;
|
90 |
|
|
border:1px solid #000000;
|
91 |
|
|
text-align:right;
|
92 |
|
|
font-size:1.2em;
|
93 |
|
|
font-family:Arial;
|
94 |
|
|
font-weight:normal;
|
95 |
|
|
color:#000000;
|
96 |
|
|
padding: 3%% 3%% 3%% 5%%;
|
97 |
|
|
}
|
98 |
|
|
#information tr:first-child td{
|
99 |
|
|
background-color:#404040;
|
100 |
|
|
text-align:center;
|
101 |
|
|
padding:2%%;
|
102 |
|
|
font-size:2em;
|
103 |
|
|
font-family:Arial;
|
104 |
|
|
font-weight:bold;
|
105 |
|
|
color:#ffffff;
|
106 |
|
|
}
|
107 |
|
|
ul{
|
108 |
|
|
padding: 0;
|
109 |
|
|
margin:0;
|
110 |
|
|
}
|
111 |
|
|
ul li{
|
112 |
|
|
list-style:none;
|
113 |
|
|
}
|
114 |
|
|
</style>
|
115 |
|
|
|
116 |
|
|
<script type="text/javascript">
|
117 |
|
|
|
118 |
|
|
var currentGlobal = 1;
|
119 |
|
|
|
120 |
|
|
function changeImage(current,total) {
|
121 |
|
|
//var imagesNumber = 6;
|
122 |
|
|
for (i=1; i<=total; i++) {
|
123 |
|
|
if (i == current) {
|
124 |
|
|
document.getElementById("normal" + current).style.display = "block";
|
125 |
|
|
} else {
|
126 |
|
|
document.getElementById("normal" + i).style.display = "none";
|
127 |
|
|
}
|
128 |
|
|
}
|
129 |
|
|
currentGlobal = current;
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
function next() {
|
133 |
|
|
if (currentGlobal==5){currentGlobal=0};
|
134 |
|
|
changeImage(currentGlobal+1,5);
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
function previous() {
|
138 |
|
|
if (currentGlobal==1){currentGlobal=6};
|
139 |
|
|
changeImage(currentGlobal-1,5);
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
window.addEventListener('keyup', function (e) {
|
143 |
|
|
if (e.keyCode === 37) {previous()}
|
144 |
|
|
if (e.keyCode === 39) {next()}
|
145 |
|
|
}, false);
|
146 |
|
|
|
147 |
|
|
</script>
|
148 |
|
|
|
149 |
|
|
</head>
|
150 |
|
|
|
151 |
|
|
<body>
|
152 |
|
|
|
153 |
|
|
<div id="gallery">
|
154 |
|
|
|
155 |
|
|
<div class="album">
|
156 |
|
|
<div class="big">
|
157 |
|
|
<div id="thumbs">
|
158 |
|
|
<a href="javascript: changeImage(1,5);"><img src="../%(DATA_DIR)s/%(SZ_FILE)s" alt="" /></a>
|
159 |
|
|
<a href="javascript: changeImage(2,5);"><img src="../%(DATA_DIR)s/%(SZ_SDSS_FILE)s" alt="" /></a>
|
160 |
|
|
<a href="javascript: changeImage(3,5);"><img src="../%(DATA_DIR)s/%(SZ_W1_FILE)s" alt="" /></a>
|
161 |
|
|
<a href="javascript: changeImage(4,5);"><img src="../%(DATA_DIR)s/%(SZ_FOF_FILE)s" alt="" /></a>
|
162 |
|
|
<a href="javascript: changeImage(5,5);"><img src="../%(DATA_DIR)s/%(SZ_ROSAT_FILE)s" alt="" /></a>
|
163 |
|
|
</div>
|
164 |
|
|
|
165 |
|
|
<div id="arrow"><a href="javascript: previous();"><img src="../%(DATA_DIR)s/prev.png" alt="" /></a></div>
|
166 |
|
|
|
167 |
|
|
<div id="bigimages">
|
168 |
|
|
<div id="normal1"><a href="javascript: next();"><img src="../%(DATA_DIR)s/%(SZ_FILE)s" alt=""/></a></div>
|
169 |
|
|
<div id="normal2"><a href="javascript: next();"><img src="../%(DATA_DIR)s/%(SZ_SDSS_FILE)s" alt=""/></a></div>
|
170 |
|
|
<div id="normal3"><a href="javascript: next();"><img src="../%(DATA_DIR)s/%(SZ_W1_FILE)s" alt=""/></a></div>
|
171 |
|
|
<div id="normal4"><a href="javascript: next();"><img src="../%(DATA_DIR)s/%(SZ_FOF_FILE)s" alt=""/></a></div>
|
172 |
|
|
<div id="normal5"><a href="javascript: next();"><img src="../%(DATA_DIR)s/%(SZ_ROSAT_FILE)s" alt=""/></a></div>
|
173 |
|
|
</div>
|
174 |
|
|
|
175 |
|
|
<div id="arrow"><a href="javascript: next();"><img src="../%(DATA_DIR)s/next.png" alt="" /></a></div>
|
176 |
|
|
<div style="clear:both;"></div>
|
177 |
|
|
</div>
|
178 |
|
|
</div>
|
179 |
|
|
<div id="information">
|
180 |
|
|
<table >
|
181 |
|
|
<tr><td colspan="2">%(NAME)s</td></tr>
|
182 |
|
|
<tr>
|
183 |
|
|
<td><b>Index</b></td>
|
184 |
|
|
<td style='text-align:left'>%(INDEX)i</td>
|
185 |
|
|
</tr>
|
186 |
|
|
<tr>
|
187 |
|
|
<td><b>RA</b></td>
|
188 |
|
|
<td style='text-align:left'>%(RA)s</td>
|
189 |
|
|
</tr>
|
190 |
|
|
<tr>
|
191 |
|
|
<td><b>DEC</b></td>
|
192 |
|
|
<td style='text-align:left'>%(DEC)s</td>
|
193 |
|
|
</tr>
|
194 |
|
|
<tr>
|
195 |
|
|
<td><b>Redshift</b></td>
|
196 |
|
|
<td style='text-align:left'>%(REDSHIFT)s</td>
|
197 |
|
|
</tr>
|
198 |
|
|
<tr>
|
199 |
|
|
<td><b>Redshift type</b></td>
|
200 |
|
|
<td style='text-align:left'>%(REDSHIFT_TYPE)s</td>
|
201 |
|
|
</tr>
|
202 |
|
|
<tr>
|
203 |
|
|
<td><b>Redshift ref.</b></td>
|
204 |
|
|
<td style='text-align:left'>%(REDSHIFT_REF)s</td>
|
205 |
|
|
|
206 |
|
|
</tr>
|
207 |
|
|
<tr>
|
208 |
|
|
%(ALT_NAME_BLOCK)s
|
209 |
|
|
</tr>
|
210 |
|
|
<tr>
|
211 |
|
|
<td><b>VO Link</b></td>
|
212 |
|
|
<td id="cds" style='text-align:left'><a href="http://simbad.u-strasbg.fr/simbad/sim-basic?Ident=%(RA)s %(DEC)s&submit=SIMBAD+search" target="_blank"><img src="../%(DATA_DIR)s/cds_icon.gif" alt="" /></a></td>
|
213 |
|
|
</tr>
|
214 |
|
|
</table>
|
215 |
|
|
</div>
|
216 |
|
|
|
217 |
|
|
</div>
|
218 |
|
|
|
219 |
|
|
</body>
|
220 |
|
|
</html>
|
221 |
|
|
"""
|
222 |
|
|
|
223 |
|
|
import psycopg2
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
dbname = "'<DB_NAME>'"
|
227 |
|
|
user = "'postgres'"
|
228 |
|
|
host = "'localhost'"
|
229 |
|
|
pwd = "''"
|
230 |
|
|
dataset = "'<DATASET_NAME>'"
|
231 |
|
|
conn = psycopg2.connect("dbname="+dbname+" user="+user+" host="+host+" password="+pwd+"")
|
232 |
|
|
|
233 |
|
|
cur = conn.cursor()
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
cur.execute("SELECT COUNT(*) FROM %s;" % dataset)
|
237 |
|
|
index_max = int(cur.fetchall()[0][0])
|
238 |
|
|
|
239 |
|
|
for i in range(0, index_max):
|
240 |
|
|
output_file = './html/index_%d.html' % (i+1)
|
241 |
|
|
|
242 |
|
|
try:
|
243 |
|
|
cur.execute("select index, name, ra, dec, redshift, redshift_type, redshift_ref, alt_name, psz1_id_ext from "+dataset+" where index="+str(i+1)+"")
|
244 |
|
|
except:
|
245 |
|
|
print 'Data access impossible for object with Index: ', i+1
|
246 |
|
|
|
247 |
|
|
rows = cur.fetchall()[0]
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
DATA_dir = 'images'
|
251 |
|
|
SZ_file = 'SZ_%d_SZ.png' % i
|
252 |
|
|
SZ_SDSS_file = 'SZ_%d_SZ_SDSS.png' % i
|
253 |
|
|
SZ_W1_file = 'SZ_%d_SZ_W1.png' % i
|
254 |
|
|
SZ_FOF_file = 'SZ_%d_SZ_FoF.png' % i
|
255 |
|
|
SZ_ROSAT_file = 'SZ_%d_SZ_ROSAT.png' % i
|
256 |
|
|
|
257 |
|
|
INDEX = int(rows[0])
|
258 |
|
|
NAME = rows[1]
|
259 |
|
|
RA = str(rows[2])
|
260 |
|
|
DEC = str(rows[3])
|
261 |
|
|
REDSHIFT = str(rows[4])
|
262 |
|
|
REDSHIFT_TYPE = rows[5]
|
263 |
|
|
REDSHIFT_REF = rows[6]
|
264 |
|
|
if str(REDSHIFT_REF).upper() in ['NULL', 'NONE']: REDSHIFT_REF = ''
|
265 |
|
|
|
266 |
|
|
ALT_NAME = rows[7]
|
267 |
|
|
ID_EXT = rows[8]
|
268 |
|
|
|
269 |
|
|
try:
|
270 |
|
|
single_alt_names = ALT_NAME.split(';')
|
271 |
|
|
except:
|
272 |
|
|
single_alt_names = ['']
|
273 |
|
|
|
274 |
|
|
ALT_NAME_BLOCK = """<td><b>Alt. Name</b></td>
|
275 |
|
|
<td style='text-align:left'>
|
276 |
|
|
<ul>"""
|
277 |
|
|
for names in single_alt_names:
|
278 |
|
|
ALT_NAME_BLOCK += """
|
279 |
|
|
<li>%s</li>""" % names.strip()
|
280 |
|
|
ALT_NAME_BLOCK += """
|
281 |
|
|
</ul>
|
282 |
|
|
</td>"""
|
283 |
|
|
|
284 |
|
|
html_current = html_template % {
|
285 |
|
|
'DATA_DIR' : DATA_dir,
|
286 |
|
|
'SZ_FILE' : SZ_file,
|
287 |
|
|
'SZ_SDSS_FILE' : SZ_SDSS_file,
|
288 |
|
|
'SZ_W1_FILE' : SZ_W1_file,
|
289 |
|
|
'SZ_FOF_FILE' : SZ_FOF_file,
|
290 |
|
|
'SZ_ROSAT_FILE' : SZ_ROSAT_file,
|
291 |
|
|
|
292 |
|
|
'NAME' : NAME,
|
293 |
|
|
'INDEX' : INDEX,
|
294 |
|
|
'RA' : RA,
|
295 |
|
|
'DEC' : DEC,
|
296 |
|
|
'REDSHIFT' : REDSHIFT,
|
297 |
|
|
'REDSHIFT_TYPE' : REDSHIFT_TYPE,
|
298 |
|
|
'REDSHIFT_REF' : REDSHIFT_REF,
|
299 |
|
|
'ALT_NAME' : ALT_NAME,
|
300 |
|
|
'ID_EXT' : ID_EXT,
|
301 |
|
|
'ALT_NAME_BLOCK' : ALT_NAME_BLOCK
|
302 |
|
|
}
|
303 |
|
|
|
304 |
|
|
|
305 |
|
|
file_out = open(output_file,'w')
|
306 |
|
|
file_out.write(html_current)
|
307 |
|
|
file_out.close()
|
308 |
|
|
|
309 |
|
|
|