-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathweatherparse.py
62 lines (47 loc) · 1.59 KB
/
weatherparse.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
#************************************************************************#
#* *#
#* P R O J E K T A V A L O N *#
#* *#
#* weatherparse.py Script for parsing pngs into weather info. *#
#* *#
#* Author Stefan Wismer *#
#* [email protected] *#
#* *#
#************************************************************************#
# Image-Libary
import gd
# DDX Access
import ddxInterface
# Init DDX Interface
store = ddxInterface.ddxStore()
# Get handle to the weather variable
V = store.variable('weather')
V.timestamp = 200903041200
# Load Images and read size
image_u = gd.image("testfiles/wind_u.png");
image_v = gd.image("testfiles/wind_v.png");
width=image_u.size()[0]
height=image_u.size()[1]
print "Die Bilder sind", width, "breit und", height, "hoch"
# max wind is assumed to be known for now... (random values)
u_max = 19.33
v_max = 20.81
# Then start reading the pixels
i = 0
j = 0
# for debugging (screen is not so filled....)
# width = 20
# height = 20
while i < height:
while j < width:
pixu = (image_u.getPixel((j+1,80-i))-115.55) / 7.24;
pixv = (image_v.getPixel((j+1,80-i))-115.55) / 7.24;
V.xdata[j][i] = pixu
V.ydata[j][i] = pixv
print "(%4.1f, %4.1f) " % (pixu,pixv),
j = j + 1
print '\n',
i = i + 1
j = 0
V.write()
print "Fertig."