# OpticalTool4mass2absorptionBrC

## Getting Started

**OpticalTool4mass2absorptionBrC** is a tool designed to calculate optical parameters for aerosols. It is based on the work of @Vincenzo Obiso. Currently, this tool computes the following parameters:

- **Absorption coefficient**
- **Total absorption (AAOD)**

## Files Description

### `physics.py`
This script defines aerosol properties, including:
- **Geometric radius**
- **Density**
- **Real and imaginary refractive index**
- **Relative humidity considerations for hydrophobic and hydrophilic species**

### `physics_aerosol_optical_properties.py`
This script handles the optical calculations of aerosols. At this stage, model concentrations are not required. The output is a dictionary containing:
- `qext`: Extinction efficiency (unitless)
- `qsca`: Scattering efficiency (unitless)
- `asym`: Asymmetry factor (unitless)
- `dens`: Mass density (dry species) [g/cm³]
- `reff`: Effective radius (wet species) [µm]
- `vphi`: Wet-to-dry volume ratio (unitless)

### `aerosol_optical_functions.py`
This script defines functions to compute:
- **AAOD (Absorption Aerosol Optical Depth)** for different aerosol types
- **Absorption coefficient**
- **AOD (Aerosol Optical Depth)** for various aerosols

### `calculate_optical_properties.py`
This script handles the calculation of:
- **Absorption coefficient** using the function `calculate_absorption_coefficient`
- **Total absorption by layer** using the function `calculate_aaod_by_layer`

### `extract_layer_data_by_number.py`
This script processes the necessary data for `calculate_optical_properties.py`, handling the dataframes and preparing them for use.

## Usage

To use this tool, you need the following:
- **Relative humidity (RH)** in percentage (%)
- **Layer thickness** in meters (m) (only required for AAOD calculation)
- **Aerosol concentrations** in micrograms per cubic meter (µg/m³), provided in a dataframe for each layer (e.g., `layer_1`, `layer_2`, ...)
- **Time resolution** Specify the desired calculation interval—Hourly (H), Daily (D), or Monthly (M). 

### Calculating Total Absorption (AAOD)
```python
from src.calculate_optical_properties import calculate_aaod_by_layer

absorption_results = calculate_aaod_by_layer(
    relative_humidity, layer_thickness, model_conc, layers, wavelength_nm, aerosol_name, time_resolution
)
```

When the aerosol name is `BRC`, `POABRC`, or `SOABRC`, the refractive imaginary index should be passed as `ri_brc`, `ri_brc_strong`, or `ri_brc_bleached`, respectively:

```python
absorption_results = calculate_aaod_by_layer(
    relative_humidity, layer_thickness, model_conc, layers, wavelength_nm, 'BRC', time_resolution, ri_brc
)
```
- `wavelength_nm` should be specified in nanometers (nm).
- `model_conc` should be in µg/m³.

### Calculating Absorption Coefficient
The target layer is the layer where the absorption coefficient will be computed. If the model results contain more than one layer, this is typically the surface layer.

```python
from src.calculate_optical_properties import calculate_absorption_coefficient

absorption_coeff = calculate_absorption_coefficient(
    relative_humidity, model_conc, target_layer, wavelength_nm, aerosol_name, time_resolution
)
```

When the aerosol name is `BRC`, `POABRC`, or `SOABRC`, the refractive imaginary index should be passed as `ri_brc`, `ri_brc_strong`, or `ri_brc_bleached`, respectively. Moreover, for this function, layer thickness is not required.

```python
absorption_coeff = calculate_absorption_coefficient(
    relative_humidity, model_conc, target_layer, wavelength_nm, aerosol_name, time_resolution
)
```

## Notes
- Ensure all input values are correctly formatted and that units are consistent.
- The tool supports various aerosol types.

