# Path: dart_board/utils.py
# def A_to_P(M1, M2, a):
#     """
#     Calculate the orbital period from the stellar masses and orbital separation.
# 
#     Args:
#         M1, M2 : floats, masses of the two stars (Msun)
#         a : float, orbital separation (Rsun)
# 
#     Returns:
#         P : float, orbital period (days)
#     """
# 
#     mu = c.G * (M1 + M2) * c.Msun_to_g
#     n = np.sqrt(mu/(a**3 * c.Rsun_to_cm**3))
#     P = 2.0*np.pi / n
# 
#     return P / c.day_to_sec
# 
# def P_to_A(M1, M2, P):
#     """
#     Calculate the orbital separation from the stellar masses and orbital period.
# 
#     Args:
#         M1, M2 : floats, masses of the two stars (Msun)
#         P : float, orbital period (days)
# 
#     Returns:
#         a : float, orbital separation (Rsun)
#     """
# 
#     mu = c.G * (M1 + M2) * c.Msun_to_g
#     n = 2.0*np.pi / P / c.day_to_sec
#     a = np.power(mu/(n*n), 1.0/3.0) / c.Rsun_to_cm
# 
#     return a


import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import matplotlib.patches as mpatches
from .utils import A_to_P, P_to_A

        a.axis('off')

        for j,k in enumerate(np.unique(k1_out)):
            a.fill_between(times[k1_out == k], 0.7, 0.9, color=k_type_colors[k])
        for j,k in enumerate(np.unique(k2_out)):
            a.fill_between(times[k2_out == k], 0.4, 0.6, color=k_type_colors[k])

        a.set_title('Stellar Type')

        a.set_xlim(np.min(times), np.max(times))



    # Add legend
    ax_k_type_list.axis('off')
    k_type_all = np.unique(np.array([k1_out, k2_out]))
    patches = [ mpatches.Patch(color=k_type_colors[k], label=k_type[k]) for k in k_type_all ]
    leg = ax_k_type_list.legend(handles=patches, mode='expand', ncol=len(k_type_all))
    leg.get_frame().set_alpha(0.0)



def plot_radius(ax, times, R1_out, R2_out, M1_out, M2_out, P_orb_out, ecc_out, sys_obs):

    # Radius
    ax.plot(times, R1_out, color=C0)
    ax.plot(times, R2_out, color=C1)

    # Roche radii - at periastron

# Path: dart_board/utils.py
# def A_to_P(M1, M2, a):
#     """
#     Calculate the orbital period from the stellar masses and orbital separation.
# 
#     Args:
#         M1, M2 : floats, masses of the two stars (Msun)
#         a : float, orbital separation (Rsun)
# 
#     Returns:
#         P : float, orbital period (days)
#     """
# 
#     mu = c.G * (M1 + M2) * c.Msun_to_g
#     n = np.sqrt(mu/(a**3 * c.Rsun_to_cm**3))
#     P = 2.0*np.pi / n
# 
#     return P / c.day_to_sec
# 
# def P_to_A(M1, M2, P):
#     """
#     Calculate the orbital separation from the stellar masses and orbital period.
# 
#     Args:
#         M1, M2 : floats, masses of the two stars (Msun)
#         P : float, orbital period (days)
# 
#     Returns:
#         a : float, orbital separation (Rsun)
#     """
# 
#     mu = c.G * (M1 + M2) * c.Msun_to_g
#     n = 2.0*np.pi / P / c.day_to_sec
#     a = np.power(mu/(n*n), 1.0/3.0) / c.Rsun_to_cm
# 
#     return a


# Path: dart_board/plot_system_evolution.py
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import matplotlib.patches as mpatches
from .utils import A_to_P, P_to_A


        a.axis('off')

        for j,k in enumerate(np.unique(k1_out)):
            a.fill_between(times[k1_out == k], 0.7, 0.9, color=k_type_colors[k])
        for j,k in enumerate(np.unique(k2_out)):
            a.fill_between(times[k2_out == k], 0.4, 0.6, color=k_type_colors[k])

        a.set_title('Stellar Type')

        a.set_xlim(np.min(times), np.max(times))



    # Add legend
    ax_k_type_list.axis('off')
    k_type_all = np.unique(np.array([k1_out, k2_out]))
    patches = [ mpatches.Patch(color=k_type_colors[k], label=k_type[k]) for k in k_type_all ]
    leg = ax_k_type_list.legend(handles=patches, mode='expand', ncol=len(k_type_all))
    leg.get_frame().set_alpha(0.0)



def plot_radius(ax, times, R1_out, R2_out, M1_out, M2_out, P_orb_out, ecc_out, sys_obs):

    # Radius
    ax.plot(times, R1_out, color=C0)
    ax.plot(times, R2_out, color=C1)

    # Roche radii - at periastron

    A_out = P_to_A(M1_out, M2_out, P_orb_out)