# astro-jingtao/bhmie-py architecture

> Architecture diagram of the GitHub repository astro-jingtao/bhmie-py, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/astro-jingtao/bhmie-py
- Repository: https://github.com/astro-jingtao/bhmie-py

## Overview

bhmiepy is a Python interface to classic BHMIE Mie-scattering, with a vectorized single-sphere API and a dust-population averaging pipeline. Users call the package API; single-sphere requests reach the compiled Fortran routine, while dust requests interpolate material data, prepare size distributions, evaluate sphere scattering across size bins, and aggregate population properties. The dust module also parses upstream parameter files. Some Fortran implementation details were not excerpted, so the binding-to-core link is shown as unverified.

Main entry points: [`src/bhmiepy/dust.py`](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/dust.py) (Dust Computation), [`src/bhmiepy/mie.py`](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/mie.py) (Sphere API), [`src/bhmiepy/__init__.py`](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/__init__.py) (Public API), [`src/bhmiepy/_fortran/bhmiepy_ext.f90`](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/_fortran/bhmiepy_ext.f90) (Extension Binding)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Python API"]
  node_public_api["Public API<br/>[__init__.py]"]
end

subgraph group_sphere["Sphere Scattering"]
  node_sphere_api["Sphere API<br/>[mie.py]"]
  node_mie_core["BHMIE Routine<br/>[bhmie.f90]"]
  node_f2py_binding["Extension Binding<br/>[bhmiepy_ext.f90]"]
end

subgraph group_dust["Dust Populations"]
  node_dust_compute["Dust Computation<br/>[dust.py]"]
  node_materials["Material Interpolation<br/>[dust.py]"]
  node_distributions["Size Distributions<br/>[dust.py]"]
  node_parameter_reader["Parameter Reader<br/>[dust.py]"]
  node_dust_results["Dust Properties<br/>[dust.py]"]
end

subgraph group_numerics["Numerical Support"]
  node_loglog["Log-Log Math<br/>[_loglog.py]"]
end

node_user(("Python User"))

node_user -->|"calls"| node_public_api
node_public_api -->|"exposes"| node_sphere_api
node_public_api -->|"exposes"| node_dust_compute
node_sphere_api -->|"calls"| node_f2py_binding
node_f2py_binding -.->|"dispatches"| node_mie_core
node_user -->|"requests"| node_sphere_api
node_dust_compute -->|"interpolates"| node_materials
node_dust_compute -->|"normalizes"| node_distributions
node_dust_compute -->|"uses scattering"| node_sphere_api
node_materials -->|"interpolates with"| node_loglog
node_distributions -->|"integrates with"| node_loglog
node_dust_compute -->|"produces"| node_dust_results
node_user -->|"provides file"| node_parameter_reader
node_parameter_reader -->|"supplies inputs"| node_dust_compute

click node_public_api "https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/__init__.py"
click node_sphere_api "https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/mie.py"
click node_mie_core "https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/_fortran/bhmie.f90"
click node_f2py_binding "https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/_fortran/bhmiepy_ext.f90"
click node_dust_compute "https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/dust.py"
click node_materials "https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/dust.py"
click node_distributions "https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/dust.py"
click node_parameter_reader "https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/dust.py"
click node_dust_results "https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/dust.py"
click node_loglog "https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/_loglog.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api,node_user toneBlue
class node_sphere_api,node_mie_core,node_f2py_binding toneAmber
class node_dust_compute,node_materials,node_distributions,node_parameter_reader,node_dust_results toneMint
class node_loglog toneRose
```

## Components

### Python API

- [Public API](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/__init__.py): `src/bhmiepy/__init__.py`

### Sphere Scattering

- [Sphere API](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/mie.py): `src/bhmiepy/mie.py`
- [BHMIE Routine](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/_fortran/bhmie.f90): `src/bhmiepy/_fortran/bhmie.f90`
- [Extension Binding](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/_fortran/bhmiepy_ext.f90): `src/bhmiepy/_fortran/bhmiepy_ext.f90`

### Dust Populations

- [Dust Computation](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/dust.py): `src/bhmiepy/dust.py`
- [Material Interpolation](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/dust.py): `src/bhmiepy/dust.py`
- [Size Distributions](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/dust.py): `src/bhmiepy/dust.py`
- [Parameter Reader](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/dust.py): `src/bhmiepy/dust.py`
- [Dust Properties](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/dust.py): `src/bhmiepy/dust.py`

### Numerical Support

- [Log-Log Math](https://github.com/astro-jingtao/bhmie-py/blob/main/src/bhmiepy/_loglog.py): `src/bhmiepy/_loglog.py`

### Other components

- **Python User**

## Connections

- Python User → Public API: calls (evidence: `README.md`)
- Public API → Sphere API: exposes (evidence: `src/bhmiepy/__init__.py`)
- Public API → Dust Computation: exposes (evidence: `src/bhmiepy/__init__.py`)
- Sphere API → Extension Binding: calls (evidence: `src/bhmiepy/mie.py`)
- Extension Binding → BHMIE Routine: dispatches
- Python User → Sphere API: requests (evidence: `README.md`)
- Dust Computation → Material Interpolation: interpolates (evidence: `src/bhmiepy/dust.py`)
- Dust Computation → Size Distributions: normalizes (evidence: `src/bhmiepy/dust.py`)
- Dust Computation → Sphere API: uses scattering (evidence: `README.md`)
- Material Interpolation → Log-Log Math: interpolates with (evidence: `src/bhmiepy/dust.py`)
- Size Distributions → Log-Log Math: integrates with (evidence: `src/bhmiepy/dust.py`)
- Dust Computation → Dust Properties: produces (evidence: `src/bhmiepy/dust.py`)
- Python User → Parameter Reader: provides file (evidence: `README.md`)
- Parameter Reader → Dust Computation: supplies inputs (evidence: `README.md`)
