
import pandas as pd 

def total_absorption_in_layer(model_conc, optical_parameters, thickness_layer, aerosol):
    """
    Calculate Absorption of BrC aerosol layer

    Parameters:
    model_conc (float): Concentration of aerosol layer [ug/m3]
    optical_parameters (dict): Optical parameters of BrC aerosol layer 
    thickness_layer (float): Thickness of aerosol layer [m]

    Returns:
    float: 
    """
    model_conc = model_conc[0]*1e-6 #convert to g/m3

    total_absorption = ((3.0* (optical_parameters[aerosol]['qext'] - optical_parameters[aerosol]['qsca']) * optical_parameters[aerosol]['vphi']) / 
                (4.0 * optical_parameters[aerosol]['dens'] * optical_parameters[aerosol]['reff'])) * model_conc * thickness_layer

    return total_absorption

def abs_coeff(model_conc, optical_parameters, aerosol):
    """
    Calculate Absorption Coefficient of BrC aerosol layer

    Parameters:
    model_conc (float): Concentration of aerosol layer [ug/m3]
    optical_parameters (dict): Optical parameters of BrC aerosol layer 

    Returns:
    float: absorption coefficient in [Mm^-1]
    """
    model_conc = model_conc[0]*1e-6 #convert to [g/m3]

    abs_coeff = ((3.0* (optical_parameters[aerosol]['qext'] - optical_parameters[aerosol]['qsca']) * optical_parameters[aerosol]['vphi']) / 
                (4.0 * optical_parameters[aerosol]['dens'] * optical_parameters[aerosol]['reff'])) * model_conc

    return abs_coeff*1e6 #convert to Mm^-1


def aod(model_conc, optical_parameters, aerosol, thickness_layer):
    """
    Calculate Aerosol Optical Depth of BrC aerosol layer

    Parameters:
    model_conc (float): Concentration of aerosol layer [ug/m3]
    optical_parameters (dict): Optical parameters of BrC aerosol layer 
    thickness_layer (float): Thickness of aerosol layer [m]

    Returns:
    float: Aerosol Optical Depth
    """
    model_conc = model_conc[0]*1e-6 #convert to [g/m3]

    aod = ((3.0* (optical_parameters[aerosol]['qext'] * optical_parameters[aerosol]['vphi']) / 
                (4.0 * optical_parameters[aerosol]['dens'] * optical_parameters[aerosol]['reff'])) * model_conc * thickness_layer)

    return aod
