#!/usr/bin/env python3

import sys
import numpy as np
import phoebe

b = phoebe.default_binary()

times, fluxes, sigmas = np.loadtxt("Lc.dat", usecols=[0, 1, 2], unpack=True)

print("times = ", times)
print("fluxes = ", fluxes)
print("sigmas = ", sigmas)

b.add_dataset('lc', times=times, fluxes=fluxes, sigmas=sigmas)

#b.plot(show=True)

b.run_compute()

f = open('twigs.txt', 'w')
for twig in b.twigs:
  f.write("%s\n" % (twig))
f.close()

print("b['times@lc01@lc@dataset'] = ", b['times@lc01@lc@dataset'])
print("b['fluxes@lc01@lc@dataset'] = ", b['fluxes@lc01@lc@dataset'])
print("b['sigmas@lc01@lc@dataset'] = ", b['sigmas@lc01@lc@dataset'])
print("b['times@lc01@phoebe01@latest@lc@model'] = ", b['times@lc01@phoebe01@latest@lc@model'])
print("b['fluxes@lc01@phoebe01@latest@lc@model'] = ", b['fluxes@lc01@phoebe01@latest@lc@model'])
print("")

b.plot(show=True)
#b.plot(x='times', y='fluxes', show=True)
#b.plot(yerror='sigmas', show=True)  # IT DOES NOT WORK, WHY?

sys.exit(1)

