#!/usr/bin/env python3
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from math import atan, tan, cos, pi, sqrt

matplotlib.rcParams.update({'font.size': 15})


t0 = 4000.
λ = 1064E-9
t0 = λ*(3759398496+0.5)
theta0 = 0.0
n = 1.0


def δ_(λ, n, t, theta):
    return 4*pi*n*t*cos(theta)/λ


def theta(r, h):
    δ = δ_(λ, n, t0*(1+h), theta0)
    return 2*atan(-tan(δ/2)*(1+sqrt(r))/(1-sqrt(r)))


def main():
    for r in (0, 0.5, 0.8, 0.986):
        hs = np.linspace(-6.63E-11, 6.63E-11, 500)
        ys = [theta(r, h) for h in hs]
        plt.plot(hs, ys, label=f"R={r}")
    plt.legend()
    plt.ylabel("$\Phi$")
    plt.xlabel("$h$")
    plt.tight_layout()
    plt.savefig("gt_etalon.png")
    # plt.show()


if __name__ == '__main__':
    main()
