import numpy as np
import matplotlib.pyplot as plt

d = 0.02   # suradnicove delenie, pre podrobnejsiu mapu zmensime delenie
dt = 0.05   # casovy krok
u = 0.5    # koeficient okrajoveho stemnenia
r = 0.2    # polomer exoplanety
intensity = []   #vysledna intenzita
for t in np.arange(-1.4, 1.4, dt):     # pohyb exoplanety po disku
    A = []
    for x in np.arange(-1, 1, d):  # x-ova suradnica bodu
        for y in np.arange(-1, 1, d):  # y-ova suradnica bodu
            if (x**2 + y**2) < 1:   # definicia disku hviezdy
                if ((x - t)**2 + y**2) <= r**2:     # poloha exoplanety
                    A.append([x, y, 0])   # intenzita v mieste exoplanety
                else:
                    # intenzita v mieste hviezdy
                    A.append([x, y, 1 - u*(1 - np.sqrt(1 - x**2 - y**2))])
    A = np.array(A)
    intensity.append(sum(A[:, 2]))
    # Prikaz scatter vytvori 2D mapu rozlozenia intenzity.
    plt.clf()
    plt.scatter(A[:, 0], A[:, 1], c=A[:, 2], lw = 0, s=5, vmin=0, vmax=1)
    plt.axis('equal')
    plt.gray()
    plt.pause(0.01)
t = np.arange(-1.4, 1.4, dt)
I = -2.5*np.log10(intensity)
plt.figure()
plt.plot(t, I, '*')
plt.axis([min(t), max(t), max(I), min(I)])
plt.xlabel('t')
plt.ylabel('I [mag]')
