-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupernova.py
87 lines (63 loc) · 1.87 KB
/
supernova.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
import pygame,random,sys,hackmain
from matplotlib import pyplot
import numpy as np
from astropy.coordinates import FK5
import astropy.units as u
def InterestingObj():
data = np.loadtxt('Objects.txt')
ra = data[:,0]
dec = data[:,1]
return ra, dec
data=hackmain.GetTransients()
ra,dec,mag,jd=data.GetData()
#Interesting Objects:
ra_i,dec_i = InterestingObj()
print ra_i,dec_i
pygame.init()
clock=pygame.time.Clock()
WIDTH=1000;HEIGHT=500;BLACK=(0,0,0)
screen=pygame.display.set_mode([WIDTH,HEIGHT])
background_image=pygame.image.load('background.png')
imagerect=background_image.get_rect()
background=pygame.Surface(screen.get_size())
background=background.convert()
pygame.mixer.init(44100,-16,2,2048)
effect=pygame.mixer.Sound('explosion-01.mp3')
def get_pixel(ra,dec):
x=int(ra/360.0*1000)
y=int((90-dec)/180.0*500)
return x,y
def draw_circle(ra,dec,mag,colour):
x,y=get_pixel(ra,dec)
size=int(mag)#int(1/mag*250)
pygame.draw.circle(screen,colour,(x,y),size)
def random_colour(min,max):
red=random.randint(min,max)
green=random.randint(min,max)
blue=random.randint(min,max)
colour=[red,green,blue]
return colour
clock = pygame.time.Clock()
lasttime = 0
totalTime = 0
while True:
for n in range(len(ra)):
totalTime += clock.tick()
clock.tick(5)
screen.blit(background_image,imagerect)
colour=random_colour(100,255)
print totalTime, lasttime
if totalTime > lasttime + 10000:
print 'Update!'
data.Update()
ra,dec,mag,jd=data.GetData()
lasttime = totalTime
clearclock = clock.tick()
draw_circle(ra[n],dec[n],mag[n],colour)
#draw_circle(ra_i[0],dec_i[0],20,[0,255,255])
#draw_circle(ra_i[1],dec_i[1],20,[0,255,255])
effect.play()
pygame.display.flip()
screen.fill((0,0,0))
raw_input("Press a key")
sys.exit()