# Path: DiscEvolution/disc_utils.py
# def make_ASCII_header(HDF5_attributes):
#     """Generates header in ASCII format from the HDF5 format."""
#     # Class name
#     head = "# {}".format(HDF5_attributes[0])
# 
#     # Add dictionary of attributes
#     def make_item(item):
#         key, value = item
#         return "{}: {}".format(key, value)
# 
#     return head + ", ".join(map(make_item, HDF5_attributes[1].items()))


import numpy as np
    import matplotlib.pyplot as plt
from scipy.interpolate import InterpolatedUnivariateSpline as ispline
from scipy.interpolate import UnivariateSpline as spline
from scipy.integrate import ode
from .constants import *
from .disc_utils import make_ASCII_header
    from .eos import LocallyIsothermalEOS, IrradiatedEOS
    from .star import SimpleStar
    from .grid import Grid
    from .dust import FixedSizeDust
           f_max : maximum accretion rate relative to disc accretion rate,
                   default=0.8

        Piso & Youdin parameters:
           f_py      : accretion rate fitting factor, default=0.2
           kappa_env : envelope opacity [cm^2/g], default=0.06
           rho_core  : core density [g cm^-3], default=5.5
    """
    def __init__(self, disc, f_max=0.8,
                 f_py=0.2, kappa_env=0.05, rho_core=5.5):

        # General properties
        self._fmax = f_max
        self._disc = disc

        # Piso & Youdin parameters
        self._fPiso = 0.1 * 1.75e-3 / f_py**2
        self._fPiso /= kappa_env * (rho_core/5.5)**(1/6.)
        # Convert Mearth / M_yr to M_E Omega0**-1
        self._fPiso *= 1e-6 / (2*np.pi)

        head = {"f_max"     : "{}".format(f_max),
                "f_py"      : "{}".format(f_py),
                "kappa_env" : "{} cm^2 g^-1".format(kappa_env),
                "rho_core"  : "{} g cm^-1".format(rho_core),
                }
        self._head = (self.__class__.__name__, head)

    def ASCII_header(self):
        """Get header details"""

# Path: DiscEvolution/disc_utils.py
# def make_ASCII_header(HDF5_attributes):
#     """Generates header in ASCII format from the HDF5 format."""
#     # Class name
#     head = "# {}".format(HDF5_attributes[0])
# 
#     # Add dictionary of attributes
#     def make_item(item):
#         key, value = item
#         return "{}: {}".format(key, value)
# 
#     return head + ", ".join(map(make_item, HDF5_attributes[1].items()))


# Path: DiscEvolution/planet_formation.py
import numpy as np
    import matplotlib.pyplot as plt
from scipy.interpolate import InterpolatedUnivariateSpline as ispline
from scipy.interpolate import UnivariateSpline as spline
from scipy.integrate import ode
from .constants import *
from .disc_utils import make_ASCII_header
    from .eos import LocallyIsothermalEOS, IrradiatedEOS
    from .star import SimpleStar
    from .grid import Grid
    from .dust import FixedSizeDust

           f_max : maximum accretion rate relative to disc accretion rate,
                   default=0.8

        Piso & Youdin parameters:
           f_py      : accretion rate fitting factor, default=0.2
           kappa_env : envelope opacity [cm^2/g], default=0.06
           rho_core  : core density [g cm^-3], default=5.5
    """
    def __init__(self, disc, f_max=0.8,
                 f_py=0.2, kappa_env=0.05, rho_core=5.5):

        # General properties
        self._fmax = f_max
        self._disc = disc

        # Piso & Youdin parameters
        self._fPiso = 0.1 * 1.75e-3 / f_py**2
        self._fPiso /= kappa_env * (rho_core/5.5)**(1/6.)
        # Convert Mearth / M_yr to M_E Omega0**-1
        self._fPiso *= 1e-6 / (2*np.pi)

        head = {"f_max"     : "{}".format(f_max),
                "f_py"      : "{}".format(f_py),
                "kappa_env" : "{} cm^2 g^-1".format(kappa_env),
                "rho_core"  : "{} g cm^-1".format(rho_core),
                }
        self._head = (self.__class__.__name__, head)

    def ASCII_header(self):
        """Get header details"""

        return make_ASCII_header(self.HDF5_attributes())